summaryrefslogtreecommitdiff
path: root/src/test/test-fs-util.c
Commit message (Collapse)AuthorAge
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-08-24
| | | | | | | | | | | 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-08-24
| | | | | | | | | | | | | | | | 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.
* test: drop unused variablesYu Watanabe2018-08-24
| | | | Follow-up for 49eb36596b72e568d4b9b785cd4544e58c89bdee.
* fs-util: add new CHASE_STEP flag to chase_symlinks()Lennart Poettering2018-08-24
| | | | | | | | If the flag is set only a single step of the normalization is executed, and the resulting path is returned. This allows callers to normalize piecemeal, taking into account every single intermediary path of the normalization.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | 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.
* fd-util: introduce fd_reopen() helper for reopening an fdLennart Poettering2018-08-24
| | | | | | We have the same code for this in place at various locations, let's unify that. Also, let's repurpose test-fs-util.c as a test for this new helper cal..
* tree-wide: warn when a directory path already exists but has bad mode/owner/typeZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | | | | | | | | | | | When we are attempting to create directory somewhere in the bowels of /var/lib and get an error that it already exists, it can be quite hard to diagnose what is wrong (especially for a user who is not aware that the directory must have the specified owner, and permissions not looser than what was requested). Let's print a warning in most cases. A warning is appropriate, because such state is usually a sign of borked installation and needs to be resolved by the adminstrator. $ build/test-fs-util Path "/tmp/test-readlink_and_make_absolute" already exists and is not a directory, refusing. (or) Directory "/tmp/test-readlink_and_make_absolute" already exists, but has mode 0775 that is too permissive (0755 was requested), refusing. (or) Directory "/tmp/test-readlink_and_make_absolute" already exists, but is owned by 1001:1000 (1000:1000 was requested), refusing. Assertion 'mkdir_safe(tempdir, 0755, getuid(), getgid(), MKDIR_WARN_MODE) >= 0' failed at ../src/test/test-fs-util.c:320, function test_readlink_and_make_absolute(). Aborting. No functional change except for the new log lines.
* basic/mkdir: convert bool flag to enumZbigniew Jędrzejewski-Szmek2018-08-24
| | | | In preparation for subsequent changes...
* Prep v238: Uncomment now needed headers and unmask now needed functions in ↵Sven Eden2018-06-05
| | | | src/test (6/6)
* fs-util: move fsync_directory_of_file() into generic codeLennart Poettering2018-05-30
| | | | | This function used by the journal code is pretty useful generically, let's move it to fs-util.c to make it useful for other code too.
* fs-util: add new unlinkat_deallocate() helperLennart Poettering2018-05-30
| | | | | | | | | | | This new helper not only removes a file from a directory but also ensures its space on disk is deallocated, by either punching a hole over the full file or truncating the file afterwards if the file's link counter is 0. This is useful in "vacuuming" algorithms to ensure that client's can't keep the disk space the vacuuming is supposed to recover pinned simply by keeping an fd open to it. (cherry picked from commit 43767d9d5e0ce8923828aebf9154da7af83916f7)
* tree-wide: port all code to use safe_getcwd()Lennart Poettering2018-05-30
|
* fs-util: add new chase_symlinks() flag CHASE_OPENLennart Poettering2018-05-30
| | | | | | | | | | | The new flag returns the O_PATH fd of the final component, which may be converted into a proper fd by open()ing it again through the /proc/self/fd/xyz path. Together with O_SAFE this provides us with a somewhat safe way to open() files in directories potentially owned by unprivileged code, where we want to refuse operation if any symlink tricks are played pointing to privileged files.
* fs-util: add new CHASE_SAFE flag to chase_symlinks()Lennart Poettering2018-05-30
| | | | | | | | | When the flag is specified we won't transition to a privilege-owned file or directory from an unprivileged-owned one. This is useful when privileged code wants to load data from a file unprivileged users have write access to, and validates the ownership, but want's to make sure that no symlink games are played to read a root-owned system file belonging to a different context.
* fs-util: rework touch_file() so that it can touch socket file nodesLennart Poettering2018-05-30
| | | | | | | | | | | | | | | | | | Let's rework touch_file() so that it works correctly on sockets, fifos, and device nodes: let's open an O_PATH file descriptor first and operate based on that, if we can. This is usually the better option as it this means we can open AF_UNIX nodes in the file system, and update their timestamps and ownership correctly. It also means we can correctly touch symlinks and block/character devices without triggering their drivers. Moreover, by operating on an O_PATH fd we can make sure that we operate on the same inode the whole time, and it can't be swapped out in the middle. While we are at it, rework the call so that we try to adjust as much as we can before returning on error. This is a good idea as we call the function quite often without checking its result, and hence it's best to leave the files around in the most "correct" fashion possible.
* Prep v236 : Add missing SPDX-License-Identifier (8/9) src/testSven Eden2018-03-26
|
* tree-wide: do not work in assert() (#7271)Yu Watanabe2017-11-07
| | | | Fixes #7270.
* test-fs-util: re-order test_readlink_and_make_absolute and ↵Mike Gilbert2017-07-25
| | | | | | | | | | | | | | | | | | | test_get_files_in_directory (#6288) test_readlink_and_make_absolute switches to a temp directory, and then removes it. test_get_files_in_directory calls opendir(".") from a directory that has been removed from the filesystem. This call sequence triggers a bug in Gentoo's sandbox library. This library attempts to resolve the "." to an absolute path, and aborts when it ultimately fails to do so. Re-ordering the calls works around the issue until the sandbox library can be fixed to more gracefully deal with this. Bug: https://bugs.gentoo.org/590084
* Prep v233.3: Add all possible coverage tests for elogindSven Eden2017-07-20