summaryrefslogtreecommitdiff
path: root/src/basic
Commit message (Collapse)AuthorAge
* 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
|
* Build system: Fix various issues that came from errornous migration.Sven Eden2018-08-24
| | | | | | | No matter how much advanced check_tree.pl is, there are plenty possibilities where upstream changes can be transported wrong. Mainly adding something we then have to mask out. But at the end of the day this is actually wanted, so we do not miss important changes.
* tree-wide: drop MSG_NOSIGNAL flag from recvmsg() invocationsLennart Poettering2018-08-24
| | | | | | | | MSG_NOSIGNAL is only defined for sendmsg(), not for recvmsg(), hence let's drop it's use, in particular as it appears to create problems on older kernels. See: https://lists.freedesktop.org/archives/systemd-devel/2018-June/040869.html
* tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | Fixes #9320. for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms' done
* Drop my copyright headersZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | perl -i -0pe 's/\s*Copyright © .... Zbigniew Jędrzejewski.*?\n/\n/gms' man/*xml git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/(#\n)?# +Copyright © [0-9, -]+ Zbigniew Jędrzejewski.*?\n//gms' git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s*\/\*\*\*\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*?\s*\*\*\*\/\s*/\n\n/gms' git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*//gms'
* tree-wide: beautify remaining copyright statementsLennart Poettering2018-08-24
| | | | | | Let's unify an beautify our remaining copyright statements, with a unicode ©. This means our copyright statements are now always formatted the same way. Yay.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-08-24
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-08-24
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* copy: rework copy_file_atomic() to copy the specified file via O_TMPFILE if ↵Lennart Poettering2018-08-24
| | | | possible
* util: allow mkdtemp_malloc() to be called with NULL patternLennart Poettering2018-08-24
| | | | In that case simply place the directory in /tmp.
* fs-util: introduce fchmod_and_chown()Yu Watanabe2018-08-24
| | | | | The new function fchmod_and_chown() is almost same as chmod_and_chown() except it takes file descriptor instead of file path.
* locale-util: on overlayfs FTW_MOUNT causes nftw(3) to not list *any* filesFranck Bui2018-08-24
| | | | | | | | | | | | | | On overlayfs, FTW_MOUNT causes nftw to not list *any* files because the condition used by glibc to verify that it's on the same mountpoint doesn't work on overlayfs, see https://bugzilla.suse.com/show_bug.cgi?id=1096807 for the details. However using FTW_MOUNT doesn't seem to be really needed when walking through the keymap directorie tree. So until the glibc or the kernel is fixed (which might take some time), let's make localectl works with overlayfs. There's a small side effect here, by which regular (non-directory) files with bind mounts will be parsed while they were skipped by the previous logic.
* tree-wide: drop !! casts to booleansZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | They are not needed, because anything that is non-zero is converted to true. C11: > 6.3.1.2: When any scalar value is converted to _Bool, the result is 0 if the > value compares equal to 0; otherwise, the result is 1. https://stackoverflow.com/questions/31551888/casting-int-to-bool-in-c-c