1
0
mirror of https://github.com/systemd/systemd synced 2026-04-23 15:34:50 +02:00

Compare commits

...

12 Commits

Author SHA1 Message Date
Yu Watanabe
60f53dd5cc NEWS: fix typo 2022-03-23 12:22:53 +09:00
Yu Watanabe
ff8619791a boot: fix typo 2022-03-23 12:21:54 +09:00
Lennart Poettering
4d5dacbef3 fs-util: make sure openat_report_new() initializes return param also on shortcut
Our coding style dictates that return parameters should be initialized
always on success, hence do so here also in the shortcut codepath.

Issue discovered by @fbuihuu:

ca8503f168 (r831911069)
2022-03-23 11:38:08 +09:00
Lennart Poettering
b312236919 fs-util: fix typos in comments 2022-03-23 11:38:08 +09:00
Zbigniew Jędrzejewski-Szmek
77d45f1f83 meson: replace sh+find with an internal glob in the python helper
As suggested in https://github.com/systemd/systemd/pull/22810#discussion_r831708052

This makes the whole thing simpler. A glob is passed to helper which then resolves
it on its own. This way it's trivial to call the helper with a different
set of files for testing.
2022-03-23 11:37:35 +09:00
Yu Watanabe
14acae357b
Merge pull request #22825 from keszybz/assorted-cleanups
Assorted cleanups
2022-03-23 11:34:46 +09:00
Luca Boccassi
a8c122c4cb NEWS: adjust MONITOR_ env vars paragraph
This actually never shipped in a release, so it's not a backward-incompatible
change. Move it down and reword it.
2022-03-22 23:03:23 +00:00
Zbigniew Jędrzejewski-Szmek
5cad4c70e3 homework: s/EWOULDBLOCK/EAGAIN/
C.f. 012d7b4217420163db5752a63da6cab39d25edf3, ff55c3c7327e6ad8ab139aef52d498386d4f4a72,
ca2031fcc863fcdd4dd1594709918cb60cfd0e1b.
2022-03-22 14:07:53 +01:00
Zbigniew Jędrzejewski-Szmek
16568fd336 errno-to-awk: simplify expression
No functional change.
2022-03-22 14:07:53 +01:00
Zbigniew Jędrzejewski-Szmek
dba8ef106e sd-bus: use _cleanup_ in one more place 2022-03-22 14:07:53 +01:00
Zbigniew Jędrzejewski-Szmek
3b9d38f5c8 tools/dbus_exporter: deblackify and shorten code a bit
When we do mkdir, we should just use 0o777 and let the umask take care of the
rest. Specifying an explicit mode is inappropriate. And when touching the code,
let's replace black madness with normal python style.
2022-03-22 14:07:53 +01:00
Zbigniew Jędrzejewski-Szmek
94f7ee9770 man: clarify that options set the message fields and are not derived from them 2022-03-22 14:07:53 +01:00
12 changed files with 99 additions and 87 deletions

19
NEWS
View File

@ -23,14 +23,6 @@ CHANGES WITH 251 in spe:
and backward compatibility broken instead on the assumption that
nobody can be affected given the current state of this interface.
* Service monitor environment variables will only be passed to
OnFailure=/OnSuccess= handlers if exactly one unit lists the handler
unit as OnFailure=/OnSuccess=. In addition, $MONITOR_METADATA is no
longer used, and instead separate variables are set:
$MONITOR_SERVICE_RESULT, $MONITOR_EXIT_CODE, $MONITOR_EXIT_STATUS,
$MONITOR_INVOCATION_ID and $MONITOR_UNIT. For cases when a single
handler needs to watch multiple units, use a templated handler.
* All kernels supported by systemd mix RDRAND (or similar) into the
entropy pool at early boot. This means that on those systems, even if
/dev/urandom is not yet initialized, it still returns bytes that that
@ -47,7 +39,7 @@ CHANGES WITH 251 in spe:
* sd-boot will now measure the kernel command line into TPM PCR 12
rather than PCR 8. This improves usefulness of the measurements on
sytems where sd-boot is chainloaded from Grub. Grub measures all
systems where sd-boot is chainloaded from Grub. Grub measures all
commands its executes into PCR 8, which makes it very hard to use
reasonably, hence separate ourselves from that and use PCR 12
instead, which is what certain Ubuntu editions already do. To retain
@ -174,6 +166,13 @@ CHANGES WITH 251 in spe:
they were installed earlier or later than the appropriate version of
the library.
* A new set of service monitor environment variables will be passed to
OnFailure=/OnSuccess= handlers, but only if exactly one unit lists the
handler unit as OnFailure=/OnSuccess=. The variables are:
$MONITOR_SERVICE_RESULT, $MONITOR_EXIT_CODE, $MONITOR_EXIT_STATUS,
$MONITOR_INVOCATION_ID and $MONITOR_UNIT. For cases when a single
handler needs to watch multiple units, use a templated handler.
* A new ExtensionDirectories= setting allows system extensions to be
loaded from a directory. (It is similar to ExtensionImages=, but
takes a path to a directory, instead of an image.)
@ -193,7 +192,7 @@ CHANGES WITH 251 in spe:
* A new unit systemd-networkd-wait-online@<interface>.service can be
used to wait for a specific interface to be up.
* systemd-resolved is started ealier (in sysinit.target), so it
* systemd-resolved is started earlier (in sysinit.target), so it
available earlier and will also be started in the initrd if installed
there.

View File

@ -233,8 +233,7 @@ endif
update_man_rules = custom_target(
'update-man-rules',
output : 'update-man-rules',
command : [sh, '-c',
'cd @0@ && '.format(project_build_root) +
'python3 @0@/tools/update-man-rules.py $(find @0@ -wholename "*/man/*.xml") >t && '.format(project_source_root) +
'mv t @0@/rules/meson.build'.format(meson.current_source_dir())],
command : [update_man_rules_py,
'@0@/man/*.xml'.format(project_source_root),
'@0@/rules/meson.build'.format(meson.current_source_dir())],
depends : custom_entities_ent)

View File

@ -2629,10 +2629,10 @@ Token=prefixstable:2002:da8:1::</programlisting></para>
<term><varname>BootServerAddress=</varname></term>
<listitem>
<para>Takes an IPv4 address of the boot server used by e.g. PXE boot systems. When specified,
the address is set to the <literal>siaddr</literal> field of the DHCP message header. See
<ulink url="https://www.rfc-editor.org/rfc/rfc2131.html">RFC 2131</ulink> for more details.
Defaults to unset.</para>
<para>Takes an IPv4 address of the boot server used by e.g. PXE boot systems. When specified, this
address is sent in the <option>siaddr</option> field of the DHCP message header. See <ulink
url="https://www.rfc-editor.org/rfc/rfc2131.html">RFC 2131</ulink> for more details. Defaults to
unset.</para>
</listitem>
</varlistentry>
@ -2640,13 +2640,13 @@ Token=prefixstable:2002:da8:1::</programlisting></para>
<term><varname>BootServerName=</varname></term>
<listitem>
<para>Takes a name of the boot server used by e.g. PXE boot systems. When specified, the
server name is set to the DHCP option 66. See
<ulink url="https://www.rfc-editor.org/rfc/rfc2132.html">RFC 2132</ulink> for more details.
Defaults to unset.</para>
<para>Note that typically one of
<varname>BootServerName=</varname>/<varname>BootServerAddress=</varname> is sufficient to be
set, but both can be set too, if desired.</para>
<para>Takes a name of the boot server used by e.g. PXE boot systems. When specified, this name is
sent in the DHCP option 66 ("TFTP server name"). See <ulink
url="https://www.rfc-editor.org/rfc/rfc2132.html">RFC 2132</ulink> for more details. Defaults to
unset.</para>
<para>Note that typically setting one of <varname>BootServerName=</varname> or
<varname>BootServerAddress=</varname> is sufficient, but both can be set too, if desired.</para>
</listitem>
</varlistentry>
@ -2654,10 +2654,10 @@ Token=prefixstable:2002:da8:1::</programlisting></para>
<term><varname>BootFilename=</varname></term>
<listitem>
<para>Takes a path or URL to a file loaded by e.g. a PXE boot loader. The specified path is
set to the DHCP option 67. See
<ulink url="https://www.rfc-editor.org/rfc/rfc2132.html">RFC 2132</ulink> for more details.
Defaults to unset.</para>
<para>Takes a path or URL to a file loaded by e.g. a PXE boot loader. When specified, this path is
sent in the DHCP option 67 ("Bootfile name"). See <ulink
url="https://www.rfc-editor.org/rfc/rfc2132.html">RFC 2132</ulink> for more details. Defaults to
unset.</para>
</listitem>
</varlistentry>

View File

@ -1803,6 +1803,7 @@ make_directive_index_py = find_program('tools/make-directive-index.py')
make_man_index_py = find_program('tools/make-man-index.py')
meson_render_jinja2 = find_program('tools/meson-render-jinja2.py')
update_dbus_docs_py = find_program('tools/update-dbus-docs.py')
update_man_rules_py = find_program('tools/update-man-rules.py')
update_hwdb_sh = find_program('tools/update-hwdb.sh')
update_hwdb_autosuspend_sh = find_program('tools/update-hwdb-autosuspend.sh')
update_syscall_tables_sh = find_program('tools/update-syscall-tables.sh')

View File

@ -3,7 +3,7 @@
BEGIN{
print "static const char* const errno_names[] = { "
}
!/EDEADLOCK/ && !/EWOULDBLOCK/ && !/ENOTSUP/ {
!/(EDEADLOCK|EWOULDBLOCK|ENOTSUP)/ {
printf " [%s] = \"%s\",\n", $1, $1
}
END{

View File

@ -1086,17 +1086,25 @@ int open_mkdir_at(int dirfd, const char *path, int flags, mode_t mode) {
int openat_report_new(int dirfd, const char *pathname, int flags, mode_t mode, bool *ret_newly_created) {
unsigned attempts = 7;
/* Just like openat(), but adds one thing: optionally returns whether we created the file anew or if
* it already existed before. This is only relevant of O_CREAT is set without O_EXCL, and thus will
* shortcut to openat() otherwise */
if (!FLAGS_SET(flags, O_CREAT) || FLAGS_SET(flags, O_EXCL) || !ret_newly_created)
return RET_NERRNO(openat(dirfd, pathname, flags, mode));
for (;;) {
int fd;
/* Just like openat(), but adds one thing: optionally returns whether we created the file anew or if
* it already existed before. This is only relevant if O_CREAT is set without O_EXCL, and thus will
* shortcut to openat() otherwise */
if (!ret_newly_created)
return RET_NERRNO(openat(dirfd, pathname, flags, mode));
if (!FLAGS_SET(flags, O_CREAT) || FLAGS_SET(flags, O_EXCL)) {
fd = openat(dirfd, pathname, flags, mode);
if (fd < 0)
return -errno;
*ret_newly_created = FLAGS_SET(flags, O_CREAT);
return fd;
}
for (;;) {
/* First, attempt to open without O_CREAT/O_EXCL, i.e. open existing file */
fd = openat(dirfd, pathname, flags & ~(O_CREAT | O_EXCL), mode);
if (fd >= 0) {
@ -1116,7 +1124,7 @@ int openat_report_new(int dirfd, const char *pathname, int flags, mode_t mode, b
return -errno;
/* Hmm, so now we got EEXIST? So it apparently exists now? If so, let's try to open again
* without the two flags. But let's not spin forever, hnce put a limit on things */
* without the two flags. But let's not spin forever, hence put a limit on things */
if (--attempts == 0) /* Give up eventually, somebody is playing with us */
return -EEXIST;

View File

@ -53,7 +53,7 @@ typedef struct {
CHAR16 *id; /* The unique identifier for this entry (typically the filename of the file defining the entry) */
CHAR16 *title_show; /* The string to actually display (this is made unique before showing) */
CHAR16 *title; /* The raw (human readable) title string of the entry (not necessarily unique) */
CHAR16 *sort_key; /* The string to use as primary sory key, usually ID= from os-release, possibly suffixed */
CHAR16 *sort_key; /* The string to use as primary sort key, usually ID= from os-release, possibly suffixed */
CHAR16 *version; /* The raw (human readable) version string of the entry */
CHAR16 *machine_id;
EFI_HANDLE *device;

View File

@ -1163,12 +1163,12 @@ static int lock_image_fd(int image_fd, const char *ip) {
if (flock(image_fd, LOCK_EX|LOCK_NB) < 0) {
if (errno == EWOULDBLOCK)
if (errno == EAGAIN)
log_error_errno(errno, "Image file '%s' already locked, can't use.", ip);
else
log_error_errno(errno, "Failed to lock image file '%s': %m", ip);
return errno != EWOULDBLOCK ? -errno : -EADDRINUSE; /* Make error recognizable */
return errno != EAGAIN ? -errno : -EADDRINUSE; /* Make error recognizable */
}
log_info("Successfully locked image file '%s'.", ip);

View File

@ -217,28 +217,26 @@ static int get_child_nodes(
const char *prefix,
struct node *n,
unsigned flags,
OrderedSet **_s,
OrderedSet **ret,
sd_bus_error *error) {
OrderedSet *s = NULL;
_cleanup_ordered_set_free_free_ OrderedSet *s = NULL;
int r;
assert(bus);
assert(prefix);
assert(n);
assert(_s);
assert(ret);
s = ordered_set_new(&string_hash_ops);
if (!s)
return -ENOMEM;
r = add_subtree_to_set(bus, prefix, n, flags, s, error);
if (r < 0) {
ordered_set_free_free(s);
if (r < 0)
return r;
}
*_s = s;
*ret = TAKE_PTR(s);
return 0;
}
@ -1499,8 +1497,7 @@ static struct node *bus_node_allocate(sd_bus *bus, const char *path) {
if (streq(path, "/"))
parent = NULL;
else {
e = strrchr(path, '/');
assert(e);
assert_se(e = strrchr(path, '/'));
p = strndupa_safe(path, MAX(1, e - path));

View File

@ -1018,6 +1018,24 @@ TEST(openat_report_new) {
assert_se(fd >= 0);
fd = safe_close(fd);
assert_se(!b);
fd = openat_report_new(AT_FDCWD, j, O_RDWR, 0666, &b);
assert_se(fd >= 0);
fd = safe_close(fd);
assert_se(!b);
fd = openat_report_new(AT_FDCWD, j, O_RDWR|O_CREAT|O_EXCL, 0666, &b);
assert_se(fd == -EEXIST);
assert_se(unlink(j) >= 0);
fd = openat_report_new(AT_FDCWD, j, O_RDWR, 0666, &b);
assert_se(fd == -ENOENT);
fd = openat_report_new(AT_FDCWD, j, O_RDWR|O_CREAT|O_EXCL, 0666, &b);
assert_se(fd >= 0);
fd = safe_close(fd);
assert_se(b);
}
static int intro(void) {

View File

@ -4,58 +4,39 @@ from argparse import ArgumentParser
from pathlib import Path
from subprocess import run, PIPE
def extract_interfaces_xml(output_dir, executable):
list_interfaces_process = run(
proc = run(
args=[executable.absolute(), '--bus-introspect', 'list'],
stdout=PIPE,
check=True,
universal_newlines=True,
)
universal_newlines=True)
interfaces_lines = list_interfaces_process.stdout.splitlines()
interface_names = [x.split()[1] for x in interfaces_lines]
interface_names = (x.split()[1] for x in proc.stdout.splitlines())
for interface_name in interface_names:
interface_introspection_run = run(
proc = run(
args=[executable.absolute(), '--bus-introspect', interface_name],
stdout=PIPE,
check=True,
universal_newlines=True,
)
universal_newlines=True)
interface_file_name = output_dir / (interface_name + '.xml')
with open(interface_file_name, mode='w') as f:
f.write(interface_introspection_run.stdout)
interface_file_name.write_text(proc.stdout)
interface_file_name.chmod(0o644)
def iterate_executables(output_dir, executables):
output_dir.mkdir(mode=0o755, exist_ok=True)
for exe in executables:
extract_interfaces_xml(output_dir, exe)
def main():
parser = ArgumentParser()
parser.add_argument(
'output',
type=Path,
)
parser.add_argument(
'executables',
type=Path,
parser.add_argument('output',
type=Path)
parser.add_argument('executables',
nargs='+',
)
type=Path)
args = parser.parse_args()
iterate_executables(args.output, args.executables)
args.output.mkdir(exist_ok=True)
for exe in args.executables:
extract_interfaces_xml(args.output, exe)
if __name__ == '__main__':
main()

View File

@ -3,9 +3,10 @@
from __future__ import print_function
import collections
import glob
import sys
from pathlib import Path
import pprint
from os.path import basename
from xml_helper import xml_parse
def man(page, number):
@ -56,7 +57,8 @@ manpages = ['''
MESON_FOOTER = '''\
]
# Really, do not edit.'''
# Really, do not edit.
'''
def make_mesonfile(rules, dist_files):
# reformat rules as
@ -76,13 +78,20 @@ def make_mesonfile(rules, dist_files):
return '\n'.join((MESON_HEADER, pprint.pformat(lines)[1:-1], MESON_FOOTER))
if __name__ == '__main__':
pages = sys.argv[1:]
source_glob = sys.argv[1]
target = Path(sys.argv[2])
pages = glob.glob(source_glob)
pages = (p for p in pages
if basename(p) not in {
if Path(p).name not in {
'systemd.directives.xml',
'systemd.index.xml',
'directives-template.xml'})
rules = create_rules(pages)
dist_files = (basename(p) for p in pages)
print(make_mesonfile(rules, dist_files))
dist_files = (Path(p).name for p in pages)
text = make_mesonfile(rules, dist_files)
tmp = target.with_suffix('.tmp')
tmp.write_text(text)
tmp.rename(target)