Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 4169 - openssh ebuild needs to add sshd user/group in postinst
Summary: openssh ebuild needs to add sshd user/group in postinst
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: x86 Linux
: High critical (vote)
Assignee: Brandon Low (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on: 4170
Blocks:
  Show dependency tree
 
Reported: 2002-06-25 19:24 UTC by Jon Nelson (RETIRED)
Modified: 2003-02-04 19:42 UTC (History)
3 users (show)

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


Attachments
portage.py (portage.py,105.34 KB, text/plain)
2002-07-02 15:55 UTC, Daniel Robbins (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jon Nelson (RETIRED) 2002-06-25 19:24:01 UTC
The openssh ebuild needs to add the sshd user/group in postinst, not pkg_setup,
because otherwise the .tbz2 is utterly useless.

Additionally, this is the proper place for it to be.

Thanks!

--- openssh-3.3_p1.ebuild       2002-06-22 20:35:06.000000000 -0500
+++ openssh-3.3_p1-r1.ebuild    2002-06-25 18:54:35.000000000 -0500
@@ -27,17 +27,6 @@
 LICENSE="as-is"
 SLOT="0"
 
-pkg_setup() {
-       if ! groupmod sshd; then
-               groupadd -g 90 sshd || die "problem adding group sshd"
-       fi
-
-       if ! id sshd; then
-               useradd -g sshd -s /dev/null -d /var/empty -c "sshd" sshd
-               assert "problem adding user sshd"
-       fi
-}
-
 src_compile() {
        local myconf
        use tcpd || myconf="${myconf} --without-tcp-wrappers"
@@ -74,6 +63,15 @@
 }
 
 pkg_postinst() {
+       if ! groupmod sshd; then
+               groupadd -g 90 sshd || die "problem adding group sshd"
+       fi
+
+       if ! id sshd; then
+               useradd -g sshd -s /dev/null -d /var/empty -c "sshd" sshd
+               assert "problem adding user sshd"
+       fi
+        
        # empty dir for the new priv separation auth chroot..
        install -d -m0755 -o root -g root ${ROOT}/var/empty
Comment 1 Donny Davies (RETIRED) gentoo-dev 2002-06-25 21:17:10 UTC
so, any ebuild doing user addition stuff in pkg_setup() is broken
by definition?

i think postfix is using a similar thingy; in its case it *needs*
to come before src_install because certain files needs to be
chown'ed to the newly created group for postfix.

so cant portage and .tbz2's work properly with pkg_setup doing
user addition stuff?  hit me with the cl00bie stick if need be.
Comment 2 Jon Nelson (RETIRED) 2002-06-30 08:36:56 UTC
Yes.
Is any action going to be taken on this?
Comment 3 Daniel Robbins (RETIRED) gentoo-dev 2002-07-02 15:53:59 UTC
pkg_setup needs to be fixed so that it also works for tbz2 packages too... since
woodchip points out that sometimes we need these accounts to exist *before*
src_install.  pkg_setup() was added by Bevin and he didn't touch every area of
the code that he needed to.  But easy enough to fix -- I can tweak portage so
that tbz2 installs call pkg_setup, then pkg_preinst, then merge, then
pkg_postinst.  That appears to be the "right thing to do" in this case.

OK, I fixed portage.py to call pkg_setup() on packages.  The order that
everything is done for .tbz2s is as follows:

1) extract info (and ebuild) from tbz2
2) run pkg_setup(), abort if problems
3) extract files from tbz2
4) run pkg_preinst()
5) merge files
6) run pkg_postinst()
 
This fix will be in Portage 2.0.10+; I'm going to attach my working copy of
portage.py to this bug so that you can test it to verify that this issue is
resolved.
Comment 4 Daniel Robbins (RETIRED) gentoo-dev 2002-07-02 15:55:33 UTC
Created attachment 1923 [details]
portage.py

pre-2.0.10 portage.py with tbz2 fixes
Comment 5 Daniel Robbins (RETIRED) gentoo-dev 2002-07-02 17:11:41 UTC
OK, jnelson has convinced me that using pkg_setup() for adding users is broken.
 If your compile process requires user accounts to be added, then your compile
process is broken and you should look into patching makefiles. pkg_setup()
should only be used for checking things, configuring environment variables, etc
-- it should make no lasting changes to the underlying system.