Commit Graph

259 Commits

Author SHA1 Message Date
ComixHe 308b80bacf feat: add rootfsPropagation support and improve error handling
- Add rootfsPropagation field to linux config (shared/slave/private/unbindable)
- Fix mount propagation flag handling (use |= instead of &=)
- Replace std::cerr with LINYAPS_BOX_ERR() for consistent logging
- Use _exit() instead of exit() in child processes
- Improve error messages with better context

Allows control over mount propagation for the root filesystem according
to OCI spec.

Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-08-05 15:43:50 +08:00
ComixHe 16f40a416a fix: resolve GCC enum conversion error in MountFlag
Use std::underlying_type_t to fix "int cannot be converted to unnamed enum"
compilation error on older GCC versions.

Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-07-23 13:47:39 +08:00
ComixHe 3951cfc9b2 fix: some warnings
- non-const global variable
- avoid array-to-pointer decay

Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-07-23 13:23:47 +08:00
ComixHe 0bb8d07bb2 feat: add runtime extension 'cn.org.linyaps.runtime.ns_last_pid'
Add support for the 'cn.org.linyaps.runtime.ns_last_pid' runtime extension
that allows setting the last PID in the namespace during container startup.

Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-07-23 13:23:47 +08:00
ComixHe ee4e07a827 refactor: resolve some warnings from static check
Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-07-23 11:38:07 +08:00
ComixHe e31f62f382 build: specifying the internal library type explicitly
Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-07-21 10:17:01 +08:00
dengbo 000fa7ff73 chore: add deepsource config
Add deepsource config.
2025-07-18 14:50:46 +08:00
ComixHe 1fd78ccf1a chore: update CMake preset
Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-07-18 11:15:47 +08:00
ComixHe f30bf60148 build: add an option to generate version
Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-07-17 21:25:25 +08:00
ComixHe aa58f981ef fix: 'cgroup-manager' is not assigned while creating container
make 'disabled' as the default value of field 'cgroup-manager'

Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-07-17 21:11:20 +08:00
ComixHe 489cc336e4 fix: correct ptmx source location
Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-07-14 14:59:23 +08:00
ComixHe 35ac00a66a feat: support runtime Dev symbolic link
Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-07-01 20:10:47 +08:00
ComixHe 9d524a908c feat: bind mount /dev/pts/ptmx to /dev/ptmx
Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-07-01 20:10:47 +08:00
ComixHe 46ff1b817f fix: correct the default value of open_at parameter 'mode'
if mode is nonzero, but how.flags does not contain O_CREAT or O_TMPFILE
will cause an EINVAL.

Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-07-01 17:32:51 +08:00
ComixHe e714f88ba3 chore: update CMakePresets
Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-06-20 17:19:55 +08:00
ComixHe 995231effc feat: add option '--env' for exec
Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-06-17 16:24:06 +08:00
ComixHe 123cfeb539 chore: add version information for vendoring dependencies
Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-06-13 13:12:28 +08:00
ComixHe 9887a351c4 fix: remove nsenter option '--wdns'
old nsenter command doesn't support '--wdns'.
remove this option for now.

Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-06-12 11:24:03 +08:00
ComixHe 37f8126145 fix: correct fallback syscall number
__NR_close_range should be 436.
include sys/syscall.h instead of asm/unistd.h.

Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-06-12 11:00:29 +08:00
ComixHe bcd7063161 Revert "fix: do not define syscall number directly"
This reverts commit 2cb58b3a0f.
2025-06-12 11:00:29 +08:00
Iceyer 16ed42928d fix: correct output flag name in inspect_fcntl_or_open_flags
The function was incorrectly outputting 'O_SYNC' when checking for
the O_NDELAY flag. This was likely a copy-paste error that could
cause confusion when debugging file descriptor flags.

The issue was in the inspect_fcntl_or_open_flags function where
the condition checked for O_NDELAY but output the wrong flag name.

Changed:
- Fixed output from 'O_SYNC' to 'O_NDELAY' to match the actual flag being checked
2025-06-12 09:31:21 +08:00
ComixHe 2cb58b3a0f fix: do not define syscall number directly
Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-06-11 18:17:20 +08:00
ComixHe cc49934702 fix: avoid dead loop in close_range_fallback
add helper class 'defer'

Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-06-04 11:48:34 +08:00
ComixHe d2b7adbb1d feat: add flag 'mount_dev_from_host'
skip processing default devices if user binds '/dev' from host

Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-05-30 17:56:03 +08:00
ComixHe 4f8ad981d5 build: add public definition 'LINYAPS_BOX_STATIC_LINK' to library target
Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-05-30 16:19:26 +08:00
ComixHe 594bedcf1c refactor: add version flag
Signed-off-by: ComixHe <ComixHe1895@outlook.com>
2025-05-23 14:32:44 +08:00
ComixHe 25fdeda582 refactor: try single mapping at first if it could be
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-05-08 15:32:36 +08:00
ComixHe 6b9422ff84 refactor: remove unneed shared_ptr
improve open/open_at

Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-30 17:40:13 +08:00
ComixHe 4d3d0002f2 test: ignore deprecated warning from libstdc++
refer: 5c34f02ba7

Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-30 16:42:57 +08:00
ComixHe f1378216b3 chore: correct log
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-30 12:10:53 +08:00
ComixHe 22c8a34f3a test: add smoke test 'output-to-null'
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-28 16:41:07 +08:00
ComixHe 599b433142 refactor: output file path when failed to open or create it
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-25 17:09:13 +08:00
ComixHe 06f3a86652 refactor: try to create devices at first
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-25 16:16:02 +08:00
ComixHe 0bed97d189 fix: remove MS_NODEV option for /dev
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-25 13:28:02 +08:00
ComixHe e83566c4b4 refactor: ignore 'owner' field when box is linked statically
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-24 17:05:52 +08:00
ComixHe cc3db26490 Revert "fix: remove 'owner' from container state file"
This reverts commit 0cb72a0b1a.

linyaps needs this field.
2025-04-24 17:05:52 +08:00
ComixHe 0cb72a0b1a fix: remove 'owner' from container state file
we need support linking statically but calling
getpwuid from a statically linked program may cause
a segment fault.

Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-21 15:57:53 +08:00
ComixHe 2f74ccca81 fix: the argument 'argv' and 'envp' of execvpe shouldn't be nullptr
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-21 15:57:53 +08:00
ComixHe fda6b3954d build: specifying labmda return type
compatible with old gcc

Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-18 17:35:22 +08:00
ComixHe adcb988fa1 fix: correct args of executing hook
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-16 17:59:18 +08:00
ComixHe 26e24766d0 fix: splitting prestart hook and createRuntime hook into two steps
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-16 16:27:38 +08:00
ComixHe a1aad2f284 fix: correct hooks type
'args' and 'env' are optional in hooks

Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-16 14:46:57 +08:00
ComixHe 08305e83d0 fix: correct bind mount flags of the configure_device fallback
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-16 12:23:39 +08:00
ComixHe f6661b83bf chore: update dependency 'nlohmann_json'
- nlohmann_json 3.12.0 released in 2025-04-11
  - change the minimal dependencies version

Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-15 10:51:14 +08:00
ComixHe cf2e547d09 refactor: compatible with libcap 2.25
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-02 16:32:07 +08:00
ComixHe 23414a6aab refactor: change the way of feature detecting
- compatible with older gcc and cmake
  - remove configuration

Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-02 15:04:39 +08:00
ComixHe 7d678a48ba build: change the compatible way of finding GTest in older cmake
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-02 13:37:00 +08:00
ComixHe 60b31b423e build: vendoring CLI11 and nlohmann_json
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-04-01 17:36:48 +08:00
ComixHe c6725bd393 chore: use macro instead of if constexpr
compatible with old gcc

Signed-off-by: ComixHe <heyuming@deepin.org>
2025-03-31 17:58:49 +08:00
ComixHe e28caa9340 chore: adjust build process when disable cap and seccomp
Signed-off-by: ComixHe <heyuming@deepin.org>
2025-03-31 17:40:11 +08:00