summaryrefslogtreecommitdiff
path: root/Linux-PAM/modules/pam_filter
diff options
context:
space:
mode:
Diffstat (limited to 'Linux-PAM/modules/pam_filter')
-rw-r--r--Linux-PAM/modules/pam_filter/Makefile2
-rw-r--r--Linux-PAM/modules/pam_filter/README2
-rw-r--r--Linux-PAM/modules/pam_filter/include/pam_filter.h2
-rw-r--r--Linux-PAM/modules/pam_filter/pam_filter.c41
-rw-r--r--Linux-PAM/modules/pam_filter/upperLOWER/Makefile9
-rw-r--r--Linux-PAM/modules/pam_filter/upperLOWER/upperLOWER.c17
6 files changed, 44 insertions, 29 deletions
diff --git a/Linux-PAM/modules/pam_filter/Makefile b/Linux-PAM/modules/pam_filter/Makefile
index caad06c7..e7d7041e 100644
--- a/Linux-PAM/modules/pam_filter/Makefile
+++ b/Linux-PAM/modules/pam_filter/Makefile
@@ -1,5 +1,5 @@
#
-# $Id: Makefile,v 1.1.1.2 2002/09/15 20:08:47 hartmans Exp $
+# $Id: Makefile,v 1.4 2001/11/11 07:43:54 agmorgan Exp $
#
# This Makefile controls a build process of $(TITLE) module for
# Linux-PAM. You should not modify this Makefile (unless you know
diff --git a/Linux-PAM/modules/pam_filter/README b/Linux-PAM/modules/pam_filter/README
index 64bac608..12c4aeb5 100644
--- a/Linux-PAM/modules/pam_filter/README
+++ b/Linux-PAM/modules/pam_filter/README
@@ -1,5 +1,5 @@
#
-# $Id: README,v 1.1.1.1 2001/04/29 04:17:19 hartmans Exp $
+# $Id: README,v 1.1.1.1 2000/06/20 22:11:35 agmorgan Exp $
#
# This describes the behavior of this module with respect to the
# /etc/pam.conf file.
diff --git a/Linux-PAM/modules/pam_filter/include/pam_filter.h b/Linux-PAM/modules/pam_filter/include/pam_filter.h
index f189c911..69e3a3e2 100644
--- a/Linux-PAM/modules/pam_filter/include/pam_filter.h
+++ b/Linux-PAM/modules/pam_filter/include/pam_filter.h
@@ -1,5 +1,5 @@
/*
- * $Id: pam_filter.h,v 1.1.1.1 2001/04/29 04:17:20 hartmans Exp $
+ * $Id: pam_filter.h,v 1.1.1.1 2000/06/20 22:11:36 agmorgan Exp $
*
* this file is associated with the Linux-PAM filter module.
* it was written by Andrew G. Morgan <morgan@linux.kernel.org>
diff --git a/Linux-PAM/modules/pam_filter/pam_filter.c b/Linux-PAM/modules/pam_filter/pam_filter.c
index 0ddd3711..9aa23f29 100644
--- a/Linux-PAM/modules/pam_filter/pam_filter.c
+++ b/Linux-PAM/modules/pam_filter/pam_filter.c
@@ -1,5 +1,5 @@
/*
- * $Id: pam_filter.c,v 1.1.1.2 2002/09/15 20:08:47 hartmans Exp $
+ * $Id: pam_filter.c,v 1.6 2004/11/16 14:27:41 toady Exp $
*
* written by Andrew Morgan <morgan@transmeta.com> with much help from
* Richard Stevens' UNIX Network Programming book.
@@ -21,7 +21,7 @@
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
-#include <termio.h>
+#include <termios.h>
#include <signal.h>
@@ -131,7 +131,7 @@ static int process_args(pam_handle_t *pamh
} else {
char **levp;
const char *tmp;
- int i,size;
+ int i,size, retval;
*filtername = *++argv;
if (ctrl & FILTER_DEBUG) {
@@ -150,7 +150,7 @@ static int process_args(pam_handle_t *pamh
/* the "ARGS" variable */
-#define ARGS_OFFSET 5 /* sizeof('ARGS='); */
+#define ARGS_OFFSET 5 /* strlen('ARGS='); */
#define ARGS_NAME "ARGS="
size += ARGS_OFFSET;
@@ -174,10 +174,18 @@ static int process_args(pam_handle_t *pamh
/* the "SERVICE" variable */
-#define SERVICE_OFFSET 8 /* sizeof('SERVICE='); */
+#define SERVICE_OFFSET 8 /* strlen('SERVICE='); */
#define SERVICE_NAME "SERVICE="
- pam_get_item(pamh, PAM_SERVICE, (const void **)&tmp);
+ retval = pam_get_item(pamh, PAM_SERVICE, (const void **)&tmp);
+ if (retval != PAM_SUCCESS || tmp == NULL) {
+ _pam_log(LOG_CRIT,"service name not found");
+ if (levp) {
+ free(levp[0]);
+ free(levp);
+ }
+ return -1;
+ }
size = SERVICE_OFFSET+strlen(tmp);
levp[1] = (char *) malloc(size+1);
@@ -196,9 +204,10 @@ static int process_args(pam_handle_t *pamh
/* the "USER" variable */
-#define USER_OFFSET 5 /* sizeof('USER='); */
+#define USER_OFFSET 5 /* strlen('USER='); */
#define USER_NAME "USER="
+ tmp = NULL;
pam_get_user(pamh, &tmp, NULL);
if (tmp == NULL) {
tmp = "<unknown>";
@@ -222,7 +231,7 @@ static int process_args(pam_handle_t *pamh
/* the "USER" variable */
-#define TYPE_OFFSET 5 /* sizeof('TYPE='); */
+#define TYPE_OFFSET 5 /* strlen('TYPE='); */
#define TYPE_NAME "TYPE="
size = TYPE_OFFSET+strlen(type);
@@ -278,7 +287,7 @@ static int set_filter(pam_handle_t *pamh, int flags, int ctrl
{
int status=-1;
char terminal[TERMINAL_LEN];
- struct termio stored_mode; /* initial terminal mode settings */
+ struct termios stored_mode; /* initial terminal mode settings */
int fd[2], child=0, child2=0, aterminal;
if (filtername == NULL || *filtername != '/') {
@@ -305,15 +314,15 @@ static int set_filter(pam_handle_t *pamh, int flags, int ctrl
/* set terminal into raw mode.. remember old mode so that we can
revert to it after the child has quit. */
- /* this is termio terminal handling... */
+ /* this is termios terminal handling... */
- if (ioctl(STDIN_FILENO, TCGETA, (char *) &stored_mode ) < 0) {
+ if ( tcgetattr(STDIN_FILENO, &stored_mode) < 0 ) {
/* in trouble, so close down */
close(fd[0]);
_pam_log(LOG_CRIT, "couldn't copy terminal mode");
return PAM_ABORT;
} else {
- struct termio t_mode = stored_mode;
+ struct termios t_mode = stored_mode;
t_mode.c_iflag = 0; /* no input control */
t_mode.c_oflag &= ~OPOST; /* no ouput post processing */
@@ -326,7 +335,7 @@ static int set_filter(pam_handle_t *pamh, int flags, int ctrl
t_mode.c_cc[VMIN] = 1; /* number of chars to satisfy a read */
t_mode.c_cc[VTIME] = 0; /* 0/10th second for chars */
- if (ioctl(STDIN_FILENO, TCSETA, (char *) &t_mode) < 0) {
+ if ( tcsetattr(STDIN_FILENO, TCSAFLUSH, &t_mode) < 0 ) {
close(fd[0]);
_pam_log(LOG_WARNING, "couldn't put terminal in RAW mode");
return PAM_ABORT;
@@ -356,7 +365,7 @@ static int set_filter(pam_handle_t *pamh, int flags, int ctrl
_pam_log(LOG_WARNING,"first fork failed");
if (aterminal) {
- (void) ioctl(STDIN_FILENO, TCSETA, (char *) &stored_mode);
+ (void) tcsetattr(STDIN_FILENO, TCSAFLUSH, &stored_mode);
}
return PAM_AUTH_ERR;
@@ -398,7 +407,7 @@ static int set_filter(pam_handle_t *pamh, int flags, int ctrl
/* initialize the child's terminal to be the way the
parent's was before we set it into RAW mode */
- if (ioctl(fd[1], TCSETA, (char *) &stored_mode) < 0) {
+ if ( tcsetattr(fd[1], TCSANOW, &stored_mode) < 0 ) {
_pam_log(LOG_WARNING,"cannot set slave terminal mode; %s"
,terminal);
close(fd[1]);
@@ -572,7 +581,7 @@ static int set_filter(pam_handle_t *pamh, int flags, int ctrl
if (aterminal) {
/* reset to initial terminal mode */
- (void) ioctl(STDIN_FILENO, TCSETA, (char *) &stored_mode);
+ (void) tcsetattr(STDIN_FILENO, TCSANOW, &stored_mode);
}
if (ctrl & FILTER_DEBUG) {
diff --git a/Linux-PAM/modules/pam_filter/upperLOWER/Makefile b/Linux-PAM/modules/pam_filter/upperLOWER/Makefile
index 3e2d667f..c75f4964 100644
--- a/Linux-PAM/modules/pam_filter/upperLOWER/Makefile
+++ b/Linux-PAM/modules/pam_filter/upperLOWER/Makefile
@@ -1,5 +1,5 @@
#
-# $Id: Makefile,v 1.1.1.2 2002/09/15 20:08:47 hartmans Exp $
+# $Id: Makefile,v 1.4 2004/09/22 09:37:47 kukuk Exp $
#
# This directory contains a pam_filter filter executable
#
@@ -12,16 +12,19 @@ TITLE=upperLOWER
#
-CFLAGS += -I../include
+CFLAGS += -I../include -I../../pammodutil/include
OBJS = $(TITLE).o
+LIBS += $(GLIB_LIBS) -L../../pammodutil -lpammodutil
+LDFLAGS = $(LIBS)
+
####################### don't edit below #######################
all: $(TITLE)
$(TITLE): $(OBJS)
- $(CC) $(CFLAGS) -o $(TITLE) $(OBJS)
+ $(CC) $(CFLAGS) -o $(TITLE) $(OBJS) $(LDFLAGS)
$(STRIP) $(TITLE)
install:
diff --git a/Linux-PAM/modules/pam_filter/upperLOWER/upperLOWER.c b/Linux-PAM/modules/pam_filter/upperLOWER/upperLOWER.c
index 59c0e0e3..ee3544a1 100644
--- a/Linux-PAM/modules/pam_filter/upperLOWER/upperLOWER.c
+++ b/Linux-PAM/modules/pam_filter/upperLOWER/upperLOWER.c
@@ -1,5 +1,5 @@
/*
- * $Id: upperLOWER.c,v 1.1.1.2 2002/09/15 20:08:48 hartmans Exp $
+ * $Id: upperLOWER.c,v 1.5 2004/09/22 09:37:48 kukuk Exp $
*
* This is a sample filter program, for use with pam_filter (a module
* provided with Linux-PAM). This filter simply transposes upper and
@@ -21,6 +21,9 @@
#include <unistd.h>
#include <security/pam_filter.h>
+#include <security/pam_modules.h>
+#include <security/_pam_macros.h>
+#include <security/_pam_modutil.h>
/* ---------------------------------------------------------------- */
@@ -109,27 +112,27 @@ int main(int argc, char **argv)
/* application errors */
if ( FD_ISSET(APPERR_FILENO,&readers) ) {
- int got = read(APPERR_FILENO, buffer, BUFSIZ);
+ int got = _pammodutil_read(APPERR_FILENO, buffer, BUFSIZ);
if (got <= 0) {
break;
} else {
/* translate to give to real terminal */
if (before_user != NULL)
before_user(buffer, got);
- if ( write(STDERR_FILENO, buffer, got) != got ) {
+ if (_pammodutil_write(STDERR_FILENO, buffer, got) != got ) {
log_this(LOG_WARNING,"couldn't write %d bytes?!",got);
break;
}
}
} else if ( FD_ISSET(APPOUT_FILENO,&readers) ) { /* app output */
- int got = read(APPOUT_FILENO, buffer, BUFSIZ);
+ int got = _pammodutil_read(APPOUT_FILENO, buffer, BUFSIZ);
if (got <= 0) {
break;
} else {
/* translate to give to real terminal */
if (before_user != NULL)
before_user(buffer, got);
- if ( write(STDOUT_FILENO, buffer, got) != got ) {
+ if (_pammodutil_write(STDOUT_FILENO, buffer, got) != got ) {
log_this(LOG_WARNING,"couldn't write %d bytes!?",got);
break;
}
@@ -137,7 +140,7 @@ int main(int argc, char **argv)
}
if ( FD_ISSET(STDIN_FILENO, &readers) ) { /* user input */
- int got = read(STDIN_FILENO, buffer, BUFSIZ);
+ int got = _pammodutil_read(STDIN_FILENO, buffer, BUFSIZ);
if (got < 0) {
log_this(LOG_WARNING,"user input junked");
break;
@@ -145,7 +148,7 @@ int main(int argc, char **argv)
/* translate to give to application */
if (before_app != NULL)
before_app(buffer, got);
- if ( write(APPIN_FILENO, buffer, got) != got ) {
+ if (_pammodutil_write(APPIN_FILENO, buffer, got) != got ) {
log_this(LOG_WARNING,"couldn't pass %d bytes!?",got);
break;
}