Skip to content

Commit 636f2d1

Browse files
committed
feat(hooks): pass container state to hooks over stdin
Complete the OCI hooks state-passing logic and fix several bugs: - Pass container state JSON to hooks over stdin as required by OCI spec - Fix socketpair created after fork (child had no socket) - Fix env variable concatenation bug ('+' was pointer arithmetic) - Fix waitpid EINTR/EAGAIN condition (&& should be ||) - Add hook timeout support via sigtimedwait - Fix poststop_hooks iterating over wrong hook list (poststart) - Update all hook call sites to pass container_status_t Also adapt to the new socket API: - Replace unixSocketClient with unix_socket - Use unix_socket::pair() instead of utils::socketpair() - Use STDIN_FILENO/STDOUT_FILENO instead of utils::fileno() - Update SPDX copyright years to 2026 Signed-off-by: ComixHe <ComixHe1895@outlook.com>
1 parent 51ec713 commit 636f2d1

10 files changed

Lines changed: 188 additions & 131 deletions

File tree

src/linyaps_box/command/exec.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2022-2025 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2022-2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: LGPL-3.0-or-later
44

@@ -25,11 +25,11 @@ auto linyaps_box::command::exec(const struct exec_options &options) -> int
2525
option.proc.args = options.command;
2626
option.proc.terminal = options.tty;
2727
option.proc.no_new_privileges = options.no_new_privs;
28-
option.proc.env = options.envs.value_or(std::vector<std::string>{});
28+
option.proc.env = options.envs.value_or(std::vector<std::string>{ });
2929
option.preserve_fds = options.preserve_fds;
3030

3131
if (option.proc.terminal && options.console_socket) {
32-
option.console_socket = unixSocketClient::connect(options.console_socket.value());
32+
option.console_socket = unix_socket::connect(options.console_socket.value());
3333
}
3434

3535
#ifdef LINYAPS_BOX_ENABLE_CAP

src/linyaps_box/command/run.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2022-2025 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2022-2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: LGPL-3.0-or-later
44

@@ -23,7 +23,7 @@ auto linyaps_box::command::run(const struct run_options &options) -> int
2323
run_options.preserve_fds = options.preserve_fds;
2424

2525
if (container.get_config().process.terminal && options.console_socket) {
26-
run_options.console_socket = unixSocketClient::connect(options.console_socket.value());
26+
run_options.console_socket = unix_socket::connect(options.console_socket.value());
2727
}
2828

2929
return container.run(std::move(run_options));

0 commit comments

Comments
 (0)