]> git.ipfire.org Git - thirdparty/systemd.git/commit - man/systemd.exec.xml
core/execute: add the magic character '!' to allow privileged execution (#3493)
authorAlessandro Puccetti <alessandro@kinvolk.io>
Fri, 10 Jun 2016 16:19:54 +0000 (18:19 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 10 Jun 2016 16:19:54 +0000 (18:19 +0200)
commitcf677fe6868f0565dd625cfbc2992a0f2cd3e053
tree3e6d5cdbf44a06a1c48d3d6e98f3192b08ae723b
parenta4e9499d8d205ab580b463882fdccce340c79434
core/execute: add the magic character '!' to allow privileged execution (#3493)

This patch implements the new magic character '!'. By putting '!' in front
of a command, systemd executes it with full privileges ignoring paramters
such as User, Group, SupplementaryGroups, CapabilityBoundingSet,
AmbientCapabilities, SecureBits, SystemCallFilter, SELinuxContext,
AppArmorProfile, SmackProcessLabel, and RestrictAddressFamilies.

Fixes partially https://github.com/systemd/systemd/issues/3414
Related to https://github.com/coreos/rkt/issues/2482

Testing:
1. Create a user 'bob'
2. Create the unit file /etc/systemd/system/exec-perm.service
   (You can use the example below)
3. sudo systemctl start ext-perm.service
4. Verify that the commands starting with '!' were not executed as bob,
   4.1 Looking to the output of ls -l /tmp/exec-perm
   4.2 Each file contains the result of the id command.

`````````````````````````````````````````````````````````````````
[Unit]
Description=ext-perm

[Service]
Type=oneshot
TimeoutStartSec=0
User=bob
ExecStartPre=!/usr/bin/sh -c "/usr/bin/rm /tmp/exec-perm*" ;
    /usr/bin/sh -c "/usr/bin/id > /tmp/exec-perm-start-pre"
ExecStart=/usr/bin/sh -c "/usr/bin/id > /tmp/exec-perm-start" ;
    !/usr/bin/sh -c "/usr/bin/id > /tmp/exec-perm-star-2"
ExecStartPost=/usr/bin/sh -c "/usr/bin/id > /tmp/exec-perm-start-post"
ExecReload=/usr/bin/sh -c "/usr/bin/id > /tmp/exec-perm-reload"
ExecStop=!/usr/bin/sh -c "/usr/bin/id > /tmp/exec-perm-stop"
ExecStopPost=/usr/bin/sh -c "/usr/bin/id > /tmp/exec-perm-stop-post"

[Install]
WantedBy=multi-user.target]
`````````````````````````````````````````````````````````````````
man/systemd.exec.xml
man/systemd.service.xml
src/core/execute.c
src/core/execute.h
src/core/load-fragment.c