1
0
mirror of https://github.com/systemd/systemd synced 2025-10-08 21:24:45 +02:00

Compare commits

...

7 Commits

Author SHA1 Message Date
Yu Watanabe
4e6c50a5d4 core: add RestrictAddressFamilies=none to deny all address families
Closes #15753.
2021-04-19 11:47:08 +01:00
Luca Boccassi
8441993621
Merge pull request #19351 from keszybz/log-message-tweaks
Log message tweaks
2021-04-19 11:44:35 +01:00
Hans de Goede
189bde4a03 hwdb: Add accel orientation quirk for the Teclast Tbook 11 tablet
Add a quirk to fix the accelerometer orientation on the
Teclast Tbook 11 tablet.
2021-04-19 11:44:16 +01:00
Hans de Goede
e15c079010 60-autosuspend.hwdb: Add Sierra Wireless EM7345-LTE modem to autosuspend list
Add the Sierra Wireless EM7345-LTE modem to the list of USB devices which
can safely autosuspend. This helps the processor reach deaper PC# states
when idle.

This was tested on a ThinkPad8 tablet with such a modem builtin.
2021-04-19 11:43:38 +01:00
Zbigniew Jędrzejewski-Szmek
59e8042ecd basic/log: change error for unset errno to ESTRPIPE
EIO is used in other contexts, so change ot something otherwise unused.
ENOTRECOVERABLE was also suggested, but it's used in various other places
in the code.

https://github.com/systemd/systemd/pull/19317#discussion_r614887661
2021-04-19 08:46:19 +02:00
Zbigniew Jędrzejewski-Szmek
19cdcd5dca logind: tweak log message
https://github.com/systemd/systemd/pull/19317#pullrequestreview-637765222
2021-04-19 08:37:57 +02:00
Zbigniew Jędrzejewski-Szmek
092c05717c udev/cdrom_id: use random_u64_range() and tweak log messages
https://github.com/systemd/systemd/pull/19317#pullrequestreview-637765222
2021-04-19 08:37:39 +02:00
8 changed files with 56 additions and 35 deletions

View File

@ -55,6 +55,14 @@ usb:v0627p0001:*QEMU USB Mouse*
usb:v0627p0001:*QEMU USB Tablet* usb:v0627p0001:*QEMU USB Tablet*
ID_AUTOSUSPEND=1 ID_AUTOSUSPEND=1
#########################################
# Sierra Wireless
#########################################
# Sierra Wireless EM7345 4G LTE modem
usb:v1199pA001*
ID_AUTOSUSPEND=1
######################################### #########################################
# Wacom # Wacom
######################################### #########################################

View File

@ -735,6 +735,10 @@ sensor:modalias:acpi:KIOX020A*:dmi:*:svnTECLAST:pnF6Pro:*
ACCEL_MOUNT_MATRIX=0, 1, 0; 1, 0, 0; 0, 0, 1 ACCEL_MOUNT_MATRIX=0, 1, 0; 1, 0, 0; 0, 0, 1
ACCEL_LOCATION=base ACCEL_LOCATION=base
# Teclast Tbook 11 (E5A6)
sensor:modalias:acpi:KIOX000A*:dmi:*:svnTECLAST:pnTbooK11:*
ACCEL_MOUNT_MATRIX=1, 0, 0; 0, -1, 0; 0, 0, 1
# Teclast X80 Plus (H5C5) # Teclast X80 Plus (H5C5)
sensor:modalias:acpi:KIOX000A*:dmi:*:svnTECLAST:pnDefaultstring:* sensor:modalias:acpi:KIOX000A*:dmi:*:svnTECLAST:pnDefaultstring:*
ACCEL_MOUNT_MATRIX=0, 1, 0; 1, 0, 0; 0, 0, 1 ACCEL_MOUNT_MATRIX=0, 1, 0; 1, 0, 0; 0, 0, 1

View File

@ -1777,11 +1777,13 @@ BindReadOnlyPaths=/var/lib/systemd</programlisting>
<term><varname>RestrictAddressFamilies=</varname></term> <term><varname>RestrictAddressFamilies=</varname></term>
<listitem><para>Restricts the set of socket address families accessible to the processes of this <listitem><para>Restricts the set of socket address families accessible to the processes of this
unit. Takes a space-separated list of address family names to allow-list, such as unit. Takes <literal>none</literal>, or a space-separated list of address family names to
<constant>AF_UNIX</constant>, <constant>AF_INET</constant> or <constant>AF_INET6</constant>. When allow-list, such as <constant>AF_UNIX</constant>, <constant>AF_INET</constant> or
prefixed with <constant>~</constant> the listed address families will be applied as deny list, <constant>AF_INET6</constant>. When <literal>none</literal> is specified, then all address
otherwise as allow list. Note that this restricts access to the <citerefentry families will be denied. When prefixed with <literal>~</literal> the listed address
project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>2</manvolnum></citerefentry> families will be applied as deny list, otherwise as allow list. Note that this restricts access
to the
<citerefentry project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>2</manvolnum></citerefentry>
system call only. Sockets passed into the process by other means (for example, by using socket system call only. Sockets passed into the process by other means (for example, by using socket
activation with socket units, see activation with socket units, see
<citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>) <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>)

View File

@ -195,7 +195,7 @@ void log_assert_failed_return(
_e = (log_get_max_level() >= LOG_PRI(_level)) \ _e = (log_get_max_level() >= LOG_PRI(_level)) \
? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \ ? log_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, __VA_ARGS__) \
: -ERRNO_VALUE(_e); \ : -ERRNO_VALUE(_e); \
_e < 0 ? _e : -EIO; \ _e < 0 ? _e : -ESTRPIPE; \
}) })
#if BUILD_MODE_DEVELOPER && !defined(TEST_CODE) #if BUILD_MODE_DEVELOPER && !defined(TEST_CODE)

View File

@ -2379,8 +2379,8 @@ int bus_exec_context_set_transient_property(
return 1; return 1;
} else if (streq(name, "RestrictAddressFamilies")) { } else if (streq(name, "RestrictAddressFamilies")) {
int allow_list;
_cleanup_strv_free_ char **l = NULL; _cleanup_strv_free_ char **l = NULL;
int allow_list;
r = sd_bus_message_enter_container(message, 'r', "bas"); r = sd_bus_message_enter_container(message, 'r', "bas");
if (r < 0) if (r < 0)
@ -2403,10 +2403,11 @@ int bus_exec_context_set_transient_property(
char **s; char **s;
if (strv_isempty(l)) { if (strv_isempty(l)) {
c->address_families_allow_list = false; c->address_families_allow_list = allow_list;
c->address_families = set_free(c->address_families); c->address_families = set_free(c->address_families);
unit_write_settingf(u, flags, name, "RestrictAddressFamilies="); unit_write_settingf(u, flags, name, "RestrictAddressFamilies=%s",
allow_list ? "none" : "");
return 1; return 1;
} }
@ -2430,7 +2431,7 @@ int bus_exec_context_set_transient_property(
if (r < 0) if (r < 0)
return r; return r;
} else } else
(void) set_remove(c->address_families, INT_TO_PTR(af)); set_remove(c->address_families, INT_TO_PTR(af));
} }
joined = strv_join(l, " "); joined = strv_join(l, " ");

View File

@ -3437,6 +3437,13 @@ int config_parse_address_families(
return 0; return 0;
} }
if (streq(rvalue, "none")) {
/* Forbid all address families. */
c->address_families = set_free(c->address_families);
c->address_families_allow_list = true;
return 0;
}
if (rvalue[0] == '~') { if (rvalue[0] == '~') {
invert = true; invert = true;
rvalue++; rvalue++;

View File

@ -268,7 +268,7 @@ static int manager_enumerate_seats(Manager *m) {
s = hashmap_get(m->seats, de->d_name); s = hashmap_get(m->seats, de->d_name);
if (!s) { if (!s) {
if (unlinkat(dirfd(d), de->d_name, 0) < 0) if (unlinkat(dirfd(d), de->d_name, 0) < 0)
log_warning_errno(errno, "Failed to remove /run/systemd/seats/%s: %m", log_warning_errno(errno, "Failed to remove /run/systemd/seats/%s, ignoring: %m",
de->d_name); de->d_name);
continue; continue;
} }

View File

@ -308,17 +308,16 @@ static int cd_media_compat(Context *c) {
r = ioctl(c->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT); r = ioctl(c->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
if (r < 0) if (r < 0)
return log_debug_errno(errno, "ioctl(CDROM_DRIVE_STATUS) failed: m"); return log_debug_errno(errno, "ioctl(CDROM_DRIVE_STATUS) failed: %m");
if (r != CDS_DISC_OK) { if (r != CDS_DISC_OK)
log_debug("ioctl(CDROM_DRIVE_STATUS) → %d (%s), ignoring", log_debug_errno(SYNTHETIC_ERRNO(ENOMEDIUM),
"ioctl(CDROM_DRIVE_STATUS) → %d (%s), ignoring.",
r, r,
r == CDS_NO_INFO ? "no info" : r == CDS_NO_INFO ? "no info" :
r == CDS_NO_DISC ? "no disc" : r == CDS_NO_DISC ? "no disc" :
r == CDS_TRAY_OPEN ? "tray open" : r == CDS_TRAY_OPEN ? "tray open" :
r == CDS_DRIVE_NOT_READY ? "drive not ready" : r == CDS_DRIVE_NOT_READY ? "drive not ready" :
"unkown status"); "unkown status");
return -ENOMEDIUM;
}
c->has_media = true; c->has_media = true;
return 0; return 0;
@ -340,7 +339,7 @@ static int cd_inquiry(Context *c) {
return r; return r;
if ((inq[0] & 0x1F) != 5) if ((inq[0] & 0x1F) != 5)
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Not an MMC unit"); return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Not an MMC unit.");
log_debug("INQUIRY: [%.8s][%.16s][%.4s]", inq + 8, inq + 16, inq + 32); log_debug("INQUIRY: [%.8s][%.16s][%.4s]", inq + 8, inq + 16, inq + 32);
return 0; return 0;
@ -450,7 +449,7 @@ static int cd_profiles(Context *c) {
log_debug("GET CONFIGURATION: size of features buffer %zu", len); log_debug("GET CONFIGURATION: size of features buffer %zu", len);
if (len > sizeof(features)) { if (len > sizeof(features)) {
log_debug("cannot get features in a single query, truncating"); log_debug("Cannot get features in a single query, truncating.");
len = sizeof(features); len = sizeof(features);
} else if (len <= 8) } else if (len <= 8)
len = sizeof(features); len = sizeof(features);
@ -470,7 +469,7 @@ static int cd_profiles(Context *c) {
log_debug("GET CONFIGURATION: size of features buffer %zu", len); log_debug("GET CONFIGURATION: size of features buffer %zu", len);
if (len > sizeof(features)) { if (len > sizeof(features)) {
log_debug("cannot get features in a single query, truncating"); log_debug("Cannot get features in a single query, truncating.");
len = sizeof(features); len = sizeof(features);
} }
@ -529,7 +528,7 @@ static int dvd_ram_media_update_state(Context *c) {
if (dvdstruct[4] & 0x02) { if (dvdstruct[4] & 0x02) {
c->media_state = MEDIA_STATE_COMPLETE; c->media_state = MEDIA_STATE_COMPLETE;
log_debug("write-protected DVD-RAM media inserted"); log_debug("Write-protected DVD-RAM media inserted");
return 1; return 1;
} }
@ -545,24 +544,24 @@ static int dvd_ram_media_update_state(Context *c) {
len = format[3]; len = format[3];
if (len & 7 || len < 16) if (len & 7 || len < 16)
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
"invalid format capacities length"); "Invalid format capacities length.");
switch(format[8] & 3) { switch(format[8] & 3) {
case 1: case 1:
/* This means that last format was interrupted or failed, blank dvd-ram discs are /* This means that last format was interrupted or failed, blank dvd-ram discs are
* factory formatted. Take no action here as it takes quite a while to reformat a * factory formatted. Take no action here as it takes quite a while to reformat a
* dvd-ram and it's not automatically started. */ * dvd-ram and it's not automatically started. */
log_debug("unformatted DVD-RAM media inserted"); log_debug("Unformatted DVD-RAM media inserted.");
return 1; return 1;
case 2: case 2:
log_debug("formatted DVD-RAM media inserted"); log_debug("Formatted DVD-RAM media inserted.");
return 0; return 0;
case 3: case 3:
c->has_media = false; c->has_media = false;
return log_debug_errno(SYNTHETIC_ERRNO(ENOMEDIUM), return log_debug_errno(SYNTHETIC_ERRNO(ENOMEDIUM),
"format capacities returned no media"); "Format capacities returned no media.");
} }
return 0; return 0;
@ -599,17 +598,17 @@ static int dvd_media_update_state(Context *c) {
for (size_t offset = 32768; offset < 32768 + 2048; offset++) for (size_t offset = 32768; offset < 32768 + 2048; offset++)
if (buffer[offset] != 0) { if (buffer[offset] != 0) {
log_debug("data in block 16, assuming complete"); log_debug("Data in block 16, assuming complete.");
return 0; return 0;
} }
for (size_t offset = 0; offset < 2048; offset++) for (size_t offset = 0; offset < 2048; offset++)
if (buffer[offset] != 0) { if (buffer[offset] != 0) {
log_debug("data in block 0, assuming complete"); log_debug("Data in block 0, assuming complete.");
return 0; return 0;
} }
log_debug("no data in blocks 0 or 16, assuming blank"); log_debug("No data in blocks 0 or 16, assuming blank.");
c->media_state = MEDIA_STATE_BLANK; c->media_state = MEDIA_STATE_BLANK;
return 0; return 0;
} }
@ -755,7 +754,7 @@ static int open_drive(Context *c) {
if (++cnt >= 20 || errno != EBUSY) if (++cnt >= 20 || errno != EBUSY)
return log_debug_errno(errno, "Unable to open '%s': %m", arg_node); return log_debug_errno(errno, "Unable to open '%s': %m", arg_node);
(void) usleep(100 * USEC_PER_MSEC + random_u64() % (100 * USEC_PER_MSEC)); (void) usleep(100 * USEC_PER_MSEC + random_u64_range(100 * USEC_PER_MSEC));
} }
log_debug("probing: '%s'", arg_node); log_debug("probing: '%s'", arg_node);
@ -831,7 +830,7 @@ static void print_feature(Feature feature, const char *prefix) {
found = typesafe_bsearch(&in, feature_to_string, ELEMENTSOF(feature_to_string), feature_to_string_compare_func); found = typesafe_bsearch(&in, feature_to_string, ELEMENTSOF(feature_to_string), feature_to_string_compare_func);
if (!found) if (!found)
return (void) log_debug("Unknown feature 0x%02x, ignoring", (unsigned) feature); return (void) log_debug("Unknown feature 0x%02x, ignoring.", (unsigned) feature);
printf("%s_%s=1\n", prefix, found->str); printf("%s_%s=1\n", prefix, found->str);
} }