I have severe doubts that the following is what depend() is intended to do: $ cd /etc/init.d $ /etc/init.d/local depend after bin boot camlp5 dev etc home lib lib32 lib64 logit media opt proc root sbin srv sys tmp usr var keyword -timeout Reproducible: Always Steps to Reproduce: 1. Run the above commands 2. Wonder whether the output is really what it is supposed to be 3. Blame me for a bogus bug if openrc never uses the depend action like I did Actual Results: The "*" in "before"/"after" clauses within a depend() in a service script always expands to the entries of the file system's root directory. Expected Results: If "*" shall expand at all, I expect it to rather expand to the entries of the /etc/init.d directory. I encountered that problem when writing a script to analyze the openrc service dependencies and looked for a way to extract the information contained in the depend() functions of the service script. I soon found out that just calling the service script with "depend" as the argument seems to display this information. However, in all entries which use a "*", this is expanded by all entries of the root directory. Obviously, the service helper /sbin/runscript runs the depend() function as a normal shell function, where the "*" is expanded by the contents of the current directory. If this current directory were /etc/init.d/, this would expand to the names of all service scripts - what the documented semantics of "*" also suggests. However, obviously /sbin/runscript runs the depend() function rather from directory "/", where the "*" expands to all top-level directory names instead. I am not sure whether this bug report is valid, because it might very well be that openrc never calls depend as a service script action like I did. If it does, however, then this would be a bug which renders the "after *" / "before *" clauses in all depend() essentially ineffective. In this case, the problem should also be rather simple to fix: /sbin/runscript just needs to do a "cd /etc/init.d" just before running depend(). Then "*" would expand to the names of all the services.
Created attachment 309529 [details] Output of emerg --info
Fixed through commit: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=9d0dce3 Thank you for your bug report! :)
I am concerned about the fix that was committed for this issue. The fix does a cd to the init.d directory for all commands that the service runs, not just depend. This means that for any command an init script writer defines we are starting them out in the init.d directory instead of /. I"m not sure that is an assumption we should make, because I think it could potentially break init scripts.
idl0r: NAK on that fix. We really need something that scans the directory better, and excludes: - tempfiles - anything not executable - anything that doesn't start with runscript.
(In reply to comment #4) > idl0r: > NAK on that fix. > We really need something that scans the directory better, and excludes: > - tempfiles > - anything not executable > - anything that doesn't start with runscript. I was already thinking about that but that will be more difficult.. Best case would be to disable globbing temp. and expand the "*" ourself but in this case you'd have to disable the globbing in the depend() function.
All, I have added commit 8d63719 on top of idl0r's commit. This allows the reporter to do what he was requesting, so I would like to close this bug and put it on the tracker. I think the enhancements requested in this bug can go to a separate bug. Thoughts?
(In reply to comment #6) you should be using pushd/popd, and quoting the path, rather than hardcoding / however, the '*' really should be expanded by openrc itself and not left to the shell. it's easy enough to use `set -f` to disable pathname expansion before evaluating the depend function.