#!/usr/bin/perl -T

####
# Print the prompt
####

syswrite STDOUT, "login: ";

####
# Reads up to 30 bytes from the stdin
####

$c = sysread STDIN, $user, 30;

if ($c < 2 || $c > 30) {
	print STDERR "Bad username.  Goodbye.\n";
	exit 1;
}

if ($user =~ /\n/) {
	$user = $`;
}
else {
	print STDERR "Bad username.  Goodbye.\n";
	exit 1;
}

if ($user =~ /[^a-zA-Z]/) {
	print STDERR "Bad username.  Goodbye.\n";
	exit 1;
}

# Execute su, allowing root commands!
if ($user eq "admin") {
	exec "/bin/su", "-", $user, "-c", "ALLOW_ROOT";
}
else {
	exec "/bin/su", "-", $user;
}


