Commit Graph

510 Commits

Author SHA1 Message Date
Lennart Poettering ac7ec2883d main: use log_error_errno() at one more place 2018-07-25 12:31:50 +02:00
Lennart Poettering ae0db6f132
Merge pull request #9687 from yuwata/rfe-9662
analyze: several systemd-analyze plot improvements
2018-07-24 09:43:57 +02:00
Yu Watanabe d4ee7bd849 core: serialize/deserialize several timestamps on initrd in different names 2018-07-24 03:45:51 +09:00
Yu Watanabe 7a293242e0 core: normalize ShowStatus 2018-07-23 21:55:26 +09:00
Zsolt Dollenstein 566b7d23eb Add support for opening files for appending
Addresses part of #8983
2018-07-20 03:54:22 -07:00
Chris Lamb 3fe910794b Correct a number of trivial typos. 2018-06-18 22:44:44 +02:00
Lennart Poettering 0c69794138 tree-wide: remove Lennart's copyright lines
These lines are generally out-of-date, incomplete and unnecessary. With
SPDX and git repository much more accurate and fine grained information
about licensing and authorship is available, hence let's drop the
per-file copyright notice. Of course, removing copyright lines of others
is problematic, hence this commit only removes my own lines and leaves
all others untouched. It might be nicer if sooner or later those could
go away too, making git the only and accurate source of authorship
information.
2018-06-14 10:20:20 +02:00
Lennart Poettering 818bf54632 tree-wide: drop 'This file is part of systemd' blurb
This part of the copyright blurb stems from the GPL use recommendations:

https://www.gnu.org/licenses/gpl-howto.en.html

The concept appears to originate in times where version control was per
file, instead of per tree, and was a way to glue the files together.
Ultimately, we nowadays don't live in that world anymore, and this
information is entirely useless anyway, as people are very welcome to
copy these files into any projects they like, and they shouldn't have to
change bits that are part of our copyright header for that.

hence, let's just get rid of this old cruft, and shorten our codebase a
bit.
2018-06-14 10:20:20 +02:00
Lennart Poettering b5752d2352 main: simplify arg_system initialization a bit
For both branches of the if check it's the first line, hence let's just
do it before.
2018-06-13 18:52:27 +02:00
Franck Bui bda7d78ba1 pid1: preserve current value of log target across re-{load,execution}
To make debugging easier, this patches allows one to change the log target and
do reload/reexec without modifying configuration permanently, which makes
debugging easier.

Indeed if one changed the log target at runtime (via the bus or via signals),
the change was lost on the next reload/reexecution.

In order to restore back the default value (set via system.conf, environment
variables or any other means ), the empty string in the "LogTarget" property is
now supported as well as sending SIGTRMIN+26 signal.
2018-06-13 18:52:27 +02:00
Franck Bui a6ecbf836c pid1: preserve current value of log level across re-{load,execution}
To make debugging easier, this patches allows one to change the log level and
do reload/reexec without modifying configuration permanently, which makes
debugging easier.

Indeed if one changed the log max level at runtime (via the bus or via
signals), the change was lost on the next daemon reload/reexecution.

In order to restore the original value back (set via system.conf, environment
variables or any other means), the empty string in the "LogLevel" property is
now supported as well as sending SIGRTMIN+23 signal.
2018-06-13 18:52:27 +02:00
Lennart Poettering 9289045238 main: combine a some if checks
Let's merge a few if blocks that are conditioned out the same way.

No change in behaviour.
2018-06-06 14:39:15 +02:00
Lennart Poettering ef59409ff2 main: use rlimit_free_all() at one more place 2018-06-06 14:39:15 +02:00
Lennart Poettering 5b65ae15d2 core: comment verbosely what the difference betweem set_manager_settings() and set_manager_defaults() is 2018-06-06 14:39:15 +02:00
Lennart Poettering 3130fca5a7 util: add new write_string_filef() helper
This new helper combines asprintf() and write_string_file() in one,
which is useful at various places to shorten the code a bit.
2018-06-06 14:39:15 +02:00
Lennart Poettering 9264cc39ce main: split out reading of /proc/sys/fs/nr_open into its own function
This doesn't really reduce the code size over all, but it does make main.c
shorter and more readable, and that's always a good thing.
2018-06-06 14:39:15 +02:00
Yu Watanabe bbc1acaba0 core: add --dump-bus-properties option to systemd
If systemd is invoked with this option, this dumps all bus properties.
This may be useful for shell completion for `systemctl --property`.
2018-05-28 18:13:19 +09:00
Lennart Poettering d58ad743f9 os-util: add helpers for finding /etc/os-release
Place this new helpers in a new source file os-util.[ch], and move the
existing and related call path_is_os_tree() to it as well.
2018-05-24 17:01:57 +02:00
Lennart Poettering 1a5a177eaf fileio: accept FILE* in addition to path in parse_env_file()
Most our other parsing functions do this, let's do this here too,
internally we accept that anyway. Also, the closely related
load_env_file() and load_env_file_pairs() also do this, so let's be
systematic.
2018-05-24 17:01:57 +02:00
Franck Bui 752bcb770b core: keep the kernel coredump defaults when systemd-coredump is disabled
If systemd-coredump is disabled (at build time), PID1 should keep the
(old) kernel defaults as they are.
2018-05-18 20:37:54 +02:00
Lennart Poettering 4f424df760 core: move config_parse_limit() to the generic conf-parser.[ch]
That way we can use it in nspawn.

Also, while we are at it, let's rename the call config_parse_rlimit(),
i.e. insert the "r", to clarify what kind of limit this is about.
2018-05-17 20:36:52 +02:00
Felipe Sateler 57b7a260c2 core: undo the dependency inversion between unit.h and all unit types 2018-05-15 14:24:34 -04:00
Lennart Poettering 2cb36f7c1e
Merge pull request #8575 from keszybz/non-absolute-paths
Do not require absolute paths in ExecStart and friends
2018-04-17 15:54:10 +02:00
Zbigniew Jędrzejewski-Szmek 4109ede778 core/manager: split out function to verify that unit is loaded and not masked
No functional change.
2018-04-16 16:07:27 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
Files which are installed as-is (any .service and other unit files, .conf
files, .policy files, etc), are left as is. My assumption is that SPDX
identifiers are not yet that well known, so it's better to retain the
extended header to avoid any doubt.

I also kept any copyright lines. We can probably remove them, but it'd nice to
obtain explicit acks from all involved authors before doing that.
2018-04-06 18:58:55 +02:00
Yu Watanabe 1cc6c93a95 tree-wide: use TAKE_PTR() and TAKE_FD() macros 2018-04-05 14:26:26 +09:00
Zbigniew Jędrzejewski-Szmek 56fbd7187a sd-bus: allow description to be set for system/user busses (#8594)
sd_bus_open/sd_bus_open_system/sd_bus_open_user are convenient, but
don't allow the description to be set. After they return, the bus is
is already started, and sd_bus_set_description() fails with -EBUSY.
It would be possible to allow sd_bus_set_description() to update the
description "live", but messages are already emitted from sd_bus_open
functions, so it's better to allow the description to be set in
sd_bus_open/sd_bus_open_system/sd_bus_open_user.

Fixes message like:
Bus n/a: changing state UNSET → OPENING
2018-03-29 16:14:11 +02:00
Zbigniew Jędrzejewski-Szmek 27fe58b77b core/main: preserve return value under valgrind 2018-03-28 10:38:45 +02:00
juergbi 39362f6f7d main: add NoNewPrivileges config option (#8475)
This makes it possible to disable new privileges for the whole system.
2018-03-21 23:41:19 +01:00
Yu Watanabe ee5324aa04 tree-wide: voidify pager_open()
Even if pager_open() fails, in general, we should continue the operations.
All erroneous cases in pager_open() show log message in the function.
So, it is not necessary to check the returned value.
2018-03-19 21:04:02 +09:00
Franck Bui 848e863acc basic/macros: rename noreturn into _noreturn_ (#8456)
"noreturn" is reserved and can be used in other header files we include:

  [   16s] In file included from /usr/include/gcrypt.h:30:0,
  [   16s]                  from ../src/journal/journal-file.h:26,
  [   16s]                  from ../src/journal/journal-vacuum.c:31:
  [   16s] /usr/include/gpg-error.h:1544:46: error: expected ‘,’ or ‘;’ before ‘)’ token
  [   16s]  void gpgrt_log_bug (const char *fmt, ...)    GPGRT_ATTR_NR_PRINTF(1,2);

Here we include grcrypt.h (which in turns include gpg-error.h) *after* we
"noreturn" was defined in macro.h.
2018-03-15 14:23:46 +09:00
Lennart Poettering 30663b6c25
Merge pull request #8199 from keszybz/small-things
Sundry small cleanups
2018-02-19 16:55:10 +01:00
Zbigniew Jędrzejewski-Szmek 56c8d7444a pid1: do not initialize join_controllers by default
We're moving towards unified cgroup hierarchy where this is not necessary.
This makes main.c a bit simpler.
2018-02-19 15:18:54 +01:00
Zbigniew Jędrzejewski-Szmek 9ecdba8cb7 Move config_parse_join_controllers to shared, add test
config_parse_join_controllers would free the destination argument on failure,
which is contrary to our normal style, where failed parsing has no effect.
Moving it to shared also allows a test to be added.
2018-02-19 15:02:13 +01:00
Zbigniew Jędrzejewski-Szmek 444d586333 meson: add -Dmemory-accounting-default=true|false
This makes it easy to set the default for distributions and users which want to
default to off because they primarily use older kernels.
2018-02-15 12:02:41 +01:00
Lennart Poettering e0c46a7364 pid1: turn memory accounting on by default now
After discussions with @htejun it appears it's OK now to enable memory
accounting by default for all units without affecting system performance
too badly. facebook has made good experiences with deploying memory
accounting across their infrastructure.

This hence turns MemoryAccounting= from opt-in to opt-out, similar to
how TasksAccounting= is already handled. The other accounting options
remain off, their performance impact is too big still.
2018-02-09 20:06:33 +01:00
Alan Jenkins cc2b9e6b20 rationalize interface for opening/closing logging
log_open_console() did not switch from stderr to /dev/console, when
"always_reopen_console" was set.  It was necessary to call
log_close_console() first.

By contrast, log_open() did switch between e.g. journald and kmsg according
to the value of "prohibit_ipc".

Let's fix log_open() to respect the values of all the log options, and we
can make log_close_*() private.

Also log_close_console() is changed.  There was some precaution, avoiding
closing the console fd if we are not PID 1.  I think commit 48a601fe made
a little mistake in leaving this in, and it only served to confuse
readers :).

Also I changed systemd-shutdown. Now we have log_set_prohibit_ipc(), let's
use it to clarify that systemd-shutdown is not expected to try and log via
journald (which it is about to kill).  We avoided ever asking it to, but
it's more convenient for the reader if they don't have to think about that.
In that sense, it's similar to using assert() to validate a function's
arguments.
2018-01-27 18:01:51 +00:00
Lennart Poettering d075092f14 pid1: make use of new "prohibit_ipc" logging flag in PID 1
Let's set it initially, and then toggle it only when we know its safe.
2018-01-24 18:22:56 +01:00
Lennart Poettering 6fdb8de42f log: make log_set_upgrade_syslog_to_journal() take effect immediately
This doesn't matter much, and we don't rely on it, but I think it's much
nicer if we log_set_target() and log_set_upgrade_syslog_to_journal() can
be called in either order and have the same effect.
2018-01-24 18:22:56 +01:00
Jan Klötzke 2a12e32efa pid1: add option to disable service watchdogs
Add a "systemd.service_watchdogs=" option to the command line which
disables all service runtime watchdogs and emergency actions.
2018-01-22 18:10:03 +01:00
Zbigniew Jędrzejewski-Szmek d8eb10d61a core: delay logging the taint string until after basic.target is reached (#7935)
This happens to be almost the same moment as when we send READY=1 in the user
instance, but the logic is slightly different, since we log taint when
basic.target is reached in the system manager, but we send the notification
only in the user manager. So add a separate flag for this and propagate it
across reloads.

Fixes #7683.
2018-01-21 21:17:54 +09:00
Zbigniew Jędrzejewski-Szmek a9883559e3
Merge pull request #7846 from poettering/nobody-getenv
some assorted fixes and additions, in particular a way to turn off "nobody" synthesizing on a specific system
2018-01-10 20:18:51 +01:00
Jan Klötzke e73c54b838 shutdown: make kill timeout configurable (#7835)
By default systemd-shutdown will wait for 90s after SIGTERM was sent
for all processes to exit. This is way too long and effectively defeats
an emergency watchdog reboot via "reboot-force" actions. Instead now
use DefaultTimeoutStopSec which is configurable.
2018-01-10 19:00:20 +01:00
Lennart Poettering e557b1a655 util: minor tweaks to disable_core_dumps()
First, let's rename it to disable_coredumps(), as in the rest of our
codebase we spell it "coredump" rather than "core_dump", so let's stick
to that.

However, also log about failures to turn off core dumpling on LOG_DEBUG,
because debug logging is always a good idea.
2018-01-10 18:44:09 +01:00
Jan Klötzke 9ce1759311 tree-wide: introduce disable_core_dumps helper and port existing users
Changes the core_pattern to prevent any core dumps by the kernel. Does
nothing if we're in a container environment as this is system wide
setting.
2018-01-10 10:54:40 +01:00
Lennart Poettering 3046b6db1d
main: don't bother with the return value of invoke_mainloop() (#7802)
We don't use the return value, and we don't have to, as the call already
initializes &ret, which is the one we return as exit code from the
process.

CID#1384230
2018-01-04 12:55:21 +01:00
Zbigniew Jędrzejewski-Szmek 97149f405c core: fix mac_selinux_setup return value check
Introduced in 74da609f0d. CID #1384210.
2018-01-04 11:31:37 +01:00
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