From 6d73c4efe5195e5ea4dfe5f4c1f8ee12ba1e0a25 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 27 Aug 2013 16:24:55 -0400 Subject: [PATCH] Fix: run_as gid/uid test should return result to parent 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 Signed-off-by: David Goulet --- src/common/runas.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/runas.c b/src/common/runas.c index bd51cd4ed..6979ad325 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; -- 2.34.1