LP1900005: Don't require a specific 'opensrf' user
authorJason Boyer <JBoyer@equinoxinitiative.org>
Thu, 15 Oct 2020 17:50:18 +0000 (13:50 -0400)
committerJason Boyer <JBoyer@EquinoxInitiative.org>
Mon, 12 Jul 2021 18:43:36 +0000 (14:43 -0400)
There's no technical reason to require a specific user beyond our
instructions stating that it's the default. One thing that we should
do is not allow our network services to be run as root.
Additionally, autogen.sh is excluded from running as root because while
that would work, it may then have to *always* be run by root or
require you to change the file owner between runs.

To test:
Pre-patch:
Use oils_ctl.sh to start SIP or z3950 as opensrf, Success.
Use oils_ctl.sh to start SIP or z3950 as yourself, Failure.
Use oils_ctl.sh to start SIP or z3950 as root, Failure.
Run autogen.sh as opensrf, Success.
Run autogen.sh as yourself, Failure.
Run autogen.sh as root, Failure.

Post patch:
Use oils_ctl.sh to start SIP or z3950 as opensrf, Success.
Use oils_ctl.sh to start SIP or z3950 as your normal user, Success.
Use oils_ctl.sh to start SIP or z3950 as root, Failure.
Run autogen.sh as opensrf, Success.
Run autogen.sh as yourself, potential Success - IF you're able to write to the correct directory / files.
Run autogen.sh as root, Failure.

Signed-off-by: Jason Boyer <JBoyer@equinoxinitiative.org>
Open-ILS/examples/oils_ctl.sh
Open-ILS/src/extras/autogen.sh

index dde70cb..92ecd9b 100755 (executable)
@@ -10,9 +10,9 @@ Z3950_LOG="LOCALSTATEDIR/log/oils_z3950.log"
 SIP_DIR="/opt/SIPServer";
 
 # ---------------------------------------------------------------------------
-# Make sure we're running as the correct user
+# Make sure we're not running as the root user
 # ---------------------------------------------------------------------------
-[ $(whoami) != 'opensrf' ] && echo 'Must run as user "opensrf"' && exit;
+[ $(whoami) = 'root' ] && echo 'Do not run as user "root"' && exit;
 
 
 function usage {
index 37c9d90..0af609a 100755 (executable)
@@ -21,10 +21,22 @@ set -e
 # Throw an error for uninitialized variables
 set -u
 
+JSDIR="LOCALSTATEDIR/web/opac/common/js/";
+FMDOJODIR="LOCALSTATEDIR/web/js/dojo/fieldmapper/";
+SLIMPACDIR="LOCALSTATEDIR/web/opac/extras/slimpac/";
+SKINDIR='LOCALSTATEDIR/web/opac/skin';
+
+COMPRESSOR="" # TODO: set via ./configure
+#COMPRESSOR="java -jar /opt/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar"
+
 # ---------------------------------------------------------------------------
-# Make sure we're running as the correct user
+# Make sure we're not root and are able to write to the destination directory
 # ---------------------------------------------------------------------------
-[ $(whoami) != 'opensrf' ] && echo 'Must run as user "opensrf"' && exit;
+[ $(whoami) = 'root' ] && echo 'Do not run as user "root"' && exit;
+if [ ! -d "$JSDIR" ] || [ ! -w "$JSDIR" ]; then
+       echo "Not able to write to ${JSDIR}!";
+       exit;
+fi
 
 function usage {
        echo "";
@@ -66,14 +78,6 @@ while getopts  "u h" flag; do
 done
 shift $((OPTIND - 1))
 
-JSDIR="LOCALSTATEDIR/web/opac/common/js/";
-FMDOJODIR="LOCALSTATEDIR/web/js/dojo/fieldmapper/";
-SLIMPACDIR="LOCALSTATEDIR/web/opac/extras/slimpac/";
-SKINDIR='LOCALSTATEDIR/web/opac/skin';
-
-COMPRESSOR="" # TODO: set via ./configure
-#COMPRESSOR="java -jar /opt/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar"
-
 echo "Updating Evergreen organization tree and IDL"
 echo ""