From 91181e075be46e9c919315f2e8f903a963754cb2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 5 May 2021 12:29:01 +0200 Subject: [PATCH] nspawn: export userns_mkdir() + userns_lchown() so that it can be used elsewhere in nspawn --- src/nspawn/meson.build | 1 + src/nspawn/nspawn.c | 5 +++-- src/nspawn/nspawn.h | 7 +++++++ 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 src/nspawn/nspawn.h diff --git a/src/nspawn/meson.build b/src/nspawn/meson.build index 172ded43c1..a0e051ed32 100644 --- a/src/nspawn/meson.build +++ b/src/nspawn/meson.build @@ -26,6 +26,7 @@ libnspawn_core_sources = files(''' nspawn-setuid.h nspawn-stub-pid1.c nspawn-stub-pid1.h + nspawn.h '''.split()) nspawn_gperf_c = custom_target( diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index a8441bf8e0..9dbe2af5d9 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -76,6 +76,7 @@ #include "nspawn-settings.h" #include "nspawn-setuid.h" #include "nspawn-stub-pid1.h" +#include "nspawn.h" #include "nulstr-util.h" #include "os-util.h" #include "pager.h" @@ -1818,7 +1819,7 @@ static int verify_arguments(void) { return 0; } -static int userns_lchown(const char *p, uid_t uid, gid_t gid) { +int userns_lchown(const char *p, uid_t uid, gid_t gid) { assert(p); if (arg_userns_mode == USER_NAMESPACE_NO) @@ -1847,7 +1848,7 @@ static int userns_lchown(const char *p, uid_t uid, gid_t gid) { return 0; } -static int userns_mkdir(const char *root, const char *path, mode_t mode, uid_t uid, gid_t gid) { +int userns_mkdir(const char *root, const char *path, mode_t mode, uid_t uid, gid_t gid) { const char *q; int r; diff --git a/src/nspawn/nspawn.h b/src/nspawn/nspawn.h new file mode 100644 index 0000000000..27fb0b44eb --- /dev/null +++ b/src/nspawn/nspawn.h @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include + +int userns_lchown(const char *p, uid_t uid, gid_t gid); +int userns_mkdir(const char *root, const char *path, mode_t mode, uid_t uid, gid_t gid);