• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3[ -f testing.sh ] && . testing.sh
4
5#testing "name" "command" "result" "infile" "stdin"
6
7# Systems with SELinux will have security context cruft,
8# and BSDs call the root group "wheel" instead.
9CLEAN="sed 's/ context=.*//g' | sed 's/wheel/root/g'"
10
11testing "0" "id 0 | $CLEAN" "uid=0(root) gid=0(root) groups=0(root)\n" "" ""
12testing "root" "id root | $CLEAN" \
13  "uid=0(root) gid=0(root) groups=0(root)\n" "" ""
14testing "-G root" "id -G root" "0\n" "" ""
15testing "-nG root" "id -nG root | $CLEAN" "root\n" "" ""
16testing "-g root" "id -g root" "0\n" "" ""
17testing "-ng root" "id -ng root | $CLEAN" "root\n" "" ""
18testing "-u root" "id -u root" "0\n" "" ""
19testing "-nu root" "id -nu root" "root\n" "" ""
20testing "no-such-user" "id no-such-user 2>/dev/null ; echo \$?" "1\n" "" ""
21testing "2147483647" "id 2147483647 2>/dev/null ; echo \$?" "1\n" "" ""
22