Import of pkgsrc-2013Q2

This commit is contained in:
2013-09-26 17:14:40 +02:00
commit 785076ae39
74991 changed files with 4380255 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
This implements a subset of useradd(8)/groupadd(8) functionality on
Darwin that is sufficient for pkgsrc use.

View File

@@ -0,0 +1,27 @@
# $NetBSD: Makefile,v 1.11 2012/10/23 19:51:28 asau Exp $
#
DISTNAME= user-20101223
CATEGORIES= sysutils
MASTER_SITES= # empty
DISTFILES= # empty
MAINTAINER= schmonz@NetBSD.org
COMMENT= Limited NetBSD-compatible useradd/groupadd commands
ONLY_FOR_PLATFORM= Darwin-*-*
PKG_INSTALLATION_TYPES= overwrite pkgviews
NO_CONFIGURE= yes
NO_BUILD= yes
INSTALLATION_DIRS= sbin
do-install:
${INSTALL_SCRIPT} ${FILESDIR}/useradd.sh ${DESTDIR}${PREFIX}/sbin/useradd
${INSTALL_SCRIPT} ${FILESDIR}/userdel.sh ${DESTDIR}${PREFIX}/sbin/userdel
${INSTALL_SCRIPT} ${FILESDIR}/groupadd.sh ${DESTDIR}${PREFIX}/sbin/groupadd
${INSTALL_SCRIPT} ${FILESDIR}/groupdel.sh ${DESTDIR}${PREFIX}/sbin/groupdel
.include "../../mk/bsd.pkg.mk"

View File

@@ -0,0 +1,5 @@
@comment $NetBSD: PLIST,v 1.1.1.1 2004/04/01 02:58:32 danw Exp $
sbin/groupadd
sbin/groupdel
sbin/useradd
sbin/userdel

View File

@@ -0,0 +1,68 @@
#!/bin/sh
PATH=/bin:/usr/bin:$PATH
while [ $# -gt 1 ]; do
case $1 in
-g) gid="$2" ;;
*) echo "groupadd: Unrecognized option $1" 1>&2; exit 1; ;;
esac
shift; shift
done
getnextgid()
{
# See the comments in useradd for more details.
used_gids=`nireport . /groups gid 2>/dev/null || \
dscl . -readall /groups PrimaryGroupID | grep '^PrimaryGroupID:' | \
cut -d' ' -f2`
low_gid=300
maybe_gid=$low_gid
while true; do
if echo $used_gids | grep -q $maybe_gid; then
maybe_gid=`expr $maybe_gid + 1`
else
echo $maybe_gid
return 0
fi
done
}
group="$1"
if [ -z "$group" ]; then
echo "groupadd: Must specify group name" 1>&2
exit 1
fi
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 || \
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
else
gid=`getnextgid`
fi
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

View File

@@ -0,0 +1,20 @@
#!/bin/sh
PATH=/bin:/usr/bin:$PATH
if [ $# -gt 1 ]; then
echo "groupdel: Unrecognized option $1" 1>&2
exit 1
fi
group="$1"
if [ -z "$group" ]; then
echo "groupdel: Must specify group" 1>&2
exit 1
fi
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

View File

@@ -0,0 +1,109 @@
#!/bin/sh
PATH=/bin:/usr/bin:$PATH
homedir="/var/empty"
shell="/usr/bin/false"
while [ $# -gt 1 ]; do
case $1 in
-c) comment="$2" ;;
-d) homedir="$2" ;;
-g) group="$2" ;;
-s) shell="$2" ;;
-u) uid="$2" ;;
*) echo "useradd: Unrecognized option $1" 1>&2; exit 1; ;;
esac
shift; shift
done
getnextuid()
{
# Find an unused UID. Constraints:
# * must be <500 (typical OS X user accounts are 500 and up)
# * must be <400 (Fink uses 400 and up)
# * must be from a reasonably sized range
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.
maybe_uid=$1
if [ $maybe_uid -ge $low_uid ] && [ $maybe_uid -le $high_uid ] && \
! echo $used_uids | grep -q $maybe_uid; then
echo $maybe_uid
return 0
fi
# Else, walk the pkgsrc-"allocated" range.
maybe_uid=$low_uid
while [ $maybe_uid -le $high_uid ]; do
if echo $used_uids | grep -q $maybe_uid; then
maybe_uid=`expr $maybe_uid + 1`
else
echo $maybe_uid
return 0
fi
done
return 1
}
user="$1"
if [ -z "$user" ]; then
echo "useradd: Must specify username" 1>&2
exit 1
fi
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
if [ -z "$group" ]; then
echo "useradd: Must specify group name" 1>&2
exit 1
fi
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 || \
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
else
if ! uid=`getnextuid $gid`; then
echo "useradd: no UIDs available in pkgsrc range" 1>&2
exit 1
fi
fi
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"
dscl . -create /users/$user Password '*'
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 2>/dev/null` 2>/dev/null || true

View File

@@ -0,0 +1,20 @@
#!/bin/sh
PATH=/bin:/usr/bin:$PATH
if [ $# -gt 1 ]; then
echo "userdel: Unrecognized option $1" 1>&2
exit 1
fi
user="$1"
if [ -z "$user" ]; then
echo "userdel: Must specify username" 1>&2
exit 1
fi
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