lamdaemon can now check existence of homedirs

This commit is contained in:
Roland Gruber 2011-05-07 08:04:45 +00:00
parent d4e51d30f7
commit 4809cb04ff
2 changed files with 26 additions and 5 deletions

View File

@ -27,7 +27,7 @@ use Sys::Syslog;
# Defines the protocol version of the lamdaemon script. # Defines the protocol version of the lamdaemon script.
# This will only be changed when additional commands are added etc. # This will only be changed when additional commands are added etc.
my $LAMDAEMON_PROTOCOL_VERSION = 1; my $LAMDAEMON_PROTOCOL_VERSION = 2;
my $SPLIT_DELIMITER = "###x##y##x###"; my $SPLIT_DELIMITER = "###x##y##x###";
@ -193,6 +193,9 @@ sub manageHomedirs {
elsif ($vals[2] eq 'rem') { elsif ($vals[2] eq 'rem') {
removeHomedir(); removeHomedir();
} }
elsif ($vals[2] eq 'check') {
checkHomedir();
}
else { else {
# Show error if undefined command is used # Show error if undefined command is used
$return = "ERROR,Lamdaemon ($hostname),Unknown home command $vals[2]."; $return = "ERROR,Lamdaemon ($hostname),Unknown home command $vals[2].";
@ -207,7 +210,7 @@ sub createHomedir {
my $homedir = $vals[3]; my $homedir = $vals[3];
if ($homedir eq '') { if ($homedir eq '') {
$return = "ERROR,Lamdaemon ($hostname),No home directory specified."; $return = "ERROR,Lamdaemon ($hostname),No home directory specified.";
logMessage(LOG_ERR, "No home directory specified."); logMessage(LOG_ERR, "No home directory specified to create.");
return; return;
} }
my $path = $homedir; my $path = $homedir;
@ -241,8 +244,8 @@ sub createHomedir {
# #
sub removeHomedir { sub removeHomedir {
if ($vals[3] eq '') { if ($vals[3] eq '') {
$return = "ERROR,Lamdaemon ($hostname),Home directory path is empty."; $return = "ERROR,Lamdaemon ($hostname),No home directory specified to delete.";
logMessage(LOG_ERR, "Home directory path is empty."); logMessage(LOG_ERR, "No home directory specified to delete.");
return; return;
} }
($<, $>) = ($>, $<); # Get root previliges ($<, $>) = ($>, $<); # Get root previliges
@ -266,6 +269,24 @@ sub removeHomedir {
($<, $>) = ($>, $<); # Give up root previleges ($<, $>) = ($>, $<); # Give up root previleges
} }
#
# Checks if the homedirectory of the user already exists.
#
sub checkHomedir {
my $homedir = $vals[3];
if ($homedir eq '') {
$return = "ERROR,Lamdaemon ($hostname),No home directory specified to check.";
logMessage(LOG_ERR, "No home directory specified to check.");
return;
}
if (-d $homedir) {
$return = "ok";
}
else {
$return = "missing";
}
}
# #
# Handles all quota related commands # Handles all quota related commands
# #

View File

@ -169,7 +169,7 @@ function lamTestLamdaemon($command, $stopTest, $handle, $testText, $container) {
*/ */
function lamRunLamdaemonTestSuite($serverName, $serverTitle, $testQuota, $container) { function lamRunLamdaemonTestSuite($serverName, $serverTitle, $testQuota, $container) {
$SPLIT_DELIMITER = "###x##y##x###"; $SPLIT_DELIMITER = "###x##y##x###";
$LAMDAEMON_PROTOCOL_VERSION = '1'; $LAMDAEMON_PROTOCOL_VERSION = '2';
$okImage = "../../graphics/pass.png"; $okImage = "../../graphics/pass.png";
$failImage = "../../graphics/fail.png"; $failImage = "../../graphics/fail.png";