mirror of
https://github.com/systemd/systemd
synced 2026-04-03 21:54:58 +02:00
Compare commits
4 Commits
6e671b3f07
...
da845dabf5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da845dabf5 | ||
|
|
a6d1760024 | ||
|
|
bf47f71c1c | ||
|
|
2d8840eb66 |
@ -4,7 +4,6 @@ custom_target(
|
||||
'README',
|
||||
input : 'README.in',
|
||||
output : 'README',
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
|
||||
install : conf.get('HAVE_SYSV_COMPAT') == 1,
|
||||
install_dir : sysvinit_path)
|
||||
|
||||
@ -56,11 +56,6 @@
|
||||
|
||||
# Sort by brand, model
|
||||
|
||||
# UC-Logic TABLET 1060N Pad
|
||||
id-input:modalias:input:b0003v5543p0081*
|
||||
ID_INPUT_TABLET=1
|
||||
ID_INPUT_TABLET_PAD=1
|
||||
|
||||
# XP-PEN STAR 06
|
||||
id-input:modalias:input:b0003v28bdp0078*
|
||||
ID_INPUT_TABLET=1
|
||||
|
||||
@ -30,8 +30,7 @@ custom_entities_ent = custom_target(
|
||||
'custom-entities.ent',
|
||||
input : 'custom-entities.ent.in',
|
||||
output : 'custom-entities.ent',
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true)
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'])
|
||||
|
||||
man_pages = []
|
||||
html_pages = []
|
||||
|
||||
@ -551,7 +551,8 @@ NAutoVTs=8
|
||||
<title><command>systemd-analyze verify <replaceable>FILE</replaceable>...</command></title>
|
||||
|
||||
<para>This command will load unit files and print warnings if any errors are detected. Files specified
|
||||
on the command line will be loaded, but also any other units referenced by them. The full unit search
|
||||
on the command line will be loaded, but also any other units referenced by them. A unit's name on disk
|
||||
can be overridden by specifying an alias after a colon; see below for an example. The full unit search
|
||||
path is formed by combining the directories for all command line arguments, and the usual unit load
|
||||
paths. The variable <varname>$SYSTEMD_UNIT_PATH</varname> is supported, and may be used to replace or
|
||||
augment the compiled in set of unit load paths; see
|
||||
@ -613,6 +614,27 @@ Service a.service not loaded, a.socket cannot be started.
|
||||
Service b@0.service not loaded, b.socket cannot be started.
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>Aliasing a unit</title>
|
||||
|
||||
<programlisting>$ cat /tmp/source
|
||||
[Unit]
|
||||
Description=Hostname printer
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/echo %H
|
||||
MysteryKey=true
|
||||
|
||||
$ systemd-analyze verify /tmp/source
|
||||
Failed to prepare filename /tmp/source: Invalid argument
|
||||
|
||||
$ systemd-analyze verify /tmp/source:alias.service
|
||||
/tmp/systemd-analyze-XXXXXX/alias.service:7: Unknown key name 'MysteryKey' in section 'Service', ignoring.
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
</refsect2>
|
||||
|
||||
<refsect2>
|
||||
|
||||
@ -52,8 +52,7 @@ foreach file : rules_in
|
||||
file,
|
||||
input : file + '.in',
|
||||
output: file,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
|
||||
install : true,
|
||||
install_dir : udevrulesdir)
|
||||
endforeach
|
||||
|
||||
@ -14,8 +14,7 @@ custom_target(
|
||||
'systemctl',
|
||||
input : 'systemctl.in',
|
||||
output : 'systemctl',
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
|
||||
install : bashcompletiondir != 'no',
|
||||
install_dir : bashcompletiondir)
|
||||
|
||||
|
||||
@ -9,8 +9,7 @@ custom_target(
|
||||
'_systemctl',
|
||||
input : '_systemctl.in',
|
||||
output : '_systemctl',
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
|
||||
install : zshcompletiondir != 'no',
|
||||
install_dir : zshcompletiondir)
|
||||
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include "copy.h"
|
||||
#include "def.h"
|
||||
#include "exit-status.h"
|
||||
#include "extract-word.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "filesystems.h"
|
||||
@ -42,6 +43,7 @@
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "pretty-print.h"
|
||||
#include "rm-rf.h"
|
||||
#if HAVE_SECCOMP
|
||||
# include "seccomp-util.h"
|
||||
#endif
|
||||
@ -53,6 +55,7 @@
|
||||
#include "strxcpyx.h"
|
||||
#include "terminal-util.h"
|
||||
#include "time-util.h"
|
||||
#include "tmpfile-util.h"
|
||||
#include "unit-name.h"
|
||||
#include "util.h"
|
||||
#include "verb-log-control.h"
|
||||
@ -230,6 +233,53 @@ static int compare_unit_start(const UnitTimes *a, const UnitTimes *b) {
|
||||
return CMP(a->activating, b->activating);
|
||||
}
|
||||
|
||||
static int process_aliases(char *argv[], char *tempdir, char ***ret) {
|
||||
_cleanup_strv_free_ char **filenames = NULL;
|
||||
char **filename;
|
||||
int r;
|
||||
|
||||
assert(argv);
|
||||
assert(tempdir);
|
||||
assert(ret);
|
||||
|
||||
STRV_FOREACH(filename, strv_skip(argv, 1)) {
|
||||
_cleanup_free_ char *src = NULL, *dst = NULL, *arg = NULL;
|
||||
char *parse_arg;
|
||||
|
||||
arg = strdup(*filename);
|
||||
if (!arg)
|
||||
return -ENOMEM;
|
||||
|
||||
parse_arg = arg;
|
||||
r = extract_first_word((const char **) &parse_arg, &src, ":", 0);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!parse_arg) {
|
||||
r = strv_extend(&filenames, src);
|
||||
if (r < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
dst = path_join(tempdir, basename(parse_arg));
|
||||
if (!dst)
|
||||
return -ENOMEM;
|
||||
|
||||
r = copy_file(src, dst, 0, 0644, 0, 0, COPY_REFLINK);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = strv_consume(&filenames, TAKE_PTR(dst));
|
||||
if (r < 0)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
*ret = TAKE_PTR(filenames);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static UnitTimes* unit_times_free_array(UnitTimes *t) {
|
||||
for (UnitTimes *p = t; p && p->has_data; p++)
|
||||
free(p->name);
|
||||
@ -2257,7 +2307,19 @@ static int do_condition(int argc, char *argv[], void *userdata) {
|
||||
}
|
||||
|
||||
static int do_verify(int argc, char *argv[], void *userdata) {
|
||||
return verify_units(strv_skip(argv, 1), arg_scope, arg_man, arg_generators, arg_recursive_errors, arg_root);
|
||||
_cleanup_strv_free_ char **filenames = NULL;
|
||||
_cleanup_(rm_rf_physical_and_freep) char *tempdir = NULL;
|
||||
int r;
|
||||
|
||||
r = mkdtemp_malloc("/tmp/systemd-analyze-XXXXXX", &tempdir);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to setup working directory: %m");
|
||||
|
||||
r = process_aliases(argv, tempdir, &filenames);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Couldn't process aliases: %m");
|
||||
|
||||
return verify_units(filenames, arg_scope, arg_man, arg_generators, arg_recursive_errors, arg_root);
|
||||
}
|
||||
|
||||
static int do_security(int argc, char *argv[], void *userdata) {
|
||||
|
||||
@ -149,8 +149,7 @@ load_fragment_gperf_gperf = custom_target(
|
||||
'load-fragment-gperf.gperf',
|
||||
input : 'load-fragment-gperf.gperf.in',
|
||||
output: 'load-fragment-gperf.gperf',
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true)
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'])
|
||||
|
||||
load_fragment_gperf_c = custom_target(
|
||||
'load-fragment-gperf.c',
|
||||
@ -202,8 +201,7 @@ foreach item : in_files
|
||||
file,
|
||||
input : file + '.in',
|
||||
output: file,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
|
||||
install : (dir == pkgsysconfdir) ? install_sysconfdir_samples : (dir != 'no'),
|
||||
install_dir : dir)
|
||||
endforeach
|
||||
|
||||
@ -54,8 +54,7 @@ foreach tuple : in_files
|
||||
file,
|
||||
input : file + '.in',
|
||||
output: file,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
|
||||
install : tuple[1],
|
||||
install_dir : pkgsysconfdir)
|
||||
endforeach
|
||||
|
||||
@ -183,8 +183,7 @@ custom_target(
|
||||
'libsystemd.pc',
|
||||
input : 'libsystemd.pc.in',
|
||||
output : 'libsystemd.pc',
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
|
||||
install : pkgconfiglibdir != 'no',
|
||||
install_dir : pkgconfiglibdir)
|
||||
|
||||
|
||||
@ -43,8 +43,7 @@ custom_target(
|
||||
'libudev.pc',
|
||||
input : 'libudev.pc.in',
|
||||
output : 'libudev.pc',
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
|
||||
install : pkgconfiglibdir != 'no',
|
||||
install_dir : pkgconfiglibdir)
|
||||
|
||||
|
||||
@ -81,8 +81,7 @@ foreach tuple : in_files
|
||||
file,
|
||||
input : file + '.in',
|
||||
output: file,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
|
||||
install : tuple[2] and install,
|
||||
install_dir : dir)
|
||||
endforeach
|
||||
|
||||
@ -166,8 +166,7 @@ custom_target(
|
||||
'resolved.conf',
|
||||
input : 'resolved.conf.in',
|
||||
output : 'resolved.conf',
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
|
||||
install : conf.get('ENABLE_RESOLVE') == 1 and install_sysconfdir_samples,
|
||||
install_dir : pkgsysconfdir)
|
||||
|
||||
|
||||
@ -18,8 +18,7 @@ foreach tuple : in_files
|
||||
file,
|
||||
input : file + '.in',
|
||||
output : file,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
|
||||
install : tuple[1],
|
||||
install_dir : tuple.length() > 2 ? tuple[2] : '',
|
||||
install_mode : tuple.length() > 3 ? tuple[3] : false,
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
nsec_t nsec;
|
||||
uint64_t v, w;
|
||||
uint64_t v, pid_max, threads_max, limit;
|
||||
int r;
|
||||
|
||||
log_parse_environment();
|
||||
@ -26,40 +26,51 @@ int main(int argc, char *argv[]) {
|
||||
assert_se(procfs_tasks_get_current(&v) >= 0);
|
||||
log_info("Current number of tasks: %" PRIu64, v);
|
||||
|
||||
v = TASKS_MAX;
|
||||
r = procfs_get_pid_max(&v);
|
||||
assert(r >= 0 || r == -ENOENT || ERRNO_IS_PRIVILEGE(r));
|
||||
log_info("kernel.pid_max: %"PRIu64, v);
|
||||
pid_max = TASKS_MAX;
|
||||
r = procfs_get_pid_max(&pid_max);
|
||||
if (r == -ENOENT || ERRNO_IS_PRIVILEGE(r))
|
||||
return log_tests_skipped_errno(r, "can't get pid max");
|
||||
assert(r >= 0);
|
||||
log_info("kernel.pid_max: %"PRIu64, pid_max);
|
||||
|
||||
w = TASKS_MAX;
|
||||
r = procfs_get_threads_max(&w);
|
||||
assert(r >= 0 || r == -ENOENT || ERRNO_IS_PRIVILEGE(r));
|
||||
log_info("kernel.threads-max: %"PRIu64, w);
|
||||
threads_max = TASKS_MAX;
|
||||
r = procfs_get_threads_max(&threads_max);
|
||||
if (r == -ENOENT || ERRNO_IS_PRIVILEGE(r))
|
||||
return log_tests_skipped_errno(r, "can't get threads max");
|
||||
assert(r >= 0);
|
||||
log_info("kernel.threads-max: %"PRIu64, threads_max);
|
||||
|
||||
v = MIN(v - (v > 0), w);
|
||||
limit = MIN(pid_max - (pid_max > 0), threads_max);
|
||||
|
||||
assert_se(r >= 0);
|
||||
log_info("Limit of tasks: %" PRIu64, v);
|
||||
assert_se(v > 0);
|
||||
r = procfs_tasks_set_limit(v);
|
||||
if (r == -ENOENT || ERRNO_IS_PRIVILEGE(r))
|
||||
return log_tests_skipped("can't set task limits");
|
||||
assert(r >= 0);
|
||||
log_info("Limit of tasks: %" PRIu64, limit);
|
||||
assert_se(limit > 0);
|
||||
|
||||
if (v > 100) {
|
||||
log_info("Reducing limit by one to %"PRIu64"…", v-1);
|
||||
/* This call should never fail, as we're trying to set it to the same limit */
|
||||
assert(procfs_tasks_set_limit(limit) >= 0);
|
||||
|
||||
r = procfs_tasks_set_limit(v-1);
|
||||
log_info_errno(r, "procfs_tasks_set_limit: %m");
|
||||
assert_se(r >= 0 || ERRNO_IS_PRIVILEGE(r) || r == -EROFS);
|
||||
if (limit > 100) {
|
||||
log_info("Reducing limit by one to %"PRIu64"…", limit-1);
|
||||
|
||||
assert_se(procfs_get_threads_max(&w) >= 0);
|
||||
assert_se(r >= 0 ? w == v - 1 : w == v);
|
||||
r = procfs_tasks_set_limit(limit-1);
|
||||
if (IN_SET(r, -ENOENT, -EROFS) || ERRNO_IS_PRIVILEGE(r))
|
||||
return log_tests_skipped_errno(r, "can't set tasks limit");
|
||||
assert_se(r >= 0);
|
||||
|
||||
assert_se(procfs_tasks_set_limit(v) >= 0);
|
||||
assert_se(procfs_get_pid_max(&v) >= 0);
|
||||
/* We never decrease the pid_max, so it shouldn't have changed */
|
||||
assert_se(v == pid_max);
|
||||
|
||||
assert_se(procfs_get_threads_max(&w) >= 0);
|
||||
assert_se(v == w);
|
||||
assert_se(procfs_get_threads_max(&v) >= 0);
|
||||
assert_se(v == limit-1);
|
||||
|
||||
assert_se(procfs_tasks_set_limit(limit) >= 0);
|
||||
|
||||
assert_se(procfs_get_pid_max(&v) >= 0);
|
||||
assert_se(v == pid_max);
|
||||
|
||||
assert_se(procfs_get_threads_max(&v) >= 0);
|
||||
assert_se(v == limit);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@ -38,8 +38,7 @@ custom_target(
|
||||
'timesyncd.conf',
|
||||
input : 'timesyncd.conf.in',
|
||||
output : 'timesyncd.conf',
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
|
||||
install : conf.get('ENABLE_TIMESYNCD') == 1 and install_sysconfdir_samples,
|
||||
install_dir : pkgsysconfdir)
|
||||
|
||||
|
||||
@ -162,8 +162,7 @@ custom_target(
|
||||
'udev.pc',
|
||||
input : 'udev.pc.in',
|
||||
output : 'udev.pc',
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
|
||||
install : pkgconfigdatadir != 'no',
|
||||
install_dir : pkgconfigdatadir)
|
||||
|
||||
|
||||
@ -4,7 +4,6 @@ custom_target(
|
||||
'90-vconsole.rules',
|
||||
input : '90-vconsole.rules.in',
|
||||
output : '90-vconsole.rules',
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
|
||||
install : conf.get('ENABLE_VCONSOLE') == 1,
|
||||
install_dir : udevrulesdir)
|
||||
|
||||
@ -16,8 +16,7 @@ custom_target(
|
||||
'50-coredump.conf',
|
||||
input : '50-coredump.conf.in',
|
||||
output : '50-coredump.conf',
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
|
||||
install : conf.get('ENABLE_COREDUMP') == 1,
|
||||
install_dir : sysctldir)
|
||||
|
||||
|
||||
@ -33,8 +33,7 @@ foreach tuple : in_files
|
||||
file,
|
||||
input : file + '.in',
|
||||
output: file,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
|
||||
install : tuple[1],
|
||||
install_dir : sysusersdir)
|
||||
endforeach
|
||||
|
||||
@ -76,6 +76,14 @@ systemd-analyze verify /tmp/.testfile.service
|
||||
|
||||
rm /tmp/.testfile.service
|
||||
|
||||
# Alias a unit file's name on disk (see #20061)
|
||||
cp /tmp/testfile.service /tmp/testsrvc
|
||||
|
||||
systemd-analyze verify /tmp/testsrvc \
|
||||
&& { echo 'unexpected success'; exit 1; }
|
||||
|
||||
systemd-analyze verify /tmp/testsrvc:alias.service
|
||||
|
||||
# Zero exit status since the value used for comparison determine exposure to security threats is by default 100
|
||||
systemd-analyze security --offline=true /tmp/testfile.service
|
||||
|
||||
|
||||
@ -40,8 +40,7 @@ foreach pair : in_files
|
||||
pair[0],
|
||||
input : pair[0] + '.in',
|
||||
output: pair[0],
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
|
||||
install : enable_tmpfiles,
|
||||
install_dir : tmpfilesdir)
|
||||
else
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
import ast
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
@ -27,4 +28,8 @@ def render(filename, defines):
|
||||
|
||||
if __name__ == '__main__':
|
||||
defines = parse_config_h(sys.argv[1])
|
||||
print(render(sys.argv[2], defines))
|
||||
output = render(sys.argv[2], defines)
|
||||
with open(sys.argv[3], 'w') as f:
|
||||
f.write(output)
|
||||
info = os.stat(sys.argv[2])
|
||||
os.chmod(sys.argv[3], info.st_mode)
|
||||
|
||||
@ -272,8 +272,7 @@ foreach tuple : in_units
|
||||
file,
|
||||
input : file + '.in',
|
||||
output : file,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@'],
|
||||
capture : true,
|
||||
command : [meson_render_jinja2, config_h, '@INPUT@', '@OUTPUT@'],
|
||||
install : install,
|
||||
install_dir : systemunitdir)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user