Fix: double close of directory fd in runas worker
[lttng-tools.git] / src / common / runas.c
index c77f198c4d4061adade2b550846d38efbd387cf8..45aad109a00904804a009e285a8bb829f115add9 100644 (file)
@@ -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(
This page took 0.024383 seconds and 5 git commands to generate.