Commit Graph

45650 Commits

Author SHA1 Message Date
Lennart Poettering 45250e66cc pid1: don't apply "systemd.clock_usec" kernel cmdline parameter outside of PID 1 2020-06-24 15:33:22 +02:00
Lennart Poettering 97f1c6af8c random-seed: use ERRNO_IS_NOT_SUPPORTED() where appropriate 2020-06-24 15:32:38 +02:00
Zbigniew Jędrzejewski-Szmek e198eba7c2 sysv-generator: reduce scope of variables 2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek 80ce54adaf socket-proxy: use structured initialization in one place 2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek add74e8929 basic/hashmap,set: propagate allocation location info in _copy()
Also use double space before the tracking args at the end. Without
the comma this looks ugly, but it's a bit better with the double space.
At least it doesn't look like a variable with a type.
2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek 35e601d4f9 tree-wide: use set_ensure_consume() in various places
No funtional change.
2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek 39dbd0c74c networkd: take ref immediately after storing item in set
I'm not sure if I understand the code correctly, but it seems that if
storig in the second set failed, we'd return with the first set having
no reference on the link object, and the link object could be freed in the
future, leaving the set with a dangling reference.
2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek d02fd8b1c6 core/bpf-firewall: use the correct cleanup function
On error, we'd just free the object, and not close the fd.

While at it, let's use set_ensure_consume() to make sure we don't leak
the object if it was already in the set. I'm not sure if that condition
can be achieved.
2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek 648c339c49 logind: fix possible memleak of message if the message was already in the set
I'm not sure if it is actually possible to encounter this condition. But
let's make the handling correct regardless.
2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek d378ef708b portable: rework set handling in portable_detach()
_cleanup_set_free_ is enough for unit_files, because unit_files is
allocated in set_put_strdup(), which uses string_hash_ops_free.

This fixes a leak if marker was already present in the table.
2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek ab9dd0b997 resolved: fix memleak on duplicate host lines in /etc/hosts 2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek ceb17827fa resolved: simplify allocation failure handling in dns_stub_process_query()
Old code was correct, but let's make things more explicit.
2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek b8b46b1ce5 basic/set,hashmap: pass through allocation info in more cases 2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek fcc1d0315d basic/set: add set_ensure_consume()
This combines set_ensure_allocated() with set_consume(). The cool thing is that
because we know the hash ops, we can correctly free the item if appropriate.
Similarly to set_consume(), the goal is to simplify handling of the case where
the item needs to be freed on error and if already present in the set.
2020-06-24 10:38:15 +02:00
Jay Burger a1ba8c5b71 feature to honor first shutdown request to completion
Create unit tests per established norm at position 52

check in_set first before getting unit
2020-06-24 09:42:01 +02:00
Lennart Poettering 7bf6babfa2
Merge pull request #16112 from poettering/nss-systemd-block-fix
rework nss-systemd recursion lock
2020-06-24 08:39:44 +02:00
Lennart Poettering bc8d57f290
Merge pull request #16223 from cgzones/user_selinux
Initialize SELinux in user instances
2020-06-24 08:39:13 +02:00
Christian Göttsche 3d9fbea43e selinux: update mac_selinux_free()
* Drop mac_selinux_use() condition from mac_selinux_free(): if the
  passed pointer holds memory we want to free it even if SELinux is
  disabled

* Drop NULL-check cause man:freecon(3) states that freecon(NULL) is a
  well-defined NOP

* Assert that on non-SELinux builds the passed pointer is always NULL,
  to avoid memory leaks
2020-06-24 08:38:34 +02:00
Gigadoc2 1cdc42f283
hwdb: add another Logitech G502 Hero variant (#16256)
The commit 67551ea already adds the G502 Hero mouse, but apparently
there are multiple variants with the same ID but different names.
2020-06-24 09:46:46 +10:00
Zbigniew Jędrzejewski-Szmek 0d0248c665
Merge pull request #16246 from benzea/benzea/xdg-autostart
Minor xdg-autostart changes
2020-06-23 21:13:07 +02:00
Zbigniew Jędrzejewski-Szmek 21856e3462
Merge pull request #16213 from yuwata/network-cleanup-link-state-file
network: cleanup link state file
2020-06-23 21:09:24 +02:00
Luca Boccassi 87d25bdead make-autosuspend-rules: restore compatibility with Python3 < 3.6
The f'...' format was introduced in Python 3.6 ( https://www.python.org/dev/peps/pep-0498/ )
and returns an error when systemd is built on a system with an older Python3 version:

<...>
  File /home/bluca/git/systemd/tools/make-autosuspend-rules.py, line 15
    print(f'pci:v{vendor:08X}d{device:08X}*')
                                           ^
SyntaxError: invalid syntax
[2/388] Generating version.h with a custom command.
ninja: build stopped: subcommand failed.
$ python3 --version
Python 3.5.6

Use an older format to keep backward compatibility.
2020-06-23 21:02:15 +02:00
Zbigniew Jędrzejewski-Szmek db3b8d5d41 fuzz-udev-rules: rewrite to not require root privileges
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20142.

It turns out we don't need to do all this preparatory work if we want to parse
just one file.
2020-06-23 20:53:19 +02:00
Christian Göttsche a9ba0e328f Make failures of mac_selinux_init() fatal 2020-06-23 19:10:07 +02:00
Christian Göttsche a11bfc17dc Initialize SELinux in user instances
Call mac_selinux_init() to setup the label cache, so objects can be
created with default SELinux context.

Fixes: #8004
2020-06-23 19:10:03 +02:00
Zbigniew Jędrzejewski-Szmek c238a1f5f1 udev: split rules object creation and loading
The only functional change is to downgrade the log line to avoid double
logging.
2020-06-23 18:04:18 +02:00
Lennart Poettering 037b0a47b0 userdb: replace recursion lock
Previously we'd used the existance of a specific AF_UNIX socket in the
abstract namespace as lock for disabling lookup recursions. (for
breaking out of the loop: userdb synthesized from nss → nss synthesized
from userdb → userdb synthesized from nss → …)

I did it like that because it promised to work the same both in static
and in dynmically linked environments and is accessible easily from any
programming language.

However, it has a weakness regarding reuse attacks: the socket is
securely hashed (siphash) from the thread ID in combination with the
AT_RANDOM secret. Thus it should not be guessable from an attacker in
advance. That's only true if a thread takes the lock only once and
keeps it forever. However, if a thread takes and releases it multiple
times an attacker might monitor that and quickly take the lock
after the first iteration for follow-up iterations.

It's not a big issue given that userdb (as the primary user for this)
never released the lock and we never made the concept a public
interface, and it was only included in one release so far, but it's
something that deserves fixing. (moreover it's a local DoS only, only
permitting to disable native userdb lookups)

With this rework the libnss_systemd.so.2 module will now export two
additional symbols. These symbols are not used by glibc, but can be used
by arbitrary programs: one can be used to disable nss-systemd, the other
to check if it is currently disabled.

The lock is per-thread. It's slightly less pretty, since it requires
people to manually link against C code via dlopen()/dlsym(), but it
should work safely without the aforementioned weakness.
2020-06-23 17:24:24 +02:00
Lennart Poettering 6e78726e20 nss-systemd: skip /etc/gshadow look-ups when we just need the GID of a group 2020-06-23 17:24:24 +02:00
Lennart Poettering 88d775b734 util: add dlfcn-util.h
This just adds a _cleanup_ helper call encapsulating dlclose().

This also means libsystemd-shared is linked against libdl now. I don't
think this is much of an issue, since libdl is part of glibc anyway, and
anything from exotic. It's not an optional part of the OS (think: NSS
requires dynamic linking), hence this pulls in no deps and is almost
certainly loaded into all process' memory anyway.

[zj: use DEFINE_TRIVIAL_CLEANUP_FUNC().]
2020-06-23 17:23:27 +02:00
Lennart Poettering 21385e639a man: replace perl bug tracker link that went away with link to paper
Fixes: #16245
2020-06-23 17:19:05 +02:00
Lennart Poettering 92d64d1444 man: s/PROGRAMM/PROGRAM/ 2020-06-23 17:13:26 +02:00
Zbigniew Jędrzejewski-Szmek 311a0e2ee6 Revert "cgroup: Allow empty assignments of Memory{Low,Min}="
This reverts commit 53aa85af24.
The reason is that that patch changes the dbus api to be different than
the types declared by introspection api.

Replaces #16122.
2020-06-23 16:54:23 +02:00
Susant Sahani 3d0c8750c5 networkctl: display DHCPv4 server address 2020-06-23 19:13:06 +09:00
Yu Watanabe fd1f3b3eed dhcp: fix entry name in parsing lease file 2020-06-23 19:13:06 +09:00
Yu Watanabe 46986251d6 network: drop duplicated information from link state file
Those entries are already in DHCP4 lease file, and not used anymore.
2020-06-23 19:13:05 +09:00
Yu Watanabe 5202be27ee sd-network: drop unused functions 2020-06-23 19:13:05 +09:00
Yu Watanabe 862e710820 networkctl: use lease file to get DHCPv4 client ID 2020-06-23 19:13:05 +09:00
Yu Watanabe d41fa6ee91 networkctl: use lease file to get DHCPv4 address 2020-06-23 19:13:05 +09:00
Yu Watanabe 35cab5f99d networkctl: load DHCPv4 lease file and use timezone data from the lease file 2020-06-23 19:13:05 +09:00
Yu Watanabe ef0daa1129 libsystemd-network: move prototypes of dhcp_lese_save/load() to network-internal.h 2020-06-23 19:13:05 +09:00
Dave Reisner cc479760b4 Revert "job: Don't mark as redundant if deps are relevant"
This reverts commit 097537f07a.

At least Fedora and Debian have already reverted this at the distro
level because it causes more problems than it solves. Arch is debating
reverting it as well [0] but would strongly prefer that this happens
upstream first. Fixes #15188.

[0] https://bugs.archlinux.org/task/66458
2020-06-23 11:42:45 +02:00
Benjamin Berg 9d9a9500cd xdg-autostart: Ignore all files with GNOME autostart phase
If an autostart file for GNOME has a phase specified, then this implies
it is a session service that needs to be started at a specific time.

We have no way of handling the ordering, and while it does make sense
to explicitly hide these services with X-systemd-skip, there is no point
in even trying to handle them.
2020-06-23 11:20:27 +02:00
Benjamin Berg 566cb7e23b xdg-autostart: Fix info message if Type= is not Application
The message was copy-pasted and not changed to correctly specify what
the problem was.
2020-06-23 11:04:44 +02:00
Luca Boccassi 0389f4fa81 core: add RootHash and RootVerity service parameters
Allow to explicitly pass root hash (explicitly or as a file) and verity
device/file as unit options. Take precedence over implicit checks.
2020-06-23 10:50:09 +02:00
Lennart Poettering 6fe01ced0e nspawn: mkdir selinux mount point once, but not twice
Since #15533 we didn't create the mount point for selinuxfs anymore.

Before it we created it twice because we mount selinuxfs twice: once the
superblock, and once we remount its bind mound read-only. The second
mkdir would mean we'd chown() the host version of selinuxfs (since
there's only one selinuxfs superblock kernel-wide).

The right time to create mount point point is once: before we mount the
selinuxfs. But not a second time for the remount.

Fixes: #16032
2020-06-23 10:17:36 +02:00
Zbigniew Jędrzejewski-Szmek 75ae672bb2
Merge pull request #16196 from mrc0mmand/travis-simplification
travis: use a matrix for similar jobs
2020-06-23 10:16:18 +02:00
Zbigniew Jędrzejewski-Szmek 5c9918aca0
Merge pull request #16216 from nabijaczleweli/make-a-fuss
man/sd-makefs: mention that mkswap can also be run and fix deadlink to btrfs-man5(5)
2020-06-23 10:12:47 +02:00
Lennart Poettering 65804d6aff selinux-util: tweak log_enforcing_errno() to return the errno passed in or 0 when in non-enforcing mode
Also, some other, minor modernizations.
2020-06-23 07:48:44 +02:00
Elisei Roca 9e1732924d
test-functions: read /usr/etc/nsswitch.conf if /etc/nsswitch.conf does not exist (#16195)
See this for more info why and since when this change is needed: https://build.opensuse.org/request/show/807179.
2020-06-23 07:42:15 +02:00
наб affa893da0
man/sd-makefs: link to btrfs.wiki.kernel.org for btrfs-man5, since the man-pages link is dead
This also adds a <citerefentry project="url"> type,
since the other btrfs manpages use man-pages/die-net and are alive,
and btrfs.w.k.o won't be used anywhere else
2020-06-22 23:12:13 +02:00