diff options
author | Mike Yuan <me@yhndnzj.com> | 2024-11-27 16:35:11 +0100 |
---|---|---|
committer | Mike Yuan <me@yhndnzj.com> | 2025-01-04 17:07:59 +0100 |
commit | 07610cafcf60d1dddd8a59d508129fdca91857d7 (patch) | |
tree | c1572c8371588cc7d38f7b0f3c73425c323d38b6 /src/nspawn/nspawn.c | |
parent | namespace-util: refuse remote pidref in pidref_namespace_open() (diff) | |
download | systemd-07610cafcf60d1dddd8a59d508129fdca91857d7.tar.xz systemd-07610cafcf60d1dddd8a59d508129fdca91857d7.zip |
namespace-util: modernize fd_is_namespace() and is_our_namespace()
- Make fd_is_namespace() take NamespaceType
- Drop support for kernel without NS_GET_NSTYPE (< 4.11)
- Port is_our_namespace() to namespace_open_by_type()
(preparation for later commits, where the latter
would go by pidfd if available, avoiding procfs)
Diffstat (limited to 'src/nspawn/nspawn.c')
-rw-r--r-- | src/nspawn/nspawn.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index c2f232ae79..69fd347ad7 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -5249,12 +5249,10 @@ static int run_container( if (child_netns_fd < 0) return log_error_errno(errno, "Cannot open file %s: %m", arg_network_namespace_path); - r = fd_is_ns(child_netns_fd, CLONE_NEWNET); - if (r == -EUCLEAN) - log_debug_errno(r, "Cannot determine if passed network namespace path '%s' really refers to a network namespace, assuming it does.", arg_network_namespace_path); - else if (r < 0) + r = fd_is_namespace(child_netns_fd, NAMESPACE_NET); + if (r < 0) return log_error_errno(r, "Failed to check %s fs type: %m", arg_network_namespace_path); - else if (r == 0) + if (r == 0) return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Path %s doesn't refer to a network namespace, refusing.", arg_network_namespace_path); } |