summaryrefslogtreecommitdiffstats
path: root/src (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
| * | sd-netlink: add nfnetlink helper routinesFlorian Westphal2020-12-163-0/+345
| | | | | | | | | | | | | | | | | | | | | | | | add nfnetlink_nftables helper functions to: * open a new nfnetlink socket to kernel * add tables, chains, rules, sets and maps * delete/flush table * add and delete elements from sets/maps
| * | sd-netlink: add nfnetlink/nftables type systemFlorian Westphal2020-12-162-1/+262
| | | | | | | | | | | | | | | Will be used by upcoming nftables support -- it will use the netlink interface directly rather than add another library dependency.
| * | linux: import nf_tables and nfnetlink headers from Linux 5.8Florian Westphal2020-12-162-0/+1950
| | | | | | | | | | | | | | | | | | Will be used/needed in the upcoming nfnetlink/nftables support. This follows existing model where kernel uapi headers are cached locally.
| * | firewall-util: introduce context structureFlorian Westphal2020-12-1611-43/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for planned nft backend we have three choices: - open/close a new nfnetlink socket for every operation - keep a nfnetlink socket open internally - expose a opaque fw_ctx and stash all internal data here. Originally I opted for the 2nd option, but during review it was suggested to avoid static storage duration because of perceived problems with threaded applications. This adds fw_ctx and new/free functions, then converts the existing api and nspawn and networkd to use it.
| * | nspawn: pass userdata pointer, not inet_addr unionFlorian Westphal2020-12-162-4/+4
| | | | | | | | | | | | | | | | | | Next patch will need to pass two pointers to the callback instead of just the addr mask. Caller will pass a compound structure, so make this 'void *userdata' to de-clutter the next patch.
| * | firewall-util: prepare for alternative to iptables backendFlorian Westphal2020-12-165-336/+410
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In a nutshell: 1. git mv firewall-util.c firewall-util-iptables.c 2. existing external functions gain _iptables_ in their names 3. firewall-util.c provides old function names 4. build system always compiles firewall-util.c, firewall-util-iptables.c is conditional instead (libiptc). 5. On first call to any of the 'old' API functions performs a probe that should return the preferred backend. In a future step, can add firewall-util-FOOTYPE.c, add its probe function to firewall-util.c and then have calls to fw_add_masq/local_dnat handed to the detected backend. For now, only iptables backend exists, and no special probing takes place for it, i.e. when systemd was built with iptables, that will be used. If not, requets to add masquerade/dnat will fail with same error (-EOPNOTSUPP) as before this change. For reference, the rules added by the libiptc/iptables backend look like this: for service export (via systemd-nspawn): [0:0] -A PREROUTING -p tcp -m tcp --dport $exportedport -m addrtype --dst-type LOCAL -j DNAT --to-destination $containerip:$port [0:0] -A OUTPUT ! -d 127.0.0.0/8 -p tcp -m tcp --dport $exportedport -m addrtype --dst-type LOCAL -j DNAT --to-destination $containerip:$port for ip masquerade: [0:0] -A POSTROUTING -s network/prefix -j MASQUERADE
| * | firewall-util: reject NULL source or address with prefixlen 0Florian Westphal2020-12-162-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make sure we don't add masquerading rules without a explicitly specified network range we should be masquerading for. The only caller aside from test case is networkd-address.c which never passes a NULL source. As it also passes the network prefix, that should always be > 0 as well. This causes expected test failure: Failed to modify firewall: Invalid argument Failed to modify firewall: Invalid argument Failed to modify firewall: Invalid argument Failed to modify firewall: Protocol not available Failed to modify firewall: Protocol not available Failed to modify firewall: Protocol not available Failed to modify firewall: Protocol not available The failing test cases are amended to expect failure on NULL source or prefix instead of success.
* | | udev: Extract RAM properties from DMI informationBastien Nocera2020-12-162-0/+711
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add memory_id program to set properties about the physical memory devices in the system. This is useful on machines with removable memory modules to show how the machine can be upgraded, and on all devices to detect the actual RAM size, without relying on the OS accessible amount. Closes: #16651
* | | test-login: skip consistency checks when logind is not activeZbigniew Jędrzejewski-Szmek2020-12-161-48/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are two ways in swich sd_login_* functions acquire data: some are derived from the cgroup path, but others use the data serialized by logind. When the tests are executed under Fedora's mock, without systemd-spawn but instead in a traditional chroot, test-login gets confused: the "outside" cgroup path is visible, so sd_pid_get_unit() and sd_pid_get_session() work, but sd_session_is_active() and other functions that need logind data fail. Such a buildroot setup is fairly bad, but it can be encountered in the wild, so let's just skip the tests in that case. /* Information printed is from the live system */ sd_pid_get_unit(0, …) → "session-237.scope" sd_pid_get_user_unit(0, …) → "n/a" sd_pid_get_slice(0, …) → "user-1000.slice" sd_pid_get_session(0, …) → "237" sd_pid_get_owner_uid(0, …) → 1000 sd_pid_get_cgroup(0, …) → "/user.slice/user-1000.slice/session-237.scope" sd_uid_get_display(1000, …) → "(null)" sd_uid_get_sessions(1000, …) → [0] "" sd_uid_get_seats(1000, …) → [0] "" Assertion 'r >= 0' failed at src/libsystemd/sd-login/test-login.c:104, function test_login(). Aborting.
* | | networkd: handle ignoring ll gateway being link llDevon Pringle2020-12-161-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the event where network discovery gets a route with the gateway being the interfaces local link address, networkd will fail the interface. systemd-networkd[44319]: br_lan: Configuring route: dst: fdcd:41a4:5559:ec03::/64, src: n/a, gw: fe80::e4da:7eff:fe77:5c5e, prefsrc: n/a, scope: global, table: main, proto: ra, type: unicast systemd-networkd[44319]: br_lan: Could not set NDisc route or address: Gateway can not be a local address. Invalid argument systemd-networkd[44319]: br_lan: Failed systemd-networkd[44319]: br_lan: State changed: configuring -> failed This patch, instead of allowing the interface to fail, will instead log the event and skip setting the route.
* | | Merge pull request #17799 from yuwata/oss-fuzz-25353Zbigniew Jędrzejewski-Szmek2020-12-168-54/+66
|\ \ \ | | | | | | | | logs-show: skip non-utf8 name entries
| * | | logs-show: refuse data which contain invalid fieldsYu Watanabe2020-12-151-12/+20
| | | |
| * | | journal: refuse data which contain invalid fieldsYu Watanabe2020-12-151-0/+3
| | | | | | | | | | | | | | | | Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25353.
| * | | journal: move journal_field_valid() to journal_file.cYu Watanabe2020-12-157-42/+43
| | | |
* | | | tree-wide: fix typoYu Watanabe2020-12-162-2/+2
| | | |
* | | | Merge pull request #17859 from ↵Yu Watanabe2020-12-1622-343/+456
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | keszybz/hostnamed-export-hostname-origin-and-simplify-logic Export hostname origin and simplify logic in hostamed
| * | | | hostnamed,shared/hostname-setup: expose the origin of the current hostnameZbigniew Jędrzejewski-Szmek2020-12-164-59/+159
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In hostnamed this is exposed as a dbus property, and in the logs in both places. This is of interest to network management software and such: if the fallback hostname is used, it's not as useful as the real configured thing. Right now various programs try to guess the source of hostname by looking at the string. E.g. "localhost" is assumed to be not the real hostname, but "fedora" is. Any such attempts are bound to fail, because we cannot distinguish "fedora" (a fallback value set by a distro), from "fedora" (received from reverse dns), from "fedora" read from /etc/hostname. /run/systemd/fallback-hostname is written with the fallback hostname when either pid1 or hostnamed sets the kernel hostname to the fallback value. Why remember the fallback value and not the transient hostname in /run/hostname instead? We have three hostname types: "static", "transient", fallback". – Distinguishing "static" is easy: the hostname that is set matches what is in /etc/hostname. – Distingiushing "transient" and "fallback" is not easy. And the "transient" hostname may be set outside of pid1+hostnamed. In particular, it may be set by container manager, some non-systemd tool in the initramfs, or even by a direct call. All those mechanisms count as "transient". Trying to get those cases to write /run/hostname is futile. It is much easier to isolate the "fallback" case which is mostly under our control. And since the file is only used as a flag to mark the hostname as fallback, it can be hidden inside of our /run/systemd directory. For https://bugzilla.redhat.com/show_bug.cgi?id=1892235.
| * | | | hostnamed: stop discriminating against "localhost" in /etc/hostnameZbigniew Jędrzejewski-Szmek2020-12-161-15/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We would sometimes ignore localhost-style names in /etc/hostname. That is brittle. If the user configured some hostname, it's most likely because they want to use that as the hostname. If they don't want to use such a hostname, they should just not create the config. Everything becomes simples if we just use the configured hostname as-is. This behaviour seems to have been a workaround for Anaconda installer and other tools writing out /etc/hostname with the default of "localhost.localdomain". Anaconda PR to stop doing that: https://github.com/rhinstaller/anaconda/pull/3040. That might have been useful as a work-around for other programs misbehaving if /etc/hostname was not present, but nowadays it's not useful because systemd mostly controls the hostname and it is perfectly happy without that file. Apart from making things simpler, this allows users to set a hostname like "localhost" and have it honoured, if such a whim strikes them.
| * | | | hostnamed: improve message about static hostnameZbigniew Jędrzejewski-Szmek2020-12-161-1/+4
| | | | | | | | | | | | | | | | | | | | Changed static hostname to 'n/a' is not very nice.
| * | | | hostnamed: minor style cleanupsZbigniew Jędrzejewski-Szmek2020-12-162-8/+4
| | | | |
| * | | | hostnamed: when hostname is set to existing value, suppress notificationsZbigniew Jędrzejewski-Szmek2020-12-161-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | | When the hostname is set through network config or such, let's optimize things a bit by suppressing the logs and dbus notifications.
| * | | | shared/hostname-setup: leave the terminator byte aloneZbigniew Jędrzejewski-Szmek2020-12-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gethostname(3) says it's unspecified whether the string is properly terminated when the hostname is too long. We created a buffer with one extra byte, and it seems the intent was to let that byte serve as terminator even if we get an unterminated string from gethostname().
| * | | | shared/hostname-setup: add mode where we check what would be set, without doingZbigniew Jędrzejewski-Szmek2020-12-165-17/+23
| | | | | | | | | | | | | | | | | | | | This allows the 'unsafe' mark to be removed from the test.
| * | | | Move hostname setup logic to new shared/hostname-setup.[ch]Zbigniew Jędrzejewski-Szmek2020-12-1620-280/+289
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | No functional change, just moving a bunch of things around. Before we needed a rather complicated setup to test hostname_setup(), because the code was in src/core/. When things are moved to src/shared/ we can just test it as any function. The test is still "unsafe" because hostname_setup() may modify the hostname.
| * | | | hostnamed: fix return valueZbigniew Jędrzejewski-Szmek2020-12-161-2/+4
| | | | |
| * | | | hostnamed: expose the fallback-hostname setting as a const dbus propertyZbigniew Jędrzejewski-Szmek2020-12-161-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Various users want to know what the fallback hostname is. Since it was made configurable in 8146c32b9264a6915d467a5cab1a24311fbede7e, we didn't expose this nicely.
* | | | | sd-netlink: routing policy rule port to fib_rule_hdrSusant Sahani2020-12-163-71/+70
| | | | |
* | | | | resolved: always take a timestamp when first seeing a packetLennart Poettering2020-12-164-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | This is later useful if we want to adjust the TTLs of packets we want to propagate to clients.
* | | | | sd-dhcp-client: fix renew/rebind timeout calculation to avoid infinite loopDan Streetman2020-12-161-1/+1
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | unfortunately I missed adding the timeout to 'now' which results in an endless loop of renewal timeouts. Fixes: 3a23834d6b0da391c1ba9cb79a7d7deea7125f4b
* | | | coredumpctl: Add --debugger-args= optionMichal Fabik2020-12-161-36/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds the possibility to pass command line options to the debugger invoked with coredumpctl debug. Resolves: #9905
* | | | Merge pull request #17968 from yuwata/purge-libudevYu Watanabe2020-12-1625-452/+448
|\ \ \ \ | |_|/ / |/| | | udev: do not link with libudev
| * | | udev: drop license boilerplateYu Watanabe2020-12-151-9/+1
| | | |
| * | | meson: do not link with libudevYu Watanabe2020-12-155-37/+32
| | | |
| * | | udev: drop unnecessary libudev-util.h inclusionsYu Watanabe2020-12-1510-10/+0
| | | |
| * | | udevadm: drop udev_queueYu Watanabe2020-12-151-9/+10
| | | |
| * | | udev: introduce udev_queue_is_empty() and udev_queue_init()Yu Watanabe2020-12-153-19/+34
| | | |
| * | | libudev: fix indentationYu Watanabe2020-12-151-1/+1
| | | |
| * | | libudev: drop unnecessary headers from libudev-util.cYu Watanabe2020-12-151-8/+0
| | | |
| * | | udev: use encode_devnode_name() instead of udev_util_encode_string()Yu Watanabe2020-12-153-7/+10
| | | | | | | | | | | | | | | | | | | | As udev_util_encode_string() is a simple wrapper of encode_devnode_name().
| * | | udev: rename UTIL_LINE_SIZE -> UDEV_LINE_SIZE and friendsYu Watanabe2020-12-157-34/+34
| | | | | | | | | | | | | | | | This also moves them to udev-util.h
| * | | udev: move util_resolve_subsys_kernel() to udev-util.cYu Watanabe2020-12-158-97/+104
| | | |
| * | | udev: move util_replace_chars() to udev-util.cYu Watanabe2020-12-1510-66/+68
| | | |
| * | | udev: move util_path_encode() and rename it to escape_path()Yu Watanabe2020-12-153-36/+35
| | | |
| * | | udev: move util_replace_whitespace() to udev-util.cYu Watanabe2020-12-1510-119/+119
| |/ /
* | | network: Allow to configure interface promiscuous modeSusant Sahani2020-12-154-1/+10
| | |
* | | Merge pull request #17967 from poettering/connect-user-busLennart Poettering2020-12-1543-157/+382
|\ \ \ | | | | | | | | add support for "systemctl --user --machine=foobar@.host" for connecting to user bus of user "foobar"
| * | | bus-util: improve logging when we can't connect to the busLennart Poettering2020-12-151-6/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we'd already have explicit logging for the case where $XDG_RUNTIME_DIR is not set. Let's also add some explicit logging for the EPERM/ACCESS case. Let's also in both cases suggest the --machine=<user>@.host syntax. And while we are at it, let's remove side-effects from the macro. By checking for both the EPERM/EACCES case and the $XDG_RUNTIME_DIR case we will now catch both the cases where people use "su" to issue a "systemctl --user" operation, and those where they (more correctly, but still not good enough) call "su -". Fixes: #17901
| * | | stdio-bridge: add support for --system and --userLennart Poettering2020-12-151-3/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far, the bridge always acted as if "--system" was used, i.e. would unconditionally connect to the system bus. Let's add "--user" too, to connect to the users session bus. This is mostly for completeness' sake. I wanted to use this when making sd-bus's ability to connect to other user's D-Bus busses work, but it didn't exist so far. In the interest of keeping things compatible the implementation in sd-bus will not use the new "--user" switch, and instead manually construct the right bus path via "--path=", but we still should add the proper switches, as preparation for a brighter future, one day.
| * | | sd-bus: add API for connecting to a specific user's user bus of a specific ↵Lennart Poettering2020-12-158-22/+217
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | container This is unfortunately harder to implement than it sounds. The user's bus is bound a to the user's lifecycle after all (i.e. only exists as long as the user has at least one PAM session), and the path dynamically (at least theoretically, in practice it's going to be the same always) generated via $XDG_RUNTIME_DIR in /run/. To fix this properly, we'll thus go through PAM before connecting to a user bus. Which is hard since we cannot just link against libpam in the container, since the container might have been compiled entirely differently. So our way out is to use systemd-run from outside, which invokes a transient unit that does PAM from outside, doing so via D-Bus. Inside the transient unit we then invoke systemd-stdio-bridge which forwards D-Bus from the user bus to us. The systemd-stdio-bridge makes up the PAM session and thus we can sure tht the bus exists at least as long as the bus connection is kept. Or so say this differently: if you use "systemctl -M lennart@foobar" now, the bus connection works like this: 1. sd-bus on the host forks off: systemd-run -M foobar -PGq --wait -pUser=lennart -pPAMName=login systemd-stdio-bridge 2. systemd-run gets a connection to the "foobar" container's system bus, and invokes the "systemd-stdio-bridge" binary as transient service inside a PAM session for the user "lennart" 3. The systemd-stdio-bridge then proxies our D-Bus traffic to the user bus. sd-bus (on host) → systemd-run (on host) → systemd-stdio-bridge (in container) Complicated? Well, to some point yes, but otoh it's actually nice in various other ways, primarily as it makes the -H and -M codepaths more alike. In the -H case (i.e. connect to remote host via SSH) a very similar three steps are used. The only difference is that instead of "systemd-run" the "ssh" binary is used to invoke the stdio bridge in a PAM session of some other system. Thus we get similar implementation and isolation for similar operations. Fixes: #14580
| * | | sd-bus: 'ret' parameter to sd_bus_query_sender_creds() is not optional, ↵Lennart Poettering2020-12-151-0/+1
| | | | | | | | | | | | | | | | check for it