]> gitweb.fluxo.info Git - firma.git/commitdiff
fix on USER and GROUP evaluation
authorrhatto <rhatto>
Mon, 9 Oct 2006 13:28:25 +0000 (13:28 +0000)
committerrhatto <rhatto>
Mon, 9 Oct 2006 13:28:25 +0000 (13:28 +0000)
firma

diff --git a/firma b/firma
index 222094f7ca8728746cdabdbc9bb5e7528ce7963d..d8087b62cd1657f0bf4914c992c24488449e6dd5 100755 (executable)
--- a/firma
+++ b/firma
@@ -185,15 +185,15 @@ WARNING: Setting LOG_TO_SYSLOG to '0'."
   fi
 
   if ! grep -q -e "^USER=" $FIRMA_CONFIG_FILE; then
-    USER="nobody"
+    FIRMA_USER="nobody"
   else
-    USER="`grep "^USER=" $FIRMA_CONFIG_FILE | sed -e 's/"//g' -e "s/'//g" | cut -d = -f 2`"
+    FIRMA_USER="`grep "^USER=" $FIRMA_CONFIG_FILE | sed -e 's/"//g' -e "s/'//g" | cut -d = -f 2`"
   fi
 
   if ! grep -q -e "^GROUP=" $FIRMA_CONFIG_FILE; then
-    GROUP="nobody"
+    FIRMA_GROUP="nobody"
   else
-    GROUP="`grep "^GROUP=" $FIRMA_CONFIG_FILE | sed -e 's/"//g' -e "s/'//g" | cut -d = -f 2`"
+    FIRMA_GROUP="`grep "^GROUP=" $FIRMA_CONFIG_FILE | sed -e 's/"//g' -e "s/'//g" | cut -d = -f 2`"
   fi
 
   return $return_code
@@ -243,6 +243,14 @@ WARNING: $LIST_NAME: Removing this address from LIST_ADMIN."
     LIST_ADMIN="$valid_admins"
   fi
 
+  if grep -q -e "^USER=" $LIST_CONFIG_FILE; then
+    FIRMA_USER="`grep "^USER=" $LIST_CONFIG_FILE | sed -e 's/"//g' -e "s/'//g" | cut -d = -f 2`"
+  fi
+
+  if grep -q -e "^GROUP=" $LIST_CONFIG_FILE; then
+    FIRMA_GROUP="`grep "^GROUP=" $LIST_CONFIG_FILE | sed -e 's/"//g' -e "s/'//g" | cut -d = -f 2`"
+  fi
+
   return $return_code
 }
 
@@ -875,7 +883,7 @@ function NewList {
     echo "Creating your config..."
     touch $LIST_CONFIG_FILE
     chmod 600 $LIST_CONFIG_FILE
-    chown $USER.$GROUP $LIST_CONFIG_FILE
+    chown $FIRMA_USER.$FIRMA_GROUP $LIST_CONFIG_FILE
     if [ -f "$LIST_CONFIG_FILE" ]; then
       DeclareGpgVars
       # removed: MAIL_AGENT=$MAIL_AGENT\nGPG_BINARY=$GPG_BINARY\n
@@ -899,7 +907,7 @@ function NewList {
 EOF
 
       # TODO: import admin pubkey and send list pubkey to admin
-      chown -R $USER.$GROUP $LIST_HOMEDIR
+      chown -R $FIRMA_USER.$FIRMA_GROUP $LIST_HOMEDIR
 
     else
       echo "$(basename $0): cannot create $LIST_PATH: Installation aborted"
@@ -1082,7 +1090,7 @@ EOF
 function CheckPermission {
   #-------------------------------------------------------------
   # check if file has correct permissions (600) and also
-  # +if the file is owned by $USER
+  # +if the file is owned by $FIRMA_USER
   # +got the idea for this function from backupninja
   #
   # parameter(s): file name
@@ -1099,8 +1107,8 @@ function CheckPermission {
     return 1
   fi
 
-  if [ `ls -ld $file | awk '{print $3}'` != "$USER" ]; then
-    echo "WARNING: Configuration files must be owned by $USER! Dying on file $file"
+  if [ `ls -ld $file | awk '{print $3}'` != "$FIRMA_USER" ]; then
+    echo "WARNING: Configuration files must be owned by $FIRMA_USER! Dying on file $file"
   fi
 
   return 0
@@ -1110,7 +1118,7 @@ function CheckPermission {
 function CheckListPermissions {
   #-------------------------------------------------------------
   # check if list files has correct permissions (600) and also
-  # +if the files are owned by $USER
+  # +if the files are owned by $FIRMA_USER
   #
   # parameter(s): list config file
   # depends on function(s): CheckPermission
@@ -1122,7 +1130,7 @@ function CheckListPermissions {
   local folder
   local config
 
-  # check and fix permissions on all files from $LIST_PATH to $USER.$GROUP
+  # check and fix permissions on all files from $LIST_PATH to $FIRMA_USER.$FIRMA_GROUP
   if [ ! -z "$1" ]; then
     folder="`dirname $1`"
     config="`basename $1`"
@@ -1130,7 +1138,7 @@ function CheckListPermissions {
       if ! CheckPermission $folder/$file; then
         LogMessage "Fixing permission and ownership for $folder/$file"
         chmod 600 $folder/$file
-        chown $USER.$GROUP $folder/$file
+        chown $FIRMA_USER.$FIRMA_GROUP $folder/$file
       fi
     done
   fi
@@ -1194,7 +1202,7 @@ function UnsubscribeUser {
     done
   fi
 
-  chown -R $USER.$GROUP $LIST_PATH
+  chown -R $FIRMA_USER.$FIRMA_GROUP $LIST_PATH
   return $return_code
 }
 
@@ -1254,7 +1262,9 @@ GLOBAL_VARS="
   GLOBAL_VARS VAR
   USER
   GROUP
-  BASENAME"
+  BASENAME
+  FIRMA_USER
+  FIRMA_GROUP"
 
 FUNCTIONS="
   Usage