Skip to content

Commit 231bfb1

Browse files
committed
nspawn: rename is_procfs_sysfs_or_suchlike() to is_fs_fully_userns_compatible()
Rename is_procfs_sysfs_or_suchlike() to is_fs_fully_userns_compatible() to give it the real meaning. This may prevent future modifications that may introduce bugs.
1 parent 87c05f3 commit 231bfb1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/nspawn/nspawn-patch-uid.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,13 @@ static int patch_fd(int fd, const char *name, const struct stat *st, uid_t shift
280280
return r > 0 || changed;
281281
}
282282

283-
static int is_procfs_sysfs_or_suchlike(int fd) {
283+
/*
284+
* Check if the filesystem is fully compatible with user namespaces or
285+
* UID/GID patching. Some filesystems in this list can be fully mounted inside
286+
* user namespaces, however their inodes may relate to host resources or only
287+
* valid in the global user namespace, therefore no patching should be applied.
288+
*/
289+
static int is_fs_fully_userns_compatible(int fd) {
284290
struct statfs sfs;
285291

286292
assert(fd >= 0);
@@ -314,8 +320,8 @@ static int recurse_fd(int fd, bool donate_fd, const struct stat *st, uid_t shift
314320

315321
/* We generally want to permit crossing of mount boundaries when patching the UIDs/GIDs. However, we
316322
* probably shouldn't do this for /proc and /sys if that is already mounted into place. Hence, let's
317-
* stop the recursion when we hit a procfs or sysfs file system. */
318-
r = is_procfs_sysfs_or_suchlike(fd);
323+
* stop the recursion when we hit procfs, sysfs or some other special file systems. */
324+
r = is_fs_fully_userns_compatible(fd);
319325
if (r < 0)
320326
goto finish;
321327
if (r > 0) {

0 commit comments

Comments
 (0)