summaryrefslogtreecommitdiff
path: root/contrib/libpam/libpam_misc
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libpam/libpam_misc')
-rw-r--r--contrib/libpam/libpam_misc/Makefile139
-rw-r--r--contrib/libpam/libpam_misc/help_env.c9
-rw-r--r--contrib/libpam/libpam_misc/include/security/pam_misc.h57
-rw-r--r--contrib/libpam/libpam_misc/misc_conv.c100
-rw-r--r--contrib/libpam/libpam_misc/xstrdup.c9
5 files changed, 159 insertions, 155 deletions
diff --git a/contrib/libpam/libpam_misc/Makefile b/contrib/libpam/libpam_misc/Makefile
index 1cfc86577b1f0..b7ff178cbe7d9 100644
--- a/contrib/libpam/libpam_misc/Makefile
+++ b/contrib/libpam/libpam_misc/Makefile
@@ -1,109 +1,106 @@
-# $Header: /home/morgan/pam/Linux-PAM-0.57/libpam_misc/RCS/Makefile,v 1.10 1997/04/05 07:00:18 morgan Exp $
#
-# $Log: Makefile,v $
-# Revision 1.10 1997/04/05 07:00:18 morgan
-# fakeroot
-#
-# Revision 1.9 1997/02/15 15:46:56 morgan
-# inherit major and minor numbers from top level
-#
-# Revision 1.8 1997/01/04 20:20:11 morgan
-# update for .55 and make -> $(MAKE)
-#
-# Revision 1.7 1996/12/01 03:28:11 morgan
-# update for 0.54
+# $Id: Makefile,v 1.3 2001/02/10 07:17:53 agmorgan Exp $
#
-dummy:
- @echo "*** This is not a top-level Makefile!"
+# lots of debugging information goes to /tmp/pam-debug.log
+#MOREFLAGS += -D"DEBUG"
-# ///////////////////////////////////////////////////////////////////
+include ../Make.Rules
-# uncomment if you wnat libpam_misc to be made as a dynamic library
-# AGM has had some segfaulting from libdl when I did this. I have not
-# investigated the cause...
-
-MAKE_DYNAMIC=yes
-
-ifeq ($(DEBUG_REL),yes)
- LIBNAME=pamd_misc
+ifeq ($(WITH_LIBDEBUG),yes)
+ LIBNAME=libpam_miscd
else
- LIBNAME=pam_misc
+ LIBNAME=libpam_misc
endif
-LIBMAJOR=$(MAJOR_REL)
-LIBMINOR=$(MINOR_REL)
-
-FILES=misc_conv help_env
+VERSION=.$(MAJOR_REL)
+MODIFICATION=.$(MINOR_REL)
-#
-# Probably no need to alter anything below here.
-#
+CFLAGS += $(MOREFLAGS) $(DYNAMIC) $(STATIC)
-# build dynamic library names
+# dynamic library names
-LIBDYNAMIC=lib$(LIBNAME).$(DYNTYPE)
-LIBDYNMAJ=$(LIBDYNAMIC).$(LIBMAJOR)
-LIBDYNMIN=$(LIBDYNMAJ).$(LIBMINOR)
+LIBNAMED = $(LIBNAME).$(DYNTYPE)
+LIBNAMEDNAME = $(LIBNAMED)$(VERSION)
+LIBNAMEDFULL = $(LIBNAMEDNAME)$(MODIFICATION)
# static library name
-LIBSTATIC = lib$(LIBNAME).a
+LIBNAMEDSTATIC = $(LIBNAME).a
+
+LIBOBJECTS = help_env.o misc_conv.o
-# sources and object files
+ifeq ($(DYNAMIC_LIBPAM),yes)
+DLIBOBJECTS = $(addprefix dynamic/,$(LIBOBJECTS))
+endif
-LIBSRC = $(addsuffix .c,$(FILES))
-LIBOBJ = $(addsuffix .o,$(FILES))
+ifeq ($(STATIC_LIBPAM),yes)
+SLIBOBJECTS = $(addprefix static/,$(LIBOBJECTS))
+endif
-# rules
+# ---------------------------------------------
+## rules
-all: $(LIBSTATIC) $(LIBDYNAMIC)
+all: dirs $(LIBNAMED) $(LIBNAMEDSTATIC)
-$(LIBDYNAMIC): $(LIBOBJ)
-ifdef MAKE_DYNAMIC
+dirs:
+ifeq ($(DYNAMIC_LIBPAM),yes)
+ $(MKDIR) dynamic
+endif
+ifeq ($(STATIC_LIBPAM),yes)
+ $(MKDIR) static
+endif
+
+dynamic/%.o : %.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
+
+static/%.o : %.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
+
+$(LIBNAMED): $(DLIBOBJECTS)
+ifeq ($(DYNAMIC_LIBPAM),yes)
ifeq ($(USESONAME),yes)
- $(LD_L) $(SOSWITCH) $(LIBDYNMAJ) -o $@ $(LIBOBJ)
+ $(LD_L) $(SOSWITCH) $(LIBNAMEDNAME) -o $@ $(DLIBOBJECTS) $(MODULES) $(LINKLIBS)
else
- $(LD_L) -o $@ $(LIBOBJ)
+ $(LD_L) -o $@ $(DLIBOBJECTS) $(MODULES)
endif
ifeq ($(NEEDSONAME),yes)
- rm -f $(LIBDYNMIN)
- ln -s $(LIBDYNAMIC) $(LIBDYNMAJ)
- rm -f $(LIBDYNMAJ)
- ln -s $(LIBDYNAMIC) $(LIBDYNMIN)
+ rm -f $(LIBNAMEDFULL)
+ ln -s $(LIBNAMED) $(LIBNAMEDFULL)
+ rm -f $(LIBNAMEDNAME)
+ ln -s $(LIBNAMED) $(LIBNAMEDNAME)
endif
endif
-$(LIBSTATIC): $(LIBOBJ)
- $(AR) $@ $(LIBOBJ)
+$(LIBNAMEDSTATIC): $(SLIBOBJECTS)
+ifeq ($(STATIC_LIBPAM),yes)
+ $(AR) rc $@ $(SLIBOBJECTS) $(MODULES)
$(RANLIB) $@
+endif
install: all
$(MKDIR) $(FAKEROOT)$(INCLUDED)
- $(INSTALL) -m 644 ./pam_misc.h $(FAKEROOT)$(INCLUDED)
-ifdef MAKE_DYNAMIC
- $(INSTALL) -m $(SHLIBMODE) $(LIBDYNAMIC) $(FAKEROOT)$(LIBDIR)/$(LIBDYNMIN)
+ $(INSTALL) -m 644 include/security/pam_misc.h $(FAKEROOT)$(INCLUDED)
+ifeq ($(DYNAMIC_LIBPAM),yes)
+ $(MKDIR) $(FAKEROOT)$(libdir)
+ $(INSTALL) -m $(SHLIBMODE) $(LIBNAMED) $(FAKEROOT)$(libdir)/$(LIBNAMEDFULL)
$(LDCONFIG)
ifneq ($(DYNTYPE),"sl")
- ( cd $(FAKEROOT)$(LIBDIR) ; ln -sf $(LIBDYNMAJ) $(LIBDYNAMIC) )
+ ( cd $(FAKEROOT)$(libdir) ; rm -f $(LIBNAMED) ; ln -s $(LIBNAMEDNAME) $(LIBNAMED) )
endif
endif
- $(INSTALL) -m 644 $(LIBSTATIC) $(FAKEROOT)$(LIBDIR)
-
-clean:
- rm -f *.so *.a core a.out *~
+ifeq ($(STATIC_LIBPAM),yes)
+ $(INSTALL) -m 644 $(LIBNAMEDSTATIC) $(FAKEROOT)$(libdir)
+endif
remove:
rm -f $(FAKEROOT)$(INCLUDED)/pam_misc.h
- rm -f $(FAKEROOT)$(LIBDIR)/$(LIBDYNAMIC).*
- rm -f $(FAKEROOT)$(LIBDIR)/$(LIBDYNAMIC)
+ rm -f $(FAKEROOT)$(libdir)/$(LIBNAMEDFULL)
+ rm -f $(FAKEROOT)$(libdir)/$(LIBNAMED)
$(LDCONFIG)
- rm -f $(FAKEROOT)$(LIBDIR)/$(LIBSTATIC)
- rm -f $(FAKEROOT)$(INCLUDED)/chk_malloc.h
-
-.c.o:
- $(CC) -c $(DEFS) $(CFLAGS) $<
-
-extraclean:
- @$(MAKE) clean
- rm -f *.o *.bak
+ rm -f $(FAKEROOT)$(libdir)/$(LIBNAMEDSTATIC)
+clean:
+ rm -f a.out core *~ static/*.o dynamic/*.o
+ rm -f *.a *.out *.o *.so ./include/security/*~
+ if [ -d dynamic ]; then rmdir dynamic ; fi
+ if [ -d static ]; then rmdir static ; fi
diff --git a/contrib/libpam/libpam_misc/help_env.c b/contrib/libpam/libpam_misc/help_env.c
index d35b66b948ca6..e1390984273ca 100644
--- a/contrib/libpam/libpam_misc/help_env.c
+++ b/contrib/libpam/libpam_misc/help_env.c
@@ -1,15 +1,8 @@
/*
- * $Id: help_env.c,v 1.2 1997/01/04 20:19:20 morgan Exp morgan $
+ * $Id: help_env.c,v 1.2 2000/12/04 19:02:34 baggins Exp $
*
* This file was written by Andrew G. Morgan <morgan@parc.power.net>
*
- * $Log: help_env.c,v $
- * Revision 1.2 1997/01/04 20:19:20 morgan
- * added a prototype (no warning) and fixed paste function
- *
- * Revision 1.1 1996/12/01 03:25:37 morgan
- * Initial revision
- *
*/
#include <stdlib.h>
diff --git a/contrib/libpam/libpam_misc/include/security/pam_misc.h b/contrib/libpam/libpam_misc/include/security/pam_misc.h
new file mode 100644
index 0000000000000..1e8c4784c532e
--- /dev/null
+++ b/contrib/libpam/libpam_misc/include/security/pam_misc.h
@@ -0,0 +1,57 @@
+/* $Id: pam_misc.h,v 1.3 2001/01/20 22:29:47 agmorgan Exp $ */
+
+#ifndef __PAMMISC_H
+#define __PAMMISC_H
+
+#include <security/pam_appl.h>
+#include <security/pam_client.h>
+
+/* include some useful macros */
+
+#include <security/_pam_macros.h>
+
+/* functions defined in pam_misc.* libraries */
+
+extern int misc_conv(int num_msg, const struct pam_message **msgm,
+ struct pam_response **response, void *appdata_ptr);
+
+#include <time.h>
+
+extern time_t pam_misc_conv_warn_time; /* time that we should warn user */
+extern time_t pam_misc_conv_die_time; /* cut-off time for input */
+extern const char *pam_misc_conv_warn_line; /* warning notice */
+extern const char *pam_misc_conv_die_line; /* cut-off remark */
+extern int pam_misc_conv_died; /* 1 = cut-off time reached (0 not) */
+extern int (*pam_binary_handler_fn)(void *appdata, pamc_bp_t *prompt_p);
+extern void (*pam_binary_handler_free)(void *appdata, pamc_bp_t *prompt_p);
+/*
+ * Environment helper functions
+ */
+
+/* transcribe given environment (to pam) */
+extern int pam_misc_paste_env(pam_handle_t *pamh
+ , const char * const * user_env);
+
+/* char **pam_misc_copy_env(pam_handle_t *pamh);
+
+ This is no longer defined as a prototype because the X/Open XSSO
+ spec makes it clear that PAM's pam_getenvlist() does exactly
+ what this was needed for.
+
+ A wrapper is still provided in the pam_misc library - so that
+ legacy applications will still work. But _BE_WARNED_ it will
+ disappear by the release of libpam 1.0 . */
+
+/* delete environment as obtained from (pam_getenvlist) */
+extern char **pam_misc_drop_env(char **env);
+
+/* provide something like the POSIX setenv function for the (Linux-)PAM
+ * environment. */
+
+extern int pam_misc_setenv(pam_handle_t *pamh, const char *name
+ , const char *value, int readonly);
+
+#endif
+
+
+
diff --git a/contrib/libpam/libpam_misc/misc_conv.c b/contrib/libpam/libpam_misc/misc_conv.c
index 53cf51b76ccc4..8e2460dc4c138 100644
--- a/contrib/libpam/libpam_misc/misc_conv.c
+++ b/contrib/libpam/libpam_misc/misc_conv.c
@@ -1,32 +1,12 @@
/*
- * $Id: misc_conv.c,v 1.5 1997/01/04 20:16:48 morgan Exp morgan $
+ * $Id: misc_conv.c,v 1.3 2001/01/20 22:29:47 agmorgan Exp $
*
* A generic conversation function for text based applications
*
* Written by Andrew Morgan <morgan@linux.kernel.org>
- *
- * $Log: misc_conv.c,v $
- * Revision 1.5 1997/01/04 20:16:48 morgan
- * removed getpass. Replaced with POSIX code for same function which
- * also observes timeouts specified by the parent application
- *
- * Revision 1.4 1996/12/01 03:26:51 morgan
- * *** empty log message ***
- *
- * Revision 1.3 1996/11/10 20:10:01 morgan
- * sgi definition
- *
- * Revision 1.2 1996/07/07 23:59:56 morgan
- * changed the name of the misc include file
- *
- * Revision 1.1 1996/05/02 05:17:06 morgan
- * Initial revision
*/
-#ifdef linux
-#define _GNU_SOURCE
-#include <features.h>
-#endif
+#include <security/_pam_aconf.h>
#include <signal.h>
#include <stdio.h>
@@ -57,39 +37,23 @@ const char *pam_misc_conv_die_line = "..\a.Sorry, your time is up!\n";
int pam_misc_conv_died=0; /* application can probe this for timeout */
-static void pam_misc_conv_delete_binary(void **delete_me)
+/*
+ * These functions are for binary prompt manipulation.
+ * The manner in which a binary prompt is processed is application
+ * specific, so these function pointers are provided and can be
+ * initialized by the application prior to the conversation function
+ * being used.
+ */
+
+static void pam_misc_conv_delete_binary(void *appdata,
+ pamc_bp_t *delete_me)
{
- if (delete_me && *delete_me) {
- unsigned char *packet = *(unsigned char **)delete_me;
- int length;
-
- length = 4+(packet[0]<<24)+(packet[1]<<16)+(packet[2]<<8)+packet[3];
- memset(packet, 0, length);
- free(packet);
- *delete_me = packet = NULL;
- }
+ PAM_BP_RENEW(delete_me, 0, 0);
}
-/* These function pointers are for application specific binary
- conversations. One or both of the arguments to the first function
- must be non-NULL. The first function must return PAM_SUCCESS or
- PAM_CONV_ERR. If input is non-NULL, a response is expected, this
- response should be malloc()'d and will eventually be free()'d by
- the calling module. The structure of this malloc()'d response is as
- follows:
-
- { int length, char data[length] }
-
- For convenience, the pointer used by the two function pointer
- prototypes is 'void *'.
-
- The ...free() fn pointer is used to discard a binary message that
- is not of the default form. It should be explicitly overwritten
- when using some other convention for the structure of a binary
- prompt (not recommended). */
-
-int (*pam_binary_handler_fn)(const void *send, void **receive) = NULL;
-void (*pam_binary_handler_free)(void **packet_p) = pam_misc_conv_delete_binary;
+int (*pam_binary_handler_fn)(void *appdata, pamc_bp_t *prompt_p) = NULL;
+void (*pam_binary_handler_free)(void *appdata, pamc_bp_t *prompt_p)
+ = pam_misc_conv_delete_binary;
/* the following code is used to get text input */
@@ -293,26 +257,26 @@ int misc_conv(int num_msg, const struct pam_message **msgm,
break;
case PAM_BINARY_PROMPT:
{
- void *pack_out=NULL;
- const void *pack_in = msgm[count]->msg;
+ pamc_bp_t binary_prompt = NULL;
- if (!pam_binary_handler_fn
- || pam_binary_handler_fn(pack_in, &pack_out) != PAM_SUCCESS
- || pack_out == NULL) {
+ if (!msgm[count]->msg || !pam_binary_handler_fn) {
goto failed_conversation;
}
- string = (char *) pack_out;
- pack_out = NULL;
- break;
- }
- case PAM_BINARY_MSG:
- {
- const void *pack_in = msgm[count]->msg;
- if (!pam_binary_handler_fn
- || pam_binary_handler_fn(pack_in, NULL) != PAM_SUCCESS) {
+ PAM_BP_RENEW(&binary_prompt,
+ PAM_BP_RCONTROL(msgm[count]->msg),
+ PAM_BP_LENGTH(msgm[count]->msg));
+ PAM_BP_FILL(binary_prompt, 0, PAM_BP_LENGTH(msgm[count]->msg),
+ PAM_BP_RDATA(msgm[count]->msg));
+
+ if (pam_binary_handler_fn(appdata_ptr,
+ &binary_prompt) != PAM_SUCCESS
+ || (binary_prompt == NULL)) {
goto failed_conversation;
}
+ string = (char *) binary_prompt;
+ binary_prompt = NULL;
+
break;
}
default:
@@ -351,11 +315,11 @@ failed_conversation:
free(reply[count].resp);
break;
case PAM_BINARY_PROMPT:
- pam_binary_handler_free((void **) &reply[count].resp);
+ pam_binary_handler_free(appdata_ptr,
+ (pamc_bp_t *) &reply[count].resp);
break;
case PAM_ERROR_MSG:
case PAM_TEXT_INFO:
- case PAM_BINARY_MSG:
/* should not actually be able to get here... */
free(reply[count].resp);
}
diff --git a/contrib/libpam/libpam_misc/xstrdup.c b/contrib/libpam/libpam_misc/xstrdup.c
index e54a87dda7a62..cce476e89f592 100644
--- a/contrib/libpam/libpam_misc/xstrdup.c
+++ b/contrib/libpam/libpam_misc/xstrdup.c
@@ -1,11 +1,4 @@
-/* $Header: /home/morgan/pam/Linux-PAM-0.53/libpam_misc/RCS/xstrdup.c,v 1.4 1996/11/10 20:10:56 morgan Exp $ */
-
-/*
- * $Log: xstrdup.c,v $
- * Revision 1.4 1996/11/10 20:10:56 morgan
- * modification for stack paranoia
- *
- */
+/* $Id: xstrdup.c,v 1.1.1.1 2000/06/20 22:11:25 agmorgan Exp $ */
#include <malloc.h>
#include <string.h>