summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configd/src/apps/su/main.cpp12
-rwxr-xr-xvespabase/src/common-env.sh7
-rwxr-xr-xvespabase/src/rhel-prestart.sh52
3 files changed, 42 insertions, 29 deletions
diff --git a/configd/src/apps/su/main.cpp b/configd/src/apps/su/main.cpp
index 7baa726d630..4cce0b5ead0 100644
--- a/configd/src/apps/su/main.cpp
+++ b/configd/src/apps/su/main.cpp
@@ -7,18 +7,22 @@
/**
* small utility to use instead of "su" when we want to just
- * switch to the "yahoo" user without any more fuss
+ * switch to the vespa user without any more fuss
**/
int main(int argc, char** argv)
{
if (argc < 2) {
- fprintf(stderr, "missing arguments, usage: run-as-yahoo <cmd> [args ...]");
+ fprintf(stderr, "missing arguments, usage: run-as-yahoo <cmd> [args ...]\n");
exit(1);
}
- struct passwd *p = getpwnam("yahoo");
+ const char *username = getenv("VESPA_USER");
+ if (username == NULL) {
+ username = "yahoo";
+ }
+ struct passwd *p = getpwnam(username);
if (p == NULL) {
- perror("FATAL error: user 'yahoo' missing in passwd file");
+ fprintf(stderr, "FATAL error: user '%s' missing in passwd file\n", username);
exit(1);
}
gid_t g = p->pw_gid;
diff --git a/vespabase/src/common-env.sh b/vespabase/src/common-env.sh
index cbc096dc1bf..3caa875b846 100755
--- a/vespabase/src/common-env.sh
+++ b/vespabase/src/common-env.sh
@@ -100,7 +100,12 @@ populate_environment () {
# VESPA_USE_NO_VESPAMALLOC - list of programs that should use normal system malloc
read_conf_file
- consider_fallback ROOT ${VESPA_HOME}
+ consider_fallback ROOT ${VESPA_HOME%/}
+ if id yahoo >/dev/null 2>&1 ; then
+ consider_fallback VESPA_USER "yahoo"
+ elif id vespa >/dev/null 2>&1 ; then
+ consider_fallback VESPA_USER "vespa"
+ fi
}
populate_environment
diff --git a/vespabase/src/rhel-prestart.sh b/vespabase/src/rhel-prestart.sh
index 761fd6af334..0778ab378b8 100755
--- a/vespabase/src/rhel-prestart.sh
+++ b/vespabase/src/rhel-prestart.sh
@@ -61,6 +61,7 @@ findroot
# END environment bootstrap section
[ "$VESPA_HOME" ] || { echo "Missing VESPA_HOME variable" 1>&2; exit 1; }
+[ "$VESPA_USER" ] || { echo "Missing VESPA_USER variable" 1>&2; exit 1; }
cd $VESPA_HOME || { echo "Cannot cd to $VESPA_HOME" 1>&2; exit 1; }
@@ -77,30 +78,33 @@ fixdir () {
# BEGIN directory fixups
-fixdir yahoo wheel 755 libdata/yell/exception
-fixdir yahoo wheel 775 libexec/vespa/modelplugins
-fixdir yahoo wheel 755 libexec/vespa/plugins/qrs
-fixdir root wheel 1777 logs
-fixdir yahoo wheel 1777 logs/vespa
-fixdir yahoo wheel 755 logs/vespa/qrs
-fixdir yahoo wheel 755 logs/vespa/search
-fixdir root wheel 1777 tmp
-fixdir yahoo wheel 1777 tmp/vespa
-fixdir yahoo wheel 755 var/cache/vespa/config
-fixdir yahoo wheel 1777 var/crash
-fixdir yahoo wheel 755 var/db/vespa
-fixdir yahoo wheel 755 var/db/vespa/config_server
-fixdir yahoo wheel 755 var/db/vespa/config_server/serverdb
-fixdir yahoo wheel 755 var/db/vespa/config_server/serverdb/applications
-fixdir yahoo wheel 755 var/db/vespa/config_server/serverdb/configs
-fixdir yahoo wheel 755 var/db/vespa/config_server/serverdb/configs/application
-fixdir yahoo wheel 755 var/db/vespa/index
-fixdir yahoo wheel 755 var/db/vespa/search
-fixdir yahoo wheel 755 var/db/vespa/logcontrol
-fixdir root wheel 1777 var/run
-
-chown -hR yahoo logs/vespa
-chown -hR yahoo var/db/vespa
+fixdir root wheel 1777 logs
+fixdir root wheel 1777 tmp
+fixdir root wheel 1777 var/run
+fixdir ${VESPA_USER} wheel 1777 var/crash
+fixdir ${VESPA_USER} wheel 1777 logs/vespa
+fixdir ${VESPA_USER} wheel 1777 tmp/vespa
+fixdir ${VESPA_USER} wheel 755 libdata/yell/exception
+fixdir ${VESPA_USER} wheel 755 libexec/vespa/plugins/qrs
+fixdir ${VESPA_USER} wheel 755 logs/vespa/qrs
+fixdir ${VESPA_USER} wheel 755 logs/vespa/search
+fixdir ${VESPA_USER} wheel 755 var/cache/vespa/config
+fixdir ${VESPA_USER} wheel 755 var/db/vespa
+fixdir ${VESPA_USER} wheel 755 var/db/vespa/config_server
+fixdir ${VESPA_USER} wheel 755 var/db/vespa/config_server/serverdb
+fixdir ${VESPA_USER} wheel 755 var/db/vespa/config_server/serverdb/applications
+fixdir ${VESPA_USER} wheel 755 var/db/vespa/config_server/serverdb/configs
+fixdir ${VESPA_USER} wheel 755 var/db/vespa/config_server/serverdb/configs/application
+fixdir ${VESPA_USER} wheel 755 var/db/vespa/index
+fixdir ${VESPA_USER} wheel 755 var/db/vespa/logcontrol
+fixdir ${VESPA_USER} wheel 755 var/db/vespa/search
+fixdir ${VESPA_USER} wheel 755 var/vespa/bundlecache
+fixdir ${VESPA_USER} wheel 755 var/vespa/bundlecache/configserver
+fixdir ${VESPA_USER} wheel 755 var/vespa/cache/config/
+fixdir ${VESPA_USER} wheel 775 libexec/vespa/modelplugins
+
+chown -hR ${VESPA_USER} logs/vespa
+chown -hR ${VESPA_USER} var/db/vespa
# END directory fixups