Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 213972 - Support for file-based capabilities for executables
Summary: Support for file-based capabilities for executables
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: SOCIDEAS
Depends on:
Blocks:
 
Reported: 2008-03-20 00:13 UTC by Diego Elio Pettenò (RETIRED)
Modified: 2013-03-03 15:48 UTC (History)
3 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 Diego Elio Pettenò (RETIRED) gentoo-dev 2008-03-20 00:13:53 UTC
With recent Linux versions file-based capabilities have been implemented. This means you can have the /bin/ping executables not setuid root, but simply with cap_net_raw capability set, allowing it just to use the RAW socket rather than executing part of it with full-fledged root privileges. This is a nice security mitigation technique.

File-based capabilities can be set with the setcap(1) tool (from libcap package) but Portage will not copy them over when copying the file around. These values can't be accessed through xattr, but libcap itself should provide access to them, or the getcap(1) command could be used to get their value.

This could be linked to USE flags for some packages so that setuid binaries can be replaced with file-based capabilities.
Comment 1 Marius Mauch (RETIRED) gentoo-dev 2008-03-20 01:05:54 UTC
Wouldn't this only require some additional calls in pkg_postinst? If so, I don't see how portage is involved here.
Comment 2 David Leverton 2008-03-20 01:14:05 UTC
I suspect general xattr support would be more worthy of a SoC project.  On Linux that would get capability support for free, if I'm reading the libcap code correctly, although other OSes might do it differently.

(In reply to comment #1)
> Wouldn't this only require some additional calls in pkg_postinst? If so, I
> don't see how portage is involved here.

Probably cleaner to make the package manager preserve them across the merge.  Assuming we do it that way, it'll need an EAPI bump, so adding pms-bugs.
Comment 3 Diego Elio Pettenò (RETIRED) gentoo-dev 2008-03-20 02:00:04 UTC
getfattr can't list the capabilities so I wouldn't suspect that xattr alone would help.
Comment 4 SpanKY gentoo-dev 2008-03-20 13:36:03 UTC
the only thing portage needs to do is preserve caps from $D to $ROOT and make sure that when creating binpkgs, this info is preserved.  same goes for ACLs or SELinux attrs and all that sort of fun stuff.

not really a PMS issue nor worthy of SoC i dont think
Comment 5 Diego Elio Pettenò (RETIRED) gentoo-dev 2008-03-20 13:39:41 UTC
Well, we could get SoC to adapt mtree to save and restore that data too, and then change portage to add an mtree output to the binpkg.
Comment 6 SpanKY gentoo-dev 2008-03-20 13:54:30 UTC
i'd like to avoid mtree if at all possible
Comment 7 Peter Volkov (RETIRED) gentoo-dev 2010-09-19 11:21:26 UTC
But what to do in case FS does not support capabilities? Currently I'm thinking about fallback like this for wireshark:

if ! setcap cap_net_raw,cap_net_admin+eip "${ROOT}"/usr/bin/dumpcap; then
    chmod 6550 "${ROOT}"/usr/bin/dumpcap
fi

Since $D and $ROOT may have different file systems (and thus different support for file-based capabilities) we need PM support here or are there better ways?
Comment 8 Diego Elio Pettenò (RETIRED) gentoo-dev 2010-09-19 11:29:35 UTC
Constanze wrote an eclass for this during the past GSoC and it's ready for submission to -dev, I just need to cut out some time to get it sent and discussed.

That eclass takes care of all the details already.
Comment 9 Brian Harring (RETIRED) gentoo-dev 2010-12-30 16:54:10 UTC
(In reply to comment #8)
> Constanze wrote an eclass for this during the past GSoC and it's ready for
> submission to -dev, I just need to cut out some time to get it sent and
> discussed.
> 
> That eclass takes care of all the details already.

Any update, or a url to the thread?  Not finding anything...
Comment 10 Peter Volkov (RETIRED) gentoo-dev 2010-12-31 10:28:02 UTC
AFAIK: http://github.com/constanze/GSoC2010_Gentoo_Capabilities

Also wireshark ebuild uses fcaps function similar to suggested in this work. I'm waiting for Diego to post RFC on -dev.
Comment 11 Diego Elio Pettenò (RETIRED) gentoo-dev 2013-02-27 18:16:57 UTC
I guess this can be closed now.
Comment 12 SpanKY gentoo-dev 2013-03-03 11:00:41 UTC
we should update PMS to preserve xattrs since this affects all technologies that use those (selinux, filecaps, etc...)
Comment 13 Ciaran McCreesh 2013-03-03 13:52:12 UTC
But Portage doesn't preserve xattrs in all cases, does it?
Comment 14 Zac Medico gentoo-dev 2013-03-03 15:48:47 UTC
Portage only preserves them when FEATURES=xattr is enabled, and the relevant file systems support it. If FEATURES=xattr is enabled and the $ROOT file system doesn't support it, Portage will abort while trying to merge the files (see bug 402323).