summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-11-21 15:38:07 +0000
committerRoy Marples <roy@marples.name>2007-11-21 15:38:07 +0000
commit0c52821cba79a0c649450c0a1519bbfb21a4f975 (patch)
tree1d05e38455d3a6626bca61a4de6bbc05de575d4b /src
parenta76f2c20e410a1414b0922b22b00d1bc7c6cc35d (diff)
downloadopenrc-0c52821cba79a0c649450c0a1519bbfb21a4f975.tar.gz
openrc-0c52821cba79a0c649450c0a1519bbfb21a4f975.tar.bz2
openrc-0c52821cba79a0c649450c0a1519bbfb21a4f975.tar.xz
We cannot use realpath to resolv services as some are symlinks.
Diffstat (limited to 'src')
-rw-r--r--src/runscript.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/runscript.c b/src/runscript.c
index 5c214c7..6ff25eb 100644
--- a/src/runscript.c
+++ b/src/runscript.c
@@ -69,7 +69,7 @@
#define PREFIX_LOCK RC_SVCDIR "/prefix.lock"
static char *applet = NULL;
-static char service[PATH_MAX];
+static char *service = NULL;
static char *exclusive = NULL;
static char *mtime_test = NULL;
static rc_depinfo_t *deptree = NULL;
@@ -345,6 +345,7 @@ static void cleanup (void)
free (mtime_test);
}
free (exclusive);
+ free (service);
free (applet);
free (prefix);
free (softlevel);
@@ -999,13 +1000,18 @@ int runscript (int argc, char **argv)
eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s", argv[0],
strerror (errno));
}
-
- /* We need the full path to the service */
- if (! realpath (argv[1], service))
- eerrorx ("unable to resolve the path `%s': %s",
- argv[1], strerror (errno));
- applet = xstrdup (basename (service));
+ applet = xstrdup (basename (argv[1]));
+ if (*argv[1] == '/')
+ service = xstrdup (argv[1]);
+ else {
+ char d[PATH_MAX];
+ getcwd (d, sizeof (d));
+ i = strlen (d) + strlen (argv[1]) + 2;
+ service = xmalloc (sizeof (char) * i);
+ snprintf (service, i, "%s/%s", d, argv[1]);
+ }
+
atexit (cleanup);
/* Change dir to / to ensure all init scripts don't use stuff in pwd */