chiark / gitweb /
elogind.git
6 years agoPrep v229: Add missing fixes from upstream [6/6] src/systemd
Sven Eden [Fri, 28 Apr 2017 05:18:56 +0000 (07:18 +0200)]
Prep v229: Add missing fixes from upstream [6/6] src/systemd

6 years agoPrep v229: Add missing fixes from upstream [5/6] src/shared
Sven Eden [Fri, 28 Apr 2017 05:08:08 +0000 (07:08 +0200)]
Prep v229: Add missing fixes from upstream [5/6] src/shared

6 years agoPrep v229: Add missing fixes from upstream [4/6] src/login
Sven Eden [Thu, 27 Apr 2017 16:17:13 +0000 (18:17 +0200)]
Prep v229: Add missing fixes from upstream [4/6] src/login

6 years agoPrep v229: Add missing fixes from upstream [3/6] src/libelogind
Sven Eden [Thu, 27 Apr 2017 10:00:06 +0000 (12:00 +0200)]
Prep v229: Add missing fixes from upstream [3/6] src/libelogind

6 years agoPrep v229: Add missing fixes from upstream [2/6] src/core
Sven Eden [Thu, 27 Apr 2017 09:50:26 +0000 (11:50 +0200)]
Prep v229: Add missing fixes from upstream [2/6] src/core

6 years agoPrep v229: Add missing fixes from upstream [1/6] src/basic
Sven Eden [Thu, 27 Apr 2017 09:30:28 +0000 (11:30 +0200)]
Prep v229: Add missing fixes from upstream [1/6] src/basic

6 years agocgroup: remove support for NetClass= directive
Daniel Mack [Wed, 10 Feb 2016 14:44:01 +0000 (15:44 +0100)]
cgroup: remove support for NetClass= directive

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.

6 years agotree-wide: remove Emacs lines from all files
Daniel Mack [Wed, 10 Feb 2016 12:26:21 +0000 (13:26 +0100)]
tree-wide: remove Emacs lines from all files

This should be handled fine now by .dir-locals.el, so need to carry that
stuff in every file.

6 years agocore: change internal error code for masked units from EBADR to ESHUTDOWN
Lennart Poettering [Tue, 9 Feb 2016 19:28:58 +0000 (20:28 +0100)]
core: change internal error code for masked units from EBADR to ESHUTDOWN

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
6 years agotime-util: introduce usec_sub()
Alexander Kuleshov [Thu, 4 Feb 2016 18:02:39 +0000 (00:02 +0600)]
time-util: introduce usec_sub()

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.

6 years agocoredump: rework coredumping logic
Lennart Poettering [Mon, 8 Feb 2016 20:16:08 +0000 (21:16 +0100)]
coredump: rework coredumping logic

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
6 years agotime-util: use dual_timestamp_get()
Alexander Kuleshov [Thu, 4 Feb 2016 19:03:23 +0000 (01:03 +0600)]
time-util: use dual_timestamp_get()

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.

6 years agocore: log about path_is_mount_point() errors
Lennart Poettering [Wed, 3 Feb 2016 22:53:08 +0000 (23:53 +0100)]
core: log about path_is_mount_point() errors

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.)

6 years agoutil: add check that makes sure time_t and TIME_T_MAX work the way we assume they do
Lennart Poettering [Wed, 3 Feb 2016 20:05:59 +0000 (21:05 +0100)]
util: add check that makes sure time_t and TIME_T_MAX work the way we assume they do

6 years agologind: load SELinux labelling system
Nicolas Iooss [Tue, 2 Feb 2016 19:07:46 +0000 (20:07 +0100)]
logind: load SELinux labelling system

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).

6 years agocore: rework unit timeout handling, and add new setting RuntimeMaxSec=
Lennart Poettering [Mon, 1 Feb 2016 20:48:10 +0000 (21:48 +0100)]
core: rework unit timeout handling, and add new setting RuntimeMaxSec=

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
6 years agocore: fix support for transient resource limit properties
Lennart Poettering [Mon, 1 Feb 2016 20:37:28 +0000 (21:37 +0100)]
core: fix support for transient resource limit properties

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.

6 years agoshared: simplify parsing of bus properties a bit
Lennart Poettering [Mon, 1 Feb 2016 20:31:44 +0000 (21:31 +0100)]
shared: simplify parsing of bus properties a bit

Let's write the property name and value in one call, when that's possible, shorthing our code a bit.

6 years agocore: fix handling of AccuracyUSec and RandomDelayUSec bus properties
Lennart Poettering [Mon, 1 Feb 2016 20:27:33 +0000 (21:27 +0100)]
core: fix handling of AccuracyUSec and RandomDelayUSec bus properties

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.

6 years agosd-event: permit a USEC_INFINITY timeout as an alternative to a disabling an event...
Lennart Poettering [Sun, 31 Jan 2016 23:20:18 +0000 (00:20 +0100)]
sd-event: permit a USEC_INFINITY timeout as an alternative to a disabling an 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".

6 years agosd-event: when determining the last allowed time a time event may elapse, deal with...
Lennart Poettering [Sun, 31 Jan 2016 23:19:14 +0000 (00:19 +0100)]
sd-event: when determining the last allowed time a time event may elapse, deal with overflows

6 years agobasic: fix touch() creating files with 07777 mode
Mantas Mikulėnas [Fri, 29 Jan 2016 21:36:08 +0000 (23:36 +0200)]
basic: fix touch() creating files with 07777 mode

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.

6 years agobasic: when parsing verb command lines, optionally shortcut them in chroot() environments
Lennart Poettering [Thu, 28 Jan 2016 18:30:56 +0000 (19:30 +0100)]
basic: when parsing verb command lines, optionally shortcut them in chroot() environments

This adds some basic infrastructure in order to fix #2015.

6 years agosystemctl: improve message when a job fails with a JOB_INVALID state
Lennart Poettering [Thu, 28 Jan 2016 17:53:34 +0000 (18:53 +0100)]
systemctl: improve message when a job fails with a JOB_INVALID state

This result can only happen if the job was a reload job for an inactive unit. Make the error message actually say that.

6 years agobasic: getauxval(AT_RANDOM) is apparently not necessarily aligned
Lennart Poettering [Thu, 28 Jan 2016 16:00:38 +0000 (17:00 +0100)]
basic: getauxval(AT_RANDOM) is apparently not necessarily aligned

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
6 years agosd-journal: add an API to enumerate known field names of the journal
Lennart Poettering [Wed, 27 Jan 2016 17:59:29 +0000 (18:59 +0100)]
sd-journal: add an API to enumerate known field names of the journal

This adds two new calls to get the list of all journal fields names currently in use.

This is the low-level support to implement the feature requested in #2176 in a more optimized way.

6 years agonss: block various signals while running NSS lookups
Lennart Poettering [Tue, 26 Jan 2016 21:34:46 +0000 (22:34 +0100)]
nss: block various signals while running NSS lookups

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

6 years agobasic: don't append suffixes to unit name glob expressions
Lennart Poettering [Tue, 26 Jan 2016 19:25:10 +0000 (20:25 +0100)]
basic: don't append suffixes to unit name glob expressions

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
6 years agomachined: add early checks for unrealistically large image/pool sizes
Lennart Poettering [Tue, 26 Jan 2016 18:02:12 +0000 (19:02 +0100)]
machined: add early checks for unrealistically large image/pool sizes

6 years agoman: document that logind's RemoveIPC= option excepts all system users
Lennart Poettering [Tue, 26 Jan 2016 12:42:04 +0000 (13:42 +0100)]
man: document that logind's RemoveIPC= option excepts all system users

Fixes #2324.

6 years agoshutdown: complain if process excluded from killing spree runs of the same rootfs...
Michal Sekletar [Sun, 24 Jan 2016 15:08:36 +0000 (16:08 +0100)]
shutdown: complain if process excluded from killing spree runs of the same rootfs as PID1

6 years agoelogind-activate: Add support for datagram sockets
Susant Sahani [Fri, 22 Jan 2016 04:11:44 +0000 (09:41 +0530)]
elogind-activate: Add support for datagram sockets

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

6 years agoresolve: generate a nice clean error when clients try to resolve a name when the...
Lennart Poettering [Wed, 20 Jan 2016 20:28:22 +0000 (21:28 +0100)]
resolve: generate a nice clean error when clients try to resolve a name when the network is down

6 years agologind,machined: bump TasksMax=
Lennart Poettering [Wed, 20 Jan 2016 19:27:21 +0000 (20:27 +0100)]
logind,machined: bump TasksMax=

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

6 years agoresolved: add bus API for configuring per-link DNS settings
Lennart Poettering [Tue, 19 Jan 2016 16:16:12 +0000 (17:16 +0100)]
resolved: add bus API for configuring per-link DNS settings

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.

6 years agoresolved: add a couple of errors to the error mapping tables
Lennart Poettering [Tue, 19 Jan 2016 16:15:02 +0000 (17:15 +0100)]
resolved: add a couple of errors to the error mapping tables

These were previously forgotten, add them now.

6 years agocore: add valgrind helper for daemon-reexec
Evgeny Vereshchagin [Tue, 19 Jan 2016 15:48:45 +0000 (15:48 +0000)]
core: add valgrind helper for daemon-reexec

Inspired by https://github.com/elogind/elogind/issues/2187#issuecomment-165587140

6 years agoFix IPv6PrivacyExtension (networkd-ndisc.c)
Dominik Hannen [Fri, 15 Jan 2016 22:39:54 +0000 (23:39 +0100)]
Fix IPv6PrivacyExtension (networkd-ndisc.c)

This small addition fixes the issues #1982 and #2242.
IPv6PrivacyExtension now works as expected even when a RA is received.

6 years agobus-error: verify additional error maps during installation
Zbigniew Jędrzejewski-Szmek [Wed, 13 Jan 2016 19:23:54 +0000 (14:23 -0500)]
bus-error: verify additional error maps during installation

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.

6 years agobasic: add ascii_strcasecmp_nn() call
Lennart Poettering [Wed, 13 Jan 2016 18:45:05 +0000 (19:45 +0100)]
basic: add ascii_strcasecmp_nn() call

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.

6 years agobasic: add new ascii_strcasecmp_n() call
Lennart Poettering [Wed, 13 Jan 2016 01:21:16 +0000 (02:21 +0100)]
basic: add new ascii_strcasecmp_n() call

6 years agobasic,bus-error: return negative error from errno_from_name
Zbigniew Jędrzejewski-Szmek [Tue, 12 Jan 2016 22:19:51 +0000 (17:19 -0500)]
basic,bus-error: return negative error from errno_from_name

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.

6 years agobasic/escape: merge utf8 and non-utf8 paths in cunescape_one
Zbigniew Jędrzejewski-Szmek [Tue, 12 Jan 2016 20:36:57 +0000 (15:36 -0500)]
basic/escape: merge utf8 and non-utf8 paths in cunescape_one

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.

6 years agosd-event: minor fixups to delays profiling changes
Vito Caputo [Tue, 12 Jan 2016 18:14:33 +0000 (10:14 -0800)]
sd-event: minor fixups to delays profiling changes

6 years agotree-wide: use xsprintf() where applicable
Daniel Mack [Tue, 12 Jan 2016 14:34:20 +0000 (15:34 +0100)]
tree-wide: use xsprintf() where applicable

Also add a coccinelle receipt to help with such transitions.

6 years agosd-event: check clock argument to sd_event_now()
Zbigniew Jędrzejewski-Szmek [Mon, 11 Jan 2016 22:19:25 +0000 (17:19 -0500)]
sd-event: check clock argument to sd_event_now()

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.

6 years agotree-wide: check if errno is greater than zero (2)
Zbigniew Jędrzejewski-Szmek [Mon, 11 Jan 2016 19:31:14 +0000 (14:31 -0500)]
tree-wide: check if errno is greater than zero (2)

Compare errno with zero in a way that tells gcc that
(if the condition is true) errno is positive.

6 years agotree-wide: check if errno is greater then zero
Zbigniew Jędrzejewski-Szmek [Mon, 11 Jan 2016 17:47:14 +0000 (12:47 -0500)]
tree-wide: check if errno is greater then zero

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

6 years agobus-kernel: reword assignment of dst_id in bus_message_setup_kmsg
Zbigniew Jędrzejewski-Szmek [Mon, 11 Jan 2016 17:42:42 +0000 (12:42 -0500)]
bus-kernel: reword assignment of dst_id in bus_message_setup_kmsg

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.

6 years agomacro.h: provide a switch-case statement generator for IN_SET
Daniel Mack [Sun, 10 Jan 2016 17:11:22 +0000 (18:11 +0100)]
macro.h: provide a switch-case statement generator for IN_SET

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

6 years agoresolved: don't attempt to send queries for DNSSEC RR types to servers not supporting...
Lennart Poettering [Fri, 8 Jan 2016 16:10:49 +0000 (17:10 +0100)]
resolved: don't attempt to send queries for DNSSEC RR types to servers not 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.

6 years agoshared: make sure foo.bar and foobar result in different domain name hashes
Lennart Poettering [Fri, 8 Jan 2016 00:11:55 +0000 (01:11 +0100)]
shared: make sure foo.bar and foobar result in different domain name hashes

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.

6 years agobasic: split hash functions into their own header files
Lennart Poettering [Fri, 8 Jan 2016 00:10:45 +0000 (01:10 +0100)]
basic: split hash functions into their own header files

The hash operations are not really that specific to hashmaps, hence split them into a .c module of their own.

6 years agobasic: introduce generic ascii_strlower_n() call and make use of it everywhere
Lennart Poettering [Thu, 7 Jan 2016 18:43:26 +0000 (19:43 +0100)]
basic: introduce generic ascii_strlower_n() call and make use of it everywhere

6 years agobasic: add string table macros for "extended boolean" enums
Lennart Poettering [Tue, 5 Jan 2016 16:10:17 +0000 (17:10 +0100)]
basic: add string table macros for "extended boolean" enums

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.

6 years agoresolved: explicitly handle case when the trust anchor is empty
Lennart Poettering [Mon, 4 Jan 2016 21:35:54 +0000 (22:35 +0100)]
resolved: explicitly handle case when the trust anchor is empty

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.

6 years agoresolved: introduce a proper bus error for DNSSEC validation errors
Lennart Poettering [Mon, 4 Jan 2016 21:35:17 +0000 (22:35 +0100)]
resolved: introduce a proper bus error for DNSSEC validation errors

6 years agobasic: modernize conf-files.c a bit
Lennart Poettering [Sat, 2 Jan 2016 20:32:45 +0000 (21:32 +0100)]
basic: modernize conf-files.c a bit

6 years agocore: socket options fix SCTP_NODELAY
Susant Sahani [Thu, 31 Dec 2015 06:35:57 +0000 (12:05 +0530)]
core: socket options fix SCTP_NODELAY

SCTP_NODELAY is diffrent to TCP_NODELAY.
Apply proper options in case of SCTP.

6 years agoresolved: properly handle SRV RRs with the DNS root as hostname
Lennart Poettering [Tue, 29 Dec 2015 17:58:05 +0000 (18:58 +0100)]
resolved: properly handle SRV RRs with the DNS root as hostname

6 years agoresolved: add errno mapping for BUS_ERROR_CONNECTION_FAILURE
Lennart Poettering [Tue, 29 Dec 2015 17:55:58 +0000 (18:55 +0100)]
resolved: add errno mapping for BUS_ERROR_CONNECTION_FAILURE

This was missing when the error type was added in
ac720200b7e5b80cc4985087e38f3452e5b3b080.

6 years agoresolved: change mapping of BUS_ERROR_NO_NAME_SERVERS to ESRCH
Lennart Poettering [Tue, 29 Dec 2015 17:55:17 +0000 (18:55 +0100)]
resolved: change mapping of BUS_ERROR_NO_NAME_SERVERS to ESRCH

EIO is really too generic, and indicates transmission problems.

6 years agobus-util: print "systemctl --user" on user service manager
WaLyong Cho [Tue, 29 Dec 2015 05:15:04 +0000 (14:15 +0900)]
bus-util: print "systemctl --user" on user service manager

When a unit was started with "systemctl --user" and it failed, error
messages is printed as "systemctl status". But it should be "systemctl
--user status".

6 years agoman: fix typos
Jakub Wilk [Sat, 26 Dec 2015 17:25:49 +0000 (18:25 +0100)]
man: fix typos

6 years agobasic: add missing word in comment
Zbigniew Jędrzejewski-Szmek [Fri, 25 Dec 2015 21:29:09 +0000 (16:29 -0500)]
basic: add missing word in comment

6 years agoresolved: generate an explicit transaction error when we cannot reach server via TCP
Lennart Poettering [Fri, 25 Dec 2015 11:54:27 +0000 (12:54 +0100)]
resolved: generate an explicit transaction error when we cannot reach server via TCP

Previously, if we couldn't reach a server via UDP we'd generate an
MAX_ATTEMPTS transaction result, but if we couldn't reach it via TCP
we'd generate a RESOURCES transaction result. While it is OK to generate
two different errors I think, "RESOURCES" is certainly a misnomer.
Introduce a new transaction result "CONNECTION_FAILURE" instead.

6 years agomount-setup.c: fix handling of symlink Smack labelling in cgroup setup
Patrick Ohly [Mon, 21 Dec 2015 13:56:00 +0000 (14:56 +0100)]
mount-setup.c: fix handling of symlink Smack labelling in cgroup setup

The code introduced in f8c1a81c51 (= elogind 227) failed for me with:
  Failed to copy smack label from net_cls to /sys/fs/cgroup/net_cls: No such file or directory

There is no need for a symlink in this case because source and target
are identical. The symlink() call is allowed to fail when the target
already exists. When that happens, copying the Smack label must be
skipped.

But the code also failed when there is a symlink, like "cpu ->
cpu,cpuacct", because mac_smack_copy() got called with
src="cpu,cpuacct" which fails to find the entry because the current
directory is not inside /sys/fs/cgroup. The absolute path to the existing
entry must be used instead.

6 years agosd-event: improve debugging of event source errors
Daniel Mack [Mon, 21 Dec 2015 12:03:24 +0000 (13:03 +0100)]
sd-event: improve debugging of event source errors

Printing the pointer variable really doesn't help, so drop that.

Instead, add a string lookup table for the EventSourceType enum, and print
the type of event source in case of errors.

6 years agoFix typo on logind-dbus.c
Joost Bremmer [Sat, 19 Dec 2015 11:46:09 +0000 (12:46 +0100)]
Fix typo on logind-dbus.c

method_schedule_shutdown referenced org.freedesktop.login1.poweroff*
which is never registered in polkit.

Now refers to org.freedesktop.login1.power-off*

Signed-off-by: Joost Bremmer <toost.b@gmail.com>
6 years agoutf8.[ch] et al: use char32_t and char16_t instead of int, int32_t, int16_t
Shawn Landden [Sun, 13 Dec 2015 22:26:43 +0000 (14:26 -0800)]
utf8.[ch] et al: use char32_t and char16_t instead of int, int32_t, int16_t

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
]

6 years agobasic: ENABLE_DEBUG_HASHMAP needs <pthread.h>
Henrik Kaare Poulsen [Sun, 13 Dec 2015 18:31:05 +0000 (19:31 +0100)]
basic: ENABLE_DEBUG_HASHMAP needs <pthread.h>

this is a follow-up for commit 11c3a36649e5e5e77db499c92f3

6 years agosd-event: instrument sd_event_run() for profiling delays
Vito Caputo [Mon, 7 Dec 2015 19:28:18 +0000 (11:28 -0800)]
sd-event: instrument sd_event_run() for profiling delays

Set SD_EVENT_PROFILE_DELAYS to activate accounting and periodic logging
of the distribution of delays between sd_event_run() calls.

Time spent in dispatching as well as time spent outside of
sd_event_run() is measured and accounted for.  Every 5 seconds a
logarithmic histogram loop iteration delays since 5 seconds previous is
logged.

This is useful in identifying the frequency and magnitude of latencies
affecting the event loop, which should be kept to a minimum.

6 years agologin: make sure /run/nologin has correct SELinux label
Michal Sekletar [Fri, 4 Dec 2015 21:29:38 +0000 (22:29 +0100)]
login: make sure /run/nologin has correct SELinux label

6 years agoshared: include what we use
Thomas Hindoe Paaboel Andersen [Thu, 3 Dec 2015 20:13:37 +0000 (21:13 +0100)]
shared: include what we use

The next step of a general cleanup of our includes. This one mostly
adds missing includes but there are a few removals as well.

6 years agojournal: unbreak sd_journal_sendv
Zbigniew Jędrzejewski-Szmek [Thu, 3 Dec 2015 07:20:39 +0000 (02:20 -0500)]
journal: unbreak sd_journal_sendv

Borked since
commit 3ee897d6c2401effbc82f5eef35fce405781d6c8
Author: Lennart Poettering <lennart@poettering.net>
Date:   Wed Sep 23 01:00:04 2015 +0200

    tree-wide: port more code to use send_one_fd() and receive_one_fd()

because here our fd is not connected and we need to specify
the address.

6 years agobasic: re-sort includes
Thomas Hindoe Paaboel Andersen [Tue, 1 Dec 2015 22:22:03 +0000 (23:22 +0100)]
basic: re-sort includes

My previous patch to only include what we use accidentially placed
the added inlcudes in non-sorted order.

6 years agojournal-remote: split-mode=host, remove port from journal filename
Klearchos Chaloulos [Tue, 1 Dec 2015 17:29:59 +0000 (19:29 +0200)]
journal-remote: split-mode=host, remove port from journal filename

When constructing the journal filename to store logs from a remote host, remove the port of the tcp connection, as the port will change with every reboot/connection loss between sender/reveiver machines. Having the port in the filename will cause a new journal file to be created for every reboot or connection loss.
For the implementation, a new argument "bool include_port" is added to the getpeername_pretty() function. This is passed to the sockaddr_pretty() function. The value of the include_port argument is set to true in all calls of getpeername_pretty(), except for 2 calls in journal-remote.c, where it is set to false.

6 years agobasic: include only what we use
Thomas Hindoe Paaboel Andersen [Mon, 30 Nov 2015 20:43:37 +0000 (21:43 +0100)]
basic: include only what we use

This is a cleaned up result of running iwyu but without forward
declarations on src/basic.

6 years agoacl-util: only set the mask if not present
Zbigniew Jędrzejewski-Szmek [Sat, 28 Nov 2015 23:41:08 +0000 (18:41 -0500)]
acl-util: only set the mask if not present

When we have non-owner user or group entries, we need the mask
for the acl to be valid. But acl_calc_mask() calculates the mask
to include all permissions, even those that were masked before.
Apparently this happens when we inherit *:r-x permissions from
a parent directory — the kernel sets *:r-x, mask:r--, effectively
masking the executable bit. acl_calc_mask() would set the mask:r-x,
effectively enabling the bit. To avoid this, be more conservative when
to add the mask entry: first iterate over all entries, and do nothing
if a mask.

This returns the code closer to J.A.Steffens' original version
in v204-90-g23ad4dd884.

Should fix https://github.com/elogind/elogind/issues/1977.

6 years agocore: expose soft limits on the bus
Evgeny Vereshchagin [Sat, 28 Nov 2015 16:49:13 +0000 (16:49 +0000)]
core: expose soft limits on the bus

This is a follow-up for https://github.com/elogind/elogind/pull/1994

See https://github.com/elogind/elogind/pull/1994#issuecomment-160087219

6 years agotree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easy
Lennart Poettering [Fri, 27 Nov 2015 18:13:45 +0000 (19:13 +0100)]
tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easy

GLIB has recently started to officially support the gcc cleanup
attribute in its public API, hence let's do the same for our APIs.

With this patch we'll define an xyz_unrefp() call for each public
xyz_unref() call, to make it easy to use inside a
__attribute__((cleanup())) expression. Then, all code is ported over to
make use of this.

The new calls are also documented in the man pages, with examples how to
use them (well, I only added docs where the _unref() call itself already
had docs, and the examples, only cover sd_bus_unrefp() and
sd_event_unrefp()).

This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we
tend to call our destructors these days.

Note that this defines no public macro that wraps gcc's attribute and
makes it easier to use. While I think it's our duty in the library to
make our stuff easy to use, I figure it's not our duty to make gcc's own
features easy to use on its own. Most likely, client code which wants to
make use of this should define its own:

       #define _cleanup_(function) __attribute__((cleanup(function)))

Or similar, to make the gcc feature easier to use.

Making this logic public has the benefit that we can remove three header
files whose only purpose was to define these functions internally.

See #2008.

6 years agocore: rename Random* to RandomizedDelay*
Zbigniew Jędrzejewski-Szmek [Thu, 26 Nov 2015 21:32:41 +0000 (16:32 -0500)]
core: rename Random* to RandomizedDelay*

The name RandomSec is too generic: "Sec" just specifies the default
unit type, and "Random" by itself is not enough. Rename to something
that should give the user general idea what the setting does without
looking at documentation.

6 years agoutil-lib: add ordered_set_ensure_allocated()
Lennart Poettering [Tue, 24 Nov 2015 20:54:22 +0000 (21:54 +0100)]
util-lib: add ordered_set_ensure_allocated()

ordered_set_ensure_allocated() does for an OrderedSet, what
set_ensure_allicated() does for a Set.

6 years agobash-completion: list valid signal names
Evgeny Vereshchagin [Tue, 24 Nov 2015 16:05:42 +0000 (16:05 +0000)]
bash-completion: list valid signal names

this is a follow-up for commit 18540892d18addc4dcb81

6 years agoescape: add cescape_length() call as generalization of cescape()
Lennart Poettering [Mon, 23 Nov 2015 20:13:59 +0000 (21:13 +0100)]
escape: add cescape_length() call as generalization of cescape()

6 years agovirt: add comment about order in virtualization detection
Christian Hesse [Mon, 23 Nov 2015 18:15:25 +0000 (19:15 +0100)]
virt: add comment about order in virtualization detection

6 years agovirt: detect dmi before cpuid
Christian Hesse [Mon, 23 Nov 2015 12:55:04 +0000 (13:55 +0100)]
virt: detect dmi before cpuid

Virtualbox should be detected as 'oracle'. This used to work but broke
with commit:

    commit 75f86906c52735c98dc0aa7e24b773edb42ee814
    Author: Lennart Poettering <lennart@poettering.net>
    Date:   Mon Sep 7 13:42:47 2015 +0200

    basic: rework virtualization detection API

We swap detection for dmi and cpuid, this fixes Virtualbox with KVM.
Hopefully it does not break anything else.

6 years agoman: include the target name when linking to man pages in html output
Zbigniew Jędrzejewski-Szmek [Mon, 23 Nov 2015 04:43:36 +0000 (23:43 -0500)]
man: include the target name when linking to man pages in html output

Links like http://www.freedesktop.org/software/elogind/man/elogind.socket.html
are changed to http://www.freedesktop.org/software/elogind/man/elogind.socket.html#Accept=.

This implementation is quick & dirty, and misses various corner
cases. A fairly important one is that when a few directives share the
same anchor (which happens when multiple directives are described in
the same paragraph), generated links for everything except the first
one link to an invalid anchor. Another shortcoming is that the
formatting does not use the proper generateID machinery, so the anchor
name could be wrong in some cases. But it seems to work for a large
percentage of links, so seems to be an improvement in usability. When
the anchor is missing, we land at the top of the page, which is the
same as before. If the anchor were to point to different spot, this
would be more confusing... Not sure if that ever happens. Anyway, the
user should be able to recover from landing on the wrong place in the
page.

(Mostly) fixes https://github.com/elogind/elogind/issues/1956.

6 years agotranslations: update-po
Daniele Medri [Sun, 22 Nov 2015 15:43:39 +0000 (16:43 +0100)]
translations: update-po

6 years agosd-event: use prioq_ensure_allocated where possible
Evgeny Vereshchagin [Sun, 22 Nov 2015 06:41:31 +0000 (06:41 +0000)]
sd-event: use prioq_ensure_allocated where possible

6 years agoman: fully document sd-event interfaces
Lennart Poettering [Thu, 19 Nov 2015 22:38:54 +0000 (23:38 +0100)]
man: fully document sd-event interfaces

This completes the set of man pages for sd-event and contains some minor
other fixes for other man pages too.

The sd_event_set_name(3) man page is renamed to
sd_event_source_set_description(3), which is the correct name of the
concept today.

6 years agosd-event: define a new PREPARING state
Lennart Poettering [Thu, 19 Nov 2015 22:33:55 +0000 (23:33 +0100)]
sd-event: define a new PREPARING state

We already have a state RUNNING and EXITING when we dispatch regular and
exit callbacks. Let's introduce a new state called PREPARING that is
active while we invoke preparation callbacks. This way we have a state
each for all three kinds of event handlers.

The states are currently not documented, hence let's add a new state to
the end, before we start documenting this.

6 years agogitignore: only ignore .html files in man/
Martin Pitt [Thu, 19 Nov 2015 09:51:19 +0000 (10:51 +0100)]
gitignore: only ignore .html files in man/

src/journal-remote/browse.html is git-tracked source and should not be ignored.
Avoid accidentally ignoring similar ones in the future.

6 years agotree-wide: sort includes in *.h
Thomas Hindoe Paaboel Andersen [Wed, 18 Nov 2015 21:46:33 +0000 (22:46 +0100)]
tree-wide: sort includes in *.h

This is a continuation of the previous include sort patch, which
only sorted for .c files.

6 years agocore: add new RandomSec= setting for time units
Lennart Poettering [Wed, 18 Nov 2015 12:37:30 +0000 (13:37 +0100)]
core: add new RandomSec= setting for time units

This allows configuration of a random time on top of the elapse events,
in order to spread time events in a network evenly across a range.

6 years agobus-util: make sure --property=RemainAfterElapse=1 works
Lennart Poettering [Wed, 18 Nov 2015 11:19:42 +0000 (12:19 +0100)]
bus-util: make sure --property=RemainAfterElapse=1 works

6 years agobus-util: add in forgotten error messages
Lennart Poettering [Wed, 18 Nov 2015 11:19:15 +0000 (12:19 +0100)]
bus-util: add in forgotten error messages

6 years agohostname-util: fix code comment
Beniamino Galvani [Tue, 17 Nov 2015 13:08:37 +0000 (14:08 +0100)]
hostname-util: fix code comment

6 years agosiphash: minor coding style fixes and modernizations
Lennart Poettering [Tue, 17 Nov 2015 00:08:44 +0000 (01:08 +0100)]
siphash: minor coding style fixes and modernizations

Only cosmetics really, doesn't change any actual logic.

6 years agocalendarspec: sub-second support, v3
Hristo Venev [Mon, 16 Nov 2015 08:15:05 +0000 (10:15 +0200)]
calendarspec: sub-second support, v3