This implements a subset of useradd(8)/groupadd(8) functionality on

IRIX that is sufficient for pkgsrc use.
This commit is contained in:
cheusov 2011-05-07 15:43:13 +00:00
parent 0a04ae0a94
commit 0c4d93a6de
7 changed files with 167 additions and 0 deletions

2
sysutils/user_irix/DESCR Normal file
View file

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

View file

@ -0,0 +1,28 @@
# $NetBSD: Makefile,v 1.1.1.1 2011/05/07 15:43:13 cheusov Exp $
#
DISTNAME= user-20110201
CATEGORIES= sysutils
MASTER_SITES= # empty
DISTFILES= # empty
MAINTAINER= vle@gmx.net
COMMENT= Limited NetBSD-compatible useradd/groupadd commands
LICENSE= 2-clause-bsd
PKG_DESTDIR_SUPPORT= user-destdir
ONLY_FOR_PLATFORM= IRIX-*-*
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"

5
sysutils/user_irix/PLIST Normal file
View file

@ -0,0 +1,5 @@
@comment $NetBSD: PLIST,v 1.1.1.1 2011/05/07 15:43:13 cheusov Exp $
sbin/groupadd
sbin/groupdel
sbin/useradd
sbin/userdel

View file

@ -0,0 +1,58 @@
#!/bin/ksh
set -e
PATH=/bin:/sbin:/usr/bin:/usr/sbin:$PATH
GID=1000 # start search from
show_usage () {
echo "usage: $0 [-ov] [-g gid] group" >&2
exit 1
}
while getopts 'g:ov' f; do
case $f in
g) gid="$OPTARG";;
o) reuse=1;;
v) ;; # ignored
\?) show_usage;;
esac
done
shift $(($OPTIND - 1))
get_unassigned_gid (){
awk -F: -v gid="$GID" '
{ h [$3] = 0 }
END {while (gid in h){++gid}; print gid}' /etc/group
}
uniq_gid (){
if ! awk -F: -v gid="$1" '$3 == gid {exit 1}' /etc/group; then
echo "Can't add group: gid $1 is a duplicate" 1>&2
exit 1
fi
}
uniq_name (){
if ! awk -F: -v name="$1" '$1 == name {exit 1}' /etc/group; then
echo "Can't add group: $1 is a duplicate" 1>&2
exit 1
fi
}
if test $# -ne 1; then
show_usage
fi
uniq_name "$1"
if test -z "$gid"; then
gid=`get_unassigned_gid`
elif test -z "$reuse"; then
uniq_gid "$gid"
fi
cp -p /etc/group /etc/group.tmp
echo "$1:*:$gid:" >> /etc/group.tmp
mv /etc/group.tmp /etc/group

View file

@ -0,0 +1,24 @@
#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:$PATH
show_usage () {
echo "usage: $0 [v] group" >&2
exit 1
}
while getopts 'v' f; do
case $f in
v) ;; # ignored
\?) show_usage;;
esac
done
shift $(($OPTIND - 1))
if test $# -ne 1; then
show_usage
fi
cp -p /etc/group /etc/group.tmp
awk -F: -v name="$1" '$1 != name' /etc/group > /etc/group.tmp
mv /etc/group.tmp /etc/group

View file

@ -0,0 +1,37 @@
#!/bin/sh
show_usage () {
echo "usage: useradd [-g gid] [-u uid] [-s shell] [-c comment] [-d home-dir] user" >&2
exit 1
}
shquote (){
__cmd=`printf '%s\n' "$1" | sed "s|'|'\\\\\''|g"`
printf "%s\n" "'$__cmd'"
}
while getopts 'g:u:s:c:d:' f; do
case $f in
g)
gid="$OPTARG"
if echo "$gid" | grep '^[0-9]*$' > /dev/null; then
:
else
gid=`awk -F: -v name="$gid" '$1 == name {print $3; exit}' /etc/group`
fi
opts="$opts -g $gid";;
u) opts="$opts -u "`shquote "$OPTARG"`;;
s) opts="$opts -s "`shquote "$OPTARG"`;;
c) opts="$opts -c "`shquote "$OPTARG"`;;
d) opts="$opts -h "`shquote "$OPTARG"`;;
\?) show_usage;;
esac
done
shift $(($OPTIND - 1))
if test $# -ne 1; then
show_usage
exit 1
fi
eval "/usr/sbin/passmgmt -a $opts $1"

View file

@ -0,0 +1,13 @@
#!/bin/sh
show_usage () {
echo "usage: userdel user" >&2
exit 1
}
if test $# -ne 1; then
show_usage
exit 1
fi
eval "/usr/sbin/passmgmt -d $1"