aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2012-08-30 11:24:18 -0500
committerTed Gould <ted@gould.cx>2012-08-30 11:24:18 -0500
commit49131cc81474a9bc7f872f948ea148ca8a602e29 (patch)
tree7ba7487dfccd21276b12ead1356d7d154bdb1b48 /src
parentd40d11a475fa08d52dc8a66f34ca2ce28ab39b7e (diff)
downloadlibpam-freerdp2-49131cc81474a9bc7f872f948ea148ca8a602e29.tar.gz
libpam-freerdp2-49131cc81474a9bc7f872f948ea148ca8a602e29.tar.bz2
libpam-freerdp2-49131cc81474a9bc7f872f948ea148ca8a602e29.zip
Setting up a pipe to communicate with the sub process
Diffstat (limited to 'src')
-rw-r--r--src/pam-freerdp.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/pam-freerdp.c b/src/pam-freerdp.c
index 5696bbd..9007a52 100644
--- a/src/pam-freerdp.c
+++ b/src/pam-freerdp.c
@@ -250,7 +250,7 @@ done:
}
static int
-session_socket_handler (struct passwd * pwdent, const char * ruser, const char * rhost, const char * rdomain, const char * password)
+session_socket_handler (struct passwd * pwdent, int readypipe, const char * ruser, const char * rhost, const char * rdomain, const char * password)
{
/* Socket stuff */
int socketfd = 0;
@@ -402,16 +402,27 @@ pam_sm_open_session (pam_handle_t *pamh, int flags, int argc, const char ** argv
goto done;
}
+ int sessionready[2];
+ if (pipe(sessionready) != 0) {
+ retval = PAM_SYSTEM_ERR;
+ goto done;
+ }
+
pid_t pid = fork();
if (pid == 0) {
int retval = 0;
- retval = session_socket_handler(pwdent, ruser, rhost, rdomain, password);
+ retval = session_socket_handler(pwdent, sessionready[1], ruser, rhost, rdomain, password);
+ close(sessionready[1]);
_exit(retval);
} else if (pid < 0) {
+ close(sessionready[0]);
+ close(sessionready[1]);
+
retval = PAM_SYSTEM_ERR;
} else {
+ close(sessionready[0]);
session_pid = pid;
}