1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-07 01:27:11 +03:00
Commit Graph

12413 Commits

Author SHA1 Message Date
Lennart Poettering
18387b5983 macro: add new assert_return() macro for early parameter checking in functions
For the library functions we expose we currently repeatedly use checks
like the following:

if (!value_is_ok(parameter1))
        return -EINVAL;
if (!value_is_ok(parameter2))
        return -EINVAL;

And so on. Let's turn this into a macro:

assert_return(value_is_ok(parameter1), -EINVAL);
assert_return(value_is_ok(paramater2), -EINVAL);

This makes our code a bit shorter and simpler, and also allows us to add
a _unlikely_() around the check.
2013-10-11 00:45:47 +02:00
Lennart Poettering
eaa3cbef3b event: refuse operation if the caller tries to reuse an event loop after a fork() 2013-10-10 21:37:50 +02:00
Lennart Poettering
c2ba3ad660 event: add timer accuracy/coalescing logic
In order to improve energy consumption we should minimize our wake-ups
when handling timers.  Hence, for each timer take an accuracy value and
schedule the actual wake-up time somewhere between the specified time
and the specified timer plus the accuracy.

The specified time of timer event sources hence becomes the time the
handler is called the *earliest*, and the specified time plus the accuracy
the time by which it is called the *latest*, leaving the library the
freedom to schedule the wake-up somewhere inbetween.

If the accuracy is specified as 0 the default of 250ms will be used.

When scheduling timeouts we will now try to elapse them at the same
point within each second, across the entire system. We do this by using
a fixed perturbation value keyed off the boot id. If this point within a
second is not in the acceptable range, we try again with a fixed time
within each 250ms time step. If that doesn't work either, we wake up at
the last possible time.
2013-10-10 21:22:59 +02:00
Lennart Poettering
5a045dad1c security: missing header inclusions 2013-10-10 21:22:59 +02:00
Tero Roponen
dfcd88f634 bus: fix duplicate comparisons
Testing for y > x is the same as testing for x < y.
2013-10-10 18:37:48 +02:00
Lennart Poettering
d682b3a7e7 security: rework selinux, smack, ima, apparmor detection logic
Always cache the results, and bypass low-level security calls when the
respective subsystem is not enabled.
2013-10-10 16:35:44 +02:00
David Herrmann
0581dac2c1 login: make sd_session_get_vt() actually work
We use VTNR, not VTNr as key. Until now sd_session_get_vt() just returns
an error.
2013-10-10 13:14:18 +02:00
David Herrmann
3f4fee033b login: fix invalid free() in sd_session_get_vt()
We need to clear variables markes as _cleanup_free_. Otherwise, our
error-paths might corrupt random memory.
2013-10-10 13:14:18 +02:00
Lennart Poettering
fd38203a2a bus: add minimal event loop API
So far we tried to use epoll directly wherever we needed an event loop.
However, that has various shortcomings, such as the inability to handle
larger amounts of timers (since each timerfd costs one fd, which is a
very limited resource, usually bounded to 1024), and inability to do
priorisation between multiple queued events.

Let's add a minimal event loop API around epoll that is suitable for
implementation of our own daemons and maybe one day can become public
API for those who desire it.

This loop is part of libsystemd-bus, but may be used independently of
it.
2013-10-10 04:44:48 +02:00
Zbigniew Jędrzejewski-Szmek
2b98f75a63 journald: remove rotated file from hashmap when rotation fails
Before, when the user journal file was rotated, journal_file_rotate
could close the old file and fail to open the new file. In that
case, we would leave the old (deallocated) file in the hashmap.
On subsequent accesses, we could retrieve this stale entry, leading
to a segfault.

When journal_file_rotate fails with the file pointer set to 0,
old file is certainly gone, and cannot be used anymore.

https://bugzilla.redhat.com/show_bug.cgi?id=890463
2013-10-09 22:32:08 -04:00
Zbigniew Jędrzejewski-Szmek
57535f4703 journald: replace new+snprintf with asprintf 2013-10-09 22:32:08 -04:00
Kay Sievers
6c7980093c do not accept "garbage" from acpi firmware performance data (FPDT)
00000000  46 42 50 54 38 00 00 00  02 00 30 02 00 00 00 00  |FBPT8.....0.....|
00000010  23 45 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |#E..............|
00000020  f5 6a 51 00 00 00 00 00  00 00 00 00 00 00 00 00  |.jQ.............|
00000030  00 00 00 00 00 00 00 00  70 74 61 6c 58 00 00 00  |........ptalX...|
2013-10-10 01:38:11 +02:00
Auke Kok
8552b17660 Smack: Test if smack is enabled before mounting
Since on most systems with xattr systemd will compile with Smack
support enabled, we still attempt to mount various fs's with
Smack-only options.

Before mounting any of these Smack-related filesystems with
Smack specific mount options, check if Smack is functionally
active on the running kernel.

If Smack is really enabled in the kernel, all these Smack mounts
are now *fatal*, as they should be.

We no longer mount smackfs if systemd was compiled without
Smack support. This makes it easier to make smackfs mount
failures a critical error when Smack is enabled.

We no longer mount these filesystems with their Smack specific
options inside containers. There these filesystems will be
mounted with there non-mount smack options for now.
2013-10-09 15:06:17 -07:00
Kay Sievers
463b5dbb0d udev: add SECLABEL{selinux}= support 2013-10-09 17:31:41 +02:00
Martin Pitt
35bffce819 keymap: Fix Samsung 900X[34]C
It appears that it's not really the 900 vs. 940 or the X3 vs X4, but the
A/B/C/D suffix after that which makes the difference between the keymaps. On a
NP900X3C-A04RU you get

   MODALIAS=dmi:bvn*:bvr*:bd*:svnSAMSUNGELECTRONICSCO.,LTD.:pn900X3C/900X3D/900X4C/900X4D:*

So change the matches to use AB vs. CDG as the differentiator.

Thanks to Anatoly Markov for reporting and testing!
2013-10-09 16:13:20 +02:00
Kay Sievers
b7e2b7641e udev: reset Linux Security Module labels if no custom rules are given 2013-10-09 04:26:41 +02:00
Lennart Poettering
753eff037e bus: fix missing initialization 2013-10-09 04:08:00 +02:00
Lennart Poettering
510b857f7d tests: fix some memory leaks in tests 2013-10-09 04:08:00 +02:00
Lennart Poettering
2ee0591d12 journald: fix minor memory leak 2013-10-09 04:08:00 +02:00
Lennart Poettering
cac914e643 build-sys: add a makefile target to run all tests through valgrind 2013-10-09 04:08:00 +02:00
Kay Sievers
87b20a8118 build-sys: add sd-bus-vtable.h header 2013-10-09 03:39:57 +02:00
Lennart Poettering
bb874efc38 bus: fix GetAll() userdata passing 2013-10-09 03:29:20 +02:00
Lennart Poettering
486e950bd9 bus: don't require that if a child object node exists its parent node must too 2013-10-09 03:29:20 +02:00
Lennart Poettering
3a7d4f1ba4 bus: fix synthetic error messages 2013-10-09 03:29:20 +02:00
Lennart Poettering
29ddb38fea libsystemd-bus: add lightweight object vtable implementation for exposing objects on the bus
This adds a lightweight scheme how to define interfaces in static fixed
arrays which then can be easily registered on a bus connection. This
makes it much easier to write bus services.

This automatically handles implementation of the Properties,
ObjectManager, and Introspection bus interfaces.
2013-10-09 02:40:07 +02:00
Lennart Poettering
8d1a280204 core: unify the way we denote serialization attributes 2013-10-09 00:13:55 +02:00
Sylvia Else
6aca9a587d systemd: serialize/deserialize forbid_restart value
The Service type's forbid_restart field was not preserved by
serialization/deserialization, so the fact that the service should not
be restarted after stopping was lost.

If a systemctl stop foo command has been given, but the foo service
has not yet stopped, and then the systemctl --system daemon-reload was
given, then when the foo service eventually stopped, systemd would
restart it.

https://bugs.freedesktop.org/show_bug.cgi?id=69800
2013-10-07 23:41:05 -04:00
Zbigniew Jędrzejewski-Szmek
2b8f6883a1 journalctl: flip to --full by default
We already shew lines in full when using a pager or not on a
tty. The commit disables ellipsization in the sole remaining case,
namely when --follow is used.

This has been a popular request for a long time, and indeed, full
output seems much more useful. Old behaviour can still be requested by
using --no-full. Old options retain their behaviour for compatiblity,
but aren't advertised as much. This change applies only to jornalctl,
not to systemctl, when ellipsization is useful to keep the layout.

https://bugzilla.redhat.com/show_bug.cgi?id=984758
2013-10-07 23:41:05 -04:00
Kay Sievers
c26547d612 udev: support custom Linux Security Module labels for device nodes 2013-10-08 02:23:24 +02:00
Auke Kok
8b197c3a8a Run with a custom SMACK domain (label).
Allows the systemd --system process to change its current
SMACK label to a predefined custom label (usually "system")
at boot time.

This is needed to have a few system-generated folders and
sockets automatically be created with the right SMACK
label. Without that, processes either cannot communicate with
systemd or systemd fails to perform some actions.
2013-10-07 10:23:20 -07:00
Auke Kok
d407c94020 Mount /run, /dev/shm usable to tasks when using SMACK.
Once systemd itself is running in a security domain for SMACK,
it will fail to start countless tasks due to missing privileges
for mounted and created directory structures. For /run and shm
specifically, we grant all tasks access.

These 2 mounts are allowed to fail, which will happen if the
system is not running a SMACK enabled kernel or security=none is
passed to the kernel.
2013-10-07 10:23:20 -07:00
Dave Reisner
1d5989fd80 shared/util: fix off-by-one error in tag_to_udev_node
Triggered false negatives when encoding a string which needed every
character to be escaped, e.g. "LABEL=/".
2013-10-06 18:29:12 -04:00
Zbigniew Jędrzejewski-Szmek
a7176505e0 utf8: fix utf8_is_printable 2013-10-05 22:59:43 -04:00
Zbigniew Jędrzejewski-Szmek
fc676b00a7 core: do not add "what" to RequiresMountsFor for network mounts
For cifs mount like //server/share, we would get
RequiresMountsFor=/server/share, which probably isn't
harmful, but quite confusing.

Unfortunately a bunch of static functions had to be moved
up, but patch is really one line.
2013-10-05 13:39:46 -04:00
Dave Reisner
9c03872bc8 mount: check for NULL before reading pm->what
Since a57f7e2c82, a mount unit with garbage in it would cause
systemd to crash on loading it.

ref: https://bugs.freedesktop.org/show_bug.cgi?id=70148
2013-10-04 18:23:53 -04:00
Lennart Poettering
660ea9620f logind: fix bus introspection data for TakeControl() 2013-10-04 21:17:17 +02:00
Lennart Poettering
a316932f5a manager: when verifying whether clients may change environment using selinux check for "reload" rather "reboot"
This appears to be a copy/paste error.
2013-10-04 17:05:15 +02:00
Lennart Poettering
7f79cd7109 update TODO 2013-10-04 17:05:14 +02:00
Zbigniew Jędrzejewski-Szmek
77009452cf systemd: order remote mounts from mountinfo before remote-fs.target
Usually the network is stopped before filesystems are umounted.
Ordering network filesystems before remote-fs.target means that their
unmounting will be performed earlier, and can terminate sucessfully.

https://bugs.freedesktop.org/show_bug.cgi?id=70002
2013-10-03 22:15:08 -04:00
Zbigniew Jędrzejewski-Szmek
5862d652ba Introduce _cleanup_endmntent_ 2013-10-03 22:13:55 -04:00
Zbigniew Jędrzejewski-Szmek
9a5cb1371b gpt-auto-generator: exit immediately if in container
Otherwise we get an ugly warning when running systemd in
a container.
2013-10-03 22:13:01 -04:00
Zbigniew Jędrzejewski-Szmek
970edce6ef execute: more debugging messages 2013-10-03 22:12:32 -04:00
Václav Pavlín
e776c8cfcd man: Improve the description of parameter X in tmpfiles.d page 2013-10-03 15:49:03 +02:00
Zbigniew Jędrzejewski-Szmek
59fccd8211 execute.c: always set $SHELL
In e6dca81 $SHELL was added to user@.service. Let's
instead provide it to all units which have a user.
2013-10-02 22:23:56 +02:00
Dave Reisner
7074fecf67 tmpfiles.d: include setgid perms for /run/log/journal
4608af4333 set permissions for journal storage on persistent disk
but not the volatile storage.

ref: https://bugs.archlinux.org/task/37170
2013-10-02 15:35:16 -04:00
Lennart Poettering
51045322c4 nspawn: always copy /etc/resolv.conf rather than bind mount
We were already creating the file if it was missing, and this way
containers can reconfigure the file without running into problems.

This also makes resolv.conf handling more alike to handling of
/etc/localtime, which is also not a bind mount.
2013-10-02 19:45:12 +02:00
Lennart Poettering
69c2b6be8f mkdir: pass a proper function pointer to mkdir_safe_internal 2013-10-02 19:45:12 +02:00
Lennart Poettering
5b4fb02d89 strv: don't access potentially NULL string arrays 2013-10-02 19:45:12 +02:00
Lennart Poettering
62678deda2 efi: never call qsort on potentially NULL arrays 2013-10-02 19:45:12 +02:00
Lennart Poettering
b857193b1d modules-load: fix error handling 2013-10-02 19:45:12 +02:00