2 # Test script for busybox id vs. coreutils id.
3 # Needs root privileges for some tests.
8 LIST
=`awk -F: '{ printf "%s\n", $1 }' /etc/passwd`
10 TEST_USER
="f583ca884c1d93458fb61ed137ff44f6"
12 echo "test 1: id [options] nousername"
14 for OPTIONS
in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
17 $BUSYBOX id
$OPTIONS >foo
2>/dev
/null
19 $ID $OPTIONS >bar
2>/dev
/null
21 if test "$RET1" != "$RET2"; then
22 echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
27 echo "test 2: id [options] username"
29 for OPTIONS
in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
33 if test "$i" = "$TEST_USER"; then
34 FLAG_USER_EXISTS
="yes"
36 $BUSYBOX id
$OPTIONS $i >foo
2>/dev
/null
38 $ID $OPTIONS $i >bar
2>/dev
/null
40 if test "$RET1" != "$RET2"; then
41 echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
47 if test $FLAG_USER_EXISTS = "yes"; then
48 echo "test 3,4,5,6,7,8,9,10,11,12 skipped because test user $TEST_USER already exists"
53 adduser
-s /bin
/true
-g "" -H -D "$TEST_USER" ||
exit 1
55 chown
$TEST_USER.
$TEST_USER $BUSYBOX
56 chmod u
+s
$BUSYBOX 2>&1 /dev
/null
57 chown
$TEST_USER.
$TEST_USER $ID
58 chmod u
+s
$ID 2>&1 /dev
/null
60 echo "test 3 setuid, existing user: id [options] no username"
62 for OPTIONS
in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
65 $BUSYBOX id
$OPTIONS >foo
2>/dev
/null
67 $ID $OPTIONS >bar
2>/dev
/null
69 if test "$RET1" != "$RET2"; then
70 echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
76 echo "test 4 setuid, existing user: id [options] username"
78 for OPTIONS
in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
82 $BUSYBOX id
$OPTIONS $i >foo
2>/dev
/null
84 $ID $OPTIONS $i >bar
2>/dev
/null
86 if test "$RET1" != "$RET2"; then
87 echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
93 chown
$TEST_USER.
$TEST_USER $BUSYBOX
94 chmod g
+s
$BUSYBOX 2>&1 /dev
/null
95 chown
$TEST_USER.
$TEST_USER $ID
96 chmod g
+s
$ID 2>&1 /dev
/null
98 echo "test 5 setgid, existing user: id [options] no username"
100 for OPTIONS
in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
103 $BUSYBOX id
$OPTIONS >foo
2>/dev
/null
105 $ID $OPTIONS >bar
2>/dev
/null
107 if test "$RET1" != "$RET2"; then
108 echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
114 echo "test 6 setgid, existing user: id [options] username"
116 for OPTIONS
in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
120 $BUSYBOX id
$OPTIONS $i >foo
2>/dev
/null
122 $ID $OPTIONS $i >bar
2>/dev
/null
124 if test "$RET1" != "$RET2"; then
125 echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
131 chown
$TEST_USER.
$TEST_USER $BUSYBOX
132 chmod u
+s
,g
+s
$BUSYBOX 2>&1 /dev
/null
133 chown
$TEST_USER.
$TEST_USER $ID
134 chmod u
+s
,g
+s
$ID 2>&1 /dev
/null
136 echo "test 7 setuid, setgid, existing user: id [options] no username"
138 for OPTIONS
in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
141 $BUSYBOX id
$OPTIONS >foo
2>/dev
/null
143 $ID $OPTIONS >bar
2>/dev
/null
145 if test "$RET1" != "$RET2"; then
146 echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
152 echo "test 8 setuid, setgid, existing user: id [options] username"
154 for OPTIONS
in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
158 $BUSYBOX id
$OPTIONS $i >foo
2>/dev
/null
160 $ID $OPTIONS $i >bar
2>/dev
/null
162 if test "$RET1" != "$RET2"; then
163 echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
169 deluser
$TEST_USER ||
exit 1
171 echo "test 9 setuid, setgid, not existing user: id [options] no username"
173 for OPTIONS
in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
176 $BUSYBOX id
$OPTIONS >foo
2>/dev
/null
178 $ID $OPTIONS >bar
2>/dev
/null
180 if test "$RET1" != "$RET2"; then
181 echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
186 echo "test 10 setuid, setgid, not existing user: id [options] username"
188 for OPTIONS
in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
192 $BUSYBOX id
$OPTIONS $i >foo
2>/dev
/null
194 $ID $OPTIONS $i >bar
2>/dev
/null
196 if test "$RET1" != "$RET2"; then
197 echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
203 chown .root
$BUSYBOX 2>&1 /dev
/null
204 chown .root
$ID 2>&1 /dev
/null
205 chmod g
+s
$BUSYBOX 2>&1 /dev
/null
206 chmod g
+s
$ID 2>&1 /dev
/null
208 echo "test 11 setgid, not existing group: id [options] no username"
210 for OPTIONS
in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
213 $BUSYBOX id
$OPTIONS >foo
2>/dev
/null
215 $ID $OPTIONS >bar
2>/dev
/null
217 if test "$RET1" != "$RET2"; then
218 echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
224 echo "test 12 setgid, not existing group: id [options] username"
226 for OPTIONS
in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
230 $BUSYBOX id
$OPTIONS $i >foo
2>/dev
/null
232 $ID $OPTIONS $i >bar
2>/dev
/null
234 if test "$RET1" != "$RET2"; then
235 echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
241 chown root.root
$BUSYBOX 2>&1 /dev
/null
242 chown root.root
$ID 2>&1 /dev
/null