diff options
author | Roy Marples <roy@marples.name> | 2007-11-14 15:29:25 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2007-11-14 15:29:25 +0000 |
commit | d3b7a917969752900920337c0235a2890dd880a6 (patch) | |
tree | 4d06ec2a25465f92bf3e7c686f7fa3cf1c126ea3 | |
parent | 75f5b5fe1d8ce62c80bc7033d717d700e0f81dbd (diff) |
Use realpath to resolve our service.
-rw-r--r-- | src/runscript.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/runscript.c b/src/runscript.c index 506bdd80..63453374 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 = NULL; +static char service[PATH_MAX]; static char *exclusive = NULL; static char *mtime_test = NULL; static rc_depinfo_t *deptree = NULL; @@ -347,7 +347,6 @@ static void cleanup (void) free (exclusive); free (applet); free (prefix); - free (service); free (softlevel); } @@ -992,14 +991,9 @@ int runscript (int argc, char **argv) char *svc; /* We need the full path to the service */ - if (*argv[1] == '/') - service = 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); - } + if (! realpath (argv[0], service)) + eerrorx ("unable to resolve the path `%s': %s", + argv[0], strerror (errno)); applet = xstrdup (basename (service)); atexit (cleanup); |