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

Compare commits

...

30 Commits

Author SHA1 Message Date
howl
84e492cdba Unify pn81H3 and cvrLenovoideapadD330-10IGM
D330-10IGM has been added due the fact that 81H3 and 81MD product name belongs to the same product version. So the fact is that now that we know 81MD has the same transformation matrix that the 81H3 we can just use the product version and get rid the product name.

Signed-off-by: David Santamaría Rogado <howl.nsp@gmail.com>
2021-05-06 11:13:48 +02:00
Phaedrus Leeds
00473ac804 docs: Fix typos in PORTABLE_SERVICES.md 2021-05-06 16:01:23 +09:00
Yu Watanabe
3d396b2837 test: drop log_trace() in test-random-util
It provides almost no inoformation. Moreover, it massively increases
logs, and firefox cannot show the results of Ubuntu CIs due to this.
2021-05-06 12:46:31 +09:00
Yu Watanabe
d8c1422439
Merge pull request #19515 from keszybz/config-parser-crash-fix
Fix crashes in config parsing
2021-05-06 12:46:13 +09:00
Yu Watanabe
d6eaee6e74
Merge pull request #19514 from keszybz/return-UnitNameFlags-more
Return UnitNameFlags from unit_name_to_instance()
2021-05-06 12:46:00 +09:00
Yu Watanabe
5971630cf6
Merge pull request #19513 from takaswie/topic/ieee1394-hwdb-entries-for-video
hwdb: ieee1394-unit-function: add entries to obsolete existent udev rules for video function
2021-05-06 12:45:05 +09:00
Yu Watanabe
f0373df1a7
Merge pull request #19507 from nabijaczleweli/bootctlpsko-lite
bootctl: take --make-machine-id-directory=yes|no|auto and make/remove \$MACHINE_ID accordingly
2021-05-06 12:44:21 +09:00
Frantisek Sumsal
c191e09230 ci: cover standalone/static binaries in build test 2021-05-06 11:52:58 +09:00
Zbigniew Jędrzejewski-Szmek
52a89a5f08 sd-device: reject empty driver name
If ":" was the last char in the string, we would call access() on ".../drivers/", which
would pass. It probably doesn't matter, but let's reject this anyway.
2021-05-05 17:15:04 +02:00
Zbigniew Jędrzejewski-Szmek
3e2d0c6ab2 sd-device: use memdupa_suffix0() where appropriate
No functional change intended.
2021-05-05 17:15:04 +02:00
Zbigniew Jędrzejewski-Szmek
e17c95af8e sd-device: do no allocate strings of unknown length on the stack
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33881.

Not only we would duplicate unknown input on the stack, we would do it
over and over. So let's first check that the input has reasonable length,
but also allocate just one fixed size buffer.
2021-05-05 17:15:04 +02:00
Zbigniew Jędrzejewski-Szmek
7ecb052fb3 fuzz-journald-kmsg: silence output as usual 2021-05-05 17:15:04 +02:00
Zbigniew Jędrzejewski-Szmek
3968ccd0cd core: fix crash in BPFProgram parsing
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33270.
2021-05-05 17:15:04 +02:00
Zbigniew Jędrzejewski-Szmek
07b3075fad basic/log: use SYNTHETIC_ERRNO in one more place 2021-05-05 17:15:04 +02:00
Zbigniew Jędrzejewski-Szmek
a687f50009 core: use the same pattern for extract_first_word() checks
No functional change, but there is no reason to write it too verbosely
or in different orders.
2021-05-05 17:15:04 +02:00
Zbigniew Jędrzejewski-Szmek
d762abece9 core: fix potential crash in BPFProgram= 2021-05-05 17:15:04 +02:00
Zbigniew Jędrzejewski-Szmek
cc87b3f68f core: fix crash in parsing of SocketBind{Allow,Deny}=
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33876.
2021-05-05 17:14:58 +02:00
Takashi Sakamoto
ecd64ffafd udev: uaccess: remove ID_FFADO entry
The ID_FFADO environment variable comes from external FFADO project.
Now we have comprehensive and self-contained rules instead of it.
Let's remove it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2021-05-05 23:10:29 +09:00
Takashi Sakamoto
e51d5b9c8a hwdb: ieee1394-unit-function: add entry for AV/C device with vendor unique command set
In IEC 61883-1:1998, we can see some values for AV/C device with vendor
unique command set in IEC 61883-1:1998. Current udev rule handles it
for video. However it brings an issue that the functions in AV/C device
are not distinguished just by the content of configuration ROM.

In former commit, hardware database was added to describe function type
of unit in the node, then udev rules are added to utilize the database.

However, we have an request to obsolete existent udev rules by putting
enough entries to the database. It should be done carefully.

This commit adds entry into hardware database just for backward
compatibility. The entry can match to some node and unit unexpectedly.
Therefore this commit modifies existent entries to invalidate the effect
from added entry.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2021-05-05 23:10:29 +09:00
Takashi Sakamoto
002f6e92af hwdb: ieee1394-unit-function: add entry for AV/C device with generic AV/C command set
Typical node of AV/C device has standard content of configuration ROM.
This is defined in documentation of 1394 Trading Association.

 * Configuration ROM for AV/C Devices 1.0 (Dec. 12, 2000, 1394 Trading
   Association, TA Document 1999027)

However, it brings an issue that the functions in AV/C device are not
distinguished just by the content of configuration ROM.

In former commit, hardware database was added to describe function type
of unit in the node, then udev rules are added to utilize the database.

However, we have an request to obsolete existent udev rules by putting
enough entries to the database. It should be done carefully.

This commit adds entry into hardware database just for backward
compatibility. The entry can match to some node and unit unexpectedly.
Therefore this commit modifies existent entries to invalidate the effect
from added entry.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2021-05-05 23:10:29 +09:00
Takashi Sakamoto
fae95d9ff5 hwdb: ieee1394-unit-function: remove entry for Cool Stream iSweet
IIDC specification describes configuration ROM without model field, thus
it's not possible to match any entry with vendor ID and model ID.
Current entry for Cool Stream iSweet can match any node and unit of
IIDC.

This commit removes the entry. I note that this model uses Texus
Instruments MC680-DCC as all-in-one chipset for video function in
IEEE 1394 bus.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2021-05-05 23:10:29 +09:00
Takashi Sakamoto
70fb7e5da5 hwdb: ieee1394-unit-function: add entries for Point Grey cameras
Point Grey Research, inc. shipped cameras to support IIDC, however some
of them are necessarily compliant to IIDC specification in terms of the
value of software version field in unit directory of configuration ROM.

This commit adds entries for them.

Reviewed-by: Damien Douxchamps <damien@douxchamps.net>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2021-05-05 23:10:29 +09:00
Takashi Sakamoto
78eb99c496 hwdb: ieee1394-unit-function: add IIDC generic entries
Instrumentation & Industrial Digital Camera (IIDC) specifications are
defined by 1394 Trading Association for camera device in IEEE 1394 bus.
IIDC2 specifications are defined by joint working group between Japan
Industrial Imaging Association (JIIA) and 1394 Trade Association as
bus-independent specification.

This commit adds entries for the specifications to remove existent udev
rules. Supported specifications are listed below:

 * 1394-based Digital Camera Specification Version 1.04 (Aug. 9, 1996,
   1394 Trading Association)
 * 1394-based Digital Camera Specification Version 1.20 (Jul. 23, 1998,
   1394 Trading Association)
 * IIDC Digital Camera Control Specification Ver.1.30 (Jul. 25, 2000,
   1394 Trading Association)
 * IIDC Digital Camera Control Specification Ver.1.31 (Feb. 2, 2004,
   1394 Trading Association, TA Document 2003017)
 * IIDC Digital Camera Control Specification Ver.1.32 (Jul. 24, 2008,
   1394 Trading Association, Document number 2007009)
 * IIDC2 Digital Camera Control Specification Ver.1.0.0 (Jan 26th, 2012,
   1394 Trading Association, TS2011001)
 * IIDC2 Digital Camera Control Specification Ver.1.1.0 (May 19th, 2015,
   1394 Trading Association, TS2015001)

Reviewed-by: Damien Douxchamps <damien@douxchamps.net>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2021-05-05 23:10:29 +09:00
Takashi Sakamoto
cc447b33f6 hwdb: ieee1394-unit-function: add entries for Digital Everywhere FloppyDTV and FireDTV
Linux kernel has firedtv kernel module as driver for Digital Everywhere
FloppyDTV and FireDTV. Although this driver works without any help of
userspace application, it's better to add entries to hardware database
for developer's convenience.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2021-05-05 23:10:29 +09:00
Takashi Sakamoto
a9c6f9b8a6 hwdb: ieee1394-unit-function: fix indentation
Zbigniew Jędrzejewski-Szmek points that current entries are against the
convention of indentation. It should be indented by one space instead of
two.

This commit fixes current entries according to it.

Reported-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fixes: 1b6d9a05b14a ("hwdb: add database entries for models with ASICs in BeBoB solution")
Fixes: 0db0564e957f ("hwdb: add database entries for models with Fireworks board module")
Fixes: 38338b302cb0 ("hwdb: add database entries for models with OXFW970/971 ASICs")
Fixes: c0d8b61f9385 ("hwdb: add database entries for models based on DICE ASICs with TCAT specification")
Fixes: a774b5099bce ("hwdb: add database entries for models based on DICE ASICs specialized to M-Audio")
Fixes: ff1cb7b9393a ("hwdb: add database entries for models based on DICE ASICs specialized to Weiss Engineering")
Fixes: 6f44dddbe20a ("hwdb: add database entries for models based on DICE ASICs specialized by Loud Technologies")
Fixes: 49ed0aad525b ("hwdb: add database entries for models based on DICE ASICs specialized by Harman Music Group")
Fixes: effbb4024b8b ("hwdb: add database entries for models based on DICE ASICs specialized by Solid State Logic")
Fixes: 4aaa093b5fb6 ("hwdb: add database entries for models of Digidesign Digi 00x family")
Fixes: c489e7f9d3c4 ("hwdb: add database entries for Tascam FireWire series")
Fixes: 650b8967a57b ("hwdb: add database entries for MOTU FireWire series")
Fixes: 51e9242b9b91 ("hwdb: add database entries for RME Fireface series")
Fixes: a90a6a9ae9f8 ("hwdb: add database entries for Yamaha mLAN 2nd generation")
Fixes: 41f2d0d393a4 ("hwdb: add database entries for Yamaha mLAN 3rd generation")
Fixes: 1d2ee962922f ("hwdb: add database entries for Focusrite Liquid Mix series")
Fixes: 0c20543835d6 ("hwdb: add database entries for TC Electronic PowerCore FireWire series")
Fixes: 8b4b76dc5021 ("hwdb: add database entry for node with single unit with video function")
Fixes: 12dd2404bee8 ("hwdb: add database entries for node with multiple units")
Fixes: dece0357e1c8 ("hwdb: add database entries for node with single unit for multiple functions")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2021-05-05 23:10:29 +09:00
Takashi Sakamoto
5d66d89c42 hwdb: fix parser to execute test for ieee1394-unit-function with no argument
When given no arguments, hwdb parser script seeks test target files by
glob pattern. Although I added a new file for IEEE 1394 unit functions,
the file is excluded as test target due to the pattern.

This commit fixes it.

Fixes: 7713f3fc6a2 ("hwdb: add parser grammar for IEEE 1394 unit function list")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2021-05-05 23:10:29 +09:00
Zbigniew Jędrzejewski-Szmek
c9816a9ac4 basic/time-util: use _cleanup_ in one more place 2021-05-05 15:08:48 +02:00
Zbigniew Jędrzejewski-Szmek
73ce91a05a Make unit_name_to_instance() return UnitNameFlags
The function returns non-negative UnitNameFlags on success, and negative
errno on error. In the past we kept the return type as int because of those
negative return values. But nowadays _UNIT_NAME_INVALID == -EINVAL. And if
we tried to actually return something that doesn't fit in the return type,
the compiler would throw an error. By changing to the "real" return type,
we allow the debugger to use symbolic representation for the variables.
2021-05-05 15:08:48 +02:00
наб
6a3fff75ba
bootctl: take --make-machine-id-directory=yes|no|auto and make/remove \$MACHINE_ID accordingly
auto resolves to yes if /etc/machine-id resides on non-tmpfs

This effectively reverts commit 31e57550b552e113bd3d44355b237c41e42beb58
2021-05-05 14:35:00 +02:00
наб
2d94502724
meson: don't fail if latest tag's commit is signed
Today this is v248 with 938bdfc0fa737d86eb3ecc70506e11e5f740e0dc, which,
if you don't know about the github webflow key fails to configure with
  meson.build:724:8: ERROR:  String "gpg: Signature made Tue 30 Mar 2021 22:59:02 CEST\ngpg:                using RSA key 4AEE18F83AFDEB23\ngpg: Can't check signature: No public key\n1617137942\n" cannot be converted to int
or, if you do, with
  meson.build:724:8: ERROR:  String 'gpg: Signature made Tue 30 Mar 2021 22:59:02 CEST\ngpg:                using RSA key 4AEE18F83AFDEB23\ngpg: Good signature from "GitHub (web-flow commit signing) <noreply@github.com>" [unknown]\ngpg: WARNING: This key is not certified with a trusted signature!\ngpg:          There is no indication that the signature belongs to the owner.\nPrimary key fingerprint: 5DE3 E050 9C47 EA3C F04A  42D3 4AEE 18F8 3AFD EB23\n1617137942\n' cannot be converted to int
2021-05-04 20:08:59 +02:00
24 changed files with 989 additions and 734 deletions

View File

@ -13,6 +13,7 @@ ARGS=(
"--optimization=3 -Db_lto=true" "--optimization=3 -Db_lto=true"
"--optimization=3 -Db_lto=false" "--optimization=3 -Db_lto=false"
"--optimization=3 -Ddns-over-tls=openssl" "--optimization=3 -Ddns-over-tls=openssl"
"--optimization=3 -Dfexecve=true -Dstandalone-binaries=true -Dstatic-libsystemd=true -Dstatic-libudev=true"
"-Db_ndebug=true" "-Db_ndebug=true"
) )
PACKAGES=( PACKAGES=(

View File

@ -59,14 +59,14 @@ The "portable service" concept ultimately will not provide a fully isolated
environment to the payload, like containers mostly intend to. Instead they are environment to the payload, like containers mostly intend to. Instead they are
from the beginning more alike regular system services, can be controlled with from the beginning more alike regular system services, can be controlled with
the same tools, are exposed the same way in all infrastructure and so on. Their the same tools, are exposed the same way in all infrastructure and so on. Their
main difference is that the use a different root directory than the rest of the main difference is that they use a different root directory than the rest of the
system. Hence, the intention is not to run code in a different, isolated world system. Hence, the intention is not to run code in a different, isolated world
from the host — like most containers would do it —, but to run it in the same from the host — like most containers would do it — but to run it in the same
world, but with stricter access controls on what the service can see and do. world, but with stricter access controls on what the service can see and do.
As one point of differentiation: as programs run as "portable services" are As one point of differentiation: as programs run as "portable services" are
pretty much regular system services, they won't run as PID 1 (like Docker would pretty much regular system services, they won't run as PID 1 (like Docker would
do it), but as normal process. A corollary of that is that they aren't supposed do it), but as normal processes. A corollary of that is that they aren't supposed
to manage anything in their own environment (such as the network) as the to manage anything in their own environment (such as the network) as the
execution environment is mostly shared with the rest of the system. execution environment is mostly shared with the rest of the system.
@ -77,12 +77,12 @@ focus includes system extensions otherwise sometimes called "super-privileged
containers". containers".
Note that portable services are only available for system services, not for Note that portable services are only available for system services, not for
user services. i.e. the functionality cannot be used for the stuff user services (i.e. the functionality cannot be used for the stuff
bubblewrap/flatpak is focusing on. bubblewrap/flatpak is focusing on).
## Mode of Operation ## Mode of Operation
If you have portable service image, maybe in a raw disk image called If you have a portable service image, maybe in a raw disk image called
`foobar_0.7.23.raw`, then attaching the services to the host is as easy as: `foobar_0.7.23.raw`, then attaching the services to the host is as easy as:
``` ```
@ -135,7 +135,7 @@ This command does the following:
And that's already it. And that's already it.
Note that the images need to stay around (and the same location) as long as the Note that the images need to stay around (and in the same location) as long as the
portable service is attached. If an image is moved, the `RootImage=` line portable service is attached. If an image is moved, the `RootImage=` line
written to the unit drop-in would point to an non-existing place, and break the written to the unit drop-in would point to an non-existing place, and break the
logic. logic.
@ -144,7 +144,7 @@ The `portablectl detach` command executes the reverse operation: it looks for
the drop-ins and the unit files associated with the image, and removes them the drop-ins and the unit files associated with the image, and removes them
again. again.
Note that `portable attach` won't enable or start any of the units it copies Note that `portablectl attach` won't enable or start any of the units it copies
out. This still has to take place in a second, separate step. (That said We out. This still has to take place in a second, separate step. (That said We
might add options to do this automatically later on.). might add options to do this automatically later on.).
@ -223,7 +223,7 @@ read-only, immutable images (e.g. squashfs images) all files and directories to
over-mount must exist already. over-mount must exist already.
Note that as no new image format or metadata is defined, it's very Note that as no new image format or metadata is defined, it's very
straight-forward to define images than can be made use of it a number of straightforward to define images than can be made use of in a number of
different ways. For example, by using `mkosi -b` you can trivially build a different ways. For example, by using `mkosi -b` you can trivially build a
single, unified image that: single, unified image that:

View File

@ -505,8 +505,7 @@ sensor:modalias:acpi:BMA250E*:dmi:bvnLENOVO:*:pvrLenovoMIIX3-1030:*
sensor:modalias:acpi:SMO8500*:dmi:bvnLENOVO:*:pvrLenovoMIIX3-830:* sensor:modalias:acpi:SMO8500*:dmi:bvnLENOVO:*:pvrLenovoMIIX3-830:*
ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, 1, 0; 0, 0, 1 ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, 1, 0; 0, 0, 1
# IdeaPad D330 and D330-10IGM # IdeaPad D330-10IGM (both 81H3 and 81MD product numbers)
sensor:modalias:acpi:BOSC0200*:dmi:*:svnLENOVO:pn81H3:*
sensor:modalias:acpi:BOSC0200*:dmi:*:svnLENOVO:*:cvrLenovoideapadD330-10IGM:* sensor:modalias:acpi:BOSC0200*:dmi:*:svnLENOVO:*:cvrLenovoideapadD330-10IGM:*
ACCEL_MOUNT_MATRIX=0, 1, 0; -1, 0, 0; 0, 0, 1 ACCEL_MOUNT_MATRIX=0, 1, 0; -1, 0, 0; 0, 0, 1

File diff suppressed because it is too large Load Diff

View File

@ -301,7 +301,7 @@ def print_summary(fname, groups):
error('{}: no matches or props'.format(fname)) error('{}: no matches or props'.format(fname))
if __name__ == '__main__': if __name__ == '__main__':
args = sys.argv[1:] or sorted(glob.glob(os.path.dirname(sys.argv[0]) + '/[67][0-9]-*.hwdb')) args = sys.argv[1:] or sorted(glob.glob(os.path.dirname(sys.argv[0]) + '/[678][0-9]-*.hwdb'))
for fname in args: for fname in args:
groups = parse(fname) groups = parse(fname)

View File

@ -237,6 +237,19 @@
cannot be written. Currently only applies to random seed operations.</para></listitem> cannot be written. Currently only applies to random seed operations.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>--make-machine-id-directory=yes|no|auto</option></term>
<listitem><para>Control creation and deletion of <literal>$ESP/$MACHINE_ID</literal> during
<option>install</option> and <option>remove</option>, respectively.
<literal>auto</literal> is equivalent to to <literal>yes</literal> if <literal>/etc/machine-id</literal>
resides on a filesystem other than tmpfs and <literal>no</literal> otherwise.
Defaults to <literal>auto</literal>.</para>
<para>Overriding this may be desired to hide the machine ID from the (unencrypted) ESP,
configure a <citerefentry><refentrytitle>kernel-install</refentrytitle><manvolnum>8</manvolnum></citerefentry> script, or,
conversely, commit a machine-id that only appears transient.</para></listitem>
</varlistentry>
<xi:include href="standard-options.xml" xpointer="no-pager"/> <xi:include href="standard-options.xml" xpointer="no-pager"/>
<xi:include href="standard-options.xml" xpointer="help"/> <xi:include href="standard-options.xml" xpointer="help"/>
<xi:include href="standard-options.xml" xpointer="version"/> <xi:include href="standard-options.xml" xpointer="version"/>

View File

@ -722,7 +722,7 @@ if time_epoch == -1
if time_epoch == '' and git.found() and run_command('test', '-e', '.git').returncode() == 0 if time_epoch == '' and git.found() and run_command('test', '-e', '.git').returncode() == 0
# If we're in a git repository, use the creation time of the latest git tag. # If we're in a git repository, use the creation time of the latest git tag.
latest_tag = run_command('git', 'describe', '--abbrev=0', '--tags').stdout().strip() latest_tag = run_command('git', 'describe', '--abbrev=0', '--tags').stdout().strip()
time_epoch = run_command('git', 'log', '-1', '--format=%at', latest_tag).stdout() time_epoch = run_command('git', 'log', '--no-show-signature', '-1', '--format=%at', latest_tag).stdout()
endif endif
if time_epoch == '' if time_epoch == ''
NEWS = files('NEWS') NEWS = files('NEWS')

View File

@ -49,11 +49,6 @@ SUBSYSTEM=="sound", GROUP="audio", \
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0664" SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0664"
SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x00010*", GROUP="video"
SUBSYSTEM=="firewire", ATTR{units}=="*0x00b09d:0x00010*", GROUP="video"
SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x010001*", GROUP="video"
SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x014001*", GROUP="video"
SUBSYSTEM=="firewire", TEST=="units", TEST=="model", \ SUBSYSTEM=="firewire", TEST=="units", TEST=="model", \
IMPORT{builtin}="hwdb 'ieee1394:node:ven$attr{vendor}mo$attr{model}units$attr{units}'" IMPORT{builtin}="hwdb 'ieee1394:node:ven$attr{vendor}mo$attr{model}units$attr{units}'"

View File

@ -1431,10 +1431,9 @@ int log_syntax_invalid_utf8_internal(
if (rvalue) if (rvalue)
p = utf8_escape_invalid(rvalue); p = utf8_escape_invalid(rvalue);
log_syntax_internal(unit, level, config_file, config_line, 0, file, line, func, return log_syntax_internal(unit, level, config_file, config_line,
"String is not UTF-8 clean, ignoring assignment: %s", strna(p)); SYNTHETIC_ERRNO(EINVAL), file, line, func,
"String is not UTF-8 clean, ignoring assignment: %s", strna(p));
return -EINVAL;
} }
void log_set_upgrade_syslog_to_journal(bool b) { void log_set_upgrade_syslog_to_journal(bool b) {

View File

@ -1278,8 +1278,8 @@ int get_timezones(char ***ret) {
f = fopen("/usr/share/zoneinfo/zone1970.tab", "re"); f = fopen("/usr/share/zoneinfo/zone1970.tab", "re");
if (f) { if (f) {
for (;;) { for (;;) {
_cleanup_free_ char *line = NULL; _cleanup_free_ char *line = NULL, *w = NULL;
char *p, *w; char *p;
size_t k; size_t k;
r = read_line(f, LONG_LINE_MAX, &line); r = read_line(f, LONG_LINE_MAX, &line);
@ -1310,12 +1310,10 @@ int get_timezones(char ***ret) {
if (!w) if (!w)
return -ENOMEM; return -ENOMEM;
if (!GREEDY_REALLOC(zones, n_allocated, n_zones + 2)) { if (!GREEDY_REALLOC(zones, n_allocated, n_zones + 2))
free(w);
return -ENOMEM; return -ENOMEM;
}
zones[n_zones++] = w; zones[n_zones++] = TAKE_PTR(w);
zones[n_zones] = NULL; zones[n_zones] = NULL;
} }

View File

@ -72,7 +72,7 @@ int unit_validate_alias_symlink_and_warn(const char *filename, const char *targe
const char *src, *dst; const char *src, *dst;
_cleanup_free_ char *src_instance = NULL, *dst_instance = NULL; _cleanup_free_ char *src_instance = NULL, *dst_instance = NULL;
UnitType src_unit_type, dst_unit_type; UnitType src_unit_type, dst_unit_type;
int src_name_type, dst_name_type; UnitNameFlags src_name_type, dst_name_type;
/* Check if the *alias* symlink is valid. This applies to symlinks like /* Check if the *alias* symlink is valid. This applies to symlinks like
* /etc/systemd/system/dbus.service dbus-broker.service, but not to .wants or .requires symlinks * /etc/systemd/system/dbus.service dbus-broker.service, but not to .wants or .requires symlinks

View File

@ -139,7 +139,7 @@ int unit_name_to_prefix(const char *n, char **ret) {
return 0; return 0;
} }
int unit_name_to_instance(const char *n, char **ret) { UnitNameFlags unit_name_to_instance(const char *n, char **ret) {
const char *p, *d; const char *p, *d;
assert(n); assert(n);

View File

@ -22,8 +22,8 @@ bool unit_instance_is_valid(const char *i) _pure_;
bool unit_suffix_is_valid(const char *s) _pure_; bool unit_suffix_is_valid(const char *s) _pure_;
int unit_name_to_prefix(const char *n, char **ret); int unit_name_to_prefix(const char *n, char **ret);
int unit_name_to_instance(const char *n, char **ret); UnitNameFlags unit_name_to_instance(const char *n, char **ret);
static inline int unit_name_classify(const char *n) { static inline UnitNameFlags unit_name_classify(const char *n) {
return unit_name_to_instance(n, NULL); return unit_name_to_instance(n, NULL);
} }
int unit_name_to_prefix_and_instance(const char *n, char **ret); int unit_name_to_prefix_and_instance(const char *n, char **ret);

View File

@ -29,6 +29,7 @@
#include "main-func.h" #include "main-func.h"
#include "mkdir.h" #include "mkdir.h"
#include "pager.h" #include "pager.h"
#include "parse-argument.h"
#include "parse-util.h" #include "parse-util.h"
#include "pretty-print.h" #include "pretty-print.h"
#include "random-util.h" #include "random-util.h"
@ -52,6 +53,7 @@ static bool arg_print_dollar_boot_path = false;
static bool arg_touch_variables = true; static bool arg_touch_variables = true;
static PagerFlags arg_pager_flags = 0; static PagerFlags arg_pager_flags = 0;
static bool arg_graceful = false; static bool arg_graceful = false;
static int arg_make_machine_id_directory = -1;
STATIC_DESTRUCTOR_REGISTER(arg_esp_path, freep); STATIC_DESTRUCTOR_REGISTER(arg_esp_path, freep);
STATIC_DESTRUCTOR_REGISTER(arg_xbootldr_path, freep); STATIC_DESTRUCTOR_REGISTER(arg_xbootldr_path, freep);
@ -112,6 +114,19 @@ static int acquire_xbootldr(bool unprivileged_mode, sd_id128_t *ret_uuid) {
return 1; return 1;
} }
static void settle_make_machine_id_directory(void) {
int r;
if (arg_make_machine_id_directory >= 0)
return;
r = path_is_temporary_fs("/etc/machine-id");
if (r < 0)
log_debug_errno(r, "Couldn't determine whether /etc/machine-id is on a temporary file system, assuming so.");
arg_make_machine_id_directory = r == 0;
}
/* search for "#### LoaderInfo: systemd-boot 218 ####" string inside the binary */ /* search for "#### LoaderInfo: systemd-boot 218 ####" string inside the binary */
static int get_file_version(int fd, char **v) { static int get_file_version(int fd, char **v) {
struct stat st; struct stat st;
@ -888,6 +903,24 @@ static int remove_subdirs(const char *root, const char *const *subdirs) {
return r < 0 ? r : q; return r < 0 ? r : q;
} }
static int remove_machine_id_directory(const char *root) {
sd_id128_t machine_id;
char buf[SD_ID128_STRING_MAX];
int r;
assert(root);
assert(arg_make_machine_id_directory >= 0);
if (!arg_make_machine_id_directory)
return 0;
r = sd_id128_get_machine(&machine_id);
if (r < 0)
return log_error_errno(r, "Failed to get machine id: %m");
return rmdir_one(root, sd_id128_to_string(machine_id, buf));
}
static int remove_binaries(const char *esp_path) { static int remove_binaries(const char *esp_path) {
const char *p; const char *p;
int r, q; int r, q;
@ -974,9 +1007,13 @@ static int install_loader_config(const char *esp_path) {
_cleanup_(unlink_and_freep) char *t = NULL; _cleanup_(unlink_and_freep) char *t = NULL;
_cleanup_fclose_ FILE *f = NULL; _cleanup_fclose_ FILE *f = NULL;
_cleanup_close_ int fd = -1; _cleanup_close_ int fd = -1;
sd_id128_t machine_id;
char machine_string[SD_ID128_STRING_MAX];
const char *p; const char *p;
int r; int r;
assert(arg_make_machine_id_directory >= 0);
p = prefix_roota(esp_path, "/loader/loader.conf"); p = prefix_roota(esp_path, "/loader/loader.conf");
if (access(p, F_OK) >= 0) /* Silently skip creation if the file already exists (early check) */ if (access(p, F_OK) >= 0) /* Silently skip creation if the file already exists (early check) */
return 0; return 0;
@ -991,6 +1028,13 @@ static int install_loader_config(const char *esp_path) {
fprintf(f, "#timeout 3\n" fprintf(f, "#timeout 3\n"
"#console-mode keep\n"); "#console-mode keep\n");
if (arg_make_machine_id_directory) {
r = sd_id128_get_machine(&machine_id);
if (r < 0)
return log_error_errno(r, "Failed to get machine id: %m");
fprintf(f, "default %s-*\n", sd_id128_to_string(machine_id, machine_string));
}
r = fflush_sync_and_check(f); r = fflush_sync_and_check(f);
if (r < 0) if (r < 0)
@ -1006,6 +1050,24 @@ static int install_loader_config(const char *esp_path) {
return 1; return 1;
} }
static int install_machine_id_directory(const char *root) {
sd_id128_t machine_id;
char buf[SD_ID128_STRING_MAX];
int r;
assert(root);
assert(arg_make_machine_id_directory >= 0);
if (!arg_make_machine_id_directory)
return 0;
r = sd_id128_get_machine(&machine_id);
if (r < 0)
return log_error_errno(r, "Failed to get machine id: %m");
return mkdir_one(root, sd_id128_to_string(machine_id, buf));
}
static int help(int argc, char *argv[], void *userdata) { static int help(int argc, char *argv[], void *userdata) {
_cleanup_free_ char *link = NULL; _cleanup_free_ char *link = NULL;
int r; int r;
@ -1043,6 +1105,8 @@ static int help(int argc, char *argv[], void *userdata) {
" --no-pager Do not pipe output into a pager\n" " --no-pager Do not pipe output into a pager\n"
" --graceful Don't fail when the ESP cannot be found or EFI\n" " --graceful Don't fail when the ESP cannot be found or EFI\n"
" variables cannot be written\n" " variables cannot be written\n"
" --make-machine-id-directory=yes|no|auto\n"
" Create $BOOT/$MACHINE_ID\n"
"\nSee the %2$s for details.\n", "\nSee the %2$s for details.\n",
program_invocation_short_name, program_invocation_short_name,
link, link,
@ -1062,24 +1126,27 @@ static int parse_argv(int argc, char *argv[]) {
ARG_NO_VARIABLES, ARG_NO_VARIABLES,
ARG_NO_PAGER, ARG_NO_PAGER,
ARG_GRACEFUL, ARG_GRACEFUL,
ARG_MAKE_MACHINE_ID_DIRECTORY,
}; };
static const struct option options[] = { static const struct option options[] = {
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, ARG_VERSION }, { "version", no_argument, NULL, ARG_VERSION },
{ "esp-path", required_argument, NULL, ARG_ESP_PATH }, { "esp-path", required_argument, NULL, ARG_ESP_PATH },
{ "path", required_argument, NULL, ARG_ESP_PATH }, /* Compatibility alias */ { "path", required_argument, NULL, ARG_ESP_PATH }, /* Compatibility alias */
{ "boot-path", required_argument, NULL, ARG_BOOT_PATH }, { "boot-path", required_argument, NULL, ARG_BOOT_PATH },
{ "print-esp-path", no_argument, NULL, 'p' }, { "print-esp-path", no_argument, NULL, 'p' },
{ "print-path", no_argument, NULL, 'p' }, /* Compatibility alias */ { "print-path", no_argument, NULL, 'p' }, /* Compatibility alias */
{ "print-boot-path", no_argument, NULL, 'x' }, { "print-boot-path", no_argument, NULL, 'x' },
{ "no-variables", no_argument, NULL, ARG_NO_VARIABLES }, { "no-variables", no_argument, NULL, ARG_NO_VARIABLES },
{ "no-pager", no_argument, NULL, ARG_NO_PAGER }, { "no-pager", no_argument, NULL, ARG_NO_PAGER },
{ "graceful", no_argument, NULL, ARG_GRACEFUL }, { "graceful", no_argument, NULL, ARG_GRACEFUL },
{ "make-machine-id-directory", required_argument, NULL, ARG_MAKE_MACHINE_ID_DIRECTORY },
{} {}
}; };
int c, r; int c, r;
bool b;
assert(argc >= 0); assert(argc >= 0);
assert(argv); assert(argv);
@ -1132,6 +1199,17 @@ static int parse_argv(int argc, char *argv[]) {
arg_graceful = true; arg_graceful = true;
break; break;
case ARG_MAKE_MACHINE_ID_DIRECTORY:
if (streq(optarg, "auto"))
arg_make_machine_id_directory = -1; /* default */
else {
r = parse_boolean_argument("--make-machine-id-directory=", optarg, &b);
if (r < 0)
return r;
arg_make_machine_id_directory = b;
}
break;
case '?': case '?':
return -EINVAL; return -EINVAL;
@ -1530,6 +1608,8 @@ static int verb_install(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return r; return r;
settle_make_machine_id_directory();
install = streq(argv[0], "install"); install = streq(argv[0], "install");
RUN_WITH_UMASK(0002) { RUN_WITH_UMASK(0002) {
@ -1555,6 +1635,10 @@ static int verb_install(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return r; return r;
r = install_machine_id_directory(arg_dollar_boot_path());
if (r < 0)
return r;
r = install_random_seed(arg_esp_path); r = install_random_seed(arg_esp_path);
if (r < 0) if (r < 0)
return r; return r;
@ -1584,6 +1668,8 @@ static int verb_remove(int argc, char *argv[], void *userdata) {
if (r < 0) if (r < 0)
return r; return r;
settle_make_machine_id_directory();
r = remove_binaries(arg_esp_path); r = remove_binaries(arg_esp_path);
q = remove_file(arg_esp_path, "/loader/loader.conf"); q = remove_file(arg_esp_path, "/loader/loader.conf");
@ -1602,11 +1688,19 @@ static int verb_remove(int argc, char *argv[], void *userdata) {
if (q < 0 && r >= 0) if (q < 0 && r >= 0)
r = q; r = q;
q = remove_machine_id_directory(arg_esp_path);
if (q < 0 && r >= 0)
r = 1;
if (arg_xbootldr_path) { if (arg_xbootldr_path) {
/* Remove the latter two also in the XBOOTLDR partition if it exists */ /* Remove the latter two also in the XBOOTLDR partition if it exists */
q = remove_subdirs(arg_xbootldr_path, dollar_boot_subdirs); q = remove_subdirs(arg_xbootldr_path, dollar_boot_subdirs);
if (q < 0 && r >= 0) if (q < 0 && r >= 0)
r = q; r = q;
q = remove_machine_id_directory(arg_xbootldr_path);
if (q < 0 && r >= 0)
r = q;
} }
(void) sync_everything(); (void) sync_everything();

View File

@ -2213,14 +2213,14 @@ int config_parse_service_sockets(
_cleanup_free_ char *word = NULL, *k = NULL; _cleanup_free_ char *word = NULL, *k = NULL;
r = extract_first_word(&p, &word, NULL, 0); r = extract_first_word(&p, &word, NULL, 0);
if (r == 0)
return 0;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Trailing garbage in sockets, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Trailing garbage in sockets, ignoring: %s", rvalue);
return 0; return 0;
} }
if (r == 0)
return 0;
r = unit_name_printf(UNIT(s), word, &k); r = unit_name_printf(UNIT(s), word, &k);
if (r < 0) { if (r < 0) {
@ -2488,14 +2488,14 @@ int config_parse_user_group_strv_compat(
_cleanup_free_ char *word = NULL, *k = NULL; _cleanup_free_ char *word = NULL, *k = NULL;
r = extract_first_word(&p, &word, NULL, 0); r = extract_first_word(&p, &word, NULL, 0);
if (r == 0)
return 0;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Invalid syntax: %s", rvalue); log_syntax(unit, LOG_ERR, filename, line, r, "Invalid syntax: %s", rvalue);
return -ENOEXEC; return -ENOEXEC;
} }
if (r == 0)
return 0;
r = unit_full_printf(u, word, &k); r = unit_full_printf(u, word, &k);
if (r < 0) { if (r < 0) {
@ -2654,8 +2654,6 @@ int config_parse_environ(
_cleanup_free_ char *word = NULL, *resolved = NULL; _cleanup_free_ char *word = NULL, *resolved = NULL;
r = extract_first_word(&p, &word, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE); r = extract_first_word(&p, &word, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE);
if (r == 0)
return 0;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
@ -2663,6 +2661,8 @@ int config_parse_environ(
"Invalid syntax, ignoring: %s", rvalue); "Invalid syntax, ignoring: %s", rvalue);
return 0; return 0;
} }
if (r == 0)
return 0;
if (u) { if (u) {
r = unit_full_printf(u, word, &resolved); r = unit_full_printf(u, word, &resolved);
@ -2719,8 +2719,6 @@ int config_parse_pass_environ(
_cleanup_free_ char *word = NULL, *k = NULL; _cleanup_free_ char *word = NULL, *k = NULL;
r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE); r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
break;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
@ -2728,6 +2726,8 @@ int config_parse_pass_environ(
"Trailing garbage in %s, ignoring: %s", lvalue, rvalue); "Trailing garbage in %s, ignoring: %s", lvalue, rvalue);
break; break;
} }
if (r == 0)
break;
if (u) { if (u) {
r = unit_full_printf(u, word, &k); r = unit_full_printf(u, word, &k);
@ -2794,8 +2794,6 @@ int config_parse_unset_environ(
_cleanup_free_ char *word = NULL, *k = NULL; _cleanup_free_ char *word = NULL, *k = NULL;
r = extract_first_word(&p, &word, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE); r = extract_first_word(&p, &word, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE);
if (r == 0)
break;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
@ -2803,6 +2801,8 @@ int config_parse_unset_environ(
"Trailing garbage in %s, ignoring: %s", lvalue, rvalue); "Trailing garbage in %s, ignoring: %s", lvalue, rvalue);
break; break;
} }
if (r == 0)
break;
if (u) { if (u) {
r = unit_full_printf(u, word, &k); r = unit_full_printf(u, word, &k);
@ -2868,14 +2868,14 @@ int config_parse_log_extra_fields(
const char *eq; const char *eq;
r = extract_first_word(&p, &word, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE); r = extract_first_word(&p, &word, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE);
if (r == 0)
return 0;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue);
return 0; return 0;
} }
if (r == 0)
return 0;
r = unit_full_printf(u, word, &k); r = unit_full_printf(u, word, &k);
if (r < 0) { if (r < 0) {
@ -3080,8 +3080,6 @@ int config_parse_unit_requires_mounts_for(
_cleanup_free_ char *word = NULL, *resolved = NULL; _cleanup_free_ char *word = NULL, *resolved = NULL;
r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE); r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
return 0;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
@ -3089,6 +3087,8 @@ int config_parse_unit_requires_mounts_for(
"Invalid syntax, ignoring: %s", rvalue); "Invalid syntax, ignoring: %s", rvalue);
return 0; return 0;
} }
if (r == 0)
return 0;
r = unit_full_printf(u, word, &resolved); r = unit_full_printf(u, word, &resolved);
if (r < 0) { if (r < 0) {
@ -3218,8 +3218,6 @@ int config_parse_syscall_filter(
int num; int num;
r = extract_first_word(&p, &word, NULL, 0); r = extract_first_word(&p, &word, NULL, 0);
if (r == 0)
return 0;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
@ -3227,6 +3225,8 @@ int config_parse_syscall_filter(
"Invalid syntax, ignoring: %s", rvalue); "Invalid syntax, ignoring: %s", rvalue);
return 0; return 0;
} }
if (r == 0)
return 0;
r = parse_syscall_and_errno(word, &name, &num); r = parse_syscall_and_errno(word, &name, &num);
if (r < 0) { if (r < 0) {
@ -3304,14 +3304,14 @@ int config_parse_syscall_log(
_cleanup_free_ char *word = NULL; _cleanup_free_ char *word = NULL;
r = extract_first_word(&p, &word, NULL, 0); r = extract_first_word(&p, &word, NULL, 0);
if (r == 0)
return 0;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue);
return 0; return 0;
} }
if (r == 0)
return 0;
r = seccomp_parse_syscall_filter( r = seccomp_parse_syscall_filter(
word, -1, c->syscall_log, word, -1, c->syscall_log,
@ -3349,8 +3349,6 @@ int config_parse_syscall_archs(
uint32_t a; uint32_t a;
r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE); r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
return 0;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
@ -3358,6 +3356,8 @@ int config_parse_syscall_archs(
"Invalid syntax, ignoring: %s", rvalue); "Invalid syntax, ignoring: %s", rvalue);
return 0; return 0;
} }
if (r == 0)
return 0;
r = seccomp_arch_from_string(word, &a); r = seccomp_arch_from_string(word, &a);
if (r < 0) { if (r < 0) {
@ -3463,8 +3463,6 @@ int config_parse_address_families(
int af; int af;
r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE); r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
return 0;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
@ -3472,6 +3470,8 @@ int config_parse_address_families(
"Invalid syntax, ignoring: %s", rvalue); "Invalid syntax, ignoring: %s", rvalue);
return 0; return 0;
} }
if (r == 0)
return 0;
af = af_from_name(word); af = af_from_name(word);
if (af < 0) { if (af < 0) {
@ -3821,14 +3821,14 @@ int config_parse_delegate(
CGroupController cc; CGroupController cc;
r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE); r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
break;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue);
return 0; return 0;
} }
if (r == 0)
break;
cc = cgroup_controller_from_string(word); cc = cgroup_controller_from_string(word);
if (cc < 0) { if (cc < 0) {
@ -3954,13 +3954,8 @@ int config_parse_device_allow(
r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE); r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r <= 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid syntax, ignoring: %s", rvalue);
return 0;
}
if (r == 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to extract device path and rights from '%s', ignoring.", rvalue); "Failed to extract device path and rights from '%s', ignoring.", rvalue);
return 0; return 0;
} }
@ -4025,13 +4020,8 @@ int config_parse_io_device_weight(
r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE); r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r <= 0 || isempty(p)) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid syntax, ignoring: %s", rvalue);
return 0;
}
if (r == 0 || isempty(p)) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to extract device path and weight from '%s', ignoring.", rvalue); "Failed to extract device path and weight from '%s', ignoring.", rvalue);
return 0; return 0;
} }
@ -4099,13 +4089,8 @@ int config_parse_io_device_latency(
r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE); r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r <= 0 || isempty(p)) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid syntax, ignoring: %s", rvalue);
return 0;
}
if (r == 0 || isempty(p)) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to extract device path and latency from '%s', ignoring.", rvalue); "Failed to extract device path and latency from '%s', ignoring.", rvalue);
return 0; return 0;
} }
@ -4174,13 +4159,8 @@ int config_parse_io_limit(
r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE); r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r <= 0 || isempty(p)) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid syntax, ignoring: %s", rvalue);
return 0;
}
if (r == 0 || isempty(p)) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to extract device node and bandwidth from '%s', ignoring.", rvalue); "Failed to extract device node and bandwidth from '%s', ignoring.", rvalue);
return 0; return 0;
} }
@ -4265,13 +4245,8 @@ int config_parse_blockio_device_weight(
r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE); r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r <= 0 || isempty(p)) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid syntax, ignoring: %s", rvalue);
return 0;
}
if (r == 0 || isempty(p)) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to extract device node and weight from '%s', ignoring.", rvalue); "Failed to extract device node and weight from '%s', ignoring.", rvalue);
return 0; return 0;
} }
@ -4343,13 +4318,8 @@ int config_parse_blockio_bandwidth(
r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE); r = extract_first_word(&p, &path, NULL, EXTRACT_UNQUOTE);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r <= 0 || isempty(p)) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid syntax, ignoring: %s", rvalue);
return 0;
}
if (r == 0 || isempty(p)) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to extract device node and bandwidth from '%s', ignoring.", rvalue); "Failed to extract device node and bandwidth from '%s', ignoring.", rvalue);
return 0; return 0;
} }
@ -4751,14 +4721,14 @@ int config_parse_namespace_path_strv(
bool ignore_enoent = false, shall_prefix = false; bool ignore_enoent = false, shall_prefix = false;
r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE); r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
break;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to extract first word, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to extract first word, ignoring: %s", rvalue);
return 0; return 0;
} }
if (r == 0)
break;
w = word; w = word;
if (startswith(w, "-")) { if (startswith(w, "-")) {
@ -4828,14 +4798,14 @@ int config_parse_temporary_filesystems(
const char *w; const char *w;
r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE); r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
if (r == 0)
return 0;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to extract first word, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to extract first word, ignoring: %s", rvalue);
return 0; return 0;
} }
if (r == 0)
return 0;
w = word; w = word;
r = extract_first_word(&w, &path, ":", EXTRACT_DONT_COALESCE_SEPARATORS); r = extract_first_word(&w, &path, ":", EXTRACT_DONT_COALESCE_SEPARATORS);
@ -4902,14 +4872,14 @@ int config_parse_bind_paths(
bool rbind = true, ignore_enoent = false; bool rbind = true, ignore_enoent = false;
r = extract_first_word(&p, &source, ":" WHITESPACE, EXTRACT_UNQUOTE|EXTRACT_DONT_COALESCE_SEPARATORS); r = extract_first_word(&p, &source, ":" WHITESPACE, EXTRACT_UNQUOTE|EXTRACT_DONT_COALESCE_SEPARATORS);
if (r == 0)
break;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s, ignoring: %s", lvalue, rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse %s, ignoring: %s", lvalue, rvalue);
return 0; return 0;
} }
if (r == 0)
break;
r = unit_full_printf(u, source, &sresolved); r = unit_full_printf(u, source, &sresolved);
if (r < 0) { if (r < 0) {
@ -5630,7 +5600,7 @@ int config_parse_bpf_foreign_program(
r = extract_first_word(&rvalue, &word, ":", 0); r = extract_first_word(&rvalue, &word, ":", 0);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r <= 0 || isempty(rvalue)) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse foreign BPF program, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse foreign BPF program, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -5670,11 +5640,11 @@ int config_parse_cgroup_socket_bind(
void *data, void *data,
void *userdata) { void *userdata) {
_cleanup_free_ CGroupSocketBindItem *item = NULL; _cleanup_free_ CGroupSocketBindItem *item = NULL;
const char *address_family = NULL, *user_port; const char *user_port;
uint16_t nr_ports = 0, port_min = 0; uint16_t nr_ports = 0, port_min = 0;
CGroupSocketBindItem **head = data; CGroupSocketBindItem **head = data;
_cleanup_free_ char *word = NULL; _cleanup_free_ char *word = NULL;
int af = AF_UNSPEC, r; int af, r;
if (isempty(rvalue)) { if (isempty(rvalue)) {
cgroup_context_remove_socket_bind(head); cgroup_context_remove_socket_bind(head);
@ -5684,29 +5654,40 @@ int config_parse_cgroup_socket_bind(
r = extract_first_word(&rvalue, &word, ":", 0); r = extract_first_word(&rvalue, &word, ":", 0);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r <= 0) {
if (rvalue) log_syntax(unit, LOG_WARNING, filename, line, r,
address_family = word; "Unable to parse %s= assignment, ignoring: %s", lvalue, rvalue);
return 0;
if (address_family) { }
if (streq(address_family, "IPv4"))
af = AF_INET; if (rvalue) {
else if (streq(address_family, "IPv6")) if (streq(word, "IPv4"))
af = AF_INET6; af = AF_INET;
else else if (streq(word, "IPv6"))
return log_warning_errno(SYNTHETIC_ERRNO(EINVAL), af = AF_INET6;
"Only IPv4 or IPv6 protocols are supported, ignoring"); else {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Only IPv4 and IPv6 protocols are supported, ignoring.");
return 0;
}
user_port = rvalue;
} else {
af = AF_UNSPEC;
user_port = word;
} }
user_port = rvalue ?: word;
if (!streq(user_port, "any")) { if (!streq(user_port, "any")) {
uint16_t port_max; uint16_t port_max;
r = parse_ip_port_range(user_port, &port_min, &port_max); r = parse_ip_port_range(user_port, &port_min, &port_max);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_warning_errno(r, "Invalid port or port range, ignoring: %m"); log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid port or port range, ignoring: %m");
return 0;
}
nr_ports = 1 + port_max - port_min; nr_ports = 1 + port_max - port_min;
} }

View File

@ -10,6 +10,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size == 0) if (size == 0)
return 0; return 0;
/* We don't want to fill the logs with assert warnings.
* Disable most logging if not running standalone */
if (!getenv("SYSTEMD_LOG_LEVEL"))
log_set_max_level(LOG_CRIT);
dummy_server_init(&s, data, size); dummy_server_init(&s, data, size);
dev_kmsg_record(&s, s.buffer, size); dev_kmsg_record(&s, s.buffer, size);
server_done(&s); server_done(&s);

View File

@ -245,72 +245,69 @@ _public_ int sd_device_new_from_devnum(sd_device **ret, char type, dev_t devnum)
} }
_public_ int sd_device_new_from_subsystem_sysname(sd_device **ret, const char *subsystem, const char *sysname) { _public_ int sd_device_new_from_subsystem_sysname(sd_device **ret, const char *subsystem, const char *sysname) {
char *name, *syspath; char syspath[PATH_MAX], *name;
size_t len = 0;
assert_return(ret, -EINVAL); assert_return(ret, -EINVAL);
assert_return(subsystem, -EINVAL); assert_return(subsystem, -EINVAL);
assert_return(sysname, -EINVAL); assert_return(sysname, -EINVAL);
assert_return(strlen(sysname) < PATH_MAX - strlen("/sys/bus/"), -ENAMETOOLONG);
if (streq(subsystem, "subsystem")) { if (streq(subsystem, "subsystem")) {
syspath = strjoina("/sys/subsystem/", sysname); if (snprintf_ok(syspath, sizeof syspath, "/sys/subsystem/%s", sysname) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
syspath = strjoina("/sys/bus/", sysname); if (snprintf_ok(syspath, sizeof syspath, "/sys/bus/%s", sysname) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
syspath = strjoina("/sys/class/", sysname); if (snprintf_ok(syspath, sizeof syspath, "/sys/class/%s", sysname) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
} else if (streq(subsystem, "module")) { } else if (streq(subsystem, "module")) {
syspath = strjoina("/sys/module/", sysname); if (snprintf_ok(syspath, sizeof syspath, "/sys/module/%s", sysname) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
} else if (streq(subsystem, "drivers")) { } else if (streq(subsystem, "drivers")) {
char subsys[PATH_MAX]; const char *subsys, *sep;
char *driver;
strscpy(subsys, sizeof(subsys), sysname); sep = strchr(sysname, ':');
driver = strchr(subsys, ':'); if (sep && sep[1] != '\0') { /* Require ":" and something non-empty after that. */
if (driver) { subsys = memdupa_suffix0(sysname, sep - sysname);
driver[0] = '\0';
driver++;
syspath = strjoina("/sys/subsystem/", subsys, "/drivers/", driver); if (snprintf_ok(syspath, sizeof syspath, "/sys/subsystem/%s/drivers/%s", subsys, sep + 1) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
syspath = strjoina("/sys/bus/", subsys, "/drivers/", driver); if (snprintf_ok(syspath, sizeof syspath, "/sys/bus/%s/drivers/%s", subsys, sep + 1) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
} }
} }
/* translate sysname back to sysfs filename */ /* translate sysname back to sysfs filename */
name = strdupa(sysname); name = strdupa(sysname);
while (name[len] != '\0') {
if (name[len] == '/')
name[len] = '!';
len++; for (size_t i = 0; name[i]; i++)
} if (name[i] == '/')
name[i] = '!';
syspath = strjoina("/sys/subsystem/", subsystem, "/devices/", name); if (snprintf_ok(syspath, sizeof syspath, "/sys/subsystem/%s/devices/%s", subsystem, name) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
syspath = strjoina("/sys/bus/", subsystem, "/devices/", name); if (snprintf_ok(syspath, sizeof syspath, "/sys/bus/%s/devices/%s", subsystem, name) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
syspath = strjoina("/sys/class/", subsystem, "/", name); if (snprintf_ok(syspath, sizeof syspath, "/sys/class/%s/%s", subsystem, name) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
syspath = strjoina("/sys/firmware/", subsystem, "/", sysname); if (snprintf_ok(syspath, sizeof syspath, "/sys/firmware/%s/%s", subsystem, sysname) &&
if (access(syspath, F_OK) >= 0) access(syspath, F_OK) >= 0)
return sd_device_new_from_syspath(ret, syspath); return sd_device_new_from_syspath(ret, syspath);
return -ENODEV; return -ENODEV;
@ -652,17 +649,15 @@ _public_ int sd_device_new_from_device_id(sd_device **ret, const char *id) {
} }
case '+': { case '+': {
char subsys[NAME_MAX+1]; /* NAME_MAX does not include the trailing NUL. */ const char *subsys, *sep;
const char *sysname;
sysname = strchr(id + 1, ':'); sep = strchr(id + 1, ':');
if (!sysname) if (!sep || sep - id - 1 > NAME_MAX)
return -EINVAL; return -EINVAL;
(void) strnscpy(subsys, sizeof(subsys), id + 1, sysname - id - 1); subsys = memdupa_suffix0(id + 1, sep - id - 1);
sysname++;
return sd_device_new_from_subsystem_sysname(ret, subsys, sysname); return sd_device_new_from_subsystem_sysname(ret, subsys, sep + 1);
} }
default: default:

View File

@ -30,20 +30,11 @@ SUBSYSTEM=="scsi_generic", SUBSYSTEMS=="scsi", ATTRS{type}=="4|5", TAG+="uaccess
SUBSYSTEM=="sound", TAG+="uaccess", \ SUBSYSTEM=="sound", TAG+="uaccess", \
OPTIONS+="static_node=snd/timer", OPTIONS+="static_node=snd/seq" OPTIONS+="static_node=snd/timer", OPTIONS+="static_node=snd/seq"
# ffado is an userspace driver for firewire sound cards
SUBSYSTEM=="firewire", ENV{ID_FFADO}=="1", TAG+="uaccess"
# Webcams, frame grabber, TV cards # Webcams, frame grabber, TV cards
SUBSYSTEM=="video4linux", TAG+="uaccess" SUBSYSTEM=="video4linux", TAG+="uaccess"
SUBSYSTEM=="dvb", TAG+="uaccess" SUBSYSTEM=="dvb", TAG+="uaccess"
# IIDC devices: industrial cameras and some webcams # industrial cameras, some webcams, camcorders, set-top boxes, TV sets, audio devices, and more
SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x00010*", TAG+="uaccess"
SUBSYSTEM=="firewire", ATTR{units}=="*0x00b09d:0x00010*", TAG+="uaccess"
# AV/C devices: camcorders, set-top boxes, TV sets, audio devices, and more
SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x010001*", TAG+="uaccess"
SUBSYSTEM=="firewire", ATTR{units}=="*0x00a02d:0x014001*", TAG+="uaccess"
SUBSYSTEM=="firewire", TEST=="units", ENV{IEEE1394_UNIT_FUNCTION_MIDI}=="1", TAG+="uaccess" SUBSYSTEM=="firewire", TEST=="units", ENV{IEEE1394_UNIT_FUNCTION_MIDI}=="1", TAG+="uaccess"
SUBSYSTEM=="firewire", TEST=="units", ENV{IEEE1394_UNIT_FUNCTION_AUDIO}=="1", TAG+="uaccess" SUBSYSTEM=="firewire", TEST=="units", ENV{IEEE1394_UNIT_FUNCTION_AUDIO}=="1", TAG+="uaccess"
SUBSYSTEM=="firewire", TEST=="units", ENV{IEEE1394_UNIT_FUNCTION_VIDEO}=="1", TAG+="uaccess" SUBSYSTEM=="firewire", TEST=="units", ENV{IEEE1394_UNIT_FUNCTION_VIDEO}=="1", TAG+="uaccess"

View File

@ -1754,12 +1754,12 @@ int unit_file_verify_alias(const UnitFileInstallInfo *i, const char *dst, char *
"Invalid path \"%s\" in alias.", dir); "Invalid path \"%s\" in alias.", dir);
*p = '\0'; /* dir should now be a unit name */ *p = '\0'; /* dir should now be a unit name */
r = unit_name_classify(dir); UnitNameFlags type = unit_name_classify(dir);
if (r < 0) if (type < 0)
return log_warning_errno(SYNTHETIC_ERRNO(EXDEV), return log_warning_errno(SYNTHETIC_ERRNO(EXDEV),
"Invalid unit name component \"%s\" in alias.", dir); "Invalid unit name component \"%s\" in alias.", dir);
const bool instance_propagation = r == UNIT_NAME_TEMPLATE; const bool instance_propagation = type == UNIT_NAME_TEMPLATE;
/* That's the name we want to use for verification. */ /* That's the name we want to use for verification. */
r = unit_symlink_name_compatible(path_alias, i->name, instance_propagation); r = unit_symlink_name_compatible(path_alias, i->name, instance_propagation);
@ -1776,11 +1776,11 @@ int unit_file_verify_alias(const UnitFileInstallInfo *i, const char *dst, char *
if (unit_name_is_valid(dst, UNIT_NAME_TEMPLATE)) { if (unit_name_is_valid(dst, UNIT_NAME_TEMPLATE)) {
_cleanup_free_ char *inst = NULL; _cleanup_free_ char *inst = NULL;
r = unit_name_to_instance(i->name, &inst); UnitNameFlags type = unit_name_to_instance(i->name, &inst);
if (r < 0) if (type < 0)
return log_error_errno(r, "Failed to extract instance name from %s: %m", i->name); return log_error_errno(type, "Failed to extract instance name from %s: %m", i->name);
if (r == UNIT_NAME_INSTANCE) { if (type == UNIT_NAME_INSTANCE) {
r = unit_name_replace_instance(dst, inst, &dst_updated); r = unit_name_replace_instance(dst, inst, &dst_updated);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to build unit name from %s+%s: %m", return log_error_errno(r, "Failed to build unit name from %s+%s: %m",

View File

@ -68,7 +68,6 @@ static void test_random_u64_range_one(unsigned mod) {
x = random_u64_range(mod); x = random_u64_range(mod);
log_trace("%05u: %"PRIu64, i, x);
count[x]++; count[x]++;
max = MAX(max, count[x]); max = MAX(max, count[x]);
} }

View File

@ -471,8 +471,8 @@ static void test_build_parent_slice(void) {
} }
static void test_unit_name_to_instance(void) { static void test_unit_name_to_instance(void) {
UnitNameFlags r;
char *instance; char *instance;
int r;
log_info("/* %s */", __func__); log_info("/* %s */", __func__);

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.