Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1188065

Summary: No possibility to run saslauthd as non-root (ie as saslauth user)
Product: Red Hat Enterprise Linux 7 Reporter: Milan Kerslager <milan.kerslager>
Component: cyrus-saslAssignee: Jakub Jelen <jjelen>
Status: CLOSED ERRATA QA Contact: Stanislav Zidek <szidek>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: jjelen, ksrot, pkis, plautrba, systemd-maint
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: cyrus-sasl-2.1.26-18.el7 Doc Type: Bug Fix
Doc Text:
Cause: Runtime directory for saslauthd was unconditionally owned by root. Consequence: If customer wanted to run authentication daemon as non-root user, it was not possible without complicated workarounds Fix: Create directory in runtime by systemd based on actual settings of Service Unit file. Result: The saslauthd daemon is able to run with non-root user.
Story Points: ---
Clone Of:
: 1189203 (view as bug list) Environment:
Last Closed: 2015-11-19 09:15:28 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1110700, 1191021    

Description Milan Kerslager 2015-02-01 23:01:11 UTC
The saslauthd daemon should be running as root only with "pam" authentication method selected (see saslauthd(8)). For other authentication methods there is the user "saslauth" the daeom should be run as.
But now there is no possibility how to run saslauthd as another user (AFAIK). In RHEL6, there is a line for this purpose in the /etc/sysconfig/saslauthd file (should be uncommented to take effect):

# DAEMONOPTS="--user saslauth"

But in RHEL7, this option is lost. Running saslauthd as root is potentionally dangerous and unnecessary. 

Also the directory /run/saslauthd should be owned by the user saslauth. If saslauthd is running as root, the ownership does not matter. But if the daemon is running as non-privileged user saslauth, the saslauthd daemon is unable to create socket in this directory. The user is able to change ownership, but any update of this package will break working setup by reverting ownership of the directory back to root.

Just FYI, I filled similar bug #1188062 few minutes ago for RHEL6.

Comment 2 Petr Lautrbach 2015-02-04 16:43:42 UTC
Thank you for your report, Milan.

DEAMONOPTS is not used anymore since we use systemd units instead of SysV initscripts. The systemd way is to use User= and Group= options in an unit file as you can see in the following example:

# mkdir /etc/systemd/system/saslauthd.service.d
# cat > /etc/systemd/system/saslauthd.service.d/user.conf <<EOF
[Service]
User=saslauth
Group=saslauth
EOF
# systemctl daemon-reload
# systemctl start saslauthd
# systemctl status saslauthd -l
saslauthd.service - SASL authentication daemon.
   Loaded: loaded (/usr/lib/systemd/system/saslauthd.service; disabled)
  Drop-In: /etc/systemd/system/saslauthd.service.d
           └─user.conf
   Active: active (running) since Wed 2015-02-04 17:23:16 CET; 8s ago
  Process: 10103 ExecStart=/usr/sbin/saslauthd -m $SOCKETDIR -a $MECH $FLAGS (code=exited, status=0/SUCCESS)
 Main PID: 10104 (saslauthd)


 With regards to the /run/saslauth, it's really a bug and it will be fixed in the next package update. In the mean time, you can use the following workaround:

# cat > /etc/tmpfiles.d/saslauthd.conf <<EOF
d /run/saslauthd 0755 saslauth saslauth -
EOF
# systemd-tmpfiles --create /etc/tmpfiles.d/saslauthd.conf
# ls -ld /run/saslauthd/
drwxr-xr-x. 2 saslauth saslauth 80 Feb  4 17:38 /run/saslauthd/

Comment 5 Stanislav Zidek 2015-07-10 10:16:56 UTC
Directory /run/saslauthd/ is created with correct group by installation and update. However, if the directory is not there, it is created by saslauthd during its start - but with incorrect group (root).

    # service saslauthd stop; service saslauthd stop; rm -rf /run/saslauthd/; ls -ld /run/sasl*
    Redirecting to /bin/systemctl stop  saslauthd.service
    Redirecting to /bin/systemctl stop  saslauthd.service
    ls: cannot access /run/sasl*: No such file or directory
     
    # service saslauthd start; ls -ld /run/sasl*
    Redirecting to /bin/systemctl start  saslauthd.service
    drwxr-xr-x. 2 root root 100 Jul 10 05:20 /run/saslauthd
     
    # rpm -qa cyrus-sasl\*
    cyrus-sasl-lib-2.1.26-18.el7.x86_64
    cyrus-sasl-plain-2.1.26-18.el7.x86_64
    cyrus-sasl-2.1.26-18.el7.x86_64

Comment 6 Jakub Jelen 2015-07-13 14:11:00 UTC
Hmm. Awesome tmpfiles.d. There is hardcoded creation of such directory in saslauthd daemon, but it doesn't work if we want specific mode and owners without many awful hacks (changing umask, group) and again superuser privileges.

The ideal way would be if tmpfiles and systemd would take care of this directory. RuntimeDirectory=  option would be best option, but it is not available in RHEL7 version of systemd. Looks like we are not the only having this problem:
https://bugs.freedesktop.org/show_bug.cgi?id=69097

Possibility is to use this line in service file. Is it recommended?
ExecStartPre=/usr/bin/systemd-tmpfiles --create saslauthd.conf

Maybe systemd maintainers will have some opinion about this issue and how to solve it when we don't have init scripts anymore?

Fortunately it is just a corner case and misconfigured system at this point so I would be quite ok to ignore it, but when Stanislav started picking into it I would like to hear some voice from systemd.

Comment 8 Michal Sekletar 2015-07-14 11:07:03 UTC
We are rebasing systemd to newer version in RHEL-7.2 so you'll be able to use RuntimeDirectory option.

Comment 9 Jakub Jelen 2015-07-14 12:09:28 UTC
Great. So I will remove tmpfiles, make the errata dependent on current systemd update and I will use of RuntimeDirectory which is ideal for our use case. Just briefly tested and works fine for me.

Comment 12 errata-xmlrpc 2015-11-19 09:15:28 UTC
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-2015-2127.html