--- loncom/lond 2004/08/04 21:11:16 1.222
+++ loncom/lond 2004/08/06 10:27:53 1.224
@@ -2,7 +2,7 @@
# The LearningOnline Network
# lond "LON Daemon" Server (port "LOND" 5663)
#
-# $Id: lond,v 1.222 2004/08/04 21:11:16 foxr Exp $
+# $Id: lond,v 1.224 2004/08/06 10:27:53 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -57,7 +57,7 @@ my $DEBUG = 1; # Non zero to ena
my $status='';
my $lastlog='';
-my $VERSION='$Revision: 1.222 $'; #' stupid emacs
+my $VERSION='$Revision: 1.224 $'; #' stupid emacs
my $remoteVERSION;
my $currenthostid="default";
my $currentdomainid;
@@ -122,8 +122,10 @@ my @passwderrors = ("ok",
"lcpasswd Cannot set new passwd.",
"lcpasswd Username has invalid characters",
"lcpasswd Invalid characters in password",
- "11", "12",
- "lcpasswd Password mismatch");
+ "lcpasswd User already exists",
+ "lcpasswd Something went wrong with user addition.",
+ "lcpasswd Password mismatch",
+ "lcpasswd Error filename is invalid");
# The array below are lcuseradd error strings.:
@@ -192,8 +194,7 @@ sub LocalConnection {
."$clientdns ne $thisserver ");
close $Socket;
return undef;
- }
- else {
+ } else {
chomp($initcmd); # Get rid of \n in filename.
my ($init, $type, $name) = split(/:/, $initcmd);
Debug(" Init command: $init $type $name ");
@@ -324,8 +325,7 @@ sub InsecureConnection {
$answer =~s/\W//g;
if($challenge eq $answer) {
return 1;
- }
- else {
+ } else {
logthis("WARNING client did not respond to challenge");
&status("No challenge reqply");
return 0;
@@ -654,8 +654,7 @@ sub PushFile {
&logthis(' Pushfile: unable to install '
.$tablefile." $! ");
return "error:$!";
- }
- else {
+ } else {
&logthis(' Installed new '.$tablefile
."");
@@ -1501,8 +1500,7 @@ sub change_password_handler {
&Failure( $client, "auth_mode_error\n", $userinput);
}
- }
- else {
+ } else {
&Failure( $client, "non_authorized\n", $userinput);
}
@@ -1689,7 +1687,7 @@ sub process_request {
} else {
my $result=&make_passwd_file($uname, $umode,$npass,
$passfilename);
- print $client $result;
+ Reply($client, $result, $userinput);
}
} else {
Reply($client, "refused\n", $userinput);
@@ -2493,8 +2491,7 @@ sub process_request {
print $store2 "done\n";
close $store2;
print $client "ok\n";
- }
- else {
+ } else {
print $client "error: ".($!+0)
." IO::File->new Failed ".
"while attempting queryreply\n";
@@ -3692,8 +3689,7 @@ sub make_new_child {
$inittype = ""; # This forces insecure attempt.
&logthis(" Certificates not "
."installed -- trying insecure auth");
- }
- else { # SSL certificates are in place so
+ } else { # SSL certificates are in place so
} # Leave the inittype alone.
}
@@ -3927,8 +3923,7 @@ sub get_auth_type
}
return "$authtype:$availinfo";
- }
- else {
+ } else {
Debug("Returning nouser");
return "nouser";
}
@@ -4008,18 +4003,15 @@ sub validate_user {
$password);
if(!$k4error) {
$validated = 1;
- }
- else {
+ } else {
$validated = 0;
&logthis('krb4: '.$user.', '.$contentpwd.', '.
&Authen::Krb4::get_err_txt($Authen::Krb4::error));
}
- }
- else {
+ } else {
$validated = 0; # Password has a match with null.
}
- }
- elsif ($howpwd eq "krb5") { # User is in kerberos 5 auth. domain.
+ } elsif ($howpwd eq "krb5") { # User is in kerberos 5 auth. domain.
if(!($password =~ /$null/)) { # Null password not allowed.
my $krbclient = &Authen::Krb5::parse_name($user.'@'
.$contentpwd);
@@ -4032,18 +4024,15 @@ sub validate_user {
$password,
$credentials);
$validated = ($krbreturn == 1);
- }
- else {
+ } else {
$validated = 0;
}
- }
- elsif ($howpwd eq "localauth") {
+ } elsif ($howpwd eq "localauth") {
# Authenticate via installation specific authentcation method:
$validated = &localauth::localauth($user,
$password,
$contentpwd);
- }
- else { # Unrecognized auth is also bad.
+ } else { # Unrecognized auth is also bad.
$validated = 0;
}
} else {
@@ -4305,7 +4294,9 @@ sub make_passwd_file {
return "no_priv_account_error\n";
}
- my $execpath="$perlvar{'lonDaemons'}/"."lcuseradd";
+ my $execpath ="$perlvar{'lonDaemons'}/"."lcuseradd";
+
+ my $lc_error_file = $execdir."/tmp/lcuseradd".$$.".status";
{
&Debug("Executing external: ".$execpath);
&Debug("user = ".$uname.", Password =". $npass);
@@ -4313,17 +4304,27 @@ sub make_passwd_file {
print $se "$uname\n";
print $se "$npass\n";
print $se "$npass\n";
+ print $se "$lc_error_file\n"; # Status -> unique file.
}
- my $useraddok = $?;
+ my $error = IO::File->new("< $lc_error_file");
+ my $useraddok = <$error>;
+ $error->close;
+ unlink($lc_error_file);
+
+ chomp $useraddok;
+
if($useraddok > 0) {
- &logthis("Failed lcuseradd: ".&lcuseraddstrerror($useraddok));
+ my $error_text = &lcuseraddstrerror($useraddok);
+ &logthis("Failed lcuseradd: $error_text");
+ $result = "lcuseradd_failed:$error_text\n";
+ } else {
+ my $pf = IO::File->new(">$passfilename");
+ print $pf "unix:\n";
}
- my $pf = IO::File->new(">$passfilename");
- print $pf "unix:\n";
}
} elsif ($umode eq 'none') {
{
- my $pf = IO::File->new(">$passfilename");
+ my $pf = IO::File->new("> $passfilename");
print $pf "none:\n";
}
} else {