Fix: double close of directory fd in runas worker
[lttng-tools.git] / src / common / runas.c
index 88e9c224436fe2a3f5d888b3343f381a64ac7318..f1cf8eb7c64970d0992984e7bc03dcf78ac49c12 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.02673 seconds and 4 git commands to generate.