summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAge
* 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.
* core: change internal error code for masked units from EBADR to ESHUTDOWNLennart Poettering2017-05-17
| | | | | | | | | | | | | | | | | This commit changes the mapping of the BUS_ERROR_UNIT_MASKED error to ESHUTDOWN. This error is used whenever the transaction engine is asked to operate on a masked unit. ESHUTDOWN is what is used for the similar case when the unit file enable/disable logic hits a masked unit file, hence is a natural candidate to be used here too. Background: before this patch both "job type not applicable" and "unit masked" where mapped to EBADR, which transaction_add_job_and_dependencies() then checked for. It actually wanted to check exclusively for the former error condition, not the latter but due to the same mapping this failed to work. This patch semi-undoes an accidental change made in caffa4ef700fdd0eadd6c0b2ef9925611672a1bc, however restores the error number to ESHUTDOWN instead of the original ENOSYS (for the reasons indicated above). To make this easier to grok for the future, I added comments to explaining which error conditions are checked for. Fixes: #2315
* 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.
* core: log about path_is_mount_point() errorsLennart Poettering2017-05-17
| | | | | | | We really shouldn't fail silently, but print a log message about these errors. Also make sure to attach error codes to all log messages where that makes sense. (While we are at it, add a couple of (void) casts to functions where we knowingly ignore return values.)
* util: add check that makes sure time_t and TIME_T_MAX work the way we assume ↵Lennart Poettering2017-05-17
| | | | they do
* logind: load SELinux labelling systemNicolas Iooss2017-05-17
| | | | | | | | | | | elogind-logind uses mkdir_label and label_fix functions without calling first mac_selinux_init. This makes /run/user/$UID/ directories not labelled correctly on an Arch Linux system using SELinux. Fix this by calling mac_selinux_init("/run") early in elogind-logind. This makes files created in /etc/udev/rules.d and /var/lib/elogind to be labelled through transitions in the SELinux policy instead of using setfscreatecon (with mac_selinux_create_file_prepare).
* core: rework unit timeout handling, and add new setting RuntimeMaxSec=Lennart Poettering2017-05-17
| | | | | | | | | | | | | | | | | | | | | | This clean-ups timeout handling in PID 1. Specifically, instead of storing 0 in internal timeout variables as indication for a disabled timeout, use USEC_INFINITY which is in-line with how we do this in the rest of our code (following the logic that 0 means "no", and USEC_INFINITY means "never"). This also replace all usec_t additions with invocations to usec_add(), so that USEC_INFINITY is properly propagated, and sd-event considers it has indication for turning off the event source. This also alters the deserialization of the units to restart timeouts from the time they were originally started from. Before this patch timeouts would be restarted beginning with the time of the deserialization, which could lead to artificially prolonged timeouts if a daemon reload took place. Finally, a new RuntimeMaxSec= setting is introduced for service units, that specifies a maximum runtime after which a specific service is forcibly terminated. This is useful to put time limits on time-intensive processing jobs. This also simplifies the various xyz_spawn() calls of the various types in that explicit distruction of the timers is removed, as that is done anyway by the state change handlers, and a state change is always done when the xyz_spawn() calls fail. Fixes: #2249
* core: fix support for transient resource limit propertiesLennart Poettering2017-05-17
| | | | | | | | | | | | | Make sure we can properly process resource limit properties. Specifically, allow transient configuration of both the soft and hard limit, the same way from the unit files. Previously, only the the hard rlimits could be configured but they'd implicitly spill into the soft hard rlimits. This also updates the client-side code to be able to parse hard/soft resource limit specifications. Since we need to serialize two properties in bus_append_unit_property_assignment() now, the marshalling of the container around it is now moved into the function itself. This has the benefit of shortening the calling code. As a side effect this now beefs up the rlimit parser of "systemctl set-property" to understand time and disk sizes where that's appropriate.
* shared: simplify parsing of bus properties a bitLennart Poettering2017-05-17
| | | | Let's write the property name and value in one call, when that's possible, shorthing our code a bit.
* core: fix handling of AccuracyUSec and RandomDelayUSec bus propertiesLennart Poettering2017-05-17
| | | | | | | | | | | Clear up some confusion regarding the USec and Sec suffixes we use. In configuration files we usually use the Sec suffix, to indicate the implied time unit if none is specified. The respective bus properties however use the USec property, since they expose 64bit unsigned integers containing time in µs. Before this patch timer units exposed a bus property AccuracyUSec (which hence is the correct name) but when parsing transient property data would look for AccuracySec instead (which is incorrect). This patch ensures we look for AccuracySec correctly, but keeps the code for AccuracyUSec in place for compatibility, but adds a warning to ensure that apps are updated to use the right property.
* sd-event: permit a USEC_INFINITY timeout as an alternative to a disabling an ↵Lennart Poettering2017-05-17
| | | | | | | event source This should simplify handling of time events in clients and is in-line with the USEC_INFINITY macro we already have. This way setting a timeout to 0 indicates "elapse immediately", and a timeout of USEC_INFINITY "elapse never".
* sd-event: when determining the last allowed time a time event may elapse, ↵Lennart Poettering2017-05-17
| | | | deal with overflows
* 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.
* systemctl: improve message when a job fails with a JOB_INVALID stateLennart Poettering2017-05-17
| | | | This result can only happen if the job was a reload job for an inactive unit. Make the error message actually say that.
* 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
* nss: block various signals while running NSS lookupsLennart Poettering2017-05-17
| | | | | | | Let's make sure our poll() calls don't get interrupted where they shouldn't (SIGALRM, ...), but allow them to be interrupted where they should (SIGINT, ...). Fixes #1965
* 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
* resolve: generate a nice clean error when clients try to resolve a name when ↵Lennart Poettering2017-05-17
| | | | the network is down
* logind,machined: bump TasksMax=Lennart Poettering2017-05-17
| | | | | | | | | Issue #2388 suggests the current TasksMax= setting for user processes is to low. Bump it to 12K. Also, bump the container TasksMax= from 8K to 16K, so that it remains higher than the one for user processes. (Compare: the kernel default limit for processes system-wide is 32K). Fixes #2388
* resolved: add bus API for configuring per-link DNS settingsLennart Poettering2017-05-17
| | | | | | | | This is useful for alternative network management solutions (such as NetworkManager) to push DNS configuration data into resolved. The calls will fail should networkd already have taken possesion of a link, so that the bus API is only available if we don't get the data from networkd.
* resolved: add a couple of errors to the error mapping tablesLennart Poettering2017-05-17
| | | | These were previously forgotten, add them now.
* 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.
* bus-error: verify additional error maps during installationZbigniew Jędrzejewski-Szmek2017-05-17
| | | | | | | Go over the entries in the map and check that they make sense. Tests are added. In the future we might want to do additional checks, e.g. verifying that the error names are in the expected format.
* 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,bus-error: return negative error from errno_from_nameZbigniew Jędrzejewski-Szmek2017-05-17
| | | | | | | | | | errno_from_name used an unusual return convention where 0 meant "not found". This tripped up config_parse_syscall_errno(), which would treat that as success. Return -EINVAL instead, and adjust bus_error_name_to_errno() for the new convention. Also remove a goto which was used as a simple if and clean up surroudning code a bit.
* 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.
* sd-event: minor fixups to delays profiling changesVito Caputo2017-05-17
|
* tree-wide: use xsprintf() where applicableDaniel Mack2017-05-17
| | | | Also add a coccinelle receipt to help with such transitions.
* sd-event: check clock argument to sd_event_now()Zbigniew Jędrzejewski-Szmek2017-05-17
| | | | | | | | sd_event_now() is a public function, so we must check all arguments for validity. Update man page and add tests. Sample debug message: Assertion 'IN_SET(clock, CLOCK_REALTIME, CLOCK_REALTIME_ALARM, CLOCK_MONOTONIC, CLOCK_BOOTTIME, CLOCK_BOOTTIME_ALARM)' failed at src/libelogind/sd-event/sd-event.c:2719, function sd_event_now(). Ignoring.
* 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
* bus-kernel: reword assignment of dst_id in bus_message_setup_kmsgZbigniew Jędrzejewski-Szmek2017-05-17
| | | | | | | | Setting of dst_id was based on interplay of two booleans, making the logic hard to follow (for humans and compilers alike). gcc was confused and emmitted a warning about an uninitialized variable. Rework the code to make it obvious that dst_id is set properly.
* 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
* resolved: don't attempt to send queries for DNSSEC RR types to servers not ↵Lennart Poettering2017-05-17
| | | | | | | | | | | supporting them If we already degraded the feature level below DO don't bother with sending requests for DS, DNSKEY, RRSIG, NSEC, NSEC3 or NSEC3PARAM RRs. After all, we cannot do DNSSEC validation then anyway, and we better not press a legacy server like this with such modern concepts. This also has the benefit that when we try to validate a response we received using DNSSEC, and we detect a limited server support level while doing so, all further auxiliary DNSSEC queries will fail right-away.
* 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.
* resolved: explicitly handle case when the trust anchor is emptyLennart Poettering2017-05-17
| | | | | | | | | | | | | | | | | | Since we honour RFC5011 revoked keys it might happen we end up with an empty trust anchor, or one where there's no entry for the root left. With this patch the logic is changed what to do in this case. Before this patch we'd end up requesting the root DS, which returns with NODATA but a signed NSEC we cannot verify, since the trust anchor is empty after all. Thus we'd return a DNSSEC result of "missing-key", as we lack a verified version of the key. With this patch in place, look-ups for the root DS are explicitly recognized, and not passed on to the DNS servers. Instead, if downgrade-ok mode is on an unsigned NODATA response is synthesized, so that the validator code continues under the assumption the root zone was unsigned. If downgrade-ok mode is off a new transaction failure is generated, that makes this case recognizable.
* resolved: introduce a proper bus error for DNSSEC validation errorsLennart Poettering2017-05-17
|
* 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.