Commit Graph

213 Commits

Author SHA1 Message Date
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
Lennart Poettering c1dc6153c9 log: never ever log to syslog from PID 1, log to the journal again
We don't support journal-less systems anyway, so let's avoid the
confusion.
2014-08-11 20:08:08 +02:00
Zbigniew Jędrzejewski-Szmek 1d749d044b tty-ask-password-agent: modernization 2014-08-03 21:46:07 -04:00
Kay Sievers 3a43da2832 time-util: add and use USEC/NSEC_INFINIY 2014-07-29 13:20:20 +02:00
Zbigniew Jędrzejewski-Szmek 1cd974edfd systemd: return the first error from manager_startup() 2014-07-20 19:48:16 -04:00
Zbigniew Jędrzejewski-Szmek 0d8c31ff72 test-engine: fix access to unit load path
Also add a bit of debugging output to help diagnose problems,
add missing units, and simplify cppflags.

Move test-engine to normal tests from manual tests, it should now
work without destroying the system.
2014-07-20 19:48:16 -04:00
Zbigniew Jędrzejewski-Szmek 6b9732b2bf Be more verbose when bind or listen fails
Also be more verbose in devnode_acl_all().
2014-07-18 21:44:59 -04:00
Umut Tezduyar Lindskog 285cd771cb core: fix oneshot service resource control
Oneshot services's cgroup is removed when the service
exits. An assert is hit otherwise.
2014-07-15 10:08:01 -04:00
Lennart Poettering e26807239b firstboot: get rid of firstboot generator again, introduce ConditionFirstBoot= instead
As Zbigniew pointed out a new ConditionFirstBoot= appears like the nicer
way to hook in systemd-firstboot.service on first boots (those with /etc
unpopulated), so let's do this, and get rid of the generator again.
2014-07-07 21:05:09 +02:00
Lennart Poettering 418b9be500 firstboot: add new component to query basic system settings on first boot, or when creating OS images offline
A new tool "systemd-firstboot" can be used either interactively on boot,
where it will query basic locale, timezone, hostname, root password
information and set it. Or it can be used non-interactively from the
command line when prepareing disk images for booting. When used
non-inertactively the tool can either copy settings from the host, or
take settings on the command line.

$ systemd-firstboot --root=/path/to/my/new/root --copy-locale --copy-root-password --hostname=waldi

The tool will be automatically invoked (interactively) now on first boot
if /etc is found unpopulated.

This also creates the infrastructure for generators to be notified via
an environment variable whether they are running on the first boot, or
not.
2014-07-07 15:25:55 +02:00
Lennart Poettering 9a05490933 cgroups: simplify CPUQuota= logic
Only accept cpu quota values in percentages, get rid of period
definition.

It's not clear whether the CFS period controllable per-cgroup even has a
future in the kernel, hence let's simplify all this, hardcode the period
to 100ms and only accept percentage based quota values.
2014-05-22 11:53:12 +09:00
Lennart Poettering db785129c9 cgroup: rework startup logic
Introduce a (unsigned long) -1 as "unset" state for cpu shares/block io
weights, and keep the startup unit set around all the time.
2014-05-22 07:13:56 +09:00
WaLyong Cho 95ae05c0e7 core: add startup resource control option
Similar to CPUShares= and BlockIOWeight= respectively. However only
assign the specified weight during startup. Each control group
attribute is re-assigned as weight by CPUShares=weight and
BlockIOWeight=weight after startup.  If not CPUShares= or
BlockIOWeight= be specified, then the attribute is re-assigned to each
default attribute value. (default cpu.shares=1024, blkio.weight=1000)
If only CPUShares=weight or BlockIOWeight=weight be specified, then
that implies StartupCPUShares=weight and StartupBlockIOWeight=weight.
2014-05-22 07:13:56 +09:00
Lennart Poettering 9bdb98c594 core: make sure to serialize jobs for all units
Previously we wouldn't serialize jobs for units that themselves have
nothing to serialize.

http://lists.freedesktop.org/archives/systemd-devel/2014-May/019051.html
2014-05-16 01:15:03 +02:00
Zbigniew Jędrzejewski-Szmek 12ed81d9c8 Make systemctl --root look for files in the proper places
Running systemctl enable/disable/set-default/... with the --root
option under strace reveals that it accessed various files and
directories in the main fs, and not underneath the specified root.
This can lead to correct results only when the layout and
configuration in the container are identical, which often is not the
case. Fix this by adding the specified root to all file access
operations.

This patch does not handle some corner cases: symlinks which point
outside of the specified root might be interpreted differently than
they would be by the kernel if the specified root was the real root.
But systemctl does not create such symlinks by itself, and I think
this is enough of a corner case not to be worth the additional
complexity of reimplementing link chasing in systemd.

Also, simplify the code in a few places and remove an hypothetical
memory leak on error.
2014-05-15 15:29:58 +02:00
Lennart Poettering b2f8b02ec2 core: expose CFS CPU time quota as high-level unit properties 2014-04-25 13:27:25 +02:00
Kay Sievers 530a9662aa core: do not read system boot timestamps in systemd --user mode
Before:
  $ systemd-analyze --user
  Startup finished in 2.810s (firmware) + 48ms (loader) + 122ms (userspace) = 122ms

After:
  $ systemd-analyze --user
  Startup finished in 122ms (userspace) = 122ms
2014-03-26 03:47:03 +01:00
Lennart Poettering bd8f585b99 core: add a setting to globally control the default for timer unit accuracy 2014-03-24 16:24:07 +01:00
Lennart Poettering 3d94f76c99 util: replace close_pipe() with new safe_close_pair()
safe_close_pair() is more like safe_close(), except that it handles
pairs of fds, and doesn't make and misleading allusion, as it works
similarly well for socketpairs() as for pipe()s...
2014-03-24 03:22:44 +01:00
Lennart Poettering 6a0f1f6d5a sd-event: rework API to support CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM, too 2014-03-24 02:58:41 +01:00
Lennart Poettering 7181dbdb2e core: move notify sockets to /run and $XDG_RUNTIME_DIR
A service with PrivateNetwork= cannot access abstract namespace sockets
of the host anymore, hence let's better not use abstract namespace
sockets for this, since we want to make sure that PrivateNetwork=
is useful and doesn't break sd_notify().
2014-03-19 22:46:45 +01:00
Lennart Poettering 03e334a1c7 util: replace close_nointr_nofail() by a more useful safe_close()
safe_close() automatically becomes a NOP when a negative fd is passed,
and returns -1 unconditionally. This makes it easy to write lines like
this:

        fd = safe_close(fd);

Which will close an fd if it is open, and reset the fd variable
correctly.

By making use of this new scheme we can drop a > 200 lines of code that
was required to test for non-negative fds or to reset the closed fd
variable afterwards.
2014-03-18 19:31:34 +01:00
Lennart Poettering 0851062751 manager: use system state enum where appropriate 2014-03-12 22:27:13 +01:00
Lennart Poettering f755e3b74b core: introduce system state enum
The system state knows the states starting →
running/degraded/maintenance → stopping, where:

starting = system startup
running = normal operation
degraded = at least one unit is currently in failed state
maintenance = rescue/emergency mode is active or queued
stopping = system shutdown
2014-03-12 20:55:13 +01:00
Daniel Mack b2cdc6664e manager: flush memory stream before using the buffer
When the manager receives a SIGUSR2 signal, it opens a memory stream
with open_memstream(), uses the returned file handle for logging, and
dumps the logged content with log_dump().

However, the char* buffer is only safe to use after the file handle has
been flushed with fflush, as the man pages states:

  When the stream is closed (fclose(3)) or flushed (fflush(3)), the
  locations pointed to by ptr and sizeloc are updated to contain,
  respectively, a pointer to the buffer and the current size of  the
  buffer.
  These values remain valid only as long as the caller performs no
  further output on the stream.  If further output is performed, then the
  stream must again be flushed before trying to access these variables.

Without that call, dump remains NULL and the daemon crashes in
log_dump().
2014-03-07 15:15:56 +01:00
Lennart Poettering aa62a8936f util: add timeout to generator execution 2014-03-06 04:00:42 +01:00
Lennart Poettering 517d56b1d0 missing: if RLIMIT_RTTIME is not defined by the libc, then we need a new define for the max number of rlimits, too 2014-03-05 02:31:09 +01:00
Lennart Poettering e66cf1a3f9 core: introduce new RuntimeDirectory= and RuntimeDirectoryMode= unit settings
As discussed on the ML these are useful to manage runtime directories
below /run for services.
2014-03-03 17:55:32 +01:00
Lennart Poettering 8f8f05a919 bus: add sd_bus_track object for tracking peers, and port core over to it
This is primarily useful for services that need to track clients which
reference certain objects they maintain, or which explicitly want to
subscribe to certain events. Something like this is done in a large
number of services, and not trivial to do. Hence, let's unify this at
one place.

This also ports over PID 1 to use this to ensure that subscriptions to
job and manager events are correctly tracked. As a side-effect this
makes sure we properly serialize and restore the track list across
daemon reexec/reload, which didn't work correctly before.

This also simplifies how we distribute messages to broadcast to the
direct busses: we only track subscriptions for the API bus and
implicitly assume that all direct busses are subscribed. This should be
a pretty OK simplification since clients connected via direct bus
connections are shortlived anyway.
2014-03-03 02:34:13 +01:00
Lennart Poettering 151b9b9662 api: in constructor function calls, always put the returned object pointer first (or second)
Previously the returned object of constructor functions where sometimes
returned as last, sometimes as first and sometimes as second parameter.
Let's clean this up a bit. Here are the new rules:

1. The object the new object is derived from is put first, if there is any

2. The object we are creating will be returned in the next arguments

3. This is followed by any additional arguments

Rationale:

For functions that operate on an object we always put that object first.
Constructors should probably not be too different in this regard. Also,
if the additional parameters might want to use varargs which suggests to
put them last.

Note that this new scheme only applies to constructor functions, not to
all other functions. We do give a lot of freedom for those.

Note that this commit only changes the order of the new functions we
added, for old ones we accept the wrong order and leave it like that.
2014-02-20 00:03:10 +01:00
Zbigniew Jędrzejewski-Szmek 4daf54a851 journald: log provenience of signals 2014-02-11 19:14:47 -05:00