bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH] test-userspec: don't lookup numeric user names


From: Jim Meyering
Subject: [PATCH] test-userspec: don't lookup numeric user names
Date: Fri, 18 Jul 2014 14:42:17 -0700

From: Jim Meyering <address@hidden>

* tests/test-userspec.c: I found a system for which getpwnam("0")
returned a pointer to a non-root user's entry, and that made the
test fail.
(T): Prefix each numeric input with "+", to inhibit lookup.
---
 ChangeLog             |  8 ++++++++
 tests/test-userspec.c | 38 +++++++++++++++++++-------------------
 2 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 94e5b84..b3e3c8d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2014-07-18  Jim Meyering  <address@hidden>
+
+       test-userspec: don't lookup numeric user names
+       * tests/test-userspec.c: I found a system for which getpwnam("0")
+       returned a pointer to a non-root user's entry, and that made the
+       test fail.
+       (T): Prefix each numeric input with "+", to inhibit lookup.
+
 2014-07-15  Eli Zaretskii  <address@hidden>

        localcharset, localename: MS-Windows support for non-default locales
diff --git a/tests/test-userspec.c b/tests/test-userspec.c
index 437049c..528107d 100644
--- a/tests/test-userspec.c
+++ b/tests/test-userspec.c
@@ -45,30 +45,30 @@ struct test

 static struct test T[] =
   {
-    { "",                      -1, -1, "",   "",   NULL},
-    { ":",                     -1, -1, "",   "",   NULL},
-    { "0:0",                    0,  0, "",   "",   NULL},
-    { ":1",                    -1,  1, "",   "",   NULL},
-    { "1",                      1, -1, "",   "",   NULL},
-    { ":+0",                   -1,  0, "",   "",   NULL},
-    { "22:42",                 22, 42, "",   "",   NULL},
+    { "",                       -1, -1, "",   "",   NULL},
+    { ":",                      -1, -1, "",   "",   NULL},
+    { "+0:+0",                   0,  0, "",   "",   NULL},
+    { ":+1",                    -1,  1, "",   "",   NULL},
+    { "+1",                      1, -1, "",   "",   NULL},
+    { ":+0",                    -1,  0, "",   "",   NULL},
+    { "+22:+42",                22, 42, "",   "",   NULL},
     /* (uint32_t)-1 should be invalid everywhere */
-    { "4294967295:4294967295",  0,  0, NULL, NULL, "invalid user"},
+    { "+4294967295:+4294967295", 0,  0, NULL, NULL, "invalid user"},
     /* likewise, but with only the group being invalid */
-    { "0:4294967295",           0,  0, NULL, NULL, "invalid group"},
-    { ":4294967295",            0,  0, NULL, NULL, "invalid group"},
+    { "+0:+4294967295",          0,  0, NULL, NULL, "invalid group"},
+    { ":+4294967295",            0,  0, NULL, NULL, "invalid group"},
     /* and only the user being invalid */
-    { "4294967295:0",           0,  0, NULL, NULL, "invalid user"},
+    { "+4294967295:+0",          0,  0, NULL, NULL, "invalid user"},
     /* and using 2^32 */
-    { "4294967296:4294967296",  0,  0, NULL, NULL, "invalid user"},
-    { "0:4294967296",           0,  0, NULL, NULL, "invalid group"},
-    { ":4294967296",            0,  0, NULL, NULL, "invalid group"},
-    { "4294967296:0",           0,  0, NULL, NULL, "invalid user"},
+    { "+4294967296:+4294967296", 0,  0, NULL, NULL, "invalid user"},
+    { "+0:+4294967296",          0,  0, NULL, NULL, "invalid group"},
+    { ":+4294967296",            0,  0, NULL, NULL, "invalid group"},
+    { "+4294967296:+0",          0,  0, NULL, NULL, "invalid user"},
     /* numeric user and no group is invalid */
-    { "4294967295:",            0,  0, NULL, NULL, "invalid spec"},
-    { "4294967296:",            0,  0, NULL, NULL, "invalid spec"},
-    { "1:",                     0,  0, NULL, NULL, "invalid spec"},
-    { "+0:",                    0,  0, NULL, NULL, "invalid spec"},
+    { "+4294967295:",            0,  0, NULL, NULL, "invalid spec"},
+    { "+4294967296:",            0,  0, NULL, NULL, "invalid spec"},
+    { "+1:",                     0,  0, NULL, NULL, "invalid spec"},
+    { "+0:",                     0,  0, NULL, NULL, "invalid spec"},

     /* "username:" must expand to UID:GID where GID is username's login group 
*/
     /* Add an entry like the following to the table, if possible.
-- 
2.0.0.421.g786a89d




reply via email to

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