summaryrefslogtreecommitdiff
path: root/src/core/main.c
AgeCommit message (Collapse)Author
2015-09-24util: refactor cpu_set parsing into its own functionFilipe Brandenburger
Use the new code in config_parse_cpu_affinity2. Tested by modifying CPUAffinity=... setting in /etc/systemd/system.conf and reloading the daemon, then checking ^Cpus_allowed in /proc/1/status to confirm the correct CPU mask is in place.
2015-09-22core: fix shutdown of --userDavid Herrmann
Shutting down a user session currently fails with: Sep 22 22:35:38 david-t2 systemd[640]: Reached target Shutdown. Sep 22 22:35:38 david-t2 systemd[640]: Starting Exit the Session... Sep 22 22:35:38 david-t2 systemd[640]: Received SIGRTMIN+24 from PID 659 (kill). Sep 22 22:35:38 david-t2 systemd[640]: Shutting down. Sep 22 22:35:38 david-t2 systemd[640]: Not executed by init (PID 1). Sep 22 22:35:38 david-t2 systemd[640]: Critical error while doing system shutdown: Operation not permitted This is a regression from: commit 287419c119ef961db487a281162ab037eba70c61 Author: Alban Crequy <alban.crequy@gmail.com> Date: Fri Sep 18 13:37:34 2015 +0200 containers: systemd exits with non-zero code Make sure we never ever execute systemd-shutdown from within a user-manager. Restore the previous behavior by partially reverting given commit.
2015-09-22cgtop: underline table headerLennart Poettering
Let's underline the header line of the table shown by cgtop, how it is customary for tables. In order to do this, let's introduce new ANSI underline macros, and clean up the existing ones as side effect.
2015-09-21containers: systemd exits with non-zero codeAlban Crequy
When a systemd service running in a container exits with a non-zero code, it can be useful to terminate the container immediately and get the exit code back to the host, when systemd-nspawn returns. This was not possible to do. This patch adds the following to make it possible: - Add a read-only "ExitCode" property on PID 1's "Manager" bus object. By default, it is 0 so the behaviour stays the same as previously. - Add a method "SetExitCode" on the same object. The method fails when called on baremetal: it is only allowed in containers or in user session. - Add support in systemctl to call "systemctl exit 42". It reuses the existing code for user session. - Add exit.target and systemd-exit.service to the system instance. - Change main() to actually call systemd-shutdown to exit() with the correct value. - Add verb 'exit' in systemd-shutdown with parameter --exit-code - Update systemctl manpage. I used the following to test it: | $ sudo rkt --debug --insecure-skip-verify run \ | --mds-register=false --local docker://busybox \ | --exec=/bin/chroot -- /proc/1/root \ | systemctl --force exit 42 | ... | Container rkt-895a0cba-5c66-4fa5-831c-e3f8ddc5810d failed with error code 42. | $ echo $? | 42 Fixes https://github.com/systemd/systemd/issues/1290
2015-09-10core: add support for the "pids" cgroup controllerLennart Poettering
This adds support for the new "pids" cgroup controller of 4.3 kernels. It allows accounting the number of tasks in a cgroup and enforcing limits on it. This adds two new setting TasksAccounting= and TasksMax= to each unit, as well as a gloabl option DefaultTasksAccounting=. This also updated "cgtop" to optionally make use of the new kernel-provided accounting. systemctl has been updated to show the number of tasks for each service if it is available. This patch also adds correct support for undoing memory limits for units using a MemoryLimit=infinity syntax. We do the same for TasksMax= now and hence keep things in sync here.
2015-09-09tree-wide: take benefit of the fact that hashmap_free() returns NULLLennart Poettering
And set_free() too. Another Coccinelle patch.
2015-09-09Merge pull request #1218 from poettering/safe-fcloseDaniel Mack
util: introduce safe_fclose() and port everything over to it
2015-09-09util: introduce safe_fclose() and port everything over to itLennart Poettering
Adds a coccinelle script to port things over automatically.
2015-09-09Merge pull request #1216 from poettering/coccinelle-fixes-2Daniel Mack
Coccinelle fixes 2
2015-09-09tree-wide: update empty-if coccinelle script to cover empty-while and moreLennart Poettering
Let's also clean up single-line while and for blocks.
2015-09-09core: freeze execution if /etc/mtab existsDaniel Mack
The mount monitor that was added to libmount v2.27 requires /etc/mtab to be non-existant. As systemd now uses that functionality, we cannot monitor any mounts anymore, and hence not support .mount units. Systems that have /etc/mtab around as regular file are unsupported by systemd since a long time. This patch makes that condition fatal, so we do not boot up with non-working mount monitor support.
2015-09-09tree-wide: drop {} from one-line if blocksLennart Poettering
Patch via coccinelle.
2015-09-09tree-wide: use coccinelle to patch a lot of code to use mfree()Lennart Poettering
This replaces this: free(p); p = NULL; by this: p = mfree(p); Change generated using coccinelle. Semantic patch is added to the sources.
2015-09-07basic: rework virtualization detection APILennart Poettering
Introduce a proper enum, and don't pass around string ids anymore. This simplifies things quite a bit, and makes virtualization detection more similar to architecture detection.
2015-09-01Merge pull request #1098 from filbranden/cpuaffinity2Lennart Poettering
Getting rid of FOREACH_WORD_QUOTED and some more cleanup in config_parse_cpu_affinity2
2015-09-01core: Log parse errors in config_parse_cpu_affinity2Filipe Brandenburger
2015-09-01Merge pull request #1111 from poettering/more-cgroup-fixesTom Gundersen
More cgroup fixes
2015-09-01cgroup: small cleanups and coding style fixesLennart Poettering
A number of simplications and adjustments to brings things closer to our coding style.
2015-09-01core: add OOM check in config_parse_join_controllersFilipe Brandenburger
2015-09-01core: Log parse errors in config_parse_join_controllersFilipe Brandenburger
2015-08-31core: Use extract_first_word in config_parse_join_controllersFilipe Brandenburger
Related to the TODO item to replace FOREACH_WORD_QUOTED with it. Tested by setting `JoinControllers=cpu,cpuacct,memory net_cls,blkio' in /etc/systemd/system.conf, rebooting the system with the patched binaries and checking that the desired setup was created by inspecting the entries under /sys/fs/cgroup. No regressions observed in test cases.
2015-08-31util: Declare a cleanup routine for a cpu_set_tFilipe Brandenburger
Make use of it in config_parse_cpu_affinity2. Tested by tweaking the `CPUAffinity' setting in /etc/systemd/system.conf and reloading the daemon to confirm it is working as expected. No regressions observed in test cases.
2015-08-31core: Use extract_first_word in config_parse_cpu_affinity2Filipe Brandenburger
Related to the TODO item to replace FOREACH_WORD_QUOTED with it. Tested by setting `CPUAfinity=0 1' (and other similar settings) in /etc/systemd/system.conf, booting the system with the patched binaries (and also using `systemctl daemon-reload` to reconfigure) and checking that /proc/1/status indicates only CPUs 0 and 1 are allowed for PID 1. No regressions observed in test cases.
2015-08-31core: use DUAL_TIMESTAMP_NULL where we canLennart Poettering
2015-08-07core: s/reexection/reexecution/ typo fixJan Pokorný
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2015-07-31tree-wide: introduce mfree()David Herrmann
Pretty trivial helper which wraps free() but returns NULL, so we can simplify this: free(foobar); foobar = NULL; to this: foobar = mfree(foobar);
2015-07-09Reload manager defaults at daemon-reloadThomas Blume
"systemctl daemon-reload" should also update the manager defaults from /etc/systemd/system.conf. For details, see: http://lists.freedesktop.org/archives/systemd-devel/2015-June/033062.html Amended to use manager_set_defaults() as common function.
2015-07-06fileio: consolidate write_string_file*()Daniel Mack
Merge write_string_file(), write_string_file_no_create() and write_string_file_atomic() into write_string_file() and provide a flags mask that allows combinations of atomic writing, newline appending and automatic file creation. Change all users accordingly.
2015-06-30core: handle --log-target=null when calling systemd-shutdownIago López Galeiras
When shutting down, if systemd was started with --log-target=null, systemd-shutdown was being called with --log-target=console.
2015-06-10tree-wide: whenever we fork off a foreign child process reset signal ↵Lennart Poettering
mask/handlers Also, when the child is potentially long-running make sure to set a death signal. Also, ignore the result of the reset operations explicitly by casting them to (void).
2015-06-05core: Remove "old kernel" warning if PR_SET_CHILD_SUBREAPER failsCristian Rodríguez
This made sense when systemd ran on older kernels, nowdays not so much.
2015-05-29util: split out signal-util.[ch] from util.[ch]Lennart Poettering
No functional changes.
2015-05-27fix extraneous space in equality checkJonathan Boulle
2015-05-15core: Execute first boot presets in an enable-only preset-mode.Dimitri John Ledkov
This means any existing enabled units well be preserved and no pre-created symlinks will be removed. This is done on first boot, when the assumption is that /etc is not populated at all (no machine-id setup). For minimal containers that gives a significant first boot speed up, approximately ~20ms / ~16% in my trials.
2015-05-11core: rename SystemdRunningAs to ManagerRunningAsLennart Poettering
It's primarily just a property of the Manager object after all, and we try to refer to PID 1 as "manager" instead of "systemd", hence let's to stick to this here too.
2015-05-11core,network: major per-object logging reworkLennart Poettering
This changes log_unit_info() (and friends) to take a real Unit* object insted of just a unit name as parameter. The call will now prefix all logged messages with the unit name, thus allowing the unit name to be dropped from the various passed romat strings, simplifying invocations drastically, and unifying log output across messages. Also, UNIT= vs. USER_UNIT= is now derived from the Manager object attached to the Unit object, instead of getpid(). This has the benefit of correcting the field for --test runs. Also contains a couple of other logging improvements: - Drops a couple of strerror() invocations in favour of using %m. - Not only .mount units now warn if a symlinks exist for the mount point already, .automount units do that too, now. - A few invocations of log_struct() that didn't actually pass any additional structured data have been replaced by simpler invocations of log_unit_info() and friends. - For structured data a new LOG_UNIT_MESSAGE() macro has been added, that works like LOG_MESSAGE() but prefixes the message with the unit name. Similar, there's now LOG_LINK_MESSAGE() and LOG_NETDEV_MESSAGE(). - For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(), LOG_NETDEV_INTERFACE() macros have been added that generate the necessary per object fields. The old log_unit_struct() call has been removed in favour of these new macros used in raw log_struct() invocations. In addition to removing one more function call this allows generated structured log messages that contain two object fields, as necessary for example for network interfaces that are joined into another network interface, and whose messages shall be indexed by both. - The LOG_ERRNO() macro has been removed, in favour of log_struct_errno(). The latter has the benefit of ensuring that %m in format strings is properly resolved to the specified error number. - A number of logging messages have been converted to use log_unit_info() instead of log_info() - The client code in sysv-generator no longer #includes core code from src/core/. - log_unit_full_errno() has been removed, log_unit_full() instead takes an errno now, too. - log_unit_info(), log_link_info(), log_netdev_info() and friends, now avoid double evaluation of their parameters
2015-05-11treewide: Correct typos and spell plural of bus consistentTorstein Husebø
2015-04-11shared: add terminal-util.[ch]Ronny Chevalier
2015-04-10shared: add process-util.[ch]Ronny Chevalier
2015-04-10shared: add formats-util.hRonny Chevalier
2015-03-16core: Remove explicit Plymouth integrationJasper St. Pierre
Even if plymouth is running, it might have not displayed the splash yet, so we'll see a few lines on fbcon when we should have otherwise had nothing. Plymouth integration was added to systemd in commit 6faa11140bf776cdaeb8d22d01816e6e48296971. That same day, Plymouth got systemd integration [0]. As such, the Plymouth integration has always been obsolete, and was probably only for older Plymouth's. But I can't imagine anybody running a Plymouth from 2011 with a systemd from 2015. Remove the Plymouth/systemd integration, and let Plymouth's code tell systemd to print the details. [0] http://cgit.freedesktop.org/plymouth/commit/?id=537c16422cd49f1beeaab1ad39846a00018faec1 Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net> Cc: Daniel Drake <dsd@endlessm.com> Cc: Ray Strode <rstrode@redhat.com>
2015-03-15Add (void) where we don't care about return valueZbigniew Jędrzejewski-Szmek
2015-03-14core: do not use quotes around virt and archZbigniew Jędrzejewski-Szmek
Quotes are useful when the string can contain spaces or be otherwise confusing. Not possible with those two.
2015-02-23remove unused includesThomas Hindoe Paaboel Andersen
This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
2015-02-18everywhere: remove configurability of sysv runlevel to target mappingLennart Poettering
With this change runlevel 2, 3, 4 are mapped to multi-user.target for good, and 5 to graphical.target. This was already the previous mapping but is now no longer reconfigurable, but hard-coded into the core. This should generally simplify things, but also fix one bug: the sysv-generator previously generated symlinks to runlevel[2-5].target units, which possibly weren't picked up if these aliases were otherwise only referenced by the real names "multi-user.target" and "graphical.target". We keep compat aliases "runlevel[2345].target" arround for cases where this target name is explicitly requested.
2015-02-12core: disarm shutdown watchdog if we fail to set timeoutLennart Poettering
Better safe than sorry, if drivers are stupid, and reset immediately on device closing if the timeout could not be initialized. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=777735
2015-02-04core: don't reset log level to NOTICE if we get quiet on the kernel cmdlineLennart Poettering
quiet should really just have an effect on the stuff we dump on the console, not what we log elsewhere. Hence: debug on kernel cmdline → interpreted by every tool, turns up log levels to "debug" everywhere. quiet on kernel cmdline → interpreted only by PID 1 (and obviously the kernel) no alteration of the max log level, but turns off status output. http://lists.freedesktop.org/archives/systemd-devel/2014-December/026271.html
2015-02-03core: use some nice macros where appropriateLennart Poettering
2015-02-01Add a snprinf wrapper which checks that the buffer was big enoughZbigniew Jędrzejewski-Szmek
If we scale our buffer to be wide enough for the format string, we should expect that the calculation was correct. char_array_0() invocations are removed, since snprintf nul-terminates the output in any case. A similar wrapper is used for strftime calls, but only in timedatectl.c.
2015-01-30core: make setting the shutdown watchdog configuration via dbus workMaxim Mikityanskiy
https://bugs.freedesktop.org/show_bug.cgi?id=88284