Bug 67971 - systemd-run splits ARGS with spaces
Summary: systemd-run splits ARGS with spaces
Status: RESOLVED FIXED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Zbigniew Jedrzejewski-Szmek
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-10 03:37 UTC by redneb
Modified: 2013-09-10 11:21 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description redneb 2013-08-10 03:37:56 UTC
When I am issuing the following command
  systemd-run /bin/sh -c 'sleep 5'
it doesn't work as expected, instead it gives the following:

Aug 09 23:18:00 vmg systemd[1]: Starting /bin/sh -c sleep 5...
Aug 09 23:18:00 vmg systemd[1]: Started /bin/sh -c sleep 5.
Aug 09 23:18:00 vmg sh[537]: sleep: missing operand
Aug 09 23:18:00 vmg sh[537]: Try 'sleep --help' for more information.
Aug 09 23:18:00 vmg systemd[1]: run-536.service: main process exited, code=exited, status=1/FAILURE
Aug 09 23:18:00 vmg systemd[1]: Unit run-536.service entered failed state.

It seems that systemd-run splits the 'sleep 5' and executes
  /bin/sh -c sleep 5
instead of
  /bin/sh -c 'sleep 5'

Is this the expected behavior?
Comment 1 Harald Hoyer 2013-08-30 10:15:35 UTC
Workaround for now:

# systemd-run /bin/sh -c \'sleep 5\'
or
# systemd-run /bin/sh -c "'sleep 5'"
Comment 3 Zbigniew Jedrzejewski-Szmek 2013-09-09 18:58:26 UTC
Fixed in http://cgit.freedesktop.org/systemd/systemd/commit/?id=a6fde353.
Comment 4 Harald Hoyer 2013-09-10 08:42:06 UTC
You remove the empty "ExecStart=", which basically clears all previous ExecStart!

- fputs("ExecStart=", f);

Please add it back.
Comment 5 Zbigniew Jedrzejewski-Szmek 2013-09-10 11:21:32 UTC
(In reply to comment #4)
> You remove the empty "ExecStart=", which basically clears all previous
> ExecStart!
> 
> - fputs("ExecStart=", f);
> 
> Please add it back.
Hm, I admit that I'm not sure what the empty ExecStart line is for, don't we create the unit from scratch and can't we put anything we want in the ExecStart line right from the beginning?

Nevertheless, I didn't touch it. If I do:

sudo systemd-run /bin/sleep " 100000"

I have:

==> /run/systemd/system/run-3233.service.d/90-ExecStart.conf <==
[Service]
ExecStart=
ExecStart=@/bin/sleep "/bin/sleep" " 100000"

and before my changes:

==> /run/systemd/system/run-4335.service.d/90-ExecStart.conf <==
[Service]
ExecStart=
ExecStart=@/bin/sleep /bin/sleep  100000

Seems to be the same, module the bug, or am I missing something?


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.