]> git.ipfire.org Git - thirdparty/systemd.git/commit
nspawn: Simplify tmpfs_patch_options() usage, and trickle that up
authorLuke Shumaker <lukeshu@parabola.nu>
Tue, 13 Jun 2017 22:06:09 +0000 (18:06 -0400)
committerLuke Shumaker <lukeshu@parabola.nu>
Fri, 20 Jul 2018 16:12:02 +0000 (12:12 -0400)
commit2fa017f16922776ff9751dc22031c7ee49920729
treeb0a3a60baa908a7dde4cd4e524fbef07ffeafe7b
parent9c0fad5fb5f47da125bb768dbb4cd0e824cccc7c
nspawn: Simplify tmpfs_patch_options() usage, and trickle that up

One of the things that tmpfs_patch_options does is take an (optional) UID,
and insert "uid=${UID},gid=${UID}" into the options string.  So we need a
uid_t argument, and a way of telling if we should use it.  Fortunately,
that is built in to the uid_t type by having UID_INVALID as a possible
value.

So this is really a feature that requires one argument.  Yet, it is somehow
taking 4!  That is absurd.  Simplify it to only take one argument, and have
that trickle all the way up to mount_all()'s usage.

Now, in may of the uses, the argument becomes

    uid_shift == 0 ? UID_INVALID : uid_shift

because it used to treat uid_shift=0 as invalid unless the patch_ids flag
was also set.  This keeps the behavior the same.  Note that in all cases
where it is invoked, if !use_userns (sometimes called !userns), then
uid_shift is 0; we don't have to add any checks for that.

That said, I'm pretty sure that "uid=0" and not setting "uid=" are the
same, but Christian Brauner seemed to not think so when implementing the
cgns support.  https://github.com/systemd/systemd/pull/3589
src/nspawn/nspawn-mount.c
src/nspawn/nspawn-mount.h
src/nspawn/nspawn.c