Commit graph

165 commits

Author SHA1 Message Date
Lennart Poettering ec16f3b6dd analyze: add new security verb 2018-11-30 16:48:09 +01:00
Lennart Poettering 2987225ce6 analyze: use strv_skip() where appropriate 2018-11-30 16:46:09 +01:00
Lennart Poettering 0ed3da7c8c analyze: remove unnecessary negation of bus_error_message() error number parameter 2018-11-30 16:46:09 +01:00
Lennart Poettering 90bea7448d analyze: fix include order 2018-11-30 16:46:09 +01:00
Michal Koutný d3340e6f95 analyze: Fix build without seccomp (#10899) 2018-11-24 02:40:32 +09:00
Zbigniew Jędrzejewski-Szmek baaa35ad70 coccinelle: make use of SYNTHETIC_ERRNO
Ideally, coccinelle would strip unnecessary braces too. But I do not see any
option in coccinelle for this, so instead, I edited the patch text using
search&replace to remove the braces. Unfortunately this is not fully automatic,
in particular it didn't deal well with if-else-if-else blocks and ifdefs, so
there is an increased likelikehood be some bugs in such spots.

I also removed part of the patch that coccinelle generated for udev, where we
returns -1 for failure. This should be fixed independently.
2018-11-22 10:54:38 +01:00
Zbigniew Jędrzejewski-Szmek 294bf0c34a Split out pretty-print.c and move pager.c and main-func.h to shared/
This is high-level functionality, and fits better in shared/ (which is for
our executables), than in basic/ (which is also for libraries).
2018-11-20 18:40:02 +01:00
Yu Watanabe d665c7b2db analyze: use static destructors 2018-11-20 16:48:21 +01:00
Lennart Poettering a9bfb3eff2 analyze: add some minimal ANSI highlighting of syscall-filter output 2018-11-16 16:10:57 +01:00
Lennart Poettering cdf6258c2e analyze: show list of syscalls the kernel supports but not included in any group in the output
This is quite useful for making sure our list is complete.
2018-11-16 16:10:57 +01:00
Lennart Poettering 042cad5737
Merge pull request #10753 from keszybz/pager-no-interrupt
Add mode in journalctl where ^C is handled by the pager
2018-11-14 20:09:39 +01:00
Zbigniew Jędrzejewski-Szmek 0221d68a13 basic/pager: convert the pager options to a flags argument
Pretty much everything uses just the first argument, and this doesn't make this
common pattern more complicated, but makes it simpler to pass multiple options.
2018-11-14 16:25:11 +01:00
Yu Watanabe 20a51f6a26 id128,analyze: fix layout of help message 2018-11-10 11:58:50 +01:00
Chris Down 3f1c1287a9 analyze: Add "timespan" command to dump time span in usec
This is useful for a couple of cases, I'm mostly interested in case #1:

1. Verifying "reasonable" values in a trivially scriptable way
2. Debugging unexpected time span parsing directly

Test Plan:

```
% build/systemd-analyze timespan 20
Original: 20
      μs: 20
   Human: 20us
% build/systemd-analyze timespan 20ms
Original: 20ms
      μs: 20000
   Human: 20ms
% build/systemd-analyze timespan 20z
Failed to parse time span '20z': Invalid argument
```
2018-10-23 14:26:51 +02:00
Lennart Poettering 41159592f8
Merge pull request #10470 from yuwata/log-message-updates
Log message updates
2018-10-19 22:58:53 +02:00
Yu Watanabe 14cb109d45 tree-wide: replace 'unsigned int' with 'unsigned' 2018-10-19 22:19:12 +02:00
Yu Watanabe 0c7539634f analyze: include error cause in the log message 2018-10-20 00:46:33 +09:00
Yu Watanabe 93bab28895 tree-wide: use typesafe_qsort() 2018-09-19 08:02:52 +09:00
Zbigniew Jędrzejewski-Szmek b5d6f7ead6 analyze: use temporary var to simplify code 2018-08-23 11:30:57 +02:00
Zbigniew Jędrzejewski-Szmek a9e241dcb3
Merge pull request #9801 from yuwata/analyze-cleanups
analyze: several improvements
2018-08-20 13:12:53 +02:00
Lennart Poettering 37ec0fdd34 tree-wide: add clickable man page link to all --help texts
This is a bit like the info link in most of GNU's --help texts, but we
don't do info but man pages, and we make them properly clickable on
terminal supporting that, because awesome.

I think it's generally advisable to link up our (brief) --help texts and
our (more comprehensive) man pages a bit, so this should be an easy and
straight-forward way to do it.
2018-08-20 11:33:04 +02:00
Yu Watanabe 4ae25393f3 tree-wide: shorten error logging a bit
Continuation of 4027f96aa0.
2018-08-07 10:14:33 +09:00
Kirill Marinushkin 02be0ccad2 analyze: fix condition for pretty printing kernel time
On target boards without RTC, `t->kernel_time` is 0 or 1 usec.
`systemd-analyze` reads this value over D-Bus from
`org.freedesktop.systemd1.Manager`, property `KernelTimestamp`.

The issue is: if `t->kernel_time` is 0, `systemd-analyze` does not print
the kernel time:

~~~~
$ systemd-analyze
Startup finished in 1.860s (userspace) = 5.957s
~~~~

This commit fixes the misbehaviour:

~~~~
$ systemd-analyze
Startup finished in 3.866s (kernel) + 2.015s (userspace) = 5.881s
~~~~

Fixes #7721.

v2: fixes one more condition (by Yu Watanabe <watanabe.yu+github@gmail.com>)
v3: fixes one more condition (by Kirill Marinushkin <kmarinushkin@de.adit-jv.com>)
2018-08-06 23:13:53 +09:00
Yu Watanabe eddb5037f1 analyze: set reverse_offset for containerized system 2018-08-06 22:21:05 +09:00
Yu Watanabe 79ecaae47d analyze-plot: do not show the legend for security when --user is specified
systemd of user instance always does not have valid value of
TIMESTAMP_SECURITY_*.
2018-08-06 22:21:05 +09:00
Yu Watanabe cc0eb780bd analyze: use bus_map_all_properties() 2018-08-06 22:21:05 +09:00
Yu Watanabe 97cec9ba5e analyze: use size_t for number of units 2018-08-06 22:21:05 +09:00
Yu Watanabe feb927762e analyze: add a space in pretty boot time string 2018-07-24 03:47:41 +09:00
Yu Watanabe 4f481d76fc analyze: show information from hostnamed in plot even when user mode 2018-07-24 03:47:31 +09:00
Yu Watanabe 8c00656560 analyze: plot initrd related timestamps 2018-07-24 03:47:20 +09:00
Yu Watanabe 7725fc11ba analyze: plot units in initrd
Closes #9662.
2018-07-24 03:34:10 +09:00
Yu Watanabe efe6112dc5 analyze: fix width calculation in plot command 2018-07-20 12:51:31 +02:00
Yu Watanabe e68131526b analyze: actually select longest activated-time of services
Discovered by LGTM.
2018-06-27 14:54:19 +09:00
Lennart Poettering 96b2fb93c5 tree-wide: beautify remaining copyright statements
Let's unify an beautify our remaining copyright statements, with a
unicode ©. This means our copyright statements are now always formatted
the same way. Yay.
2018-06-14 10:20:21 +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
Zbigniew Jędrzejewski-Szmek 5d904a6aaa tree-wide: drop !! casts to booleans
They are not needed, because anything that is non-zero is converted
to true.

C11:
> 6.3.1.2: When any scalar value is converted to _Bool, the result is 0 if the
> value compares equal to 0; otherwise, the result is 1.

https://stackoverflow.com/questions/31551888/casting-int-to-bool-in-c-c
2018-06-13 10:52:40 +02:00
Filipe Brandenburger df560cf6b1 analyze: use _cleanup_ for struct unit_times
This introduces a has_data boolean field in struct unit_files which can
be used to detect the end of the array.

Use a _cleanup_ for struct unit_files in acquire_time_data and its
callers. Code for acquire_time_data is also simplified by replacing
goto's with straight returns.

Tested: By running the commands below, also checking them under valgrind.
  - build/systemd-analyze blame
  - build/systemd-analyze critical-chain
  - build/systemd-analyze plot

Fixes: Coverity finding CID 996464.
2018-06-08 15:46:07 +02:00
David Tardon c0a1bfacfe systemd-analyze: make dump work for large # of units
If there is a large number of units, the size of the generated dump
string can overstep DBus message size limit. So let's pass that string
via a fd.
2018-05-11 08:11:02 -07:00
Lennart Poettering cb91deaf77 terminal-util: add a function that shows a pretty separator line
Follow-up for #8824
2018-05-11 08:15:33 +02:00
Lennart Poettering 81321f51cf
Merge pull request #8824 from keszybz/analyze-show-config
systemd-analyze show-config
2018-05-10 11:14:23 -07:00
Yu Watanabe fb507898a3 bus-util: print a friendly message when PID1 is not systemd
Follow-up for 861f16d267.

Fixes #8913.
2018-05-09 17:07:37 +09:00
Yu Watanabe f7e2933677 analyze: merge acquire_full_bus() and acquire_systemd_bus()
Follow-up for 5c69b31c13.
2018-05-09 17:07:37 +09:00
Zbigniew Jędrzejewski-Szmek 971f6ea551 analyze: allow full paths for cat-config
$ systemd-analyze cat-config systemd/logind.conf
$ systemd-analyze cat-config /etc/systemd/logind.conf
$ systemd-analyze cat-config /usr/lib/systemd/logind.conf
are all equvalent,
$ systemd-analyze cat-config /var/systemd/logind.conf
is an error.
2018-05-07 18:17:36 +02:00
Zbigniew Jędrzejewski-Szmek 2e1ec10a62 analyze: seperate config file groups by underline
When multiple configuration file groups are shown together (e.g.
systemd-analyze cat-config systemd/system.conf systemd/user.conf), it's nice
to separate them visually.

I tried first to write a line of spaces and underline that. This does not look
too good, because the line is too low. Then I tried a block of blue-background
spaces. In this version, there are two lines, one is full of spaces and
underlined, so visually we get an empty line in the middle.

I then tried underlining the last line of the previous file. This does not look
right, unless the line is full width, i.e. unless spaces are written out until
the end of the line. But when those spaces are added, it's not clear if they
were part of the original file or not. Here, the spaces are between groups, so
it seems less likely that somebody will mistake those spaces for part of the
configuration file.
2018-05-07 18:15:29 +02:00
Zbigniew Jędrzejewski-Szmek 46d8646a9f analyze: add --root option for cat-config 2018-04-27 10:06:24 +02:00
Zbigniew Jędrzejewski-Szmek 854a42fb2e analyze: add 'cat-config' verb
This is used as 'systemd-analyze show-config systemd/logind.conf', which
will dump
   /etc/systemd/system/user@.service
   /etc/systemd/system/user@.service.d/*.conf
   /run/systemd/system/user@.service.d/*.conf
   /usr/local/lib/systemd/system/user@.service.d/*.conf
   /usr/lib/systemd/system/user@.service.d/*.conf

The idea is to make it easy to dump the configuration using the same locations
and order that systemd programs use themselves (including masking, in the right
order, etc.). This is the generic variant that works with any configuration
scheme that follows the same general rules:

$ systemd-analyze cat-config systemd/system.conf
$ systemd-analyze cat-config systemd/user.conf
$ systemd-analyze cat-config systemd/logind.conf
$ systemd-analyze cat-config systemd/sleep.conf
$ systemd-analyze cat-config systemd/journald.conf
$ systemd-analyze cat-config systemd/journal-remote.conf
$ systemd-analyze cat-config systemd/journal-upload.conf
$ systemd-analyze cat-config systemd/coredump.conf
$ systemd-analyze cat-config systemd/resolved.conf
$ systemd-analyze cat-config systemd/timesyncd.conf
$ systemd-analyze cat-config udev/udev.conf
2018-04-27 10:06:24 +02:00
Lennart Poettering 8e766630f0 tree-wide: drop redundant _cleanup_ macros (#8810)
This drops a good number of type-specific _cleanup_ macros, and patches
all users to just use the generic ones.

In most recent code we abstained from defining type-specific macros, and
this basically removes all those added already, with the exception of
the really low-level ones.

Having explicit macros for this is not too useful, as the expression
without the extra macro is generally just 2ch wider. We should generally
emphesize generic code, unless there are really good reasons for
specific code, hence let's follow this in this case too.

Note that _cleanup_free_ and similar really low-level, libc'ish, Linux
API'ish macros continue to be defined, only the really high-level OO
ones are dropped. From now on this should really be the rule: for really
low-level stuff, such as memory allocation, fd handling and so one, go
ahead and define explicit per-type macros, but for high-level, specific
program code, just use the generic _cleanup_() macro directly, in order
to keep things simple and as readable as possible for the uninitiated.

Note that before this patch some of the APIs (notable libudev ones) were
already used with the high-level macros at some places and with the
generic _cleanup_ macro at others. With this patch we hence unify on the
latter.
2018-04-25 12:31:45 +02:00
Lennart Poettering 5d13a15b1d tree-wide: drop spurious newlines (#8764)
Double newlines (i.e. one empty lines) are great to structure code. But
let's avoid triple newlines (i.e. two empty lines), quadruple newlines,
quintuple newlines, …, that's just spurious whitespace.

It's an easy way to drop 121 lines of code, and keeps the coding style
of our sources a bit tigther.
2018-04-19 12:13:23 +02:00
Lennart Poettering 4d09e1c8ba
Merge pull request #8676 from keszybz/drop-license-boilerplate
Drop license boilerplate
2018-04-10 14:53:31 +02:00