Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 15048 - Make distccd run as "distccd" user instead of nobody
Summary: Make distccd run as "distccd" user instead of nobody
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Zach Welch (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on: 13897 15969
Blocks:
  Show dependency tree
 
Reported: 2003-02-03 11:46 UTC by Max Kalika (RETIRED)
Modified: 2003-04-19 19:13 UTC (History)
4 users (show)

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


Attachments
patch to the ebuild described in the bug report (distcc-1.1.ebuild_run_as_distccd.patch,609 bytes, patch)
2003-02-03 11:47 UTC, Max Kalika (RETIRED)
Details | Diff
patch to the rc script described in the report (distccd.1_run_as_distccd.patch,499 bytes, patch)
2003-02-03 11:49 UTC, Max Kalika (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Max Kalika (RETIRED) gentoo-dev 2003-02-03 11:46:20 UTC
The following patches allow distccd run as a "distccd" user instead of nobody.  
This also allowes to save the PID file in /var/run for consistancy.

Reproducible: Always
Steps to Reproduce:
1.
2.
3.




Portage 2.0.46-r9 (default-x86-1.4, gcc-3.2.1, glibc-2.3.1-r2)
=================================================================
System uname: 2.4.20 i686 Pentium III (Coppermine)
GENTOO_MIRRORS="ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo"
CONFIG_PROTECT="/etc /var/qmail/control /usr/kde/2/share/config /usr/kde/3/share
/config /usr/X11R6/lib/X11/xkb /usr/kde/3.1/share/config /usr/share/config"
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d"
PORTDIR="/usr/portage"
DISTDIR="/usr/portage/distfiles"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR_OVERLAY="/usr/local/portage"
USE="x86 oss 3dnow avi cups encode gif jpeg kde libg++ libwww mmx mpeg ncurses 
pdflib png qtmt quicktime sdl spell truetype xml2 xv zlib berkdb readline arts 
java pam ssl python oggvorbis motif opengl alsa dvd ldap mozilla pic samba 
tiff -perl -apm -cdr -crypt -gdbm -gnome -gpm -gtk -imlib -mikmod -nls -qt -
slang -svga -tcpd -usb -X -xmms"
COMPILER="gcc3"
CHOST="i686-pc-linux-gnu"
CFLAGS="-march=pentium3 -O3 -pipe"
CXXFLAGS="-march=pentium3 -O3 -pipe"
ACCEPT_KEYWORDS="x86"
MAKEOPTS="-j2"
AUTOCLEAN="yes"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
FEATURES="sandbox ccache buildpkg"
Comment 1 Max Kalika (RETIRED) gentoo-dev 2003-02-03 11:47:16 UTC
Created attachment 7883 [details, diff]
patch to the ebuild described in the bug report
Comment 2 Max Kalika (RETIRED) gentoo-dev 2003-02-03 11:49:36 UTC
Created attachment 7884 [details, diff]
patch to the rc script described in the report
Comment 3 Max Kalika (RETIRED) gentoo-dev 2003-02-03 13:40:05 UTC
oops!  sorry about the first hunk of the ebuild patch.  forgot to remove the KEYWORDS change.  Please ignore that.
Comment 4 Yannick Koehler (RETIRED) gentoo-dev 2003-02-06 09:53:32 UTC
And how you defined the distccd user?  My /var/run doesn't give write access to other than the owner and the owner is root

drwxr-xr-x   11 root     root         4096 Jan 29 09:38 run
Comment 5 Yannick Koehler (RETIRED) gentoo-dev 2003-02-06 10:04:03 UTC
I simply changed /etc/init.d/distccd to start as nobody:users and it works.  But I am unsure of the security consequence...

So you leave the script as is and change the -c nobody to -c nobody:users and the /var/tmp I believe is already set

drwxrwxr-x    8 root     users        4096 Feb  6 10:00 tmp
Comment 6 Max Kalika (RETIRED) gentoo-dev 2003-02-06 11:03:28 UTC
The same way that bind defines the "named" user and mysql defines the "mysql"
user.  Those services get around the /var/run owner restrictions by creating a
subdirectory that the respective accounts can write their PID files to.  The
ebuild patch presented provides the same consistant functionality.

Aside from that, there may be other tweaks to add to the rc script -- one is
that the new versions of distcc (1.1) allow for a --user flag, which maybe
cleaner.
Comment 7 Brad Cowan (RETIRED) gentoo-dev 2003-02-06 17:57:35 UTC
I have been meaning to do this for a long time, as it really isn't a good idea to run distccd as -nobody :) I'll pass all the distcc stuff on to u now that I see u want it :)
Comment 8 Zach Welch (RETIRED) gentoo-dev 2003-02-08 19:20:30 UTC
And so this falls into my lap.  I like the idea this change.  Let me check
in the latest distcc-1.1-r7 and we can tackle this in -r8.  See bug 13897
for the saga describing the changes that will be included.

In the future, please generate unified diffs (using diff -u); if you
had done so, your ebuild patch would probably still apply to the -r7 ebuild.
As it is, please merge your changes with -r7 once it's available and
resubmit your changes using diff -u.  Thanks.

Well, okay, after looking a little closer, I think it will be best to
have the user and group added to baselayout, which can be justified
now that portage has better integration with the latest distcc ebuilds.

Also, the /var/run/distccd should probably be done in install with:

dodir /var/run/distccd && touch ${D}/var/run/distccd/.keep.

These two things would eliminate the need for the pre/postinst routines, 
if I am not mistaken.  Let me know what you think.
Comment 9 Zach Welch (RETIRED) gentoo-dev 2003-02-08 20:13:08 UTC
Right after posting my last comment, I began thinking about the future.
Given the current PATH hack when starting distccd, wouldn't it be nice
to be able to start the daemon on a per-user basis?  This plays into the
overall distcc plans for allowing each user to set their gcc-config settings
independently from the system setting.

As such, they could simply run gcc-config to set the compiler, then run a
distccd on a private (but specified by the user) port.  The distcc package
already supports this, it's just a matter of putting the remaining pieces
in place - and there aren't many of those.  What do ya'll think?
Comment 10 Martin Pool 2003-02-11 01:31:23 UTC
Note that distcc CVS supports automatically changing to the username "distcc".  Please change to use the standard name.
Comment 11 Zach Welch (RETIRED) gentoo-dev 2003-02-17 18:50:44 UTC
I have fixed this in CVS in the latest -r10 release.  It seems to work well,
but let me know if it breaks anything for you.
Comment 12 Max Kalika (RETIRED) gentoo-dev 2003-02-18 13:03:37 UTC
Sorry to keep being a bother with this, but I don't think its entirely solved.  In src_install() we now 
create the /var/run/distccd directory and try to make it owned by the distcc user (which doesn't yet 
exist -- it gets created at pkg_preinstall() step)  resulting in this error: 
 
install: invalid user `distcc' 
touch: creating `/var/tmp/portage/distcc-1.1-r10/image//var/run/distccd/.keep': No such file or 
directory 
 
I don't know of a correct way of fixing this other than having distcc user added to baselayout (I'm 
not sure if this has happened already). 
 
Aside from this, we are using the diropts() function after dodir().  is this the correct way?  wouldn't 
it make more sense to do something like this (pardon my ignorance if I am wrong). 
 
   diropts -m0755 -o distcc -g daemon 
   keepdir /var/run/distccd 
Comment 13 Zach Welch (RETIRED) gentoo-dev 2003-02-18 22:18:12 UTC
Okay, this explains the 'install it twice and it works' phenomenon I've heard.

Doing what should have been done before, I've submitted bug 15969 to have 
the distcc user added to baselayout and added it here as a dependency.

So the saga continues.
Comment 14 Max Kalika (RETIRED) gentoo-dev 2003-02-19 00:45:26 UTC
Adding another chapter to this saga:  Is it necessary to make /usr/lib/distcc a
keepdir?  When unmerging, portage ignores this directory and leaves all the
links which remain pointing to a /usr/bin/distcc that no longer exists.
(Should this be filed as a separate bug?)
Comment 15 Eric Andresen 2003-02-19 00:55:11 UTC
That is a portage problem, I believe. the same thing happens in gcc-config >1.2.9 ebuilds when unmerged.
Comment 16 Zach Welch (RETIRED) gentoo-dev 2003-02-19 01:21:59 UTC
Really, the process of building symlinks should be left to distcc-config,
which would be run as a side-effect of gcc-config (if if the former was detected)
after a new cross-compiling toolchain is installed/uninstalled to rebuild the symlinks.  distcc-config should have an --uninstall feature that deletes this
directory as a side-effect.
Comment 17 Zach Welch (RETIRED) gentoo-dev 2003-02-24 21:46:14 UTC
Okay, all of this should be fixed in the latest distcc-1.2.ebuild.

A distcc-config script is now included, its --install-links option used by the 
ebuild; uninstall is not done right now but is possible manually.  Also now 
allows for a future gcc-config to run this tool when installing/uninstalling 
cross-compilers.  Also, fixed up the distcc user install silliness, I hope.

Please verify everything is kosher.
Comment 18 Steve Arnold archtester gentoo-dev 2003-04-19 19:13:36 UTC
While having distcc run as user distcc is a good idea, it horks up the default log file location, since it can't write to /var/log/distcc.log (using the masked 2.0.1 version).

To fix it, I made a directory for the lof file, just like the /var/run/distcc stuff.  It seems to work fine, but I'm not sure if this is thge right way to fix it.  Should this be added to the ebuild too?