summaryrefslogtreecommitdiff
path: root/src/tmpfiles
Commit message (Collapse)AuthorAgeFilesLines
...
* Merge pull request #13862 from zachsmith/systemd-tmpfiles-deprecate-for-forceZbigniew Jędrzejewski-Szmek2019-11-121-11/+7
|\ | | | | systemd-tmpfiles: deprecate F for f+
| * systemd-tmpfiles: deprecate F for f+Zach Smith2019-10-311-11/+7
| |
* | tree-wide: drop stdio.h when stdio-util.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 glob.h when glob-util.h is includedYu Watanabe2019-11-041-1/+0
| |
* | tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe2019-11-041-1/+0
| |
* | tree-wide: drop missing.hYu Watanabe2019-10-311-1/+0
|/
* basic/fs-util: change CHASE_OPEN flag into a separate output parameterZbigniew Jędrzejewski-Szmek2019-10-241-11/+11
| | | | | | | | | | | | | chase_symlinks() would return negative on error, and either a non-negative status or a non-negative fd when CHASE_OPEN was given. This made the interface quite complicated, because dependning on the flags used, we would get two different "types" of return object. Coverity was always confused by this, and flagged every use of chase_symlinks() without CHASE_OPEN as a resource leak (because it would this that an fd is returned). This patch uses a saparate output parameter, so there is no confusion. (I think it is OK to have functions which return either an error or an fd. It's only returning *either* an fd or a non-fd that is confusing.)
* systemd-tmpfiles: allow appending content to fileZach Smith2019-10-031-3/+5
| | | | | | | Adds support to append to files with w+ type. w /tmp/13291.out - - - - first line\n w+ /tmp/13291.out - - - - second line\n
* systemd-tmpfiles: rename force to append_or_forceZach Smith2019-10-031-12/+12
| | | | | | | The force field of the Item struct is used to indicate force creation or appending in different context. This change renames the field to append_or_force to improve readability.
* tree-wide: get rid of strappend()Lennart Poettering2019-07-121-2/+2
| | | | | It's a special case of strjoin(), so no need to keep both. In particular as typing strjoin() is even shoert than strappend().
* tmpfiles: use path_join() where it makes senseLennart Poettering2019-07-111-1/+1
|
* tmpfiles: fix buildLennart Poettering2019-07-111-1/+1
| | | | | | After I merged #12750 we don't build anymore, since the merged PR (which passed CI) uses prefix_root() which doesn't exist anymore. Let's fix that.
* Merge pull request #12750 from keszybz/tmpfiles-c-copyLennart Poettering2019-07-111-2/+10
|\ | | | | Make tmpfiles C use --root
| * tmpfiles: also prefix C source paths with --rootZbigniew Jędrzejewski-Szmek2019-06-051-2/+10
| | | | | | | | | | | | | | | | | | | | | | This makes the code match the docs for --root ("all paths will be prefixed"). I think this is reasonable, because --root also works for config paths, and any configuration inside --root must refer to paths under --root. If we allowed C to go "outside of root" in this way, the effect of calling systemd-tmpfiles --root=... and chrooting first and then calling systemd-tmpfiles second would be quite different. I think it's better to keep things simple and consistent. Fixes #12467.
* | tmpfiles: use log_syntax() for complaining about configuration file errorsLennart Poettering2019-07-101-2/+1
| | | | | | | | | | | | | | In the light of #12926 I needed some log messages for testing. This tmpfiles one came to mind, since it's frequently seen on typical Fedora systems. Alas, they didn't actually use log_syntax, and thus weren't recognizable by the new config file urlifaction code. Let's fix that.
* | Rename EXTRACT_QUOTES to EXTRACT_UNQUOTEZbigniew Jędrzejewski-Szmek2019-06-281-2/+2
| | | | | | | | | | | | Whenever I see EXTRACT_QUOTES, I'm always confused whether it means to leave the quotes in or to take them out. Let's say "unquote", like we say "cunescape".
* | tree-wide: replace strjoin() with path_join()Yu Watanabe2019-06-241-1/+1
| |
* | path-util: get rid of prefix_root()Lennart Poettering2019-06-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | prefix_root() is equivalent to path_join() in almost all ways, hence let's remove it. There are subtle differences though: prefix_root() will try shorten multiple "/" before and after the prefix. path_join() doesn't do that. This means prefix_root() might return a string shorter than both its inputs combined, while path_join() never does that. I like the path_join() semantics better, hence I think dropping prefix_root() is totally OK. In the end the strings generated by both functon should always be identical in terms of path_equal() if not streq(). This leaves prefix_roota() in place. Ideally we'd have path_joina(), but I don't think we can reasonably implement that as a macro. or maybe we can? (if so, sounds like something for a later PR) Also add in a few missing OOM checks
* | tmpfiles: use common fd_is_mount_point() implementation in tmpfiles.cLennart Poettering2019-06-181-36/+10
| | | | | | | | | | No need to have a private reimplementation here. Let's just use the common one, which supports "fdinfo" as fallback.
* | tmpfiles: merge two nested if checks into oneLennart Poettering2019-06-181-8/+10
| |
* | tmpfiles: use path_join() where we canLennart Poettering2019-06-181-1/+1
|/
* Merge pull request #12431 from poettering/tmpfiles-chmod-chown-orderZbigniew Jędrzejewski-Szmek2019-05-221-19/+57
|\ | | | | tmpfiles: run chown() before chmod()
| * tmpfiles: be more careful when adjusting chmod() + chown()Lennart Poettering2019-04-301-11/+41
| | | | | | | | | | | | | | | | | | | | | | | | chown() might drop the suid/sgid bit from files. hence let's chmod() after chown(). But also, let's tighten the transition a bit: before issuing chown() let's set the file mask to the minimum of the old and new access bitmask, so that at no point in time additional privs are available on the file with a non-matching ownership. Fixes: #12354
| * tmpfiles: split out ~ mode handling into a helper functionLennart Poettering2019-04-301-10/+18
| | | | | | | | No change of behaviour, just some minor refactoring.
* | tree-wide: replace explicit NULL checks with their shorter variantsFrantisek Sumsal2019-04-281-1/+1
|/ | | | Done by coccinelle/equals-null.cocci
* tree-wide: introduce empty_or_dash() helperLennart Poettering2019-04-081-5/+5
| | | | | At quite a few places we check isempty() || streq(…, "-"), let's add a helper to simplify that, and replace that by a single function call.
* tmpfiles: move full chattr flag set to chattr-util.hLennart Poettering2019-03-281-18/+1
| | | | It's a pretty generic concept and fits will there, hence let's move it.
* tmpfiles: support the FS_PROJINHERIT_FL chattr flagLennart Poettering2019-03-281-1/+3
|
* tree-wide: constify a few static string tablesLennart Poettering2019-03-251-1/+1
|
* util: split out sorting related calls to new sort-util.[ch]Lennart Poettering2019-03-131-1/+1
|
* tmpfiles: pass arg_root to chase_symlinks as the root prefixDavid Michael2019-02-281-3/+3
| | | | | | | | | | | This informs chase_symlinks that symlinks should be treated as if the path given by --root= is the root of their file system. With the parent commit, this allows tmpfiles to create files as the root user under a prefix that may be owned by an unprivileged user. In particular, this fixes the case where tmpfiles generates initial files in a staging root directory for packaging under a directory owned by the unprivileged packager user (e.g. in Gentoo).
* tmpfiles: let's bump RLIMIT_NOFILE for tmpfilesLennart Poettering2019-02-151-0/+4
| | | | | | | | | | | | | We potentially might descent into quite deep directory trees. Let's hence make sure we can allocate a lot of fds. (This reflects the fact that glibc nftw() and friends have some logic in place to reduce fd usage while descending into directory trees. Doing so is a bit nasty I think, and given that fds are basically free now, if we ask for them, lte's just protect ourselves and make use of that) (No, I am not aware of a real-world case where this was necessary, but let's better be safe than sorry)
* tmpfiles: while aging, take a BSD file lock on each directory we descent intoLennart Poettering2019-02-151-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let's add a fully safe way to exclude certain directories from aging, by taking a BSD file lock on them before aging them. This is useful for clients that untar tarballs into /tmp or /var/tmp, which might have really old timestamps, and to which the aging logic would be very harsh: they can simply take a BSD file lock on any directory they like and thus exclude it from automatic aging, and thus need not to be afraid of untarring stuff below it. Previously, similar functionality was already available through the sticky bit on non-directories, but it's problematic, since as soon as the bit is set no clean-up is done for it at all anymore, forever. Also, it is not suitable for untarring stuff, since the sticky bit after all is a concept denoted in the tarball itself. BSD file locking semantics are much much nicer there, as they are automatically released when the application that has them dies, and they are entirely orthogonal to data encoded in tarballs. This patch takes BSD file locks only on *directories* while descending down the tree, not on regular files. Moreover, it will do so in non-blocking mode only, i.e. if anyone else has a lock the aging for a dir and everything below it is immediately skipped for the current clean-up iteration. Of course applications might take BSD file locks for other reasons than just prevent aging (i.e for their own reasons), but that should be entirely OK, as in that case tmpfiles should step away from those files anyway too: it's a good idea to stay away from any such locked file anyway since it's apparently curretnly being manipulated. This allows us to fix bugs like this: https://github.com/systemd/mkosi/issues/252
* tmpfiles: make some log messages a tiny bit less cryptic for mere mortalsLennart Poettering2019-02-151-7/+6
|
* tmpfiles: break comment blocks according to our current editor settingsLennart Poettering2019-02-151-12/+7
|
* tmpfiles: clean up restoring of access times after aging a bitLennart Poettering2019-02-151-8/+8
| | | | | Let's minimize file scope, use compund literals and only use LOG_WARN for errors we ignore.
* tree-wide: use newa() instead of alloca() wherever we canLennart Poettering2019-01-261-1/+1
| | | | | Typesafety is nice. And this way we can take benefit of the new size assert() the previous commit added.
* tmpfiles: Make C still copy if the destination directory is emptyRyan Gonzalez2019-01-081-1/+1
| | | | Fixes #11287.
* Mark *data and *userdata params to specifier_printf() as constZbigniew Jędrzejewski-Szmek2018-12-121-4/+4
| | | | | | | It would be very wrong if any of the specfier printf calls modified any of the objects or data being printed. Let's mark all arguments as const (primarily to make it easier for the reader to see where modifications cannot occur).
* Merge pull request #10984 from ↵Lennart Poettering2018-12-101-11/+8
|\ | | | | | | | | fbuihuu/tmpfiles-be-more-explicit-with-unsafe-transition tmpfiles: be more explicit when an unsafe path transition is met
| * fs-util: make CHASE_WARN effective with CHASE_NO_AUTOFSFranck Bui2018-12-101-3/+4
| | | | | | | | | | | | | | | | This has the side effect to upgrade the log level at which the log is emitted from debug to warning. This might be better since after all we didn't apply a tmpfiles.d/ rule and that actually might end up being problematic eventually.
| * tmpfiles: use CHASE_WARN in addition to CHASE_SAFEFranck Bui2018-12-101-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | and let's emit a more comprehensive warning when an unsafe transition is encountered. Before this patch: Unsafe symlinks encountered in /run/nrpe, refusing. After: Detected unsafe path transition / → /run during canonicalization of /run/nrpe.
| * fs-util: make chase_symlink() returns -ENOLINK when unsafe transitions are metFranck Bui2018-12-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | We previously returned -EPERM but it can be returned for various other reasons too. Let's use -ENOLINK instead as this value shouldn't be used currently. This allows users of CHASE_SAFE to detect without any ambiguities when unsafe transitions are encountered by chase_symlinks(). All current users of CHASE_SAFE that explicitly reacted on -EPERM have been converted to react on -ENOLINK.
* | tmpfiles: define main through macroYu Watanabe2018-12-021-50/+40
| |
* | tmpfiles: make load_unix_sockets() return negative errno on failureYu Watanabe2018-12-021-45/+31
| |
* | tree-wide: rename path_join_many() to path_join()Zbigniew Jędrzejewski-Szmek2018-11-301-1/+1
| | | | | | | | | | | | $ git grep -e path_join_many -l|xargs sed -r -i 's/path_join_many/path_join/g' The two test functions are merged into one.
* | tree-wide: replace path_join with path_join_manyZbigniew Jędrzejewski-Szmek2018-11-301-1/+1
| |
* | Merge pull request #10996 from poettering/oci-prepZbigniew Jędrzejewski-Szmek2018-11-301-7/+4
|\ \ | | | | | | Preparation for the nspawn-OCI work
| * | tree-wide: port various parts of the code to use parse_dev()Lennart Poettering2018-11-291-7/+4
| |/