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
commitc3ab8f90c5f29e9a5e011372211296a54e45c927 (patch)
tree7ba7487dfccd21276b12ead1356d7d154bdb1b48 /src
parent55e28977cad16a59abecbe5857fbebfefab4f811 (diff)
downloadlibpam-x2go-c3ab8f90c5f29e9a5e011372211296a54e45c927.tar.gz
libpam-x2go-c3ab8f90c5f29e9a5e011372211296a54e45c927.tar.bz2
libpam-x2go-c3ab8f90c5f29e9a5e011372211296a54e45c927.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;
}