Commit 6d366ce7 authored by Brendan Shanks's avatar Brendan Shanks Committed by Alexandre Julliard

msv1_0: Implement ntlm_fork() using posix_spawn().

parent d18fd2c1
......@@ -28,6 +28,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <spawn.h>
#include <sys/wait.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
......@@ -39,6 +40,8 @@
#include "wine/debug.h"
#include "unixlib.h"
extern char **environ;
WINE_DEFAULT_DEBUG_CHANNEL(ntlm);
WINE_DECLARE_DEBUG_CHANNEL(winediag);
......@@ -155,6 +158,7 @@ static NTSTATUS ntlm_fork( void *args )
{
const struct fork_params *params = args;
struct ntlm_ctx *ctx = params->ctx;
posix_spawn_file_actions_t file_actions;
int pipe_in[2], pipe_out[2];
#ifdef HAVE_PIPE2
......@@ -179,28 +183,28 @@ static NTSTATUS ntlm_fork( void *args )
fcntl( pipe_out[1], F_SETFD, FD_CLOEXEC );
}
if (!(ctx->pid = fork())) /* child */
{
dup2( pipe_out[0], 0 );
close( pipe_out[0] );
close( pipe_out[1] );
posix_spawn_file_actions_init( &file_actions );
dup2( pipe_in[1], 1 );
close( pipe_in[0] );
close( pipe_in[1] );
posix_spawn_file_actions_adddup2( &file_actions, pipe_out[0], 0 );
posix_spawn_file_actions_addclose( &file_actions, pipe_out[0] );
posix_spawn_file_actions_addclose( &file_actions, pipe_out[1] );
execvp( params->argv[0], params->argv );
posix_spawn_file_actions_adddup2( &file_actions, pipe_in[1], 1 );
posix_spawn_file_actions_addclose( &file_actions, pipe_in[0] );
posix_spawn_file_actions_addclose( &file_actions, pipe_in[1] );
write( 1, "BH\n", 3 );
_exit( 1 );
}
else
if (posix_spawnp( &ctx->pid, params->argv[0], &file_actions, NULL, params->argv, environ ))
{
ctx->pid = -1;
write( pipe_in[1], "BH\n", 3 );
}
ctx->pipe_in = pipe_in[0];
close( pipe_in[1] );
ctx->pipe_out = pipe_out[1];
close( pipe_out[0] );
}
posix_spawn_file_actions_destroy( &file_actions );
return SEC_E_OK;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment