[systemd-devel] Supporting ExecStartPre= and friends in `systemctl set-property` or `systemd-run -p`

Richard Maw richard.maw at codethink.co.uk
Fri May 15 03:36:54 PDT 2015


On Fri, May 15, 2015 at 12:10:58PM +0200, Lennart Poettering wrote:
> On Fri, 15.05.15 13:03, Ivan Shapovalov (intelfx100 at gmail.com) wrote:
> > Hm. Actually, usage of *any* token as a command line separator makes it
> > impossible to include that token *in* the command line. My original
> > idea is even worse as it disallows ever giving "--aux-unit" switch to
> > the client program. So I guess I retract that idea...
> > What about the second one?
> 
> Well, I think this isn't too bad, we could devise a simple escaping
> scheme to cover this. For example, if we use "--" as separator, then
> we could tell people to escape this as "\--" (which on the shell would
> become "\\--") if they actually want it included in the command
> line...
> 
> I much prefer a syntax like this over reading things from arbitrary
> files I must say...

Is there precedent in any other commonly used command that could be used
instead? I've never seen anything that required escaping like this before, and
I'd prefer something that had common behaviour with something that is already
used.

Some options I've thought of are:

1.  Accept the command to run as a single string, `sh -c` style and parse it.
    Parsing it like an ExecStart= line would be nice for consistency.

    systemd-run --name=foo.service '/bin/foo arg -- arg2' -- \
                --name=bar.service -p Nice=80 /bin/bar -- \
                -p Nice=20 --name=bazz.service '/usr/bin/bazz arg1 -- arg2'

2.  Require the argv of the command to be run to have each argument prefixed by
    an option, such as --arg, like how you pass -Wl,option to the linker on gcc's
    command-line.

    systemd-run --name=foo.service \
                  --arg /bin/foo --arg arg --arg -- --arg arg2 -- \
                --name=bar.service -p Nice=80 \
                  --arg /bin/bar -- \
                -p Nice=20 --name=bazz.service
                  --arg /usr/bin/bazz --arg arg1 --arg -- --arg arg2

3.  Require that if users need to embed the separator in their command, that
    they use `sh -c`.

    systemd-run --name=foo.service /bin/sh -c '/bin/foo arg -- arg2' -- \
                --name=bar.service -p Nice=80 /bin/bar -- \
                -p Nice=20 --name=bazz.service
                /bin/sh -c '/usr/bin/bazz arg1 -- arg2'


More information about the systemd-devel mailing list