summaryrefslogtreecommitdiff
path: root/src/basic
Commit message (Collapse)AuthorAge
...
* missing.h: Explicitly check for IFLA_BRPORT_PROXYARPDaniel Mack2017-06-16
| | | | | | | | | | | | | | | RHEL explicitly disables IFLA_BRPORT_PROXYARP by renaming the enum value. In order to support unpatched builds, we have two options: a) redefine the enum value through missing.h and ignore the fact that it is really unsupported, or b) omit that enum value on rtnl_prot_info_bridge_port_types[] As we are not actually using this netlink type anywhere, and because it is only hooked up for the sake of completeness, this patch opts for the former.
* tree-wide: place #pragma once at the same place everywhereLennart Poettering2017-06-16
| | | | | | Usually, we place the #pragma once before the copyright blurb in header files, but in a few cases we didn't. Move those around, so that we do the same thing everywhere.
* sd-lldp: move ETHERTYPE_LLDP to missing.hLennart Poettering2017-06-16
| | | | | After all, most ETHERTYPE variables are defined in the system headers, hence define these where we defined all other fill-ins for system headers.
* alloc-util: cleanupsAlexander Kuleshov2017-06-16
| | | | | | | | | | | | | | | This patch contains a set of little cleanups for alloc-util.h: 1. The malloc_multiply(), realloc_multiply() and memdup_multiply() functions check allocation related parameters on overflow. Let's move them to the separate size_multiply_overflow() function for simplicity, code duplication prevention and possible reuse in future. 2. use SIZE_MAX from stdlib instead of ((size_t) - 1) to be more clear. 3. The 'a'/'b' variables are renamed to 'size' and 'need' to be more clear.'
* time-util: Rename and fix call of deserialize_timestamp_value()Benjamin Robin2017-06-16
| | | | | | The deserialize_timestamp_value() is renamed timestamp_deserialize() to be more consistent with dual_timestamp_deserialize() And add the NULL check back on realtime and monotonic
* build-sys: fix type detectionLennart Poettering2017-06-16
| | | | | | | | | | | | | Before this patch existence of char16_t, char32_t, key_serial_t was checked with AC_CHECK_DECLS() which doesn't actually work for types. Correct this to use AC_CHECK_TYPES() instead. Also, while we are at it, change the check for memfd_create() to use AC_CHECK_DECLS() instead of AC_CHECK_FUNCS(). This is a better choice, since a couple of syscalls are defined by glibc but not exported in the header files (pivot_root() for example), and we hence should probably be more picky with memfd_create() too, which glibc might decide to expose one day, but not necessarily in the headers too.
* time-util: introduce deserialize_timestamp_value()Alexander Kuleshov2017-06-16
| | | | | | | | | | | | | The time-util.c provides dual_timestamp_deserialize() function to convert value to usec_t and set it as value of ts->monotonic and ts->realtime. There are some places in code which do the same but only for one clockid_t (realtime or monotonic), when dual_timestamp_deserialize() sets value of both. This patch introduces the deserialize_timestamp_value() which converts a given value to usec_t and write it to a given timestamp.
* tree-wide: make more global variables staticLennart Poettering2017-06-16
| | | | let's export as little as we can
* missing.h: define IFLA_EXT_MASKRabin Vincent2017-06-16
| | | | | | We already define IFLA_PROMISCUITY and some other of these masks in order to allow building with older headers. Define IFLA_EXT_MASK too, which was added in the same kernel version as IFLA_PROMISCUITY (v3.10).
* basic/strv: fix strv_join for first empty argumentZbigniew Jędrzejewski-Szmek2017-06-16
| | | | | | | | | | | | | | | | | | | | | | | | | Empty strings were ignored in strv_join, but only if they were at the beginning of the string. Empty strings after at least one non-empty item were treated normally. Previously: {"x"} → "x" {"x", ""} → "x" {"x", "", ""} → "x::" {""} → "" {"", ""} → "" {"", "", ""} → "" {"", "x"} → "x" {"", "x", ""} → "x:" Now: {"x"} → "x" {"x", ""} → "x" {"x", "", ""} → "x::" {""} → "" {"", ""} → ":" {"", "", ""} → "::" {"", "x"} → ":x" {"", "x", ""} → ":x:"
* Add memcpy_safeZbigniew Jędrzejewski-Szmek2017-06-16
| | | | | | | | | | | | | | | | | ISO/IEC 9899:1999 §7.21.1/2 says: Where an argument declared as size_t n specifies the length of the array for a function, n can have the value zero on a call to that function. Unless explicitly stated otherwise in the description of a particular function in this subclause, pointer arguments on such a call shall still have valid values, as described in 7.1.4. In base64_append_width memcpy was called as memcpy(x, NULL, 0). GCC 4.9 started making use of this and assumes This worked fine under -O0, but does something strange under -O3. This patch fixes a bug in base64_append_width(), fixes a possible bug in journal_file_append_entry_internal(), and makes use of the new function to simplify the code in other places.
* cgroup2: use new fstype for unified hierarchyAlban Crequy2017-06-16
| | | | | | | | | | | | | | Since Linux v4.4-rc1, __DEVEL__sane_behavior does not exist anymore and is replaced by a new fstype "cgroup2". With this patch, elogind no longer supports the old (unstable) way of doing unified hierarchy with __DEVEL__sane_behavior and elogind now requires Linux v4.4 for unified hierarchy. Non-unified hierarchy is still the default and is unchanged by this patch. https://github.com/torvalds/linux/commit/67e9c74b8a873408c27ac9a8e4c1d1c8d72c93ff
* musl-fix: faccessat does not support AT_SYMLINK_NOFOLLOW with musl.Enno Boland2017-05-24
|
* Prep v229: Some musl-libc compatibility updatesSven Eden2017-05-22
| | | | | | - musl-libc has no <bits/local_lim.h> - musl-libc has no <xlocale.h> - added <missing.h> include to basic/mdkir.c
* Prep v229: Mask more unused functions in src/basicSven Eden2017-05-18
|
* Prep v229: Use parse-printf-format.h if configure did not find printf.hSven Eden2017-05-18
|
* Prep v229: Add include for parse-printf-format.h to src/basic/stdio-util.hSven Eden2017-05-17
| | | | | | | Now that dedicated libc headers are included in their corresponding foo-util.h headers, stdio-util.h is the only place left, where printf.h was included. The nice thing is, that this is the only place left where we have to take care about printf and musl-libc.
* Prep v229: Remove remaining emacs settings [1/6] src/basicSven Eden2017-05-17
|
* Prep v229: Add missing fixes from upstream [1/6] src/basicSven Eden2017-05-17
|
* cgroup: remove support for NetClass= directiveDaniel Mack2017-05-17
| | | | | | | | | | | | | | | | | | | Support for net_cls.class_id through the NetClass= configuration directive has been added in v227 in preparation for a per-unit packet filter mechanism. However, it turns out the kernel people have decided to deprecate the net_cls and net_prio controllers in v2. Tejun provides a comprehensive justification for this in his commit, which has landed during the merge window for kernel v4.5: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=bd1060a1d671 As we're aiming for full support for the v2 cgroup hierarchy, we can no longer support this feature. Userspace tool such as nftables are moving over to setting rules that are specific to the full cgroup path of a task, which obsoletes these controllers anyway. This commit removes support for tweaking details in the net_cls controller, but keeps the NetClass= directive around for legacy compatibility reasons.
* tree-wide: remove Emacs lines from all filesDaniel Mack2017-05-17
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* time-util: introduce usec_sub()Alexander Kuleshov2017-05-17
| | | | | | | The dual_timestamp_from_realtime(), dual_timestamp_from_monotonic() and dual_timestamp_from_boottime_or_monotonic() shares the same code for comparison given ts with delta. Let's move it to the separate inline function to prevent code duplication.
* coredump: rework coredumping logicLennart Poettering2017-05-17
| | | | | | | | | | | | | | | | This reworks the coredumping logic so that the coredump handler invoked from the kernel only collects runtime data about the crashed process, and then submits it for processing to a socket-activate coredump service, which extracts a stacktrace and writes the coredump to disk. This has a number of benefits: the disk IO and stack trace generation may take a substantial amount of resources, and hence should better be managed by PID 1, so that resource management applies. This patch uses RuntimeMaxSec=, Nice=, OOMScoreAdjust= and various sandboxing settings to ensure that the coredump handler doesn't take away unbounded resources from normally priorized processes. This logic is also nice since this makes sure the coredump processing and storage is delayed correctly until /var/elogind/coredump is mounted and writable. Fixes: #2286
* time-util: use dual_timestamp_get()Alexander Kuleshov2017-05-17
| | | | | | The time-util.c provides dual_timestamp_get() function for getting realtime and monotonic timestamps. Let's use it instead of direct realtime/monotonic calculation.
* util: add check that makes sure time_t and TIME_T_MAX work the way we assume ↵Lennart Poettering2017-05-17
| | | | they do
* basic: fix touch() creating files with 07777 modeMantas Mikulėnas2017-05-17
| | | | | | | mode_t is unsigned, so MODE_INVALID < 0 can never be true. This fixes a possible DoS where any user could fill /run by writing to a world-writable /run/elogind/show-status.
* basic: when parsing verb command lines, optionally shortcut them in chroot() ↵Lennart Poettering2017-05-17
| | | | | | environments This adds some basic infrastructure in order to fix #2015.
* basic: getauxval(AT_RANDOM) is apparently not necessarily alignedLennart Poettering2017-05-17
| | | | | | Let's make sure we read it in a way compatible with non-aligned memory. Fixes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=812928
* basic: don't append suffixes to unit name glob expressionsLennart Poettering2017-05-17
| | | | | | | When the user specifies "foo*" as unit name glob expression, we shouldn't turn this into "foo*.service". Hence: only append a suffix if the specified string isn't a glob expression. Fixes: #2397
* machined: add early checks for unrealistically large image/pool sizesLennart Poettering2017-05-17
|
* shutdown: complain if process excluded from killing spree runs of the same ↵Michal Sekletar2017-05-17
| | | | rootfs as PID1
* elogind-activate: Add support for datagram socketsSusant Sahani2017-05-17
| | | | | | | | | core: Add flexible way to provide socket type the socket type should be a diffrent argumet in make_socket_fd . In this way we can set the socket type like SOCK_STREAM SOCK_DGRAM in the address. journal-remote: modify make_socket_fd
* core: add valgrind helper for daemon-reexecEvgeny Vereshchagin2017-05-17
| | | | Inspired by https://github.com/elogind/elogind/issues/2187#issuecomment-165587140
* Fix IPv6PrivacyExtension (networkd-ndisc.c)Dominik Hannen2017-05-17
| | | | | This small addition fixes the issues #1982 and #2242. IPv6PrivacyExtension now works as expected even when a RA is received.
* basic: add ascii_strcasecmp_nn() callLennart Poettering2017-05-17
| | | | | In contrast to ascii_strcasecmp_nn() it takes two character buffers with their individual length. It will then compare the buffers up the smaller size of the two buffers, and finally the length themselves.
* basic: add new ascii_strcasecmp_n() callLennart Poettering2017-05-17
|
* basic/escape: merge utf8 and non-utf8 paths in cunescape_oneZbigniew Jędrzejewski-Szmek2017-05-17
| | | | | | | | | | | | | | | | | | | Not every byte sequence is valid utf8. We allow escaping of non-utf8 sequences in strings by using octal and hexadecimal escape sequences (\123 and \0xAB) for bytes at or above 128. Users of cunescape_one could infer whether such use occured when they received an answer between 128 and 256 in *ret (a non-ascii one byte character). But this is subtle and misleading: the comments were wrong, because ascii is a subset of unicode, so c != 0 did not mean non-unicode, but rather ascii-subset-of-unicode-or-raw-byte. This was all rather confusing, so make the "single byte" condition explicit. I'm not convinced that allowing non-utf8 sequences to be produced is useful in all cases where we allow it (e.g. in config files), but that behaviour is unchanged, just made more explicit. This also fixes an (invalid) gcc warning about unitialized variable (*ret_unicode) in callers of cunescape_one.
* tree-wide: use xsprintf() where applicableDaniel Mack2017-05-17
| | | | Also add a coccinelle receipt to help with such transitions.
* tree-wide: check if errno is greater than zero (2)Zbigniew Jędrzejewski-Szmek2017-05-17
| | | | | Compare errno with zero in a way that tells gcc that (if the condition is true) errno is positive.
* tree-wide: check if errno is greater then zeroZbigniew Jędrzejewski-Szmek2017-05-17
| | | | | | | | | | | | | | gcc is confused by the common idiom of return errno ? -errno : -ESOMETHING and thinks a positive value may be returned. Replace this condition with errno > 0 to help gcc and avoid many spurious warnings. I filed a gcc rfe a long time ago, but it hard to say if it will ever be implemented [1]. Both conventions were used in the codebase, this change makes things more consistent. This is a follow up to bcb161b0230f. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61846
* macro.h: provide a switch-case statement generator for IN_SETDaniel Mack2017-05-17
| | | | | | | | | | | | Rather than walking a list of valid values one-by-one, generate a switch-case statement for the IN_SET() macro. This allows the compiler to further optimize its code output, possibly by generating jump tables. This effectively decreases the binary size slightly. The implementation is based on macro overloading depending on the number of arguments. h/t to the following post: https://stackoverflow.com/questions/11761703/overloading-macro-on-number-of-arguments
* shared: make sure foo.bar and foobar result in different domain name hashesLennart Poettering2017-05-17
| | | | | This also introduces a new macro siphash24_compress_byte() which is useful to add a single byte into the hash stream, and ports one user over to it.
* basic: split hash functions into their own header filesLennart Poettering2017-05-17
| | | | The hash operations are not really that specific to hashmaps, hence split them into a .c module of their own.
* basic: introduce generic ascii_strlower_n() call and make use of it everywhereLennart Poettering2017-05-17
|
* basic: add string table macros for "extended boolean" enumsLennart Poettering2017-05-17
| | | | | | | | | | In a couple of cases we maintain configuration settings that know an on and off state, like a boolean, plus some additional states. We generally parse them as booleans first, and if that fails check for specific additional values. This adds a generalized set of macros for parsing such settings, and ports one use in resolved and another in networkd over to it.
* basic: modernize conf-files.c a bitLennart Poettering2017-05-17
|
* core: socket options fix SCTP_NODELAYSusant Sahani2017-05-17
| | | | | SCTP_NODELAY is diffrent to TCP_NODELAY. Apply proper options in case of SCTP.
* basic: add missing word in commentZbigniew Jędrzejewski-Szmek2017-05-17
|
* utf8.[ch] et al: use char32_t and char16_t instead of int, int32_t, int16_tShawn Landden2017-05-17
| | | | | | | | | | | | rework C11 utf8.[ch] to use char32_t instead of uint32_t when referring to unicode chars, to make things more expressive. [ @zonque: * rebased to current master * use AC_CHECK_DECLS to detect availibility of char{16,32}_t * make utf8_encoded_to_unichar() return int ]
* basic: ENABLE_DEBUG_HASHMAP needs <pthread.h>Henrik Kaare Poulsen2017-05-17
| | | | this is a follow-up for commit 11c3a36649e5e5e77db499c92f3