Commit graph

38 commits

Author SHA1 Message Date
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Frantisek Sumsal d7a0f1f4f9 tree-wide: assorted coccinelle fixes 2020-10-09 15:02:23 +02:00
Lennart Poettering ed125c936c analyze-security: check for ProtectProc=/ProcSubset= 2020-08-24 20:11:10 +02:00
Zbigniew Jędrzejewski-Szmek a9134af2e3 analyze-security: include an actual syscall name in the message
This information was already available in the debug output, but I think it
is good to include it in the message in the table. This makes it easier to wrap
one's head around the allowlist/denylist filtering.
2020-08-17 19:48:32 +02:00
Zbigniew Jędrzejewski-Szmek 01ecb3674a analyze-security: do not assign badness to filtered-out syscalls
Fixes #16451, https://bugzilla.redhat.com/show_bug.cgi?id=1856273.
2020-08-01 11:54:26 +02:00
Anita Zhang b5ef66101a analyze: CAP_RAWIO -> CAP_SYS_RAWIO
Fixes #16489
2020-07-16 21:14:59 +02:00
Lennart Poettering 807542bece shared: split out code that maps properties to local structs
Just some refactoring, no code changes.
2020-06-30 15:09:35 +02:00
Lennart Poettering 6b000af4f2 tree-wide: avoid some loaded terms
https://tools.ietf.org/html/draft-knodel-terminology-02
https://lwn.net/Articles/823224/

This gets rid of most but not occasions of these loaded terms:

1. scsi_id and friends are something that is supposed to be removed from
   our tree (see #7594)

2. The test suite defines an API used by the ubuntu CI. We can remove
   this too later, but this needs to be done in sync with the ubuntu CI.

3. In some cases the terms are part of APIs we call or where we expose
   concepts the kernel names the way it names them. (In particular all
   remaining uses of the word "slave" in our codebase are like this,
   it's used by the POSIX PTY layer, by the network subsystem, the mount
   API and the block device subsystem). Getting rid of the term in these
   contexts would mean doing some major fixes of the kernel ABI first.

Regarding the replacements: when whitelist/blacklist is used as noun we
replace with with allow list/deny list, and when used as verb with
allow-list/deny-list.
2020-06-25 09:00:19 +02:00
Zbigniew Jędrzejewski-Szmek be32732168 basic/set: let set_put_strdup() create the set with string hash ops
If we're using a set with _put_strdup(), most of the time we want to use
string hash ops on the set, and free the strings when done. This defines
the appropriate a new string_hash_ops_free structure to automatically free
the keys when removing the set, and makes set_put_strdup() and set_put_strdupv()
instantiate the set with those hash ops.

hashmap_put_strdup() was already doing something similar.

(It is OK to instantiate the set earlier, possibly with a different hash ops
structure. set_put_strdup() will then use the existing set. It is also OK
to call set_free_free() instead of set_free() on a set with
string_hash_ops_free, the effect is the same, we're just overriding the
override of the cleanup function.)

No functional change intended.
2020-05-06 16:54:06 +02:00
Alin Popa ad5555b42e systemd: Fix busctl crash on aarch64 when setting output table format
The enum used for column names is integer type while table_set_display() is parsing
arguments on size_t alignment which may result in assert in table_set_display() if
the size between types missmatch. This patch cast the enums to size_t.
It also fixes all other occurences for table_set_display() and
table_set_sort().
2020-02-16 02:09:26 +09:00
Kevin Kuehler 9f37272a19 analyze: Add ProtectClock= to analyze-security 2020-01-26 12:44:47 -08:00
Wieland Hoffmann 287cf2d802 typo: "May modify to" -> "May modify" 2020-01-18 10:08:27 +01:00
Yu Watanabe 9c46b437fc analyze: optimize table creation by using table_add_many() 2020-01-10 18:28:09 +09:00
Topi Miettinen d909b40fda
analyze: badness if neither of RootImage and RootDirectory exists
Instead of requiring both RootImage and RootDirectory directives, give badness
points if neither is present. Fixes conversion in d737b451f.
2019-12-18 20:38:04 +02:00
Kevin Kuehler 82dce83b19 systemd-analyze: Add ProtectKernelLogs to security 2019-11-15 00:59:54 -08:00
Yu Watanabe f5947a5e92 tree-wide: drop missing.h 2019-10-31 17:57:03 +09:00
Zbigniew Jędrzejewski-Szmek df7c4eb62a various tools: be more explicit when a glob is passed when not supported
See https://bugzilla.redhat.com/show_bug.cgi?id=1763488: when we say that
'foo@*.service' is not a valid unit name, this is not clear enough. Let's
include the name of the operation that does not support globbing in the
error message:

$ build/systemctl enable 'foo@*.service'
Glob pattern passed to enable, but globs are not supported for this.
Invalid unit name "foo@*.service" escaped as "foo@\x2a.service".
...
2019-10-25 13:41:49 +09:00
Johannes Christ 7f024cb211 Fix typo in analyze-security.c. 2019-08-11 06:08:42 +09:00
Jan Synacek 28a06f5abe analyze-security: move assert above first use of the variable (#13238) 2019-07-31 16:13:35 +02:00
Lennart Poettering 2cb434cfc1 analyze: port over one part of systemd-analyze to use new table_add_many() concepts 2019-07-16 12:45:38 +02:00
Kai Lüke fab347489f bpf-firewall: custom BPF programs through IP(Ingress|Egress)FilterPath=
Takes a single /sys/fs/bpf/pinned_prog string as argument, but may be
specified multiple times. An empty assignment resets all previous filters.

Closes https://github.com/systemd/systemd/issues/10227
2019-06-25 09:56:16 +02:00
Sebastian Jennen 1ace223ca7 code style format: clang-format applied to src/a*/*
[zj: this is a subset of changes generated by clang-format, just the ones
  I think improve readability or consistency.]

This is a part of https://github.com/systemd/systemd/pull/11811.
2019-04-12 17:26:33 +02:00
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 d8b4d14df4 util: split out nulstr related stuff to nulstr-util.[ch] 2019-03-14 13:25:52 +01:00
Topi Miettinen 527bd7f185 analyze security: check for ProtectHostname=yes 2019-02-27 16:20:38 +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
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
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 ec16f3b6dd analyze: add new security verb 2018-11-30 16:48:09 +01:00