[systemd-devel] StartTransientService problems

Barry Scott barry.scott at onelan.co.uk
Wed Feb 5 19:27:15 CET 2014


On Wed 05 Feb 2014 02:07:33 Lennart Poettering wrote:
> On Fri, 31.01.14 16:42, Barry Scott (barry.scott at onelan.co.uk) wrote:
> > I have finally managed to get StartTransientService to run a process for
> > me
> > but I'm encountering issues:
> > 
> > we start a daemon that calls StartTransientService as required. The daemon
> > does not run as root, it runs as "onelan". We configure dbus to allow
> > "onelan" to call all systemd Manager APIs.
> > 
> > I want to set the User, Nice and Type of the service. I get the errors:
> > 
> > DBusException: org.freedesktop.DBus.Error.PropertyReadOnly: Cannot set
> > property User, or unknown property.
> > 
> > DBusException: org.freedesktop.DBus.Error.PropertyReadOnly: Cannot set
> > property Type, or unknown property.
> > 
> > DBusException: org.freedesktop.DBus.Error.PropertyReadOnly: Cannot set
> > property Nice, or unknown property.
> > 
> > What do I need to do to allow these properties to be set?
> > 
> > I also need to set the Environment. I can pass the environment in as a
> > property but it does not show up the the process created or in
> > systemctl status for the transient service. I do not see any messages in
> > the systemd logging.
> 
> These options weren't settable so far for transient units, because I was
> too lazy to make them settable. ;-)
> 
> I have added this in now:
> 
> http://cgit.freedesktop.org/systemd/systemd/commit/?id=c7040b5d1c2c148f12b6a
> 5eef3dfce1661805131

Thanks you for adding this. I'm attempting to test the patch.
I have built from git the latest code on a F20 system.
I then created a tar ball of the make install DESTDIR=tmp
and explored that tar ball over a F20 working system.

But I am hitting 2 issues:
1) We cannot call sched_setscheduler() in spite of the cpu cgroup being setup 
correctly (e.g. works with systemd-208):
# grep . /sys/fs/cgroup/cpu/onelan.slice/onelan-screen.slice/cpu.rt*
/sys/fs/cgroup/cpu/onelan.slice/onelan-
screen.slice/cpu.rt_period_us:1000000000
/sys/fs/cgroup/cpu/onelan.slice/onelan-
screen.slice/cpu.rt_runtime_us:900000000

2) When I call StartTransientUnit I get a permission error:
DBusException: org.freedesktop.DBus.Error.AccessDenied: Access to 
org.freedesktop.systemd1.Manager.StartTransientUnit() not permitted.

I have the following setup
(copied from /etc/dbus-1/system.d/org.freedesktop.systemd1.conf):

# cat /etc/dbus-1/system.d/ONELAN-systemd.conf 
<?xml version="1.0"?>
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 
1.0//EN"
    "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">

<busconfig>
        <policy user="onelan">
                <allow own="org.freedesktop.systemd1"/>

                <!-- Onelan clients can do everything -->
                <allow send_destination="org.freedesktop.systemd1"/>
                <allow receive_sender="org.freedesktop.systemd1"/>

                <!-- systemd may receive activator requests -->
                <allow receive_interface="org.freedesktop.systemd1.Activator"
                       receive_member="ActivationRequest"/>
        </policy>

</busconfig>

Which should have allowed the process running as "onelan" user to call
StartTransientUnit.

> 
> Which should make them available via the bus for transient units. If you
> need other props like this, just let me know and I'll add them too...
> 
> > And lastly what do I have to do to remove the transient service from
> > systemd after the last process in the service exits? RemainAfterExit=no
> 
> RemainAfterExit=no is already available?

Transient services that fail persist until you reboot the system.
This can be shown by using systemd-run to run /bin/true and /bin/false
all the /bin/true are removed but the /bin/false cannot be removed.

# systemd-run --desc false /bin/false
Running as unit run-1073.service.

# systemctl status run-1073.service
run-1073.service - false
   Loaded: loaded (/run/systemd/system/run-1073.service; static)
  Drop-In: /run/systemd/system/run-1073.service.d
           └─90-Description.conf, 90-ExecStart.conf, 90-RemainAfterExit.conf, 
90-SendSIGHUP.conf
   Active: failed (Result: exit-code) since Wed 2014-02-05 18:21:51 GMT; 12s 
ago
  Process: 1074 ExecStart=/bin/false (code=exited, status=1/FAILURE)
 Main PID: 1074 (code=exited, status=1/FAILURE)

Feb 05 18:21:51 localhost.localdomain systemd[1]: Starting false...
Feb 05 18:21:51 localhost.localdomain systemd[1]: Started false.
Feb 05 18:21:51 localhost.localdomain systemd[1]: run-1073.service: main 
process exited, code=exited, status=1/FAILURE
Feb 05 18:21:51 localhost.localdomain systemd[1]: Unit run-1073.service 
entered failed state.

# systemctl --full |grep ^run
run-1073.service                                                                          
loaded failed failed    false

# systemctl  stop run-1073.service

# systemctl --full |grep ^run
run-1073.service                                                                          
loaded failed failed    false


Barry





More information about the systemd-devel mailing list