From 4bdfccc2c2b2fa67d52f62e62775fc00cb5c0599 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Wed, 30 Jan 2008 12:50:44 +0000 Subject: Fix adding net scripts to the boot runlevel. --- src/librc/librc.c | 14 ++++++++------ 1 file 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), -- cgit v1.2.3