Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 2313 - apache ebuild should test (better) for group/user existing before failure
Summary: apache ebuild should test (better) for group/user existing before failure
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Nicholas Jones (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-05-01 14:19 UTC by Tim Hobbs
Modified: 2003-02-04 19:42 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 Tim Hobbs 2002-05-01 14:19:23 UTC
apache ebuild 1.3.24-r1 tests for "apache" user and group existing only 
in /etc/passwd and /etc/group.

If someone is using a different user source, let's say for example...LDAP, then 
the apache group and user may not exist in /etc/passwd and /etc/group.  
However, apache IS a valid user and group, and the subsequent call to groupadd 
and useradd will fail, which causes the entire ebuild to abort.

Perhaps testing with id apache would work, or checking the response from 
groupadd and useradd.

I commented out the groupadd/useradd in the ebuild to "force" the install, so 
have worked around the issue in the short term.
Comment 1 Donny Davies (RETIRED) gentoo-dev 2002-05-04 21:59:55 UTC
good point; having not really gotten into ldap i didn't realize this.

so will changing the checks to:
if ! id -g apache ; then ...
if ! id -u apache ; then ...

make it friendlier?  theres a few more ebuilds doing this sort
of thing, so it'd be good to find a nice generic solution here.

im guessing this is the way to go, but i'll wait for your reply.
thanks.
Comment 2 Donny Davies (RETIRED) gentoo-dev 2002-05-04 22:02:49 UTC
note that the new check would be:

if ! id -u apache >/dev/null 2>&1 ; then
...

and similar for the group.

Comment 3 Donny Davies (RETIRED) gentoo-dev 2002-05-13 22:53:15 UTC
bleh

id -g foobar 

doesnt do what i guessed it does.  bummer, i need a nice,
generic way to test for existing groups that is LDAP
friendly.  

any suggestions welcome.
Comment 4 Tim Hobbs 2002-05-18 18:02:17 UTC
I'm sure the emails to me bounced - apologies.

What do you think of this:
if ! groupadd -g 81 apache ; then
  die "problem adding group apache"
fi

and the same for useradd?

Comment 5 Donny Davies (RETIRED) gentoo-dev 2002-06-08 14:54:05 UTC
Problem with that is it'll fail for most people using /etc/group; since
apache:81 is already in the Gentoo baselayout /etc/group file :/

id -u apache for the user check sounded good i guess,
unfortunately i dunno what to do about the group.

fortunately it doesnt seem like a major issue, still i'd like to
smooth it out if you have any further ideas ;)
Comment 6 Nicholas Jones (RETIRED) gentoo-dev 2002-06-18 16:32:16 UTC
Should be fixed in apache 1.3.24-r6

if ! groupmod apache; then
...
fi

if ! id apache; then
...
fi
Comment 7 Matthew Walker 2002-06-18 18:37:37 UTC
Nope. Not fixed. I just tried to update my apache, and got this error on install: 

adamantium root # emerge --update world
Calculating world dependencies ...done!
>>> emerge net-www/apache-1.3.24-r6 to /
>>> md5 ;-) apache_1.3.24.tar.gz
>>> md5 ;-) mod_ssl-2.8.8-1.3.24.tar.gz
uid=1001(apache) gid=407 groups=407
useradd: user apache exists

!!! ERROR: The ebuild did not complete successfully.
!!! Function pkg_setup, Line 9, Exitcode 9
!!! problem adding user apache

!!! emerge aborting on  /usr/portage/net-www/apache/apache-1.3.24-r6.ebuild .
Comment 8 Nicholas Jones (RETIRED) gentoo-dev 2002-06-18 21:38:46 UTC
This works fine over here on non-ldap...
Can you do and post these here...

id root   &>/dev/null; echo "-- id root:   $?"
id zsp234 &>/dev/null; echo "-- id zsp234: $?"
id apache &>/dev/null; echo "-- id apache: $?"

Comment 9 Matthew Walker 2002-06-18 21:45:36 UTC
id root   &>/dev/null; echo "-- id root:   $?"
-- id root:   0

id zsp234 &>/dev/null; echo "-- id zsp234: $?"
-- id zsp234: 1

id apache &>/dev/null; echo "-- id apache: $?"
-- id apache: 1

Comment 10 Nicholas Jones (RETIRED) gentoo-dev 2002-06-20 10:34:56 UTC
Did you have Apache installed on that box?

Did you have user 'apache' on that box?

Do you know of a way to check for ldap users?

Do you know how to query for their information
that would normally exist in /etc/passwd?

(hopefully these will actually work)
Try these and post the results please:
usermod root; echo $?
usermod apache; echo $?
usermod SOME_LDAP_USERNAME; echo $?

Comment 11 Tim Hobbs 2002-06-20 10:50:33 UTC
akira root # usermod root; echo $?
usermod: no flags given
2
akira root # usermod apache; echo $?
usermod: no flags given
2
akira root # usermod rectrix; echo $?
usermod: no flags given
2
akira root # usermod foo; echo $?
usermod: user foo does not exist
6
akira root #
Comment 12 Nicholas Jones (RETIRED) gentoo-dev 2002-06-20 21:54:35 UTC
apache-1.3.26-r1 -- is another shot at fixing the problem. Lemme know the results.  

If it's not in portage yet, give it a couple minutes.

Please, if you have any ldap tools for user editing, let me know what they are
and how they work. It'd help to solve the issue.
Comment 13 Matthew Walker 2002-06-26 00:40:42 UTC
Works fine for me now.