summaryrefslogtreecommitdiff
path: root/src/basic
Commit message (Collapse)AuthorAge
* format-table: don't use unsigned when there's no point in itLennart Poettering2018-10-29
| | | | | | CID 1394372 (cherry picked from commit ee7b9f1dfc4653cc8ce26d57cbed249d7f9cea4b)
* mempool: only enable mempool use when linked to libsystemd-shared.soZbigniew Jędrzejewski-Szmek2018-10-29
| | | | | | | | | | | | | Mempool use is enabled or disabled based on the mempool_use_allowed symbol that is linked in. Should fix assert crashes in external programs caused by #9792. Replaces #10286. v2: - use two different source files instead of a gcc constructor (cherry picked from commit a5d8835c78112206bbf0812dd4cb471f803bfe88)
* Move use_pool() to mempool.c and rename to mempool_enabled()Zbigniew Jędrzejewski-Szmek2018-10-29
| | | | | | The only user is in hashmap.c, but it's a mempool thing. (cherry picked from commit 7c48ea02800782651b7da373c6165abb052f1382)
* hashmap: add an explicit assert() for detecting when objects migrated ↵Lennart Poettering2018-10-29
| | | | | | | | | | | | | between threads When clients don't follow protocol and use the same object from different threads, then we previously would silently corrupt memory. With this assert we'll fail with an assert(). This doesn't fix anything but certainly makes mis-uses easier to detect and debug. Triggered by https://bugzilla.redhat.com/show_bug.cgi?id=1609349 (cherry picked from commit 205c085bc36c2c61a09dc40621d8561b135d9b57)
* hashmap: add an environment variable to turn off the memory pool used by ↵Lennart Poettering2018-10-29
| | | | | | | | hashmaps Triggered by https://bugzilla.redhat.com/show_bug.cgi?id=1609349 (cherry picked from commit b4f607433cac749b617e15b3d5d122322ed2bc71)
* terminal-util: extra safety checks when parsing $COLUMNS or $LINES (#10314)Lennart Poettering2018-10-29
| | | | | | | | Let's make sure the integers we parse out are not larger than USHRT_MAX. This is a good idea as the kernel's TIOCSWINSZ ioctl for sizing terminals can't take larger values, and we shouldn't risk an overflow. (cherry picked from commit d09a71356e3ed78be7cef3cd7d9919dc77508b41)
* basic/proc-cmdline: allow parsing of cmdline from a stringZbigniew Jędrzejewski-Szmek2018-10-29
| | | | | | | | | | | Comes with tests. Also add direct test for $SYSTEMD_PROC_CMDLINE. In test-proc-cmdline, "true" was masquerading as PROC_CMDLINE_STRIP_RD_PREFIX, fix that. Also, reorder functions to match call order. (cherry picked from commit 9a135c084ae6d06734ec3380f0eafdecd7c216f8)
* Add $SYSTEMD_IN_INITRD=yes|no override for debuggingZbigniew Jędrzejewski-Szmek2018-10-29
| | | | (cherry picked from commit 0307ea49c70b1ed4f3af3c80566c8c098dc080bb)
* * hack around deficiencies in prctl() PR_SET_MM_*Frank Schaefer2018-10-29
| | | | (cherry picked from commit 14ee72b7d8de34a6b02767b865c3c49ceef2ed84)
* fileio: fix error propagation in link_tmpfile()Lennart Poettering2018-10-29
| | | | (cherry picked from commit eaa680c09e5701a62e8ac819211e5969eda84f2d)
* basic/hexdecoct: check for overflowZbigniew Jędrzejewski-Szmek2018-10-29
| | | | | | | | | LGTM was complaining: > Multiplication result may overflow 'int' before it is converted to 'long'. Fix this by changing all types to ssize_t and add a check for overflow while at it. (cherry picked from commit 3d6c1844744f631995af72867d5f293430d8015b)
* Introduce free_and_strndup and use it in bus-message.cZbigniew Jędrzejewski-Szmek2018-10-29
| | | | | | | | | | | | | | | | v2: fix error in free_and_strndup() When the orignal and copied message were the same, but shorter than specified length l, memory read past the end of the buffer would be performed. A test case is included: a string that had an embedded NUL ("q\0") is used to replace "q". v3: Fix one more bug in free_and_strndup and add tests. v4: Some style fixed based on review, one more use of free_and_replace, and make the tests more comprehensive. (cherry picked from commit 7f546026abbdc56c453a577e52d57159458c3e9c)
* exec-util: add missing logging callLennart Poettering2018-10-29
| | | | | | | This function logs about all errors, but one case was forgotten. Fix that. (cherry picked from commit 653d469519f78d3931c0bc9fe5597d18454bef3d)
* exec-util: handle putenv() errorsLennart Poettering2018-10-29
| | | | | | | | | Just paranoia, as putenv() can fail and we should catch it, like we catch all other errors. Follow-up for #10073 (cherry picked from commit ed689f7894e56024a11bd02327b2bdfce5636dfd)
* exec-util: in execute_directories, support initial exec environmentDimitri John Ledkov2018-10-29
| | | | (cherry picked from commit 78ec1bb436fb18df3b56212c442cc4775a136d1a)
* detect-virt: do not try to read all of /proc/cpuinfoZbigniew Jędrzejewski-Szmek2018-10-29
| | | | | | | | | | | | | | | Quoting https://github.com/systemd/systemd/issues/10074: > detect_vm_uml() reads /proc/cpuinfo with read_full_file() > read_full_file() has a file max limit size of READ_FULL_BYTES_MAX=(4U*1024U*1024U) > Unfortunately, the size of my /proc/cpuinfo is bigger, approximately: > echo $(( 4* $(cat /proc/cpuinfo | wc -c))) > 9918072 > This causes read_full_file() to fail and the Condition test fallout. Let's just read line by line until we find an intersting line. This also helps if not running under UML, because we avoid reading as much data. (cherry picked from commit 6058516a14ada1748313af6783f5b4e7e3006654)
* socket-util: attempt SO_RCVBUFFORCE/SO_SNDBUFFORCE only if ↵Franck Bui2018-10-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | SO_RCVBUF/SO_SNDBUF fails Both SO_SNDBUFFORCE and SO_RCVBUFFORCE requires capability 'net_admin'. If this capability is not granted to the service the first attempt to increase the recv/snd buffers (via sd_notify()) with SO_RCVBUFFORCE/SO_SNDBUFFORCE will fail, even if the requested size is lower than the limit enforced by the kernel. If apparmor is used, the DENIED logs for net_admin will show up. These log entries are seen as red warning light, because they could indicate that a program has been hacked and tries to compromise the system. It would be nicer if they can be avoided without giving services (relying on sd_notify) net_admin capability or dropping DENIED logs for all such services via their apparmor profile. I'm not sure if sd_notify really needs to forcibly increase the buffer sizes, but at least if the requested size is below the kernel limit, the capability (hence the log entries) should be avoided. Hence let's first ask politely for increasing the buffers and only if it fails then ignore the kernel limit if we have sufficient privileges. (cherry picked from commit 10ce2e0681ac16e7bb3619b7bb1a72a6f98a2f2c)
* importd, basic/string-util: use case-insensitive comparison for HTTP headersDongsu Park2018-10-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to RFC2616[1], HTTP header names are case-insensitive. So it's totally valid to have a header starting with either `Date:` or `date:`. However, when systemd-importd pulls an image from an HTTP server, it parses HTTP headers by comparing header names as-is, without any conversion. That causes failures when some HTTP servers return headers with different combinations of upper-/lower-cases. An example: https://alpha.release.flatcar-linux.net/amd64-usr/current/flatcar_developer_container.bin.bz2 returns `Etag: "pe89so9oir60"`, while https://alpha.release.core-os.net/amd64-usr/current/coreos_developer_container.bin.bz2 returns `ETag: "f03372edea9a1e7232e282c346099857"`. Since systemd-importd expects to see `ETag`, the etag for the Container Linux image is correctly interpreted as a part of the hidden file name. However, it cannot parse etag for Flatcar Linux, so the etag the Flatcar Linux image is not appended to the hidden file name. ``` $ sudo ls -al /var/lib/machines/ -r--r--r-- 1 root root 3303014400 Aug 21 20:07 '.raw-https:\x2f\x2falpha\x2erelease\x2ecore-os\x2enet\x2famd64-usr\x2fcurrent\x2fcoreos_developer_container\x2ebin\x2ebz2.\x22f03372edea9a1e7232e282c346099857\x22.raw' -r--r--r-- 1 root root 3303014400 Aug 17 06:15 '.raw-https:\x2f\x2falpha\x2erelease\x2eflatcar-linux\x2enet\x2famd64-usr\x2fcurrent\x2fflatcar_developer_container\x2ebin\x2ebz2.raw' ``` As a result, when the Flatcar image is removed and downloaded again, systemd-importd is not able to determine if the file has been already downloaded, so it always download it again. Then it fails to rename it to an expected name, because there's already a hidden file. To fix this issue, let's introduce a new helper function `memory_startswith_no_case()`, which compares memory regions in a case-insensitive way. Use this function in `curl_header_strdup()`. See also https://github.com/kinvolk/kube-spawn/issues/304 [1]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2 (cherry picked from commit 21224070e802878f81c342835364880ef1a63e88)
* util: do not use stack frame for parsing arbitrary inputsYu Watanabe2018-10-29
| | | | | | | | | | This replaces strndupa() by strndup() in socket_address_parse(), as input string may be too long. Fixes issue 10007 by ClusterFuzz-External: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10007 (cherry picked from commit 8d30fcb9b51b1d102a589171b6e28f5f370236f6)
* resolve: treat some icmp errors as disconnectedYu Watanabe2018-10-29
| | | | | | Fixes #9773. (cherry picked from commit 68c597e9e4bb36ade966d9df54dfaa9f956230e9)
* void call of page_size guarantees that sysconf is not called from signal handlerDaniel2018-10-29
| | | | (cherry picked from commit 1595b257df98b361d178b3ce3e4ca5ac463be0cd)
* parse-util: in parse_permille() check negative earlierLennart Poettering2018-10-29
| | | | | | | | | | If 'v' is negative, it's wrong to add the decimal to it, as we'd actually need to subtract it in this case. But given that we don't want to allow negative vaues anyway, simply check earlier whether what we have parsed so far was negative, and react to that before adding the decimal to it. (cherry picked from commit 8cbc92d5975b603002c3141364a7709a9c66e23a)
* Move module-util.h to src/shared/ and load_module() to libsharedZbigniew Jędrzejewski-Szmek2018-10-29
| | | | | | | | | | Unfortunately this needs libshared to link to libkmod. Before it was linked into systemd-udevd, udevadm, and systemd each seperately. On most systems this doesn't make much difference, because at least systemd would be installed, but it might not be in small chroots. It is a small library, so I hope this is not a big issue. (cherry picked from commit 3cb9b42af3b205fba176ebf51ce0e07739698278)
* format-table: fix typo in commentYu Watanabe2018-10-29
| | | | (cherry picked from commit 475d8599b0821eefb6e6c283f4f9847cffbb4b7b)
* format-table: make all widths be set properlyNOGISAKA Sadata2018-10-29
| | | | | | Fixes #9549. (cherry picked from commit a26db0bc5d4011de24e5930af6fd9051deeb46be)
* Use #if instead of #ifdef for ENABLE_GSHADOWChenQi19892018-10-29
| | | | | | ENABLE_GSHADOW is defined to be 0 or 1. So #if should be used instead of #ifdef. (cherry picked from commit 4f07ffa8f5ab85011422bb7114f1cddf49d4923d)
* basic: add missing comma in raw_clone assembly for sparcMike Gilbert2018-10-29
| | | | | | Fixes: 96f64eb5741b157f26a9089816fdd992e959792e Closes: https://github.com/systemd/systemd/issues/9444 (cherry picked from commit 358248caa3eca525751694de7c34b16bb46d5a9c)
* core/dbus-execute: fix parsing CPUScheduling* and Nice for transient servicesYu Watanabe2018-10-29
| | | | | | Fixes #10290. (cherry picked from commit c250bf671b89768ed27984defe9b5af262618e42)
* meson: unify linux/stat.h check with other checks and use _GNU_SOURCEZbigniew Jędrzejewski-Szmek2018-10-29
| | | | | | | | Using _GNU_SOURCE is better because that's how we include the headers in the actual build, and some headers define different stuff when it is defined. sys/stat.h for example defines 'struct statx' conditionally. (cherry picked from commit 9c869d08d82c73f62ab3527567858ce4b0cf1257)
* build-sys: Detect whether struct statx is defined in sys/stat.hFilipe Brandenburger2018-10-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Starting with glibc 2.27.9000-36.fc29, include file sys/stat.h will have a definition for struct statx, in which case include file linux/stat.h should be avoided, in order to prevent a duplicate definition. In file included from ../src/basic/missing.h:18, from ../src/basic/util.h:28, from ../src/basic/hashmap.h:10, from ../src/shared/bus-util.h:12, from ../src/libsystemd/sd-bus/bus-creds.c:11: /usr/include/linux/stat.h:99:8: error: redefinition of ‘struct statx’ struct statx { ^~~~~ In file included from /usr/include/sys/stat.h:446, from ../src/basic/util.h:19, from ../src/basic/hashmap.h:10, from ../src/shared/bus-util.h:12, from ../src/libsystemd/sd-bus/bus-creds.c:11: /usr/include/bits/statx.h:36:8: note: originally defined here struct statx ^~~~~ Extend our meson.build to look for struct statx when only sys/stat.h is included and, in that case, do not include linux/stat.h anymore. Tested that systemd builds correctly when using a glibc version that includes a definition for struct statx. glibc Fedora RPM update: https://src.fedoraproject.org/rpms/glibc/c/28cb5d31fc1e5887912283c889689c47076278ae glibc upstream commit: https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=fd70af45528d59a00eb3190ef6706cb299488fcd (cherry picked from commit 75720bff62a84896e9a0654afc7cf9408cf89a38)
* Support system_bus_socket to be found in /var/run/dbus as well as /run/dbus.Christoph Willing2018-09-26
| | | | | | | | | | | | | | | | Currently the path to system_bus_socket is hardcoded to /run/dbus/system_bus_socket which works everywhere for systemd. However, distributions which do no symlink /var/run on /run will have it only accessible via /run/dbus/system_bus_socket which should be supported by elogind, too. Closes #77 Signed-off-by: Christoph Willing <chris.willing@linux.com> Sigend-off-by: Sven Eden <sven.eden@prydeworx.com>
* Enhance the dealing with glibc-2.28Sven Eden2018-09-26
| | | | | | | It appears that the necessary bits were already there, but commented out. When meson checked for 'struct statx', the inclusion of both sys/stat.h and linux/stat.h where commented out. Uncommenting them should be enough.
* Deal with glibc-2.28Christoph Willing2018-09-25
| | | | | | Closes: https://github.com/elogind/elogind/issues/74 Signed-off-by: Christoph Willing <chris.willing@linux.com> Signed-off-by: Sven Eden <sven.eden@prydeworx.com>
* Prep v239: Unmask cg_weight_parse()Sven Eden2018-08-24
|
* Prep v239: Remove os-util.[hc] - We do not need anything in there.Sven Eden2018-08-24
|
* Prep v239: Unmasked mkdtemp_malloc(), it is needed to test inotify.Sven Eden2018-08-24
|
* Prep v239: Unmask inotify_add_watch_fd()Sven Eden2018-08-24
|
* Prep v239: Mask all unneeded functions in the new format-table.[hc] files.Sven Eden2018-08-24
|
* Prep v239: Unmask delete_chars()Sven Eden2018-08-24
|
* Prep v239: Unmask inotify event stuff, now ustilized by the sd_event struct.Sven Eden2018-08-24
|
* Prep v239: Mirror upstream and move pager.[hc] from shared to basic.Sven Eden2018-08-24
|
* Prep v239: Fix conf-parser.[hc], it got a bit mangled by migration.Sven Eden2018-08-24
|
* Prep v239: terminal-util.[hc] - Mask new 'urlify' functions, we do not need ↵Sven Eden2018-08-24
| | | | them.
* Prep v239: string-util.[hc] - Unmasked skip_leading_chars() - Newly utilized ↵Sven Eden2018-08-24
| | | | by strstrip()
* Prep v239: path-util.[hc] - Masked path_simplify_and_warn() - Nowhere needed.Sven Eden2018-08-24
|
* Prep v239: fd-util.[hc] - Masked fd_duplicate_data_fd() - Nowhere needed.Sven Eden2018-08-24
|
* Prep v239: Uncomment header inclusions that are new or needed now.Sven Eden2018-08-24
|
* Prep v239: fs-util: Mask new chase_symlinks_and_*() functions.Sven Eden2018-08-24
| | | | They are nowhere needed.
* Prep v239: Remove basic/set.c - No longer needed.Sven Eden2018-08-24
|
* Prep v239: Add missing updates that evaded migration.Sven Eden2018-08-24
|