From d3b7a917969752900920337c0235a2890dd880a6 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Wed, 14 Nov 2007 15:29:25 +0000 Subject: Use realpath to resolve our service. --- src/runscript.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/runscript.c') 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); -- cgit v1.2.3