]> git.ipfire.org Git - thirdparty/systemd.git/commit
selinux: fix regression of systemctl subcommands when absolute unit file paths are... 1044/head
authorHATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
Wed, 26 Aug 2015 03:07:31 +0000 (12:07 +0900)
committerHATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
Wed, 26 Aug 2015 06:00:05 +0000 (15:00 +0900)
commit9fa7c1aeb9ec7e9d9f35184ce5c9d334f057d9de
tree292f70b28c5f121e717cad73e217b977f2ead54b
parent7c268a04894852b6aa564668014fe6e070d590be
selinux: fix regression of systemctl subcommands when absolute unit file paths are specified

The commit 4938696301a914ec26bcfc60bb99a1e9624e3789 overlooked the
fact that unit files can be specified as unit file paths, not unit
file names, wrongly passing a unit file path to the 1st argument of
manager_load_unit() that handles it as a unit file name. As a result,
the following 4 systemctl subcommands:

    enable
    disable
    reenable
    link
    mask
    unmask

fail with the following error message:

    # systemctl enable /usr/lib/systemd/system/kdump.service
    Failed to execute operation: Unit name /usr/lib/systemd/system/kdump.service is not valid.
    # systemctl disable /usr/lib/systemd/system/kdump.service
    Failed to execute operation: Unit name /usr/lib/systemd/system/kdump.service is not valid.
    # systemctl reenable /usr/lib/systemd/system/kdump.service
    Failed to execute operation: Unit name /usr/lib/systemd/system/kdump.service is not valid.
    # cp /usr/lib/systemd/system/kdump.service /tmp/
    # systemctl link /tmp/kdump.service
    Failed to execute operation: Unit name /tmp/kdump.service is not valid.
    # systemctl mask /usr/lib/systemd/system/kdump.service
    Failed to execute operation: Unit name /usr/lib/systemd/system/kdump.service is not valid.
    # systemctl unmask /usr/lib/systemd/system/kdump.service
    Failed to execute operation: Unit name /usr/lib/systemd/system/kdump.service is not valid.

To fix the issue, first check whether a unit file is passed as a unit
file name or a unit file path, and then pass the unit file to the
appropreate argument of manager_load_unit().

By the way, even with this commit mask and unmask reject unit file
paths as follows and this is a correct behavior:

    # systemctl mask /usr/lib/systemd/system/kdump.service
    Failed to execute operation: Invalid argument
    # systemctl unmask /usr/lib/systemd/system/kdump.service
    Failed to execute operation: Invalid argument
src/core/selinux-access.c