Bug 1296288 - tmpfiles: don't follow symlinks when adjusting ACLs, fille attributes…
tmpfiles: don't follow symlinks when adjusting ACLs, fille attributes…
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: systemd (Show other bugs)
7.2
All Linux
unspecified Severity medium
: rc
: ---
Assigned To: systemd-maint
Branislav Blaškovič
:
Depends On:
Blocks: 1203710 1289485 1313485 1559762 1559765
  Show dependency treegraph
 
Reported: 2016-01-06 14:42 EST by Robert Scheck
Modified: 2018-03-23 05:03 EDT (History)
7 users (show)

See Also:
Fixed In Version: systemd-219-21.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1559762 (view as bug list)
Environment:
Last Closed: 2016-11-03 20:50:14 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Robert Scheck 2016-01-06 14:42:47 EST
Description of problem:
systemd-tmpfiles doesn't create symlinks with correct ownership but always
with root, example:

/usr/lib/tmpfiles.d/mimedefang.conf contains the line:

L+ /var/spool/MIMEDefang/.razor/razor-agent.log - defang defang - /dev/null

The result however is, that /var/spool/MIMEDefang/.razor/razor-agent.log is
owned by root:root rather defang:defang. So it feels like the needed "chown 
--no-dereference defang:defang" is not performed by systemd-tmpfiles, which
I believe is a bug (because I was unable in the documentation of systemd to
find a pointer which says that different ownership is not allowed).

Version-Release number of selected component (if applicable):
systemd-219-19.el7
mimedefang-2.78-5.el7

Actual results:
L+ /var/spool/MIMEDefang/.razor/razor-agent.log - defang defang - /dev/null
leads to root:root owned symlink.

Expected results:
L+ /var/spool/MIMEDefang/.razor/razor-agent.log - defang defang - /dev/null
should lead to defang:defang owned symlink.
Comment 1 Robert Scheck 2016-01-06 14:45:44 EST
Cross-filed case 01562812 on the Red Hat customer portal.
Comment 3 Lukáš Nykrýn 2016-01-07 11:16:44 EST
Why so you want to change the owner of the symlink? Even normal chown follows the symlinks and does not change the permission of it.

This behavior is expected:
https://github.com/systemd/systemd/blob/master/src/tmpfiles/tmpfiles.c#L626
Comment 4 Lukáš Nykrýn 2016-01-07 11:21:58 EST
In systemd in rhal we don't have that check, so we might end chowning the target.

So we should backport https://github.com/systemd/systemd/commit/48b8aaa82724bc2d8440470f414fb0d2416f29c7
Comment 5 Robert Scheck 2016-01-07 12:16:22 EST
If I'm able to specify permissions for L+, my personal expectation is that
these permissions are applied to the symlink, not to the target. And given
the second commit, it doesn't seem to be really that much expected (for the
target). But what sense does it make to be able to specific access mode and 
ownership for a symlink, if it does not get applied at all (second commit)?
Comment 6 Robert Scheck 2016-01-07 12:39:08 EST
From what I can see, Z follows symlinks (even the documentation at
http://www.freedesktop.org/software/systemd/man/tmpfiles.d.html says
different). Having:

Z /var/spool/MIMEDefang 0750 defang defang - -
d /var/spool/MIMEDefang/.razor 0750 defang defang - -
L+ /var/spool/MIMEDefang/.razor/razor-agent.log - - - - /dev/null

leads to /dev/null with permissions 750 defang:defang. If I disable
the first line, /dev/null has correct permissions again. This needs
IMHO either to be fixed or to be clarified in the documentation. The

L+ /var/spool/MIMEDefang/.razor/razor-agent.log - defang defang - /dev/null

line by itself does not chown the target but does also not chown the
symlink. If that is expected behaviour, at least the documentation
should mention that setting owner/group for L+ doesn't do anything...
Comment 7 Jan Synacek 2016-01-13 02:37:11 EST
(In reply to Robert Scheck from comment #6)
> line by itself does not chown the target but does also not chown the
> symlink. If that is expected behaviour, at least the documentation
> should mention that setting owner/group for L+ doesn't do anything...

Quoting symlink(2):

The  permissions of a symbolic link are irrelevant; the ownership is ignored when following the link, but is checked when removal or renaming of the link is requested and the link is in a directory with the sticky bit (S_ISVTX) set.


But, as you mention, it would be nice to emphasize this behavior in the man pages, as it might not be obvious.
Comment 8 Jan Synacek 2016-01-13 08:44:12 EST
In addition to the patch in comment 4, we should also backport https://github.com/systemd/systemd/commit/0aaa263f1651cab2ae1a02ae64cbf523b21fb6e1.
Comment 9 Robert Scheck 2016-01-13 08:46:58 EST
By the way, given comment #7 regarding that the ownership might matter, it
IMHO should be possible to set a different ownership via systemd-tmpfiles.
Comment 10 Lukáš Nykrýn 2016-01-13 09:01:18 EST
Create a symlink in /tmp and allow a specific user or group to remove it. 
To be honest I can't imagine a real use-case for that.
Comment 12 Robert Scheck 2016-03-22 07:10:01 EDT
Given I got a reminder via the support ticket: What exactly will be fixed/
changed using this RHBZ? Per comment #10, my original request won't happen
I guess?
Comment 14 Lukáš Nykrýn 2016-03-23 08:54:59 EDT
https://github.com/lnykryn/systemd-rhel/pull/14
Comment 15 Lukáš Nykrýn 2016-04-04 02:33:12 EDT
Pushed to staging -> post
Comment 17 Branislav Blaškovič 2016-09-01 06:46:59 EDT
NEW VERSION:

:: [   LOG    ] :: Package versions:
:: [   LOG    ] ::   systemd-219-27.el7.x86_64
:: [   PASS   ] :: Creating tmp directory (Expected 0, got 0)
:: [   PASS   ] :: Command 'pushd /tmp/tmp.JwI6Bkx2nJ' (Expected 0, got 0)
:: [   PASS   ] :: Command 'useradd foo' (Expected 0, got 0)
:: [   PASS   ] :: Command 'groupadd bar' (Expected 0, got 0)
:: [   LOG    ] :: Duration: 0s
:: [   LOG    ] :: Assertions: 5 good, 0 bad
:: [   PASS   ] :: RESULT: Setup

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: bug 1296288
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   PASS   ] :: Command 'systemd-tmpfiles --create' (Expected 0, got 0)
:: [   PASS   ] :: Command 'ls -l  /run/hello2/' (Expected 0, got 0)
:: [   PASS   ] :: File '/var/tmp/tmp.1m3e8oXcb5' should contain 'root.*root.* hello2.test$'
:: [   PASS   ] :: File '/var/tmp/tmp.1m3e8oXcb5' should contain 'root.*root.* hello2.link -> /run/hello2/hello2.test$'
:: [   LOG    ] :: Duration: 0s
:: [   LOG    ] :: Assertions: 4 good, 0 bad
:: [   PASS   ] :: RESULT: bug 1296288


OLD VERSION:
:: [   LOG    ] :: Package versions:
:: [   LOG    ] ::   systemd-219-19.el7.x86_64
:: [   PASS   ] :: Creating tmp directory (Expected 0, got 0)
:: [   PASS   ] :: Command 'pushd /tmp/tmp.3mOpnl39DI' (Expected 0, got 0)
:: [   PASS   ] :: Command 'useradd foo' (Expected 0, got 0)
:: [   PASS   ] :: Command 'groupadd bar' (Expected 0, got 0)
:: [   LOG    ] :: Duration: 1s
:: [   LOG    ] :: Assertions: 5 good, 0 bad
:: [   PASS   ] :: RESULT: Setup

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: bug 1296288
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   PASS   ] :: Command 'systemd-tmpfiles --create' (Expected 0, got 0)
:: [   PASS   ] :: Command 'ls -l  /run/hello2/' (Expected 0, got 0)
:: [   FAIL   ] :: File '/var/tmp/tmp.0cFDE8bNiY' should contain 'root.*root.* hello2.test$'
:: [   PASS   ] :: File '/var/tmp/tmp.0cFDE8bNiY' should contain 'root.*root.* hello2.link -> /run/hello2/hello2.test$'
:: [   LOG    ] :: Duration: 1s
:: [   LOG    ] :: Assertions: 3 good, 1 bad
:: [   FAIL   ] :: RESULT: bug 1296288


Verified...
Comment 19 errata-xmlrpc 2016-11-03 20:50:14 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2216.html

Note You need to log in before you can comment on or make changes to this bug.