Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 37725 - shadow package lacks libshadow.so
Summary: shadow package lacks libshadow.so
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: Alpha Linux
: High major (vote)
Assignee: Aron Griffis (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on: 37719
Blocks: 39149
  Show dependency tree
 
Reported: 2004-01-09 11:25 UTC by Nico Baggus
Modified: 2004-05-28 14:43 UTC (History)
1 user (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 Nico Baggus 2004-01-09 11:25:12 UTC
When building freeradius I ran into the following problem:
when building the rlm_unix dynamic module (trace follows) it tries to link with  -lshadow, there is no libshadow.so (i'll get into that a bit later.)
so libtool will make that a "-Wl,--whole-archive /usr/lib/libshadow.a -Wl,--no-whole-archive" sequence. rlm_unix is dynamic, but libshadow.a IS NOT compiled with -fPIC therefore the following errors are logged:
---8<---
/usr/lib/gcc-lib/alphaev56-unknown-linux-gnu/3.3.2/../../../../alphaev56-unknown-linux-gnu/bin/ld: /usr/lib/libshadow.a(pwauth.o): gp-relative relocation against dynamic symbol wipe_clear_pass
/usr/lib/gcc-lib/alphaev56-unknown-linux-gnu/3.3.2/../../../../alphaev56-unknown-linux-gnu/bin/ld: /usr/lib/libshadow.a(pwauth.o): gp-relative relocation against dynamic symbol clear_pass
/usr/lib/gcc-lib/alphaev56-unknown-linux-gnu/3.3.2/../../../../alphaev56-unknown-linux-gnu/bin/ld: /usr/lib/libshadow.a(pwauth.o): gp-relative relocation against dynamic symbol wipe_clear_pass
/usr/lib/gcc-lib/alphaev56-unknown-linux-gnu/3.3.2/../../../../alphaev56-unknown-linux-gnu/bin/ld: /usr/lib/libshadow.a(pwauth.o): gp-relative relocation against dynamic symbol clear_pass
---8<---
hinting that libshadow.a should be compiled with -fPIC.

If a libshadow.so were existent all would have gone well, as -dynamic modeles get built with -fPIC.

Trying to build shadow-4.0.3-r9 it shows it DOES NOT BUILD .so libraries
it even says in the release notes they are deleted.
Building it will show that dynamic building fails because of a missing -lpam -lpam_misc library during linking.


The problem seems to be related to the makefile, the LIBS= assignment is empty
if that assignment is LIB="-lpam -lpam_misc" then linking works.

This does prevent freeradius from being built.
Comment 1 Aron Griffis (RETIRED) gentoo-dev 2004-01-09 17:40:22 UTC
Nico, what do you mean by "it even says in the release notes they are deleted"?
Comment 2 Aron Griffis (RETIRED) gentoo-dev 2004-01-09 18:40:05 UTC
Thanks Nico, this is fixed in shadow-4.0.3-r10
Comment 3 Nico Baggus 2004-01-09 22:44:38 UTC
I found some references to it in the NEWS file within the package...

shadow-980626 => shadow-980724

- security: login no longer gives you a root shell if setgid()
  or initgroups() or setuid() fails for any reason, discovered
  by Ted Hickman <thickman@sy.net>
- remove libshadow.so -> libshadow.so.x.x symlink after install
- a few int -> uid_t type cleanups
- fail immediately (don't retry) in *_lock() if euid != 0
- added sample PAM config files etc/pam.d/{passwd,su}
- preliminary PAM support in su (untested - use at your own risk,
  comments and patches welcome!)
- cleanup and more comments in OPIE code (Algis Rudys)
- added support for TCFS (Transparent Cryptographic File System)
  (use ./configure --with-libtcfs, see http://tcfs.dia.unisa.it/
  for more info), thanks to Aniello Del Sorbo
...


I'll test the package when it arrives...
Comment 4 Nico Baggus 2004-01-10 05:21:58 UTC
It compiled without troubles for me now, i'll use parts of it in the coming week to verify it still works... ;-)

Comment 5 Nico Baggus 2004-01-10 06:05:45 UTC
reviewing the shado build the following struck me....

everything except /bin/su & /bin/groups are in /usr/bin or /usr/sbin...
the libraries are in /usr/lib

this means that su & groups won't work when /usr isn't mounted!
(they also use libcrypt & libcrack )

maybe the libshadow.so and libmisc.so need to be on the /lib directory..?
or su and groups can move to /usr/bin?

groups is in the /usr/bin directory on redhat.
su is in /bin there.

Redhat doesn't use the crypt & crack libraries in the shadow-utils. Also pam isn't used there....

Comment 6 Aron Griffis (RETIRED) gentoo-dev 2004-01-10 07:58:30 UTC
Azarah, would you mind commenting on this?  I see the following comment in the Makefile.am:

# XXX why are login and su in /bin anyway (other than for
# historical reasons)?
#
# if the system is screwed so badly that it can't mount /usr,
# you can (hopefully) boot single user, and then you're root
# so you don't need these programs for recovery.
#
# also /lib/libshadow.so.x.xx (if any) could be moved to /usr/lib
# and installation would be much simpler (just two directories,
# $prefix/bin and $prefix/sbin, no install-data hacks...)

It seems to me that we have three options, and I would like you to tell me which one would be best in your opinion (Az):

1. Move /bin/su, /bin/login and /bin/groups to /usr/bin based on the Makefile.am comment above.  This means that libshadow.so and libmisc.so could stay in /usr/lib

2. Move /usr/lib/libshadow.so and /usr/lib/libmisc.so to /lib

3. Revert the ebuild to --disable-shared so that only libmisc.a and libshadow.a are built, but add -fPIC to the ebuild so that shared objects can link against these archives.

Do you see any other options?  What is your opinion?  Presently -r9 builds only the static libs, and that is the stable version.  -r10 builds the shared objs and installs them in /usr/lib, and is the ~arch version.
Comment 7 Martin Schlemmer (RETIRED) gentoo-dev 2004-01-11 11:37:57 UTC
Either way I do not have an issue.  I think there was issues with shared
libshadow (anyone tried a bootstrap && emerge system with -r10 yet?), but
I wont swear by it.  You might run into issues with / bloat fanatics if
you move the libs to /lib.

If you however decide on .so's in /lib, please look at gen_usr_ldscript()
in eutils.eclass ...

BTW, does both pam 0.76 and 0.77 build with the shared libs?
Comment 8 Martin Schlemmer (RETIRED) gentoo-dev 2004-01-11 11:50:36 UTC
Btw, /bin/login is hardcoded into agetty, so either we need another
symlink, or the /lib/*.so is the best bet.
Comment 9 Martin Schlemmer (RETIRED) gentoo-dev 2004-01-11 11:52:41 UTC
Or -fPIC I guess.  It will be the smallest one (no extra files/libs/symlinks) ...
Comment 10 Aron Griffis (RETIRED) gentoo-dev 2004-01-11 16:43:58 UTC
Az, I think the first thing I'll try is option 1 in comment 6.  That's moving the binaries to /usr/bin.  It's the most likely option to have problems, but on the other hand, if it works then we have removed three binaries from the root partition.  I'll look into fixing agetty to use /usr/bin/login (and search for other programs/scripts that would need to be fixed).

In order for this to happen, I'll package.mask -r10 for now and I'll test a bootstrap.
Comment 11 solar (RETIRED) gentoo-dev 2004-01-23 21:24:11 UTC
Re comment #10
login belongs in /bin please don't try to move it to /usr/bin
Comment 12 Martin Schlemmer (RETIRED) gentoo-dev 2004-01-24 08:53:02 UTC
I go for -fPIC then.  Aron, is it Ok to just add 'add-flags -fPIC' to the ebuild,
or do you guys do it another way?
Comment 13 Nico Baggus 2004-01-24 11:27:07 UTC
AFAICT,

/bin/login doesn't use libshadow.so so that is not an issue for this one...
Comment 14 Martin Schlemmer (RETIRED) gentoo-dev 2004-01-28 09:52:44 UTC
It will if you remerge pam with the shared libshadow around ...
Comment 15 Aron Griffis (RETIRED) gentoo-dev 2004-05-06 14:24:17 UTC
fixed in shadow-4.0.4.1-r1 by adding -fPIC
Comment 16 Reporter 2004-05-09 19:06:35 UTC
Okay, I'll bite. But just because noone else does (even though they were going
to more than a year ago..)

<extra_quiet> THAT'S WRONG WRONG WRONG! </extra_quiet>

libshadow, as well as libmisc, are internal to the shadow package and are not
supposed to be in /usr/lib. In linux, shadow support is in libc5, well, ever
since there are shadow passwords in linux, and in glibc2 forever. Just look
what other distributions are doing. Why do you want to punish all the innocent
shadow binaries with -fPIC? Way too cruel for my taste!

BAM!
Comment 17 Nico Baggus 2004-05-10 14:39:30 UTC
on 64 bit (risk-)architectures a lot of the code/data is only reached when base pointers to datastructures are used. That is because there is no place
to store 64bit pointers inside an instruction (for risk at most 32bits wide)
For static programs of fairly small sizes this is an academic issue.
On 32 bit architectures that can reference memory directly from an struction 
the same...
In my case freeradius is dynamicaly linked and it uses the shadow libraries to verify passwords. Because the shadow libraries were not -fPIC compiled they
were preventing freeradius from building on 64bit architectures.

Thats why sometimes -fPIC IS needed...

As far as I'm concerned freeradius now build with the current options.
Thanks.
Comment 18 Reporter 2004-05-10 18:39:54 UTC
Yes, that'd all be correct if freeradius really needed to link to libshadow; in
that case it would be wrong to link non-pic objects into a shared lib on ALL arches.
And it's still wrong to link pic objects into executables on ALL arches.

BUT; what gentoo maintainers seem to forget is:

(1) freeradius does NOT NEED libshadow.
(2) libshadow and libmisc are internal libs to the shadow suite and should 
NOT EXIST in /usr/lib.

It's just another example of 'If something unrelated breaks, -fPIC will cure it.'


So let's start a little quiz:

1. What header file declares types and functions exported from libshadow? The
shadow ebuild certainly does not install any headers.

2. Name the .deb, .tgz, or .rpm that provides libshadow.a in Deb/Slac/SuSE.

3. What function(s) does freeradius (really) need from libshadow?

(4. I'll ask this Q later because it would give away the answers to 1.-3.)
Comment 19 Aron Griffis (RETIRED) gentoo-dev 2004-05-10 19:15:26 UTC
Hans, I appreciate the expertise you bring to the table.  Regarding shadow and freeradius, neither one is my area of expertise, I'm just helping out in an area that needs the help.  If you want to provide some help, that's quite appreciated, but you might consider offering patches instead of quizzes.  I'll re-open this bug in anticipation of your follow-up.
Comment 20 Nico Baggus 2004-05-11 10:54:07 UTC
functions reference in the link errors are:

1) I didn't study libshadow and it's surroundings, just tried to get 
   freeradius working. (a mail is underway on freeradius about this...)
2) No idea, don't use debian,Suse,Slacware I used to run Redhat 9
	but that was announce to be scrapped about now, so I converted
	to something else..... here comes Gentoo
3) And the nominees are:
	- wipe_clear_pass
	- clear_pass
   as used in the rlm_unix module.
Couldn't find a reference to those in glibc
Comment 21 Nico Baggus 2004-05-11 15:23:42 UTC
appearantly the whole discussion is moot now, the rlm_unix module can link without -lshadow.... The make file still names the library though
Comment 22 Reporter 2004-05-12 10:52:36 UTC
easy to explain:

src/modules/rlm_unix first checks for getspnam in libc:

AC_CHECK_FUNCS(getspnam getusershell)

    checking for getspnam... yes
    checking for getusershell... yes

next test is getspnam in libshadow:

        AC_CHECK_LIB(shadow, getspnam,
                [
                        unix_ldflags="${unix_ldflags} -lshadow"
                        AC_DEFINE(HAVE_GETSPNAM)
                ]
        )

    checking for getspnam in -lshadow... (result doesn't matter at this pt.)

whether the test succeeds or not; doesn't matter; the first test already has
found getspnam in libc and add HAVE_GETSPNAM in config.h; no effect on the
generated code; only difference is:

    libshadow !found:   nothing
    libshadow found:    append -lshadow to ldflags

probably because whoever wrote these tests did not expect shadow functions in
more than one place.
^L

Best fix that does not need modifications to other packages is simply to not
install libshadow. Quoting from shadow-4.0.3/doc/README.linux:

    "Currently, libshadow.a is for internal use only, so if you
    see -lshadow in a Makefile of some other package, it is safe
    to remove it."

But such Makefiles are rare, most configure scripts never put -lshadow in 
Makefiles if there is no libshadow.


___Debian___ simply skips libshadow and libmisc when moving files to their
individual sub-packages.


___SuSE___ does this:

  ./configure [...] --disable-shared [...]

  make install DESTDIR=$RPM_BUILD_ROOT
  rm $RPM_BUILD_ROOT/lib/lib{misc,shadow}.{a,la}


Slackware and RedHat may be doing the same or something completely different,
but with the same result.


so how about this:::

--------8<--------8<--------8<--------8<--------8<--------8<--------8<--------

--- shadow-4.0.3/lib/Makefile.am~       Sat Oct  6 21:53:20 2001
+++ shadow-4.0.3/lib/Makefile.am        Wed May 12 19:33:52 2004
@@ -4,7 +4,7 @@
 DEFS = 
 INCLUDES = -I$(top_srcdir)
 
-lib_LTLIBRARIES = libshadow.la
+noinst_LTLIBRARIES = libshadow.la
 
 libshadow_la_LDFLAGS = -version-info 0:0:0
 libshadow_la_LIBADD = $(INTLLIBS) $(LIBCRYPT) $(LIBTCFS) $(LIBSKEY) $(LIBMD) \

--- shadow-4.0.3/libmisc/Makefile.am~  Sun Mar 10 08:11:55 2002
+++ shadow-4.0.3/libmisc/Makefile.am   Wed May 12 19:34:43 2004
@@ -5,7 +5,7 @@
 
 INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/lib
 
-lib_LTLIBRARIES = libmisc.la
+noinst_LTLIBRARIES = libmisc.la
 
 libmisc_la_SOURCES = \
        addgrps.c \

-------->8-------->8-------->8-------->8-------->8-------->8-------->8--------

???

Comment 23 Aron Griffis (RETIRED) gentoo-dev 2004-05-24 20:42:54 UTC
Hans, I still haven't forgotten this... just back from vacation and digging into bugs :-)
Comment 24 Aron Griffis (RETIRED) gentoo-dev 2004-05-28 14:43:14 UTC
Thanks Hans!  I used the Suse approach and removed the libraries instead of patching Makefile.am.  That way I don't need to add an autoconf dep to the shadow package for now.

Finally fixed.  Please let me know if you spot something I did wrong.