summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-07-04 14:56:59 +0000
committerRoy Marples <roy@marples.name>2007-07-04 14:56:59 +0000
commit46156cc8cdfcdcc676d5d5d0a1a753978e412018 (patch)
tree87e8ab762f841eb4b16e260284d0e1cbb891b708 /src
parent0234605bf48da701295efc421a3bf4cf95dae347 (diff)
downloadopenrc-46156cc8cdfcdcc676d5d5d0a1a753978e412018.tar.gz
openrc-46156cc8cdfcdcc676d5d5d0a1a753978e412018.tar.bz2
openrc-46156cc8cdfcdcc676d5d5d0a1a753978e412018.tar.xz
We need the full path to the service before chdir /
Diffstat (limited to 'src')
-rw-r--r--src/runscript.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/runscript.c b/src/runscript.c
index cbdc98a..ad2d69a 100644
--- a/src/runscript.c
+++ b/src/runscript.c
@@ -293,6 +293,7 @@ static void cleanup (void)
free (exclusive);
free (applet);
free (prefix);
+ free (service);
}
static int write_prefix (int fd, const char *buffer, size_t bytes, bool *prefixed) {
@@ -992,7 +993,16 @@ int main (int argc, char **argv)
int retval;
int opt;
- service = argv[1];
+ /* We need the full path to the service */
+ if (*argv[1] == '/')
+ service = rc_xstrdup (argv[1]);
+ else {
+ char pwd[PATH_MAX];
+ if (! getcwd (pwd, PATH_MAX))
+ eerrorx ("getcwd: %s", strerror (errno));
+ service = rc_strcatpaths (pwd, argv[1], (char *) NULL);
+ }
+
applet = rc_xstrdup (basename (service));
atexit (cleanup);