fixed homedir management and error handling
This commit is contained in:
parent
d4cdd87d0a
commit
10e3d9219b
|
@ -116,11 +116,16 @@ function lamdaemonSSH($commands) {
|
|||
$entry = ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
||||
$userName = $entry[0]['uid'][0];
|
||||
if (!$userName) return array();
|
||||
ssh2_auth_password($handle, $userName, $credentials[1]);
|
||||
if (@ssh2_auth_password($handle, $userName, $credentials[1])) {
|
||||
$shell = ssh2_exec($handle, "sudo " . $_SESSION['config']->scriptPath);
|
||||
fwrite($shell, $commands);
|
||||
$return = array();
|
||||
$time = time() + (sizeof($commands) * 30);
|
||||
while (sizeof($return) < sizeof($commands)) {
|
||||
if ($time < time()) {
|
||||
$return = array("ERROR," . _("Timeout while executing lamdaemon commands!") . ",");
|
||||
return $return;
|
||||
}
|
||||
usleep(100);
|
||||
$read = split("\n", trim(fread($shell, 100000)));
|
||||
if ((sizeof($read) == 1) && (!isset($read[0]) || ($read[0] == ""))) continue;
|
||||
|
@ -130,6 +135,11 @@ function lamdaemonSSH($commands) {
|
|||
}
|
||||
return $return;
|
||||
}
|
||||
else {
|
||||
$return = array("ERROR," . _('Unable to connect to remote server!') . "," . $_SESSION['config']->scriptServer);
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
|
|
|
@ -122,9 +122,10 @@ if ($< == 0 ) { # we are root
|
|||
if (-e '/usr/sbin/useradd.local') {
|
||||
system '/usr/sbin/useradd.local', $user[0]; # run useradd-script
|
||||
}
|
||||
$return = "Ok";
|
||||
}
|
||||
else {
|
||||
$return = "ERROR,Lamdaemon,Homedirectory already exists.:$return";
|
||||
$return = "ERROR,Lamdaemon,Home directory already exists.";
|
||||
}
|
||||
($<, $>) = ($>, $<); # Give up root previleges
|
||||
last switch2;
|
||||
|
@ -137,20 +138,21 @@ if ($< == 0 ) { # we are root
|
|||
if (-e '/usr/sbin/userdel.local') {
|
||||
system '/usr/sbin/userdel.local', $user[0];
|
||||
}
|
||||
$return = "Ok";
|
||||
}
|
||||
else {
|
||||
$return = "ERROR,Lamdaemon,Homedirectory not owned by $user[2].:$return";
|
||||
$return = "ERROR,Lamdaemon,Home directory not owned by $user[2].";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$return = "ERROR,Lamdaemon,Homedirectory doesn't exists.:$return";
|
||||
$return = "ERROR,Lamdaemon,Home directory does not exist.";
|
||||
}
|
||||
($<, $>) = ($>, $<); # Give up root previleges
|
||||
last switch2;
|
||||
};
|
||||
}
|
||||
# Show error if undfined command is used
|
||||
$return = "ERROR,Lamdaemon,Unknown command $vals[2].:$return";
|
||||
$return = "ERROR,Lamdaemon,Unknown command $vals[2].";
|
||||
}
|
||||
last switch;
|
||||
};
|
||||
$vals[1] eq 'quota' && do {
|
||||
|
@ -223,11 +225,11 @@ if ($< == 0 ) { # we are root
|
|||
($<, $>) = ($>, $<); # Give up root previleges
|
||||
last switch2;
|
||||
};
|
||||
$return = "ERROR,Lamdaemon,Unknown command $vals[2].:$return";
|
||||
$return = "ERROR,Lamdaemon,Unknown command $vals[2].";
|
||||
}
|
||||
};
|
||||
last switch;
|
||||
$return = "ERROR,Lamdaemon,Unknown command $vals[1].:$return";
|
||||
$return = "ERROR,Lamdaemon,Unknown command $vals[1].";
|
||||
};
|
||||
print "$return\n";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue