Fix adding net scripts to the boot runlevel.

This commit is contained in:
Roy Marples 2008-01-30 12:50:44 +00:00
parent c1d18354c6
commit 4bdfccc2c2

View File

@ -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 /* We need to ensure that only things in /etc/init.d are added
* to the boot runlevel */ * to the boot runlevel */
if (strcmp (runlevel, RC_LEVEL_BOOT) == 0) { 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);
return (false);
retval = (strcmp (dirname (tmp), RC_INITDIR) == 0);
if (! retval) {
free (init); free (init);
if (! *p)
return (false);
retval = (strcmp (tmp, RC_INITDIR) == 0);
if (! retval) {
errno = EPERM; errno = EPERM;
return (false); return (false);
} }
free (init); init = rc_strcatpaths (RC_INITDIR, service, (char *) NULL);
init = xstrdup (tmp);
} }
file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename_c (service), file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename_c (service),