diff options
author | Pádraig Brady <P@draigBrady.com> | 2013-09-20 12:38:00 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2013-09-22 03:27:17 +0100 |
commit | 7415d8d9f823dae484d3791b425f184f1e3b4cad (patch) | |
tree | ca7c6b5124d25e355d8b210ac1d79ff2b6ffc414 /tests | |
parent | f9992690f40646f64d8bd0bfb55faed1980df0ad (diff) | |
download | coreutils-7415d8d9f823dae484d3791b425f184f1e3b4cad.tar.xz |
id: support specifying the user by user ID
* src/id.c (usage): Remove 'name' from the synopsis,
implying that one can also specify by user ID.
(main): Like chown(1), call parse_user_spec() to implement
user name or ID lookup with appropriate precedence.
* doc/coreutils.texi (id invocation): Mention that
a user ID is supported and how '+' affects lookup order.
* tests/misc/id-groups.sh: Remove test now subsumed into...
* tests/misc/id-uid.sh: New test covering new interface.
* tests/local.mk: Rename the test.
* NEWS: Mention the new feature.
Addresses http://bugs.gnu.org/15421
Diffstat (limited to 'tests')
-rw-r--r-- | tests/local.mk | 2 | ||||
-rwxr-xr-x | tests/misc/id-uid.sh (renamed from tests/misc/id-groups.sh) | 20 |
2 files changed, 18 insertions, 4 deletions
diff --git a/tests/local.mk b/tests/local.mk index 8f76b2371..1f3e82fe0 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -275,7 +275,7 @@ all_tests = \ tests/misc/head-c.sh \ tests/misc/head-pos.sh \ tests/misc/id-context.sh \ - tests/misc/id-groups.sh \ + tests/misc/id-uid.sh \ tests/misc/id-setgid.sh \ tests/misc/id-zero.sh \ tests/misc/md5sum.pl \ diff --git a/tests/misc/id-groups.sh b/tests/misc/id-uid.sh index ff3dc59fc..13f5663a6 100755 --- a/tests/misc/id-groups.sh +++ b/tests/misc/id-uid.sh @@ -1,6 +1,6 @@ #!/bin/sh -# Ensure that "id" outputs groups for a user -# Copyright (C) 2009-2013 Free Software Foundation, Inc. +# Ensure that "id" works with numeric user ids +# Copyright (C) 2013 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,6 +18,20 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ id -id -G $(id -nu) || fail=1 +uid=$(id -u) || fail=1 +user=$(id -nu) || fail=1 + +# Ensure the empty user spec is discarded +id '' && fail=1 + +for mode in '' '-G' '-g'; do + id $mode $user > user_out || fail=1 # lookup name for comparison + + id $mode $uid > uid_out || fail=1 # lookup name "$uid" before id "$uid" + compare user_out uid_out || fail=1 + + id $mode +$uid > uid_out || fail=1 # lookup only id "$uid" + compare user_out uid_out || fail=1 +done Exit $fail |