X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=src%2Fcommon%2Frunas.c;h=f1cf8eb7c64970d0992984e7bc03dcf78ac49c12;hb=e1ddb036519b78242b349981054a41e765260e90;hp=88e9c224436fe2a3f5d888b3343f381a64ac7318;hpb=a4ee1b7e15b25e449c62a929e35850b2916f54cc;p=lttng-tools.git diff --git a/src/common/runas.c b/src/common/runas.c index 88e9c2244..f1cf8eb7c 100644 --- a/src/common/runas.c +++ b/src/common/runas.c @@ -199,6 +199,8 @@ int _mkdirat_recursive(struct run_as_data *data, struct run_as_ret *ret_value) mode = data->u.mkdirat.mode; (void) lttng_directory_handle_init_from_dirfd(&handle, data->fd); + /* Ownership of dirfd is transferred to the handle. */ + data->fd = -1; /* Safe to call as we have transitioned to the requested uid/gid. */ ret_value->u.mkdirat.ret = lttng_directory_handle_create_subdirectory_recursive( @@ -220,6 +222,8 @@ int _mkdirat(struct run_as_data *data, struct run_as_ret *ret_value) mode = data->u.mkdirat.mode; (void) lttng_directory_handle_init_from_dirfd(&handle, data->fd); + /* Ownership of dirfd is transferred to the handle. */ + data->fd = -1; /* Safe to call as we have transitioned to the requested uid/gid. */ ret_value->u.mkdirat.ret = lttng_directory_handle_create_subdirectory(