|
|
904b9f |
diff -up Linux-PAM-1.1.6/modules/pam_mkhomedir/pam_mkhomedir.c.std-noclose Linux-PAM-1.1.6/modules/pam_mkhomedir/pam_mkhomedir.c
|
|
|
904b9f |
--- Linux-PAM-1.1.6/modules/pam_mkhomedir/pam_mkhomedir.c.std-noclose 2012-08-15 13:08:43.000000000 +0200
|
|
|
904b9f |
+++ Linux-PAM-1.1.6/modules/pam_mkhomedir/pam_mkhomedir.c 2013-04-24 13:11:14.768817086 +0200
|
|
|
904b9f |
@@ -35,6 +35,7 @@
|
|
|
904b9f |
#include <sys/time.h>
|
|
|
904b9f |
#include <sys/resource.h>
|
|
|
904b9f |
#include <sys/wait.h>
|
|
|
904b9f |
+#include <fcntl.h>
|
|
|
904b9f |
#include <unistd.h>
|
|
|
904b9f |
#include <pwd.h>
|
|
|
904b9f |
#include <errno.h>
|
|
|
904b9f |
@@ -133,13 +134,21 @@ create_homedir (pam_handle_t *pamh, opti
|
|
|
904b9f |
if (child == 0) {
|
|
|
904b9f |
int i;
|
|
|
904b9f |
struct rlimit rlim;
|
|
|
904b9f |
+ int dummyfds[2];
|
|
|
904b9f |
static char *envp[] = { NULL };
|
|
|
904b9f |
char *args[] = { NULL, NULL, NULL, NULL, NULL };
|
|
|
904b9f |
|
|
|
904b9f |
+ /* replace std file descriptors with a dummy pipe */
|
|
|
904b9f |
+ if (pipe2(dummyfds, O_NONBLOCK) == 0) {
|
|
|
904b9f |
+ dup2(dummyfds[0], STDIN_FILENO);
|
|
|
904b9f |
+ dup2(dummyfds[1], STDOUT_FILENO);
|
|
|
904b9f |
+ dup2(dummyfds[1], STDERR_FILENO);
|
|
|
904b9f |
+ }
|
|
|
904b9f |
+
|
|
|
904b9f |
if (getrlimit(RLIMIT_NOFILE, &rlim)==0) {
|
|
|
904b9f |
if (rlim.rlim_max >= MAX_FD_NO)
|
|
|
904b9f |
rlim.rlim_max = MAX_FD_NO;
|
|
|
904b9f |
- for (i=0; i < (int)rlim.rlim_max; i++) {
|
|
|
904b9f |
+ for (i = STDERR_FILENO + 1; i < (int)rlim.rlim_max; i++) {
|
|
|
904b9f |
close(i);
|
|
|
904b9f |
}
|
|
|
904b9f |
}
|
|
|
904b9f |
diff -up Linux-PAM-1.1.6/modules/pam_unix/pam_unix_acct.c.std-noclose Linux-PAM-1.1.6/modules/pam_unix/pam_unix_acct.c
|
|
|
904b9f |
--- Linux-PAM-1.1.6/modules/pam_unix/pam_unix_acct.c.std-noclose 2012-08-15 13:08:43.000000000 +0200
|
|
|
904b9f |
+++ Linux-PAM-1.1.6/modules/pam_unix/pam_unix_acct.c 2013-04-24 13:12:17.105990961 +0200
|
|
|
904b9f |
@@ -39,6 +39,7 @@
|
|
|
904b9f |
#include <stdlib.h>
|
|
|
904b9f |
#include <stdio.h>
|
|
|
904b9f |
#include <string.h>
|
|
|
904b9f |
+#include <fcntl.h>
|
|
|
904b9f |
#include <unistd.h>
|
|
|
904b9f |
#include <sys/types.h>
|
|
|
904b9f |
#include <sys/resource.h>
|
|
|
904b9f |
@@ -100,21 +101,26 @@ int _unix_run_verify_binary(pam_handle_t
|
|
|
904b9f |
if (child == 0) {
|
|
|
904b9f |
int i=0;
|
|
|
904b9f |
struct rlimit rlim;
|
|
|
904b9f |
+ int dummyfds[2];
|
|
|
904b9f |
static char *envp[] = { NULL };
|
|
|
904b9f |
char *args[] = { NULL, NULL, NULL, NULL };
|
|
|
904b9f |
|
|
|
904b9f |
/* reopen stdout as pipe */
|
|
|
904b9f |
dup2(fds[1], STDOUT_FILENO);
|
|
|
904b9f |
|
|
|
904b9f |
+ /* replace std file descriptors with a dummy pipe */
|
|
|
904b9f |
+ if (pipe2(dummyfds, O_NONBLOCK) == 0) {
|
|
|
904b9f |
+ dup2(dummyfds[0], STDIN_FILENO);
|
|
|
904b9f |
+ dup2(dummyfds[1], STDERR_FILENO);
|
|
|
904b9f |
+ }
|
|
|
904b9f |
+
|
|
|
904b9f |
/* XXX - should really tidy up PAM here too */
|
|
|
904b9f |
|
|
|
904b9f |
if (getrlimit(RLIMIT_NOFILE,&rlim)==0) {
|
|
|
904b9f |
if (rlim.rlim_max >= MAX_FD_NO)
|
|
|
904b9f |
rlim.rlim_max = MAX_FD_NO;
|
|
|
904b9f |
- for (i=0; i < (int)rlim.rlim_max; i++) {
|
|
|
904b9f |
- if (i != STDOUT_FILENO) {
|
|
|
904b9f |
- close(i);
|
|
|
904b9f |
- }
|
|
|
904b9f |
+ for (i = STDERR_FILENO + 1; i < (int)rlim.rlim_max; i++) {
|
|
|
904b9f |
+ close(i);
|
|
|
904b9f |
}
|
|
|
904b9f |
}
|
|
|
904b9f |
|
|
|
904b9f |
diff -up Linux-PAM-1.1.6/modules/pam_unix/pam_unix_passwd.c.std-noclose Linux-PAM-1.1.6/modules/pam_unix/pam_unix_passwd.c
|
|
|
904b9f |
--- Linux-PAM-1.1.6/modules/pam_unix/pam_unix_passwd.c.std-noclose 2012-08-15 13:08:43.000000000 +0200
|
|
|
904b9f |
+++ Linux-PAM-1.1.6/modules/pam_unix/pam_unix_passwd.c 2013-04-23 17:13:49.047499806 +0200
|
|
|
904b9f |
@@ -202,6 +202,7 @@ static int _unix_run_update_binary(pam_h
|
|
|
904b9f |
if (child == 0) {
|
|
|
904b9f |
int i=0;
|
|
|
904b9f |
struct rlimit rlim;
|
|
|
904b9f |
+ int dummyfds[2];
|
|
|
904b9f |
static char *envp[] = { NULL };
|
|
|
904b9f |
char *args[] = { NULL, NULL, NULL, NULL, NULL, NULL };
|
|
|
904b9f |
char buffer[16];
|
|
|
904b9f |
@@ -211,11 +212,17 @@ static int _unix_run_update_binary(pam_h
|
|
|
904b9f |
/* reopen stdin as pipe */
|
|
|
904b9f |
dup2(fds[0], STDIN_FILENO);
|
|
|
904b9f |
|
|
|
904b9f |
+ /* replace std file descriptors with a dummy pipe */
|
|
|
904b9f |
+ if (pipe2(dummyfds, O_NONBLOCK) == 0) {
|
|
|
904b9f |
+ dup2(dummyfds[1], STDOUT_FILENO);
|
|
|
904b9f |
+ dup2(dummyfds[1], STDERR_FILENO);
|
|
|
904b9f |
+ }
|
|
|
904b9f |
+
|
|
|
904b9f |
if (getrlimit(RLIMIT_NOFILE,&rlim)==0) {
|
|
|
904b9f |
if (rlim.rlim_max >= MAX_FD_NO)
|
|
|
904b9f |
rlim.rlim_max = MAX_FD_NO;
|
|
|
904b9f |
- for (i=0; i < (int)rlim.rlim_max; i++) {
|
|
|
904b9f |
- if (i != STDIN_FILENO)
|
|
|
904b9f |
+ for (i = STDERR_FILENO + 1; i < (int)rlim.rlim_max; i++) {
|
|
|
904b9f |
+ if (i != dummyfds[0])
|
|
|
904b9f |
close(i);
|
|
|
904b9f |
}
|
|
|
904b9f |
}
|
|
|
904b9f |
diff -up Linux-PAM-1.1.6/modules/pam_unix/support.c.std-noclose Linux-PAM-1.1.6/modules/pam_unix/support.c
|
|
|
904b9f |
--- Linux-PAM-1.1.6/modules/pam_unix/support.c.std-noclose 2012-08-15 13:08:43.000000000 +0200
|
|
|
904b9f |
+++ Linux-PAM-1.1.6/modules/pam_unix/support.c 2013-04-24 13:12:42.893064361 +0200
|
|
|
904b9f |
@@ -5,6 +5,7 @@
|
|
|
904b9f |
#include "config.h"
|
|
|
904b9f |
|
|
|
904b9f |
#include <stdlib.h>
|
|
|
904b9f |
+#include <fcntl.h>
|
|
|
904b9f |
#include <unistd.h>
|
|
|
904b9f |
#include <stdarg.h>
|
|
|
904b9f |
#include <stdio.h>
|
|
|
904b9f |
@@ -462,6 +463,7 @@ static int _unix_run_helper_binary(pam_h
|
|
|
904b9f |
if (child == 0) {
|
|
|
904b9f |
int i=0;
|
|
|
904b9f |
struct rlimit rlim;
|
|
|
904b9f |
+ int dummyfds[2];
|
|
|
904b9f |
static char *envp[] = { NULL };
|
|
|
904b9f |
char *args[] = { NULL, NULL, NULL, NULL };
|
|
|
904b9f |
|
|
|
904b9f |
@@ -470,11 +472,17 @@ static int _unix_run_helper_binary(pam_h
|
|
|
904b9f |
/* reopen stdin as pipe */
|
|
|
904b9f |
dup2(fds[0], STDIN_FILENO);
|
|
|
904b9f |
|
|
|
904b9f |
+ /* replace std file descriptors with a dummy pipe */
|
|
|
904b9f |
+ if (pipe2(dummyfds, O_NONBLOCK) == 0) {
|
|
|
904b9f |
+ dup2(dummyfds[1], STDOUT_FILENO);
|
|
|
904b9f |
+ dup2(dummyfds[1], STDERR_FILENO);
|
|
|
904b9f |
+ }
|
|
|
904b9f |
+
|
|
|
904b9f |
if (getrlimit(RLIMIT_NOFILE,&rlim)==0) {
|
|
|
904b9f |
if (rlim.rlim_max >= MAX_FD_NO)
|
|
|
904b9f |
rlim.rlim_max = MAX_FD_NO;
|
|
|
904b9f |
- for (i=0; i < (int)rlim.rlim_max; i++) {
|
|
|
904b9f |
- if (i != STDIN_FILENO)
|
|
|
904b9f |
+ for (i = STDERR_FILENO + 1; i < (int)rlim.rlim_max; i++) {
|
|
|
904b9f |
+ if (i != dummyfds[0])
|
|
|
904b9f |
close(i);
|
|
|
904b9f |
}
|
|
|
904b9f |
}
|