summaryrefslogtreecommitdiff
path: root/src/basic/fs-util.h
Commit message (Collapse)AuthorAge
* Apply updates from upstreamSven Eden2017-12-07
|
* tmpfiles: silently ignore any path that passes through autofs (#6506)NeilBrown2017-09-04
| | | | | | | | | | | | | | | | | If a path passes though an autofs filesystem, then accessing the path might trigger and automount. As elogind-tmpfiles is run before the network is up, and as automounts are often used for networked filesystems, this can cause a deadlock. So chase_symlinks is enhance to accept a new flag which tells it to check for autofs, and return -EREMOTE if autofs is found. tmpfiles is changed to check just before acting on a path so that it can avoid autofs even if a symlink was created earlier by tmpfiles that would send this path through an autofs. This fixes a deadlock that happens when /home is listed in /etc/fstab as x-elogind.automount for an NFS directory.
* Prep v233.3: Unmask various functions for future coverage tests.Sven Eden2017-07-19
| | | | | These functions, although not used by elogind itself, are mostly tiny and crucial for important tests to work.
* Prep v233.2: Mask unneeded functions and definitions in src/basicSven Eden2017-07-18
|
* Prep v233: Unmask now needed functions in src/basicSven Eden2017-07-17
|
* bootctl: create loader.conf only if it doesn't exist yetLennart Poettering2017-07-17
| | | | | | | | | If the snippet aleady exists, don't do anything, as the file was already installed then. (This also reworks the code to create the file atomically) Fixes: #5396
* util-lib: add easy helpers for temporary directories that rmdir()ed via ↵Lennart Poettering2017-07-17
| | | | | | | | | | | | | | | | _cleanup_ This adds mkdtemp_malloc() that is a combination of mkdtemp() plus strdup(). It initializes its return paremeter only if the temporary directory could be created successfully, so that the parameter is exactly non-NULL when the directory exists. rmdir_and_free() and rmdir_and_freep() are also added, and the latter may be used inside of _cleanup_ for such a directory string variable, to automatically rmdir() the directory if it is non-NULL when the scope exits. rmdir_and_free() is similar to the existing rm_rf_and_free() however, is only removes a single directory and does not operate recursively.
* util-lib: rename CHASE_NON_EXISTING → CHASE_NONEXISTENTLennart Poettering2017-07-17
| | | | As suggested by @keszybz
* fs-util: add new CHASE_NON_EXISTING flag to chase_symlinks()Lennart Poettering2017-07-17
| | | | | | | | | | | | | | | | | This new flag controls whether to consider a problem if the referenced path doesn't actually exist. If specified it's OK if the final file doesn't exist. Note that this permits one or more final components of the path not to exist, but these must not contain "../" for safety reasons (or, to be extra safe, neither "./" and a couple of others, i.e. what path_is_safe() permits). This new flag is useful when resolving paths before issuing an mkdir() or open(O_CREAT) on a path, as it permits that the file or directory is created later. The return code of chase_symlinks() is changed to return 1 if the file exists, and 0 if it doesn't. The latter is only returned in case CHASE_NON_EXISTING is set.
* fs-util: add flags parameter to chase_symlinks()Lennart Poettering2017-07-17
| | | | | | Let's remove chase_symlinks_prefix() and instead introduce a flags parameter to chase_symlinks(), with a flag CHASE_PREFIX_ROOT that exposes the behaviour of chase_symlinks_prefix().
* fs-util: add chase_symlinks_prefix() and extend commentsLennart Poettering2017-07-17
| | | | | | | | chase_symlinks() currently expects a fully qualified, absolute path, relative to the host's root as first argument. Which is useful in many ways, and similar to the paths unlink(), rename(), open(), … expect. Sometimes it's however useful to first prefix the specified path with the specified root directory. Add a new call chase_symlinks_prefix() for this, that is a simple wrapper.
* tree-wide: stop using canonicalize_file_name(), use chase_symlinks() insteadLennart Poettering2017-07-17
| | | | | | | | Let's use chase_symlinks() everywhere, and stop using GNU canonicalize_file_name() everywhere. For most cases this should not change behaviour, however increase exposure of our function to get better tested. Most importantly in a few cases (most notably nspawn) it can take the correct root directory into account when chasing symlinks.
* Prep v232.2: Mask more unneeded functionsSven Eden2017-07-07
|
* namespace: chase symlinks for mounts to set up in userspaceLennart Poettering2017-07-05
| | | | | | | | | | | | | | | | This adds logic to chase symlinks for all mount points that shall be created in a namespace environment in userspace, instead of leaving this to the kernel. This has the advantage that we can correctly handle absolute symlinks that shall be taken relative to a specific root directory. Moreover, we can properly handle mounts created on symlinked files or directories as we can merge their mounts as necessary. (This also drops the "done" flag in the namespace logic, which was never actually working, but was supposed to permit a partial rollback of the namespace logic, which however is only mildly useful as it wasn't clear in which case it would or would not be able to roll back.) Fixes: #3867
* util-lib: rework /tmp and /var/tmp handling codeLennart Poettering2017-07-05
| | | | | | | | | | | | | | | | | | | | Beef up the existing var_tmp() call, rename it to var_tmp_dir() and add a matching tmp_dir() call (the former looks for the place for /var/tmp, the latter for /tmp). Both calls check $TMPDIR, $TEMP, $TMP, following the algorithm Python3 uses. All dirs are validated before use. secure_getenv() is used in order to limite exposure in suid binaries. This also ports a couple of users over to these new APIs. The var_tmp() return parameter is changed from an allocated buffer the caller will own to a const string either pointing into environ[], or into a static const buffer. Given that environ[] is mostly considered constant (and this is exposed in the very well-known getenv() call), this should be OK behaviour and allows us to avoid memory allocations in most cases. Note that $TMPDIR and friends override both /var/tmp and /tmp usage if set.
* Prep v231: Apply missing fixes from upstream (1/6) src/basicSven Eden2017-06-16
|
* Prep v230: Apply missing upstream fixes and updates (2/8) src/basic.Sven Eden2017-06-16
|
* musl-fix: faccessat does not support AT_SYMLINK_NOFOLLOW with musl.Enno Boland2017-05-24
|
* tree-wide: remove Emacs lines from all filesDaniel Mack2017-05-17
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* basic: include only what we useThomas Hindoe Paaboel Andersen2017-05-17
| | | | | This is a cleaned up result of running iwyu but without forward declarations on src/basic.
* tree-wide: sort includes in *.hThomas Hindoe Paaboel Andersen2017-05-17
| | | | | This is a continuation of the previous include sort patch, which only sorted for .c files.
* Prep v228: Condense elogind source masks (1/5)Sven Eden2017-04-26
| | | | | | | | | | | | Although having a two line mask like /// UNNEEDED by elogind #if 0 it is much more easier to read (and patch!) if those two lines were condense into a one-line mask start like #if 0 /// UNNEEDED by elogind
* Prep v228: Substitute declaration masks (1/4)Sven Eden2017-04-26
| | | | | | | | | | | | | | | | | Although it looks very ugly, substitute all declaration masks of the form: // UNNEEDED type foo(...); with: /// UNNEEDED by elogind #if 0 type foo(...); #endif // 0 to make future merging of upstream pathes easier, as the relevant lines themselves are not changed any more.
* Prep v228: Clean up the new src/basic/*-util-[hc] files:Sven Eden2017-04-26
| | | | | | | | | | | | | - src/basic/capability-util.[hc] - src/basic/cgroup-util.[hc] - src/basic/fd-util.[hc] - src/basic/fs-util.[hc] - src/basic/memfd-util.[hc] - src/basic/path-util.[hc] - src/basic/socket-util.[hc] - src/basic/terminal-util.[hc] - src/basic/user-util.[hc] - src/basic/xattr-util.[hc]
* Prep v228: Add remaining updates from upstream (1/3)Sven Eden2017-04-26
The util.[hc] files have been stripped of a lot of functions, that got sorted into various new files representing the type of utility. This commit adds the missing files.