summaryrefslogtreecommitdiff
path: root/src/tmpfiles
Commit message (Collapse)AuthorAgeFilesLines
* dissect-image: port mount_image_privately_interactively() to use ↵Lennart Poettering2023-05-161-3/+3
| | | | | | | | | | /run/systemd/mount-rootfs/ too Let's use the same common directory as the unit logic uses. This means we have less to clean up, and opens the door to eventually allow unprivileged operation of the mount_image_privately_interactively() logic.
* tmpfiles: Add merge support for copy files actionDaan De Meyer2023-05-101-1/+1
| | | | | If '+' is specified with 'C', let's merge the tree with any existing tree.
* tmpfiles: add conditionalized execute bit (X) supportMike Yuan2023-04-271-5/+149
| | | | | | | | | | | | | | | | | | According to setfacl(1), "the character X stands for the execute permission if the file is a directory or already has execute permission for some user." After this commit, parse_acl() would return 3 acl objects. The newly-added acl_exec object contains entries that are subject to conditionalized execute bit mangling. In tmpfiles, we would iterate the acl_exec object, check the permission of the target files, and remove the execute bit if necessary. Here's an example entry: A /tmp/test - - - - u:test:rwX Closes #25114
* tree-wide: use TAKE_STRUCTDavid Tardon2023-04-141-2/+1
|
* image-policy: introduce parse_image_policy_argument() helperYu Watanabe2023-04-131-13/+8
| | | | | | | | | Addresses https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1060130312, https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1067927293, and https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1067926416. Follow-up for 84be0c710d9d562f6d2cf986cc2a8ff4c98a138b.
* tree-wide: hook up image dissection policy logic everywhereLennart Poettering2023-04-051-0/+17
|
* tmpfiles: Try to take a BSD lock on files as wellDaan De Meyer2023-03-301-0/+10
| | | | | | Similar to what we do for directories, just before we remove a file, let's try to take a BSD lock on it. If that fails, skip removing the file.
* chase-symlinks: Rename chase_symlinks() to chase()Daan De Meyer2023-03-242-7/+7
| | | | | | | | | Chasing symlinks is a core function that's used in a lot of places so it deservers a less verbose names so let's rename it to chase() and chaseat(). We also slightly change the pattern used for the chaseat() helpers so we get chase_and_openat() and similar.
* tmpfiles: show file type in octal, instead of hexYu Watanabe2023-03-181-1/+1
|
* basic: add RuntimeScope enumLennart Poettering2023-03-101-8/+16
| | | | | | | | | | | | In various tools and services we have a per-system and per-user concept. So far we sometimes used a boolean indicating whether we are in system mode, or a reversed boolean indicating whether we are in user mode, or the LookupScope enum used by the lookup path logic. Let's address that, in introduce a common enum for this, we can use all across the board. This is mostly just search/replace, no actual code changes.
* meson: Use dicts for test definitionsJan Janssen2023-02-211-2/+6
| | | | | | | Although this slightly more verbose it makes it much easier to reason about. The code that produces the tests heavily benefits from this. Test lists are also now sorted by test name.
* dissect-image: Return mount point fd if requestedDaan De Meyer2023-02-171-0/+1
|
* tmpfiles: avoid double specifier expansion in L linesDmitry V. Levin2022-01-291-6/+8
| | | | | | | | | | | Starting with commit 2f3b873a4973, when the path contains a specifier and the argument is omitted, tmpfiles used to perform specifier expansions twice: first specifier expansion was applied to the path itself, and afterwards the result of the first expansion was used in the constructed argument and expanded once again. Resolves: #26244 Fixes: 2f3b873a4973 ("tmpfiles: copy/link /usr/share/factory/ files when the source argument is omitted")
* tmpfiles: fix specifier expansion in arguments of C linesDmitry V. Levin2022-01-291-28/+35
| | | | | | | | | | | | | | | | | | | | | | Make sure the argument of "C" type undergoes specifier expansion before it's checked for validity. In particular, starting with commit ce610af143b2, the check for path existence used to fail in case of presence of any specifier in the argument. Also, starting with commit 2f3b873a4973, when the path contains a specifier and the argument is omitted, tmpfiles used to perform specifier expansions twice: first specifier expansion was applied to the path itself, and afterwards the result of the first expansion was used in the constructed argument and expanded once again. Finally, starting with commit 849958d1ba35, when the argument begins with %h specifier, tmpfiles used to complain that the source path is not absolute. Resolves: #25381 Fixes: ce610af143b2 ('tmpfiles: in C lines, make missing source graceful error') Fixes: 2f3b873a4973 ('tmpfiles: copy/link /usr/share/factory/ files when the source argument is omitted') Fixes: 849958d1ba35 ('tmpfiles: add new "C" line for copying files or directories')
* meson: Do not include headers in source listsJan Janssen2023-01-241-3/+2
| | | | | | Meson+ninja+compiler do this for us and are better at it. https://mesonbuild.com/FAQ.html#do-i-need-to-add-my-headers-to-the-sources-list-like-in-autotools
* tmpfile: make failure in path_extract_filename() non-criticalYu Watanabe2023-01-091-6/+6
|
* tmpfile: fix resource leakYu Watanabe2023-01-091-2/+3
| | | | Fixes CID#1501687.
* tmpfiles: avoid null free() for acl attributesSam James2023-01-061-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | When built with ACL support, we might be processing a tmpfiles entry where there's no cause for us to call parse_acls_from_arg, then we get to the end of parse_line without having ever populated i.{acl_access, acl_default}. Then we pass a null pointer into acl_free(). From UBSAN w/ GCC 13.0.0_pre20230101: ``` $ systemd-tmpfiles --clean /var/tmp/portage/sys-apps/acl-2.3.1-r1/work/acl-2.3.1/libacl/acl_free.c:44:14: runtime error: applying non-zero offset 18446744073709551608 to null pointer #0 0x7f65d868b482 in acl_free /var/tmp/portage/sys-apps/acl-2.3.1-r1/work/acl-2.3.1/libacl/acl_free.c:44 #1 0x55fe7e592249 in item_free_contents ../systemd-9999/src/tmpfiles/tmpfiles.c:2855 #2 0x55fe7e5a347a in parse_line ../systemd-9999/src/tmpfiles/tmpfiles.c:3158 #3 0x55fe7e5a347a in read_config_file ../systemd-9999/src/tmpfiles/tmpfiles.c:3897 #4 0x55fe7e590c61 in read_config_files ../systemd-9999/src/tmpfiles/tmpfiles.c:3985 #5 0x55fe7e590c61 in run ../systemd-9999/src/tmpfiles/tmpfiles.c:4157 #6 0x55fe7e590c61 in main ../systemd-9999/src/tmpfiles/tmpfiles.c:4218 #7 0x7f65d7ebe289 (/usr/lib64/libc.so.6+0x23289) #8 0x7f65d7ebe344 in __libc_start_main (/usr/lib64/libc.so.6+0x23344) #9 0x55fe7e591900 in _start (/usr/bin/systemd-tmpfiles+0x11900) ```
* fundamental: rework IN_SET() to require at least three argumentsLennart Poettering2023-01-021-1/+1
| | | | | | | If less than three parameters are passed a simple comparison is the better choice. Lo and behold this found two pretty bad typos.
* tmpfiles: port basename() → path_extract_filename()Lennart Poettering2022-12-231-2/+7
|
* tree-wide: have_effective_cap() may return negative errnoYu Watanabe2022-12-231-1/+1
|
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-192-22/+22
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* treewide: drop "RUN_" from "RUN_WITH_UMASK"Zbigniew Jędrzejewski-Szmek2022-12-131-10/+10
| | | | | | RUN_WITH_UMASK was initially conceived for spawning externals progs with the umask set. But nowadays we use it various syscalls and stuff that doesn't "run" anything, so the "RUN_" prefix has outlived its usefulness.
* Fix typojcg2022-11-261-1/+1
|
* tmpfiles: log at info level when some allowed failures occurLuca Boccassi2022-11-141-16/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | In provision.conf we ship: d- /root :0700 root :root - d- /root/.ssh :0700 root :root - These are allowed to fail, for example on a read-only filesystem. But they still log at error level, which is annoying and gets flagged. Tune those specific errors down to info. There are likely more that could be tuned down, but the important thing is to cover the tmpfiles.d that we ship right now. Before: $ echo -e "d- /root :0700 root :root - \nd- /root/.ssh :0700 root :root -" | SYSTEMD_LOG_LEVEL=err build/systemd-tmpfiles --root=/tmp/img --create - Failed to create directory or subvolume "/tmp/img/root": Read-only file system Failed to open path '/tmp/img/root': No such file or directory $ After: $ echo -e "d- /root :0700 root :root - \nd- /root/.ssh :0700 root :root -" | SYSTEMD_LOG_LEVEL=err build/systemd-tmpfiles --root=/tmp/img --create - $
* strv: move nulstr utilities to nulstr-util.[ch]Lennart Poettering2022-11-131-0/+1
| | | | | | | Let's move them out of the generic, already very long strv.[ch] module into the more specific nulst-util.[ch] No code changes.
* copy: Support passing a deny list of files/directories to not copyDaan De Meyer2022-11-101-1/+2
|
* Rename def.h to constants.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+1
| | | | | | The name "def.h" originates from before the rule of "no needless abbreviations" was established. Let's rename the file to clarify that it contains a collection of various semi-related constants.
* basic: move version() to build.h+cZbigniew Jędrzejewski-Szmek2022-11-081-0/+1
|
* tmpfiles: downgrade missing creds/source path log to debugLuca Boccassi2022-10-291-2/+2
| | | | | | | | | | | | | | | | | When installing systemd 252 in debian: Setting up systemd (252~rc3-2) ... Installing new version of config file /etc/systemd/logind.conf ... Installing new version of config file /etc/systemd/system.conf ... Installing new version of config file /etc/systemd/user.conf ... /usr/lib/tmpfiles.d/provision.conf:13: Credential 'login.motd' not specified, skipping line. /usr/lib/tmpfiles.d/provision.conf:14: Credential 'login.issue' not specified, skipping line. /usr/lib/tmpfiles.d/provision.conf:17: Credential 'network.hosts' not specified, skipping line. /usr/lib/tmpfiles.d/provision.conf:22: Credential 'ssh.authorized_keys.root' not specified, skipping line. /usr/lib/tmpfiles.d/systemd.conf:43: Copy source path '/.extra/tpm2-pcr-signature.json' does not exist, skipping line. /usr/lib/tmpfiles.d/systemd.conf:44: Copy source path '/.extra/tpm2-pcr-public-key.pem' does not exist, skipping line. Downgrade to debug level
* tmpfiles: fix assertTopi Miettinen2022-10-031-1/+1
| | | | | | | Oct 03 17:33:20 systemd-tmpfiles[872]: Assertion 'IN_SET(i->type, CREATE_BLOCK_DEVICE|CREATE_CHAR_DEVICE)' failed at src/tmpfiles/tmpfiles.c:1837, function create_device(). Aborting. I think this is caused by the line: b! /dev/private/smartmontools-dev/sda 0660 root disk - 8:0
* tmpfiles: downgrade message about unitialized-/etcZbigniew Jędrzejewski-Szmek2022-09-271-8/+17
| | | | | | | | | | If we're running with --root, or in a chroot (*), it's expected that machine-id and other specifiers will be unresolvable, so downgrade the warning to debug. Fixes #24655. (*) sd_booted() in principle means more than that, but nowadays systemd dominates and those others things are infrequently seen.
* tmpfiles: fix detection of unitialized-/etcZbigniew Jędrzejewski-Szmek2022-09-271-18/+14
| | | | | | | | | | | | | | | | In 6ec4c852c910b1aca649e87ba3143841334f01fa I changed specifier_machine_id() to return EUNATCH, but the code catching in tmpfiles wasn't adjusted. Instead of translating errors at various levels, let the "original" errno value (whatever was returned by the low-level reading function) propagate all the way to the logging function, and only check which errnos to suppress there. This makes it easier to follow the flow of data through all the layers. Also, we don't need to provide wrapper functions for each place where we want to do the supression. The common set of errnos that have similar meaning are are caught using ERRNO_IS_NOINFO(). It is more managable to use a wider net than to figure out which errors could be returned in specific cases.
* tmpfiles: fix wrong return valueYu Watanabe2022-09-241-1/+1
| | | | Follow-up for 27f6aa0b7112024c1236957abd909071b06869a8.
* tmpfiles: rework empty_directory() to also use chase_symlinks()Lennart Poettering2022-09-231-8/+15
|
* tmpfiles: move symlink creation into its own function, and modernizeLennart Poettering2022-09-231-45/+94
| | | | | Let's ensure it also operates based on O_PATH, like fifo/device node/… creation.
* tmpfiles: whenever creating an inode, immediately O_PATH open it to pin itLennart Poettering2022-09-231-118/+165
| | | | | | let's make things a bit less racy: whenever we create an inode, immediately open it via O_PATH, compare type and continue operations with the acquired fd.
* tmpfiles: allow prefixing uid/gid/mode with ":" to only apply on creationLennart Poettering2022-09-231-37/+56
| | | | | | | | | | | | | | | | | | | | | In some cases it is useful to specify the access mode/uid/gid for inodes we create without also enforcing them on existing inodes. Let's add a new flag for that: if the uid/gid/mode specificaitons are prefixed with ":", then they only apply to creation, not otherwise. This is specifically useful for provisioning SSH keys later. Those we'd like to provision like this: <snip> d /root :0700 root root - d /root/.ssh :0700 root root - f^ /root/.ssh/authorized_keys - - - - ssh.authorized_keys </snip> While /root/ + /root/.ssh/ being owned by root is pretty uncontroversial the access mode of /root/ and /root/.ssh/ might not be. Hence we should only have a default mode defined that is used when we create the dir, but not otherwise.
* tmpfiles: generalize CreationMode and pass it everywhereLennart Poettering2022-09-231-72/+140
| | | | | | | For some purposes we had CreationMode which indicates whether an inode was created by us, or is pre-existing. Let's generalize that for *all* operations. This is later useful to conditionalize certain operations on that (and makes the codebase more systematic)
* tmpfiles: rebreak some commentsLennart Poettering2022-09-231-16/+10
|
* tree-wide: drop unused reference to DecryptedImageYu Watanabe2022-09-181-3/+1
|
* fd-util: rename CLOSE_AND_REPLACE() -> close_and_replace()Yu Watanabe2022-09-171-1/+1
| | | | | | | | We have free_and_replace() and friends, they are all named with lower letters, even they are macros, not functions. For consistency, let's rename CLOSE_AND_REPLACE() with lower letters. This also mekes the macro used more places.
* tmpfiles: let's suffix path to dirs with '/' also in log messagesLennart Poettering2022-09-171-1/+1
|
* tmpfiles: drop redundant forward declarationsLennart Poettering2022-09-171-3/+0
|
* tree-wide: Fix a some remaining format warnings by castingJan Janssen2022-08-301-1/+7
|
* tmpfiles: move validation/normalization of path before we use itLennart Poettering2022-08-261-8/+8
| | | | | | | | We need to normalize/validate the path (i.e. first column) of tmpfiles.d/ lines before we start using the path, otherwise we'll use it before it's known to be good. This matters since for some line types the path is mangled into the argument column (i.e. sevents column), and we should only do that once we know it's in a good state.
* tmpfiles: in C lines, make missing source graceful errorLennart Poettering2022-08-261-0/+7
| | | | | | | | | | | | | | | | | | I don't see where it would ever be a good thing that file copies done via tmpfiles.d/ C lines cause the tmpfiles operation to fail if their source happens to be missing. It's a problem if we can't set up the destination properly (which is the job of systemd-tmpfiles after all), but if the source is simply missing (NB: setting up the source is the job of of the rules writer) this shouldn't be a problem. This is useful for copying stuff into place if it happens to exist. For example, if systemd-stub passes additional data into the initrd's /.extra/ directory, we can copy it into a better place (e.g. /run/) with this, where it will survive the initrd→host transition. This mirrors behaviour of the recently added "^" line modifier which may be used source "w" lines from credentials – there two the behaviour is to simply skip the line if the source is missing.
* tmpfiles: add ^ line modifier for loading file contents from specific credentialLennart Poettering2022-07-201-8/+34
|
* tmpfiles: accept additional tmpfiles lines via credentialLennart Poettering2022-07-201-1/+30
|
* tmpfiles: minor shortening of codeLennart Poettering2022-07-151-3/+1
|