Fix: run_as gid/uid test should return result to parent
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 27 Aug 2013 20:24:55 +0000 (16:24 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 27 Aug 2013 21:42:33 +0000 (17:42 -0400)
Failure to do so could cause the parent to hang on read() waiting for
the return value from the child.

Targets: 2.3-rc and stable-2.2 branches.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/common/runas.c

index bd51cd4ed2b7b6b8c00221b19209a63dba10c698..6979ad3257c1da144955b6567ad7ce16afacdbaa 100644 (file)
@@ -130,14 +130,16 @@ int child_run_as(void *_data)
                ret = setegid(data->gid);
                if (ret < 0) {
                        PERROR("setegid");
-                       return EXIT_FAILURE;
+                       sendret.i = -1;
+                       goto write_return;
                }
        }
        if (data->uid != geteuid()) {
                ret = seteuid(data->uid);
                if (ret < 0) {
                        PERROR("seteuid");
-                       return EXIT_FAILURE;
+                       sendret.i = -1;
+                       goto write_return;
                }
        }
        /*
@@ -145,6 +147,8 @@ int child_run_as(void *_data)
         */
        umask(0);
        sendret.i = (*data->cmd)(data->data);
+
+write_return:
        /* send back return value */
        writeleft = sizeof(sendret);
        index = 0;
This page took 0.026961 seconds and 5 git commands to generate.