 
            From: Paul Gofman pgofman@codeweavers.com
--- server/process.c | 9 ++++++--- server/request.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/server/process.c b/server/process.c index f037562a82b..e5f8d685655 100644 --- a/server/process.c +++ b/server/process.c @@ -736,9 +736,12 @@ struct process *create_process( int fd, struct process *parent, unsigned int fla { obj_handle_t std_handles[3];
- std_handles[0] = info->hstdin; - std_handles[1] = info->hstdout; - std_handles[2] = info->hstderr; + if (flags & PROCESS_CREATE_FLAGS_INHERIT_HANDLES) + { + std_handles[0] = info->hstdin; + std_handles[1] = info->hstdout; + std_handles[2] = info->hstderr; + }
process->parent_id = parent->id; if (flags & PROCESS_CREATE_FLAGS_INHERIT_HANDLES) diff --git a/server/request.c b/server/request.c index 835ea30cec3..6fe75546738 100644 --- a/server/request.c +++ b/server/request.c @@ -558,10 +558,37 @@ static void master_socket_poll_event( struct fd *fd, int event ) struct process *process; struct sockaddr_un dummy; socklen_t len = sizeof(dummy); + struct thread *thread = NULL; + int client = accept( get_unix_fd( master_socket->fd ), (struct sockaddr *) &dummy, &len ); if (client == -1) return; fcntl( client, F_SETFL, O_NONBLOCK ); - if ((process = create_process( client, NULL, 0, NULL, NULL, NULL, 0, NULL ))) +#ifdef SO_PEERCRED + { + struct ucred ucred; + + len = sizeof(ucred); + if (!getsockopt( client, SOL_SOCKET, SO_PEERCRED, &ucred, &len )) + { + pid_t ppid; + char s[256]; + FILE *f; + + sprintf( s, "/proc/%d/status", ucred.pid ); + if ((f = fopen( s, "r" ))) + { + while (fgets( s, sizeof(s), f )) + { + if (sscanf( s, "PPid:%d", &ppid ) != 1) continue; + thread = get_thread_from_pid( ppid ); + break; + } + fclose( f ); + } + } + } +#endif + if ((process = create_process( client, thread ? thread->process : NULL, 0, NULL, NULL, NULL, 0, NULL ))) { create_thread( -1, process, NULL ); release_object( process );