[lttng-dev] [PATCH lttng-tools] Fix: run_as gid/uid test should return result to parent

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Tue Aug 27 16:24:55 EDT 2013


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 at efficios.com>
---
diff --git a/src/common/runas.c b/src/common/runas.c
index bd51cd4..6979ad3 100644
--- a/src/common/runas.c
+++ b/src/common/runas.c
@@ -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;

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list