core: create inaccessible nodes for users when making runtime dirs

To support ProtectHome=y in a user namespace (which mounts the inaccessible
nodes), the nodes need to be accessible by the user. Create these paths and
devices in the user runtime directory so they can be used later if needed.
This commit is contained in:
Anita Zhang
2019-12-18 11:09:30 -08:00
parent a49ad4c482
commit e5f10cafe0
11 changed files with 96 additions and 30 deletions
+4 -3
View File
@@ -883,8 +883,7 @@ static int mount_overlay(const char *dest, CustomMount *m) {
}
static int mount_inaccessible(const char *dest, CustomMount *m) {
_cleanup_free_ char *where = NULL;
const char *source;
_cleanup_free_ char *where = NULL, *source = NULL;
struct stat st;
int r;
@@ -897,7 +896,9 @@ static int mount_inaccessible(const char *dest, CustomMount *m) {
return m->graceful ? 0 : r;
}
assert_se(source = mode_to_inaccessible_node(st.st_mode));
r = mode_to_inaccessible_node("/run/systemd", st.st_mode, &source);
if (r < 0)
return m->graceful ? 0 : r;
r = mount_verbose(m->graceful ? LOG_DEBUG : LOG_ERR, source, where, NULL, MS_BIND, NULL);
if (r < 0)
+4 -1
View File
@@ -3252,6 +3252,7 @@ static int outer_child(
int netns_fd) {
_cleanup_close_ int fd = -1;
const char *p;
pid_t pid;
ssize_t l;
int r;
@@ -3447,7 +3448,9 @@ static int outer_child(
return r;
(void) dev_setup(directory, arg_uid_shift, arg_uid_shift);
(void) make_inaccessible_nodes(directory, arg_uid_shift, arg_uid_shift);
p = prefix_roota(directory, "/run/systemd");
(void) make_inaccessible_nodes(p, arg_uid_shift, arg_uid_shift);
r = setup_pts(directory);
if (r < 0)