Commit graph

279 commits

Author SHA1 Message Date
Lennart Poettering 5556b5fe41 core: clean up some confusing regarding SI decimal and IEC binary suffixes for sizes
According to Wikipedia it is customary to specify hardware metrics and
transfer speeds to the basis 1000 (SI decimal), while software metrics
and physical volatile memory (RAM) sizes to the basis 1024 (IEC binary).
So far we specified everything in IEC, let's fix that and be more
true to what's otherwise customary. Since we don't want to parse "Mi"
instead of "M" we document each time what the context used is.
2014-02-23 03:19:04 +01:00
Daniel Mack 9e82ffa040 systemctl: fix compiler warning in list_timers()
get_next_elapse() will always fill 'next' with values when it
returns >= 0. Hence, the compiler is wrong about this warning.
Initialize 'next' nevertheless.

src/systemctl/systemctl.c: In function ‘list_timers’:
src/systemctl/systemctl.c:953:43: warning: ‘next.monotonic’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
                                 converted = nw.realtime - (nw.monotonic - next.monotonic);
                                           ^
In file included from ./src/shared/log.h:30:0,
                 from src/systemctl/systemctl.c:46:
./src/shared/macro.h:137:38: warning: ‘next.realtime’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
                         _a < _b ? _a : _b;      \
                                      ^
src/systemctl/systemctl.c:933:32: note: ‘next.realtime’ was declared here
                 dual_timestamp next;
                                ^
2014-02-21 12:05:38 +01:00
Lennart Poettering 151b9b9662 api: in constructor function calls, always put the returned object pointer first (or second)
Previously the returned object of constructor functions where sometimes
returned as last, sometimes as first and sometimes as second parameter.
Let's clean this up a bit. Here are the new rules:

1. The object the new object is derived from is put first, if there is any

2. The object we are creating will be returned in the next arguments

3. This is followed by any additional arguments

Rationale:

For functions that operate on an object we always put that object first.
Constructors should probably not be too different in this regard. Also,
if the additional parameters might want to use varargs which suggests to
put them last.

Note that this new scheme only applies to constructor functions, not to
all other functions. We do give a lot of freedom for those.

Note that this commit only changes the order of the new functions we
added, for old ones we accept the wrong order and leave it like that.
2014-02-20 00:03:10 +01:00
Maciej Wereski 31d5a60cae systemctl: remove erroneous return in runlevel_parse_argv() 2014-02-19 16:24:16 +01:00
Dave Reisner 5a1aece581 systemctl: fix exit statuses from is-active/is-failed
This was inadvertantly disturbed in e3e0314b when glob support was
added.
2014-02-13 10:14:31 -05:00
Lennart Poettering 57183d117a core: add SystemCallArchitectures= unit setting to allow disabling of non-native
architecture support for system calls

Also, turn system call filter bus properties into complex types instead
of concatenated strings.
2014-02-13 00:24:00 +01:00
Tom Gundersen 36e0e6311b includes: remove duplicate includes
Found by the new check-includes make target.
2014-02-10 13:06:31 +01:00
Lennart Poettering 67d6621059 systemctl: skip native unit file handling if sysv file handling already handled everything
Issue pointed out by Colin Guthrie.
2014-01-20 13:43:57 +01:00
Lennart Poettering ac3efa8ac6 systemctl: introduce new "import-environment" command
This may be used in graphical session start-up scripts to upload
environment variables such as $DISPLAY into the systemd manager easily.
2014-01-15 20:16:20 +01: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
Thomas Hindoe Paaboel Andersen 39602c3905 systemctl: improve readability on failed commands
Not long ago a failed command would print:
"Failed to start something.service: ..."
regardless of whether the command was to start/stop/restart/etc.

With e3e0314 this was improved to print the method used. E.g. for stopping:
"Failed to StopUnit something.service: ..."

This patch matches the method to a more human readable word. E.g:
"Failed to stop something.service: ..."
2014-01-04 12:49:40 +01:00
Thomas Hindoe Paaboel Andersen 984af580b3 systemctl: remove unused variable 2013-12-27 12:04:00 +01:00
Zbigniew Jędrzejewski-Szmek f78e6385dc Use enums to make it obvious what boolean params mean
Suggested-by: Russ Allbery <rra@debian.org>
2013-12-26 15:49:54 -05:00
Zbigniew Jędrzejewski-Szmek e3e0314b56 systemctl: allow globbing in commands which take multiple unit names 2013-12-26 13:24:36 -05:00
Zbigniew Jędrzejewski-Szmek 8d5ba5a946 systemctl: drop uninteresting units immediately
Also properly free memory if list-unit-files --root=... is used.
2013-12-26 11:24:42 -05:00
Zbigniew Jędrzejewski-Szmek b652054662 systemctl: simplify start_unit 2013-12-26 11:24:42 -05:00
Zbigniew Jędrzejewski-Szmek 58684be9a7 systemctl: also color filenames of drop-ins in cat 2013-12-22 18:55:01 -05:00
Lennart Poettering 373d32c9f4 systemctl: fix bad memory access when processing PIDs on the "systemctl status" command line 2013-12-21 05:15:09 +01:00
Zbigniew Jędrzejewski-Szmek a669d6226d systemct: add empty line between units in cat 2013-12-18 23:58:24 -05:00
Zbigniew Jędrzejewski-Szmek c0fdf09885 systemctl: highlight filenames in cat 2013-12-16 23:21:51 -05:00
Zbigniew Jędrzejewski-Szmek c0ea486f6e systemctl: fix return value from cat 2013-12-16 23:21:51 -05:00
Lennart Poettering 999b600390 systemctl: properly initialize and free sd_bus_error in "systemctl cat"
We need to properly initialize all error structs before use and free
them after use.

Also, there's no point in flushing stdout if we output a \n anyway...
2013-12-16 21:06:57 +01:00
Djalal Harouni 815ebc540d systemctl: add the --plain option to the help message 2013-12-14 18:13:24 -05:00
Zbigniew Jędrzejewski-Szmek 04504f93d1 systemctl: fix 'is-enabled' 2013-12-08 19:26:51 -05:00
Zbigniew Jędrzejewski-Szmek d08e75edf9 systemctl: simplify argument parsing 2013-12-08 19:26:51 -05:00
Zbigniew Jędrzejewski-Szmek 4f8f66cb42 Help output spring cleaning
Use [brackets] only for optional elements.
Use <optional> in XML sources.
2013-12-08 19:26:51 -05:00
Thomas Hindoe Paaboel Andersen 4c49ab0e7a systemctl: fix and refactor wait_for_jobs
wait_for_jobs was ignoring the errors from the jobs stored in r.
It would only ever return whether the call to sd_bus_remove_filter
went ok. This patch changes it to return the first job related error
encountered. If a job related error is found, then the result of the
call to sd_bus_remove_filter is ignored.

wait_for_jobs was a bit hard to read so I split it up to avoid
the goto and deep nesting.
2013-12-07 22:39:46 +01:00
Zbigniew Jędrzejewski-Szmek d8fba7c6cc systemctl: allow globbing in list-<whatever> commands
It is nicer to say 'systemctl list-units ssh\*' then to use grep,
because colouring is preserved and it is easier to match just against
the unit name.
2013-12-06 21:29:55 -05:00
Zbigniew Jędrzejewski-Szmek 2b6bf07dd2 Get rid of our reimplementation of basename
The only problem is that libgen.h #defines basename to point to it's
own broken implementation instead of the GNU one. This can be fixed
by #undefining basename.
2013-12-06 21:29:55 -05:00
Thomas Hindoe Paaboel Andersen f433609894 systemctl: check the value from start_unit_one
introduced in f459b6025f
2013-12-06 21:13:46 +01:00
Thomas Hindoe Paaboel Andersen 071066a5e5 systemctl: make an always true assert static
Silences a warning i clang
2013-12-04 22:29:58 +01:00
Thomas Hindoe Paaboel Andersen 4fd944ec82 systemctl: no need to fdopen stdout 2013-12-04 22:29:51 +01:00
Thomas Hindoe Paaboel Andersen f168c27313 trivial coding style clean ups
- Add space between if/for and the opening parentheses
- Place the opening brace on same line as the function (not for  udev)

From the CODING_STYLE
Try to use this:
    void foo() {
    }
instead of this:
    void foo()
    {
    }
2013-12-03 22:27:45 +01:00
Zbigniew Jędrzejewski-Szmek e4c0fbe50c systemctl: do not show SourcePath when FragmentPath cannot be found
Those files can be in a completely deferent format and also
arbitrarily long, and usually contain information about other
stuff. If we ever add SourceLine= or SourceLines= in addition
to SourcePath=, and can show the relevant information only, this
commit can be reverted.
2013-11-30 22:36:08 -05:00
Shawn Landden e93c33d4aa systemctl: add "systemctl cat" 2013-11-30 22:20:20 -05:00
Shawn Landden f74294c1da systemctl: refactor show()
v2, don't leave in unused function
2013-11-30 21:59:53 -05:00
Kay Sievers cc3f2093f6 systemctl: fix enable/disable reply handling 2013-11-26 05:19:39 +01:00
Lennart Poettering 4dc5b821ae systemctl: replace the three job mode options by a single --job-mode= option
Also, expose the new "flush" job mode this way.
2013-11-26 02:26:31 +01:00
Lennart Poettering d2bd639262 systemctl: remove debug log message 2013-11-25 17:40:54 +01:00
Lennart Poettering dbed408b8e systemctl: when status is called without arguments show pager 2013-11-25 17:40:54 +01:00
Lennart Poettering dbc2c080de systemctl: indicate in list-dependencies whether a unit is already running 2013-11-22 19:27:56 +01:00
Lennart Poettering ebcf1f97de bus: rework message handlers to always take an error argument
Message handler callbacks can be simplified drastically if the
dispatcher automatically replies to method calls if errors are returned.

Thus: add an sd_bus_error argument to all message handlers. When we
dispatch a message handler and it returns negative or a set sd_bus_error
we send this as message error back to the client. This means errors
returned by handlers by default are given back to clients instead of
rippling all the way up to the event loop, which is desirable to make
things robust.

As a side-effect we can now easily turn the SELinux checks into normal
function calls, since the method call dispatcher will generate the right
error replies automatically now.

Also, make sure we always pass the error structure to all property and
method handlers as last argument to follow the usual style of passing
variables for return values as last argument.
2013-11-21 21:12:36 +01:00
Lennart Poettering 718db96199 core: convert PID 1 to libsystemd-bus
This patch converts PID 1 to libsystemd-bus and thus drops the
dependency on libdbus. The only remaining code using libdbus is a test
case that validates our bus marshalling against libdbus' marshalling,
and this dependency can be turned off.

This patch also adds a couple of things to libsystem-bus, that are
necessary to make the port work:

- Synthesizing of "Disconnected" messages when bus connections are
  severed.

- Support for attaching multiple vtables for the same interface on the
  same path.

This patch also fixes the SetDefaultTarget() and GetDefaultTarget() bus
calls which used an inappropriate signature.

As a side effect we will now generate PropertiesChanged messages which
carry property contents, rather than just invalidation information.
2013-11-20 20:52:36 +01:00
Karel Zak 4561be3a64 Remove duplicate includes 2013-11-18 20:28:55 -05:00
Thomas Hindoe Paaboel Andersen d5d217eae1 remove unused variables 2013-11-18 23:04:16 +01:00
Mantas Mikulėnas 6ce774fd80 systemctl: honor --no-legend in 'list-jobs' 2013-11-14 00:17:23 +10:00
Lennart Poettering c49b30a235 bus: rename sd_bus_send_with_reply_and_block() to sd_bus_call()
The call is one of the most important ones we expose, where we place
major emphasis on. We should make sure to give it a short, memorable
name.
2013-11-12 00:12:43 +01:00
Kay Sievers 1823b86ebf systemctl: warning: ‘r’ may be used uninitialized in this function 2013-11-11 17:18:51 +01:00
Zbigniew Jędrzejewski-Szmek ad83b4c47c systemctl: avoid unitialized access when showing 0 timers 2013-11-11 10:55:51 -05:00
Lennart Poettering cbb76c29cc systemctl: add new "list-timers" command 2013-11-11 15:54:43 +01:00