chiark / gitweb /
elogind.git
6 years agotest-compress-benchmark: fix argument parsing on 32bit
Zbigniew Jędrzejewski-Szmek [Sat, 2 Apr 2016 21:46:49 +0000 (17:46 -0400)]
test-compress-benchmark: fix argument parsing on 32bit

The patch is not minimal, but a function to parse size_t is probably
going to come in handy in other places, so I think it's nicer to define
a proper parsing function than to open-code the cast.

6 years agobus-util: Fix reading uint32 properties
Martin Pitt [Fri, 1 Apr 2016 12:16:14 +0000 (14:16 +0200)]
bus-util: Fix reading uint32 properties

Fix copy&paste bug in map_basic() to use the correct data type for
SD_BUS_TYPE_UINT32. Before we were copying the wrong 32 bits into the
destination pointer, resulting in complete garbage on big-endian systems.

Fixes #2927

6 years agoshared: fix a misspelling of "journalctl"
Biao Lu [Mon, 28 Mar 2016 17:46:04 +0000 (01:46 +0800)]
shared: fix a misspelling of "journalctl"

6 years agocore: update populated event handling in unified hierarchy
Tejun Heo [Fri, 25 Mar 2016 15:38:50 +0000 (11:38 -0400)]
core: update populated event handling in unified hierarchy

Earlier during the development of unified hierarchy, the populated event was
reported through by the dedicated "cgroup.populated" file; however, the
interface was updated so that it's reported through the "populated" field of
"cgroup.events" file.  Update populated event handling logic accordingly.

6 years agoIgnore BOM in config files
Zbigniew Jędrzejewski-Szmek [Tue, 22 Mar 2016 03:34:13 +0000 (23:34 -0400)]
Ignore BOM in config files

Fixes #2823.

Also remove unnecessary feof check.

6 years agobasic/missing: move syscall definitions to basic/missing_syscall.h
Zbigniew Jędrzejewski-Szmek [Thu, 17 Mar 2016 17:26:13 +0000 (13:26 -0400)]
basic/missing: move syscall definitions to basic/missing_syscall.h

We have a bunch of syscall wrapper definitions and it's easier to
see that they follow the same pattern if they are not interspersed
with other defines.

Change the wrappers to be uniform:
- if __NR_XXX is not defined, do not bother to call the syscall,
  and return -1/ENOSYS immediately.
- do not check __NR_XXX defines if we detect the symbol as defined,
  since we don't need them anyway
- reindent stuff for readability

New file basic/missing_syscall.h is included at the end of missing.h
because it might make use of some of the definitions in missing.h.

6 years agologinctl: add --value option
Zbigniew Jędrzejewski-Szmek [Thu, 17 Mar 2016 16:48:02 +0000 (12:48 -0400)]
loginctl: add --value option

6 years agorules: allow users to access frame buffer devices
Zbigniew Jędrzejewski-Szmek [Thu, 17 Mar 2016 12:40:39 +0000 (08:40 -0400)]
rules: allow users to access frame buffer devices

For example it allows weston to be started unprivileged.

Related discussion:
https://bugs.freedesktop.org/show_bug.cgi?id=73782
https://lists.freedesktop.org/archives/wayland-devel/2015-May/022005.html
https://bugzilla.redhat.com/show_bug.cgi?id=1226680

6 years agobasic/log: remove unused return value
Zbigniew Jędrzejewski-Szmek [Tue, 15 Mar 2016 23:27:36 +0000 (19:27 -0400)]
basic/log: remove unused return value

6 years agobasic/macros: clang 3.5 doesn't support alloc_size
Zbigniew Jędrzejewski-Szmek [Tue, 15 Mar 2016 23:27:28 +0000 (19:27 -0400)]
basic/macros: clang 3.5 doesn't support alloc_size

The attribute was removed in commit c047507 in the clang repository as it
was never properly implemented anyway. Avoid using the attribute with
clang because it generates a ton of annoying warnings.

6 years agobasic/missing: add copy_file_range
Zbigniew Jędrzejewski-Szmek [Tue, 15 Mar 2016 23:26:30 +0000 (19:26 -0400)]
basic/missing: add copy_file_range

syscall numbers based on:
https://fedora.juszkiewicz.com.pl/syscalls.html

6 years agoAdded support for 3D printers to uaccess (ID_MAKER_TOOL)
Jaroslav Škarvada [Tue, 15 Mar 2016 13:25:51 +0000 (14:25 +0100)]
Added support for 3D printers to uaccess (ID_MAKER_TOOL)

This is to support 3D printers, CNCs, laser cutters, 3D scanners, etc.

6 years agoinclude sys/sysmacros.h in more places
Mike Frysinger [Mon, 14 Mar 2016 21:44:49 +0000 (17:44 -0400)]
include sys/sysmacros.h in more places

Since glibc is moving away from implicitly including sys/sysmacros.h
all the time via sys/types.h, include the header directly in more
places.  This seems to cover most makedev/major/minor usage.

6 years agoheaders: use __inline__ instead of inline
Zbigniew Jędrzejewski-Szmek [Fri, 11 Mar 2016 18:41:49 +0000 (13:41 -0500)]
headers: use __inline__ instead of inline

https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gcc/Alternate-Keywords.html#Alternate-Keywords
recommends __inline__ over inline in ANSI C compatible headers.
Tested with gcc-5.3 and clang-3.7.

https://bugzilla.redhat.com/show_bug.cgi?id=1316964

6 years agostring-table: split long definitions
Zbigniew Jędrzejewski-Szmek [Fri, 4 Mar 2016 16:28:04 +0000 (11:28 -0500)]
string-table: split long definitions

6 years agotree-wide: use SET_FLAG() macro to make code more clear
Alexander Kuleshov [Thu, 3 Mar 2016 17:30:37 +0000 (23:30 +0600)]
tree-wide: use SET_FLAG() macro to make code more clear

6 years agoselinux: always try to load the full selinux db
Zbigniew Jędrzejewski-Szmek [Wed, 2 Mar 2016 01:35:55 +0000 (20:35 -0500)]
selinux: always try to load the full selinux db

https://github.com/elogind/elogind/pull/2508#issuecomment-190901170
Maybe fixes https://bugzilla.redhat.com/show_bug.cgi?id=1308771.

6 years agotree-wide: no need to pass excess flags to open()/openat() if O_PATH is passed
Alexander Kuleshov [Tue, 1 Mar 2016 18:25:09 +0000 (00:25 +0600)]
tree-wide: no need to pass excess flags to open()/openat() if O_PATH is passed

As described in the documentation:

When O_PATH is specified in flags, flag bits other than O_CLOEXEC,
O_DIRECTORY, and O_NOFOLLOW are ignored.

So, we can remove unnecessary flags in a case when O_PATH is passed
to the open() or openat().

6 years agoRedefine 32bit time_t format to signed
Zbigniew Jędrzejewski-Szmek [Tue, 1 Mar 2016 17:08:02 +0000 (12:08 -0500)]
Redefine 32bit time_t format to signed

It seems that it is signed both on i386 and arm.

Avoids a stupid gcc warning on arm:

src/udev/udevadm-monitor.c: In function ‘print_device’:
src/udev/udevadm-monitor.c:44:16: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘__time_t {aka long int}’ [-Wformat=]
         printf("%-6s[%"PRI_TIME".%06ld] %-8s %s (%s)\n",
                ^

6 years agocore: avoid compiler warning when compiling with -fexceptions
Thomas Haller [Sat, 27 Feb 2016 12:40:50 +0000 (13:40 +0100)]
core: avoid compiler warning when compiling with -fexceptions

Initialize auto variables with cleanup attribute, otherwise we
get a compiler warning with -fexceptions.

    ./configure CFLAGS='-Wmaybe-uninitialized -fexceptions -O2'

6 years agocore: when enabling a generated unit file, return a clean error
Lennart Poettering [Wed, 24 Feb 2016 15:02:48 +0000 (16:02 +0100)]
core: when enabling a generated unit file, return a clean error

Let's be precise when the user tries to invoke an "enable" operation on a
generated unit file.

6 years agobasic: mark unused variable as such
Thomas Hindoe Paaboel Andersen [Tue, 23 Feb 2016 18:21:54 +0000 (19:21 +0100)]
basic: mark unused variable as such

6 years agotree-wide: minor formatting inconsistency cleanups
Vito Caputo [Tue, 23 Feb 2016 17:52:52 +0000 (09:52 -0800)]
tree-wide: minor formatting inconsistency cleanups

6 years agotree-wide: make ++/-- usage consistent WRT spacing
Vito Caputo [Tue, 23 Feb 2016 04:32:04 +0000 (20:32 -0800)]
tree-wide: make ++/-- usage consistent WRT spacing

Throughout the tree there's spurious use of spaces separating ++ and --
operators from their respective operands.  Make ++ and -- operator
consistent with the majority of existing uses; discard the spaces.

6 years agoresolved: fix notification iteration logic when transactions are completed
Lennart Poettering [Mon, 22 Feb 2016 19:39:45 +0000 (20:39 +0100)]
resolved: fix notification iteration logic when transactions are completed

When a transaction is complete, and we notify its owners, make sure we deal
correctly with the requesters removing themselves from the list of owners while
we continue iterating.

This was previously already dealt with with transactions that require other
transactions for DNSSEC purposes, fix this for other possibly transaction
owners too now.

Since iterating through "Set" objects is not safe regarding removal of entries
from it, rework the logic to use two Sets, and move each entry we notified from
one set to the other set before we dispatch the notification. This move operation
requires no additional memory, and enables us to ensure that we don't notify
any object twice.

Fixes: #2676
6 years agohashmap: use void* and uint8_t* for generic pointers
Lennart Poettering [Mon, 22 Feb 2016 17:40:28 +0000 (18:40 +0100)]
hashmap: use void* and uint8_t* for generic pointers

As suggested by CODING_STYLE we should use "void*" as type for generic memory,
and uint8_t* for generic bytes. Hence use that instead of "char*", which should
really be used only for strings these days.

6 years agoutil-lib: simplify personality() string matching
Lennart Poettering [Mon, 22 Feb 2016 17:29:05 +0000 (18:29 +0100)]
util-lib: simplify personality() string matching

6 years agoutil-lib: support various ppc archs in personality logic
Lennart Poettering [Mon, 22 Feb 2016 14:50:35 +0000 (15:50 +0100)]
util-lib: support various ppc archs in personality logic

6 years agoutil-lib: use the architecture ids from architecture.h for personalities
Lennart Poettering [Mon, 22 Feb 2016 14:39:52 +0000 (15:39 +0100)]
util-lib: use the architecture ids from architecture.h for personalities

We have this ids, hence let's use them universally.

6 years agomissing.h: Explicitly check for IFLA_BRPORT_PROXYARP
Daniel Mack [Mon, 22 Feb 2016 12:10:16 +0000 (13:10 +0100)]
missing.h: Explicitly check for IFLA_BRPORT_PROXYARP

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.

6 years agonetworkd: add basic LLDP transmission support
Lennart Poettering [Sun, 21 Feb 2016 13:14:08 +0000 (14:14 +0100)]
networkd: add basic LLDP transmission support

Let's add some minimalistic LLDP sender support. The idea is that this is
either on or off, and all fields determined automatically rather than
configured explicitly.

6 years agotree-wide: merge pager_open_if_enabled() to the pager_open()
Alexander Kuleshov [Fri, 19 Feb 2016 18:25:13 +0000 (00:25 +0600)]
tree-wide: merge pager_open_if_enabled() to the pager_open()

Many subsystems define own pager_open_if_enabled() function which
checks '--no-pager' command line argument and open pager depends
on its value. All implementations of pager_open_if_enabled() are
the same. Let's merger this function with pager_open() from the
shared/pager.c and remove pager_open_if_enabled() from all subsytems
to prevent code duplication.

6 years agotree-wide: place #pragma once at the same place everywhere
Lennart Poettering [Tue, 16 Feb 2016 19:05:15 +0000 (20:05 +0100)]
tree-wide: place #pragma once at the same place everywhere

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.

6 years agosd-lldp: move ETHERTYPE_LLDP to missing.h
Lennart Poettering [Tue, 16 Feb 2016 18:46:28 +0000 (19:46 +0100)]
sd-lldp: move ETHERTYPE_LLDP to missing.h

After all, most ETHERTYPE variables are defined in the system headers, hence
define these where we defined all other fill-ins for system headers.

6 years agoalloc-util: cleanups
Alexander Kuleshov [Tue, 16 Feb 2016 17:51:43 +0000 (23:51 +0600)]
alloc-util: cleanups

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

6 years agosystemctl: fix style to avoid modification of array passed by caller
Zbigniew Jędrzejewski-Szmek [Tue, 16 Feb 2016 00:06:53 +0000 (19:06 -0500)]
systemctl: fix style to avoid modification of array passed by caller

Followup for 4524439edb7d.

6 years agotime-util: Rename and fix call of deserialize_timestamp_value()
Benjamin Robin [Mon, 15 Feb 2016 22:26:34 +0000 (23:26 +0100)]
time-util: Rename and fix call of deserialize_timestamp_value()

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

6 years agobuild-sys: fix type detection
Lennart Poettering [Mon, 15 Feb 2016 18:06:01 +0000 (19:06 +0100)]
build-sys: fix type detection

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.

6 years agologind: use deserialize_timestamp_value()
Alexander Kuleshov [Mon, 15 Feb 2016 18:04:49 +0000 (00:04 +0600)]
logind: use deserialize_timestamp_value()

which is introduced in the ebf30a086d commit.

6 years agotime-util: introduce deserialize_timestamp_value()
Alexander Kuleshov [Mon, 15 Feb 2016 18:01:44 +0000 (00:01 +0600)]
time-util: introduce deserialize_timestamp_value()

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.

6 years agosystemctl: include -M or -H arguments in the hint
Zbigniew Jędrzejewski-Szmek [Mon, 15 Feb 2016 16:57:48 +0000 (11:57 -0500)]
systemctl: include -M or -H arguments in the hint

https://github.com/elogind/elogind/issues/2431

Some newlines are added, but the output will still exceed 80 columns in many
cases. The fallback for oom conditions is changed from "n/a" to something
"<service>", and a similar pattern is used for the new code. This way we
have a realistic fallback for oom, which seems nicer than making the whole
function return an error code which would then have to be propagated.

$ systemctl -M fedora-rawhide restart elogind-networkd.service
Job for elogind-networkd.service failed because start of the service was attempted too often.
See "systemctl -M fedora-rawhide status elogind-networkd.service" and "journalctl -M fedora-rawhide -xe" for details.
To force a start use "systemctl -M fedora-rawhide reset-failed elogind-networkd.service"
followed by "systemctl -M fedora-rawhide start elogind-networkd.service" again.

6 years agoresolved: drop references to two bus error codes no longer used
Lennart Poettering [Sat, 13 Feb 2016 19:01:52 +0000 (20:01 +0100)]
resolved: drop references to two bus error codes no longer used

6 years agotree-wide: make more global variables static
Lennart Poettering [Sat, 13 Feb 2016 11:28:28 +0000 (12:28 +0100)]
tree-wide: make more global variables static

let's export as little as we can

6 years agoresolve: always align flags to 8th column and print CAA flags
Zbigniew Jędrzejewski-Szmek [Tue, 2 Feb 2016 02:35:44 +0000 (21:35 -0500)]
resolve: always align flags to 8th column and print CAA flags

Left-over unknown flags are printed numerically. Otherwise,
it wouldn't be known what bits are remaining without knowning
what the known bits are.

A test case is added to verify the flag printing code:
============== src/resolve/test-data/fake-caa.pkts ==============
google.com. IN CAA   0 issue "symantec.com"
google.com. IN CAA   128 issue "symantec.com"
        -- Flags: critical
google.com. IN CAA   129 issue "symantec.com"
        -- Flags: critical 1
google.com. IN CAA   22 issue "symantec.com"
        -- Flags: 22

6 years agotime-util: map ALARM clockids to non-ALARM clockids in now()
Lennart Poettering [Fri, 12 Feb 2016 20:29:01 +0000 (21:29 +0100)]
time-util: map ALARM clockids to non-ALARM clockids in now()

Fixes: #2597
6 years agomissing.h: define IFLA_EXT_MASK
Rabin Vincent [Fri, 12 Feb 2016 07:41:44 +0000 (08:41 +0100)]
missing.h: define IFLA_EXT_MASK

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

6 years agobasic/strv: fix strv_join for first empty argument
Zbigniew Jędrzejewski-Szmek [Fri, 12 Feb 2016 04:24:14 +0000 (23:24 -0500)]
basic/strv: fix strv_join for first empty argument

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:"

6 years agoTypo
Zbigniew Jędrzejewski-Szmek [Fri, 12 Feb 2016 02:52:02 +0000 (21:52 -0500)]
Typo

6 years agotreewide: fix typos and then/that use
Torstein Husebø [Mon, 8 Feb 2016 12:27:22 +0000 (13:27 +0100)]
treewide: fix typos and then/that use

6 years agoAdd memcpy_safe
Zbigniew Jędrzejewski-Szmek [Tue, 2 Feb 2016 02:57:41 +0000 (21:57 -0500)]
Add memcpy_safe

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.

6 years agocgroup2: use new fstype for unified hierarchy
Alban Crequy [Mon, 7 Dec 2015 00:10:50 +0000 (01:10 +0100)]
cgroup2: use new fstype for unified hierarchy

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

6 years agosystemctl: add --value option
Zbigniew Jędrzejewski-Szmek [Sun, 2 Aug 2015 18:22:10 +0000 (14:22 -0400)]
systemctl: add --value option

With this option, systemctl will only print the rhs in show:
$ systemctl show -p Wants,After elogind-journald --value
elogind-journald.socket ...
elogind-journald-dev-log.socket ...

This is useful in scripts, because the need to call awk or similar
is removed.

6 years agoMerge pull request #16 from Gottox/fix-musl-228.3
Sven Eden [Wed, 24 May 2017 11:50:55 +0000 (13:50 +0200)]
Merge pull request #16 from Gottox/fix-musl-228.3

musl-fix for 228.3

6 years agomusl-fix: faccessat does not support AT_SYMLINK_NOFOLLOW with musl.
Enno Boland [Wed, 24 May 2017 11:19:32 +0000 (13:19 +0200)]
musl-fix: faccessat does not support AT_SYMLINK_NOFOLLOW with musl.

6 years agoVersion 229.1 Release v229.1
Sven Eden [Tue, 23 May 2017 12:50:10 +0000 (14:50 +0200)]
Version 229.1 Release

6 years agoMerge pull request #15 from elogind/dev_v229
Sven Eden [Tue, 23 May 2017 12:48:18 +0000 (14:48 +0200)]
Merge pull request #15 from elogind/dev_v229

Candidate for first v229 release

6 years agoPrep v229: Update man pages (fix most inappropriate stuff. Still lots to do...)
Sven Eden [Tue, 23 May 2017 09:18:11 +0000 (11:18 +0200)]
Prep v229: Update man pages (fix most inappropriate stuff. Still lots to do...)

6 years agoPrep v229: Some musl-libc compatibility updates
Sven Eden [Mon, 22 May 2017 08:18:56 +0000 (10:18 +0200)]
Prep v229: Some musl-libc compatibility updates

- musl-libc has no <bits/local_lim.h>
- musl-libc has no <xlocale.h>
- added <missing.h> include to basic/mdkir.c

6 years agoPrep v229: Consolidate system sleep functions.
Sven Eden [Mon, 22 May 2017 07:12:52 +0000 (09:12 +0200)]
Prep v229: Consolidate system sleep functions.

Move sleep relevant functions from shared/sleep-config.* and
login/logind-action.* into login/logind-sleep.* - they aren't used outside
of elogind anyway.

6 years agoPrep v229: elogind should honor its Sleep configuration.
Sven Eden [Fri, 19 May 2017 11:18:31 +0000 (13:18 +0200)]
Prep v229: elogind should honor its Sleep configuration.

6 years agosrc/login/logind.conf : Fix naming
Sven Eden [Fri, 19 May 2017 06:53:29 +0000 (08:53 +0200)]
src/login/logind.conf : Fix naming

6 years agoPrep v229: Update and fix man page building (Makefile-man.am)
Sven Eden [Thu, 18 May 2017 07:14:33 +0000 (09:14 +0200)]
Prep v229: Update and fix man page building (Makefile-man.am)

6 years agoPrep v229: Mask more unused functions in src/basic
Sven Eden [Thu, 18 May 2017 05:25:40 +0000 (07:25 +0200)]
Prep v229: Mask more unused functions in src/basic

6 years agoPrep v229: Use parse-printf-format.h if configure did not find printf.h
Sven Eden [Thu, 18 May 2017 05:50:58 +0000 (07:50 +0200)]
Prep v229: Use parse-printf-format.h if configure did not find printf.h

6 years agoPrep v229: Remove orphaned files
Sven Eden [Wed, 17 May 2017 15:46:20 +0000 (17:46 +0200)]
Prep v229: Remove orphaned files

The files
 - src/shared/output-mode.h and
 - src/test/test-signal-util.c
are not used anywhere anymore.

6 years agoPrep v229: Add include for parse-printf-format.h to src/basic/stdio-util.h
Sven Eden [Wed, 17 May 2017 13:26:47 +0000 (15:26 +0200)]
Prep v229: Add include for parse-printf-format.h to src/basic/stdio-util.h

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.

6 years agoPrep v229: Update core build files to upstream
Sven Eden [Tue, 25 Apr 2017 11:03:09 +0000 (13:03 +0200)]
Prep v229: Update core build files to upstream

6 years agoPrep v229: Remove remaining emacs settings [6/6] src/systemd
Sven Eden [Fri, 28 Apr 2017 05:20:08 +0000 (07:20 +0200)]
Prep v229: Remove remaining emacs settings [6/6] src/systemd

6 years agoPrep v229: Remove remaining emacs settings [5/6] src/shared
Sven Eden [Fri, 28 Apr 2017 05:09:06 +0000 (07:09 +0200)]
Prep v229: Remove remaining emacs settings [5/6] src/shared

6 years agoPrep v229: Remove remaining emacs settings [4/6] src/login
Sven Eden [Fri, 28 Apr 2017 04:51:48 +0000 (06:51 +0200)]
Prep v229: Remove remaining emacs settings [4/6] src/login

6 years agoPrep v229: Remove remaining emacs settings [3/6] src/libelogind
Sven Eden [Thu, 27 Apr 2017 10:01:28 +0000 (12:01 +0200)]
Prep v229: Remove remaining emacs settings [3/6] src/libelogind

6 years agoPrep v229: Remove remaining emacs settings [2/6] src/core
Sven Eden [Thu, 27 Apr 2017 09:50:44 +0000 (11:50 +0200)]
Prep v229: Remove remaining emacs settings [2/6] src/core

6 years agoPrep v229: Remove remaining emacs settings [1/6] src/basic
Sven Eden [Thu, 27 Apr 2017 09:36:03 +0000 (11:36 +0200)]
Prep v229: Remove remaining emacs settings [1/6] src/basic

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