From 2f36c829822a4b016ba075575c720ad9cb3c6463 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Sun, 13 Jul 2003 18:41:04 +0000 Subject: Relevant BUGIDs: 643357 Purpose of commit: bugfix Commit summary: --------------- Patch from Sam Hartman to fix handling of module linking on Linux: modules should be linked against libpam if they call any functions from the library, since not all platforms will correctly resolve symbol references otherwise. Also, make sure we use gcc, not ld, when linking, since there's additional linker glue that gcc will pull in for us. --- Make.Rules.in | 1 + Makefile | 6 +++++- configure.in | 10 ++++------ libpam/Makefile | 7 ++++++- modules/Simple.Rules | 2 +- modules/pam_access/Makefile | 3 +++ modules/pam_limits/Makefile | 3 +++ modules/pam_tally/Makefile | 2 +- modules/pam_unix/Makefile | 2 +- 9 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Make.Rules.in b/Make.Rules.in index d7b87be2..e42c965b 100644 --- a/Make.Rules.in +++ b/Make.Rules.in @@ -44,6 +44,7 @@ SHLIBMODE=@SHLIBMODE@ NEED_LINK_LIB_C=@PAM_NEEDS_LIBC@ HAVE_LCKPWDF=@HAVE_LCKPWDF@ HAVE_LIBCRACK=@HAVE_LIBCRACK@ +HAVE_LIBCAP=@HAVE_LIBCAP@ HAVE_LIBCRYPT=@HAVE_LIBCRYPT@ HAVE_LIBUTIL=@HAVE_LIBUTIL@ HAVE_NDBM_H=@HAVE_NDBM_H@ diff --git a/Makefile b/Makefile index 47c7bd39..06c162fd 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,10 @@ THINGSTOMAKE = modules libpam libpamc libpam_misc doc examples all: $(THINGSTOMAKE) + # Let's get a dynamic libpam.so first + bootstrap-libpam: _pam_aconf.h prep + $(MAKE) -C libpam bootstrap-libpam + prep: rm -f security ln -sf . security @@ -52,7 +56,7 @@ configure: configure.in @rm -f configure @exit 1 -$(THINGSTOMAKE): _pam_aconf.h prep +$(THINGSTOMAKE): _pam_aconf.h prep bootstrap-libpam $(MAKE) -C $@ all install: _pam_aconf.h prep diff --git a/configure.in b/configure.in index 3c498a7c..a7a298c7 100644 --- a/configure.in +++ b/configure.in @@ -42,7 +42,7 @@ SHLIBMODE=755 ; AC_SUBST(SHLIBMODE) dnl These are most likely platform specific - I think HPUX differs USESONAME=yes ; AC_SUBST(USESONAME) -SOSWITCH=-soname ; AC_SUBST(SOSWITCH) +SOSWITCH='-Xlinker -soname -Xlinker ' ; AC_SUBST(SOSWITCH) NEEDSONAME=no ; AC_SUBST(NEEDSONAME) LDCONFIG=/sbin/ldconfig ; AC_SUBST(LDCONFIG) @@ -282,9 +282,7 @@ AC_SUBST(CRACKLIB_DICTPATH) dnl Set FLAGS, linker options etc. depending on C compiler. dnl gcc is tested and much preferred; others less so, if at all dnl -dnl If compiling with gcc, linking is also supposed to be done with gcc; -dnl since we use linker-specific arguments, we may not gain anything by -dnl switching LD_L over, but I think we can use LD_D as-is. +dnl If compiling with gcc, linking is also supposed to be done with gcc dnl dnl For the moment, gcc is enforced above at "CC=gcc". dnl @@ -309,8 +307,8 @@ if test "$GCC" = yes; then WARNINGS="$GCC_WARNINGS" PIC="-fPIC" DYNTYPE=so - LD=ld - LD_L="$LD -x -shared" + LD=gcc + LD_L="$LD -Xlinker -x -shared" RANLIB=ranlib STRIP=strip CC_STATIC="-Xlinker -export-dynamic" diff --git a/libpam/Makefile b/libpam/Makefile index cf49f627..d87cb028 100644 --- a/libpam/Makefile +++ b/libpam/Makefile @@ -10,6 +10,8 @@ MOREFLAGS=-D"DEFAULT_MODULE_PATH=\"$(SECUREDIR)/\"" ifeq ($(WITH_LIBDEBUG),yes) LIBNAME=libpamd + CFLAGS += -D"DEBUG" + CFLAGS += -g else LIBNAME=libpam endif @@ -37,7 +39,7 @@ LIBPAMFULL = $(LIBPAMNAME)$(MODIFICATION) LIBPAMSTATIC = $(LIBNAME).a ifdef STATIC -@echo Did you mean to set STATIC\? +# @echo Did you mean to set STATIC\? MODULES = $(shell cat ../modules/_static_module_objects) STATICOBJ = pam_static.o else @@ -88,6 +90,9 @@ dynamic/%.o : %.c static/%.o : %.c $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@ +bootstrap-libpam: bootdir $(LIBPAM) +bootdir: + test -d dynamic || mkdir dynamic $(LIBPAM): $(DLIBOBJECTS) ifeq ($(DYNAMIC_LIBPAM),yes) diff --git a/modules/Simple.Rules b/modules/Simple.Rules index 2d79b00c..bb16e48d 100644 --- a/modules/Simple.Rules +++ b/modules/Simple.Rules @@ -19,7 +19,7 @@ LIBOBJ = $(addsuffix .o,$(LIBFILES)) LIBOBJD = $(addprefix dynamic/,$(LIBOBJ)) LIBOBJS = $(addprefix static/,$(LIBOBJ)) -LINK_PAMMODUTILS = -L../pammodutil -lpammodutil +LINK_PAMMODUTILS = -L../pammodutil -lpammodutil -L../../libpam -lpam INCLUDE_PAMMODUTILS = -I../pammodutil/include ifdef DYNAMIC diff --git a/modules/pam_access/Makefile b/modules/pam_access/Makefile index d93c9f40..87b2b3e6 100644 --- a/modules/pam_access/Makefile +++ b/modules/pam_access/Makefile @@ -10,6 +10,9 @@ include ../../Make.Rules TITLE=pam_access LOCAL_CONFILE=./access.conf INSTALLED_CONFILE=$(SCONFIGD)/access.conf +ifeq ($(HAVE_LIBNSL),yes) +MODULE_SIMPLE_EXTRALIBS=-lnsl +endif DEFS=-DDEFAULT_CONF_FILE=\"$(INSTALLED_CONFILE)\" CFLAGS += $(DEFS) diff --git a/modules/pam_limits/Makefile b/modules/pam_limits/Makefile index 9473d915..0a481fe8 100644 --- a/modules/pam_limits/Makefile +++ b/modules/pam_limits/Makefile @@ -21,6 +21,9 @@ CFLAGS += $(DEFS) MODULE_SIMPLE_INSTALL=bash -f ../install_conf "$(FAKEROOT)" "$(SCONFIGD)" "$(INSTALLED_CONFILE)" "$(TITLE)" "$(LOCAL_CONFILE)" MODULE_SIMPLE_REMOVE=rm -f $(FAKEROOT)$(INSTALLED_CONFILE) MODULE_SIMPLE_CLEAN=rm -f ./.ignore_age +ifeq ($(HAVE_LIBCAP),yes) +MODULE_SIMPLE_EXTRALIBS=-lcap +endif include ../Simple.Rules diff --git a/modules/pam_tally/Makefile b/modules/pam_tally/Makefile index 1c5106e3..c39970dd 100644 --- a/modules/pam_tally/Makefile +++ b/modules/pam_tally/Makefile @@ -65,7 +65,7 @@ ifdef DYNAMIC $(LIBOBJD): $(LIBSRC) $(LIBSHARED): $(LIBOBJD) - $(LD_D) -o $@ $(LIBOBJD) + $(LD_D) -o $@ $(LIBOBJD) -L../../libpam -lpam $(NEED_LINK_LIB_C) $(APPLICATION): $(APPOBJD) $(TITLE).c $(CC) $(CFLAGS) -o $@ $(APPOBJD) $(LOADLIBES) diff --git a/modules/pam_unix/Makefile b/modules/pam_unix/Makefile index 0cab34bc..61c4beaa 100644 --- a/modules/pam_unix/Makefile +++ b/modules/pam_unix/Makefile @@ -109,7 +109,7 @@ ifdef DYNAMIC $(LIBOBJD): $(LIBSRC) $(LIBSHARED): $(LIBOBJD) - $(LD_D) -o $@ $(LIBOBJD) $(PLUS) $(CRACKLIB) $(LDLIBS) $(LIBNSL) $(LIBCRYPT) + $(LD_D) -o $@ $(LIBOBJD) $(PLUS) $(CRACKLIB) $(LDLIBS) $(LIBNSL) $(LIBCRYPT) $(NEED_LINK_LIB_C) -L../../libpam -lpam endif ifdef STATIC -- cgit v1.2.3