2 # Exercise "id --zero".
4 # Copyright (C) 2013-2015 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
26 # id(1) should refuse --zero in default format.
27 echo 'id: option --zero not permitted in default format' > err-exp \
29 id
--zero > out
2>err
&& fail
=1
30 compare
/dev
/null out || fail
=1
31 compare err-exp err || fail
=1
33 # Create a nice list of users.
34 # Add $USER to ensure we have at least one explicit entry.
36 # Add a few typical users to test single group and multiple groups.
37 for u
in root man postfix sshd nobody
; do
38 id
$u >/dev
/null
2>&1 && users
="$users $u"
40 # Add $users and '' (implicit $USER) to list to process.
41 printf '%s\n' $users '' >> users || framework_failure_
43 # Exercise "id -z" with various options.
44 printf '\n' > exp || framework_failure_
45 > out || framework_failure_
48 for o
in g gr G Gr u ur
; do
50 printf '%s: ' "id -${o}${n}[z] $u" >> exp || framework_failure_
51 printf '\n%s: ' "id -${o}${n}[z] $u" >> out || framework_failure_
52 # There may be no name corresponding to an id, so don't check
53 # exit status when in name lookup mode
54 id
-${o}${n} $u >> exp ||
55 { test $?
-ne 1 ||
test -z "$n" && fail
=1; }
56 id
-${o}${n}z
$u > tmp ||
57 { test $?
-ne 1 ||
test -z "$n" && fail
=1; }
58 head -c-1 < tmp
>> out || framework_failure_
62 printf '\n' >> out || framework_failure_
63 tr '\0' ' ' < out
> out2 || framework_failure_
64 compare exp out2 || fail
=1