pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/sysutils/user_darwin Update the user_darwin scripts to...
details: https://anonhg.NetBSD.org/pkgsrc/rev/931a424617e9
branches: trunk
changeset: 534665:931a424617e9
user: rh <rh%pkgsrc.org@localhost>
date: Mon Oct 29 08:12:55 2007 +0000
description:
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:
sysutils/user_darwin/Makefile | 4 +-
sysutils/user_darwin/files/groupadd.sh | 25 ++++++++++++++++++-----
sysutils/user_darwin/files/groupdel.sh | 3 +-
sysutils/user_darwin/files/useradd.sh | 35 ++++++++++++++++++++++++++-------
sysutils/user_darwin/files/userdel.sh | 3 +-
5 files changed, 52 insertions(+), 18 deletions(-)
diffs (164 lines):
diff -r ee57d024a443 -r 931a424617e9 sysutils/user_darwin/Makefile
--- a/sysutils/user_darwin/Makefile Mon Oct 29 04:57:17 2007 +0000
+++ b/sysutils/user_darwin/Makefile Mon Oct 29 08:12:55 2007 +0000
@@ -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 -r ee57d024a443 -r 931a424617e9 sysutils/user_darwin/files/groupadd.sh
--- a/sysutils/user_darwin/files/groupadd.sh Mon Oct 29 04:57:17 2007 +0000
+++ b/sysutils/user_darwin/files/groupadd.sh Mon Oct 29 08:12:55 2007 +0000
@@ -14,7 +14,9 @@
{
# 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 @@
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 @@
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 -r ee57d024a443 -r 931a424617e9 sysutils/user_darwin/files/groupdel.sh
--- a/sysutils/user_darwin/files/groupdel.sh Mon Oct 29 04:57:17 2007 +0000
+++ b/sysutils/user_darwin/files/groupdel.sh Mon Oct 29 08:12:55 2007 +0000
@@ -13,7 +13,8 @@
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 -r ee57d024a443 -r 931a424617e9 sysutils/user_darwin/files/useradd.sh
--- a/sysutils/user_darwin/files/useradd.sh Mon Oct 29 04:57:17 2007 +0000
+++ b/sysutils/user_darwin/files/useradd.sh Mon Oct 29 08:12:55 2007 +0000
@@ -24,7 +24,8 @@
# * 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 @@
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 @@
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 @@
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 -r ee57d024a443 -r 931a424617e9 sysutils/user_darwin/files/userdel.sh
--- a/sysutils/user_darwin/files/userdel.sh Mon Oct 29 04:57:17 2007 +0000
+++ b/sysutils/user_darwin/files/userdel.sh Mon Oct 29 08:12:55 2007 +0000
@@ -13,7 +13,8 @@
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
Home |
Main Index |
Thread Index |
Old Index