X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Frunas.c;h=45aad109a00904804a009e285a8bb829f115add9;hb=87bbb85674277f43cb219223303c2e76f92c48dd;hp=c77f198c4d4061adade2b550846d38efbd387cf8;hpb=0c1b0f77482b0d1856fefabc42978b82b5dd267c;p=lttng-tools.git diff --git a/src/common/runas.c b/src/common/runas.c index c77f198c4..45aad109a 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(