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 1115533 - Attempt to start /bin/dbus-daemon --system --fork fails with Failed to drop capabilities: Operation not permitted
Summary: Attempt to start /bin/dbus-daemon --system --fork fails with Failed to drop c...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: docker
Version: 7.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Daniel Walsh
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 1109938
TreeView+ depends on / blocked
 
Reported: 2014-07-02 14:35 UTC by Jan Pazdziora
Modified: 2019-03-06 02:24 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-09-18 20:46:02 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
build & run script for fake library and dbus (133 bytes, application/x-shellscript)
2014-07-09 18:17 UTC, Marcel Wysocki
no flags Details
fake library (235 bytes, text/x-csrc)
2014-07-09 18:17 UTC, Marcel Wysocki
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1266 0 normal SHIPPED_LIVE docker bug fix and enhancement update 2014-09-19 00:45:12 UTC

Description Jan Pazdziora 2014-07-02 14:35:15 UTC
Description of problem:

Attempt to start /bin/dbus-daemon --system --fork in a container leaves no process running. Stracing the process shows message Failed to drop capabilities: Operation not permitted.

Version-Release number of selected component (if applicable):

3.10.0-123.el7.x86_64 on the host
docker-0.11.1-22.el7.x86_64 on the host
dbus-1.6.12-8.el7.x86_64 in the container

How reproducible:

Deterministic.

Steps to Reproduce:
1. Run strace -s 500 -f -o /tmp/dbus.strace /bin/dbus-daemon --system --fork
2. Check /tmp/dbus.strace

Actual results:

54    geteuid()                         = 0
54    capget({0 /* _LINUX_CAPABILITY_VERSION_??? */, 0}, NULL) = 0
54    gettid()                          = 54
54    prctl(PR_SET_KEEPCAPS, 1)         = 0
54    capset({_LINUX_CAPABILITY_VERSION_3, 54}, {CAP_SETGID|CAP_SETUID|CAP_AUDIT_WRITE, CAP_SETGID|CAP_SETUID|CAP_AUDIT_WRITE, 0}) = -1 EPERM (Operation not permitted)
54    epoll_ctl(3, EPOLL_CTL_DEL, 4, {0, {u32=0, u64=0}}) = 0
54    close(4)                          = 0
54    unlink("/var/run/dbus/system_bus_socket") = 0
54    unlink("/var/run/messagebus.pid") = 0
54    write(2, "Failed to start message bus: Failed to drop capabilities: Operation not permitted\n\n", 83) = 83
54    exit_group(1)                     = ?

The matching piece of source seems to be

      capng_clear (CAPNG_SELECT_BOTH);
      capng_update (CAPNG_ADD, CAPNG_EFFECTIVE | CAPNG_PERMITTED,
                    CAP_AUDIT_WRITE);
      rc = capng_change_id (uid, gid, CAPNG_DROP_SUPP_GRP);
      if (rc)
        {
          switch (rc) {
            default:
              dbus_set_error (error, DBUS_ERROR_FAILED,
                              "Failed to drop capabilities: %s\n",
                              _dbus_strerror (errno));
              break;

Expected results:

Dropping capabilities seems like an operation that should pass in a container.

Additional info:

Comment 1 Jan Pazdziora 2014-07-02 14:36:48 UTC
Or does it actually fail because CAP_AUDIT_WRITE is being added?

Comment 3 Marcel Wysocki 2014-07-09 17:22:43 UTC
+1 I am affected by this as well.
Trying to run FreeIPA in a docker container.

Comment 4 Marcel Wysocki 2014-07-09 18:17:08 UTC
Created attachment 916918 [details]
build & run script for fake library and dbus

Comment 5 Marcel Wysocki 2014-07-09 18:17:34 UTC
Created attachment 916919 [details]
fake library

Comment 6 Marcel Wysocki 2014-07-09 18:18:29 UTC
was able to get it working with the good old LD_PRELOAD script.
Test files attached

Comment 7 Daniel Walsh 2014-07-15 17:00:08 UTC
Docker just added support for --cap-add which you should be able to figure out which capability you are missing.  You should be able to drop caps but you might not have all of the caps you need.

Comment 8 Marcel Wysocki 2014-07-16 13:22:58 UTC
but using --cap-add will permanently add that capability to the container, which could be a security risk. :/
I was able to start the dbus-daemon without the capability and just faking the library calls for dbus-daemon.

Comment 9 Marcel Wysocki 2014-07-23 18:03:53 UTC
@dwalsh

I put something together, might interest you

http://maci0.wordpress.com/2014/07/23/run-systemd-in-an-unprivileged-docker-container/

Comment 10 Daniel Walsh 2014-07-23 18:32:59 UTC
Have you tried working with systemd-container?

BTW I just added back AUDIT_WRITE to docker-1.1.1-3.el7.x86_64

Comment 11 Jan Pazdziora 2014-07-24 14:36:46 UTC
For FreeIPA, I just run the dbus as dbus directly from systemd:

https://github.com/adelton/docker-freeipa/commit/7a66b011dde9c60d63cc493904b798347f5530d3

That avoids the critical part of the code.

Comment 12 Daniel Walsh 2014-08-13 16:22:52 UTC
Fixed in docker-1.1.2-8.el7.x86_64

Comment 13 Jan Pazdziora 2014-08-14 13:22:04 UTC
(In reply to Daniel Walsh from comment #12)
> Fixed in docker-1.1.2-8.el7.x86_64

Confirming that with this daemon, dbus-daemon process starts and is running.

Comment 15 errata-xmlrpc 2014-09-18 20:46:02 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.

http://rhn.redhat.com/errata/RHBA-2014-1266.html


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