If adding to the boot runlevel, ensure that the realpath of the resolved service points to /etc/init.d/$service
This commit is contained in:
parent
0b5d44af8d
commit
c6774d1c74
@ -765,14 +765,18 @@ 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 = xstrdup (init);
|
char tmp[MAXPATHLEN];
|
||||||
|
|
||||||
|
if (! realpath (init, tmp))
|
||||||
|
return (false);
|
||||||
retval = (strcmp (dirname (tmp), RC_INITDIR) == 0);
|
retval = (strcmp (dirname (tmp), RC_INITDIR) == 0);
|
||||||
free (tmp);
|
|
||||||
if (! retval) {
|
if (! retval) {
|
||||||
free (init);
|
free (init);
|
||||||
errno = EPERM;
|
errno = EPERM;
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
free (init);
|
||||||
|
init = xstrdup (tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename_c (service),
|
file = rc_strcatpaths (RC_RUNLEVELDIR, runlevel, basename_c (service),
|
||||||
|
Loading…
Reference in New Issue
Block a user