From 222d1272ae12d807ba02c195308509bcad84597a Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 18 Jul 2014 14:16:44 -0700 Subject: [PATCH] test-userspec: don't look up 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. --- ChangeLog | 8 ++++++++ tests/test-userspec.c | 38 +++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 94e5b84025..cd702dd548 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2014-07-18 Jim Meyering + + test-userspec: don't look up 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 localcharset, localename: MS-Windows support for non-default locales diff --git a/tests/test-userspec.c b/tests/test-userspec.c index 437049c473..528107da67 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.39.5