Commit graph

243 commits

Author SHA1 Message Date
Lennart Poettering 9c3349e23b core: rework counting of running jobs
Let's unify the code that counts the running jobs a bit, in order to
make sure we are less likely to miss one.

This is related to this bug:

https://bugs.freedesktop.org/show_bug.cgi?id=87349

However, it probably won't fix it fully, and I cannot reproduce the issue.

The change also adds an explicit assert change when the counter is off.
2015-01-05 17:54:59 +01:00
Lennart Poettering a34bf9db5d util: rename ignore_file() to hidden_file()
hidden_file() is a bit more precise, since dot files usually shouldn't
be ignored, but certainly be considered hidden.
2014-12-19 20:03:36 +01:00
Lennart Poettering 0faacd470d unit: handle nicely of certain unit types are not supported on specific systems
Containers do not really support .device, .automount or .swap units;
Systems compiled without support for swap do not support .swap units;
Systems without kdbus do not support .busname units.

With this change attempts to start a unsupported unit types will result
in an immediate "unsupported" job result, which is a lot more
descriptive then before. Also, attempts to start device units in
containers will now immediately fail instead of causing jobs to be
enqueued that never go away.
2014-12-15 19:02:17 +01:00
Torstein Husebø ee33e53a70 core: correct spacing near eol in code comments 2014-12-11 15:09:51 +01:00
Lennart Poettering 96aad8d15a sd-bus: move common errors src/shared/bus-errors.h → src/libsystemd/sd-bus/bus-common-errors.h
Stuff in src/shared/ should not use stuff from src/libsystemd/ really.
2014-12-10 19:07:48 +01:00
Lennart Poettering e5035a2778 manager: log deserialization errors only at LOG_DEBUG level
During upgrades and when transitioning between different systemd
versions in initrd and on the host we have to expect that some
serialization fields are unknown or parse incorrectly. This shouldn't
really be considered an error, hence downgrade the log messages about
it to debug. This way we can still trace it, but it doesn't confuse
users.

This kinda reverts 46849c3f.
2014-12-02 13:23:03 +01:00
Lennart Poettering 230314d718 core: OOM really shouldn't be considered a deserialization parse failure 2014-12-02 13:23:03 +01:00
Chris Leech befb6d5494 mount: monitor for utab changes with inotify
Parsing the mount table with libmount races against the mount command,
which will handle the actual mounting before updating utab.  This means
the poll event on /proc/self/mountinfo can kick of a reparse in systemd
before the utab information is available.

This change adds in an additional event source using inotify to watch
for changes to utab.  It only watches for IN_MOVED_TO events, matching
libmount behavior of always overwriting this file using rename(2).

This does add a second pass through the mount table parsing when utab is
updated.
2014-11-28 14:30:50 -05:00
Michal Schmidt 4a62c710b6 treewide: another round of simplifications
Using the same scripts as in f647962d64 "treewide: yet more log_*_errno
+ return simplifications".
2014-11-28 19:57:32 +01:00
Michal Schmidt 56f64d9576 treewide: use log_*_errno whenever %m is in the format string
If the format string contains %m, clearly errno must have a meaningful
value, so we might as well use log_*_errno to have ERRNO= logged.

Using:
find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/'

Plus some whitespace, linewrap, and indent adjustments.
2014-11-28 19:49:27 +01:00
Michal Schmidt 895b3a7b44 core: fix return value in error path after sd_event_add_io() failure
sd_event_add_io() does not set errno, it returns negative errno.

Noticed during log_*_errno conversions.
2014-11-28 19:20:59 +01:00
Michal Schmidt 23bbb0de4e treewide: more log_*_errno + return simplifications 2014-11-28 18:24:30 +01:00
Michal Schmidt eb56eb9b40 treewide: simplify log_*_errno(r,...) immediately followed by "return r" 2014-11-28 17:34:26 +01:00
Michal Schmidt c33b329709 treewide: more log_*_errno() conversions, multiline calls
Basically:

find . -name '*.[ch]' | while read f; do perl -i.mmm -e \
'local $/;
 local $_=<>;
 s/log_(debug|info|notice|warning|error|emergency)\("([^"]*)%s"([^;]*),\s*strerror\(-?([->a-zA-Z_]+)\)\);/log_\1_errno(\4, "\2%m"\3);/gms;print;' \
 $f; done

Plus manual indentation fixups.
2014-11-28 17:17:51 +01:00
Michal Schmidt da927ba997 treewide: no need to negate errno for log_*_errno()
It corrrectly handles both positive and negative errno values.
2014-11-28 13:29:21 +01:00
Michal Schmidt 0a1beeb642 treewide: auto-convert the simple cases to log_*_errno()
As a followup to 086891e5c1 "log: add an "error" parameter to all
low-level logging calls and intrdouce log_error_errno() as log calls
that take error numbers", use sed to convert the simple cases to use
the new macros:

find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/'

Multi-line log_*() invocations are not covered.
And we also should add log_unit_*_errno().
2014-11-28 12:04:41 +01:00
Lennart Poettering 387eba0084 core: only override kdbus attach mask when running as PID 1 2014-11-28 02:26:05 +01:00
Lennart Poettering e2cc6eca73 log: fix order of log_unit_struct() to match other logging calls
Also, while we are at it, introduce some syntactic sugar for creating
ERRNO= and MESSAGE= structured logging fields.
2014-11-28 02:18:46 +01:00
Lennart Poettering 1a29929959 kdbus: set kernel attach mask before creating the first bus 2014-11-27 22:05:24 +01:00
Lennart Poettering 79008bddf6 log: rearrange log function naming
- Rename log_meta() → log_internal(), to follow naming scheme of most
  other log functions that are usually invoked through macros, but never
  directly.

- Rename log_info_object() to log_object_info(), simply because the
  object should be before any other parameters, to follow OO-style
  programming style.
2014-11-27 22:05:24 +01:00
Zbigniew Jędrzejewski-Szmek cb6531bee6 manager: print fatal errors on the console too
When booting in quiet mode, fatal messages would not be shown at all to the user.

https://bugzilla.redhat.com/show_bug.cgi?id=1155468
2014-11-26 15:17:07 -05:00
Zbigniew Jędrzejewski-Szmek 06d8d842e9 manager: let manager_free() handle NULLs
This makes the calling code a bit simpler.
2014-11-23 19:17:28 -05:00
Lukas Nykryn f44b9efcec dbus: return non-zero return value in the case that prefix won't match
strv_extend returns 0 in the case of success which means that
else if (bus_track_deserialize_item(&m->deserialized_subscribed, l) == 0)
        log_warning("Unknown serialization item '%s'", l);
will be printed when value is added correctly.
2014-11-23 19:15:20 -05:00
Daniel Mack 63cc4c3138 sd-bus: sync with kdbus upstream (ABI break)
kdbus has seen a larger update than expected lately, most notably with
kdbusfs, a file system to expose the kdbus control files:

 * Each time a file system of this type is mounted, a new kdbus
   domain is created.

 * The layout inside each mount point is the same as before, except
   that domains are not hierarchically nested anymore.

 * Domains are therefore also unnamed now.

 * Unmounting a kdbusfs will automatically also detroy the
   associated domain.

 * Hence, the action of creating a kdbus domain is now as
   privileged as mounting a filesystem.

 * This way, we can get around creating dev nodes for everything,
   which is last but not least something that is not limited by
   20-bit minor numbers.

The kdbus specific bits in nspawn have all been dropped now, as nspawn
can rely on the container OS to set up its own kdbus domain, simply by
mounting a new instance.

A new set of mounts has been added to mount things *after* the kernel
modules have been loaded. For now, only kdbus is in this set, which is
invoked with mount_setup_late().
2014-11-13 20:41:52 +01:00
Ronny Chevalier 07aa32e31d manager: allow test run to catch SIGCHLD events
Otherwise we cannot know when a service exited
2014-11-13 10:39:51 +01:00
Ronny Chevalier 0c2a5d721e core: remove unused macro GC_QUEUE_USEC_MAX
It is unused since cf1265e188
2014-11-08 22:48:17 +01:00
Lennart Poettering f0e62e8997 core: unify how we create the notify and private dbus socket
Use the same robust logic of mkdir + unlink of any existing AF_UNIX
socket, ignoring the return value, right before bind().
2014-11-07 16:36:14 +01:00
Lennart Poettering 498e87d6b7 manager: cast mkdir() result to (void) to make sure coverity is quiet
Also simplify the code a bit by moving mkdir to the common path.
2014-11-07 02:05:50 +01:00
Colin Guthrie 0c3f25e0c1 manager: Ensure user's systemd runtime directory exists.
This mirrors code in dbus.c when creating the private socket and
avoids error messages like:

systemd[1353]: bind(/run/user/603/systemd/notify) failed: No such file or directory
systemd[1353]: Failed to fully start up daemon: No such file or directory
2014-11-05 14:49:06 +00:00
Lennart Poettering 0aa281df2c audit: improve the audit messages we generate
always pass along comm, as documented by audit. Always set the correct
comm value.
2014-11-04 00:48:09 +01:00
Zbigniew Jędrzejewski-Szmek 56dacdbc1c manager: do not print timing when running in test mode 2014-11-02 12:33:54 -05:00
Zbigniew Jędrzejewski-Szmek 7358dc029a Convert the rest to sd_bus_errnomap
I tried to preserve most errno values, but in some cases they were
inconsistent (different errno values for the same error name) or just
mismatched.
2014-10-30 20:38:28 -04:00
Zbigniew Jędrzejewski-Szmek ebc5788e88 manager: print warning on console before reboot
It will be printed even if a prompt is blocking other messages.
2014-10-27 23:17:49 -04:00
Zbigniew Jędrzejewski-Szmek 127d5fd156 manager: convert ephemeral to enum
In preparation for subsequent changes.
2014-10-27 23:02:54 -04:00
Zbigniew Jędrzejewski-Szmek e46b13c8c7 manager: do not print anything while passwords are being queried
https://bugs.freedesktop.org/show_bug.cgi?id=73942
2014-10-27 22:33:14 -04:00
Lennart Poettering fa1b91632c core: remove system start timeout logic again
The system start timeout as previously implemented would get confused by
long-running services that are included in the initial system startup
transaction for example by being cron-job-like long-running services
triggered immediately at boot. Such long-running jobs would be subject
to the default 15min timeout, esily triggering it.

Hence, remove this again. In a subsequent commit, introduce per-target
job timeouts instead, that allow us to control these timeouts more
finegrained.
2014-10-28 01:42:13 +01:00
Lennart Poettering 4dffec1459 manager: Linux on hppa has fewer rtsigs, hence avoid using the higher ones there
https://bugs.freedesktop.org/show_bug.cgi?id=84931
2014-10-24 13:45:24 +02:00
Ronny Chevalier e4746b5738 util: avoid duplication of TIME_T_MAX 2014-10-21 00:38:30 +02:00
Zbigniew Jędrzejewski-Szmek e7bc519620 systemd: try harder to bind to notify socket
Without the socket open we are going to crash and burn. If for
whatever reason we fail during deserialization we will fail when
trying to open the socket. In this case it is better to unlink the old
socket and maybe lose some messages, than to continue without the
notification socket.

Of course this situation should not happen, but we should handle
it as gracefully as possible anyway.

https://bugzilla.redhat.com/show_bug.cgi?id=1099299
2014-10-17 10:09:27 -04:00
Zbigniew Jędrzejewski-Szmek 46849c3fb1 systemd: log deserialization errors as warnings
If we failed to parse something that we wrote ourselves,
things are seriously off. This is also likely to lead to
problems futher on.
2014-10-17 10:09:27 -04:00
Andreas Henriksson aa9f8a30fd core: fix resource leak in manager_environment_add
Second error path must free the (potentially) allocated memory in the
first code chunk before returning.

Found by coverity. Fixes: CID#1237750
2014-09-16 21:47:24 +02:00
Michal Schmidt d5099efc47 hashmap: introduce hash_ops to make struct Hashmap smaller
It is redundant to store 'hash' and 'compare' function pointers in
struct Hashmap separately. The functions always comprise a pair.
Store a single pointer to struct hash_ops instead.

systemd keeps hundreds of hashmaps, so this saves a little bit of
memory.
2014-09-15 16:08:50 +02:00
Thomas Hindoe Paaboel Andersen 807d0cca2b manager: use correct cleanup function
Close the dir instead of attempt to free it.

Introduced in 874310b7b6

Found with coverity. Fixes: CID#996368
2014-09-11 21:22:45 +02:00
Lennart Poettering d81afec1c9 core: split up "starting" manager state into "initializing" and "starting"
We'll stay in "initializing" until basic.target has reached, at which
point we will enter "starting".

This is preparation so that we can change the startip timeout to only
apply to the first phase of startup, not the full procedure.
2014-08-22 18:10:31 +02:00
Lennart Poettering f07756bfe2 core: introduce "poweroff" as new failure action types
Also, change the default action on a system start-up timeout to powering off.
2014-08-22 18:10:31 +02:00
Lennart Poettering e12919e8be core: print 'startup finished' messages even if we log to console 2014-08-22 18:10:31 +02:00
Lennart Poettering 2928b0a863 core: add support for a configurable system-wide start-up timeout
When this system-wide start-up timeout is hit we execute one of the
failure actions already implemented for services that fail.

This should not only be useful on embedded devices, but also on laptops
which have the power-button reachable when the lid is closed. This
devices, when in a backpack might get powered on by accident due to the
easily reachable power button. We want to make sure that the system
turns itself off if it starts up due this after a while.

When the system manages to fully start-up logind will suspend the
machine by default if the lid is closed. However, in some cases we don't
even get as far as logind, and the boot hangs much earlier, for example
because we ask for a LUKS password that nobody ever enters.

Yeah, this is a real-life problem on my Yoga 13, which has one of those
easily accessible power buttons, even if the device is closed.
2014-08-22 18:10:31 +02:00
Lennart Poettering af4ec4309e notify: send STOPPING=1 from our daemons 2014-08-21 17:24:21 +02:00
Lennart Poettering 70af4d17da manager: don#t dispatch sd_notify() messages and SIGCHLD multiple times to the same units 2014-08-21 17:24:21 +02:00
Lennart Poettering 55836941ff manager: reuse sockaddr_union instead of redefining our own version of it 2014-08-21 17:24:21 +02:00