From dfa837f9324a23dbf52f445cb0aab4e381f7e296 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 2 Jan 2010 18:40:29 +0000 Subject: [PATCH] check NSS LDAP --- lam/lib/lamdaemon.pl | 26 ++++++++++++++++++++++++-- lam/templates/tests/lamdaemonTest.php | 3 +++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lam/lib/lamdaemon.pl b/lam/lib/lamdaemon.pl index 230e42c9..9f7fd7b1 100755 --- a/lam/lib/lamdaemon.pl +++ b/lam/lib/lamdaemon.pl @@ -140,12 +140,34 @@ while (1) { sub runTest { # basic test if ($vals[2] eq 'basic') { - $return = "Ok"; + $return = "INFO,Basic test ok"; } # quota test elsif ($vals[2] eq 'quota') { require Quota; - $return = "Ok"; + $return = "INFO,Quota test ok"; + } + # NSS LDAP + elsif ($vals[2] eq 'nss') { + $userName = $vals[3]; + # check if the user exists in /etc/passwd + system("grep", "-q", "^" . $userName . ":", "/etc/passwd"); + if ( $? == 0 ) { + $error = "User $userName is a local user (/etc/passwd) but should be LDAP only."; + $return = "ERROR,$error"; + logMessage(LOG_ERR, $error); + } + else { + # check if home directory is readable + @user = getpwnam($userName); + if ($user[7] eq '') { + $return = "ERROR,Unable to determine home directory of user $userName. Please check that NSS LDAP is correctly configured."; + logMessage(LOG_ERR, "Unable to determine home directory of user $userName. Please check that NSS LDAP is correctly configured."); + } + else { + $return = "INFO,NSS test ok"; + } + } } } diff --git a/lam/templates/tests/lamdaemonTest.php b/lam/templates/tests/lamdaemonTest.php index e9f18fa8..f1deff6c 100644 --- a/lam/templates/tests/lamdaemonTest.php +++ b/lam/templates/tests/lamdaemonTest.php @@ -292,6 +292,9 @@ function lamRunLamdaemonTestSuite($serverName, $serverTitle, $testQuota) { flush(); $stopTest = lamTestLamdaemon("+" . $SPLIT_DELIMITER . "test" . $SPLIT_DELIMITER . "basic\n", $stopTest, $handle, _("Execute lamdaemon")); + $handle = lamTestConnectSSH($serverName); + @ssh2_auth_password($handle, $userName, $credentials[1]); + $stopTest = lamTestLamdaemon("+" . $SPLIT_DELIMITER . "test" . $SPLIT_DELIMITER . "nss" . $SPLIT_DELIMITER . "$userName\n", $stopTest, $handle, _("Lamdaemon: check NSS LDAP")); if ($testQuota) { $handle = lamTestConnectSSH($serverName); @ssh2_auth_password($handle, $userName, $credentials[1]);