summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-02-21 06:41:01 +0900
committerGitHub <noreply@github.com>2023-02-21 06:41:01 +0900
commite814f8b24661ef89cd84fb4c3f64f5be2d53061e (patch)
treee1c9816d560c6c6346688a11b431ef4aea0fe2e3
parent53b3512f9c3f0b6c91820f5a33ce32a821a0c751 (diff)
parentbeca6b6e6b64cebfe9fc2c89117f6abd3c1b5701 (diff)
downloadsystemd-e814f8b24661ef89cd84fb4c3f64f5be2d53061e.tar.gz
Merge pull request #26506 from keszybz/tiny-cleanups
Various trivial cleanups and follow-ups
-rw-r--r--TODO7
-rw-r--r--man/tmpfiles.d.xml16
-rw-r--r--src/basic/constants.h3
-rw-r--r--src/boot/efi/measure.c4
-rw-r--r--src/boot/measure.c30
-rw-r--r--src/shared/hwdb-util.c5
-rw-r--r--src/sleep/sleep.c3
7 files changed, 38 insertions, 30 deletions
diff --git a/TODO b/TODO
index 34c4f87410..9186fb8f52 100644
--- a/TODO
+++ b/TODO
@@ -522,10 +522,6 @@ Features:
would just use the same public key specified with --public-key= (or the one
automatically derived from --private-key=).
-* tmpfiles: add new line type for setting btrfs subvolume attributes (i.e. rw/ro)
-
-* tmpfiles: add new line type for setting fcaps
-
* push people to use ".sysext.raw" as suffix for sysext DDIs (DDI =
discoverable disk images, i.e. the new name for gpt disk images following the
discoverable disk spec). [Also: just ".sysext/" for directory-based sysext]
@@ -2328,6 +2324,7 @@ Features:
* tmpfiles:
- apply "x" on "D" too (see patch from William Douglas)
+ - allow time-based cleanup in r and R too
- instead of ignoring unknown fields, reject them.
- creating new directories/subvolumes/fifos/device nodes
should not follow symlinks. None of the other adjustment or creation
@@ -2336,6 +2333,8 @@ Features:
- teach tmpfiles.d q/Q logic something sensible in the context of XFS/ext4
project quota
- teach tmpfiles.d m/M to move / atomic move + symlink old -> new
+ - add new line type for setting btrfs subvolume attributes (i.e. rw/ro)
+ - tmpfiles: add new line type for setting fcaps
* udev-link-config:
- Make sure ID_PATH is always exported and complete for
diff --git a/man/tmpfiles.d.xml b/man/tmpfiles.d.xml
index 11a61808d6..b50423dc77 100644
--- a/man/tmpfiles.d.xml
+++ b/man/tmpfiles.d.xml
@@ -43,9 +43,9 @@ f /file/to/create mode user group - conte
f+ /file/to/create-or-truncate mode user group - content
w /file/to/write-to - - - - content
w+ /file/to/append-to - - - - content
-d /directory/to/create-and-cleanup mode user group cleanup-age -
+d /directory/to/create-and-clean-up mode user group cleanup-age -
D /directory/to/create-and-remove mode user group cleanup-age -
-e /directory/to/cleanup mode user group cleanup-age -
+e /directory/to/clean-up mode user group cleanup-age -
v /subvolume-or-directory/to/create mode user group cleanup-age -
q /subvolume-or-directory/to/create mode user group cleanup-age -
Q /subvolume-or-directory/to/create mode user group cleanup-age -
@@ -60,8 +60,8 @@ b+ /dev/block-device-to-[re]create mode user group - major
C /target/to/create - - - cleanup-age /source/to/copy
x /path-or-glob/to/ignore/recursively - - - cleanup-age -
X /path-or-glob/to/ignore - - - cleanup-age -
-r /empty/dir/to/remove - - - - -
-R /dir/to/remove/recursively - - - - -
+r /path-or-glob/to/remove - - - - -
+R /path-or-glob/to/remove/recursively - - - - -
z /path-or-glob/to/adjust/mode mode user group - -
Z /path-or-glob/to/adjust/mode/recursively mode user group - -
t /path-or-glob/to/set/xattrs - - - - xattrs
@@ -192,7 +192,7 @@ L /tmp/foobar - - - - /dev/null</programlisting>
<varlistentry>
<term><varname>d</varname></term>
<listitem><para>Create a directory. The mode and ownership will be adjusted if specified. Contents
- of this directory are subject to time based cleanup if the age argument is specified.
+ of this directory are subject to time-based cleanup if the age argument is specified.
</para></listitem>
</varlistentry>
@@ -207,7 +207,7 @@ L /tmp/foobar - - - - /dev/null</programlisting>
<listitem><para>Adjust the mode and ownership of existing directories and remove their contents
based on age.
Lines of this type accept shell-style globs in place of normal path names. Contents of the
- directories are subject to time based cleanup if the age argument is specified. If the age argument
+ directories are subject to time-based cleanup if the age argument is specified. If the age argument
is <literal>0</literal>, contents will be unconditionally deleted every time
<command>systemd-tmpfiles --clean</command> is run.</para>
@@ -334,7 +334,7 @@ L /tmp/foobar - - - - /dev/null</programlisting>
skipped. If the argument is omitted, files from the source directory
<filename>/usr/share/factory/</filename> with the same name
are copied. Does not follow symlinks. Contents of the directories
- are subject to time based cleanup if the age argument is specified.
+ are subject to time-based cleanup if the age argument is specified.
</para></listitem>
</varlistentry>
@@ -781,7 +781,7 @@ t /run/cups - - - - security.SMACK64=printing user.attr-with-spaces="foo bar"
</programlisting>
<para>The directory will be owned by root and have default mode. Its contents are
- not subject to time based cleanup, but will be obliterated when
+ not subject to time-based cleanup, but will be obliterated when
<command>systemd-tmpfiles --remove</command> runs.</para>
</example>
diff --git a/src/basic/constants.h b/src/basic/constants.h
index 5d68cc6332..3e935f1bca 100644
--- a/src/basic/constants.h
+++ b/src/basic/constants.h
@@ -42,6 +42,9 @@
#define DEFAULT_START_LIMIT_INTERVAL (10*USEC_PER_SEC)
#define DEFAULT_START_LIMIT_BURST 5
+/* Wait for 1.5 seconds at maximum for freeze operation */
+#define FREEZE_TIMEOUT (1500 * USEC_PER_MSEC)
+
/* The default time after which exit-on-idle services exit. This
* should be kept lower than the watchdog timeout, because otherwise
* the watchdog pings will keep the loop busy. */
diff --git a/src/boot/efi/measure.c b/src/boot/efi/measure.c
index 949e26350c..2f9b2b9e9d 100644
--- a/src/boot/efi/measure.c
+++ b/src/boot/efi/measure.c
@@ -78,7 +78,7 @@ static EFI_STATUS tpm2_measure_to_pcr_and_event_log(
tcg_event);
}
-static EFI_TCG *tcg1_interface_check(void) {
+static EFI_TCG* tcg1_interface_check(void) {
EFI_PHYSICAL_ADDRESS event_log_location, event_log_last_entry;
TCG_BOOT_SERVICE_CAPABILITY capability = {
.Size = sizeof(capability),
@@ -109,7 +109,7 @@ static EFI_TCG *tcg1_interface_check(void) {
return tcg;
}
-static EFI_TCG2 * tcg2_interface_check(void) {
+static EFI_TCG2* tcg2_interface_check(void) {
EFI_TCG2_BOOT_SERVICE_CAPABILITY capability = {
.Size = sizeof(capability),
};
diff --git a/src/boot/measure.c b/src/boot/measure.c
index f2fbd9d2c1..18838686a9 100644
--- a/src/boot/measure.c
+++ b/src/boot/measure.c
@@ -286,7 +286,8 @@ static int parse_argv(int argc, char *argv[]) {
if (arg_current)
for (UnifiedSection us = 0; us < _UNIFIED_SECTION_MAX; us++)
if (arg_sections[us])
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "The --current switch cannot be used in combination with --linux= and related switches.");
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "The --current switch cannot be used in combination with --linux= and related switches.");
if (strv_isempty(arg_phase)) {
/* If no phases are specifically selected, pick everything from the beginning of the initrd
@@ -448,7 +449,8 @@ static int measure_kernel(PcrState *pcr_states, size_t n) {
return log_oom();
if (EVP_DigestInit_ex(mdctx[i], pcr_states[i].md, NULL) != 1)
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to initialize data %s context.", pcr_states[i].bank);
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Failed to initialize data %s context.", pcr_states[i].bank);
}
for (;;) {
@@ -630,13 +632,14 @@ static void pcr_states_restore(PcrState *pcr_states, size_t n) {
static int verb_calculate(int argc, char *argv[], void *userdata) {
_cleanup_(json_variant_unrefp) JsonVariant *w = NULL;
_cleanup_(pcr_state_free_all) PcrState *pcr_states = NULL;
- size_t n;
int r;
if (!arg_sections[UNIFIED_SECTION_LINUX] && !arg_current)
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Either --linux= or --current must be specified, refusing.");
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Either --linux= or --current must be specified, refusing.");
if (arg_append)
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "The --append= switch is only supported for 'sign', not 'calculate'.");
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "The --append= switch is only supported for 'sign', not 'calculate'.");
assert(!strv_isempty(arg_banks));
assert(!strv_isempty(arg_phase));
@@ -645,7 +648,7 @@ static int verb_calculate(int argc, char *argv[], void *userdata) {
if (r < 0)
return r;
- n = (size_t) r;
+ size_t n = r;
r = measure_kernel(pcr_states, n);
if (r < 0)
@@ -732,10 +735,12 @@ static int verb_sign(int argc, char *argv[], void *userdata) {
int r;
if (!arg_sections[UNIFIED_SECTION_LINUX] && !arg_current)
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Either --linux= or --current must be specified, refusing.");
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Either --linux= or --current must be specified, refusing.");
if (!arg_private_key)
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "No private key specified, use --private-key=.");
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "No private key specified, use --private-key=.");
assert(!strv_isempty(arg_banks));
assert(!strv_isempty(arg_phase));
@@ -746,7 +751,8 @@ static int verb_sign(int argc, char *argv[], void *userdata) {
return log_error_errno(r, "Failed to parse '%s': %m", arg_append);
if (!json_variant_is_object(v))
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "File '%s' is not a valid JSON object, refusing.", arg_append);
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "File '%s' is not a valid JSON object, refusing.", arg_append);
}
/* When signing we only support JSON output */
@@ -782,13 +788,15 @@ static int verb_sign(int argc, char *argv[], void *userdata) {
return log_oom();
if (i2d_PUBKEY_fp(tf, privkey) != 1)
- return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to extract public key from private key file '%s'.", arg_private_key);
+ return log_error_errno(SYNTHETIC_ERRNO(EIO),
+ "Failed to extract public key from private key file '%s'.", arg_private_key);
fflush(tf);
rewind(tf);
if (!d2i_PUBKEY_fp(tf, &pubkey))
- return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to parse extracted public key of private key file '%s'.", arg_private_key);
+ return log_error_errno(SYNTHETIC_ERRNO(EIO),
+ "Failed to parse extracted public key of private key file '%s'.", arg_private_key);
}
r = pcr_states_allocate(&pcr_states);
diff --git a/src/shared/hwdb-util.c b/src/shared/hwdb-util.c
index 0ff686d24b..45910a36e3 100644
--- a/src/shared/hwdb-util.c
+++ b/src/shared/hwdb-util.c
@@ -21,8 +21,7 @@
#include "strv.h"
#include "tmpfile-util.h"
-static const char *default_hwdb_bin_dir = "/etc/udev";
-static const char * const conf_file_dirs[] = {
+static const char* const conf_file_dirs[] = {
"/etc/udev/hwdb.d",
UDEVLIBEXECDIR "/hwdb.d",
NULL
@@ -634,7 +633,7 @@ int hwdb_update(const char *root, const char *hwdb_bin_dir, bool strict, bool co
log_debug("strings dedup'ed: %8zu bytes (%8zu)",
trie->strings->dedup_len, trie->strings->dedup_count);
- hwdb_bin = path_join(root, hwdb_bin_dir ?: default_hwdb_bin_dir, "hwdb.bin");
+ hwdb_bin = path_join(root, hwdb_bin_dir ?: "/etc/udev", "hwdb.bin");
if (!hwdb_bin)
return -ENOMEM;
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c
index 9c51a3367f..9018188cba 100644
--- a/src/sleep/sleep.c
+++ b/src/sleep/sleep.c
@@ -382,8 +382,7 @@ static int freeze_thaw_user_slice(const char **method) {
if (r < 0)
return log_debug_errno(r, "Failed to open connection to systemd: %m");
- /* Wait for 1.5 seconds at maximum for freeze operation */
- (void) sd_bus_set_method_call_timeout(bus, 1500 * USEC_PER_MSEC);
+ (void) sd_bus_set_method_call_timeout(bus, FREEZE_TIMEOUT);
r = bus_call_method(bus, bus_systemd_mgr, *method, &error, NULL, "s", SPECIAL_USER_SLICE);
if (r < 0)