X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=common-src%2Fpipespawn.c;fp=common-src%2Fpipespawn.c;h=28f342bdc18f5a6e7564bde5a9a1f016c11018fc;hb=2627875b7d18858bc1f9f7652811e4d8c15a23eb;hp=16fd67cdda4dfc916cd0e3dc71ec8bd8001049dc;hpb=fb2bd066c2f8b34addafe48d62550e3033a59431;p=debian%2Famanda diff --git a/common-src/pipespawn.c b/common-src/pipespawn.c index 16fd67c..28f342b 100644 --- a/common-src/pipespawn.c +++ b/common-src/pipespawn.c @@ -6,7 +6,7 @@ char skip_argument[1]; -pid_t pipespawnv_passwd(char *prog, int pipedef, +pid_t pipespawnv_passwd(char *prog, int pipedef, int need_root, int *stdinfd, int *stdoutfd, int *stderrfd, char **my_argv); @@ -19,6 +19,7 @@ pid_t pipespawn( char * prog, int pipedef, + int need_root, int * stdinfd, int * stdoutfd, int * stderrfd, @@ -49,7 +50,8 @@ pipespawn( } arglist_end(ap); - pid = pipespawnv_passwd(prog, pipedef, stdinfd, stdoutfd, stderrfd, argv); + pid = pipespawnv_passwd(prog, pipedef, need_root, + stdinfd, stdoutfd, stderrfd, argv); amfree(argv); return pid; } @@ -58,12 +60,14 @@ pid_t pipespawnv( char * prog, int pipedef, + int need_root, int * stdinfd, int * stdoutfd, int * stderrfd, char ** my_argv) { - return pipespawnv_passwd(prog, pipedef, stdinfd, stdoutfd, stderrfd, + return pipespawnv_passwd(prog, pipedef, need_root, + stdinfd, stdoutfd, stderrfd, my_argv); } @@ -71,6 +75,7 @@ pid_t pipespawnv_passwd( char * prog, int pipedef, + int need_root, int * stdinfd, int * stdoutfd, int * stderrfd, @@ -96,6 +101,7 @@ pipespawnv_passwd( passwdvar = *my_argv++; passwdfd = (int *)*my_argv++; } + g_debug("pipespawnv: stdoutfd is %d", *stdoutfd); memset(inpipe, -1, SIZEOF(inpipe)); memset(outpipe, -1, SIZEOF(outpipe)); memset(errpipe, -1, SIZEOF(errpipe)); @@ -225,6 +231,8 @@ pipespawnv_passwd( safe_fd(-1, 0); } + if (need_root) + become_root(); execve(prog, my_argv, env); e = strerror(errno); error(_("error [exec %s: %s]"), prog, e);