]> git.tuebingen.mpg.de Git - gsu.git/commitdiff
gsu: Don't fail if HOME is unset.
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 26 Aug 2014 19:52:07 +0000 (21:52 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Fri, 29 Aug 2014 19:39:59 +0000 (21:39 +0200)
As pointed out by Joffrey Fitz, gsu-based scripts do not work when
run as a user without home directory. This happens for example if
the script is executed through a web application as the www-data user.

This patch replaces all references to HOME by ${HOME:-}, i.e. we just
default to the empty string but don't fail immediately.

misc/gsu/config
misc/gsu/gui
misc/gsu/subcommand

index 6edd502fec0a0fd29a0af3abb922e78bea80a464..09330f355cc5b16d8cb0288760f3c620f92c65ef 100644 (file)
@@ -4,7 +4,7 @@
 # file.
 gsu_check_options()
 {
 # file.
 gsu_check_options()
 {
-       local i conf="${gsu_config_file:=$HOME/.$gsu_name.rc}" val
+       local i conf="${gsu_config_file:=${HOME:-}/.$gsu_name.rc}" val
 
        for ((i=0; i < ${#gsu_options[@]}; i++)); do
                eval "${gsu_options[$i]}"
 
        for ((i=0; i < ${#gsu_options[@]}; i++)); do
                eval "${gsu_options[$i]}"
@@ -79,7 +79,7 @@ gsu_check_options_or_die()
 }
 
 if [[ "$(type -t _gsu_setup)" != "function" ]]; then
 }
 
 if [[ "$(type -t _gsu_setup)" != "function" ]]; then
-       gsu_dir=${gsu_dir:=$HOME/.gsu}
+       gsu_dir=${gsu_dir:=${HOME:-}/.gsu}
        . $gsu_dir/common || exit 1
        _gsu_setup
 fi
        . $gsu_dir/common || exit 1
        _gsu_setup
 fi
index 99da51a78cf74091eb8b7f726883e5b2cb3f1bc8..eb9f29f37c9e1d7aef03c96f08b4838285931f1a 100644 (file)
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 if [[ $(type -t gsu_is_a_number) != "function" ]]; then
 #!/bin/bash
 
 if [[ $(type -t gsu_is_a_number) != "function" ]]; then
-       GSU_DIR=${GSU_DIR:=$HOME/.gsu}
+       GSU_DIR=${GSU_DIR:=${HOME:-}/.gsu}
        . $GSU_DIR/common || exit 1
 fi
 
        . $GSU_DIR/common || exit 1
 fi
 
index 3a1bc6db6697c7a0676a45ae940b930d18ee8901..f1685aa1e416af8bf3ddb3d78a2a93ec1f9bacaa 100644 (file)
@@ -2,7 +2,7 @@
 # (C) 2006-2011 Andre Noll
 
 if [[ $(type -t gsu_is_a_number) != "function" ]]; then
 # (C) 2006-2011 Andre Noll
 
 if [[ $(type -t gsu_is_a_number) != "function" ]]; then
-       GSU_DIR=${GSU_DIR:=$HOME/.gsu}
+       GSU_DIR=${GSU_DIR:=${HOME-}/.gsu}
        . $GSU_DIR/common || exit 1
 fi
 
        . $GSU_DIR/common || exit 1
 fi
 
@@ -90,7 +90,7 @@ options, the command prints out a list of all cmt config variables, together
 with their current value and the default value."
 _com_prefs()
 {
 with their current value and the default value."
 _com_prefs()
 {
-       local i conf="${gsu_config_file:=$HOME/.$gsu_name.rc}"
+       local i conf="${gsu_config_file:=${HOME:-}/.$gsu_name.rc}"
 
        gsu_getopts "e"
        eval "$result"
 
        gsu_getopts "e"
        eval "$result"