1
0
mirror of https://github.com/systemd/systemd synced 2025-11-21 17:54:46 +01:00

Compare commits

..

29 Commits

Author SHA1 Message Date
Yu Watanabe
b49bff0da7
shared/bootspec: don't warn for new loader.conf options and correctly parse new uki and profile boot entry options (#39165)
Commit e2a3d562189c413de3262ec47cdc1e1b0b13d78b added the `uki` option
to sd-boot, and 1e9c9773b994f2f703a5aa5ba80961e90be3a892 added
`profile`, but because these were not added in src/shared/bootspec,
bootctl still shows warnings like `Unknown line 'uki', ignoring.` when
parsing the config. This PR allows parsing and displaying them correctly
in `bootctl` output. It also stops it from printing a warning for any of
the new `loader.conf` options (`log-level`, `reboot-on-error`, etc.).
Note that `uki-url` is still not handled as I can't easily test it.
2025-10-04 23:35:54 +02:00
Zbigniew Jędrzejewski-Szmek
60597825ef man/sd-login: minor grammar updates 2025-10-04 23:26:47 +02:00
Zbigniew Jędrzejewski-Szmek
4a3620c55a man: fix advice regarding thread safety of libsystemd
The prohibition to move libsystemd objects between threads was added in
64a7ef8bc06b5dcfcd9f99ea10a43bde75c4370f ('man: be more explicit about thread
safety of sd_journal'). At the time, this was valid, because we were using the
mempool for allocation and it apparently didn't handle access from different
threads. Sadlly, the commit links to a bugzilla entry referenced in the commit
is not publicly visible anymore, so the details are murky. But we stopped using
the mempool in a5d8835c78112206bbf0812dd4cb471f803bfe88 ('mempool: only enable
mempool use when linked to libsystemd-shared.so'), with subsequent followup in
b01f31954f1c7c4601925173ae2638b572224e9a ('Turn mempool_enabled() into a weak
symbol'). The restriction added in the man page is not necessary since then.

The text in the man page was arguably incorrect in calling the code
"thread-agnostic". If the code does not support being touched from threads at
all and has global state to tied to the main thread, it is not "agnostic", but
just doesn't support threads.

(I'm looking into https://github.com/systemd/python-systemd/issues/143, and
with the current scheme, the python-systemd module and all python code using
libsystemd would be very hard to use. With the change to free-threaded python
in python3.13, i.e. the replacement of single Global Interpreter Lock by
locking on individual objects, this limitation would become even more
constraining.)
2025-10-04 23:26:47 +02:00
Yu Watanabe
5fc94cc6d9
Use string tables to parse option arguments (#39173) 2025-10-04 23:16:12 +02:00
val4oss
b8efd65975 TEST-74-AUX-UTILS: use sshd_config.d
* From the TEST-74-AUX-UTILS.ssh.sh writing directly into
  /etc/ssh/sshd_config can hide config from distro using /usr/etc.
* Using directory configuration /etc/ssh/sshd_config.d/* suits for all
  cases.

Signed-off-by: val4oss <val4oss@pm.me>
2025-10-04 23:00:31 +02:00
Yu Watanabe
273cb33b61 man: fix typo
Follow-up for 91214a37ef4eb8042d2598aa89bae52b410d11a7.
Fixes #39203.
2025-10-05 05:45:21 +09:00
Yu Watanabe
9ce3ef1304
meson: add man and html targets (#39207) 2025-10-04 22:41:58 +02:00
Oğuz Ersen
5fd9939789 po: Translated using Weblate (Turkish)
Currently translated at 100.0% (264 of 264 strings)

Co-authored-by: Oğuz Ersen <oguz@ersen.moe>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/tr/
Translation: systemd/main
2025-10-04 22:39:07 +02:00
Zbigniew Jędrzejewski-Szmek
1e737d44d1 meson: add target aliases 'man' and 'html'
Previously we would need to say 'ninja -C build man/man man/html', now
just 'ninja -C build man html'.
2025-10-04 18:13:27 +02:00
Zbigniew Jędrzejewski-Szmek
29832663dc meson: drop remaining target names
Most of those were dropped in 7d247d3cb875e1778e6cc81dbf255b13092b29e0. I left
behind the few cases where the 'output' name was different from the target name.
But we actually don't need those either, so get rid of those. (And one case
where I missed the name argument.)

No functional change, except that e.g. 'ninja -C build update-man-rules-impl'
doesn't work, but I hope nobody was using that.
2025-10-04 18:13:27 +02:00
Zbigniew Jędrzejewski-Szmek
675bfef837 Stop specifying license for generated file, instead mark as generated
I exclude generated files from license check, and I noticed
that this file was marked with a license header, which doesn't
make much sense, it is not copyrightable.
2025-10-04 18:13:27 +02:00
David Tardon
188049d38c tree-wide: combine DUMP_STRING_TABLE() and return 2025-10-02 16:19:03 +02:00
David Tardon
365399c4e4 nspawn: inline handle_arg_console() to its only call place 2025-10-02 16:19:03 +02:00
David Tardon
65c4347d6e nspawn: set arguments directly
There's no point in going through handle_arg_console() now that all the
checks have been moved out of it.
2025-10-02 16:19:03 +02:00
David Tardon
99df84ef23 nspawn: postpone selection of console mode
Moving it away from argument parsing code allows to simplify that.
2025-10-02 16:19:03 +02:00
David Tardon
25f1473c81 nspawn: use table to parse --console= 2025-10-02 16:18:41 +02:00
David Tardon
1da7dcf427 main: extract common code to a function 2025-10-02 16:13:40 +02:00
David Tardon
f29f6b6b7d userdbctl: use table to parse --output= 2025-10-02 16:13:40 +02:00
David Tardon
a5fada5d5d userdbctl: require value for --output=
Currently, when --output= is used with empty string, it resets the mode.
E.g.,

 # userdbctl user --output=json --output= ...

will use the default output mode, not JSON. But that functionality is
not documented and it seems to be of little practical use. Let's just
drop it.
2025-10-02 16:13:40 +02:00
David Tardon
292928e964 vpick-tool: use table to parse --print= 2025-10-02 16:13:40 +02:00
David Tardon
9033f923f9 homectl: use table to parse --export-format= 2025-10-02 16:13:40 +02:00
David Tardon
9b3041d9fe cgtop: rename enum value to match its string repr. 2025-10-02 16:13:20 +02:00
David Tardon
048d813fcd cgtop: use table to parse --cpu= 2025-10-01 16:16:58 +02:00
David Tardon
3a21f6aa6e cgtop: use table to parse --order= 2025-10-01 16:16:47 +02:00
Felix Pehla
0b89d8cfec shared/bootspec: update valid loader.conf options 2025-09-29 23:46:59 +02:00
Felix Pehla
aaa3e6880d shared/bootspec: parse loader.conf options added in v258 2025-09-29 23:14:11 +02:00
Felix Pehla
5fb90fa319 shared/bootspec: parse 'profile' boot entry option
Commit 1e9c9773b994f2f703a5aa5ba80961e90be3a892 makes sd-boot recognize
a 'profile' option in a boot loader entry but bootctl and other
components parsing said config do not know about it.

This commit makes the option get parsed correctly and displays it too.
2025-09-29 23:01:12 +02:00
Felix Pehla
4a94a1b83f shared/bootspec: parse 'uki' boot entry option
Commit e2a3d562189c413de3262ec47cdc1e1b0b13d78b (as part of #36314)
makes sd-boot recognize a 'uki' stanza in a boot loader entry and
uapi-group/specifications@3f2bd8236d adds
it to the BLS, but bootctl and other components parsing said config do
not know about it, leading to the error message
`Unknown line 'uki', ignoring.` when attempting to parse the same entry.

This commit makes it get parsed the same way that that 'efi' is.
2025-09-29 22:59:49 +02:00
David Tardon
854789543b export: use table to parse --format= 2025-09-29 16:04:12 +02:00
36 changed files with 300 additions and 294 deletions

View File

@ -166,7 +166,7 @@
command line or <filename>/etc/fstab</filename>, or otherwise configured. If true, full state-less boot mode
is selected. In this case, the root directory is mounted as volatile memory file system (<literal>tmpfs</literal>),
and only <filename>/usr/</filename> is mounted from the file system configured as root device, in read-only mode.
This enables fully state-less boots were the vendor-supplied OS is used as shipped, with only default
This enables fully state-less boots where the vendor-supplied OS is used as shipped, with only default
configuration and no stored state in effect, as <filename>/etc/</filename> and <filename>/var/</filename> (as
well as all other resources shipped in the root file system) are reset at boot and lost on shutdown. If this
setting is set to <literal>state</literal> the root file system is mounted read-only, however

View File

@ -217,7 +217,6 @@ configure_file(
############################################################
update_dbus_docs = custom_target(
'update-dbus-docs-impl',
output : 'update-dbus-docs',
command : [update_dbus_docs_py, '--build-dir', meson.project_build_root(), '@INPUT@'],
input : dbus_docs,
@ -237,7 +236,6 @@ if conf.get('BUILD_MODE_DEVELOPER') == 1
endif
update_man_rules = custom_target(
'update-man-rules-impl',
output : 'update-man-rules',
command : [update_man_rules_py,
'@0@/man/*.xml'.format(meson.project_source_root()),

1
man/rules/.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
meson.build generated

View File

@ -1,5 +1,3 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
# Do not edit. Generated by update-man-rules.py.
# Update with:
# ninja -C build update-man-rules

View File

@ -75,13 +75,14 @@
<refsect1>
<title>Thread safety</title>
<para>Functions that operate on <structname>sd_journal</structname> objects are thread agnostic — given
<structname>sd_journal</structname> pointer may only be used from one specific thread at all times (and it has to
be the very same one during the entire lifetime of the object), but multiple, independent threads may use multiple,
independent objects safely. Other functions — those that are used to send entries to the journal, like
<citerefentry><refentrytitle>sd_journal_print</refentrytitle><manvolnum>3</manvolnum></citerefentry> and similar,
or those that are used to retrieve global information like
<citerefentry><refentrytitle>sd_journal_stream_fd</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
<para>Functions that operate on <structname>sd_journal</structname> objects are thread agnostic — a given
<structname>sd_journal</structname> pointer may only be used from one thread at a time, but multiple
independent threads may use multiple objects concurrently. Some functions — those that are used to send
entries to the journal, like
<citerefentry><refentrytitle>sd_journal_print</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
similar, or those that are used to retrieve global information like
<citerefentry><refentrytitle>sd_journal_stream_fd</refentrytitle><manvolnum>3</manvolnum></citerefentry>
and
<citerefentry><refentrytitle>sd_journal_get_catalog_for_message_id</refentrytitle><manvolnum>3</manvolnum></citerefentry>
— are fully thread-safe and may be called from multiple threads in parallel.</para>
</refsect1>

View File

@ -41,10 +41,10 @@
system.</para>
<para>Note that these APIs only allow purely passive access and
monitoring of seats, sessions and users. To actively make changes
monitoring of seats, sessions, and users. To actively make changes
to the seat configuration, terminate login sessions, or switch
session on a seat you need to utilize the D-Bus API of
systemd-logind, instead.</para>
systemd-logind instead.</para>
<para>These functions synchronously access data in
<filename>/proc/</filename>, <filename>/sys/fs/cgroup/</filename>
@ -62,7 +62,7 @@
other.</para>
<para>If the functions return string arrays, these are generally
<constant>NULL</constant> terminated and need to be freed by the
<constant>NULL</constant>-terminated and need to be freed by the
caller with the libc
<citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
call after use, including the strings referenced therein.

View File

@ -84,14 +84,12 @@
<refsect1>
<title>Notes</title>
<para>Function <function>sd_journal_get_catalog()</function> is thread-agnostic and only
a single specific thread may operate on a given object during its entire lifetime. It is safe to allocate multiple
independent objects and use each from a specific thread in parallel. However, it is not safe to allocate such an
object in one thread, and operate or free it from any other, even if locking is used to ensure these threads do not
operate on it at the very same time.</para>
<para>Function <function>sd_journal_get_catalog()</function> is thread-agnostic and only a single thread
may operate on a given object at any given time. Multiple independent objects may be used from different
threads in parallel.</para>
<para>Function <function>sd_journal_get_catalog_for_message_id()</function> is are thread-safe and may be called in
parallel from multiple threads.</para>
<para>Function <function>sd_journal_get_catalog_for_message_id()</function> is thread-safe and may be
called from multiple threads in parallel.</para>
<xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
</refsect1>

View File

@ -6,10 +6,9 @@
<refsect1>
<title/>
<para id="strict">All functions listed here are thread-agnostic and only a single specific thread may operate on a
given object during its entire lifetime. It is safe to allocate multiple independent objects and use each from a
specific thread in parallel. However, it is not safe to allocate such an object in one thread, and operate or free it
from any other, even if locking is used to ensure these threads do not operate on it at the very same time.</para>
<para id="strict">All functions listed here are thread-agnostic and only a single thread may operate on a
given object at any given time. Different threads may access the same object at different times. Multiple
independent objects may be used from different threads in parallel.</para>
<para id="safe">All functions listed here are thread-safe and may be called in parallel from multiple threads.</para>

View File

@ -2743,11 +2743,11 @@ foreach executable : ['systemd-journal-remote', 'systemd-sbsign', 'systemd-keyut
endforeach
if mkosi.found()
custom_target('mkosi',
custom_target(
build_always_stale : true,
build_by_default: false,
console : true,
output : '.',
output : 'mkosi',
command : [
mkosi,
'--directory', meson.current_source_dir(),
@ -2940,6 +2940,8 @@ run_target(
libsystemd.full_path(),
libudev.full_path()])
alias_target('man', man)
alias_target('html', html)
alias_target('update-dbus-docs', update_dbus_docs)
alias_target('update-man-rules', update_man_rules)

View File

@ -5,14 +5,14 @@
# Gökhan Gurbetoğlu <ggurbet@gmail.com>, 2015.
# Oğuz Ersen <oguzersen@protonmail.com>, 2020.
# Muhammet Kara <muhammetk@gmail.com>, 2015-2020.
# Oğuz Ersen <oguz@ersen.moe>, 2022, 2023, 2024.
# Oğuz Ersen <oguz@ersen.moe>, 2022, 2023, 2024, 2025.
# Emir SARI <emir_sari@icloud.com>, 2025.
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-07-23 15:38+0100\n"
"PO-Revision-Date: 2025-07-29 19:53+0000\n"
"Last-Translator: Emir SARI <emir_sari@icloud.com>\n"
"PO-Revision-Date: 2025-10-04 19:48+0000\n"
"Last-Translator: Oğuz Ersen <oguz@ersen.moe>\n"
"Language-Team: Turkish <https://translate.fedoraproject.org/projects/systemd/"
"main/tr/>\n"
"Language: tr\n"
@ -20,7 +20,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Weblate 5.12.2\n"
"X-Generator: Weblate 5.13.3\n"
#: src/core/org.freedesktop.systemd1.policy.in:22
msgid "Send passphrase back to system"
@ -928,19 +928,14 @@ msgstr ""
"gereklidir."
#: src/machine/org.freedesktop.machine1.policy:106
#, fuzzy
#| msgid "Create a local virtual machine or container"
msgid "Register a local virtual machine or container"
msgstr "Yerel sanal makine veya kapsayıcı oluştur"
msgstr "Yerel sanal makine veya kapsayıcı kaydet"
#: src/machine/org.freedesktop.machine1.policy:107
#, fuzzy
#| msgid ""
#| "Authentication is required to create a local virtual machine or container."
msgid ""
"Authentication is required to register a local virtual machine or container."
msgstr ""
"Yerel sanal makine veya kapsayıcı oluşturmak için kimlik doğrulaması "
"Yerel sanal makine veya kapsayıcı kaydetmek için kimlik doğrulaması "
"gereklidir."
#: src/machine/org.freedesktop.machine1.policy:116
@ -1181,13 +1176,11 @@ msgstr "Arama sonuçlarına abone olmak için kimlik doğrulaması gereklidir."
#: src/resolve/org.freedesktop.resolve1.policy:154
msgid "Subscribe to DNS configuration"
msgstr ""
msgstr "DNS yapılandırmasına abone ol"
#: src/resolve/org.freedesktop.resolve1.policy:155
#, fuzzy
#| msgid "Authentication is required to subscribe query results."
msgid "Authentication is required to subscribe to DNS configuration."
msgstr "Arama sonuçlarına abone olmak için kimlik doğrulaması gereklidir."
msgstr "DNS yapılandırmasına abone olmak için kimlik doğrulaması gereklidir."
#: src/resolve/org.freedesktop.resolve1.policy:165
msgid "Dump cache"
@ -1330,16 +1323,12 @@ msgstr ""
"gereklidir."
#: src/core/dbus-unit.c:620
#, fuzzy
#| msgid ""
#| "Authentication is required to send a UNIX signal to the processes of "
#| "'$(unit)'."
msgid ""
"Authentication is required to send a UNIX signal to the processes of "
"subgroup of '$(unit)'."
msgstr ""
"'$(unit)' süreçlerine bir UNIX sinyali göndermek için kimlik doğrulaması "
"gereklidir."
"'$(unit)' alt gruplarının süreçlerine bir UNIX sinyali göndermek için kimlik "
"doğrulaması gereklidir."
#: src/core/dbus-unit.c:648
msgid "Authentication is required to reset the \"failed\" state of '$(unit)'."

View File

@ -472,10 +472,9 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_RECURSIVE_ERRORS:
if (streq(optarg, "help")) {
DUMP_STRING_TABLE(recursive_errors, RecursiveErrors, _RECURSIVE_ERRORS_MAX);
return 0;
}
if (streq(optarg, "help"))
return DUMP_STRING_TABLE(recursive_errors, RecursiveErrors, _RECURSIVE_ERRORS_MAX);
r = recursive_errors_from_string(optarg);
if (r < 0)
return log_error_errno(r, "Unknown mode passed to --recursive-errors='%s'.", optarg);

View File

@ -1013,6 +1013,8 @@ static void config_defaults_load_from_file(Config *config, char *content) {
assert(config);
assert(content);
/* If you add, remove, or change an option name here, please also update
* shared/bootspec.c@boot_loader_read_conf() to make parsing by bootctl/logind/etc. work. */
while ((line = line_get_key_value(content, " \t", &pos, &key, &value)))
if (streq8(key, "timeout")) {
if (streq8(value, "menu-disabled"))
@ -1291,6 +1293,8 @@ static void boot_entry_add_type1(
.call = call_image_start,
};
/* If you add, remove, or change an option name here, please also update shared/bootspec.c and
* shared/varlink-io.systemd.BootControl to make parsing by bootctl/logind/etc. work. */
while ((line = line_get_key_value(content, " \t", &pos, &key, &value)))
if (streq8(key, "title")) {
free(entry->title);
@ -1299,6 +1303,7 @@ static void boot_entry_add_type1(
} else if (streq8(key, "sort-key")) {
free(entry->sort_key);
entry->sort_key = xstr8_to_16(value);
} else if (streq8(key, "profile")) {
uint64_t u;
if (parse_number8(value, &u, NULL) && u <= UINT_MAX)

View File

@ -732,6 +732,9 @@ static int count_known_files(const BootConfig *config, const char* root, Hashmap
if (r < 0)
return r;
r = ref_file(&known_files, e->efi, +1);
if (r < 0)
return r;
r = ref_file(&known_files, e->uki, +1);
if (r < 0)
return r;
STRV_FOREACH(s, e->initrd) {
@ -792,6 +795,7 @@ static int unlink_entry(const BootConfig *config, const char *root, const char *
deref_unlink_file(&known_files, e->kernel, e->root);
deref_unlink_file(&known_files, e->efi, e->root);
deref_unlink_file(&known_files, e->uki, e->root);
STRV_FOREACH(s, e->initrd)
deref_unlink_file(&known_files, *s, e->root);
deref_unlink_file(&known_files, e->device_tree, e->root);

View File

@ -20,6 +20,7 @@
#include "process-util.h"
#include "procfs-util.h"
#include "sort-util.h"
#include "string-table.h"
#include "terminal-util.h"
#include "time-util.h"
#include "virt.h"
@ -54,6 +55,23 @@ typedef enum PidsCount {
COUNT_PIDS, /* most, requires pids controller */
} PidsCount;
typedef enum {
ORDER_PATH,
ORDER_TASKS,
ORDER_CPU,
ORDER_MEMORY,
ORDER_IO,
_ORDER_MAX,
_ORDER_INVALID = -EINVAL,
} Order;
typedef enum {
CPU_PERCENTAGE,
CPU_TIME,
_CPU_MAX,
_CPU_INVALID = -EINVAL,
} CPUType;
static unsigned arg_depth = 3;
static unsigned arg_iterations = UINT_MAX;
static bool arg_batch = false;
@ -63,21 +81,26 @@ static char* arg_machine = NULL;
static char* arg_root = NULL;
static bool arg_recursive = true;
static bool arg_recursive_unset = false;
static PidsCount arg_count = COUNT_PIDS;
static Order arg_order = ORDER_CPU;
static CPUType arg_cpu_type = CPU_PERCENTAGE;
static enum {
ORDER_PATH,
ORDER_TASKS,
ORDER_CPU,
ORDER_MEMORY,
ORDER_IO,
} arg_order = ORDER_CPU;
static const char *order_table[_ORDER_MAX] = {
[ORDER_PATH] = "path",
[ORDER_TASKS] = "tasks",
[ORDER_CPU] = "cpu",
[ORDER_MEMORY] = "memory",
[ORDER_IO] = "io",
};
static enum {
CPU_PERCENT,
CPU_TIME,
} arg_cpu_type = CPU_PERCENT;
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(order, Order);
static const char *cpu_type_table[_CPU_MAX] = {
[CPU_PERCENTAGE] = "percentage",
[CPU_TIME] = "time",
};
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(cpu_type, CPUType);
static Group *group_free(Group *g) {
if (!g)
@ -507,7 +530,7 @@ static int group_compare(Group * const *a, Group * const *b) {
break;
case ORDER_CPU:
if (arg_cpu_type == CPU_PERCENT) {
if (arg_cpu_type == CPU_PERCENTAGE) {
if (x->cpu_valid && y->cpu_valid) {
r = CMP(y->cpu_fraction, x->cpu_fraction);
if (r != 0)
@ -557,6 +580,12 @@ static int group_compare(Group * const *a, Group * const *b) {
return -1;
else if (y->io_valid)
return 1;
break;
case _ORDER_MAX:
case _ORDER_INVALID:
assert_not_reached();
}
return path_compare(x->path, y->path);
@ -595,7 +624,7 @@ static void display(Hashmap *a) {
if (on_tty()) {
const char *on, *off;
int cpu_len = arg_cpu_type == CPU_PERCENT ? 6 : maxtcpu;
int cpu_len = arg_cpu_type == CPU_PERCENTAGE ? 6 : maxtcpu;
path_columns = columns() - 36 - cpu_len;
if (path_columns < 10)
@ -613,7 +642,7 @@ static void display(Hashmap *a) {
arg_order == ORDER_TASKS ? off : "",
arg_order == ORDER_CPU ? on : "",
cpu_len,
arg_cpu_type == CPU_PERCENT ? "%CPU" : "CPU Time",
arg_cpu_type == CPU_PERCENTAGE ? "%CPU" : "CPU Time",
arg_order == ORDER_CPU ? off : "",
arg_order == ORDER_MEMORY ? on : "", "Memory",
arg_order == ORDER_MEMORY ? off : "",
@ -643,7 +672,7 @@ static void display(Hashmap *a) {
else
fputs(" -", stdout);
if (arg_cpu_type == CPU_PERCENT) {
if (arg_cpu_type == CPU_PERCENTAGE) {
if (g->cpu_valid)
printf(" %6.1f", g->cpu_fraction*100);
else
@ -739,12 +768,9 @@ static int parse_argv(int argc, char *argv[]) {
case ARG_CPU_TYPE:
if (optarg) {
if (streq(optarg, "time"))
arg_cpu_type = CPU_TIME;
else if (streq(optarg, "percentage"))
arg_cpu_type = CPU_PERCENT;
else
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
arg_cpu_type = cpu_type_from_string(optarg);
if (arg_cpu_type < 0)
return log_error_errno(arg_cpu_type,
"Unknown argument to --cpu=: %s",
optarg);
} else
@ -810,18 +836,9 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_ORDER:
if (streq(optarg, "path"))
arg_order = ORDER_PATH;
else if (streq(optarg, "tasks"))
arg_order = ORDER_TASKS;
else if (streq(optarg, "cpu"))
arg_order = ORDER_CPU;
else if (streq(optarg, "memory"))
arg_order = ORDER_MEMORY;
else if (streq(optarg, "io"))
arg_order = ORDER_IO;
else
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
arg_order = order_from_string(optarg);
if (arg_order < 0)
return log_error_errno(arg_order,
"Invalid argument to --order=: %s",
optarg);
break;
@ -959,7 +976,7 @@ static int loop(const char *root) {
break;
case '%':
arg_cpu_type = arg_cpu_type == CPU_TIME ? CPU_PERCENT : CPU_TIME;
arg_cpu_type = arg_cpu_type == CPU_TIME ? CPU_PERCENTAGE : CPU_TIME;
break;
case 'k':

View File

@ -255,6 +255,22 @@ static int console_setup(void) {
return 0;
}
static int parse_timeout(const char *value, usec_t *ret) {
int r = 0;
assert(value);
assert(ret);
if (streq(value, "default"))
*ret = USEC_INFINITY;
else if (streq(value, "off"))
*ret = 0;
else
r = parse_sec(value, ret);
return r;
}
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
int r;
@ -456,16 +472,10 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
if (proc_cmdline_value_missing(key, value))
return 0;
if (streq(value, "default"))
arg_runtime_watchdog = USEC_INFINITY;
else if (streq(value, "off"))
arg_runtime_watchdog = 0;
else {
r = parse_sec(value, &arg_runtime_watchdog);
if (r < 0) {
log_warning_errno(r, "Failed to parse systemd.watchdog_sec= argument '%s', ignoring: %m", value);
return 0;
}
r = parse_timeout(value, &arg_runtime_watchdog);
if (r < 0) {
log_warning_errno(r, "Failed to parse systemd.watchdog_sec= argument '%s', ignoring: %m", value);
return 0;
}
arg_kexec_watchdog = arg_reboot_watchdog = arg_runtime_watchdog;
@ -475,16 +485,10 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
if (proc_cmdline_value_missing(key, value))
return 0;
if (streq(value, "default"))
arg_pretimeout_watchdog = USEC_INFINITY;
else if (streq(value, "off"))
arg_pretimeout_watchdog = 0;
else {
r = parse_sec(value, &arg_pretimeout_watchdog);
if (r < 0) {
log_warning_errno(r, "Failed to parse systemd.watchdog_pre_sec= argument '%s', ignoring: %m", value);
return 0;
}
r = parse_timeout(value, &arg_pretimeout_watchdog);
if (r < 0) {
log_warning_errno(r, "Failed to parse systemd.watchdog_pre_sec= argument '%s', ignoring: %m", value);
return 0;
}
} else if (proc_cmdline_key_streq(key, "systemd.watchdog_pretimeout_governor")) {

View File

@ -109,16 +109,14 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_LIST:
DUMP_STRING_TABLE(virtualization, Virtualization, _VIRTUALIZATION_MAX);
return 0;
return DUMP_STRING_TABLE(virtualization, Virtualization, _VIRTUALIZATION_MAX);
case ARG_CVM:
arg_mode = ONLY_CVM;
return 1;
case ARG_LIST_CVM:
DUMP_STRING_TABLE(confidential_virtualization, ConfidentialVirtualization, _CONFIDENTIAL_VIRTUALIZATION_MAX);
return 0;
return DUMP_STRING_TABLE(confidential_virtualization, ConfidentialVirtualization, _CONFIDENTIAL_VIRTUALIZATION_MAX);
case '?':
return -EINVAL;

View File

@ -56,6 +56,7 @@
#include "rlimit-util.h"
#include "runtime-scope.h"
#include "stat-util.h"
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "terminal-util.h"
@ -69,6 +70,14 @@
#include "userdb.h"
#include "verbs.h"
typedef enum {
EXPORT_FORMAT_FULL, /* export the full record */
EXPORT_FORMAT_STRIPPED, /* strip "state" + "binding", but leave signature in place */
EXPORT_FORMAT_MINIMAL, /* also strip signature */
_EXPORT_FORMAT_MAX,
_EXPORT_FORMAT_INVALID = -EINVAL,
} ExportFormat;
static PagerFlags arg_pager_flags = 0;
static bool arg_legend = true;
static bool arg_ask_password = true;
@ -97,11 +106,7 @@ static bool arg_recovery_key = false;
static sd_json_format_flags_t arg_json_format_flags = SD_JSON_FORMAT_OFF;
static bool arg_and_resize = false;
static bool arg_and_change_password = false;
static enum {
EXPORT_FORMAT_FULL, /* export the full record */
EXPORT_FORMAT_STRIPPED, /* strip "state" + "binding", but leave signature in place */
EXPORT_FORMAT_MINIMAL, /* also strip signature */
} arg_export_format = EXPORT_FORMAT_FULL;
static ExportFormat arg_export_format = EXPORT_FORMAT_FULL;
static uint64_t arg_capability_bounding_set = UINT64_MAX;
static uint64_t arg_capability_ambient_set = UINT64_MAX;
static char *arg_blob_dir = NULL;
@ -131,6 +136,14 @@ STATIC_DESTRUCTOR_REGISTER(arg_key_name, freep);
static const BusLocator *bus_mgr;
static const char *export_format_table[_EXPORT_FORMAT_MAX] = {
[EXPORT_FORMAT_FULL] = "full",
[EXPORT_FORMAT_STRIPPED] = "stripped",
[EXPORT_FORMAT_MINIMAL] = "minimal",
};
DEFINE_PRIVATE_STRING_TABLE_LOOKUP(export_format, ExportFormat);
static bool identity_properties_specified(void) {
return
arg_identity ||
@ -4732,18 +4745,12 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_EXPORT_FORMAT:
if (streq(optarg, "full"))
arg_export_format = EXPORT_FORMAT_FULL;
else if (streq(optarg, "stripped"))
arg_export_format = EXPORT_FORMAT_STRIPPED;
else if (streq(optarg, "minimal"))
arg_export_format = EXPORT_FORMAT_MINIMAL;
else if (streq(optarg, "help")) {
puts("full\n"
"stripped\n"
"minimal");
return 0;
}
if (streq(optarg, "help"))
return DUMP_STRING_TABLE(export_format, ExportFormat, _EXPORT_FORMAT_MAX);
arg_export_format = export_format_from_string(optarg);
if (arg_export_format < 0)
return log_error_errno(arg_export_format, "Invalid export format: %s", optarg);
break;

View File

@ -249,17 +249,8 @@ static int parse_argv(int argc, char *argv[]) {
return version();
case ARG_FORMAT:
if (streq(optarg, "uncompressed"))
arg_compress = IMPORT_COMPRESS_UNCOMPRESSED;
else if (streq(optarg, "xz"))
arg_compress = IMPORT_COMPRESS_XZ;
else if (streq(optarg, "gzip"))
arg_compress = IMPORT_COMPRESS_GZIP;
else if (streq(optarg, "bzip2"))
arg_compress = IMPORT_COMPRESS_BZIP2;
else if (streq(optarg, "zstd"))
arg_compress = IMPORT_COMPRESS_ZSTD;
else
arg_compress = import_compress_type_from_string(optarg);
if (arg_compress < 0 || arg_compress == IMPORT_COMPRESS_UNKNOWN)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Unknown format: %s", optarg);
break;

View File

@ -1127,10 +1127,8 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_VERIFY:
if (streq(optarg, "help")) {
DUMP_STRING_TABLE(import_verify, ImportVerify, _IMPORT_VERIFY_MAX);
return 0;
}
if (streq(optarg, "help"))
return DUMP_STRING_TABLE(import_verify, ImportVerify, _IMPORT_VERIFY_MAX);
r = import_verify_from_string(optarg);
if (r < 0)

View File

@ -476,10 +476,8 @@ static int parse_argv(int argc, char *argv[]) {
break;
case 'o':
if (streq(optarg, "help")) {
DUMP_STRING_TABLE(output_mode, OutputMode, _OUTPUT_MODE_MAX);
return 0;
}
if (streq(optarg, "help"))
return DUMP_STRING_TABLE(output_mode, OutputMode, _OUTPUT_MODE_MAX);
arg_output = output_mode_from_string(optarg);
if (arg_output < 0)

View File

@ -1600,10 +1600,8 @@ static int parse_argv(int argc, char *argv[]) {
break;
case 'o':
if (streq(optarg, "help")) {
DUMP_STRING_TABLE(output_mode, OutputMode, _OUTPUT_MODE_MAX);
return 0;
}
if (streq(optarg, "help"))
return DUMP_STRING_TABLE(output_mode, OutputMode, _OUTPUT_MODE_MAX);
arg_output = output_mode_from_string(optarg);
if (arg_output < 0)

View File

@ -2295,10 +2295,8 @@ static int parse_argv(int argc, char *argv[]) {
break;
case 'o':
if (streq(optarg, "help")) {
DUMP_STRING_TABLE(output_mode, OutputMode, _OUTPUT_MODE_MAX);
return 0;
}
if (streq(optarg, "help"))
return DUMP_STRING_TABLE(output_mode, OutputMode, _OUTPUT_MODE_MAX);
r = output_mode_from_string(optarg);
if (r < 0)
@ -2354,10 +2352,8 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_VERIFY:
if (streq(optarg, "help")) {
DUMP_STRING_TABLE(import_verify, ImportVerify, _IMPORT_VERIFY_MAX);
return 0;
}
if (streq(optarg, "help"))
return DUMP_STRING_TABLE(import_verify, ImportVerify, _IMPORT_VERIFY_MAX);
r = import_verify_from_string(optarg);
if (r < 0)

View File

@ -914,6 +914,16 @@ static const char *const timezone_mode_table[_TIMEZONE_MODE_MAX] = {
DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(timezone_mode, TimezoneMode, TIMEZONE_AUTO);
static const char *const console_mode_table[_CONSOLE_MODE_MAX] = {
[CONSOLE_AUTOPIPE] = "autopipe",
[CONSOLE_INTERACTIVE] = "interactive",
[CONSOLE_READ_ONLY] = "read-only",
[CONSOLE_PASSIVE] = "passive",
[CONSOLE_PIPE] = "pipe",
};
DEFINE_STRING_TABLE_LOOKUP(console_mode, ConsoleMode);
DEFINE_CONFIG_PARSE_ENUM(config_parse_userns_ownership, user_namespace_ownership, UserNamespaceOwnership);
static const char *const user_namespace_ownership_table[_USER_NAMESPACE_OWNERSHIP_MAX] = {

View File

@ -82,6 +82,7 @@ typedef enum TimezoneMode {
} TimezoneMode;
typedef enum ConsoleMode {
CONSOLE_AUTOPIPE,
CONSOLE_INTERACTIVE,
CONSOLE_READ_ONLY,
CONSOLE_PASSIVE,
@ -282,6 +283,9 @@ ResolvConfMode resolv_conf_mode_from_string(const char *s) _pure_;
const char* timezone_mode_to_string(TimezoneMode a) _const_;
TimezoneMode timezone_mode_from_string(const char *s) _pure_;
const char* console_mode_to_string(ConsoleMode m) _const_;
ConsoleMode console_mode_from_string(const char *s) _pure_;
const char* user_namespace_ownership_to_string(UserNamespaceOwnership a) _const_;
UserNamespaceOwnership user_namespace_ownership_from_string(const char *s) _pure_;

View File

@ -286,42 +286,6 @@ STATIC_DESTRUCTOR_REGISTER(arg_settings_filename, freep);
STATIC_DESTRUCTOR_REGISTER(arg_image_policy, image_policy_freep);
STATIC_DESTRUCTOR_REGISTER(arg_background, freep);
static int handle_arg_console(const char *arg) {
if (streq(arg, "help")) {
puts("autopipe\n"
"interactive\n"
"passive\n"
"pipe\n"
"read-only");
return 0;
}
if (streq(arg, "interactive"))
arg_console_mode = CONSOLE_INTERACTIVE;
else if (streq(arg, "read-only"))
arg_console_mode = CONSOLE_READ_ONLY;
else if (streq(arg, "passive"))
arg_console_mode = CONSOLE_PASSIVE;
else if (streq(arg, "pipe")) {
if (isatty_safe(STDIN_FILENO) && isatty_safe(STDOUT_FILENO))
log_full(arg_quiet ? LOG_DEBUG : LOG_NOTICE,
"Console mode 'pipe' selected, but standard input/output are connected to an interactive TTY. "
"Most likely you want to use 'interactive' console mode for proper interactivity and shell job control. "
"Proceeding anyway.");
arg_console_mode = CONSOLE_PIPE;
} else if (streq(arg, "autopipe")) {
if (isatty_safe(STDIN_FILENO) && isatty_safe(STDOUT_FILENO))
arg_console_mode = CONSOLE_INTERACTIVE;
else
arg_console_mode = CONSOLE_PIPE;
} else
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown console mode: %s", optarg);
arg_settings_mask |= SETTING_CONSOLE_MODE;
return 1;
}
static int help(void) {
_cleanup_free_ char *link = NULL;
int r;
@ -1133,10 +1097,9 @@ static int parse_argv(int argc, char *argv[]) {
if (!optarg)
arg_volatile_mode = VOLATILE_YES;
else if (streq(optarg, "help")) {
DUMP_STRING_TABLE(volatile_mode, VolatileMode, _VOLATILE_MODE_MAX);
return 0;
} else {
else if (streq(optarg, "help"))
return DUMP_STRING_TABLE(volatile_mode, VolatileMode, _VOLATILE_MODE_MAX);
else {
VolatileMode m;
m = volatile_mode_from_string(optarg);
@ -1238,10 +1201,8 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_PRIVATE_USERS_OWNERSHIP:
if (streq(optarg, "help")) {
DUMP_STRING_TABLE(user_namespace_ownership, UserNamespaceOwnership, _USER_NAMESPACE_OWNERSHIP_MAX);
return 0;
}
if (streq(optarg, "help"))
return DUMP_STRING_TABLE(user_namespace_ownership, UserNamespaceOwnership, _USER_NAMESPACE_OWNERSHIP_MAX);
arg_userns_ownership = user_namespace_ownership_from_string(optarg);
if (arg_userns_ownership < 0)
@ -1251,10 +1212,8 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_KILL_SIGNAL:
if (streq(optarg, "help")) {
DUMP_STRING_TABLE(signal, int, _NSIG);
return 0;
}
if (streq(optarg, "help"))
return DUMP_STRING_TABLE(signal, int, _NSIG);
arg_kill_signal = signal_from_string(optarg);
if (arg_kill_signal < 0)
@ -1413,10 +1372,8 @@ static int parse_argv(int argc, char *argv[]) {
_cleanup_free_ char *name = NULL;
int rl;
if (streq(optarg, "help")) {
DUMP_STRING_TABLE(rlimit, int, _RLIMIT_MAX);
return 0;
}
if (streq(optarg, "help"))
return DUMP_STRING_TABLE(rlimit, int, _RLIMIT_MAX);
eq = strchr(optarg, '=');
if (!eq)
@ -1467,10 +1424,8 @@ static int parse_argv(int argc, char *argv[]) {
}
case ARG_RESOLV_CONF:
if (streq(optarg, "help")) {
DUMP_STRING_TABLE(resolv_conf_mode, ResolvConfMode, _RESOLV_CONF_MODE_MAX);
return 0;
}
if (streq(optarg, "help"))
return DUMP_STRING_TABLE(resolv_conf_mode, ResolvConfMode, _RESOLV_CONF_MODE_MAX);
arg_resolv_conf = resolv_conf_mode_from_string(optarg);
if (arg_resolv_conf < 0)
@ -1481,10 +1436,8 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_TIMEZONE:
if (streq(optarg, "help")) {
DUMP_STRING_TABLE(timezone_mode, TimezoneMode, _TIMEZONE_MODE_MAX);
return 0;
}
if (streq(optarg, "help"))
return DUMP_STRING_TABLE(timezone_mode, TimezoneMode, _TIMEZONE_MODE_MAX);
arg_timezone = timezone_mode_from_string(optarg);
if (arg_timezone < 0)
@ -1495,16 +1448,21 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_CONSOLE:
r = handle_arg_console(optarg);
if (r <= 0)
return r;
if (streq(optarg, "help"))
return DUMP_STRING_TABLE(console_mode, ConsoleMode, _CONSOLE_MODE_MAX);
arg_console_mode = console_mode_from_string(optarg);
if (arg_console_mode < 0)
return log_error_errno(arg_console_mode, "Unknown console mode: %s", optarg);
arg_settings_mask |= SETTING_CONSOLE_MODE;
break;
case 'P':
case ARG_PIPE:
r = handle_arg_console("pipe");
if (r <= 0)
return r;
arg_console_mode = CONSOLE_PIPE;
arg_settings_mask |= SETTING_CONSOLE_MODE;
break;
case ARG_NO_PAGER:
@ -1738,6 +1696,12 @@ static int verify_arguments(void) {
if (r < 0)
return r;
if (arg_console_mode == CONSOLE_PIPE && isatty_safe(STDIN_FILENO) && isatty_safe(STDOUT_FILENO))
log_full(arg_quiet ? LOG_DEBUG : LOG_NOTICE,
"Console mode 'pipe' selected, but standard input/output are connected to an interactive TTY. "
"Most likely you want to use 'interactive' console mode for proper interactivity and shell job control. "
"Proceeding anyway.");
return 0;
}
@ -5983,6 +5947,13 @@ static int run(int argc, char *argv[]) {
arg_console_mode = isatty_safe(STDIN_FILENO) && isatty_safe(STDOUT_FILENO) ?
CONSOLE_INTERACTIVE : CONSOLE_READ_ONLY;
if (arg_console_mode == CONSOLE_AUTOPIPE) {
if (isatty_safe(STDIN_FILENO) && isatty_safe(STDOUT_FILENO))
arg_console_mode = CONSOLE_INTERACTIVE;
else
arg_console_mode = CONSOLE_PIPE;
}
if (arg_console_mode == CONSOLE_PIPE) /* if we pass STDERR on to the container, don't add our own logs into it too */
arg_quiet = true;

View File

@ -93,6 +93,7 @@ static void boot_entry_free(BootEntry *entry) {
boot_entry_addons_done(&entry->local_addons);
free(entry->kernel);
free(entry->efi);
free(entry->uki);
strv_free(entry->initrd);
free(entry->device_tree);
strv_free(entry->device_tree_overlay);
@ -403,6 +404,10 @@ static int boot_entry_load_type1(
r = parse_path_one(tmp.path, line, field, &tmp.kernel, p);
else if (streq(field, "efi"))
r = parse_path_one(tmp.path, line, field, &tmp.efi, p);
else if (streq(field, "uki"))
r = parse_path_one(tmp.path, line, field, &tmp.uki, p);
else if (streq(field, "profile"))
r = safe_atou_full(p, 10, &tmp.profile);
else if (streq(field, "initrd"))
r = parse_path_strv(tmp.path, line, field, &tmp.initrd, p);
else if (streq(field, "devicetree"))
@ -511,7 +516,8 @@ int boot_loader_read_conf(BootConfig *config, FILE *file, const char *path) {
r = free_and_strdup(&config->default_pattern, p);
else if (STR_IN_SET(field, "timeout", "editor", "auto-entries", "auto-firmware",
"auto-poweroff", "auto-reboot", "beep", "reboot-for-bitlocker",
"secure-boot-enroll", "console-mode"))
"reboot-on-error", "secure-boot-enroll", "secure-boot-enroll-action",
"secure-boot-enroll-timeout-sec", "console-mode", "log-level"))
r = 0; /* we don't parse these in userspace, but they are OK */
else {
log_syntax(NULL, LOG_WARNING, path, line, 0, "Unknown line '%s', ignoring.", field);
@ -1628,6 +1634,7 @@ int boot_config_augment_from_loader(
.reported_by_loader = true,
.tries_left = UINT_MAX,
.tries_done = UINT_MAX,
.profile = UINT_MAX,
.global_addons = &no_addons,
};
}
@ -1896,6 +1903,10 @@ int show_boot_entry(
boot_entry_file_list("linux", e->root, e->kernel, &status);
if (e->efi)
boot_entry_file_list("efi", e->root, e->efi, &status);
if (e->uki)
boot_entry_file_list("uki", e->root, e->uki, &status);
if (e->profile != UINT_MAX)
printf(" profile: %u\n", e->profile);
STRV_FOREACH(s, e->initrd)
boot_entry_file_list(s == e->initrd ? "initrd" : NULL,
@ -1957,9 +1968,9 @@ int boot_entry_to_json(const BootConfig *c, size_t i, sd_json_variant **ret) {
SD_JSON_BUILD_PAIR_CONDITION(!!opts, "options", SD_JSON_BUILD_STRING(opts)),
SD_JSON_BUILD_PAIR_CONDITION(!!e->kernel, "linux", SD_JSON_BUILD_STRING(e->kernel)),
SD_JSON_BUILD_PAIR_CONDITION(!!e->efi, "efi", SD_JSON_BUILD_STRING(e->efi)),
SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(e->initrd), "initrd", SD_JSON_BUILD_STRV(e->initrd)),
SD_JSON_BUILD_PAIR_CONDITION(!!e->device_tree, "devicetree", SD_JSON_BUILD_STRING(e->device_tree)),
SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(e->device_tree_overlay), "devicetreeOverlay", SD_JSON_BUILD_STRV(e->device_tree_overlay)));
SD_JSON_BUILD_PAIR_CONDITION(!!e->uki, "uki", SD_JSON_BUILD_STRING(e->uki)),
SD_JSON_BUILD_PAIR_CONDITION(e->profile != UINT_MAX, "profile", SD_JSON_BUILD_UNSIGNED(e->profile)),
SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(e->initrd), "initrd", SD_JSON_BUILD_STRV(e->initrd)));
if (r < 0)
return log_oom();
@ -1968,6 +1979,8 @@ int boot_entry_to_json(const BootConfig *c, size_t i, sd_json_variant **ret) {
* at once. */
r = sd_json_variant_merge_objectbo(
&v,
SD_JSON_BUILD_PAIR_CONDITION(!!e->device_tree, "devicetree", SD_JSON_BUILD_STRING(e->device_tree)),
SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(e->device_tree_overlay), "devicetreeOverlay", SD_JSON_BUILD_STRV(e->device_tree_overlay)),
SD_JSON_BUILD_PAIR("isReported", SD_JSON_BUILD_BOOLEAN(e->reported_by_loader)),
SD_JSON_BUILD_PAIR_CONDITION(e->tries_left != UINT_MAX, "triesLeft", SD_JSON_BUILD_UNSIGNED(e->tries_left)),
SD_JSON_BUILD_PAIR_CONDITION(e->tries_done != UINT_MAX, "triesDone", SD_JSON_BUILD_UNSIGNED(e->tries_done)),

View File

@ -50,6 +50,7 @@ typedef struct BootEntry {
const BootEntryAddons *global_addons; /* Backpointer into the BootConfig; we don't own this here */
char *kernel; /* linux is #defined to 1, yikes! */
char *efi;
char *uki;
char **initrd;
char *device_tree;
char **device_tree_overlay;
@ -64,6 +65,7 @@ typedef struct BootEntry {
.source = (s), \
.tries_left = UINT_MAX, \
.tries_done = UINT_MAX, \
.profile = UINT_MAX, \
}
typedef struct BootConfig {

View File

@ -110,10 +110,8 @@ int parse_signal_argument(const char *s, int *ret) {
assert(s);
assert(ret);
if (streq(s, "help")) {
DUMP_STRING_TABLE(signal, int, _NSIG);
return 0;
}
if (streq(s, "help"))
return DUMP_STRING_TABLE(signal, int, _NSIG);
if (streq(s, "list")) {
_cleanup_(table_unrefp) Table *table = NULL;

View File

@ -47,6 +47,8 @@ static SD_VARLINK_DEFINE_STRUCT_TYPE(
SD_VARLINK_DEFINE_FIELD(options, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(linux, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(efi, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(uki, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(profile, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(initrd, SD_VARLINK_STRING, SD_VARLINK_NULLABLE|SD_VARLINK_ARRAY),
SD_VARLINK_DEFINE_FIELD(devicetree, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
SD_VARLINK_DEFINE_FIELD(devicetreeOverlay, SD_VARLINK_STRING, SD_VARLINK_NULLABLE|SD_VARLINK_ARRAY),

View File

@ -2581,8 +2581,7 @@ static int parse_argv(int argc, char *argv[]) {
if (arg_legend)
puts("Known mutability modes:");
DUMP_STRING_TABLE(mutable_mode, MutableMode, _MUTABLE_MAX);
return 0;
return DUMP_STRING_TABLE(mutable_mode, MutableMode, _MUTABLE_MAX);
}
r = parse_mutable_mode(optarg);

View File

@ -810,10 +810,8 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
break;
case 'o':
if (streq(optarg, "help")) {
DUMP_STRING_TABLE(output_mode, OutputMode, _OUTPUT_MODE_MAX);
return 0;
}
if (streq(optarg, "help"))
return DUMP_STRING_TABLE(output_mode, OutputMode, _OUTPUT_MODE_MAX);
arg_output = output_mode_from_string(optarg);
if (arg_output < 0)
@ -899,10 +897,8 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
break;
case ARG_PRESET_MODE:
if (streq(optarg, "help")) {
DUMP_STRING_TABLE(unit_file_preset_mode, UnitFilePresetMode, _UNIT_FILE_PRESET_MODE_MAX);
return 0;
}
if (streq(optarg, "help"))
return DUMP_STRING_TABLE(unit_file_preset_mode, UnitFilePresetMode, _UNIT_FILE_PRESET_MODE_MAX);
arg_preset_mode = unit_file_preset_mode_from_string(optarg);
if (arg_preset_mode < 0)
@ -964,10 +960,8 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
break;
case ARG_TIMESTAMP_STYLE:
if (streq(optarg, "help")) {
DUMP_STRING_TABLE(timestamp_style, TimestampStyle, _TIMESTAMP_STYLE_MAX);
return 0;
}
if (streq(optarg, "help"))
return DUMP_STRING_TABLE(timestamp_style, TimestampStyle, _TIMESTAMP_STYLE_MAX);
arg_timestamp_style = timestamp_style_from_string(optarg);
if (arg_timestamp_style < 0)

View File

@ -26,6 +26,7 @@
#include "pretty-print.h"
#include "recurse-dir.h"
#include "socket-util.h"
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "uid-classification.h"
@ -37,14 +38,16 @@
#include "verbs.h"
#include "virt.h"
static enum {
typedef enum {
OUTPUT_CLASSIC,
OUTPUT_TABLE,
OUTPUT_FRIENDLY,
OUTPUT_JSON,
_OUTPUT_MAX,
_OUTPUT_INVALID = -EINVAL,
} arg_output = _OUTPUT_INVALID;
} Output;
static Output arg_output = _OUTPUT_INVALID;
static PagerFlags arg_pager_flags = 0;
static bool arg_legend = true;
static char** arg_services = NULL;
@ -61,6 +64,15 @@ static sd_json_variant *arg_from_file = NULL;
STATIC_DESTRUCTOR_REGISTER(arg_services, strv_freep);
STATIC_DESTRUCTOR_REGISTER(arg_from_file, sd_json_variant_unrefp);
static const char *output_table[_OUTPUT_MAX] = {
[OUTPUT_CLASSIC] = "classic",
[OUTPUT_TABLE] = "table",
[OUTPUT_FRIENDLY] = "friendly",
[OUTPUT_JSON] = "json",
};
DEFINE_PRIVATE_STRING_TABLE_LOOKUP(output, Output);
static const char *user_disposition_to_color(UserDisposition d) {
assert(d >= 0);
assert(d < _USER_DISPOSITION_MAX);
@ -1652,24 +1664,12 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_OUTPUT:
if (isempty(optarg))
arg_output = _OUTPUT_INVALID;
else if (streq(optarg, "classic"))
arg_output = OUTPUT_CLASSIC;
else if (streq(optarg, "friendly"))
arg_output = OUTPUT_FRIENDLY;
else if (streq(optarg, "json"))
arg_output = OUTPUT_JSON;
else if (streq(optarg, "table"))
arg_output = OUTPUT_TABLE;
else if (streq(optarg, "help")) {
puts("classic\n"
"friendly\n"
"json\n"
"table");
return 0;
} else
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid --output= mode: %s", optarg);
if (streq(optarg, "help"))
return DUMP_STRING_TABLE(output, Output, _OUTPUT_MAX);
arg_output = output_from_string(optarg);
if (arg_output < 0)
return log_error_errno(arg_output, "Invalid --output= mode: %s", optarg);
arg_json_format_flags = arg_output == OUTPUT_JSON ? SD_JSON_FORMAT_PRETTY|SD_JSON_FORMAT_COLOR_AUTO : SD_JSON_FORMAT_OFF;
break;

View File

@ -13,16 +13,12 @@
#include "path-util.h"
#include "pretty-print.h"
#include "stat-util.h"
#include "string-table.h"
#include "string-util.h"
#include "strv.h"
#include "vpick.h"
static char *arg_filter_basename = NULL;
static char *arg_filter_version = NULL;
static Architecture arg_filter_architecture = _ARCHITECTURE_INVALID;
static char *arg_filter_suffix = NULL;
static uint32_t arg_filter_type_mask = 0;
static enum {
typedef enum {
PRINT_PATH,
PRINT_FILENAME,
PRINT_VERSION,
@ -30,14 +26,34 @@ static enum {
PRINT_ARCHITECTURE,
PRINT_TRIES,
PRINT_ALL,
_PRINT_MAX,
_PRINT_INVALID = -EINVAL,
} arg_print = _PRINT_INVALID;
} Print;
static char *arg_filter_basename = NULL;
static char *arg_filter_version = NULL;
static Architecture arg_filter_architecture = _ARCHITECTURE_INVALID;
static char *arg_filter_suffix = NULL;
static uint32_t arg_filter_type_mask = 0;
static Print arg_print = _PRINT_INVALID;
static PickFlags arg_flags = PICK_ARCHITECTURE|PICK_TRIES;
STATIC_DESTRUCTOR_REGISTER(arg_filter_basename, freep);
STATIC_DESTRUCTOR_REGISTER(arg_filter_version, freep);
STATIC_DESTRUCTOR_REGISTER(arg_filter_suffix, freep);
static const char *print_table[_PRINT_MAX] = {
[PRINT_PATH] = "path",
[PRINT_FILENAME] = "filename",
[PRINT_VERSION] = "version",
[PRINT_TYPE] = "type",
[PRINT_ARCHITECTURE] = "architecture",
[PRINT_TRIES] = "tries",
[PRINT_ALL] = "all",
};
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(print, Print);
static int help(void) {
_cleanup_free_ char *link = NULL;
int r;
@ -173,22 +189,12 @@ static int parse_argv(int argc, char *argv[]) {
break;
case 'p':
if (streq(optarg, "path"))
arg_print = PRINT_PATH;
else if (streq(optarg, "filename"))
arg_print = PRINT_FILENAME;
else if (streq(optarg, "version"))
arg_print = PRINT_VERSION;
else if (streq(optarg, "type"))
arg_print = PRINT_TYPE;
else if (STR_IN_SET(optarg, "arch", "architecture"))
if (streq(optarg, "arch")) /* accept abbreviation too */
arg_print = PRINT_ARCHITECTURE;
else if (streq(optarg, "tries"))
arg_print = PRINT_TRIES;
else if (streq(optarg, "all"))
arg_print = PRINT_ALL;
else
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown --print= argument: %s", optarg);
arg_print = print_from_string(optarg);
if (arg_print < 0)
return log_error_errno(arg_print, "Unknown --print= argument: %s", optarg);
break;

View File

@ -43,8 +43,17 @@ usermod -U root
mkdir -p /etc/ssh
test -f /etc/ssh/ssh_host_rsa_key || ssh-keygen -t rsa -C '' -N '' -f /etc/ssh/ssh_host_rsa_key
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
echo "LogLevel DEBUG3" >> /etc/ssh/sshd_config
SSHD_CONF_P="/etc/ssh/sshd_config.d/test.conf"
mkdir -p "$(basename ${SSHD_CONF_P})"
{
echo "PermitRootLogin yes"
echo "LogLevel DEBUG3"
} >"${SSHD_CONF_P}"
rm_sshd_conf() {
rm -f "${SSHD_CONF_P}"
}
trap rm_sshd_conf EXIT
test -f /etc/ssh/ssh_config || {
echo 'Include /etc/ssh/ssh_config.d/*.conf'

View File

@ -49,8 +49,6 @@ def mjoin(files):
return ' \\\n\t'.join(sorted(files) or '#')
MESON_HEADER = '''\
# SPDX-License-Identifier: LGPL-2.1-or-later
# Do not edit. Generated by update-man-rules.py.
# Update with:
# ninja -C build update-man-rules

View File

@ -82,7 +82,6 @@ foreach unit : units
if needs_jinja
t = custom_target(
name,
input : source,
output : name,
command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],