summaryrefslogtreecommitdiffstats
path: root/configd
diff options
context:
space:
mode:
authorArne Juul <arnej@yahoo-inc.com>2016-06-17 11:36:57 +0200
committerArne Juul <arnej@yahoo-inc.com>2016-06-17 11:41:11 +0200
commit6d88abf17818df9e4918d51f315aa3fdc0f0af5b (patch)
treedde93c7a14ee602175e6f9135501420c217f0e25 /configd
parent5f183818539ce83b19f6c3b09315db0eed20be56 (diff)
use VESPA_USER environment variable
* defaults to "yahoo" if VESPA_USER is not set
Diffstat (limited to 'configd')
-rw-r--r--configd/src/apps/su/main.cpp12
1 files changed, 8 insertions, 4 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;