Fix nobody group check and change default uid/gid for nobody.
This was failing unnecessarily on Ubuntu because Debian uses nogroup instead of nobody for an anonymous group.
Also change the default gid so that it's 65534, not 99. Standard copies of Unix (sans Redhat and Solaris apparently) use gid -> 65534 for nobody:
FreeBSD:
$ id nobody
uid=65534(nobody) gid=65534(nobody) groups=65534(nobody)
RHEL 4.6:
$ id nobody
uid=99(nobody) gid=99 groups=99
Solaris:
% id nobody
uid=60001(nobody) gid=60001(nobody)
Ubuntu:
uid=65534(nobody) gid=65534(nogroup) groups=65534(nogroup)
For grins, OSX Leopard just uses some whacky UINT32_MAX value for nobody XD...
$ id nobody
uid=4294967294(nobody) gid=4294967294(nobody) groups=4294967294(nobody)
Signed-off-by: Garrett Cooper <yanegomi@gmail.com>
diff --git a/IDcheck.sh b/IDcheck.sh
index 96e6d35..d453c91 100755
--- a/IDcheck.sh
+++ b/IDcheck.sh
@@ -53,7 +53,7 @@
echo -n "If any required user ids and/or groups are missing, would you like these created? [y/N]"
read ans
case "$ans" in
- Y*|y*) CREATE_ENTRIES=1 ;;
+ [Yy]*) CREATE_ENTRIES=1 ;;
*) CREATE_ENTRIES=0 ;;
esac
else
@@ -80,7 +80,7 @@
fe bin "$group"; NO_BIN_GRP=$?
fe daemon "$group"; NO_DAEMON_GRP=$?
-fe nobody "$group"; NO_NOBODY_GRP=$?
+fe nobody "$group" || fe nogroup "$group"; NO_NOBODY_GRP=$?
fe sys "$group"; NO_SYS_GRP=$?
fe users "$group"; NO_USERS_GRP=$?
@@ -89,16 +89,16 @@
debug_vals() {
echo "Missing the following group / user entries:"
-echo "Group file: $group"
-echo "Password file: $passwd"
-echo "nobody: $NO_NOBODY_ID"
-echo "bin: $NO_BIN_ID"
-echo "daemon: $NO_DAEMON_ID"
-echo "nobody grp: $NO_NOBODY_GRP"
-echo "bin grp: $NO_BIN_GRP"
-echo "daemon grp: $NO_DAEMON_GRP"
-echo "sys grp: $NO_SYS_GRP"
-echo "users grp: $NO_USERS_GRP"
+echo "Group file: $group"
+echo "Password file: $passwd"
+echo "nobody: $NO_NOBODY_ID"
+echo "bin: $NO_BIN_ID"
+echo "daemon: $NO_DAEMON_ID"
+echo "nobody[/nogroup] grp: $NO_NOBODY_GRP"
+echo "bin grp: $NO_BIN_GRP"
+echo "daemon grp: $NO_DAEMON_GRP"
+echo "sys grp: $NO_SYS_GRP"
+echo "users grp: $NO_USERS_GRP"
echo ""
}
@@ -130,7 +130,7 @@
fi
fi
}
-make_user_group nobody 99 $NO_NOBODY_ID $NO_NOBODY_GRP
+make_user_group nobody 65534 $NO_NOBODY_ID $NO_NOBODY_GRP
make_user_group bin 1 $NO_BIN_ID $NO_BIN_GRP
make_user_group daemon 2 $NO_DAEMON_ID $NO_DAEMON_GRP
@@ -149,7 +149,7 @@
MISSING_ENTRY=0
# For entries that exist in both $group and $passwd.
-for i in nobody bin daemon; do
+for i in bin daemon; do
for file in "$group" "$passwd"; do
if ! fe "$i" "$file"; then
MISSING_ENTRY=1
@@ -161,6 +161,13 @@
fi
done
+# nobody is a standard group on all distros, apart from debian based ones;
+# let's account for the fact that they use the nogroup group instead.
+if ! fe "nobody" "$passwd" || ! (fe "nogroup" "$group" || fe "nobody" "$group")
+then
+ MISSING_ENTRY=1
+fi
+
# For entries that only exist in $group.
for i in users sys; do
if ! fe "$i" "$group" ; then