Commit graph

511 commits

Author SHA1 Message Date
Lennart Poettering 8fcde01280 util-lib: split stat()/statfs()/stavfs() related calls into stat-util.[ch] 2015-10-27 13:25:56 +01:00
Lennart Poettering f4f15635ec util-lib: move a number of fs operations into fs-util.[ch] 2015-10-27 13:25:56 +01:00
Lennart Poettering 78f22b973f util-lib: split out resource limits related calls into rlimit-util.[ch] 2015-10-27 13:25:56 +01:00
Lennart Poettering 5f311f8c0e util: remove path_get_parent(), in favour of dirname_malloc()
We don't need two functions that do essentialy the same, hence drop
path_get_parent(), and stick to dirname_malloc(), but move it to
path-util.[ch].
2015-10-27 13:25:55 +01:00
Lennart Poettering 6bedfcbb29 util-lib: split string parsing related calls from util.[ch] into parse-util.[ch] 2015-10-27 13:25:55 +01:00
Lennart Poettering b1d4f8e154 util-lib: split out user/group/uid/gid calls into user-util.[ch] 2015-10-26 01:24:38 +01:00
Lennart Poettering c004493cde util-lib: split out IO related calls to io-util.[ch] 2015-10-26 01:24:38 +01:00
Lennart Poettering 3ffd4af220 util-lib: split out fd-related operations into fd-util.[ch]
There are more than enough to deserve their own .c file, hence move them
over.
2015-10-25 13:19:18 +01:00
Lennart Poettering 0f03c2a4c0 path-util: unify how we process paths specified on the command line
Let's introduce a common function that makes relative paths absolute and
warns about any errors while doing so.
2015-10-24 23:03:49 +02:00
Lennart Poettering 5b7481633f systemctl: the various list commands actually can take any number of arguments
I accidentally broke this a while back when I ported systemctl to the
verbs logic.

Add support for this back.
2015-10-22 01:59:24 +02:00
Lennart Poettering 7e9d36e06b systemctl: fix how we decode types and states
There was a bad memory access among other smaller issues.
2015-10-01 14:27:20 +02:00
reverendhomer bc6c18fef1 systemctl: fix memory leak in systemctl_parse_argv
This commit fixes Coverity #1325228
2015-10-01 12:09:00 +03:00
Lennart Poettering 32c6d387bf Merge pull request #1422 from keszybz/sd-daemon-mq-badf
sd-daemon: fix return value for sd_is_mq
2015-09-30 22:33:50 +02:00
Lennart Poettering 23a749f285 Merge pull request #1419 from keszybz/shell-completion
Shell completion tweaks
2015-09-30 22:32:09 +02:00
Zbigniew Jędrzejewski-Szmek 7bbb5359c0 systemctl: do not set variable to be immediately overwritten 2015-09-30 12:33:31 -04:00
Lennart Poettering a4420f7b8e systemctl: when reading legacy -t argument for shutdown, don't drop following parameter
We currently completely ignore the following parameter, but we really
should not, as that is actually the time to shut down on.
2015-09-30 12:23:33 +02:00
Lennart Poettering 45519fd630 systemctl: various modernizations 2015-09-30 12:23:32 +02:00
Daniel Mack 5cfee41459 tree-wide: use strempty() where possible
Also add a Coccinell patch to detect such locations in the future.
2015-09-30 11:41:03 +02:00
Lennart Poettering 7f96539d45 systemctl: when a shutdown is scheduled, always go via logind 2015-09-29 21:55:53 +02:00
Lennart Poettering 19578bb26b systemctl: minor modernizations 2015-09-29 21:55:53 +02:00
Lennart Poettering e449de8777 systemctl: port verb dispatching to generic verbs.[ch] code
Let's parse the command line the same way in our various tools.
2015-09-29 21:55:53 +02:00
Lennart Poettering 7089051f67 systemctl: prefer shutting down through logind even as root
Otherwise, wall messages will not be generated for root.
2015-09-29 21:55:53 +02:00
Lennart Poettering 57ab90065d systemctl: split out code invoking SetExitCode() into function of its own 2015-09-29 21:55:53 +02:00
Lennart Poettering 4057e12315 systemctl: don't assert on the arguments array unnecessarily
In most verbs it's fine to treat the arguments array being NULL is empty
array, hence do so.
2015-09-29 21:55:53 +02:00
Lennart Poettering 14b316ebf8 systemctl: make use of strv_skip() where appropriate 2015-09-29 21:55:53 +02:00
Lennart Poettering 691395d84c systemctl: make use of log_error_errno() where we can
Also adds a couple of "return" statements, where they are missing.
2015-09-29 21:55:52 +02:00
Lennart Poettering 4fbd7192c5 systemctl: rework how we connect to busses
Sometimes we have to connect to the system manager directly (early boot,
initrd, late boot, ...), sometimes through the system bus (unprivileged,
remote, logind, ...). Instead of guessing in advance, which kind of
connection we require (and sometimes guessing incorrectly), let's make
sure each time we need  bus connection we request the right bus
explicitly.

This way, we set up exactly the bus connections require, never guess
incorrectly, and do so only immediately when necessary.

As effect this reworks avoid_bus() into install_client_side(), since
that's all it determines now: whether to install unit files client-side
or server-side (i.e. in PID 1).
2015-09-29 21:55:52 +02:00
Lennart Poettering 266f3e269d bus-util: rename bus_open_transport() to bus_connect_transport()
In sd-bus, the sd_bus_open_xyz() family of calls allocates a new bus,
while sd_bus_default_xyz() family tries to reuse the thread's default
bus. bus_open_transport() sometimes internally uses the former,
sometimes the latter family, but suggests it only calls the former via
its name. Hence, let's avoid this confusion, and generically rename the
call to bus_connect_transport().

Similar for all related calls.

And while we are at it, also change cgls + cgtop to do direct systemd
connections where possible, since all they do is talk to systemd itself.
2015-09-29 21:55:52 +02:00
Lennart Poettering 2cc7b0a25f systemctl: rename parse_time_spec() to parse_shutdown_time_spec()
Let's clarify that this function is specific to shutdown time
specifications, nothing else.
2015-09-29 21:55:52 +02:00
Lennart Poettering eca830bee9 systemctl: conditionalize /dev/initctl fallback on HAVE_SYSV_COMPAT 2015-09-29 21:55:52 +02:00
Lennart Poettering 172d7abfea systemctl: allocate arg_wall only on the heap
Previously, we'd allocate it sometimes from the heap, but otherwise let
it point directly int argv[]. Let's clean this up, so that we know
exactly how to release its resources, and do so at the end.
2015-09-29 21:55:52 +02:00
Lennart Poettering fc2ffaf17d systemctl: add 'const' where appropriate 2015-09-29 21:55:52 +02:00
Lennart Poettering 48ec22bc02 systemctl: remove client-side wall message support
logind sends out wall messages now, let's remove this from the systemctl
client side hence. If people build systemd without logind support they
won't get wall messages now, but that's OK.
2015-09-29 21:55:52 +02:00
Lennart Poettering e3ead6bb42 systemctl: move strv_skip_first() out of systemctl.c
Make it generic, call it strv_skip() and move it to strv.[ch]
2015-09-29 21:55:52 +02:00
Lennart Poettering 56a730fa56 systemctl: split out code that schedules shutdowsn into its own function 2015-09-29 21:55:52 +02:00
Lennart Poettering 2cf05793f2 systemctl: rename all logind-specific functions to logind_xyz() 2015-09-29 21:55:52 +02:00
Lennart Poettering 949d9ce954 systemctl: move shutdown cancelling code into its own function
Let's make sure the main switch statement only invokes functions, but
doesn't do anything real on its own.
2015-09-29 21:55:52 +02:00
Lennart Poettering 4f16c1f479 systemctl: don't special case ACTION_RUNLEVEL anymore
Let's move its dispatching to the main switch statement.
2015-09-29 21:55:51 +02:00
Lennart Poettering f2d11d35e9 systemctl: introduce a single function to set the wall message
Let's not have the same code three times, but reduce it to one function.
2015-09-29 21:55:51 +02:00
Lennart Poettering 94f099d813 systemctl: make "systemctl is-system-running" return "offline" if we are not booted with systemd
This sounds like the better place to expose this than in "systemd-notify
--booted".

Also document the so far undocumented "unknown" state the command might
return. And rearrange the table of states documented to be more like the
one for "is-running".

Also, don't document the precise exit code of this function, just say
errors are reported != 0 or > 0...
2015-09-29 21:55:51 +02:00
Lennart Poettering 3f6fd1ba65 util: introduce common version() implementation and use it everywhere
This also allows us to drop build.h from a ton of files, hence do so.
Since we touched the #includes of those files, let's order them properly
according to CODING_STYLE.
2015-09-29 21:08:37 +02:00
Zbigniew Jędrzejewski-Szmek 7e55de3b96 Move all unit states to basic/ and extend systemctl --state=help 2015-09-28 15:09:34 -04:00
Zbigniew Jędrzejewski-Szmek e16972e626 systemctl: add --state=help
This mirrors --type=help and simplifies completion scripts.

The array of states is dense, so the is no need to check if the string is null.
2015-09-28 15:09:34 -04:00
David Herrmann 840cdfcd81 Merge pull request #1334 from poettering/sd-bus-default-flush-close
sd-bus: introduce new sd_bus_default_flush_close() call
2015-09-22 17:33:58 +02:00
Lennart Poettering 1fc464f6fb cgtop: underline table header
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-22 16:30:42 +02:00
Lennart Poettering fa2f8973ad sd-bus: introduce new sd_bus_default_flush_close() call
If code enqueues a message on one of the default busses, but doesn't
sync on it, and immediately drops the reference to the bus again, it
will stay queued and consume memory. Intrdouce a new call
sd_bus_default_flush_close() that can be invoked at the end of programs
(or threads) and flushes out all unsent messages on any of the default
busses.
2015-09-22 16:29:10 +02:00
Alban Crequy 287419c119 containers: systemd exits with non-zero code
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-21 17:32:45 +02:00
Jan Synacek ac5e3a505e core: extend KillUnit() to return error when no unit was killed 2015-09-21 10:05:49 +02:00
Lennart Poettering 3227b2bced Merge pull request #1227 from intelfx/systemctl-legacy-tools-polkit
systemctl: fix various aspects of polkit authorization in legacy tools.
2015-09-10 19:53:31 +02:00
Daniel Mack a18f3caa56 Merge pull request #1239 from poettering/cgroup-pids
core: add support for the "pids" cgroup controller
2015-09-10 19:11:29 +02:00