Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 679772 - app-portage/pfl should drop privileges if stared as root
Summary: app-portage/pfl should drop privileges if stared as root
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Daniel Pielmeier
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-08 15:34 UTC by Andrew Savchenko
Modified: 2019-07-06 09:41 UTC (History)
1 user (show)

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


Attachments
Changes required for running the cron job as user portage (pfl-3.0.1.diff,926 bytes, patch)
2019-06-23 09:18 UTC, Daniel Pielmeier
Details | Diff
Necessary ebuild changes (pfl-3.0.1.ebuild.diff,732 bytes, patch)
2019-06-23 09:18 UTC, Daniel Pielmeier
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Savchenko gentoo-dev 2019-03-08 15:34:28 UTC
Hi!

If pfl is started as root (e.g. via cron job) it should drop privileges, since portage db is accessible by unprivileged user and pfl does network interaction which impose sufficient security risk.

P.S. I locally start it from unprivileged user, but it will be nice to have this functionality implemented properly and by default for all users.
Comment 1 Daniel Pielmeier gentoo-dev 2019-06-23 09:17:53 UTC
Hi thanks for the report.

The cron job in /etc/cron.weekly must run as root. However it should be possible to drop the privileges. From my research there are multiple possibilities.

I suggest using setpriv from util-linux to drop the privileges and run as portage:portage. Maybe there are better ways, I am open for suggestions.


@Daniel: This also requires changes in the pfl upload script, as it checks if the current user is root. If yes it writes the pfl version and the last upload time to pfl.info in /var/lib/pfl/, if not to the current users home directory. So this test needs to check for the user portage instead of root.

I am planning to create a new version (3.0.1) including this changes along with other fixes for e-file fixing #684346 and #674120.


Also the ebuild needs to be changed to fix the initial permissions of /var/lib/pfl/pfl.info.
Comment 2 Daniel Pielmeier gentoo-dev 2019-06-23 09:18:29 UTC
Created attachment 580546 [details, diff]
Changes required for running the cron job as user portage
Comment 3 Daniel Pielmeier gentoo-dev 2019-06-23 09:18:48 UTC
Created attachment 580548 [details, diff]
Necessary ebuild changes
Comment 4 Daniel Pielmeier gentoo-dev 2019-07-06 09:41:54 UTC
Fixed in Git with pfl-3.0.1.

@Daniel: The tarball for 3.0.1 is available here: https://dev.gentoo.org/~billie/distfiles/pfl-3.0.1.tar.bz2