Darwin (OS X) diffs for Linux-PAM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here are the patches to get 0.75 building on Darwin. Note that
this has only been tested building with the wrapper makefile in
the Darwin repository, but all that does is pass a few arguments
to configure so... see www.opensource.apple.com for more information
on retrieving things from Apple's CVS repository.

Note that I have merged in most of Mark Murray's FreeBSD patches,
but not included them below; see his message of the 7th August for
those. Also, there are some diffs to the FreeBSD extensions
(primarily support for {use,try}_mapped_pass in pam_get_pass.c
using Apple's Keychain technology, which incidentally is now
open source) which I can send separately if you are interested.

Also, we don't build _ANY_ of the Linux-PAM modules: we used
to build the ones we could (with 0.72) but it was such a mess
that we have decided to build the FreeBSD modules instead.

Individual comments follow for each file below:

Add USESONAME and NEEDSONAME to Make.Rules.in so they are exported
to makefiles.
Use override to co-exist properly with environment (needed for
wrapper makefiles) -- this may break without gnumake.

Index: Make.Rules.in
===================================================================
RCS file: /cvs/Darwin/Libraries/Other/pam/pam/Make.Rules.in,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
--- Make.Rules.in	2001/08/08 11:31:03	1.1.1.1
+++ Make.Rules.in	2001/08/09 01:48:14	1.3
@@ -67,6 +67,8 @@
 DYNAMIC_LIBPAM=@DYNAMIC_LIBPAM@
 STATIC=@STATIC@
 DYNAMIC=@DYNAMIC@
+USESONAME=@USESONAME@
+NEEDSONAME=@NEEDSONAME@
 
 # Location of libraries when installed on the system
 FAKEROOT=@FAKEROOT@
@@ -79,7 +81,7 @@
 # generic build setup
 OS=@OS@
 CC=@CC@
-CFLAGS=$(WARNINGS) -D$(OS) $(OS_CFLAGS) $(HEADER_DIRS) @CONF_CFLAGS@
+override CFLAGS+=$(WARNINGS) -D$(OS) $(OS_CFLAGS) $(HEADER_DIRS) @CONF_CFLAGS@
 LD=@LD@
 LD_D=@LD_D@
 LD_L=@LD_L@

Add PAM_DYLD, HAVE_KEYCHAIN macros to autoconf header.

Index: _pam_aconf.h.in
===================================================================
RCS file: /cvs/Darwin/Libraries/Other/pam/pam/_pam_aconf.h.in,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- _pam_aconf.h.in	2001/08/08 11:31:04	1.1.1.1
+++ _pam_aconf.h.in	2001/08/08 17:03:40	1.2
@@ -61,4 +61,10 @@
 /* location of the mail spool directory */
 #undef PAM_PATH_MAILDIR
 
+/* Darwin */
+#undef PAM_DYLD
+
+/* OS X */
+#undef HAVE_KEYCHAIN
+
 #endif /* PAM_ACONF_H */

Use cc for Darwin (really gcc).
Add Darwin specific tests and defines.

Index: configure.in
===================================================================
RCS file: /cvs/Darwin/Libraries/Other/pam/pam/configure.in,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
--- configure.in	2001/08/08 11:31:04	1.1.1.1
+++ configure.in	2001/08/09 01:48:14	1.3
@@ -26,13 +26,19 @@
 dnl Rules needed for the following (hardcoded Linux defaults for now)
 dnl
 
-CC=gcc				; AC_SUBST(CC)
 CONF_CFLAGS=			; AC_SUBST(CONF_CFLAGS)
 MKDIR="mkdir -p"		; AC_SUBST(MKDIR)
 LOCALSRCDIR=`/bin/pwd`		; AC_SUBST(LOCALSRCDIR)
 OS=`uname|sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
 AC_SUBST(OS)
 
+if test "$OS" = darwin; then
+# cc is really gcc
+CC=cc				; AC_SUBST(CC)
+else
+CC=gcc				; AC_SUBST(CC)
+fi
+
 dnl These are most likely platform specific - I think HPUX differs
 DYNTYPE=so			; AC_SUBST(DYNTYPE)
 USESONAME=yes			; AC_SUBST(USESONAME)
@@ -42,7 +48,11 @@
 dnl ### Should enable this INSTALL detection.
 dnl ### Would need to distribute GNU's config.guess and config.sub
 dnl AC_PROG_INSTALL
+if test "$OS" = darwin; then
+INSTALL="/usr/bin/install -c"	; AC_SUBST(INSTALL)
+else
 INSTALL=/usr/bin/install	; AC_SUBST(INSTALL)
+fi
 
 dnl Checks for programs.
 AC_PROG_CC
@@ -262,7 +272,28 @@
 	-Wnested-externs -Winline -Wshadow"
 
 if test "$GCC" = yes; then
+if test "$OS" = darwin; then
+###
+### Darwin needs really special attention 
 ###
+	AC_DEFINE(PAM_DYLD)
+	if test -d "/System/Library/Frameworks/Security.framework/PrivateHeaders"; then
+		AC_DEFINE(HAVE_KEYCHAIN)
+		OS_CFLAGS="-traditional-cpp -I/System/Library/Frameworks/Security.framework/PrivateHeaders"
+	else
+		OS_CFLAGS="-traditional-cpp"
+	fi
+	WARNINGS="$GCC_WARNINGS"
+	PIC="-fPIC"
+	LD=ld
+	LD_D="cc -bundle -undefined suppress"
+	LD_L='libtool -dynamic -lSystem -undefined suppress -compatibility_version $(MAJOR_REL).$(MINOR_REL) -current_version $(MAJOR_REL).$(MINOR_REL)'
+	DYNTYPE=dylib
+	RANLIB=ranlib
+	STRIP=strip
+	CC_STATIC="-Xlinker -export-dynamic"
+else
+###
 ### Non-Linux needs attention on per-OS basis
 	OS_CFLAGS="-ansi -D_POSIX_SOURCE -pedantic"
 	WARNINGS="$GCC_WARNINGS"
@@ -274,6 +305,7 @@
 	RANLIB=ranlib
 	STRIP=strip
 	CC_STATIC="-Xlinker -export-dynamic"
+fi
 else
 ###
 ### Non-gcc needs attention on per-OS basis

We install the configuration file manually, ours is different.

Index: conf/install_conf
===================================================================
RCS file: /cvs/Darwin/Libraries/Other/pam/pam/conf/install_conf,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 install_conf
--- install_conf	2000/06/13 01:21:53	1.1.1.1
+++ install_conf	2001/08/09 12:47:11
@@ -1,5 +1,10 @@
 #!/bin/bash
 
+if [ -d /System ]; then
+	echo "Skipping install_conf for Darwin."
+	exit 0
+fi
+
 CONFILE="$FAKEROOT"$CONFIGED/pam.conf
 IGNORE_AGE=./.ignore_age
 CONF=./pam.conf

libl.a not libfl.a; this should be tested for in configure.

Index: conf/pam_conv1/Makefile
===================================================================
RCS file: /cvs/Darwin/Libraries/Other/pam/pam/conf/pam_conv1/Makefile,v
retrieving revision 1.1.1.1
retrieving revision 1.5
diff -u -r1.1.1.1 -r1.5
--- Makefile	2000/06/13 01:21:53	1.1.1.1
+++ Makefile	2001/08/08 17:03:42	1.5
@@ -16,7 +16,11 @@
 all: pam_conv1
 
 pam_conv1: pam_conv.tab.c lex.yy.c
+ifeq ($(OS),darwin)
+	$(CC) -o pam_conv1 pam_conv.tab.c -ll
+else
 	$(CC) -o pam_conv1 pam_conv.tab.c -lfl
+endif
 
 pam_conv.tab.c: pam_conv.y lex.yy.c
 	bison pam_conv.y

Special doc dirs for Darwin, should probably be moved into
autoconf :-)
Make man dirs separately, seems to be a problem on Darwin

Index: doc/Makefile
===================================================================
RCS file: /cvs/Darwin/Libraries/Other/pam/pam/doc/Makefile,v
retrieving revision 1.1.1.2
retrieving revision 1.4
diff -u -r1.1.1.2 -r1.4
--- Makefile	2001/08/08 11:31:06	1.1.1.2
+++ Makefile	2001/08/08 17:03:42	1.4
@@ -4,8 +4,13 @@
 include ../Make.Rules
 
 # These two should probably be moved into autoconf...
+ifeq ($(OS),darwin)   
+DOCDIR=/System/Documentation/Administration/Libraries/PAM
+MANDIR=/usr/share/man
+else    
 DOCDIR=/usr/doc/Linux-PAM
 MANDIR=/usr/man
+endif
 
 #######################################################
 
@@ -118,7 +123,8 @@
 	  install -m 644 $$file $(FAKEROOT)$(DOCDIR)/html ; \
 	done
 endif
-	mkdir -p $(FAKEROOT)$(MANDIR)/man{3,8}
+	mkdir -p $(FAKEROOT)$(MANDIR)/man3
+	mkdir -p $(FAKEROOT)$(MANDIR)/man8
 	for file in man/*.3 ; do \
 	  install -m 644 $$file $(FAKEROOT)$(MANDIR)/man3 ; \
 	done

Correct arguments for pam_strerror().

Index: examples/test.c
===================================================================
RCS file: /cvs/Darwin/Libraries/Other/pam/pam/examples/test.c,v
retrieving revision 1.1.1.2
retrieving revision 1.3
diff -u -r1.1.1.2 -r1.3
--- test.c	2001/08/08 11:31:17	1.1.1.2
+++ test.c	2001/08/08 17:03:43	1.3
@@ -82,7 +82,7 @@
 	fprintf( stdout, "*** Attempting to perform "
 		 "PAM authentication...\n");
 	fprintf( stdout, "%s\n",
-		 pam_strerror( pam_authenticate( pamh, 0 ) ) ) ;
+		 pam_strerror(pamh, pam_authenticate( pamh, 0 ) ) ) ;
     
 	pam_end(pamh, PAM_SUCCESS);
 }

Under Darwin libraries are libfoo.1.0.dylib not libfoo.so.1.0
Various horrible stuff needed to build shared libraries which
should also be moved into autoconf

Index: libpam/Makefile
===================================================================
RCS file: /cvs/Darwin/Libraries/Other/pam/pam/libpam/Makefile,v
retrieving revision 1.1.1.2
retrieving revision 1.10
diff -u -r1.1.1.2 -r1.10
--- Makefile	2001/08/08 11:31:17	1.1.1.2
+++ Makefile	2001/08/09 01:48:15	1.10
@@ -22,15 +22,21 @@
 
 # ---------------------------------------------
 
-CFLAGS += $(DYNAMIC) $(STATIC) $(MOREFLAGS) \
+override CFLAGS += $(DYNAMIC) $(STATIC) $(MOREFLAGS) \
   -DLIBPAM_VERSION_MAJOR=$(MAJOR_REL) \
   -DLIBPAM_VERSION_MINOR=$(MINOR_REL)
 
 # dynamic library names
 
 LIBPAM = $(LIBNAME).$(DYNTYPE)
+
+ifeq ($(DYNTYPE),dylib)
+LIBPAMNAME = $(LIBNAME)$(VERSION).$(DYNTYPE)
+LIBPAMFULL = $(LIBNAME)$(VERSION)$(MODIFICATION).$(DYNTYPE)
+else
 LIBPAMNAME = $(LIBPAM)$(VERSION)
 LIBPAMFULL = $(LIBPAMNAME)$(MODIFICATION)
+endif
 
 # static library name
 
@@ -48,6 +54,11 @@
 EXTRAS += pam_malloc.o
 endif
 
+ifeq ($(OS),darwin)
+# from FreeBSD libpam; in the same repository for us.
+EXTRAS += pam_get_pass.o pam_prompt.o pam_std_option.o pam_debug_log.o 
+endif
+
 LIBOBJECTS = pam_item.o pam_strerror.o pam_end.o pam_start.o pam_data.o \
 		pam_delay.o pam_dispatch.o pam_handlers.o pam_misc.o \
 		pam_account.o pam_auth.o pam_session.o pam_password.o \
@@ -92,10 +103,15 @@
 $(LIBPAM): $(DLIBOBJECTS)
 ifeq ($(DYNAMIC_LIBPAM),yes)
     ifeq ($(USESONAME),yes)
+      ifeq ($(DYNTYPE),dylib)
+	$(LD_L) -install_name $(libdir)/$(LIBPAMFULL) -o $@ $(DLIBOBJECTS) \
+		$(MODULES) $(LINKLIBS)
+      else
 	$(LD_L) $(SOSWITCH) $(LIBPAMNAME) -o $@ $(DLIBOBJECTS) \
 		$(MODULES) $(LINKLIBS)
+      endif
     else
-	$(LD_L) -o $@ $(DLIBOBJECTS) $(MODULES) $(LINKLIBS)
+	$(LD_L) -o $@ $(DLIBOBJECTS) $(MODULES)
     endif
     ifeq ($(NEEDSONAME),yes)
 	rm -f $(LIBPAMFULL)
@@ -118,6 +134,9 @@
 	$(INSTALL) -m 644 include/security/_pam_macros.h $(FAKEROOT)$(INCLUDED)
 	$(INSTALL) -m 644 include/security/_pam_types.h $(FAKEROOT)$(INCLUDED)
 	$(INSTALL) -m 644 include/security/_pam_compat.h $(FAKEROOT)$(INCLUDED)
+ifeq ($(OS),darwin)
+	$(INSTALL) -m 644 include/security/pam_mod_misc.h $(FAKEROOT)$(INCLUDED)
+endif
 ifdef MEMORY_DEBUG
 	$(INSTALL) -m 644 include/security/pam_malloc.h $(FAKEROOT)$(INCLUDED)
 endif
@@ -125,8 +144,11 @@
 	$(INSTALL) -m $(SHLIBMODE) $(LIBPAM) $(FAKEROOT)$(libdir)/$(LIBPAMFULL)
 	$(LDCONFIG)
   ifneq ($(DYNTYPE),"sl")
-	( cd $(FAKEROOT)$(libdir) ; rm -f $(LIBPAM) ; \
-	  ln -sf $(LIBPAMNAME) $(LIBPAM) )
+    ifeq ($(DYNTYPE),dylib)
+	( cd $(FAKEROOT)$(libdir) ; rm -f $(LIBPAM) ; ln -s $(LIBPAMFULL) $(LIBPAM) )
+    else
+	( cd $(FAKEROOT)$(libdir) ; rm -f $(LIBPAM) ; ln -s $(LIBPAMNAME) $(LIBPAM) )
+    endif
   endif
 endif
 ifeq ($(STATIC_LIBPAM),yes)
@@ -139,6 +161,9 @@
 	rm -f $(FAKEROOT)$(INCLUDED)/pam_appl.h
 	rm -f $(FAKEROOT)$(INCLUDED)/pam_modules.h
 	rm -f $(FAKEROOT)$(INCLUDED)/pam_malloc.h
+ifeq ($(OS),darwin)
+	rm -f $(FAKEROOT)$(INCLUDED)/pam_mod_misc.h
+endif
 	rm -f $(FAKEROOT)$(libdir)/$(LIBPAM).*
 	rm -f $(FAKEROOT)$(libdir)/$(LIBPAM)
 	$(LDCONFIG)

Use Darwin dynamic linker API.
 
Index: libpam/pam_handlers.c
===================================================================
RCS file: /cvs/Darwin/Libraries/Other/pam/pam/libpam/pam_handlers.c,v
retrieving revision 1.1.1.2
retrieving revision 1.12
diff -u -r1.1.1.2 -r1.12
--- pam_handlers.c	2001/08/08 11:31:18	1.1.1.2
+++ pam_handlers.c	2001/08/08 17:03:44	1.12
@@ -14,23 +14,28 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #ifdef PAM_DYNAMIC
-# ifdef PAM_SHL
+# include <security/_pam_aconf.h>
+# if defined(PAM_SHL)
 #  include <dl.h>
-# else /* PAM_SHL */
+# elif defined(PAM_DYLD)
+#  include <mach-o/dyld.h>
+# else
 #  include <dlfcn.h>
-# endif /* PAM_SHL */
+# endif
 #endif /* PAM_DYNAMIC */
 #include <fcntl.h>
 #include <unistd.h>
 
 #include "pam_private.h"
 
-/* FreeBSD doesn't define this */
-#ifndef RTLD_NOW
-# define RTLD_NOW      1
+/* On OS X, we search a secondary path for non-vendor modules. */
+#ifdef __APPLE__
+# define DEFAULT_SYSTEM_MODULE_PATH    "/System/Library/Security/"
+# define SHLIB_SYM_PREFIX              "_"
+static int _pam_make_bundle_path(pam_handle_t *pamh, char **mod_full_path_p, const char *mod_path);
 #endif
 
-/* If not required, define as nothing - FreeBSD needs it to be "_"... */
+/* If not required, define as nothing */
 #ifndef SHLIB_SYM_PREFIX
 # define SHLIB_SYM_PREFIX ""
 #endif
@@ -217,6 +222,51 @@
     return ( (x < 0) ? PAM_ABORT:PAM_SUCCESS );
 }
 
+#ifdef __APPLE__
+/*
+ * MacOS X / Darwin can use "bundles" which are directories containing
+ * loadable code _plus_ other resources. We need to support both
+ * these bundles as well as individual files. The loadable code is
+ * always of Mach-O type MH_BUNDLE.
+ *
+ * char *mod_path = "kerberos.pluggableAuthenticator"; // from pam.conf
+ * char *mod_full_path =
+ *  strdup("/Local/Library/Authenticators/kerberos.pluggableAuthenticator");
+ * int success = _pam_make_bundle_path(&mod_full_path, mod_path);
+ *
+ * Now, mod_full_path =
+ *  /Local/Library/Authenticators/kerberos.pluggableAuthenticator/kerberos
+ *
+ */
+static int _pam_make_bundle_path(pam_handle_t *pamh, char **mod_full_path_p, const char *mod_path)
+{
+    char *bundle_full_path;
+    char *tmp;
+    int bundle_name_len;
+    const char *mod_full_path = *mod_full_path_p;
+
+    tmp = strrchr(mod_path, '.');
+    if (tmp != NULL) {
+        bundle_name_len = (tmp - mod_path);
+    } else {
+        bundle_name_len = strlen(mod_path);
+    }
+
+    bundle_full_path = malloc(strlen(mod_full_path) + bundle_name_len + 2 /* / \0 */);
+    if (bundle_full_path == NULL) {
+        _pam_system_log(LOG_CRIT, "_pam_make_bundle_path: cannot malloc full bundle path");
+        return PAM_ABORT;
+    }
+
+    sprintf(bundle_full_path, "%s/%.*s", mod_full_path, bundle_name_len, mod_path);
+    /* swap over the two variables */
+    _pam_drop(*mod_full_path_p);
+    *mod_full_path_p = bundle_full_path;
+
+    return PAM_SUCCESS;
+}
+#endif /* __APPLE__ */
+
 /* Parse config file, allocate handler structures, dlopen() */
 int _pam_init_handlers(pam_handle_t *pamh)
 {
@@ -279,7 +329,8 @@
 	struct stat test_d;
 	
 	/* Is there a PAM_CONFIG_D directory? */
-	if ( stat(PAM_CONFIG_D, &test_d) == 0 && S_ISDIR(test_d.st_mode) ) {
+	if ( stat(PAM_CONFIG_D, &test_d) == 0 && S_ISDIR(test_d.st_mode) )
+	{
 	    char *filename;
 	    int read_something=0;
 
@@ -492,6 +543,12 @@
     const char *sym, *sym2;
 #ifdef PAM_SHL
     const char *_sym, *_sym2;
+#elif defined(PAM_DYLD)
+    NSObjectFileImage ofile;
+    NSSymbol nsSymbol;
+#endif /* PAM_SHL */
+#ifdef __APPLE__
+    struct stat sb;
 #endif
     char *mod_full_path=NULL;
     servicefn func, func2;
@@ -504,14 +561,69 @@
     switch (mod_path != NULL) {
     default:
 	if (mod_path[0] == '/') {
-	    break;
-	}
-	mod_full_path = malloc(sizeof(DEFAULT_MODULE_PATH)+strlen(mod_path));
-	if (mod_full_path) {
-	    sprintf(mod_full_path, DEFAULT_MODULE_PATH "%s", mod_path);
-	    mod_path = mod_full_path;
+#ifdef __APPLE__
+	    /* Check whether the path is a bundle. */
+	    if ((stat(mod_path, &sb) == 0) && S_ISDIR(sb.st_mode)) {
+		mod_full_path = _pam_strdup(mod_path);
+		mod_path = strrchr(mod_full_path, '/');
+		if (mod_path == NULL) {
+		    /* Should never happen, because mod_path[0] == '/'. */
+		    return PAM_ABORT;
+		}
+		mod_path++; /* skip past slash */
+		success = _pam_make_bundle_path(pamh, &mod_full_path, mod_path);
+		if (success != PAM_SUCCESS) {
+		    _pam_drop(mod_full_path);
+		    return success;
+		}
+		mod_path = mod_full_path;
+	    }
+#endif /* __APPLE__ */
 	    break;
 	}
+#ifdef __APPLE__
+        mod_full_path = malloc(sizeof(DEFAULT_SYSTEM_MODULE_PATH) + strlen(mod_path));
+        if (mod_full_path != NULL) {
+	    /* first, try /System/Library/Security */
+	    sprintf(mod_full_path, DEFAULT_SYSTEM_MODULE_PATH "%s", mod_path);
+	    if (stat(mod_full_path, &sb) == 0) {
+		if (S_ISDIR(sb.st_mode)) {
+		    /* module is a bundle */
+		    success = _pam_make_bundle_path(pamh, &mod_full_path, mod_path);
+		    if (success != PAM_SUCCESS) {
+			_pam_drop(mod_full_path);
+			return success;
+		    }
+		} /* else module is a regular file */
+	    } else {
+		/* next, try /Local/Library/Security */
+		_pam_drop(mod_full_path);
+		mod_full_path = malloc(sizeof(DEFAULT_MODULE_PATH) + strlen(mod_path));
+		if (mod_full_path == NULL) {
+		    _pam_system_log(LOG_CRIT, "cannot malloc full mod path");
+		    return PAM_ABORT;
+		}
+		sprintf(mod_full_path, DEFAULT_MODULE_PATH "%s", mod_path);
+		if ((stat(mod_full_path, &sb) == 0) && S_ISDIR(sb.st_mode)) {
+		    /* module is a bundle */
+		    success = _pam_make_bundle_path(pamh, &mod_full_path, mod_path);
+		    if (success != PAM_SUCCESS) {
+			_pam_drop(mod_full_path);
+			return success;
+		    }
+		}
+	    }
+            mod_path = mod_full_path;
+            break;
+        }
+#else  /* __APPLE__ */
+        mod_full_path = malloc(sizeof(DEFAULT_MODULE_PATH)+strlen(mod_path));
+        if (mod_full_path) {
+            sprintf(mod_full_path, DEFAULT_MODULE_PATH "%s", mod_path);
+            mod_path = mod_full_path;
+            break;
+        }
+#endif /* __APPLE__ */
 	_pam_system_log(LOG_CRIT, "cannot malloc full mod path");
     case 0:
 	mod_path = UNKNOWN_MODULE_PATH;
@@ -549,20 +661,40 @@
 	success = PAM_ABORT;
 
 #ifdef PAM_DYNAMIC
-	D(("_pam_add_handler: dlopen(%s) -> %lx", mod_path, &mod->dl_handle));
-	mod->dl_handle =
-# ifdef PAM_SHL
+# ifdef PAM_DYLD
+        D(("_pam_add_handler: NSCreateObjectFileImageFromFile(%s) -> %lx", mod_path, &mod->dl_handle));
+        if (NSCreateObjectFileImageFromFile(mod_path, &ofile) != NSObjectFileImageSuccess) {
+            D(("_pam_add_hadler: NSCreateObjectFileImageFromFile(%s) failed", mod_path));
+            _pam_system_log(LOG_ERR, "unable to NSCreateObjectFileImageFromFile(%s)", mod_path);
+        } else {
+            mod->dl_handle = (void *)NSLinkModule(ofile, mod_path,
+                                                  NSLINKMODULE_OPTION_PRIVATE |
+                                                  NSLINKMODULE_OPTION_BINDNOW);
+            if (mod->dl_handle == NULL) {
+                D(("_pam_add_handler: NSLinkModule(%s) failed", mod_path));
+                _pam_system_log(LOG_ERR, "unable to NSLinkModule(%s)", mod_path);
+            } else {
+                D(("module added successfully"));
+                success = PAM_SUCCESS;
+                mod->type = PAM_MT_DYNAMIC_MOD;
+                pamh->handlers.modules_used++;
+            }
+        }
+# else
+        D(("_pam_add_handler: dlopen(%s) -> %lx", mod_path, &mod->dl_handle));
+        mod->dl_handle =
+#  ifdef PAM_SHL
 	    shl_load(mod_path, BIND_IMMEDIATE, 0L);
-# else /* PAM_SHL */
+#  else /* PAM_SHL */
 	    dlopen(mod_path, RTLD_NOW);
-# endif /* PAM_SHL */
+#  endif /* PAM_SHL */
 	D(("_pam_add_handler: dlopen'ed"));
 	if (mod->dl_handle == NULL) {
 	    D(("_pam_add_handler: dlopen(%s) failed", mod_path));
 	    _pam_system_log(LOG_ERR, "unable to dlopen(%s)", mod_path);
-# ifndef PAM_SHL
+#  ifndef PAM_SHL
 	    _pam_system_log(LOG_ERR, "[dlerror: %s]", dlerror());
-# endif /* PAM_SHL */
+#  endif /* PAM_SHL */
 	    /* Don't abort yet; static code may be able to find function.
 	     * But defaults to abort if nothing found below... */
 	} else {
@@ -570,7 +702,8 @@
 	    success = PAM_SUCCESS;
 	    mod->type = PAM_MT_DYNAMIC_MOD;
 	    pamh->handlers.modules_used++;
-	}
+        }
+# endif /* PAM_DYLD */
 #endif
 #ifdef PAM_STATIC
 	/* Only load static function if function was not found dynamically.
@@ -606,7 +739,7 @@
 	    D(("_pam_handler: couldn't get memory for mod_path"));
 	    _pam_system_log(LOG_ERR, "no memory for module path", mod_path);
 	    success = PAM_ABORT;
-	}
+        }
 
     } else {                           /* x != pamh->handlers.modules_used */
 	mod += x;                                    /* the located module */
@@ -706,6 +839,9 @@
 # ifdef PAM_SHL
 	(shl_findsym(&mod->dl_handle, sym, (short) TYPE_PROCEDURE, &func) &&
 	 shl_findsym(&mod->dl_handle, _sym, (short) TYPE_PROCEDURE, &func))
+# elif defined(PAM_DYLD)
+        ((nsSymbol = NSLookupSymbolInModule((NSModule)mod->dl_handle, sym)) == NULL ||
+         (func = (servicefn)NSAddressOfSymbol(nsSymbol)) == NULL)
 # else /* PAM_SHL */
         (func = (servicefn) dlsym(mod->dl_handle, sym)) == NULL
 # endif /* PAM_SHL */
@@ -720,11 +856,14 @@
     }
 #endif
     if (sym2) {
-#ifdef PAM_DYNAMIC
+#ifdef PAM_DYNAMIC        
 	if ((mod->type == PAM_MT_DYNAMIC_MOD) &&
 # ifdef PAM_SHL
 	    (shl_findsym(&mod->dl_handle,sym2,(short)TYPE_PROCEDURE, &func2)&&
 	     shl_findsym(&mod->dl_handle,_sym2,(short)TYPE_PROCEDURE, &func2))
+# elif defined(PAM_DYLD)
+	    ((nsSymbol = NSLookupSymbolInModule((NSModule)mod->dl_handle, sym2)) == NULL ||
+	      (func2 = (servicefn)NSAddressOfSymbol(nsSymbol)) == NULL)
 # else /* PAM_SHL */
 	    (func2 = (servicefn) dlsym(mod->dl_handle, sym2)) == NULL
 # endif /* PAM_SHL */
@@ -817,7 +956,9 @@
 	if (mod->type == PAM_MT_DYNAMIC_MOD) {
 # ifdef PAM_SHL
 	    shl_unload(mod->dl_handle);
-# else
+# elif defined(PAM_DYLD)
+            NSUnLinkModule((NSModule)mod->dl_handle, NSUNLINKMODULE_OPTION_NONE);
+# else                  
 	    dlclose(mod->dl_handle);
 # endif
 	}

Don't mention Linux :-)
 
Index: libpam/pam_strerror.c
===================================================================
RCS file: /cvs/Darwin/Libraries/Other/pam/pam/libpam/pam_strerror.c,v
retrieving revision 1.1.1.2
retrieving revision 1.3
diff -u -r1.1.1.2 -r1.3
--- pam_strerror.c	2001/08/08 11:31:20	1.1.1.2
+++ pam_strerror.c	2001/08/08 17:03:45	1.3
@@ -89,5 +89,9 @@
 	return "Application needs to call libpam again";
     }
 
+#ifdef __APPLE__
+    return "Unknown PAM error";
+#else
     return "Unknown Linux-PAM error (need to upgrde libpam?)";
+#endif
 }

Shared library mess for makefiles.
 
Index: libpam_misc/Makefile
===================================================================
RCS file: /cvs/Darwin/Libraries/Other/pam/pam/libpam_misc/Makefile,v
retrieving revision 1.1.1.2
retrieving revision 1.7
diff -u -r1.1.1.2 -r1.7
--- Makefile	2001/08/08 11:31:22	1.1.1.2
+++ Makefile	2001/08/09 01:48:16	1.7
@@ -15,13 +15,18 @@
 VERSION=.$(MAJOR_REL)
 MODIFICATION=.$(MINOR_REL)
 
-CFLAGS += $(MOREFLAGS) $(DYNAMIC) $(STATIC)
+override CFLAGS += $(MOREFLAGS) $(DYNAMIC) $(STATIC)
 
 # dynamic library names
 
 LIBNAMED = $(LIBNAME).$(DYNTYPE)
+ifeq ($(DYNTYPE),dylib)
+LIBNAMEDNAME=$(LIBNAME)$(VERSION).$(DYNTYPE)
+LIBNAMEDFULL=$(LIBNAME)$(VERSION)$(MODIFICATION).$(DYNTYPE)
+else
 LIBNAMEDNAME = $(LIBNAMED)$(VERSION)
 LIBNAMEDFULL = $(LIBNAMEDNAME)$(MODIFICATION)
+endif
 
 # static library name
 
@@ -59,7 +64,11 @@
 $(LIBNAMED): $(DLIBOBJECTS)
 ifeq ($(DYNAMIC_LIBPAM),yes)
     ifeq ($(USESONAME),yes)
+      ifeq ($(DYNTYPE),dylib)
+	$(LD_L) -install_name $(libdir)/$(LIBNAMEDFULL) -o $@ $(DLIBOBJECTS) $(MODULES) $(LINKLIBS)
+      else
 	$(LD_L) $(SOSWITCH) $(LIBNAMEDNAME) -o $@ $(DLIBOBJECTS) $(MODULES) $(LINKLIBS)
+      endif
     else
 	$(LD_L) -o $@ $(DLIBOBJECTS) $(MODULES)
     endif
@@ -85,7 +94,11 @@
 	$(INSTALL) -m $(SHLIBMODE) $(LIBNAMED) $(FAKEROOT)$(libdir)/$(LIBNAMEDFULL)
 	$(LDCONFIG)
   ifneq ($(DYNTYPE),"sl")
+     ifeq ($(DYNTYPE),dylib)
+	( cd $(FAKEROOT)$(libdir) ; rm -f $(LIBNAMED) ; ln -s $(LIBNAMEDFULL) $(LIBNAMED) )
+     else
 	( cd $(FAKEROOT)$(libdir) ; rm -f $(LIBNAMED) ; ln -s $(LIBNAMEDNAME) $(LIBNAMED) )
+     endif
   endif
 endif
 ifeq ($(STATIC_LIBPAM),yes)
 
Index: libpamc/Makefile
===================================================================
RCS file: /cvs/Darwin/Libraries/Other/pam/pam/libpamc/Makefile,v
retrieving revision 1.1.1.2
retrieving revision 1.7
diff -u -r1.1.1.2 -r1.7
--- Makefile	2001/08/08 11:31:22	1.1.1.2
+++ Makefile	2001/08/09 01:48:17	1.7
@@ -15,13 +15,18 @@
 VERSION=.$(MAJOR_REL)
 MODIFICATION=.$(MINOR_REL)
 
-CFLAGS += $(MOREFLAGS) $(DYNAMIC) $(STATIC)
+override CFLAGS += $(MOREFLAGS) $(DYNAMIC) $(STATIC)
 
 # dynamic library names
 
 LIBNAMED = $(LIBNAME).$(DYNTYPE)
+ifeq ($(DYNTYPE),dylib)
+LIBNAMEDNAME=$(LIBNAME)$(VERSION).$(DYNTYPE)
+LIBNAMEDFULL=$(LIBNAME)$(VERSION)$(MODIFICATION).$(DYNTYPE)
+else
 LIBNAMEDNAME = $(LIBNAMED)$(VERSION)
 LIBNAMEDFULL = $(LIBNAMEDNAME)$(MODIFICATION)
+endif
 
 # static library name
 
@@ -59,7 +64,11 @@
 $(LIBNAMED): $(DLIBOBJECTS)
 ifeq ($(DYNAMIC_LIBPAM),yes)
     ifeq ($(USESONAME),yes)
+     ifeq ($(DYNTYPE),dylib)
+	$(LD_L) -install_name $(libdir)/$(LIBNAMEDFULL) -o $@ $(DLIBOBJECTS) $(MODULES) $(LINKLIBS)
+     else
 	$(LD_L) $(SOSWITCH) $(LIBNAMEDNAME) -o $@ $(DLIBOBJECTS) $(MODULES) $(LINKLIBS)
+     endif
     else
 	$(LD_L) -o $@ $(DLIBOBJECTS) $(MODULES)
     endif
@@ -85,7 +94,11 @@
 	$(INSTALL) -m $(SHLIBMODE) $(LIBNAMED) $(FAKEROOT)$(libdir)/$(LIBNAMEDFULL)
 	$(LDCONFIG)
   ifneq ($(DYNTYPE),"sl")
+    ifeq ($(DYNTYPE),dylib)
+	( cd $(FAKEROOT)$(libdir) ; rm -f $(LIBNAMED) ; ln -s $(LIBNAMEDFULL) $(LIBNAMED) )
+    else
 	( cd $(FAKEROOT)$(libdir) ; rm -f $(LIBNAMED) ; ln -s $(LIBNAMEDNAME) $(LIBNAMED) )
+    endif
   endif
 endif
 ifeq ($(STATIC_LIBPAM),yes)
--
Luke Howard | lukehoward.com
PADL Software | www.padl.com





[Index of Archives]     [Fedora Users]     [Kernel]     [Red Hat Install]     [Linux for the blind]     [Gimp]

  Powered by Linux