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