From b022b95a13194547a812c2b1fd5e0a66f3cdd09e Mon Sep 17 00:00:00 2001 From: Andrew Lewman Date: Tue, 12 Jun 2007 22:17:24 +0000 Subject: [PATCH] Backport candidate. Updated to work with all versions of osx we support (10.3-10.5). svn:r10579 --- contrib/osx/addsysuser | 75 +++++++++++++++++++---------- contrib/osx/uninstall_tor_bundle.sh | 11 ++--- 2 files changed, 54 insertions(+), 32 deletions(-) diff --git a/contrib/osx/addsysuser b/contrib/osx/addsysuser index c57f46e139..7b167eac00 100755 --- a/contrib/osx/addsysuser +++ b/contrib/osx/addsysuser @@ -5,6 +5,9 @@ # Modified for Tor installer by Nick Mathewson # 2007-06-12 Modified for leopard by Andrew Lewman + +ROOTPROP=/ + if [ "`whoami`" != "root" ]; then echo "You must be root to execute this script." exit @@ -16,30 +19,50 @@ fi username=$1 realname=$2 homedir=$3 -# GID 20 is "staff" which is the default. Change it if you want. -#gid=`niutil -readprop $ROOTPROP /groups/daemon gid` -gid=`dscl . -read /groups/daemon gid` -echo $gid -#if [ "x`niutil -list $ROOTPROP /users|cut -f2 -d' '|grep $username`" != "x" ]; then -if [ "x`dscl . -list /users|cut -f2 -d' '|grep $username`" != "x" ]; then -echo The account $username already exists. -exit 0 +if [ -x /usr/bin/dscl ]; then + # Determine the gid of the daemon group + gid=`dscl . -read /groups/daemon gid` + if [ "x`dscl . -list /users|cut -f2 -d' '|grep $username`" != "x" ]; then + echo The account $username already exists. + exit 0 + fi + # home is the local path to the home directory + home=/Users/$username + echo Creating account for $username... + dscl . -create /users/$username + dscl . -create /users/$username _writers_tim_passwd $username + dscl . -create /users/$username realname $realname + dscl . -create /users/$username _writers_passwd $username + dscl . -create /users/$username gid $gid + dscl . -create /users/$username home $homedir + dscl . -create /users/$username name $username + dscl . -create /users/$username passwd '*' + dscl . -create /users/$username shell /dev/null +else + # Determine the gid of the daemon group + gid=`niutil -readprop $ROOTPROP /groups/daemon gid` + if [ "x`niutil -list $ROOTPROP /users|cut -f2 -d' '|grep $username`" != "x" ]; then + echo The account $username already exists. + exit 0 + fi + # home is the local path to the home directory + home=/Users/$username + # defhome is what goes into NetInfo + defhome="/Network/Servers/MyServer/Users" + #echo "Determining next available system uid (please be patient)..." + # Uids over 500 are for system users. + uiddef=`nidump passwd / | cut -d: -f3 | sort -n | grep -v '^[56789]..' |grep -v '^....$' | tail -n 1` + uiddef=`echo $uiddef + 1 |bc` + echo Creating account for $username... + niutil -create $ROOTPROP /users/$username + niutil -createprop $ROOTPROP /users/$username _writers_tim_passwd $username + niutil -createprop $ROOTPROP /users/$username realname $realname + niutil -createprop $ROOTPROP /users/$username _writers_passwd $username + niutil -createprop $ROOTPROP /users/$username uid $uiddef + #niutil -createprop $ROOTPROP /users/$username home_loc "afp://afp.server.com/Users/$username" + niutil -createprop $ROOTPROP /users/$username gid $gid + niutil -createprop $ROOTPROP /users/$username home $homedir + niutil -createprop $ROOTPROP /users/$username name $username + niutil -createprop $ROOTPROP /users/$username passwd '*' + niutil -createprop $ROOTPROP /users/$username shell /dev/null fi -# home is the local path to the home directory -home=/Users/$username -# defhome is what goes into NetInfo -defhome="/Network/Servers/MyServer/Users" -#echo "Determining next available system uid (please be patient)..." -# Uids over 500 are for system users. -#uiddef=`nidump passwd / | cut -d: -f3 | sort -n | grep -v '^[56789]..' |grep -v '^....$' | tail -n 1` -#uiddef=`echo $uiddef + 1 |bc` -echo Creating account for $username... -dscl . -create /users/$username -dscl . -create /users/$username _writers_tim_passwd $username -dscl . -create /users/$username realname $realname -dscl . -create /users/$username _writers_passwd $username -dscl . -create /users/$username gid $gid -dscl . -create /users/$username home $homedir -dscl . -create /users/$username name $username -dscl . -create /users/$username passwd '*' -dscl . -create /users/$username shell /dev/null diff --git a/contrib/osx/uninstall_tor_bundle.sh b/contrib/osx/uninstall_tor_bundle.sh index c1c6f507af..bb992f7a95 100755 --- a/contrib/osx/uninstall_tor_bundle.sh +++ b/contrib/osx/uninstall_tor_bundle.sh @@ -33,11 +33,9 @@ ## (ie "Tor", "torstartup", ...) the list should be new-line-delimited. PACKAGE_LIST_SRC=./package_list.txt - ### this is the name of the user created in the install process of Tor TOR_USER=_tor - ### these should be constant across all osX installs (so leave them be) STARTUP_ITEMS_DIR=/Library/StartupItems PKG_RCPT_BASE_DIR=/Library/Receipts @@ -45,7 +43,6 @@ BOM_INTERMEDIATE_DIR=Contents/Resources INFO_INTERMEDIATE_DIR=$BOM_INTERMEDIATE_DIR/English.lproj TEMP_BOM_CONTENTS=/tmp/tor_uninst_scratch - ### make sure the script is being run as root, barf if not if [ "`whoami`" != "root" ]; then echo "Must be root to run the uninstall script." @@ -128,9 +125,11 @@ done < $PACKAGE_LIST_SRC ## nuke the user created by the install process. echo ". Removing created user $TOR_USER" -#niutil -destroy . /users/$TOR_USER -dscl . -delete /users/$TOR_USER - +if [ -x /usr/bin/dscl ]; then + dscl . -delete /users/$TOR_USER +else + niutil -destroy . /users/$TOR_USER +fi ## clean up echo ". Cleaning up"