Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Jun 2005 19:33:00 GMT
From:      Dag-Erling Smorgrav <des@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 78271 for review
Message-ID:  <200506091933.j59JX0gf057596@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=78271

Change 78271 by des@des.at.des.no on 2005/06/09 19:32:00

	If the module path is relative, prepend the module installation
	directory which was specified at configure time.
	
	Inspired by:	NetBSD

Affected files ...

.. //depot/projects/openpam/lib/Makefile.am#4 edit
.. //depot/projects/openpam/lib/openpam_dynamic.c#14 edit

Differences ...

==== //depot/projects/openpam/lib/Makefile.am#4 (text+ko) ====

@@ -1,3 +1,5 @@
+# $P4: //depot/projects/openpam/lib/Makefile.am#4 $
+
 NULL =
 
 INCLUDES = -I$(top_srcdir)/include
@@ -48,6 +50,8 @@
 	pam_vprompt.c \
 	$(NULL)
 
+libpam_la_CFLAGS = -DOPENPAM_MODULES_DIR='"@OPENPAM_MODULES_DIR@"'
+
 libpam_la_LDFLAGS = -no-undefined -version-info @LIB_MAJ@ @DL_LIBS@
 
 # Not implemented yet:

==== //depot/projects/openpam/lib/openpam_dynamic.c#14 (text+ko) ====

@@ -31,7 +31,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $P4: //depot/projects/openpam/lib/openpam_dynamic.c#13 $
+ * $P4: //depot/projects/openpam/lib/openpam_dynamic.c#14 $
  */
 
 #include <dlfcn.h>
@@ -57,6 +57,7 @@
 openpam_dynamic(const char *path)
 {
 	pam_module_t *module;
+	const char *prefix;
 	char *vpath;
 	void *dlh;
 	int i;
@@ -65,8 +66,14 @@
 	if ((module = calloc(1, sizeof *module)) == NULL)
 		goto buf_err;
 
+	/* Prepend the standard prefix if not an absolute pathname. */
+	if (path[0] != '/')
+		prefix = OPENPAM_MODULES_DIR;
+	else
+		prefix = "";
+
 	/* try versioned module first, then unversioned module */
-	if (asprintf(&vpath, "%s.%d", path, LIB_MAJ) < 0)
+	if (asprintf(&vpath, "%s%s.%d", prefix, path, LIB_MAJ) < 0)
 		goto buf_err;
 	if ((dlh = dlopen(vpath, RTLD_NOW)) == NULL) {
 		openpam_log(PAM_LOG_DEBUG, "%s: %s", vpath, dlerror());



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200506091933.j59JX0gf057596>