summaryrefslogtreecommitdiff
path: root/src/nspawn/nspawn-patch-uid.c
Commit message (Collapse)AuthorAgeFilesLines
* nspawn: guard acl_free() with a NULL checkLennart Poettering2023-01-061-1/+3
| | | | | | | Inspired by #25957 there's one other place where we don't guard acl_free() calls with a NULL check. Fix that.
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-2/+2
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* tree-wide: make FOREACH_DIRENT_ALL define the iterator variableZbigniew Jędrzejewski-Szmek2021-12-151-2/+0
| | | | | | | | | The variable is not useful outside of the loop (it'll always be null after the loop is finished), so we can declare it inline in the loop. This saves one variable declaration and reduces the chances that somebody tries to use the variable outside of the loop. For consistency, 'de' is used everywhere for the var name.
* tree-wide: port things over to FORMAT_PROC_FD_PATH()Lennart Poettering2021-08-191-14/+6
|
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* *: convert amenable fdopendir() calls to take_fdopendir()Vito Caputo2020-03-311-2/+2
| | | | | | | Some fdopendir() calls remain where safe_close() is manually performed, those could be simplified as well by converting to use the _cleanup_close_ machinery, but makes things less trivial to review so left for a future cleanup.
* tree-wide: drop magic.h when missing_magic.h is includedYu Watanabe2019-11-041-1/+0
|
* tree-wide: drop stat.h or statfs.h when stat-util.h is includedYu Watanabe2019-11-041-1/+0
|
* tree-wide: drop acl.h when acl-util.h is includedYu Watanabe2019-11-041-3/+0
|
* tree-wide: drop missing.hYu Watanabe2019-10-311-1/+1
|
* codespell: fix spelling errorsBen Boeckel2019-04-291-1/+1
|
* tree-wide: fix false search hits with ppp (typos)Topi Miettinen2019-03-181-1/+1
|
* tree-wide: remove various unused functionsLennart Poettering2018-12-021-4/+0
| | | | All found with "cppcheck --enable=unusedFunction".
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-04-051-2/+1
|
* tree-wide: make use of new STRLEN() macro everywhere (#7639)Lennart Poettering2017-12-141-2/+2
| | | | | Let's employ coccinelle to do this for us. Follow-up for #7625.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* nspawn: make recursive chown()ing logic safe for being aborted in the middleLennart Poettering2017-11-171-46/+75
| | | | | | | | | | | | | | | | | | | | | | | We currently use the ownership of the top-level directory as a hint whether we need to descent into the whole tree to chown() it recursively or not. This is problematic with the previous chown()ing algorithm, as when descending into the tree we'd first chown() and then descend further down, which meant that the top-level directory would be chowned first, and an aborted recursive chowning would appear on the next invocation as successful, even though it was not. Let's reshuffle things a bit, to make the re-chown()ing safe regarding interruptions: a) We chown() the dir we are looking at last, and descent into all its children first. That way we know that if the top-level dir is properly owned everything inside of it is properly owned too. b) Before starting a chown()ing operation, we mark the top-level directory as owned by a special "busy" UID range, which we can use to recognize whether a tree was fully chowned: if it is marked as busy, it's definitely not fully chowned, as the busy ownership will only be fixed as final step of the chowning. Fixes: #6292
* build-sys: use #if Y instead of #ifdef Y everywhereZbigniew Jędrzejewski-Szmek2017-10-041-2/+2
| | | | | | | | | | | | | | | The advantage is that is the name is mispellt, cpp will warn us. $ git grep -Ee "conf.set\('(HAVE|ENABLE)_" -l|xargs sed -r -i "s/conf.set\('(HAVE|ENABLE)_/conf.set10('\1_/" $ git grep -Ee '#ifn?def (HAVE|ENABLE)' -l|xargs sed -r -i 's/#ifdef (HAVE|ENABLE)/#if \1/; s/#ifndef (HAVE|ENABLE)/#if ! \1/;' $ git grep -Ee 'if.*defined\(HAVE' -l|xargs sed -i -r 's/defined\((HAVE_[A-Z0-9_]*)\)/\1/g' $ git grep -Ee 'if.*defined\(ENABLE' -l|xargs sed -i -r 's/defined\((ENABLE_[A-Z0-9_]*)\)/\1/g' + manual changes to meson.build squash! build-sys: use #if Y instead of #ifdef Y everywhere v2: - fix incorrect setting of HAVE_LIBIDN2
* nspawn: properly report all kinds of changed UID/GID when patching things ↵Lennart Poettering2017-10-021-0/+2
| | | | | | for userns We forgot to propagate one chmod().
* fs-util: unify code we use to check if dirent's d_name is "." or ".."Lennart Poettering2017-02-021-1/+1
| | | | | We use different idioms at different places. Let's replace this is the one true new idiom, that is even a bit faster...
* nspawn: fix uid patching logic (#3599)Lennart Poettering2016-06-251-3/+6
| | | | | | An incorrectly set if/else chain caused aus to apply the access mode of a symlink to the directory it is located in. Yuck. Fixes: #3547
* nspawn: rename is_procfs_sysfs_or_suchlike() to is_fs_fully_userns_compatible()Djalal Harouni2016-05-261-3/+9
| | | | | | 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.
* nspawn: a bench of special fileystems that should not be shiftedDjalal Harouni2016-05-261-0/+3
| | | | | Add some special filesystems that should not be shifted, most of them relate to the host and not to containers.
* nspawn: when readjusting UID/GID ownership of OS trees, skip read-only subtreesLennart Poettering2016-04-251-3/+15
| | | | | | | | This should allow tools like rkt to pre-mount read-only subtrees in the OS tree, without breaking the patching code. Note that the code will still fail, if the top-level directory is already read-only.
* nspawn: don't try to patch UIDs/GIDs of procfs and suchlikeLennart Poettering2016-04-251-2/+42
|
* nspawn: optionally fix up OS tree uid/gids for usernsLennart Poettering2016-04-251-0/+417
This adds a new --private-userns-chown switch that may be used in combination with --private-userns. If it is passed a recursive chmod() operation is run on the OS tree, fixing all file owner UID/GIDs to the right ranges. This should make user namespacing pretty workable, as the OS trees don't need to be prepared manually anymore.