summaryrefslogtreecommitdiffstats
path: root/src/tmpfiles (follow)
Commit message (Collapse)AuthorAgeFilesLines
* 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-111-1/+1
|\ | | | | core: simplify dbus properties
| * path-util: introduce empty_to_root() and use it many placesYu Watanabe2018-05-101-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.
* tmpfiles: also add %t/%S/%C/%L specifiersZbigniew Jędrzejewski-Szmek2017-12-061-16/+65
| | | | | | | | | sd_path_home() returns ENXIO when a variable (such as $XDG_RUNTIME_DIR) is not defined. Previously we used ENOKEY for unresolvable specifiers. To avoid having two codes, or translating ENXIO to ENOKEY, I replaced ENOKEY use with ENXIO. v2: - use sd_path_home and change to ENXIO everywhere
* tmpfiles: add --user switchZbigniew Jędrzejewski-Szmek2017-12-061-8/+89
|
* tmpfiles: Add specifiers to allow running as user instanceayekat2017-12-061-0/+4
| | | | | | | | | This commit adds specifiers %U, %u and %h for the user UID, name and home directory, respectively. [zj: drop untrue copy-pasted comments and move the next text to the new "Specifiers" section. Now that #7444 has been merged, also drop the specifier functions.]
* tmpfiles: "e" takes globsZbigniew Jędrzejewski-Szmek2017-12-061-1/+1
| | | | Fixes #7369.
* tmpfiles: fix typo in error messageZbigniew Jędrzejewski-Szmek2017-12-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #4097. As of current master, systemd-tmpfiles behaves correctly, apart from a trivial typo. So let's tell github to close the bug. With current git: $ sudo SYSTEMD_LOG_LEVEL=debug build/systemd-tmpfiles --create `pwd`/test/tmpfiles.d/link-loop.conf Successfully loaded SELinux database in 2.385ms, size on heap is 321K. Reading config file "/home/zbyszek/src/systemd-work/test/tmpfiles.d/link-loop.conf". Running create action for entry D /run/hello2 Found existing directory "/run/hello2". "/run/hello2" has right mode 41777 Running create action for entry f /run/hello2/hello2.test "/run/hello2/hello2.test" has been created. "/run/hello2/hello2.test" has right mode 101777 chown "/run/hello2/hello2.test" to 0.84 Running create action for entry L /run/hello2/hello2.link Found existing symlink "/run/hello2/hello2.link". Running create action for entry z /run/hello2/hello2.test "/run/hello2/hello2.test" has right mode 101777 chown "/run/hello2/hello2.test" to 0.0 Running create action for entry z /run/hello2/hello2.link Skipping mode an owner fix for symlink /run/hello2/hello2.link. and the permissions are: $ ls -dl /run/hello2/ /run/hello2/* drwxrwxrwt. 2 foo bar 80 Nov 22 14:40 /run/hello2/ lrwxrwxrwx. 1 root root 23 Nov 22 14:40 /run/hello2/hello2.link -> /run/hello2/hello2.test -rwxrwxrwt. 1 root root 0 Nov 22 14:40 /run/hello2/hello2.test Everything seems correct.
* tmpfiles: downgrade warning about duplicate lineZbigniew Jędrzejewski-Szmek2017-12-061-2/+2
| | | | | This happens occasionally, especially when moving lines between configuration files in different packages, and usually is not a big deal.
* Fail on unknown (alphanumerical) specifiersZbigniew Jędrzejewski-Szmek2017-12-061-5/+9
| | | | | | | | | | | | | | | | | | | | | | | The code intentionally ignored unknown specifiers, treating them as text. This needs to change because otherwise we can never add a new specifier in a backwards compatible way. So just treat an unknown (potential) specifier as an error. In principle this is a break of backwards compatibility, but the previous behaviour was pretty much useless, since the expanded value could change every time we add new specifiers, which we do all the time. As a compromise for backwards compatibility, only fail on alphanumerical characters. This should cover the most cases where an unescaped percent character is used, like size=5% and such, which behave the same as before with this patch. OTOH, this means that we will not be able to use non-alphanumerical specifiers without breaking backwards compatibility again. I think that's an acceptable compromise. v2: - add NEWS entry v3: - only fail on alphanumerical
* tmpfiles: add a special return code for syntax failuresZbigniew Jędrzejewski-Szmek2017-12-011-14/+52
| | | | | | | | | In this way, individual errors in files can be treated differently than a failure of the whole service. A test is added to check that the expected value is returned. Some parts are commented out, because it is not. This will be fixed in a subsequent commit.