From c9d1b77034eceb7325fac46b3c3bd2c82171e0ca Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Thu, 13 Dec 2001 17:00:32 +0000 Subject: volinit-netatalk: Improve uid check and fallback to default user and group. --- volinit-netatalk | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'volinit-netatalk') diff --git a/volinit-netatalk b/volinit-netatalk index f81bad8..3307851 100755 --- a/volinit-netatalk +++ b/volinit-netatalk @@ -11,6 +11,10 @@ # NDIR="/var/local/netatalk" # +# Fallback to this uid and gid if group uid doesn't exist +GRP_UID="admin" +GRP_GID="admin" + [ -f /etc/local/volumes ] || exit 1 . /etc/local/volumes [ "x$NDIR" = "x" ] && exit 1 @@ -18,28 +22,40 @@ if [ $# -eq 0 ]; then echo "Usage: $0 [create]" exit 1 - fi +fi if [ "x$1" = "x" ]; then - echo "$0: base directory missing" + echo "$0: base directory missing - exiting..." exit 1 - fi +fi VOL=$NDIR/$1 if [ "x$2" = "x" ]; then - echo "$0: read group missing" + echo "$0: read group missing - exiting..." exit 1 - fi +fi ALL=$2 +#if [ `getent passwd "$ALL" | awk -F: '{print $1}';` ]; then +if [ `getent passwd "$ALL"` ]; then + ALL_UID=$ALL + ALL_GID=$ALL +else + echo "$0: User id $ALL doesn't exist - exiting..." + exit 1 +fi if [ "x$3" = "x" ]; then - echo "$0: write group missing" + echo "$0: write group missing - exiting..." exit 1 - fi +fi GRP=$3 - -GRPUSER="admin" -id $GRP >/dev/null && GRPUSER=$GRP +#if [ `getent passwd "$GRP" | awk -F: '{print $1}';` = "" ]; then +if [ `getent passwd "$GRP"` ]; then + GRP_UID=$GRP + GRP_GID=$GRP +else + echo "User id $GRP doesn't exist - using $GRP_UID:$GRP_GID instead" +fi if [ "x$4" != "x" ]; then if [ "x$4" == "xcreate" ]; then @@ -53,15 +69,15 @@ fi test -d $VOL/$ALL/$GRP || exit test -d $VOL/$ALL/$GRP/.AppleDouble || mkdir $VOL/$ALL/$GRP/.AppleDouble test -d $VOL/$ALL/$GRP/.AppleDesktop || mkdir $VOL/$ALL/$GRP/.AppleDesktop -chown root:$ALL $VOL/$ALL -chown $GRPUSER:$ALL $VOL/$ALL/$GRP +chown root:$ALL_GID $VOL/$ALL +chown $GRP_UID:$ALL_GID $VOL/$ALL/$GRP chmod u=rwX,g=rXs,o= $VOL/$ALL chmod u=rwX,g=rXs,o= $VOL/$ALL/$GRP echo "People in group $GRP has read/write access through AppleShare" test $GRP = $ALL || echo "People in group $ALL has read access through AppleShare" echo "Others have no access" echo -n "Checking permissions..." -chown -R :$GRP $VOL/$ALL/$GRP \ +chown -R .$GRP_GID $VOL/$ALL/$GRP \ && chmod -R u=rwX,g=rwXs,o=rX $VOL/$ALL/$GRP \ && chmod u=rwX,g=rXs,o=rX $VOL/$ALL/$GRP echo "." -- cgit v1.2.3