summaryrefslogtreecommitdiff
path: root/sysutils/user_darwin
diff options
context:
space:
mode:
authorrh <rh>2007-10-29 08:12:55 +0000
committerrh <rh>2007-10-29 08:12:55 +0000
commit2c531203a1a1962261fa1dc4f7d7c952b754e47d (patch)
tree18b3d8a20e4bdbad9654fc748edc4476b7db0754 /sysutils/user_darwin
parent3a8b6e8b2959bee99de969acebe058c12a81eb9a (diff)
downloadpkgsrc-2c531203a1a1962261fa1dc4f7d7c952b754e47d.tar.gz
Update the user_darwin scripts to 20071026. This adds compatibility with
Darwin 9.x / Mac OS X 10.5 (Leopard), which no longer uses netinfo.
Diffstat (limited to 'sysutils/user_darwin')
-rw-r--r--sysutils/user_darwin/Makefile4
-rwxr-xr-xsysutils/user_darwin/files/groupadd.sh25
-rwxr-xr-xsysutils/user_darwin/files/groupdel.sh3
-rwxr-xr-xsysutils/user_darwin/files/useradd.sh35
-rwxr-xr-xsysutils/user_darwin/files/userdel.sh3
5 files changed, 52 insertions, 18 deletions
diff --git a/sysutils/user_darwin/Makefile b/sysutils/user_darwin/Makefile
index 98286a2de92..6d1ee1015f4 100644
--- a/sysutils/user_darwin/Makefile
+++ b/sysutils/user_darwin/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.5 2005/12/05 20:51:01 rillig Exp $
+# $NetBSD: Makefile,v 1.6 2007/10/29 08:12:55 rh Exp $
#
-DISTNAME= user-20040801
+DISTNAME= user-20071026
CATEGORIES= sysutils
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/sysutils/user_darwin/files/groupadd.sh b/sysutils/user_darwin/files/groupadd.sh
index 5fd6ee8156f..ab9dcc6fb26 100755
--- a/sysutils/user_darwin/files/groupadd.sh
+++ b/sysutils/user_darwin/files/groupadd.sh
@@ -14,7 +14,9 @@ getnextgid()
{
# See the comments in useradd for more details.
- used_gids=`nireport . /groups gid`
+ used_gids=`nireport . /groups gid 2>/dev/null || \
+ dscl . -readall /groups PrimaryGroupID | grep '^PrimaryGroupID:' | \
+ cut -d' ' -f2`
low_gid=300
maybe_gid=$low_gid
@@ -34,13 +36,16 @@ if [ -z "$group" ]; then
exit 1
fi
-if nireport . /groups/$group gid 2>/dev/null; then
+if nireport . /groups/$group gid 2>/dev/null || \
+ dscl . -read /groups/$group gid >/dev/null 2>&1; then
echo "groupadd: Group '$group' already exists" 1>&2
exit 1
fi
if [ -n "$gid" ]; then
- if nireport . /groups/gid=$gid gid 2>/dev/null; then
+ if nireport . /groups/gid=$gid gid 2>/dev/null || \
+ dscl . -search /groups PrimaryGroupID $gid 2>/dev/null | \
+ grep PrimaryGroupID >/dev/null 2>&1 ; then
echo "groupadd: GID $gid already exists" 1>&2
exit 1
fi
@@ -48,8 +53,16 @@ else
gid=`getnextgid`
fi
-echo "${group}:*:${gid}:" | niload group .
-if ! nireport . /groups/$group gid 2>/dev/null; then
- echo "groupadd: Could not create group" 1>&2
+if [ -x /usr/bin/niload ] || which niload | grep -v -q '^no '; then
+ echo "${group}:*:${gid}:" | niload group .
+else
+ dscl . -create /groups/$group RecordName $group
+ dscl . -create /groups/$group RecordType dsRecTypeNative:groups
+ dscl . -create /groups/$group PrimaryGroupID $gid
+fi
+if ! nireport . /groups/$group gid 2>/dev/null && \
+ ! dscl . -search /groups PrimaryGroupID $gid 2>/dev/null | \
+ grep PrimaryGroupID >/dev/null 2>&1 ; then
+ echo "groupadd: Could not create group $gid: $group" 1>&2
exit 1
fi
diff --git a/sysutils/user_darwin/files/groupdel.sh b/sysutils/user_darwin/files/groupdel.sh
index 3f1a2ef984c..07e34ef5799 100755
--- a/sysutils/user_darwin/files/groupdel.sh
+++ b/sysutils/user_darwin/files/groupdel.sh
@@ -13,7 +13,8 @@ if [ -z "$group" ]; then
exit 1
fi
-if ! niutil -destroy . /groups/$group 2>/dev/null; then
+if ! niutil -destroy . /groups/$group 2>/dev/null && \
+ ! dscl . -delete /groups/$group >/dev/null 2>&1 ; then
echo "groupdel: Could not delete group" 1>&2
exit 1
fi
diff --git a/sysutils/user_darwin/files/useradd.sh b/sysutils/user_darwin/files/useradd.sh
index 23dfbf199d4..ef77d275777 100755
--- a/sysutils/user_darwin/files/useradd.sh
+++ b/sysutils/user_darwin/files/useradd.sh
@@ -24,7 +24,8 @@ getnextuid()
# * must be <400 (Fink uses 400 and up)
# * must be from a reasonably sized range
- used_uids=`nireport . /users uid`
+ used_uids=`nireport . /users uid 2>/dev/null || \
+ dscl . -readall /users UniqueID | grep '^UniqueID:' | cut -d' ' -f2`
low_uid=300; high_uid=399
# Try to use the GID as the UID.
@@ -53,7 +54,8 @@ if [ -z "$user" ]; then
echo "useradd: Must specify username" 1>&2
exit 1
fi
-if nireport . /users/$user uid 2>/dev/null; then
+if nireport . /users/$user uid 2>/dev/null || \
+ dscl . -read /users/$user uid >/dev/null 2>&1; then
echo "useradd: User '$user' already exists" 1>&2
exit 1
fi
@@ -62,14 +64,17 @@ if [ -z "$group" ]; then
echo "useradd: Must specify group name" 1>&2
exit 1
fi
-gid=`niutil -readprop . /groups/$group gid 2>/dev/null`
-if [ -z "$gid" ]; then
+gid=`niutil -readprop . /groups/$group gid 2>/dev/null || \
+ dscl . -read /groups/$group gid 2>/dev/null | cut -d' ' -f2`
+if [ -z "$gid" -o "$gid" = "Invalid" ]; then
echo "useradd: No group '$group'" 1>&2
exit 1
fi
if [ -n "$uid" ]; then
- if nireport . /users/uid=$uid uid 2>/dev/null; then
+ if nireport . /users/uid=$uid uid 2>/dev/null || \
+ dscl . -search /users UniqueID $uid 2>/dev/null | \
+ grep UniqueID >/dev/null 2>&1 ; then
echo "useradd: UID $uid already exists" 1>&2
exit 1
fi
@@ -80,10 +85,24 @@ else
fi
fi
-echo "${user}:*:${uid}:${gid}::0:0:${comment}:${homedir}:${shell}" | niload passwd .
-if ! nireport . /users/$user uid 2>/dev/null; then
+if [ -x /usr/bin/niload ] || which niload | grep -v -q '^no '; then
+ echo "${user}:*:${uid}:${gid}::0:0:${comment}:${homedir}:${shell}" | \
+ niload passwd .
+else
+ dscl . -create /users/$user RecordName $user
+ dscl . -create /users/$user RecordType dsRecTypeNative:users
+ dscl . -create /users/$user UniqueID $uid
+ dscl . -create /users/$user PrimaryGroupID $gid
+ dscl . -create /users/$user NFSHomeDirectory "$homedir"
+ dscl . -create /users/$user UserShell "$shell"
+ dscl . -create /users/$user Comment "$comment"
+fi
+
+if ! nireport . /users/uid=$uid uid 2>/dev/null && \
+ ! dscl . -search /users UniqueID $uid 2>/dev/null | \
+ grep UniqueID >/dev/null 2>&1 ; then
echo "useradd: Could not create user" 1>&2
exit 1
fi
-kill -HUP `cat /var/run/lookupd.pid`
+kill -HUP `cat /var/run/lookupd.pid 2>/dev/null` 2>/dev/null || true
diff --git a/sysutils/user_darwin/files/userdel.sh b/sysutils/user_darwin/files/userdel.sh
index 56087c3b6db..d5ce0c1be56 100755
--- a/sysutils/user_darwin/files/userdel.sh
+++ b/sysutils/user_darwin/files/userdel.sh
@@ -13,7 +13,8 @@ if [ -z "$user" ]; then
exit 1
fi
-if ! niutil -destroy . /users/$user 2>/dev/null; then
+if ! niutil -destroy . /users/$user 2>/dev/null && \
+ ! dscl . -delete /users/$user >/dev/null 2>&1 ; then
echo "userdel: Could not delete user" 1>&2
exit 1
fi