1
0
mirror of https://github.com/systemd/systemd synced 2026-03-04 04:04:47 +01:00

Compare commits

..

No commits in common. "db1689e69cbb25c5e24d845601088897bf3df5d7" and "a23d89065a9e3dba24a045c5a9738de059bcc163" have entirely different histories.

15 changed files with 40 additions and 36 deletions

View File

@ -47,7 +47,7 @@ jobs:
# older glibc # older glibc
- env: { COMPILER: "gcc", COMPILER_VERSION: "12", LINKER: "bfd", CUSTOM_PYTHON: "1" } - env: { COMPILER: "gcc", COMPILER_VERSION: "12", LINKER: "bfd", CUSTOM_PYTHON: "1" }
runner: [ ubuntu-22.04 ] runner: [ ubuntu-22.04 ]
python-version: '3.9' python-version: '3.7'
env: ${{ matrix.env }} env: ${{ matrix.env }}
steps: steps:
- name: Repository checkout - name: Repository checkout

2
README
View File

@ -247,7 +247,7 @@ REQUIREMENTS:
gperf gperf
docbook-xsl (optional, required for documentation) docbook-xsl (optional, required for documentation)
xsltproc (optional, required for documentation) xsltproc (optional, required for documentation)
python >= 3.9 python >= 3.7 (required by meson too, >= 3.9 is required for ukify)
python-jinja2 python-jinja2
python-pefile (optional, required for ukify) python-pefile (optional, required for ukify)
python-lxml (optional, required to build the indices) python-lxml (optional, required to build the indices)

View File

@ -17,7 +17,8 @@ def read_os_release():
line = line.rstrip() line = line.rstrip()
if not line or line.startswith('#'): if not line or line.startswith('#'):
continue continue
if m := re.match(r'([A-Z][A-Z_0-9]+)=(.*)', line): m = re.match(r'([A-Z][A-Z_0-9]+)=(.*)', line)
if m:
name, val = m.groups() name, val = m.groups()
if val and val[0] in '"\'': if val and val[0] in '"\'':
val = ast.literal_eval(val) val = ast.literal_eval(val)

View File

@ -221,9 +221,6 @@
when the VM shuts down. This mode is not suitable for VMs which lock disk encryption keys to the when the VM shuts down. This mode is not suitable for VMs which lock disk encryption keys to the
TPM, as these keys will be lost on every reboot. Defaults to <literal>auto</literal>.</para> TPM, as these keys will be lost on every reboot. Defaults to <literal>auto</literal>.</para>
<para>If <option>--ephemeral</option> is specified, <literal>auto</literal> behaves like
<literal>off</literal>.</para>
<xi:include href="version-info.xml" xpointer="v258"/></listitem> <xi:include href="version-info.xml" xpointer="v258"/></listitem>
</varlistentry> </varlistentry>

View File

@ -1695,9 +1695,7 @@ conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', want_slow_tests)
pymod = import('python') pymod = import('python')
python = pymod.find_installation('python3', required : true, modules : ['jinja2']) python = pymod.find_installation('python3', required : true, modules : ['jinja2'])
if not python.language_version().version_compare('>=3.9') python_39 = python.language_version().version_compare('>=3.9')
error('Python >= 3.9 is required')
endif
##################################################################### #####################################################################
@ -1898,7 +1896,9 @@ if have and efi_arch == 'x64' and cc.links('''
efi_cpu_family_alt = 'x86' efi_cpu_family_alt = 'x86'
endif endif
want_ukify = pymod.find_installation('python3', required: get_option('ukify'), modules : ['pefile']).found() pefile = pymod.find_installation('python3', required: false, modules : ['pefile'])
want_ukify = get_option('ukify').require(python_39 and (want_tests != 'true' or pefile.found()), error_message : 'Python >= 3.9 and pefile required').allowed()
conf.set10('ENABLE_UKIFY', want_ukify) conf.set10('ENABLE_UKIFY', want_ukify)
##################################################################### #####################################################################

View File

@ -1,6 +1,11 @@
target-version = "py39" target-version = "py37"
line-length = 109 line-length = 109
lint.select = ["E", "F", "I", "UP"] lint.select = ["E", "F", "I", "UP"]
[format] [format]
quote-style = "single" quote-style = "single"
[per-file-target-version]
"src/ukify/*.py" = "py39"
"test/**/integration-test-wrapper.py" = "py39"
"test/test-udev.py" = "py39"

View File

@ -47,8 +47,6 @@ SUBSYSTEM=="drm", KERNEL=="card*", TAG+="uaccess"
{% if GROUP_RENDER_UACCESS %} {% if GROUP_RENDER_UACCESS %}
# DRI render nodes # DRI render nodes
SUBSYSTEM=="drm", KERNEL=="renderD*", TAG+="uaccess", TAG+="xaccess-render" SUBSYSTEM=="drm", KERNEL=="renderD*", TAG+="uaccess", TAG+="xaccess-render"
# DRI accel nodes
SUBSYSTEM=="accel", KERNEL=="accel*", TAG+="uaccess", TAG+="xaccess-accel"
{% endif %} {% endif %}
{% if DEV_KVM_UACCESS %} {% if DEV_KVM_UACCESS %}
# KVM # KVM

View File

@ -308,7 +308,7 @@ def generate_fs_in_group():
print(' switch (fs_group) {') print(' switch (fs_group) {')
for name, _, *filesystems in FILESYSTEM_SETS: for name, _, *filesystems in FILESYSTEM_SETS:
magics = sorted(set(sum((NAME_TO_MAGIC[fs] for fs in filesystems), start=[]))) magics = sorted(set(sum((NAME_TO_MAGIC[fs] for fs in filesystems), [])))
enum = 'FILESYSTEM_SET_' + name[1:].upper().replace('-', '_') enum = 'FILESYSTEM_SET_' + name[1:].upper().replace('-', '_')
print(f' case {enum}:') print(f' case {enum}:')
opts = '\n || '.join(f'F_TYPE_EQUAL(st->f_type, {magic})' opts = '\n || '.join(f'F_TYPE_EQUAL(st->f_type, {magic})'
@ -355,7 +355,7 @@ def magic_defines():
def check(): def check():
kernel_magics = set(magic_defines()) kernel_magics = set(magic_defines())
our_magics = set(sum(NAME_TO_MAGIC.values(), start=[])) our_magics = set(sum(NAME_TO_MAGIC.values(), []))
extra = kernel_magics - our_magics extra = kernel_magics - our_magics
if extra: if extra:
sys.exit(f"kernel knows additional filesystem magics: {', '.join(sorted(extra))}") sys.exit(f"kernel knows additional filesystem magics: {', '.join(sorted(extra))}")

View File

@ -275,16 +275,8 @@ EFI_STATUS linux_exec(
if (h->SizeOfRawData == 0) if (h->SizeOfRawData == 0)
continue; continue;
if (UINT32_MAX - h->VirtualAddress < h->SizeOfRawData)
return log_error_status(EFI_LOAD_ERROR, "Invalid PE section, SizeOfRawData + VirtualAddress, overflows");
if (h->VirtualAddress + h->SizeOfRawData > kernel_size_in_memory) if (h->VirtualAddress + h->SizeOfRawData > kernel_size_in_memory)
return log_error_status(EFI_LOAD_ERROR, "Section would write outside of memory"); return log_error_status(EFI_LOAD_ERROR, "Section would write outside of memory");
if (h->SizeOfRawData > h->VirtualSize)
return log_error_status(EFI_LOAD_ERROR, "Invalid PE section, raw data size is greater than virtual size");
if (UINT32_MAX - h->PointerToRawData < h->SizeOfRawData)
return log_error_status(EFI_LOAD_ERROR, "Invalid PE section, PointerToRawData + SizeOfRawData overflows");
if (h->PointerToRawData + h->SizeOfRawData > kernel->iov_len)
return log_error_status(EFI_LOAD_ERROR, "Invalid PE section, raw data extends outside of file");
memcpy(loaded_kernel + h->VirtualAddress, memcpy(loaded_kernel + h->VirtualAddress,
(const uint8_t*)kernel->iov_base + h->PointerToRawData, (const uint8_t*)kernel->iov_base + h->PointerToRawData,
h->SizeOfRawData); h->SizeOfRawData);

View File

@ -7,6 +7,7 @@
import re import re
import sys import sys
import typing
def print_usage_and_exit() -> None: def print_usage_and_exit() -> None:
@ -26,7 +27,7 @@ if output not in ['code', 'doc']:
with open(header) as file: with open(header) as file:
inEnum = False inEnum = False
enumValues: list[str] = [] enumValues: typing.List[str] = []
enumName = '' enumName = ''
if output == 'doc': if output == 'doc':
@ -67,7 +68,9 @@ with open(header) as file:
match = re.fullmatch(r'(\w+)\b,', line) match = re.fullmatch(r'(\w+)\b,', line)
if match and len(match.groups()) > 0 and not match[1].startswith('__'): if match and len(match.groups()) > 0 and not match[1].startswith('__'):
enumValues.append(match[1]) enumValues.append(match[1])
elif match := re.match(r'^\s*enum\s+bpf_(cmd|map_type|prog_type|attach_type)+\s*{', line): else:
match = re.match(r'^\s*enum\s+bpf_(cmd|map_type|prog_type|attach_type)+\s*{', line)
if match:
# Start of a new enum # Start of a new enum
inEnum = True inEnum = True
enumName = 'bpf_delegate_' + match[1] enumName = 'bpf_delegate_' + match[1]

View File

@ -373,7 +373,7 @@ int bus_machine_method_open_shell(sd_bus_message *message, void *userdata, sd_bu
* do not need to check the caller's uid, as that will be checked by polkit, and if they machine's * do not need to check the caller's uid, as that will be checked by polkit, and if they machine's
* and the caller's do not match, authorization will be required. It's only the case where the * and the caller's do not match, authorization will be required. It's only the case where the
* caller owns the machine that will be shortcut and needs to be checked here. */ * caller owns the machine that will be shortcut and needs to be checked here. */
if (m->manager->runtime_scope != RUNTIME_SCOPE_USER && m->uid != 0 && m->class != MACHINE_HOST) { if (m->uid != 0 && m->class != MACHINE_HOST) {
r = pidref_in_same_namespace(&PIDREF_MAKE_FROM_PID(1), &m->leader, NAMESPACE_USER); r = pidref_in_same_namespace(&PIDREF_MAKE_FROM_PID(1), &m->leader, NAMESPACE_USER);
if (r < 0) if (r < 0)
return log_debug_errno( return log_debug_errno(

View File

@ -260,7 +260,7 @@ int pcrextend_verity_now(
if (r < 0) if (r < 0)
return r; return r;
_cleanup_(sd_varlink_unrefp) sd_varlink *vl = NULL; _cleanup_free_ sd_varlink *vl = NULL;
r = sd_varlink_connect_address(&vl, "/run/systemd/io.systemd.PCRExtend"); r = sd_varlink_connect_address(&vl, "/run/systemd/io.systemd.PCRExtend");
if (r < 0) if (r < 0)
return r; return r;

View File

@ -85,7 +85,7 @@
typedef enum TpmStateMode { typedef enum TpmStateMode {
TPM_STATE_OFF, /* keep no state around */ TPM_STATE_OFF, /* keep no state around */
TPM_STATE_AUTO, /* keep state around if not ephemeral, derive path from image/directory */ TPM_STATE_AUTO, /* keep state around, derive path from image/directory */
TPM_STATE_PATH, /* explicitly specified location */ TPM_STATE_PATH, /* explicitly specified location */
_TPM_STATE_MODE_MAX, _TPM_STATE_MODE_MAX,
_TPM_STATE_MODE_INVALID = -EINVAL, _TPM_STATE_MODE_INVALID = -EINVAL,
@ -2569,7 +2569,7 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
_cleanup_free_ char *swtpm = NULL; _cleanup_free_ char *swtpm = NULL;
if (arg_tpm != 0) { if (arg_tpm != 0) {
if (arg_tpm_state_mode == TPM_STATE_AUTO && !arg_ephemeral) { if (arg_tpm_state_mode == TPM_STATE_AUTO) {
assert(!arg_tpm_state_path); assert(!arg_tpm_state_path);
const char *p = ASSERT_PTR(arg_image ?: arg_directory); const char *p = ASSERT_PTR(arg_image ?: arg_directory);

View File

@ -17,7 +17,6 @@
# removes the device node. After creation and removal the result is checked # removes the device node. After creation and removal the result is checked
# against the expected value and the result is printed. # against the expected value and the result is printed.
import dataclasses
import functools import functools
import os import os
import pwd, grp import pwd, grp
@ -31,6 +30,7 @@ from pathlib import Path
from typing import Callable, Optional from typing import Callable, Optional
try: try:
import dataclasses # requires Python >= 3.7
import pytest import pytest
except ImportError as e: except ImportError as e:
print(str(e), file=sys.stderr) print(str(e), file=sys.stderr)

View File

@ -19,6 +19,11 @@ try:
except ImportError as e: except ImportError as e:
shlex_join = e shlex_join = e
try:
from shlex import quote as shlex_quote
except ImportError as e:
shlex_quote = e
class NoCommand(Exception): class NoCommand(Exception):
pass pass
@ -209,6 +214,9 @@ def subst_output(document, programlisting, stats, missing_version):
interface = programlisting.get('interface') interface = programlisting.get('interface')
argv = [f'{arguments.build_dir}/{executable}', f'--bus-introspect={interface}'] argv = [f'{arguments.build_dir}/{executable}', f'--bus-introspect={interface}']
if isinstance(shlex_join, Exception):
print(f'COMMAND: {" ".join(shlex_quote(arg) for arg in argv)}')
else:
print(f'COMMAND: {shlex_join(argv)}') print(f'COMMAND: {shlex_join(argv)}')
try: try:
@ -318,7 +326,7 @@ def main():
global arguments global arguments
arguments = parse_args() arguments = parse_args()
for item in (etree, shlex_join): for item in (etree, shlex_quote):
if isinstance(item, Exception): if isinstance(item, Exception):
print(item, file=sys.stderr) print(item, file=sys.stderr)
sys.exit(77 if arguments.test else 1) sys.exit(77 if arguments.test else 1)
@ -340,7 +348,7 @@ def main():
# Let's print all statistics at the end # Let's print all statistics at the end
mlen = max(len(page) for page in stats) mlen = max(len(page) for page in stats)
total = sum((item['stats'] for item in stats.values()), start=collections.Counter()) total = sum((item['stats'] for item in stats.values()), collections.Counter())
total = 'total', { "stats" : total, "modified" : False } total = 'total', { "stats" : total, "modified" : False }
modified = [] modified = []
classification = 'OUTDATED' if arguments.test else 'MODIFIED' classification = 'OUTDATED' if arguments.test else 'MODIFIED'