Commit graph

463 commits

Author SHA1 Message Date
Lennart Poettering a45d7127e7 tree-wide: use EXIT_SUCCESS/EXIT_FAILURE in exit() where we can 2017-12-25 11:48:21 +01:00
Lennart Poettering d72a8f10b6 main: add some more comments for the early initialization phase 2017-12-15 20:52:28 +01:00
Lennart Poettering 625e8690ab main: reorder variable declarations a bit
Let's remove a bit redundancy, and list variables of the same
type/category in one declaration line.
2017-12-15 20:52:28 +01:00
Lennart Poettering aa40ff0703 main: split out 'skip_setup' check into its own functions
And let's optimize it a tiny bit, by only iterating through the argument
list once, instead of twice.
2017-12-15 20:52:28 +01:00
Lennart Poettering b9e90f3aa6 main: do bother with uid_to_name() unless we do debug logging 2017-12-15 20:52:28 +01:00
Lennart Poettering 43db615ba4 main: conditionalize fixup_environment() internally
This code is executed before we parse command line/configuration
parameters, hence let's not use arg_system to figure our how to clean up
things, but instead PID == 1. Let's move that check inside of the
function, to make things a bit more robust abstract from the outside.

Also, let's add a log message about this, that was so far missing.
2017-12-15 20:52:28 +01:00
Lennart Poettering 2d77603838 main: let's move ACTION_RUN test into initialize_runtime()
Let's hide this check inside the function and make it easier to follow
the general control flow of main().
2017-12-15 20:52:28 +01:00
Lennart Poettering 3a671cd130 main: tweak timerslack message a bit
Let's clarify that this is a non-issue, by downgrading it to LOG_WARN
and saying "ignoring" in the message.
2017-12-15 20:52:28 +01:00
Lennart Poettering 3c3c6cb95d main: move install_crash_handler() and mount_cgroup_controllers() invocations
Let's place them in initialize_runtime(), where they appear to fit best.
Effectively this is just a move a little bit down, swapping places with
log_execution_mode(), which should require neither call to be done
first.

Note that changes the conditionalization a bit for these calls, from
(PID == 1) to (arg_system && arg_action == ACTION_RUN). At this point this is pretty much the same
however, as we don't allow PID 1 without ACTION_RUN and without
arg_system set, safety_checks() ensures that.
2017-12-15 20:52:28 +01:00
Lennart Poettering db33214b52 core: move arg_show_status fix-up into load_configuration()
It's part of finalizing our runtime parameters, hence let's move this
into load_configuration() after we loaded everything else. This is safe,
since we don't use it between the location where it was and where we
place it now yet.
2017-12-15 20:52:28 +01:00
Lennart Poettering 2e51b31caf main: split out code that sets up the console/terminal and stuff
More refactoring to make main() more digestable.
2017-12-15 20:52:28 +01:00
Lennart Poettering efeb853fbd main: split out code that collects passed fds
More refactoring to make main() more digestable
2017-12-15 20:52:28 +01:00
Lennart Poettering 72c7329b6e main: slight modernizations for status_welcome()
There's no point in duplicating the complex parse_env_file() invocation,
hence let's not do it.
2017-12-15 20:52:28 +01:00
Lennart Poettering fd8c85c652 main: let's move the arg_show_status check into status_welcome()
It's kinda nice to hide this check inside of status_welcome() itself, so
that it handles all this on its own.
2017-12-15 20:52:28 +01:00
Lennart Poettering a70c72a046 main: slightly rearrange serialization fdset, and logging/console setup
Let's merge two if blocks, and move log_close()/log_open() out of the
testing codepath, as there's no reason to have it there.
2017-12-15 20:52:28 +01:00
Lennart Poettering 5a2e0c6257 main: move chdir("/") a bit earlier
There's no need to do this within the block where logging is closed,
hence move it earlier, so that this block can be kept as small as
possible.
2017-12-15 20:52:28 +01:00
Lennart Poettering 6f101b566f main: move initialize_join_controllers() invocation into load_configuration()
This just sets up some variables the loaded configuration will then
modify. Let's invoke it hence right before loading the configuration.

This moves the initialization just a tiny bit later, but that shouldn't
matter, since we never access it in-between.
2017-12-15 20:52:28 +01:00
Lennart Poettering 51e5ff02a8 main: split out taint string logging into its own function
It's sufficiently complex now, let's add our own function for this too.
2017-12-15 20:52:28 +01:00
Lennart Poettering febf46a46c core: add more safety check
Let's make sure that if we are PID 1 we are invoked in ACTION_RUN mode,
and in arg_system mode, as well as the opposite.

Everything else is untested and probably not worth supporting hence
let's bail out early if people try anyway.
2017-12-15 20:52:28 +01:00
Lennart Poettering 263162da6c core: split out test summary output into its own function
More refactoring to make main() shorter.
2017-12-15 20:52:28 +01:00
Lennart Poettering 74da609f0d main: split out security policy loading into its own function
More refactoring to make things more digestable.
2017-12-15 20:52:28 +01:00
Lennart Poettering 5625c18a47 main: invoke pager_open() only at one place
Let's just move this up a few lines and unify the invocation.
2017-12-15 20:52:28 +01:00
Lennart Poettering b0d7c98993 core: split out various startup safety checks from main() into its own function
No functional changes, just some refactoring to make main() more
digestable.
2017-12-15 20:52:28 +01:00
Lennart Poettering 97d1fb94ba main: split out all parsing of command line arguments/kernel arguments/configuration files
Let's shorten main() a bit, and split out everything that loads our
configuration and runtime parameters into a function of its own.

No changes in behaviour.
2017-12-15 20:52:28 +01:00
Lennart Poettering 4dc63c4bc7 main: minor optimization
Let's remove one memory allocation in the common path.
2017-12-15 20:52:28 +01:00
Zbigniew Jędrzejewski-Szmek b2e7486cc7 Make taint message structured and add catalog entry
Dec 14 14:10:54 krowka systemd[1]: System is tainted: overflowgid-not-65534
-- Subject: The system is configured in a way that might cause problems
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The following "tags" are possible:
-- - "split-usr" — /usr is a separate file system and was not mounted when systemd
--   was booted
-- - "cgroups-missing" — the kernel was compiled without cgroup support or access
--   to expected interface files is resticted
-- - "var-run-bad" — /var/run is not a symlink to /run
-- - "overflowuid-not-65534" — the kernel user ID used for "unknown" users (with
--   NFS or user namespaces) is not 65534
-- - "overflowgid-not-65534" — the kernel group ID used for "unknown" users (with
--   NFS or user namespaces) is not 65534
-- Current system is tagged as overflowgid-not-65534.
2017-12-14 22:14:38 +01:00
Lennart Poettering 234519ae6d tree-wide: drop a few == NULL and != NULL comparison
Our CODING_STYLE suggests not comparing with NULL, but relying on C's
downgrade-to-bool feature for that. Fix up some code to match these
guidelines. (This is not comprehensive, the coccinelle output for this
is unfortunately kinda borked)
2017-12-11 16:05:40 +01:00
Edward A. James 8a2c1fbfc3 core: Add WatchdogDevice config option and implement it
This option allows a device path to be specified for the systemd
watchdog (both runtime and shutdown).

If a system requires a watchdog other than /dev/watchdog (pointing to
/dev/watchdog0) to be used to reboot the system, this setting should be
changed to the relevant watchdog device path (e.g. /dev/watchdog1).
2017-12-08 11:26:44 -06:00
Lennart Poettering cefb3eda60 core: add console error message if manager_startup() fails 2017-12-07 11:28:00 +01:00
Lennart Poettering af6b0ecc4c core: make "taint" string logic a bit more generic and output it at boot
The tainting logic existed for a long time, but was hidden inside the
bus interfaces. Let's give it a small bit more coverage, by logging its
value early at boot during initialization.
2017-12-07 11:27:07 +01:00
Lennart Poettering 31aef7ff2b core: split out execution context logging from main()
Again, no functional changes, let's just shorten main() a bit, by
splitting out more code into a separate functions.
2017-12-06 21:57:35 +01:00
Lennart Poettering 6c78f016d7 core: move write_container_id() invocation into initialize_runtime()
This moves the invocation a bit later, but that shoudln't matter. By
moving it we gain two things: first of all, its closer to other code
where it belongs, secondly its naturally conditioned properly, as we no
longer will rewrite the container ID file on every reexecution again,
and not in test mode either.
2017-12-06 21:57:35 +01:00
Lennart Poettering 5afbaa36f4 core: split out various system/process initialization steps into its own function
Again, no changes in behaviour, just some refactoring to make main() a
bit more digestable.
2017-12-06 21:57:35 +01:00
Lennart Poettering 970777b59a core: split out code that frees arg_xyz variables
No change in behaviour, just some refactoring to shorten main() a bit.
2017-12-06 21:57:35 +01:00
Lennart Poettering 6acca5fcd1 core: split out code that queues default job from main()
No functional changes really, just some refactoring to shorten main() a
bit
2017-12-06 21:57:35 +01:00
Lennart Poettering 7eb3504969 core: split out the core loop out of main()
No real functional changes, just some rearranging to shorten the overly
long main() function a bit.

This gets rid of the arm_reboot_watchdog variable, as it can be directly
derived from shutdown_verb, and we need it only one time. By dropping it
we can reduce the number of arguments we need to pass around.
2017-12-06 21:57:35 +01:00
Lennart Poettering 3c7878f94b core: split out reexecution code of main() into its own function
No functional changes, just an attempt to shorten main() a bit.
2017-12-06 21:57:35 +01:00
Zbigniew Jędrzejewski-Szmek d387cfdddd pid1: clarify that min_max is always initialized
read_one_line_file() always returns <= 0, so the code was OK, but let's write
the check a bit differently to make it obvious that min_max is always set.
2017-11-28 09:26:14 +01:00
Zbigniew Jędrzejewski-Szmek bfbcf21d75
Merge pull request #7406 from poettering/timestamp-rework
timestamping rework
2017-11-22 11:55:04 +01:00
Lennart Poettering 9f9f034271 manager: rework the timestamps logic, so that they are an enum-index array
This makes things quite a bit more systematic I think, as we can
systematically operate on all timestamps, for example for the purpose of
serialization/deserialization.

This rework doesn't necessarily make things shorter in the individual
lines, but it does reduce the line count a bit.

(This is useful particularly when we want to add additional timestamps,
for example to solve #7023)
2017-11-21 10:22:28 +01:00
Shawn Landden 4831981d89 tree-wide: adjust fall through comments so that gcc is happy
Distcc removes comments, making the comment silencing
not work.

I know there was a decision against a macro in commit
ec251fe7d5
2017-11-20 13:06:25 -08:00
Lennart Poettering 0133d5553a
Merge pull request #7198 from poettering/stdin-stdout
Add StandardInput=data, StandardInput=file:... and more
2017-11-19 19:49:11 +01:00
Zbigniew Jędrzejewski-Szmek 53e1b68390 Add SPDX license identifiers to source files under the LGPL
This follows what the kernel is doing, c.f.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
2017-11-19 19:08:15 +01:00
Lennart Poettering a68aef7a95 main: uid_to_name() might theoretically fail, handle that 2017-11-17 11:28:17 +01:00
Lennart Poettering 1e41242e11 core: shorten main() a bit, split out coredump initialization
No functional changes.
2017-11-17 11:28:17 +01:00
Lennart Poettering e839bafdf4 main: let's make main() shorter, let's split out clock initialization
no functional changes
2017-11-17 11:28:17 +01:00
Lennart Poettering 4a36297c41 main: let's make main() shorter, let's split out invocation of shutdown binary
No functional changes
2017-11-17 11:28:17 +01:00
Lennart Poettering 6808a0bc80 core: let's shorten main() a bit, let's split out telinit redirection into a separate function 2017-11-17 11:28:17 +01:00
Lennart Poettering 7b46fc6adc main: add set_manager_settings(), similar in style to set_manager_defaults() 2017-11-17 11:28:17 +01:00
Lennart Poettering fd1306121d core: never apply first boot presets in the initrd
Presets are useful to initialize uninitialized /etc, but that doesn't
apply to the initrd.

Also, let's rename etc_empty → first_boot. After all, the variable
doesn't actually reflect whether /etc is really empty, it just reflects
whether /etc/machine-id existed originally or not. Moreover, we later on
directly initialize manager_set_first_boot() from it, hence let's just
name it the same way all through the codepath, to make this all less
confusing.

See: #7100
2017-11-17 11:28:17 +01:00