diff options
author | Ramón M. Gómez <ramongomez@us.es> | 2019-09-24 13:40:59 +0200 |
---|---|---|
committer | Ramón M. Gómez <ramongomez@us.es> | 2019-09-24 13:40:59 +0200 |
commit | e371a87cda399315213e2d73cb7a509e49afc67e (patch) | |
tree | d2b3fdb69e5a61093df0a3107cf89972b50f93a3 | |
parent | 4d5cafd6747a77f9142c076ce80fcbb6730bcbc5 (diff) |
#802 #888 setclientmode: fix web user detection.
-rwxr-xr-x | server/bin/setclientmode | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/server/bin/setclientmode b/server/bin/setclientmode index 2aab03d9..4004e932 100755 --- a/server/bin/setclientmode +++ b/server/bin/setclientmode @@ -44,7 +44,9 @@ if [ $# -ne 3 ]; then exit 1 fi -if [ "$USER" != "root" -a "$USER" != "www-data" ]; then +# Comprobar si el usuario es "root" o el del servicio web. +WEBUSER=$(ps axho user,comm|awk '!/root/ && /httpd|apache/ {print $1; exit;}') +if [ "$USER" != "root" -a "$USER" != "$WEBUSER" ]; then echo "$PROG: Need to be root. (The console can also call the script)." >&2 exit 1 fi @@ -147,8 +149,7 @@ for MAC in $ETHERNET; do OGLIVEDIR=$(echo "$DATOS" | awk -F= 'BEGIN {RS=" "} $1=="oglivedir" {print $2}') # Pondremos como propietario al usuario y grupo de Apache para que se pueda cambiar desde la consola web. - PERMS=$(ps axho user,group,comm|awk '!/root/ && /httpd|apache/ {u=$1; g=$2} END {if (g) printf "%s:%s",u,g}') - + WEBGROUP=$(ps axho group,comm|awk '!/root/ && /httpd|apache/ {print $1; exit;}') for BOOTTYPE in 0 1; do # Si no existe la plantilla borramos el archivo PXE anterior continuamos if [ -z "${TEMPLATE[$BOOTTYPE]}" ]; then @@ -164,7 +165,7 @@ for MAC in $ETHERNET; do # Crear fichero PXE a partir de la plantilla con los datos obtenidos en la BD. sed -e "s,vga=[0-9]*,,g; s,INFOHOST,${DATOSAUX//,/\\,},g; s,set ISODIR=.*,set ISODIR=$OGLIVEDIR,g" ${TEMPLATE[$BOOTTYPE]} >${PXEDIR[$BOOTTYPE]}/${PXEFILE[$BOOTTYPE]} - [ -n "$PERMS" ] && chown $PERMS ${PXEDIR[$BOOTTYPE]}/${PXEFILEE[$BOOTTYPE]} + [ -n "$WEBUSER" ] && chown $WEBUSER:$WEBGROUP ${PXEDIR[$BOOTTYPE]}/${PXEFILEE[$BOOTTYPE]} done |