We cannot use realpath to resolv services as some are symlinks.

This commit is contained in:
Roy Marples 2007-11-21 15:38:07 +00:00
parent a76f2c20e4
commit 0c52821cba

View File

@ -69,7 +69,7 @@
#define PREFIX_LOCK RC_SVCDIR "/prefix.lock" #define PREFIX_LOCK RC_SVCDIR "/prefix.lock"
static char *applet = NULL; static char *applet = NULL;
static char service[PATH_MAX]; static char *service = NULL;
static char *exclusive = NULL; static char *exclusive = NULL;
static char *mtime_test = NULL; static char *mtime_test = NULL;
static rc_depinfo_t *deptree = NULL; static rc_depinfo_t *deptree = NULL;
@ -345,6 +345,7 @@ static void cleanup (void)
free (mtime_test); free (mtime_test);
} }
free (exclusive); free (exclusive);
free (service);
free (applet); free (applet);
free (prefix); free (prefix);
free (softlevel); free (softlevel);
@ -999,13 +1000,18 @@ int runscript (int argc, char **argv)
eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s", argv[0], eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s", argv[0],
strerror (errno)); 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); atexit (cleanup);
/* Change dir to / to ensure all init scripts don't use stuff in pwd */ /* Change dir to / to ensure all init scripts don't use stuff in pwd */