summaryrefslogtreecommitdiff
path: root/src/basic
Commit message (Collapse)AuthorAgeFilesLines
* test: use cap_last_cap() for max supported cap number, not ↵Dan Streetman2020-11-261-0/+3
| | | | | | | | | | | | | capability_list_length() This test assumes capability_list_length() is an invalid cap number, but that isn't true if the running kernel supports more caps than we were compiled with, which results in the test failing. Instead use cap_last_cap() + 1. If cap_last_cap() is 63, there are no more 'invalid' cap numbers to test with, so the invalid cap number test part is skipped.
* tree-wide: fix typoYu Watanabe2020-11-251-1/+1
|
* khash: fix structured initializerYu Watanabe2020-11-181-2/+2
| | | | Fixes #17646.
* tree-wide: update "that that"Yu Watanabe2020-11-181-1/+1
|
* Merge pull request #17597 from yuwata/fix-typoZbigniew Jędrzejewski-Szmek2020-11-172-4/+3
|\ | | | | tree-wide: Fix typo
| * tree-wide: fix "a the" or "the a"Yu Watanabe2020-11-132-4/+3
| |
* | missing: define several syscall numbers for MIPS archYu Watanabe2020-11-161-65/+79
| | | | | | | | Fixes #17591.
* | io-util: do not call log_oom() in library functionsYu Watanabe2020-11-131-2/+2
|/
* ratelimit: fix integer overflowEtienne Doms2020-11-121-1/+1
| | | If StartLimitIntervalSec is huge, or more specifically, set to "infinity", we need to take care about overflows.
* Merge pull request #17567 from keszybz/various-small-cleanupsYu Watanabe2020-11-124-6/+21
|\ | | | | Various small cleanups
| * basic/fileio: constify struct timespec argumentsZbigniew Jędrzejewski-Szmek2020-11-102-6/+6
| |
| * basic/env-util: add little helper to call setenv or unsetenvZbigniew Jędrzejewski-Szmek2020-11-102-0/+15
| |
* | Merge pull request #16603 from benzea/benzea/special-app-sliceLennart Poettering2020-11-111-0/+5
|\ \ | |/ |/| Use app.slice by default in user manager (and define special user slices)
| * basic: Define macros for special user slicesBenjamin Berg2020-10-231-0/+5
| |
* | Merge pull request #17431 from msekletar/udev-link-update-raceZbigniew Jędrzejewski-Szmek2020-11-101-1/+2
|\ \ | | | | | | udev: make algorithm that selects highest priority devlink less susceptible to race conditions
| * | basic/stat-util: make mtime check stricter and use entire timestampMichal Sekletár2020-11-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note that st_mtime member of struct stat is defined as follows, #define st_mtime st_mtim.tv_sec Hence we omitted checking nanosecond part of the timestamp (struct timespec) and possibly would miss modifications that happened within the same second.
* | | license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-09218-218/+218
| | |
* | | errno: ETIMEDOUT is also a connection errorLennart Poettering2020-11-061-2/+6
| | |
* | | selinux: also try the netlink-based fallback and continue on permission errorZbigniew Jędrzejewski-Szmek2020-11-041-8/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fedora Rawhide still has the old policy, so selinux prevents our selinux code from checking if selinux is enabled. But it seems smart to fall back to the old API anyway. Follow-up for fd5e402fa9377f2860e02bdb5b84d5f5942e73f4. Both the reference policy [1] and Fedora selinux policy [2] needed to be updated, so it's likely that this will impact other distros too. [1] https://github.com/SELinuxProject/refpolicy/pull/308 [2] https://github.com/fedora-selinux/selinux-policy/pull/464
* | | Merge pull request #17493 from Villemoes/va-arg-simplificationsZbigniew Jędrzejewski-Szmek2020-11-043-79/+29
|\ \ \ | | | | | | | | Some vararg simplifications
| * | | strv.c: simplify strv_new_apRasmus Villemoes2020-11-031-29/+13
| | | | | | | | | | | | | | | | | | | | Instead of duplicating the code for x and the varargs, handle them all the same way by using for loops.
| * | | signal-util: make sigaction_many_ap a little more conciseRasmus Villemoes2020-11-031-10/+1
| | | | | | | | | | | | | | | | | | | | There's no reason to duplicate the stop condition sig < 0, nor the sigaction() call.
| * | | string-util: improve overflow checkingRasmus Villemoes2020-11-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current overflow checking is broken in the corner case of the strings' combined length being exactly SIZE_MAX: After the loop, l would be SIZE_MAX, but we're not testing whether the l+1 expression overflows. Fix it by simply pre-accounting for the final '\0': initialize l to 1 instead of 0.
| * | | string-util: simplify logic in strjoin_real()Rasmus Villemoes2020-11-031-40/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The loops over (x, then all varargs, until a NULL is found) can be written much simpler with an ordinary for loop. Just initialize the loop variable to x, test that, and in the increment part, fetch the next va_arg(). That removes a level of indentation, and avoids doing a separate strlen()/stpcpy() call for x. While touching this code anyway, change (size_t)-1 to the more readable SIZE_MAX.
* | | | fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket ↵Lennart Poettering2020-11-032-3/+23
| |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | name This beefs up the READ_FULL_FILE_CONNECT_SOCKET logic of read_full_file_full() a bit: when used a sender socket name may be specified. If specified as NULL behaviour is as before: the client socket name is picked by the kernel. But if specified as non-NULL the client can pick a socket name to use when connecting. This is useful to communicate a minimal amount of metainformation from client to server, outside of the transport payload. Specifically, these beefs up the service credential logic to pass an abstract AF_UNIX socket name as client socket name when connecting via READ_FULL_FILE_CONNECT_SOCKET, that includes the requesting unit name and the eventual credential name. This allows servers implementing the trivial credential socket logic to distinguish clients: via a simple getpeername() it can be determined which unit is requesting a credential, and which credential specifically. Example: with this patch in place, in a unit file "waldo.service" a configuration line like the following: LoadCredential=foo:/run/quux/creds.sock will result in a connection to the AF_UNIX socket /run/quux/creds.sock, originating from an abstract namespace AF_UNIX socket: @$RANDOM/unit/waldo.service/foo (The $RANDOM is replaced by some randomized string. This is included in the socket name order to avoid namespace squatting issues: the abstract socket namespace is open to unprivileged users after all, and care needs to be taken not to use guessable names) The services listening on the /run/quux/creds.sock socket may thus easily retrieve the name of the unit the credential is requested for plus the credential name, via a simpler getpeername(), discarding the random preifx and the /unit/ string. This logic uses "/" as separator between the fields, since both unit names and credential names appear in the file system, and thus are designed to use "/" as outer separators. Given that it's a good safe choice to use as separators here, too avoid any conflicts. This is a minimal patch only: the new logic is used only for the unit file credential logic. For other places where we use READ_FULL_FILE_CONNECT_SOCKET it is probably a good idea to use this scheme too, but this should be done carefully in later patches, since the socket names become API that way, and we should determine the right amount of info to pass over.
* | | Merge pull request #17444 from BtbN/fix_ib_dhcp4Zbigniew Jędrzejewski-Szmek2020-10-292-0/+39
|\ \ \ | | | | | | | | networkd: fix DHCP on InfiniBand interfaces
| * | | sd-netlink: introduce netlink_message_{read,append}_hw_addrTimo Rothenpieler2020-10-282-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | Hardware addresses come in various shapes and sizes, these new functions and accomapying data structures account for that instead of hard-coding a hardware address to the 6 bytes of an ethernet MAC.
* | | | Merge pull request #17472 from keszybz/spdx-license-headersZbigniew Jędrzejewski-Szmek2020-10-299-3/+16
|\ \ \ \ | |/ / / |/| | | More SPDX license headers
| * | | headers: use custom LicenseRef- spdx tag for various "public domain" filesZbigniew Jędrzejewski-Szmek2020-10-292-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is no spdx tag defined for those versions of "public domain", but we can add a custom tag, see https://spdx.github.io/spdx-spec/6-other-licensing-information-detected/. crc32.h is updated to match crc32.c.
| * | | headers: add spdx tags to imported files with a known licenseZbigniew Jędrzejewski-Szmek2020-10-294-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I added the header in the cases where the license text is present and it is easy to find the appropriate SPDX header. For "public domain" stuff: SDPX treats each "public domain" license as unique [1], but luckily the one in siphash24.c is one of the identified variants. There are some other cases which specify "public domain" but there doesn't seem to be a SPDX identifier. [1] https://wiki.spdx.org/view/Legal_Team/Decisions/Dealing_with_Public_Domain_within_SPDX_Files gunicode.[ch] are imported from glib, which is licensed as LGPL2.1+, see https://gitlab.gnome.org/GNOME/glib/-/blob/master/glib/gunicode.h.
| * | | tree-wide: use the usual SPDX header for our own filesZbigniew Jędrzejewski-Szmek2020-10-293-0/+6
| | | |
* | | | socket-util: make socket_set_recvpktinfo control PACKET_AUXDATA sockopt on ↵Lennart Poettering2020-10-271-0/+3
|/ / / | | | | | | | | | | | | | | | AF_PACKET Just for the sake of completness.
* | | Revert "basic/env-util: (mostly) follow POSIX for what variable names are ↵Zbigniew Jędrzejewski-Szmek2020-10-231-10/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | allowed" This reverts commit b45c068dd8fac7661a15e99e7cf699ff06010b13. I think the idea was generally sound, but didn't take into account the limitations of show-environment and how it is used. People expect to be able to eval systemctl show-environment output in bash, and no escaping syntax is defined for environment *names* (we only do escaping for *values*). We could skip such problematic variables in 'systemctl show-environment', and only allow them to be inherited directly. But this would be confusing and ugly. The original motivation for this change was that various import operations would fail. a4ccce22d9552dc74b6916cc5ec57f2a0b686b4f changed systemctl to filter invalid variables in import-environment. https://gitlab.gnome.org/GNOME/gnome-session/-/issues/71 does a similar change in GNOME. So those problematic variables should not cause failures, but just be silently ignored. Finally, the environment block is becoming a dumping ground. In my gnome session 'systemctl show-environment --user' includes stuff like PWD, FPATH (from zsh), SHLVL=0 (no idea what that is). This is not directly related to variable names (since all those are allowed under the stricter rules too), but I think we should start pushing people away from running import-environment and towards importing only select variables. https://github.com/systemd/systemd/pull/17188#issuecomment-708676511
* | | basic/env-util: make function shorterZbigniew Jędrzejewski-Szmek2020-10-231-4/+1
| |/ |/|
* | Merge pull request #17324 from keszybz/resolvectl-compat-outputLennart Poettering2020-10-222-0/+8
|\ \ | | | | | | resolvectl compat output
| * | format-table: add TABLE_STRV_WRAPPEDZbigniew Jędrzejewski-Szmek2020-10-221-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The idea is that we have strvs like list of server names or addresses, where the majority of strings is rather short, but some are long and there can potentially be many strings. So formattting them either all on one line or all in separate lines leads to output that is either hard to read or uses way too many rows. We want to wrap them, but relying on the pager to do the wrapping is not nice. Normal text has a lot of redundancy, so when the pager wraps a line in the middle of a word the read can understand what is going on without any trouble. But for a high-density zero-redundancy text like an IP address it is much nicer to wrap between words. This also makes c&p easier. This adds a variant of TABLE_STRV which is wrapped on output (with line breaks inserted between different strv entries). The change table_print() is quite ugly. A second pass is added to re-calculate column widths. Since column size is now "soft", i.e. it can adjust based on available columns, we need to two passes: - first we figure out how much space we want - in the second pass we figure out what the actual wrapped columns widths will be. To avoid unnessary work, the second pass is only done when we actually have wrappable fields. A test is added in test-format-table.
| * | resolvectl: use compat status string instead of a field-by-field tableZbigniew Jędrzejewski-Szmek2020-10-201-0/+4
| | | | | | | | | | | | | | | | | | | | | The status string is modeled after our --version output: +enabled -disabled equals=more-info For example: Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=allow-downgrade/supported
| * | resolvectl: break nta/domain/dns listings with newlinesZbigniew Jędrzejewski-Szmek2020-10-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We would print the whole string as a single super-long line. Let's nicely break the text into lines that fit on the screen. $ COLUMNS=70 build/resolvectl --no-pager nta Global: home local intranet 23.172.in-addr.arpa lan 18.172.in-addr.arpa 16.172.in-addr.arpa 19.172.in-addr.arpa 25.172.in-addr.arpa 21.172.in-addr.arpa d.f.ip6.arpa 20.172.in-addr.arpa 30.172.in-addr.arpa 17.172.in-addr.arpa internal 168.192.in-addr.arpa 28.172.in-addr.arpa 22.172.in-addr.arpa 24.172.in-addr.arpa 26.172.in-addr.arpa corp 10.in-addr.arpa private 29.172.in-addr.arpa test 27.172.in-addr.arpa 31.172.in-addr.arpa Link 2 (hub0): Link 4 (enp0s31f6): Link 5 (wlp4s0): Link 7 (virbr0): adsfasdfasdfasd.com 21.172.in-addr.arpa lan j b a.com home d.f.ip6.arpa b.com local 16.172.in-addr.arpa 19.172.in-addr.arpa 18.172.in-addr.arpa 25.172.in-addr.arpa 20.172.in-addr.arpa k i h 23.172.in-addr.arpa 168.192.in-addr.arpa d g intranet 17.172.in-addr.arpa c e.com 30.172.in-addr.arpa a f d.com e internal Link 8 (virbr0-nic): Link 9 (vnet0): Link 10 (vb-rawhide): Link 15 (wwp0s20f0u2i12):
* | | Merge pull request #16632 from keszybz/test-path-yet-againLennart Poettering2020-10-223-1/+12
|\ \ \ | | | | | | | | Tighten handling of spawned services in tests that may fail
| * | | tests: add helper function to autodetect CI environmentsZbigniew Jędrzejewski-Szmek2020-10-221-0/+6
| | | | | | | | | | | | | | | | | | | | Sadly there is no standarized way to check if we're running in some CI environment. So let's try to gather the heuristics in one helper function.
| * | | meson: convert developer_mode boolean to an enumZbigniew Jędrzejewski-Szmek2020-10-222-1/+6
| | | | | | | | | | | | | | | | | | | | I initially changed this to add a third state. But even with two values having an explicit name instead of just 0/1 is mode descriptive.
* | | | Merge pull request #13589 from williamvds/systemctl-edit-copyLennart Poettering2020-10-224-9/+25
|\ \ \ \ | |/ / / |/| | | systemctl: show original contents in comment when editing unit
| * | | Add WRITE_STRING_FILE_TRUNCATE to set O_TRUNCwilliamvds2020-10-212-9/+11
| | | |
| * | | Add strv_prependwilliamvds2020-10-212-0/+14
| | | | | | | | | | | | | | | | Inserts a copy of the value at the head of the list.
* | | | macro: introduce POINTER_MAX as define for (void*) -1Lennart Poettering2020-10-224-8/+11
| | | | | | | | | | | | | | | | | | | | Just add a safer, prettier way to write (void*) -1, that doesn't rely on two's complement, but uses the correct underlying C constructs.
* | | | cgtop: Display cpu time in microseonds with --rawArian van Putten2020-10-211-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | this makes the CPU time easily parseable; which was the goal of --raw in the first place. This only triggers if --raw is combined with --cpu=time
* | | | util: make size macros unsignedLennart Poettering2020-10-202-5/+8
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | By making them unsigned comparing them with other sizes is less likely to trigger compiler warnings regarding signed/unsigned comparisons. After all sizes (i.e. size_t) are generally assumed to be unsigned, so these should be too. Prompted-by: https://github.com/systemd/systemd/pull/17345#issuecomment-709402332
* | | meson: Fix missing libseccomp dependenciesMichal Koutný2020-10-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The builds with HAVE_SECCOMP fail on missing include paths: FAILED: src/basic/libbasic.a.p/parse-util.c.o cc -Isrc/basic/libbasic.a.p -Isrc/basic -I../src/basic -Isrc/boot -I../src/boot -Isrc/home -I../src/home -Isrc/shared -I../src/shared -Isrc/systemd -I../src/systemd -Isrc/journal -I../src/journal -Isrc/journal-remote -I../src/journal-remote -Isrc/nspawn -I../src/nspawn -Isrc/resolve -I../src/resolve -Isrc/timesync -I../src/timesync -I../src/time-wait-sync -Isrc/login -I../src/login -Isrc/udev -I../src/udev -Isrc/libudev -I../src/libudev -Isrc/core -I../src/core -Isrc/shutdown -I../src/shutdown -I../src/xdg-autostart-generator -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/libsystemd-network -I../src/libsystemd-network -I. -I.. -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu99 -g -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result -Wno-format-signedness -Werror=undef -Wlogical-op -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Winit-self -Wfloat-equal -Wsuggest-attribute=noreturn -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=missing-declarations -Werror=return-type -Werror=incompatible-pointer-types -Werror=format=2 -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wimplicit-fallthrough=5 -Wshadow -Wendif-labels -Wstrict-aliasing=2 -Wwrite-strings -Werror=overflow -Werror=shift-count-overflow -Werror=shift-overflow=2 -Wdate-time -Wnested-externs -Wno-maybe-uninitialized -ffast-math -fno-common -fdiagnostics-show-option -fno-strict-aliasing -fvisibility=hidden -fstack-protector -fstack-protector-strong --param=ssp-buffer-size=4 -Werror=shadow -include config.h -fPIC -pthread -fvisibility=default -MD -MQ src/basic/libbasic.a.p/parse-util.c.o -MF src/basic/libbasic.a.p/parse-util.c.o.d -o src/basic/libbasic.a.p/parse-util.c.o -c ../src/basic/parse-util.c In file included from ../src/basic/parse-util.c:20: ../src/shared/seccomp-util.h:4:10: fatal error: seccomp.h: No such file or directory 4 | #include <seccomp.h> | ^~~~~~~~~~~ compilation terminated. FAILED: test-parse-util.p/src_test_test-parse-util.c.o cc -Itest-parse-util.p -I. -I.. -Isrc/basic -I../src/basic -Isrc/boot -I../src/boot -Isrc/home -I../src/home -Isrc/shared -I../src/shared -Isrc/systemd -I../src/systemd -Isrc/journal -I../src/journal -Isrc/journal-remote -I../src/journal-remote -Isrc/nspawn -I../src/nspawn -Isrc/resolve -I../src/resolve -Isrc/timesync -I../src/timesync -I../src/time-wait-sync -Isrc/login -I../src/login -Isrc/udev -I../src/udev -Isrc/libudev -I../src/libudev -Isrc/core -I../src/core -Isrc/shutdown -I../src/shutdown -I../src/xdg-autostart-generator -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/libsystemd-network -I../src/libsystemd-network -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu99 -g -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result -Wno-format-signedness -Werror=undef -Wlogical-op -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Winit-self -Wfloat-equal -Wsuggest-attribute=noreturn -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=missing-declarations -Werror=return-type -Werror=incompatible-pointer-types -Werror=format=2 -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wimplicit-fallthrough=5 -Wshadow -Wendif-labels -Wstrict-aliasing=2 -Wwrite-strings -Werror=overflow -Werror=shift-count-overflow -Werror=shift-overflow=2 -Wdate-time -Wnested-externs -Wno-maybe-uninitialized -ffast-math -fno-common -fdiagnostics-show-option -fno-strict-aliasing -fvisibility=hidden -fstack-protector -fstack-protector-strong --param=ssp-buffer-size=4 -Werror=shadow -include config.h -MD -MQ test-parse-util.p/src_test_test-parse-util.c.o -MF test-parse-util.p/src_test_test-parse-util.c.o.d -o test-parse-util.p/src_test_test-parse-util.c.o -c ../src/test/test-parse-util.c In file included from ../src/test/test-parse-util.c:14: ../src/shared/seccomp-util.h:4:10: fatal error: seccomp.h: No such file or directory 4 | #include <seccomp.h> | ^~~~~~~~~~~ compilation terminated. Add the respective deps. Fixes: 005bfaf118 ("exec: Add kill action to system call filters")
* | | Merge pull request #15206 from anitazha/systoomd-v0Zbigniew Jędrzejewski-Szmek2020-10-157-4/+149
|\ \ \ | | | | | | | | systemd-oomd
| * | | cgroup-util: add cg_get_attribute_as_bool() helperAnita Zhang2020-10-072-0/+23
| | | |