A quote from the inittab man page: --- Please note that including certain characters in the process field will result in init attempting to launch a shell to interpret the command contained in the process field. The characters which will trigger a shell are: ˜‘!$ˆ&*()=|}[]; --- According to this quote, inittab should support command chaining. Add this to /etc/inittab: ww:c:once:echo TEST1a ; echo TEST1b wx:c:once:echo TEST2a && echo TEST2b wy:c:once:/bin/false || echo TEST3 wz:c:once:echo TEST4 > /dev/tty11 Then run: telinit c Expected output: TEST1a TEST1b TEST2a TEST2b TEST3 ... on current console and: TEST4 ... on tty11 Actual output: TEST1a TEST2a There is no TEST1b, TEST2b, TEST3 or TEST4. Thank you.
Looking at the source (init.c line 1103) it seems to be a logic error: sysvinit does spawn a shell (as documented), but first it prepends "exec " to the whole command line (this part isn't), which smells like premature optimization to me. That means the only way it's ever going to execute more than one command is if you shell-inject a prefix that causes the exec to fail. I don't have any sysvinit systems, but I'm pretty confident that if you add "wv:c:once:/notfound && echo TEST5" it'll produce output.
I'm using sh -c "command && command", but I'm hoping this gets fixed.
Is this the source you're looking at? https://github.com/slicer69/sysvinit/ What's the procedure in this case? Should I report it there?
(In reply to Marius Dinu from comment #3) > Is this the source you're looking at? > https://github.com/slicer69/sysvinit/ > > What's the procedure in this case? Should I report it there? I'm going by what `emerge --fetchonly sysvinit` grabbed, which looks to be that one. The git log says this code's been like that for 15+ years (probably much longer, as github seems to be showing incomplete history), but I'd say go ahead and report it there anyway. Fixing this has a small but non-zero chance of surprising people inadvertently reliant on the broken behaviour, but that'd also happen if they switched to something else with inittab support (busybox, systemd, upstart).
Yes, please do (and link it here).
https://github.com/slicer69/sysvinit/issues/25 Waiting for v3.11 release. The command chaining fix is here: https://github.com/slicer69/sysvinit/commit/24234e7eb320e59d5944281024e3246c1827cdd7 The man page fix is here: https://github.com/slicer69/sysvinit/commit/65cac9970edd3be9d671719300a4ce4b6c7aeb85 I'm going to test them this weekend, ahead of official release.
Many thanks.
sysvinit-3.12-r1.ebuild is available. Closing this issue.