提交 4e8b81e5 编写于 作者: P Peter Krempa

util: polkit: Fix polkit agent startup

Commit 0b36b0e9 broke polkit agent startup when attempting to fix a
coverity warning. Refactor it properly so that we don't need the 'cmd'
intermediate variable.
上级 a391a9c5
...@@ -167,7 +167,6 @@ virPolkitAgentPtr ...@@ -167,7 +167,6 @@ virPolkitAgentPtr
virPolkitAgentCreate(void) virPolkitAgentCreate(void)
{ {
virPolkitAgentPtr agent = NULL; virPolkitAgentPtr agent = NULL;
virCommandPtr cmd = virCommandNewArgList(PKTTYAGENT, "--process", NULL);
int pipe_fd[2] = {-1, -1}; int pipe_fd[2] = {-1, -1};
struct pollfd pollfd; struct pollfd pollfd;
int outfd = STDOUT_FILENO; int outfd = STDOUT_FILENO;
...@@ -181,18 +180,18 @@ virPolkitAgentCreate(void) ...@@ -181,18 +180,18 @@ virPolkitAgentCreate(void)
if (VIR_ALLOC(agent) < 0) if (VIR_ALLOC(agent) < 0)
goto error; goto error;
agent->cmd = cmd;
cmd = NULL; agent->cmd = virCommandNewArgList(PKTTYAGENT, "--process", NULL);
virCommandAddArgFormat(cmd, "%lld", (long long int) getpid()); virCommandAddArgFormat(agent->cmd, "%lld", (long long int) getpid());
virCommandAddArg(cmd, "--notify-fd"); virCommandAddArg(agent->cmd, "--notify-fd");
virCommandAddArgFormat(cmd, "%d", pipe_fd[1]); virCommandAddArgFormat(agent->cmd, "%d", pipe_fd[1]);
virCommandAddArg(cmd, "--fallback"); virCommandAddArg(agent->cmd, "--fallback");
virCommandSetInputFD(cmd, STDIN_FILENO); virCommandSetInputFD(agent->cmd, STDIN_FILENO);
virCommandSetOutputFD(cmd, &outfd); virCommandSetOutputFD(agent->cmd, &outfd);
virCommandSetErrorFD(cmd, &errfd); virCommandSetErrorFD(agent->cmd, &errfd);
virCommandPassFD(cmd, pipe_fd[1], VIR_COMMAND_PASS_FD_CLOSE_PARENT); virCommandPassFD(agent->cmd, pipe_fd[1], VIR_COMMAND_PASS_FD_CLOSE_PARENT);
if (virCommandRunAsync(cmd, NULL) < 0) if (virCommandRunAsync(agent->cmd, NULL) < 0)
goto error; goto error;
pollfd.fd = pipe_fd[0]; pollfd.fd = pipe_fd[0];
...@@ -207,7 +206,6 @@ virPolkitAgentCreate(void) ...@@ -207,7 +206,6 @@ virPolkitAgentCreate(void)
VIR_FORCE_CLOSE(pipe_fd[0]); VIR_FORCE_CLOSE(pipe_fd[0]);
VIR_FORCE_CLOSE(pipe_fd[1]); VIR_FORCE_CLOSE(pipe_fd[1]);
virPolkitAgentDestroy(agent); virPolkitAgentDestroy(agent);
virCommandFree(cmd);
return NULL; return NULL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册