Commit graph

174 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek e9f3d2d508 Constify ConfigTableItem tables 2014-07-15 22:34:40 -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 3408ba015a main: explain our /etc empty check a bit in a comment 2014-07-07 15:25:55 +02:00
Lennart Poettering baa1bdf70f main: change check whether /etc is unpopulated to look for /etc/machine-id
Previously, we checked whether /etc was completely empty. This makes it
difficult though for container managers such as nspawn to install a
small number of files (such as /etc/timezone), and have the system
otherwise populate its own tree.

Hence, change this by looking for /etc/machine-id, which should be a
good sign whether /etc is populated or not.
2014-07-04 03:24:42 +02:00
Lennart Poettering 1f97091d3c main: uid_to_name() might fail due to OOM, protect against that 2014-06-27 19:35:57 +02:00
Michał Bartoszkiewicz d6239dc4b0 core: use correct format string for UIDs 2014-06-26 01:41:04 -04:00
Lennart Poettering 9bfcda9528 core: clean-up signal reset logic when reexec
There's no need to save the old sigmask, if we are going to die. Let's
simplify this. Also, reset all the signal handlers, so that we don't
leave SIG_IGN set for some of them across reexec.
2014-06-20 19:32:05 +02:00
Lennart Poettering 9e01adfa90 main: don't show help text anymore when we detect an unknown kernel cmdline value starting with "systemd."
As generators and other components started to maintain their own kernel
command line options this help text needed more and more exceptions and
wasn't complete anyway. Fixing that would leak more information about
specific generators into PID 1, which we should avoid.

Given that kernel cmdline handling traditionally doesn't generate errors
or show help texts, let's just remove the logic for it for systemd too.
2014-06-19 16:33:01 +02:00
Lennart Poettering ca05941b9a main: honour rd.systemd.unit= only in the initrd, not the host 2014-06-19 16:33:01 +02:00
Lennart Poettering 5f5c2f3855 core: populate unit file set with preset data if we boot with empty /etc 2014-06-17 03:29:23 +02:00
Lennart Poettering 489388fbc0 machine-id-setup: allow passing NULL as function argument, for simplicity 2014-06-17 03:26:40 +02:00
Lennart Poettering c47fc1f025 kmod: conditionalize kmod setup on CAP_SYS_MODULE, not whether we run in a container
It's generally preferrable to conditionalize on the actual ability to do
something then the context we run in.
2014-06-17 03:26:40 +02:00
Lennart Poettering d7b15e0a01 log: don't downgrade log level in non-PID 1 if "quiet" is passed on kernel cmdline
"debug" should apply to all tools, but "quiet" only to PID1.
2014-06-17 02:43:44 +02:00
Ruediger Oertel 5a85ca1cb6 Reset signal-mask on re-exec to init=..
Process 1 (aka init) needs to be started with an empty signal mask.
That includes the process 1 that's started after the initrd is finished.
When the initrd is using systemd (as it does with dracut based initrds)
then it is systemd that calls the real init.  Normally this is systemd
again, except when the user uses for instance "init=/bin/bash" on the
kernel command line.
2014-06-16 15:23:17 +02:00
Lennart Poettering 5b4c013121 core: don't complain at early boot if /etc/mtab is not the right symlink
When we boot up with an empty /etc it's ok if the symlink doesn't exist.
We will create it later with tmpfiles.
2014-06-13 20:11:59 +02:00
Lennart Poettering 5ae4d543cb os-release: define /usr/lib/os-release as fallback for /etc/os-release
The file should have been in /usr/lib/ in the first place, since it
describes the OS container in /usr (and not the configuration in /etc),
hence, let's support os-release files in /usr/lib as fallback if no
version in /etc exists, following the usual override logic.

A prior commit already enabled tmpfiles to create /etc/os-release as a
symlink to /usr/lib/os-release should it be missing, thus providing nice
compatibility with applications only checking in /etc.

While it's probably a good idea if all apps check both locations via a
fallback logic, it is only necessary in the early boot process, as long
as the /etc/os-release symlink has not been restored, in case we boot
with an empty /etc.
2014-06-13 20:11:59 +02:00
Lennart Poettering fdd2531170 virt: rework container detection logic
Instead of accessing /proc/1/environ directly, trying to read the
$container variable from it, let's make PID 1 save the contents of that
variable to /run/systemd/container. This allows us to detect containers
without the need for CAP_SYS_PTRACE, which allows us to drop it from a
number of daemons and from the file capabilities of systemd-detect-virt.

Also, don't consider chroot a container technology anymore. After all,
we don't consider file system namespaces container technology anymore,
and hence chroot() should be considered a container even less.
2014-05-28 18:53:44 +08:00
Kay Sievers 24efb11245 shared: rename hwclock.[ch] to clock-util.[ch] 2014-05-24 07:56:20 +09: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
Kay Sievers 99a17ada9c core: require cgroups filesystem to be available
We should no longer pretend that we can run in any sensible way
without the kernel supporting us with cgroups functionality.
2014-05-05 18:52:36 +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 b2103dccb3 reduce the amount of messages logged to /dev/kmsg when "debug" is specified 2014-04-06 00:10:18 -04: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 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
Greg KH 92f2f92edc machine-id: add --root option to operate on an alternate fs tree
This makes it possible to initialize the /etc/machine-id file on an
arbitrary filesystem hierarchy.  This helps systems that wish to run
this at image creation time in a subdirectory, or from initramfs before
pivot-root is called.

[tomegun: converted to using _cleanup_free_ macros]
2014-03-14 12:44:17 +01:00
Dave Reisner 26abdc73a2 fix off by one error in array index assertion
Since the index is already post-incremented when the array is appended
to, this assertion can be wrongly reached when the array is at capacity
(with the NULL terminator). The bug is reproducible on shutdown with
the following settings in /etc/systemd/system.conf:

  LogTarget=journal-or-kmsg
  LogColor=yes
  LogLocation=yes

Reported by Thermi on IRC.
2014-03-08 17:57:18 -05:00
Lennart Poettering 73b80ec2d9 gpt-auto-generator: automatically find the root disk of the system
When run in an initrd and no root= argument is set (or is set to
root=gpt-auto) we will automatically look for the root partition on the
same disk the EFI ESP is located on.

Since we look for swap, /home and /srv on the disk the root partition is
located on, we hence have a fully discoverable chain:

    Firmware discovers the EFI ESP partition → the initrd discovers the
    root partition → the host OS discovers swap, /home, and /srv.

Note that this requires an EFI boot loader that sets the
LoaderDevicePartUUID EFI variable, such as Gummiboot.
2014-03-07 04:31:26 +01:00
Lennart Poettering 059cb3858a util: move more intellegince into parse_proc_cmdline()
Already split variable assignments before invoking the callback. And
drop "rd." settings if we are not in an initrd.
2014-03-06 18:48:22 +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 4d7213b274 core: move ShowStatus type into the core
Let's make the scope of the show-status stuff a bit smaller, and make it
private to the core, rather than shared API in shared/.
2014-03-03 21:23:12 +01:00
Lennart Poettering b64a3d86bc execute: no need to include seccomp.h from execute.h 2014-03-03 17:55:32 +01:00
Lennart Poettering 085afe36cb core: add global settings for enabling CPUAccounting=, MemoryAccounting=, BlockIOAccounting= for all units at once 2014-02-24 23:50:10 +01:00
Łukasz Stelmach e49d3c0167 smack: set loaded_policy in smack_setup()
With loaded_policy set to true mount_setup() relabels /dev properly.
2014-02-24 17:36:13 +01:00
Lennart Poettering d9d93745cd hostnamectl: should the sanitized arch, not the native uname() one 2014-02-21 02:43:14 +01:00
Lennart Poettering 15bd5aee09 main: make gcc shut up 2014-02-17 16:18:17 +01:00
Lennart Poettering b6e2f3293d core: fixate show_status earlier, so that we actually print the welcome message
Previously, we'd fixed show_state only after printing the welcome
message which had the effect that the welcome message was almost always
suppressed.
2014-02-17 16:17:08 +01:00
Lennart Poettering 8a8bf3c045 main: don't set no_new_privs when using SystemCallArchitectures= system-wide
After all, we want to allow userspace to get new privs...
2014-02-17 15:49:21 +01:00
Zbigniew Jędrzejewski-Szmek b1e90ec515 Pass log config from systemd to systemd-shutdown
If PID 1 debug logging is enabled, it is nice to keep those settings
when switching to systemd-shutdown binary, independently of whether
this was done through /proc/cmdline options, or through runtime
manipulations.
2014-02-17 02:26:22 -05:00
Zbigniew Jędrzejewski-Szmek fb4729006a Some modernizations 2014-02-17 02:26:22 -05:00
Zbigniew Jędrzejewski-Szmek 141a79f491 Extract looping over /proc/cmdline into a shared function
In cryptsetup-generator automatic cleanup had to be replaced
with manual cleanup, and the code gets a bit longer. But existing
code had the issue that it returned negative values from main(),
which was wrong, so should be reworked anyway.
2014-02-17 02:26:22 -05:00
Lennart Poettering 89fffa2735 seccomp: fix build again if libseccomp is missing 2014-02-13 02:25:45 +01:00
Lennart Poettering d3b1c50833 core: add a system-wide SystemCallArchitectures= setting
This is useful to prohibit execution of non-native processes on systems,
for example 32bit binaries on 64bit systems, this lowering the attack
service on incorrect syscall and ioctl 32→64bit mappings.
2014-02-13 01:40:50 +01:00
Zbigniew Jędrzejewski-Szmek d450b6f2a9 manager: add systemd.show_status=auto mode
When set to auto, status will shown when the first ephemeral message
is shown (a job has been running for five seconds). Then until the
boot or shutdown ends, status messages will be shown.

No indication about the switch is done: I think it should be clear
for the user that first the cylon eye and the ephemeral messages appear,
and afterwards messages are displayed.

The initial arming of the event source was still wrong, but now should
really be fixed.
2014-01-27 23:17:03 -05:00
Zbigniew Jędrzejewski-Szmek d8160f21fd Improve messages about user mode a bit 2014-01-08 22:15:27 -05:00
Zbigniew Jędrzejewski-Szmek cc3d61683d Remove unused variables 2014-01-05 09:16:15 -05:00
Simon Peeters e3e45d4f82 strv: multiple cleanups
- turn strv_merge into strv_extend_strv.
   appending strv b to the end of strv a instead of creating a new strv
- strv_append: remove in favor of strv_extend and strv_push.
- strv_remove: write slightly more elegant
- strv_remove_prefix: remove unused function
- strv_overlap: use strv_contains
- strv_printf: STRV_FOREACH handles NULL correctly
2014-01-05 09:16:15 -05:00
Zbigniew Jędrzejewski-Szmek ccd06097c7 Use format patterns for usec_t, pid_t, nsec_t, usec_t
It is nicer to predefine patterns using configure time check instead of
using casts everywhere.

Since we do not need to use any flags, include "%" in the format instead
of excluding it like PRI* macros.
2014-01-02 19:45:47 -05:00
Lennart Poettering b8d0ffc21f log: als turn on debug logging in non-PID1 if /proc/cmdline contains "debug" 2013-12-23 17:56:44 +01:00
Kay Sievers b43b8f7a7e do not run kmod-setup in a container 2013-12-19 01:32:55 +01:00