File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,10 +11,11 @@ if which systemctl &>/dev/null && \
1111 grep -Ev ' ^(root|nobody)' /etc/passwd > " $passwd_file "
1212else
1313 case ` uname` in
14- # The first two lines of /etc/passwd on FreeBSD are not account entries
15- FreeBSD)
16- sed 1,2d /etc/passwd > $passwd_file
14+ # BSD passwd files may contain comments that are ignored by getpwent(3).
15+ Darwin| FreeBSD)
16+ grep -Ev ' ^(#|$) ' /etc/passwd > " $passwd_file "
1717 ;;
18+ # Fall back to the raw passwd file elsewhere.
1819 * )
1920 cp /etc/passwd " $passwd_file "
2021 ;;
@@ -33,10 +34,30 @@ function getField {
3334 echo $LINE | awk -F' :' ' {print $2}'
3435 ;;
3536 ' user_id' )
36- echo $LINE | awk -F' :' ' {print $3}'
37+ case ` uname` in
38+ FreeBSD)
39+ id -u " ` echo $LINE | awk -F' :' ' {print $1}' ` "
40+ ;;
41+ Darwin)
42+ id -u " ` echo $LINE | awk -F' :' ' {print $1}' ` "
43+ ;;
44+ * )
45+ echo $LINE | awk -F' :' ' {print $3}'
46+ ;;
47+ esac
3748 ;;
3849 ' group_id' )
39- echo $LINE | awk -F' :' ' {print $4}'
50+ case ` uname` in
51+ FreeBSD)
52+ id -g " ` echo $LINE | awk -F' :' ' {print $1}' ` "
53+ ;;
54+ Darwin)
55+ id -g " ` echo $LINE | awk -F' :' ' {print $1}' ` "
56+ ;;
57+ * )
58+ echo $LINE | awk -F' :' ' {print $4}'
59+ ;;
60+ esac
4061 ;;
4162 ' gcos' )
4263 echo $LINE | awk -F' :' ' {gsub(/&/,"&",$5); print $5}'
You can’t perform that action at this time.
0 commit comments