annotate previous-work/more_control_helpers/sbin/groupadd @ 9:a0c0ccd22ca5

progress on setuid wrapper script.
author Robert McIntyre <rlm@mit.edu>
date Wed, 09 Jan 2013 04:53:59 +0000
parents d6bef198ae71
children
rev   line source
rlm@1 1 #!/bin/bash
rlm@1 2 # Copyright (c) 2000,2004 Matthias S. Benkmann <article AT winterdrache DOT de>
rlm@1 3 # You may do everything with this code except misrepresent its origin.
rlm@1 4 # PROVIDED `AS IS' WITH ABSOLUTELY NO WARRANTY OF ANY KIND!
rlm@1 5
rlm@1 6 #
rlm@1 7 # This is a primitive script to serve as groupadd until the real groupadd
rlm@1 8 # has been installed. It has little error checking, so don't pass it anything
rlm@1 9 # stupid or it'll mess up your /etc/group file.
rlm@1 10 #
rlm@1 11
rlm@1 12 if [ $# -ne 3 -o z$1 != z-g ]; then
rlm@1 13 echo 1>&2 USAGE: groupadd -g gid groupname
rlm@1 14 exit 1
rlm@1 15 fi
rlm@1 16
rlm@1 17 #test if group already exists
rlm@1 18 grep "^${3}:.*" /etc/group
rlm@1 19 if [ $? -eq 0 ]; then
rlm@1 20 echo 1>&2 $0: Group does already exist
rlm@1 21 exit 1
rlm@1 22 fi
rlm@1 23
rlm@1 24 cp /etc/group /tmp/group123456
rlm@1 25 echo ${3}:x:${2}: | sort -t : -k3,3n -m /tmp/group123456 - > /etc/group
rlm@1 26