#!/usr/bin/perl
# EasyHost
# Built by CyberScript
# Website: http://www.cyberscript.net
# Email: rcampbell@cyberscript.net
# (C) Copyright 2001, All Rights Reserved.
#####################################################
# The following code may not be modified            #
# or redistributed by anyone other then CyberScript #
#####################################################

$pwd = ($0 =~ /^(.+)[\/\\]/)[0] || '.';
require ("$pwd/cs-lib.pl");

if (!$ENV{AUTHD_ACCOUNT} || !&user_exist($ENV{AUTHD_ACCOUNT})) {
	print "auth_ok:0\n";
	print "end\n";
	exit();
}

my %user = &user_display($ENV{AUTHD_ACCOUNT});

if (crypt($tokens{password},'as') ne $user{password} || $tokens{login_status} != 1) {
	print "auth_ok:-1\n";
	print "end\n";
} else {
	my @stat = stat("$tokens{root_dir}/$ENV{AUTHD_ACCOUNT}");
	my %package = ();

	foreach my $line (split(/\n/,&file_read("$tokens{data_dir}/packages/$user{package}"))) {
		my @line=split(/=/,$line,2);
		$package{"$line[0]"}=$line[1];
	}

	print "auth_ok:1\n";
	print "uid:$stat[4]\n";
	print "gid:$stat[5]\n";
	print "dir:$tokens{root_dir}/$ENV{AUTHD_ACCOUNT}\n";
	print "user_quota_size:$package{space_limit}\n";
	print "end\n";
}