Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 251465 - enable app-misc/uptimed to run as an unpriviledged user
Summary: enable app-misc/uptimed to run as an unpriviledged user
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Raúl Porcel (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-18 12:40 UTC by Georg Weiss
Modified: 2009-02-19 19:33 UTC (History)
0 users

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


Attachments
uptimed init-script (uptimed.patch,572 bytes, text/plain)
2008-12-18 15:14 UTC, Georg Weiss
Details
uptimed.diff (uptimed.diff,673 bytes, patch)
2009-01-04 17:06 UTC, Lars Wendler (Polynomial-C) (RETIRED)
Details | Diff
uptimed-0.3.16.ebuild.diff (uptimed-0.3.16.ebuild.diff,675 bytes, patch)
2009-01-04 17:11 UTC, Lars Wendler (Polynomial-C) (RETIRED)
Details | Diff
uptimed.diff (uptimed.diff,737 bytes, patch)
2009-01-04 17:54 UTC, Lars Wendler (Polynomial-C) (RETIRED)
Details | Diff
uptimed.diff (uptimed.diff,723 bytes, patch)
2009-01-05 00:53 UTC, Lars Wendler (Polynomial-C) (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Georg Weiss 2008-12-18 12:40:48 UTC
Hi

I discovered that debian (etch) has uptimed running as user "daemon" whereas on gentoo it runs as "root". Changing that is fairly easy and thinking with security in mind i suggest this should be changed.

I was able to achieve it just by
--8<--
chown -R daemon:daemon /var/spool/uptimed
--8<--

and patching the initscript to start uptimed as daemon:
--8<--
start-stop-daemon --quiet --start --user daemon --chuid daemon --pidfile /var/run/uptimed --exec /usr/sbin/uptimed
--8<--

Thanks
Comment 1 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2008-12-18 13:12:11 UTC
Georg, could you attach a patch of your changed init-script, please?

Reassigning to maintainer.
Comment 2 Georg Weiss 2008-12-18 15:14:53 UTC
Created attachment 175732 [details]
uptimed init-script

added patch for uptimed init-script.
I've had to remove the pidfile option (daemon cannot write to /var/run), but it works without it.
Comment 3 Raúl Porcel (RETIRED) gentoo-dev 2009-01-01 15:34:16 UTC
I'd prefer to run it as its own user, to be honest.
Comment 4 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2009-01-04 17:06:48 UTC
Created attachment 177359 [details, diff]
uptimed.diff

Alright, let's try to make your wishes come true, Raúl  :)

With this patch applied to the init script, we can still rely on the pidfile for start-stop-daemon on stop. I've tested this with start-stop-daemon from baselayout-1* and openrc-0.4.1-r1.
Please note that uptimed needs its own directory inside of /var/run for being able to create the pidfile. I will ataach an ebuild patch which takes care of this.
Comment 5 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2009-01-04 17:11:52 UTC
Created attachment 177361 [details, diff]
uptimed-0.3.16.ebuild.diff

* added pkg_setup() with calls to enew{grup,user} for creating the uptimed user.
* changed ownership of /var/sppol/uptimed as is needs to be writeable by uptimed user
* create a /var/run/uptimed directory so uptimed is able to create its pidfile as user uptimed as well.

One problem with this patch is that if you upgrade from a previous installation of uptimed, the ownership of /var/spool/uptimed and its content remains as root. Needless to say that uptimed refuses to run when it cannot touch its own files inside of /var/spool/uptimed. Maybe some einfo-message in pkg_postinst() could take care of this.
Comment 6 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2009-01-04 17:54:20 UTC
Created attachment 177367 [details, diff]
uptimed.diff

Whoops, my previous diff was against an unfinished version of the script. Here's the finished one...
Comment 7 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2009-01-05 00:53:25 UTC
Created attachment 177435 [details, diff]
uptimed.diff

--user and --chuid are the same in openrc's start-stop-daemon but not in the one from baselayout-1*. The --user option from baselayout-1* doesn't change the UID of daemons on start but --chuid does.
This patch adds --chuid to s-s-d on start and --user to s-s-d on stop.
Again tested with s-s-d from both packages.
Comment 8 Raúl Porcel (RETIRED) gentoo-dev 2009-02-19 19:33:14 UTC
In CVS :)