 
            From: Paul Gofman pgofman@codeweavers.com
--- server/process.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/server/process.c b/server/process.c index b0dd947d628..f037562a82b 100644 --- a/server/process.c +++ b/server/process.c @@ -657,6 +657,7 @@ struct process *create_process( int fd, struct process *parent, unsigned int fla unsigned int handle_count, struct token *token ) { struct process *process; + struct job *job;
if (!(process = alloc_object( &process_ops ))) { @@ -753,6 +754,22 @@ struct process *create_process( int fd, struct process *parent, unsigned int fla process->session_id = token_get_session_id( process->token );
set_fd_events( process->msg_fd, POLLIN ); /* start listening to events */ + + if (!parent) return process; + job = parent->job; + while (job) + { + if (!(job->limit_flags & JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK) + && !(flags & PROCESS_CREATE_FLAGS_BREAKAWAY + && job->limit_flags & JOB_OBJECT_LIMIT_BREAKAWAY_OK)) + { + add_job_process( job, process ); + assert( !get_error() ); + break; + } + job = job->parent; + } + return process;
error: @@ -1327,20 +1344,6 @@ DECL_HANDLER(new_process) process->machine = req->machine; process->startup_info = (struct startup_info *)grab_object( info );
- job = parent->job; - while (job) - { - if (!(job->limit_flags & JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK) - && !(req->flags & PROCESS_CREATE_FLAGS_BREAKAWAY - && job->limit_flags & JOB_OBJECT_LIMIT_BREAKAWAY_OK)) - { - add_job_process( job, process ); - assert( !get_error() ); - break; - } - job = job->parent; - } - for (i = 0; i < job_handle_count; ++i) { job = get_job_obj( current->process, job_handles[i], JOB_OBJECT_ASSIGN_PROCESS );
 
            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 );
 
            That is motivated by probably an unsupported use case.
EOS Easy Anti Cheat bootstrapper creates the process calling Wine directly by Unix means, without calling Wine's NtCreateUserProcess. The process created this way looses, in particular, Win-side parent process id and inclusion to job. That breaks some aspects of Ubisoft API functioning when a game launched through Ubisoft launcher relaunches itself through EAC. If, however, the Unix parent process is a Wine process (like the case here with EAC bootstrapper) it is possible to detect that and inherit those parameters (apart from environment variables which are a separate story).
I realize that this is not quite supported use case. Yet maybe we can do that as it probably looks harmless. If there are entirely Unix side processes created they won't become seen on the Win side this way, for this patch to have effect both parent and child must be Wine processes. This specific use case involving EOS EAC doesn't depend on any Proton-specific components, it is supposed to work with upstream Wine too without requiring additional modules.

