myserver-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9_2-61-g


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. 0_9_2-61-gc48f59e
Date: Mon, 01 Mar 2010 10:46:08 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU MyServer".

The branch, master has been updated
       via  c48f59eddcfe03fa31232bf611ad134cdfa0fb2d (commit)
      from  bb5cf6002034761e10707b923a85d487856ac4b2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------


commit c48f59eddcfe03fa31232bf611ad134cdfa0fb2d
Author: Giuseppe Scrivano <address@hidden>
Date:   Mon Mar 1 11:46:02 2010 +0100

    Handle the case `getpwnam' returns NULL and sets `errno' to zero.

diff --git a/myserver/src/base/home_dir/home_dir.cpp 
b/myserver/src/base/home_dir/home_dir.cpp
index 23db24a..b360b58 100644
--- a/myserver/src/base/home_dir/home_dir.cpp
+++ b/myserver/src/base/home_dir/home_dir.cpp
@@ -243,7 +243,7 @@ int HomeDir::getHomeDir (string& userName, string& out)
   int ret = 0;
 
   loadMutex.lock ();
-
+  errno = 0;
   p = ::getpwnam (userName.c_str ());
   if (p == NULL)
     ret = 1;
@@ -253,8 +253,8 @@ int HomeDir::getHomeDir (string& userName, string& out)
   loadMutex.unlock ();
 
   /* The user was not found.  */
-  if (p == NULL && (errno == ENOENT || errno == ESRCH || errno == EBADF
-                    || errno == EPERM))
+  if (p == NULL && (errno == 0 || errno == ENOENT || errno == ESRCH
+                    || errno == EBADF || errno == EPERM))
     return 1;
 
   return p ? 0 : -1;
diff --git a/myserver/tests/test_homedir.cpp b/myserver/tests/test_homedir.cpp
index ce8f295..3afb0d9 100644
--- a/myserver/tests/test_homedir.cpp
+++ b/myserver/tests/test_homedir.cpp
@@ -24,9 +24,10 @@
 
 class TestHomeDir : public CppUnit::TestFixture
 {
-  CPPUNIT_TEST_SUITE ( TestHomeDir );
-  CPPUNIT_TEST ( testLoadClear );
-  CPPUNIT_TEST ( testGetAdmin );
+  CPPUNIT_TEST_SUITE (TestHomeDir);
+  CPPUNIT_TEST (testLoadClear);
+  CPPUNIT_TEST (testGetAdmin);
+  CPPUNIT_TEST (testUserDoesNotExist);
   CPPUNIT_TEST_SUITE_END ();
   HomeDir *homeDir;
 public:
@@ -46,6 +47,17 @@ public:
     CPPUNIT_ASSERT (!homeDir->isLoaded ());
   }
 
+
+  void testUserDoesNotExist ()
+  {
+    homeDir->load ();
+    string username = "ShoUlDnTExist";
+    string dir;
+    int ret = homeDir->getHomeDir (username, dir);
+    CPPUNIT_ASSERT (ret > 0);
+    homeDir->clear ();
+  }
+
   void testGetAdmin ()
   {
     homeDir->load ();

-----------------------------------------------------------------------

Summary of changes:
 myserver/src/base/home_dir/home_dir.cpp |    6 +++---
 myserver/tests/test_homedir.cpp         |   18 +++++++++++++++---
 2 files changed, 18 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
GNU MyServer




reply via email to

[Prev in Thread] Current Thread [Next in Thread]