diff options
-rw-r--r-- | src/librc/librc.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/librc/librc.c b/src/librc/librc.c index 7093ddab..dbbdbb5e 100644 --- a/src/librc/librc.c +++ b/src/librc/librc.c @@ -765,18 +765,20 @@ bool rc_service_add (const char *runlevel, const char *service) /* We need to ensure that only things in /etc/init.d are added * to the boot runlevel */ if (strcmp (runlevel, RC_LEVEL_BOOT) == 0) { - char tmp[MAXPATHLEN]; + char tmp[MAXPATHLEN] = { '\0' }; + char *p; - if (! realpath (init, tmp)) + p = realpath (dirname (init), tmp); + free (init); + if (! *p) return (false); - retval = (strcmp (dirname (tmp), RC_INITDIR) == 0); + + retval = (strcmp (tmp, RC_INITDIR) == 0); if (! retval) { - free (init); errno = EPERM; return (false); } - free (init); - init = xstrdup (tmp); + init = rc_strcatpaths (RC_INITDIR, service, (char *) NULL); } file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename_c (service), |