Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 680456 - sys-apps/portage: "Unable to unshare" messages could be more specific, and could be deduplicated
Summary: sys-apps/portage: "Unable to unshare" messages could be more specific, and co...
Status: CONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All All
: Normal normal with 1 vote (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-15 16:21 UTC by Zac Medico
Modified: 2019-12-15 23:04 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zac Medico gentoo-dev 2019-03-15 16:21:25 UTC
Since ipc-sandbox, network-sandbox, and pid-sandbox are enabled by default, users without the necessary kernel configuration will see "Unable to unshare" messages which are not very specific. For example, if network namespaces or ipc namespaces are not enabled in the kernel then running egencache will produce a vast number of identical "Unable to unshare" messages.

I've had an unconfirmed report that disabling FEATURES="pid-sandbox" suppresses the "Unable to unshare" messages for egencache with portage-2.3.62, however that should not be the case since pid-sandbox is supposed to be automatically disabled for the "depend" phase here:

https://gitweb.gentoo.org/proj/portage.git/commit/?id=e2eb3c8252c2ad154e84cc8803974103e9635eee
Comment 1 Agostino Sarubbo gentoo-dev 2019-08-13 13:05:14 UTC
This is reproducible by installing docker on e.g. Centos7 and run a gentoo image.

I'm able to suppress the warning with:
FEATURES="-ipc-sandbox -network-sandbox -pid-sandbox"

I tried also different combo, but I can suppress the warning only by disable all the three feature.
Comment 2 Simon 2019-12-15 15:16:14 UTC
@Zac Medico, did you manage to find a way to make these messages more specific?
I've had a couple of occasions where I got a bunch of "Unable to unshare: EPERM" but it's not really clear what's causing them.

So far I've only seen this happen in a Docker container btw, not on my host itself.
Comment 3 Zac Medico gentoo-dev 2019-12-15 19:23:32 UTC
(In reply to Simon from comment #2)
> @Zac Medico, did you manage to find a way to make these messages more
> specific?

I think we probably should make it simply display all of the enabled FEATURES that contribute to the unshare flags. Generally, all unshare calls will fail in a docker container that's not running in privileged mode, and you can use this to disable all of the relevant FEATURES:

export FEATURES="-ipc-sandbox -mount-sandbox -network-sandbox -pid-sandbox"

Also, if the container does not have ptrace capabilities (--cap-add=SYS_PTRACE), then you'll also want FEATURES="-sandbox -usersandbox".
Comment 4 Zac Medico gentoo-dev 2019-12-15 19:44:21 UTC
I think it would be useful to implement a simpler way to disable FEATURES that are not expected to work in an unprivileged docker container, for example we could implement something like FEATURES="-ptrace -unshare" that would disable all of the relevant FEATURES that are not expected to work.
Comment 5 Simon 2019-12-15 20:08:20 UTC
(In reply to Zac Medico from comment #3)
> (In reply to Simon from comment #2)
> > @Zac Medico, did you manage to find a way to make these messages more
> > specific?
> 
> I think we probably should make it simply display all of the enabled
> FEATURES that contribute to the unshare flags. Generally, all unshare calls
> will fail in a docker container that's not running in privileged mode, and
> you can use this to disable all of the relevant FEATURES:
> 
> export FEATURES="-ipc-sandbox -mount-sandbox -network-sandbox -pid-sandbox"
> 
> Also, if the container does not have ptrace capabilities
> (--cap-add=SYS_PTRACE), then you'll also want FEATURES="-sandbox
> -usersandbox".

There's no easy way to determine which specific unshare call/feature caused the "Unable to unshare" message?

I think a more specific message, like "IPC sandbox: Unable to unshare" or something like that would already help a lot with giving a user some information to act on.

(In reply to Zac Medico from comment #4)
> I think it would be useful to implement a simpler way to disable FEATURES
> that are not expected to work in an unprivileged docker container, for
> example we could implement something like FEATURES="-ptrace -unshare" that
> would disable all of the relevant FEATURES that are not expected to work.

Flags that aggregate several options would be easy, but wouldn't that clutter  FEATURES? Or would these two new flags replace the specific sandbox ones?

A user still needs to know which flags exist and what they do, speaking for myself, I'd need to lookup what the IPC/mount/etc sandbox or unshare does and if/how I can disable it. Once I've done that there's not much difference between adding one or four things to FEATURES to me.
Comment 6 Larry the Git Cow gentoo-dev 2019-12-15 23:00:46 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9557f104aa85b65c7d394c52c5c8d8727a111651

commit 9557f104aa85b65c7d394c52c5c8d8727a111651
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2019-12-15 22:53:50 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2019-12-15 22:56:34 +0000

    sys-apps/portage: Bump to version 2.3.82
    
     #310009 emerge: Show package USE in conflict messages
     #680456 display relevant FEATURES when unshare fails
     #693454 emerge-webrsync: support gentoo-YYYYMMDD snapshots
     #702146 emerge: drop FEATURES=distcc-pump support
     #702970 emerge-webrsync: enable xz snapshots for tarsync
    
    Bug: https://bugs.gentoo.org/701268
    Bug: https://bugs.gentoo.org/310009
    Bug: https://bugs.gentoo.org/680456
    Bug: https://bugs.gentoo.org/693454
    Bug: https://bugs.gentoo.org/702146
    Bug: https://bugs.gentoo.org/702970
    Package-Manager: Portage-2.3.82, Repoman-2.3.20
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 sys-apps/portage/Manifest              |   1 +
 sys-apps/portage/portage-2.3.82.ebuild | 272 +++++++++++++++++++++++++++++++++
 2 files changed, 273 insertions(+)
Comment 7 Larry the Git Cow gentoo-dev 2019-12-15 23:04:58 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=e385eee1614b7b1e296b0e9560ad2d87ace9ea69

commit e385eee1614b7b1e296b0e9560ad2d87ace9ea69
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2019-12-15 22:11:55 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2019-12-15 22:21:23 +0000

    process: display relevant FEATURES when unshare fails
    
    For example, the message will now look like this:
    
    Unable to unshare: EPERM (for FEATURES="ipc-sandbox mount-sandbox network-sandbox pid-sandbox")
    
    Bug: https://bugs.gentoo.org/680456
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/portage/process.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)