Summary: | =sys-apps/openrc-0.9.4 : init scripts can't be executed from /etc/init.d/ directory | ||
---|---|---|---|
Product: | Gentoo Hosted Projects | Reporter: | Nathaniel <nathaniel> |
Component: | OpenRC | Assignee: | OpenRC Team <openrc> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | galandilias, veejar.net |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Bug Depends on: | |||
Bug Blocks: | 394205 |
Description
Nathaniel
2011-11-29 20:06:31 UTC
confirmed here confirmed I confirm this as well on i686 (32-bit) OpenRC 0.9.4. Adding `pwd' to the start of runscript.sh, it appears that the pwd is set to the root directory when runscript calls runscript.sh. This is the cause of the error that occurs. Line 1129 of runscript.c shows why this is happening: 1128 /* Change dir to / to ensure all init scripts don't use stuff in pwd */ 1129 if (chdir("/") == -1) 1130 eerror("chdir: %s", strerror(errno)); Obviously this breaks scripts called using a relative path. To fix this, I propose: --- a/src/rc/runscript.c +++ b/src/rc/runscript.c @@ -1122,1 +1122,1 @@ runscript(int argc, char **argv) - service = xstrdup(argv[1]); + service = realpath(argv[1], NULL); (In reply to comment #3) > I confirm this as well on i686 (32-bit) OpenRC 0.9.4. > > Adding `pwd' to the start of runscript.sh, it appears that the pwd is set to > the root directory when runscript calls runscript.sh. This is the cause of the > error that occurs. > > Line 1129 of runscript.c shows why this is happening: > 1128 /* Change dir to / to ensure all init scripts don't use stuff in > pwd */ > 1129 if (chdir("/") == -1) > 1130 eerror("chdir: %s", strerror(errno)); > > Obviously this breaks scripts called using a relative path. To fix this, I > propose: > --- a/src/rc/runscript.c > +++ b/src/rc/runscript.c > @@ -1122,1 +1122,1 @@ runscript(int argc, char **argv) > - service = xstrdup(argv[1]); > + service = realpath(argv[1], NULL); I just tested this, and it breaks any script in /etc/init.d that is a symbolic link, e.g. net.eth0. So we can't use this proposal. This is fixed in git, commit 5e01051. Thanks for the report. |