summaryrefslogtreecommitdiff
path: root/src/tmpfiles/tmpfiles.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek2018-06-201-3/+0
| | | | | | | | Fixes #9320. for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms' done
* Drop my copyright headersZbigniew Jędrzejewski-Szmek2018-06-141-1/+0
| | | | | | | perl -i -0pe 's/\s*Copyright © .... Zbigniew Jędrzejewski.*?\n/\n/gms' man/*xml git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/(#\n)?# +Copyright © [0-9, -]+ Zbigniew Jędrzejewski.*?\n//gms' git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s*\/\*\*\*\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*?\s*\*\*\*\/\s*/\n\n/gms' git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*//gms'
* tree-wide: beautify remaining copyright statementsLennart Poettering2018-06-141-2/+2
| | | | | | Let's unify an beautify our remaining copyright statements, with a unicode ©. This means our copyright statements are now always formatted the same way. Yay.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-1/+1
| | | | | | | | | | | 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.
* binfmt,sysctl,sysuers,tmpfiles: add auto-paging for --cat-config commandsLennart Poettering2018-06-131-0/+13
| | | | | The output of these commands is really long, and already enriched with color. Let's add auto-paging to make this easier to digest.
* path-util: introduce path_simplify()Yu Watanabe2018-06-031-3/+3
| | | | | | | | The function is similar to path_kill_slashes() but also removes initial './', trailing '/.', and '/./' in the path. When the second argument of path_simplify() is false, then it behaves as the same as path_kill_slashes(). Hence, this also replaces path_kill_slashes() with path_simplify().
* tree-wide: some O_NDELAY → O_NONBLOCK fixesLennart Poettering2018-05-311-1/+1
| | | | Somehow the coccinelle script misses these, hence fix them manually.
* core: introduce specifiers for /tmp and /var/tmpLennart Poettering2018-05-291-0/+3
| | | | | | | | | | | This corresponds nicely with the specifiers we already pass for /var/lib, /var/cache, /run and so on. This is particular useful to update the test-path service files to operate without guessable files, thus allowing multiple parallel test-path invocations to pass without issues (the idea is to set $TMPDIR early on in the test to some private directory, and then only use the new %T or %V specifier to refer to it).
* Merge pull request #8981 from keszybz/ratelimit-and-dbusLennart Poettering2018-05-181-1/+1
|\ | | | | Ratelimit renaming and dbus error message fix
| * Use STRLEN in two placesZbigniew Jędrzejewski-Szmek2018-05-131-1/+1
| |
* | tmpfiles: fix up and complain paths referring to /var/run (instead of /run) ↵Lennart Poettering2018-05-181-0/+41
|/ | | | | | | | | | | | | | | | | | | | | automatically tmpfiles.d relies on merging lines for the same file paths, as well as detecting conflicts between lines for the same file paths. /var/run is a prominent case that is an alias for /run, any many tmpfiles snippets refer to paths in /var/run rather than /run currently, which breaks the conflict detection and merging. We can't really fix this comprehensively, as doing so would require us to resolve symlinks early on, but that's precisely not what we want to do, as tmpfiles is usually run very early on where the paths might not be fully available yet (in particular as we might likely create them ourselves). Hence, let's at least detect and fix this case for the most prominent case of this ambiguity, and also log explicitly about this, asking users to fix the snippets in question so that the merging and conflict detection works properly again.
* tmpfiles: remove newline that shouldn't be thereLennart Poettering2018-05-111-3/+1
| | | | | We should really keep "else" branches together with their "if", hence drop the double newline here...
* Merge pull request #8953 from yuwata/bus-macroLennart Poettering2018-05-101-1/+1
|\ | | | | core: simplify dbus properties
| * path-util: introduce empty_to_root() and use it many placesYu Watanabe2018-05-111-1/+1
| |
* | tmpfiles: add --cat-configZbigniew Jędrzejewski-Szmek2018-04-271-27/+45
|/ | | | | | This implements similar logic as conf_files_cat(), but with slightly different file gathering logic. I also want to add support for replacement files later on, so it seems better to keep those two file-gathering functions separate.
* tmpfiles: 'e' is supposed to accept shell-style globsFranck Bui2018-04-241-1/+1
|
* tmpfiles: 'e' is supposed to operate on directory onlyFranck Bui2018-04-241-0/+3
|
* fs-util: introduce fchmod_opath()Franck Bui2018-04-241-8/+2
| | | | fchmod(2) still doesn't take file descriptors opened with O_PATH.
* tmpfiles: remove spurious curly braces in create_item()Franck Bui2018-04-241-3/+1
|
* 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.
* Merge pull request #8617 from keszybz/tmpfiles-relaxLennart Poettering2018-04-051-10/+10
|\ | | | | Do not exit with error when systemd-tmpfiles --boot fails
| * tmpfiles: add a new return code for "operational failure" when processingZbigniew Jędrzejewski-Szmek2018-04-051-10/+10
| | | | | | | | | | | | | | | | Things can fail, and we have no control over it: - file system issues (immutable bits, file system errors, MAC refusals, etc) - kernel refusing certain arguments when writing to /proc/sys or /sys Let's add a new code for the case where we parsed configuration but failed to execute it because of external errors.
* | Merge pull request #8605 from poettering/drop-in-name-fixZbigniew Jędrzejewski-Szmek2018-04-041-4/+1
|\ \ | | | | | | | | | Fix validation of unit file drop-in naming in install.c.
| * | fd-util: introduce fd_reopen() helper for reopening an fdLennart Poettering2018-03-291-4/+1
| |/ | | | | | | | | | | 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..
* | tmpfiles: fix directory removal with force symlink (#8619)Ricardo Salveti de Araujo2018-04-031-1/+1
|/ | | | | | | | symlink_atomic returns -EISDIR when the target symlink path is a directory. Fixes #7447 Signed-off-by: Ricardo Salveti <ricardo@opensourcefoundries.com>
* label: rework label_fix() implementations (#8583)Lennart Poettering2018-03-271-1/+1
| | | | | | | | | | | | | | | | | | | | This reworks the SELinux and SMACK label fixing calls in a number of ways: 1. The two separate boolean arguments of these functions are converted into a flags type LabelFixFlags. 2. The operations are now implemented based on O_PATH. This should resolve TTOCTTOU races between determining the label for the file system object and applying it, as it it allows to pin the object while we are operating on it. 3. When changing a label fails we'll query the label previously set, and if matches what we want to set anyway we'll suppress the error. Also, all calls to label_fix() are now (void)ified, when we ignore the return values. Fixes: #8566
* coccinelle: run const-strlen.cocci againLennart Poettering2018-03-231-4/+4
|
* macro: introduce TAKE_PTR() macroLennart Poettering2018-03-221-2/+1
| | | | | | | | | | | | | | | | This macro will read a pointer of any type, return it, and set the pointer to NULL. This is useful as an explicit concept of passing ownership of a memory area between pointers. This takes inspiration from Rust: https://doc.rust-lang.org/std/option/enum.Option.html#method.take and was suggested by Alan Jenkins (@sourcejedi). It drops ~160 lines of code from our codebase, which makes me like it. Also, I think it clarifies passing of ownership, and thus helps readability a bit (at least for the initiated who know the new macro)
* tmpfiles: don't resolve pathnames when traversing recursively through ↵Franck Bui2018-03-051-124/+239
| | | | | | | | | | | | | | | | | | | | | | | directory trees Otherwise we can be fooled if one path component is replaced underneath us. The patch achieves that by always operating at file descriptor level (by using *at() helpers) and by making sure we do not any path resolution when traversing direcotry trees. However this is not always possible, for instance when listing the content of a directory or some operations don't provide the *at() helpers or others (such as fchmodat()) don't have the AT_EMPTY_PATH flag. In such cases we operate on /proc/self/fd/%i pseudo-symlink instead, which works the same for all kinds of objects and requires no checking of type beforehand. Also O_PATH flag is used when opening file objects in order to prevent undesired behaviors: device nodes from reacting, automounts from triggering, etc... Fixes: #7986 Fixes: CVE-2018-6954
* tmpfiles: fstat() works with fd opened with O_PATH since Linux 3.6Franck Bui2018-03-051-2/+2
|
* tmpfiles: make hardlink_vulnerable() argument constantFranck Bui2018-03-051-1/+1
|
* Merge pull request #8144 from poettering/journal-inotify-fixesZbigniew Jędrzejewski-Szmek2018-02-141-2/+4
|\ | | | | various journal fixes
| * tree-wide: use path_hash_ops instead of string_hash_ops whenever we key by a ↵Lennart Poettering2018-02-121-2/+4
| | | | | | | | | | | | path Let's make use of our new hash_ops!
* | tmpfiles: age root-owned read-only files, by default (#7917)itsbill2018-02-121-6/+0
|/ | | | [zj: The note in NEWS was added in 82c8e3e6503a40684cf265842bb1c26a8f7681b5 and released as part of systemd-237.]
* tmpfiles: allow admin/runtime overrides to runtime configZbigniew Jędrzejewski-Szmek2018-02-051-27/+83
| | | | | This is very similar to d16a1c1bb6. For tmpfiles this is much less useful compared to sysusers, but let's add this anyway for consistency.
* tmpfiles: make "f" lines behaviour match what the documentation saysLennart Poettering2018-01-241-2/+7
| | | | | | | | | | | | | | | | | | | | CHANGE OF BEHAVIOUR — with this commit "f" line's behaviour is altered to match what the documentation says: if an "argument" string is specified it is written to the file only when the file didn't exist before. Previously, it would be appended to the file each time systemd-tmpfiles was invoked — which is not a particularly useful behaviour as the tool is not idempotent then and the indicated files grow without bounds each time the tool is invoked. I did some spelunking whether this change in behaviour would break things, but afaics nothing relies on the previous O_APPEND behaviour of this line type, hence I think it's relatively safe to make "f" lines work the way the docs say, rather than adding a new modifier for it or so. Triggered by: https://lists.freedesktop.org/archives/systemd-devel/2018-January/040171.html
* tmpfiles: create parent directories if they are missing for more line typesLennart Poettering2018-01-231-2/+20
| | | | | | | | | | | | | | | Currently, we create leading directories implicitly for all lines that create directory or directory-like nodes. With this, we also do the same for a number of other lines: f/F, C, p, L, c/b (that is regular files, pipes, symlinks, device nodes as well as file trees we copy). The leading directories are created with te default access mode of 0755. If something else is desired, users should simply declare appropriate "d" lines. Fixes: #7853
* tmpfiles: refuse to chown()/chmod() files which are hardlinked, unless ↵Lennart Poettering2018-01-231-0/+43
| | | | | | | | protected_hardlinks sysctl is on Let's add some extra safety. Fixes: #7736
* tmpfiles: fix check for figuring out whether to call chmod()Lennart Poettering2018-01-231-2/+2
| | | | No need to call chown() if everything matches already.
* tmpfiles: shortcut path_set_perms() if there's nothing to doLennart Poettering2018-01-231-1/+4
| | | | No need to open() anything in that case, hence don't.
* tmpfiles: change ownership of symlinks tooLennart Poettering2018-01-231-20/+21
| | | | | | | Ownership is supported for symlinks, too, only file modes are not. Support that too. Fixes: #7509
* tmpfiles: use the DEBUG_LOGGING macro where applicableLennart Poettering2018-01-221-1/+1
|
* tmpfiles: add missing OOM checkLennart Poettering2018-01-221-0/+3
|
* tmpfiles: avoid using wrong type for strlen() resultLennart Poettering2018-01-221-4/+1
| | | | | | The result of strlen is size_t, hence let's not store it in an "int" just to pass it on as as size_t right-away. In fact let's not store it at all…
* tmpfiles: in dir_cleanup() take benefit that log_error_errno() returns the ↵Lennart Poettering2018-01-221-4/+2
| | | | error code passed in
* tmpfiles: fold five lines into twoLennart Poettering2018-01-221-5/+2
| | | | | log_full_errno() has all these nice benefits, let's make use of them to shorten five lines into two.
* tmpfiles: consider /etc uninitialized also when /etc/machine-id is present ↵Franck Bui2018-01-101-3/+3
| | | | but empty (#7849)
* tmpfiles: modernize load_unix_sockets() a bitLennart Poettering2018-01-101-15/+30
| | | | | | | | Let's log in case of error. Let's use read_line() instead of a fixed-size buffer Let's make use of set_free_free()'s return value.
* 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.