Commit Graph

449 Commits

Author SHA1 Message Date
Lennart Poettering c2bc710b24 string-util: imply NULL termination of strextend() argument list
The trailing NULL in the argument list is now implied (similar to
what we already have in place in strjoin()).
2021-01-06 17:24:46 +01:00
Yu Watanabe d1a61dfa69 tmpfiles: fix typo
Follow-up for 94566540e3.
2020-12-19 00:58:22 +09:00
Yu Watanabe 94566540e3 tmpfiles: try to set file attributes one by one
Closes #17690.
2020-12-18 12:35:57 +09:00
Yu Watanabe e93387f38b tree-wide: sort specifiers and move common comments to specifier.h 2020-11-25 15:12:27 +09:00
Lennart Poettering 2824aa0796 specifiers: introduce common macros for generating specifier tables
In many cases the tables are largely the same, hence define a common set
of macros to generate the common parts.

This adds in a couple of missing specifiers here and there, so is more
thant just refactoring: it actually fixes accidental omissions.

Note that some entries that look like they could be unified under these
macros can't really be unified, since they are slightly different. For
example in the DNSSD service logic we want to use the DNSSD hostname for
%H rather than the unmodified kernel one.
2020-11-25 14:13:02 +09:00
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Pat Coulthard 3045c416e1 tmpfiles: Handle filesystems without ACL support in more cases. 2020-10-26 10:20:10 +01:00
Michael Biebl 427103f7a6
Merge pull request #17297 from keszybz/tmpfiles-sysusers-disable-standalone-image
tmpfiles,sysusers: disable --image= support in standalone versions
2020-10-20 23:07:16 +02:00
Lennart Poettering 6008336ffa tmpfiles: no need to specify a synthetic error code if we don't propagate it 2020-10-19 14:22:25 +02:00
Zbigniew Jędrzejewski-Szmek 3537577c37 tmpfiles,sysusers: disable --image= support in standalone versions
Fixes #17278.
2020-10-09 18:03:04 +02:00
Frantisek Sumsal d7a0f1f4f9 tree-wide: assorted coccinelle fixes 2020-10-09 15:02:23 +02:00
Frantisek Sumsal 69e3234db7 tree-wide: fix typos found by codespell
Reported by Fossies.org
2020-09-14 15:32:37 +02:00
Zbigniew Jędrzejewski-Szmek f8bff7805e
Merge pull request #16933 from poettering/copy-hardlinks
copy: optionally recreate hardlinks when copying file trees
2020-09-10 19:04:52 +02:00
Lennart Poettering dee00c1939 fs-util,tmpfiles: fix error handling of fchmod_opath()
When 4dfaa528d4 was first commited its callers relied on `errno` instead of the
return value for error reporting. Which worked fine, since internally
under all conditions base were set — even if ugly and not inline with
our coding style. Things then got broken in
f8606626ed where suddenly additional
syscalls might end up being done in the function, thus corrupting `errno`.
2020-09-10 12:47:50 +02:00
Lennart Poettering 652d90407a tree-wide: copy hardlinks wherever we deal with possibly large OS-style trees
Fixes: #7382
2020-09-09 20:21:49 +02:00
Zbigniew Jędrzejewski-Szmek 90e74a66e6 tree-wide: define iterator inside of the macro 2020-09-08 12:14:05 +02:00
Lennart Poettering ca194a2a0c stat-util: provide single fallback implementation of statx()
This simplifies things quite a bit, and is reusable wherever we want to
use statx() later on. Not sure why I didn't do it like this right from
the beginning...
2020-09-03 15:02:34 +02:00
Lennart Poettering 7cd296c28f stat-util: add new macros for declaring statx variable
Let's deal with the msan initialization issue once for all cases instead
of over and over again.
2020-09-03 15:02:16 +02:00
Zbigniew Jędrzejewski-Szmek f77d6ec953
Merge pull request #16877 from poettering/tmpfiles-statx
tmpfiles: use statx()
2020-09-01 16:32:50 +02:00
Lennart Poettering 95d2155aeb tree-wide: no need to negate argument to ERROR_IS_XYZ()
These macros call abs() internally, hence let's simplify invocations.
2020-08-28 22:58:58 +02:00
Lennart Poettering ddb439b8f9 tmpfiles: use statx() when aging files
This allows us to properly detect mount points, for free. (Also, allows
us to respect btimes that are newer than the cutoff, which should be
useful when people untar file trees in /var/tmp)

Fixes: #16848
2020-08-28 15:45:37 +02:00
Luca Boccassi 7b3eb5c97e basic/time-util: add function to format timestamps with different styles
Instead of a multiple fixed format helper functions, add an enum and
a single helper, so that it's easier to extend in the future.
2020-08-19 15:30:13 +01:00
Lennart Poettering 63d3d0a50b tmpfiles: support --image= similar to --root= 2020-08-05 20:34:58 +02:00
Lennart Poettering b8e35011f7 tmpfiles: properly prefix paths in debug outputs
This is otherwise very confusing...
2020-08-05 20:26:25 +02:00
Lennart Poettering b63aacaa1a tmpfiles: we don't support the combination of --root and --user, hence refuse it
--user only really works with certain env vars such as XDG_RUNTIME_DIR
set, but that's just weird if --root= is used.
2020-08-05 20:26:25 +02:00
Lennart Poettering dd04fb3268 tmpfiles: add new switch -E for quickly excluding /proc, /dev, /sys and /run 2020-08-05 20:26:25 +02:00
Lennart Poettering 6b000af4f2 tree-wide: avoid some loaded terms
https://tools.ietf.org/html/draft-knodel-terminology-02
https://lwn.net/Articles/823224/

This gets rid of most but not occasions of these loaded terms:

1. scsi_id and friends are something that is supposed to be removed from
   our tree (see #7594)

2. The test suite defines an API used by the ubuntu CI. We can remove
   this too later, but this needs to be done in sync with the ubuntu CI.

3. In some cases the terms are part of APIs we call or where we expose
   concepts the kernel names the way it names them. (In particular all
   remaining uses of the word "slave" in our codebase are like this,
   it's used by the POSIX PTY layer, by the network subsystem, the mount
   API and the block device subsystem). Getting rid of the term in these
   contexts would mean doing some major fixes of the kernel ABI first.

Regarding the replacements: when whitelist/blacklist is used as noun we
replace with with allow list/deny list, and when used as verb with
allow-list/deny-list.
2020-06-25 09:00:19 +02:00
Zbigniew Jędrzejewski-Szmek f83803a649
Merge pull request #16238 from keszybz/set-handling-more
Fix handling of cases where a duplicate item is added to a set and related cleanups
2020-06-24 17:42:13 +02:00
Christian Göttsche a9ba0e328f Make failures of mac_selinux_init() fatal 2020-06-23 19:10:07 +02:00
Zbigniew Jędrzejewski-Szmek de7fef4b6e tree-wide: use set_ensure_put()
Patch contains a coccinelle script, but it only works in some cases. Many
parts were converted by hand.

Note: I did not fix errors in return value handing. This will be done separate
to keep the patch comprehensible. No functional change is intended in this
patch.
2020-06-22 16:32:37 +02:00
Daan De Meyer 8a7b71bd97
Merge pull request #15910 from poettering/tmpfiles-pstore-tweak
tmpfiles: let's make pstore sysfs failure silent
2020-05-26 21:59:13 +02:00
Lennart Poettering 4b019d2f2d tmpfiles: deal with kernel errno change if quota is not enabled
Old kernels returned EINVAL if quota was off but we tried to manipulate
it anyway. Since
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8a36e408d40606e21cd4e2dd9601004a67b14868
this changed: now ENOTCONN is returned. This of course is a kernel API
compat breakage, but let's not make a fuss and just map EINVAL to
ENOTCONN to make it recognizable the same way everywhere.

Fixes: #15896
2020-05-26 21:36:29 +02:00
Lennart Poettering 1baaf8aa04 tmpfiles: downgrade log message when we can't write a file and failure is allowed 2020-05-25 16:43:35 +02:00
Zbigniew Jędrzejewski-Szmek 165bda37ba
Merge pull request #15718 from poettering/tmpfiles-offline
tmpfiles: read /etc/passwd + /etc/group with fgetpwent()/fgetgrent() if --root= is specified
2020-05-08 11:22:19 +02:00
Zbigniew Jędrzejewski-Szmek e97708fa3e Add %l as specifier for the hostname without any domain component
As described in #15603, it is a fairly common setup to use a fqdn as the
configured hostname. But it is often convenient to use just the actual
hostname, i.e. until the first dot. This adds support in tmpfiles, sysusers,
and unit files for %l which expands to that.

Fixes #15603.
2020-05-07 17:36:44 +02:00
Lennart Poettering 7dc6477dc9 sysusers/tmpfiles: use --root=/ as way to force offline operation (i.e. without NSS) 2020-05-07 16:35:20 +02:00
Lennart Poettering a3451c2c4c tmpfiles: optionally, read /etc/passwd + /etc/group without NSS
There are two libc APIs for accessing the user database: NSS/getpwuid(),
and fgetpwent(). if we run in --root= mode (i.e. "offline" mode), let's
use the latter. Otherwise the former. This means tmpfiles can use the
database included in the root environment for chowning, which is a lot
more appropriate.

Fixes: #14806
2020-05-07 16:35:20 +02:00
Frantisek Sumsal e83ef04d97
Merge pull request #15626 from poettering/more-specifiers
tmpfiles,sysusers,pid1: add a bunch of more specifiers
2020-04-29 10:07:12 +02:00
Lennart Poettering dfe01841e6 tmpfiles: remove unnecessary assert
if we parse an xattr line that has no valid assignment, we might end up
with an empty ->xattr list. Don't hit assert on that, just go on.

Fixes: #15610
2020-04-29 00:23:28 +02:00
Lennart Poettering d02933fded tmpfiles: use log_syntax() for all parse errors 2020-04-29 00:23:28 +02:00
Lennart Poettering 268f5a5463 tree-wide: support a bunch of additional specifiers 2020-04-28 22:47:21 +02:00
Lennart Poettering f8606626ed tmpfiles: if we get ENOENT when opening /proc/self/fd/, check if /proc is mounted
let's return ENOSYS in that case, to make things a bit less confusng.

Previously we'd just propagate ENOENT, which people might mistake as
applying to the object being modified rather than /proc/ just not being
there.

Let's return ENOSYS instead, i.e. an error clearly indicating that some
kernel API is not available. This hopefully should put people on a
better track.

Note that we only do the procfs check in the error path, which hopefully
means it's the less likely path.

We probably can add similar bits to more suitable codepaths dealing with
/proc/self/fd, but for now, let's pick to the ones noticed in #14745.

Fixes: #14745
2020-04-23 14:52:10 +02:00
Lennart Poettering 0f7e4b2888 sysusers,tmpfiles: always mention error when failing to replace specifiers 2020-04-23 14:50:07 +02:00
Zbigniew Jędrzejewski-Szmek 51327bcc74 sd-path: rename the two functions
I think the two names were both pretty bad. They did not give a proper hint
what the difference between the two functions is, and sd_path_home sounds like
it is somehow related to /home or home directories or whatever, when in fact
both functions return the same set of paths as either a colon-delimited string
or a strv. "_strv" suffix is used by various functions in sd-bus, so let's
reuse that.

Those functions are not public yet, so let's rename.
2020-03-27 20:12:44 +01:00
Christian Göttsche 80e7c84081 tmpfiles: create with correct MAC label on option C
Closes: #10855
2019-11-28 12:18:04 +01:00
Zbigniew Jędrzejewski-Szmek 9e9dd3e329
Merge pull request #13862 from zachsmith/systemd-tmpfiles-deprecate-for-force
systemd-tmpfiles: deprecate F for f+
2019-11-12 10:28:59 +01:00
Yu Watanabe 1405cb653a tree-wide: drop stdio.h when stdio-util.h is included 2019-11-04 00:30:32 +09:00
Yu Watanabe e30e8b5073 tree-wide: drop stat.h or statfs.h when stat-util.h is included 2019-11-04 00:30:32 +09:00
Yu Watanabe 99e0d09731 tree-wide: drop glob.h when glob-util.h is included 2019-11-04 00:30:32 +09:00
Yu Watanabe 455fa9610c tree-wide: drop string.h when string-util.h or friends are included 2019-11-04 00:30:32 +09:00