-# We have to return the most basic form of id to be portable
-# group file is used for supplemental groups.
-if [ -f "${MOCKDIR}/is_member" ]; then
- echo "uid=${deb_uid}(\${1}) gid=6(${amanda_group})"
+# We can only use id with no flags to have consistent results. Solaris
+# /usr/bin/id does not provide any standard flags. Since /usr/xpg4/bin is
+# not part of a minimal install we can't depend on it. Any flags *at all*
+# should raise an error in the tests.
+# group file and /usr/bin/groups can be used (with some tweaks).
+for f in "\$@"; do
+ case \$f in
+ # -- is ok, surprisingly.
+ --) : ;;
+ -?*) echo "id: no options are portable! '\$f'"
+ # Solaris exits with 2, others with 1. ugh.
+ exit 2
+ ;;
+ *) : ;;
+ esac
+done
+
+# Use id_group to control primary group name.
+[ -f ${MOCKDIR}/id_group ] && group=\`cat ${MOCKDIR}/id_group\` || group=bar
+
+# Solaris, Linux and OSX differ in the exact format of the output from id,
+# so we provide sample output based on the contents of id_os. We don't
+# parse it, but its presence can't break things.
+test_os=\`cat ${MOCKDIR}/id_os\`
+case \${test_os} in
+ linux) sup_groups=" groups=999(\${group}),1000(foo)" ;;
+ solaris) sup_groups="" ;;
+ osx) sup_groups=" groups=999(\${group}), 1000(foo)" ;;
+esac
+
+if [ -f ${MOCKDIR}/id_exists ]; then
+ # Note: uid is set when the mock is created.
+ echo "uid=${deb_uid}(\${1}) gid=6(\${group})\${sup_groups}"