diff options
author | Ted Gould <ted@gould.cx> | 2012-08-30 11:24:18 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2012-08-30 11:24:18 -0500 |
commit | c3ab8f90c5f29e9a5e011372211296a54e45c927 (patch) | |
tree | 7ba7487dfccd21276b12ead1356d7d154bdb1b48 /src | |
parent | 55e28977cad16a59abecbe5857fbebfefab4f811 (diff) | |
download | libpam-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.c | 15 |
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; } |