Commit Graph

265 Commits

Author SHA1 Message Date
Yu Watanabe 33ca308f38
Merge pull request #12188 from poettering/coccinelle-fixlets
tree-wide: let's run coccinelle again
2019-04-03 01:46:54 +09:00
Lennart Poettering 9d880b70ba analyze: check for RestrictSUIDSGID= in "systemd-analyze security"
And let's give it a heigh weight, since it pretty much can be used for
bad things only.
2019-04-02 16:56:48 +02:00
Lennart Poettering d737b451fe analyze: use empty_or_root() where appropriate 2019-04-02 14:53:25 +02:00
Lennart Poettering 196f306795 analyze: check both possible mount points of tracefs
Let's try the new one first, the old one second.
2019-03-29 14:57:37 +01:00
Zbigniew Jędrzejewski-Szmek c6335c3b51
Merge pull request #12115 from poettering/verbose-job-enqueue
add "systemctl --show-transaction start" as a more verbose "systemctl start" that shows enqueued jobs
2019-03-28 11:04:26 +01:00
Lennart Poettering 50cbaba4fe core: add new API for enqueing a job with returning the transaction data 2019-03-27 12:37:37 +01:00
Zbigniew Jędrzejewski-Szmek ca78ad1de9 headers: remove unneeded includes from util.h
This means we need to include many more headers in various files that simply
included util.h before, but it seems cleaner to do it this way.
2019-03-27 11:53:12 +01:00
Zbigniew Jędrzejewski-Szmek 2fffb93b32 analyze: reword explanation in critical-chain header
Let's try to make it a bit clearer.
2019-03-15 10:17:46 +01:00
Lennart Poettering d8b4d14df4 util: split out nulstr related stuff to nulstr-util.[ch] 2019-03-14 13:25:52 +01:00
Lennart Poettering 760877e90c util: split out sorting related calls to new sort-util.[ch] 2019-03-13 12:16:43 +01:00
Topi Miettinen 527bd7f185 analyze security: check for ProtectHostname=yes 2019-02-27 16:20:38 +01:00
Zbigniew Jędrzejewski-Szmek deed4d50a2 analyze: add color highlighting when printing calendar elapses
With multiple iterations, I found it hard to pick out the interesting bits in
the column of text. I tried plain highlighting first, but it doesn't seem
enough. But blue/yellow makes it easy to jump to the right iteration.
2019-02-22 09:32:17 +01:00
Zbigniew Jędrzejewski-Szmek 84653d99fa analyze: split out loop innards into a separate function
This was intended to be just a refactoring, but it also fixes a minor bug:
after printing "never", we would skip subsequent expressions:

$ systemd-analyze calendar --iterations=20 @0 @1
systemd-analyze calendar --iterations=20 @0 @1
  Original form: @0
Normalized form: 1970-01-01 00:00:00 UTC
    Next elapse: never

(the second expression was skipped).
2019-02-22 09:32:17 +01:00
Lennart Poettering f2ccf8320a analyze: optionally, show more than one elapse time for calendar expressions 2019-02-22 09:10:54 +01:00
Zbigniew Jędrzejewski-Szmek f1d9d36ac5 analyze: generalize cat-config to apply to tmpfiles, presets, hwdb.d, etc.
Fixes #10256.

What works:

systemd-analyze cat-config systemd/system-preset
systemd-analyze cat-config systemd/user-preset
systemd-analyze cat-config tmpfiles.d
systemd-analyze cat-config sysusers.d
systemd-analyze cat-config systemd/sleep.conf
systemd-analyze cat-config systemd/user.conf
systemd-analyze cat-config systemd/system.conf
systemd-analyze cat-config udev/udev.conf
(and other .conf files)
systemd-analyze cat-config udev/rules.d
systemd-analyze cat-config environment.d
systemd-analyze cat-config environment

Directories may be specified with the trailing dash or not.

The caveat is that for user configuration, systemd and other tools also look
at ~/.config/. It would be nice to support this, but this patch doesn't.
"cat-config --user" is rejected, and we may allow it in the future and then
extend the search path with directories under ~/.config.

What doesn't work (and probably shouldn't because those files cannot be
meaningfully concatenated):

systemd-analyze cat-config systemd/system  (.service, .slice, .socket, ...)
systemd-analyze cat-config systemd/user
systemd-analyze cat-config systemd/network (.network, .link, and .dnssd)

The hardcoding of information about paths in this manner is a bit ugly, but
OTOH, it is not too onerous, and at least we have one place where all the
schemes are "documented" through code. It'll make us think twice before adding
yet another slightly different scheme.
2019-02-18 10:29:33 +01:00
Zbigniew Jędrzejewski-Szmek c2953e0808 analyze: use SYNTHETIC_ERRNO 2019-02-18 10:29:33 +01:00
Yu Watanabe 95832a0f8c analyze security: fix recursive call of syscall_names_in_filter()
When `syscall_names_in_filter()` is called in itself, it is already
examined with `whitelist`. Or, in other words, `syscall_names_in_filter()`
returns bad or good in boolean. So, the returned value should not be
compared with `whitelist` again.

This replaces #11302.
2019-02-04 16:01:38 +01:00
Topi Miettinen 7ae3561a5a Delete duplicate lines
Found by inspecting results of running this small program:

int main(int argc, const char **argv) {
	for (int i = 1; i < argc; i++) {
		FILE *f;
		char line[1024], prev[1024], *r;
		int lineno;

		prev[0] = '\0';
		lineno = 1;
		f = fopen(argv[i], "r");
		if (!f)
			exit(1);
		do {
			r = fgets(line, sizeof(line), f);
			if (!r)
				break;
			if (strcmp(line, prev) == 0)
				printf("%s:%d: error: dup %s", argv[i], lineno, line);
			lineno++;
			strcpy(prev, line);
		} while (!feof(f));
		fclose(f);
	}
}
2019-01-12 16:02:26 +01:00
Yu Watanabe a92f2af28a
Merge pull request #11230 from keszybz/version-string-alt
Generate version string from git describe (alternative approach)
2019-01-03 21:33:55 +09:00
Zbigniew Jędrzejewski-Szmek 5f9026027d analyze: add assert to verify we are not dividing by 0
CID #1397051.
2018-12-21 16:15:14 +01:00
Zbigniew Jędrzejewski-Szmek 681bd2c524 meson: generate version tag from git
$ build/systemctl --version
systemd 239-3555-g6178cbb5b5
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN +PCRE2 default-hierarchy=hybrid
$ git tag v240 -m 'v240'
$ ninja -C build
ninja: Entering directory `build'
[76/76] Linking target fuzz-unit-file.
$ build/systemctl --version
systemd 240
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN +PCRE2 default-hierarchy=hybrid

This is very useful during development, because a precise version string is
embedded in the build product and displayed during boot, so we don't have to
guess answers for questions like "did I just boot the latest version or the one
from before?".

This change creates an overhead for "noop" builds. On my laptop, 'ninja -C
build' that does nothing goes from 0.1 to 0.5 s. It would be nice to avoid
this, but I think that <1 s is still acceptable.

Fixes #7183.

PACKAGE_VERSION is renamed to GIT_VERSION, to make it obvious that this is the
more dynamically changing version string.

Why save to a file? It would be easy to generate the version tag using
run_command(), but we want to go through a file so that stuff gets rebuilt when
this file changes. If we just defined an variable in meson, ninja wouldn't know
it needs to rebuild things.
2018-12-21 13:43:20 +01:00
Lennart Poettering 9a6f746fb6 locale-util: prefix special glyph enum values with SPECIAL_GLYPH_
This has been irritating me for quite a while: let's prefix these enum
values with a common prefix, like we do for almost all other enums.

No change in behaviour, just some renaming.
2018-12-14 08:22:54 +01:00
Lennart Poettering ee589a1882
Merge pull request #11041 from yuwata/update-missing-v2
missing: separate missing.h more
2018-12-04 16:19:02 +01:00
Zbigniew Jędrzejewski-Szmek 0c630f4bf8
Merge pull request #11037 from poettering/json-table
optionally output tables as JSON
2018-12-04 14:32:10 +01:00
Yu Watanabe 36dd5ffd5d util: drop missing.h from util.h 2018-12-04 10:00:34 +01:00
William A. Kennington III 3a5d89fa82 analyze: Fix if not HAVE_SECCOMP
The new systemd analyze code dependend on routines provided by
libseccomp even if HAVE_SECCOMP is false. This expands the code disabled
in analyze-security to make sure we don't depend on seccomp.
2018-12-04 13:51:59 +09:00
Lennart Poettering 9969b54279 tree-wide: specify all table headers in lower-case 2018-12-03 22:42:38 +01:00
David Malcolm 1e8817b327 analyze: tweak wording of description for ProtectSystem= (#11035) 2018-12-03 21:57:09 +01:00
Lennart Poettering ac20048fc0
Merge pull request #11002 from keszybz/path_join-merging
Path join merging
2018-12-01 00:44:58 +01:00
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
Zbigniew Jędrzejewski-Szmek 62a85ee0a9 tree-wide: rename path_join_many() to path_join()
$ git grep -e path_join_many -l|xargs sed -r -i 's/path_join_many/path_join/g'

The two test functions are merged into one.
2018-11-30 10:59:47 +01:00
Zbigniew Jędrzejewski-Szmek 30016f21b3 tree-wide: replace path_join with path_join_many 2018-11-30 10:40:38 +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 e95a86c79e analyze: update log message 2018-10-20 00:43:02 +09:00
Lennart Poettering 572986ca14 core: log in all cases in manager_startup()
We missed some cases where we'd fail without any logging at all. Let's
fix that.
2018-10-09 19:43:43 +02:00