Commit Graph

3046 Commits

Author SHA1 Message Date
Jörg Thalheim ff12a7954c treewide: more portable bash shebangs
As in 2a5fcfae02
and in 3e67e5c992
using /usr/bin/env allows bash to be looked up in PATH
rather than being hard-coded.

As with the previous changes the same arguments apply
- distributions have scripts to rewrite shebangs on installation and
  they know what locations to rely on.
- For tests/compilation we should rather rely on the user to have setup
  there PATH correctly.

In particular this makes testing from git easier on NixOS where do not provide
/bin/bash to improve compose-ability.
2020-03-05 17:27:07 +01:00
Zbigniew Jędrzejewski-Szmek efd58985f6
Merge pull request #15002 from keszybz/sysusers-no-proc
Make systemd-sysusers work if /proc is unavailable
2020-03-03 20:28:02 +01:00
Christian Göttsche fdb0405edd selinux: check return value of string_to_security_class()
This should never happen, but better safe than sorry.
2020-03-03 14:17:52 +01:00
Zbigniew Jędrzejewski-Szmek 6cb356ca9f basic/fs-util: add a version of chmod_and_chown that doesn not use /proc 2020-03-03 11:56:44 +01:00
Zbigniew Jędrzejewski-Szmek aa73f181e9 basic/string-table: avoid crash when table is sparse
Generated _from_string() would crash when invoked on a table with some
holes.
2020-02-27 21:36:58 +01:00
Zbigniew Jędrzejewski-Szmek d7887449e7 basic/selinux-util: expose _cleanup_freecon_ 2020-02-06 22:27:21 +01:00
Chris Down e0e2112f61 cgroup: systemctl: Don't display NULL if protection was set to max
Inside format_bytes, we return NULL if the value is UINT64_MAX. This
makes some kind of sense where this has some other semantic meaning than
being a value, but in this case the value is both a.) not the default
(so we definitely want to display it), and b.) means "infinity" (or
"max" in cgroup terminology).

This patch adds a small wrapper around format_bytes that can be used for
these cases, to avoid the following situation:

    [root@tangsanjiao ~]# cat /sys/fs/cgroup/workload.slice/memory.low
    max
    [root@tangsanjiao ~]# systemctl show workload.slice -p MemoryLow
    MemoryLow=infinity
    [root@tangsanjiao ~]# systemctl status workload.slice | grep low:
	Memory: 14.9G (low: (null))

After the patch:

    [root@tangsanjiao ~]# systemctl status workload.slice | grep low:
	Memory: 15.1G (low: infinity)
2020-02-05 18:32:33 +01:00
Christian Göttsche 074b597dd9 selinux-util: increase log severity
`log_enforcing()` and `log_enforcing_errno()` are only used for important messages, which describe failures in enforced mode.
They are guarded either by `!mac_selinux_use()` or `!label_hnd` checks, where the latter is itself guarded by the former.
Only SELinux enabled systems print these logs.
This helps to configure a system in permissive mode, without getting surprising failures when switching to enforced mode.
2020-02-04 18:11:42 +01:00
Naïm Favier 53e1ba280f
network: add SuppressPrefixLength option to RoutingPolicyRule (#14736)
Closes #14724.
2020-02-03 08:25:48 +09:00
Yu Watanabe 60d0a5098b util: uid_t, gid_t, and pid_t must be 32bit
We already have assert_cc(sizeof(uid_t) == sizeof(uint32_t)) or friends
at various places.
2020-02-02 17:13:08 +01:00
Yu Watanabe 03de302a31 util: add parse_uid_range() helper function 2020-02-02 22:43:38 +09:00
Lennart Poettering 5ee69e144e
Merge pull request #14178 from poettering/journal-namespace
journal: add concept of "journal namespaces"
2020-02-01 11:25:48 +01:00
Yu Watanabe 4af8ab2cab user-util: fix use after free() on error path
Fixes CID#1412356.
2020-01-31 23:23:44 +09:00
Lennart Poettering 839d1b2014 string-util: add brief explanatory comment 2020-01-31 15:01:39 +01:00
Lennart Poettering b1852c48c1 journald: allow running multiple instances of journald
If we do, we operate on a separate set of logs and runtime objects

The namespace is configured via argv[1].

Fixes: #12123

Fixes: #10230 #9519

(These latter two issues ask for slightly different stuff, but the
usecases generally can be solved by running separate instances of
journald now, hence also declaring that as "Fixes:")
2020-01-31 15:01:18 +01:00
Lennart Poettering 47d7ab727c fs-util: make sure we output normalized paths in chase_symlinks()
Let's eat up multiple slashes.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1787089
Replaces: #14687
2020-01-28 22:53:59 +01:00
Lennart Poettering c2595d3b02 fs-util: when calling chase_symlinks() with root path, leave root part unresolved
Previously there was a weird asymmetry: initially we'd resolve the
specified prefix path when chasing symlinks together with the actual
path we were supposed to cover, except when we hit an absolute symlink
where we'd use the root as it was. Let's unify handling here: the prefix
path is never resolved, and always left as it is.

This in particular fixes issues with symlinks in the prefix path, as
that confused the check that made sure we never left the root directory.

Fixes: #14634
Replaces: #14635
2020-01-28 22:53:59 +01:00
Yu Watanabe 0e72e469f8 escape: introduce UNESCAPE_ACCEPT_NUL flag 2020-01-27 18:04:46 +09:00
Yu Watanabe 46dc83440f escape: make cunescape() and cunescape_length() inline 2020-01-27 17:38:41 +09:00
Zbigniew Jędrzejewski-Szmek 5e176a4dee Merge pull request #14368 from poettering/repart 2020-01-23 19:07:02 +01:00
Lennart Poettering c680e4efa8
Merge pull request #14617 from poettering/no-strv-clear
strv: remove strv_clear() and some other minor fixes
2020-01-21 15:08:38 +01:00
Yu Watanabe 680120bb20 virt: do not define vm_from_string() for non-x86 architecture
Fixes #14615.
2020-01-21 13:47:08 +01:00
Lennart Poettering 2e5180d38b strv: get rid of strv_clear()
Let's remove a function of questionnable utility.

strv_clear() frees the items of a string array, but not the array
itself. i.e. it half-drestructs a string array and makes it empty. This
is not too useful an operation since we almost never need to just do
that, we also want to free the whole thing. In fact, strv_clear() is
only used in one of our .c file, and there it appears like unnecessary
optimization, given that for each array with n elements it leaves the
number of free()s we need to at O(n) which is not really an optimization
at all (it goes from n+1 to n, that's all).

Prompted by the discussions on #14605
2020-01-21 10:07:34 +01:00
Lennart Poettering 7e70f2cb0e locale-util: add special glyph Σ 2020-01-20 17:42:03 +01:00
Lennart Poettering 1d2a1a0cb8 locale-util: add block drawing special glyphs 2020-01-20 17:42:03 +01:00
Arian van Putten c7d26acce6 Disable reading SystemdOptions EFI Var when in SecureBoot mode
In SecureBoot mode this is probably not what you want. As your cmdline
is cryptographically signed like when using Type #2 EFI Unified Kernel
Images (https://systemd.io/BOOT_LOADER_SPECIFICATION/) The user's
intention is then that the cmdline should not be modified.  You want to
make sure that the system starts up as exactly specified in the signed
artifact.
2020-01-16 18:46:56 +01:00
Lennart Poettering 42f3b2f975 shared: split out crypt() specific helpers into its own .c/.h in src/shared/
This way we can use libxcrypt specific functionality such as
crypt_gensalt() and thus take benefit of the newer algorithms libxcrypt
implements. (Also adds support for a new env var $SYSTEMD_CRYPT_PREFIX
which may be used to select the hash algorithm to use for libxcrypt.)

Also, let's move the weird crypt.h inclusion into libcrypt.h so that
there's a single place for it.
2020-01-15 15:26:27 +01:00
Lennart Poettering 2ee4b118fa nss-util: add macros for generating getpwent()/getgrent() prototypes
We have similar macros already for getpwuid()/getpwnam(), let's add more
of this.
2020-01-15 15:25:32 +01:00
Zbigniew Jędrzejewski-Szmek 98f44b97bb
Merge pull request #14562 from yuwata/table-strv
introduce TABLE_STRV and use it in networkctl and resolvectl
2020-01-15 13:59:11 +01:00
Yu Watanabe 222a6aace7
Merge pull request #14547 from keszybz/networkctl-matching
networkctl: return error or warning when interfaces are not matched
2020-01-15 11:56:01 +09:00
Yu Watanabe 8b75798d12 strv: introduce strv_compare() 2020-01-15 11:52:40 +09:00
Zbigniew Jędrzejewski-Szmek 191a3f1634 basic/strv: drop flags argument from strv_fnmatch() 2020-01-14 13:10:29 +01:00
Zbigniew Jędrzejewski-Szmek 0ef84b80c5 networkctl: return error or warning when interfaces are not matched
We'd just print nothing and exit with 0. If the user gave an explicit
name, we should fail. If a pattern didn't match, we should at least warn.

$ networkctl status enx54ee75cb1dc0a* --no-pager && echo $?
No interfaces matched.
0

$ networkctl status enx54ee75cb1dc0a --no-pager
Interface "enx54ee75cb1dc0a" not found.
1
2020-01-14 13:09:46 +01:00
Yu Watanabe ab1b472062
Merge pull request #14555 from poettering/table-multine
format-table: proper multi-line support
2020-01-14 06:48:57 +09:00
Lennart Poettering 765d88698f
Merge pull request #14400 from keszybz/alias-check
Alias check rework
2020-01-13 18:03:13 +01:00
Lennart Poettering 04d8507f68
Merge pull request #14381 from keszybz/ifindex-cleanup
Resolve alternative names
2020-01-13 17:57:59 +01:00
Lennart Poettering 200427cf7c
Merge pull request #11199 from dargad/restore-pam-setcred
Restore call to pam_setcred
2020-01-13 17:44:34 +01:00
Lennart Poettering f6857fa601 string-util: add helper for extracting n'th line of a string 2020-01-13 16:37:42 +01:00
Lennart Poettering 8dd6491ef9 string-util: let's add helper for truncating string after a specified number of lines 2020-01-13 16:36:47 +01:00
Dariusz Gadomski 0c5d667932 user-util: Add helper functions for gid lists operations 2020-01-13 10:29:10 +01:00
Zbigniew Jędrzejewski-Szmek d308bb99d2 Resolve alternative ifnames wherever we would resolve an interface name
To keep the names manageable, "ifname_or_ifindex" is replaced by "interface".
2020-01-12 11:24:35 +01:00
Zbigniew Jędrzejewski-Szmek 5c3fa98db6 util-lib: move things that parse ifnames to shared/
In subsequent commits, calls to if_nametoindex() will be replaced by a wrapper
that falls back to alternative name resolution over netlink. netlink support
requires libsystemd (for sd-netlink), and we don't want to add any functions
that require netlink in basic/. So stuff that calls if_nametoindex() for user
supplied interface names, and everything that depends on that, needs to be
moved.
2020-01-11 12:07:28 +01:00
Zbigniew Jędrzejewski-Szmek 955bb7fac3 basic/socket-util: indent for clarity 2020-01-11 12:07:28 +01:00
Zbigniew Jędrzejewski-Szmek 597da51bae tree-wide: make parse_ifindex simply return the index
We don't need a seperate output parameter that is of type int.  glibc() says
that the type is "unsigned", but the kernel thinks it's "int".  And the
"alternative names" interface also uses ints. So let's standarize on ints,
since it's clearly not realisitic to have interface numbers in the upper half
of unsigned int range.
2020-01-11 12:06:08 +01:00
Lennart Poettering 3593fa60f2 path-util: express PATH_IN_SET() through path_strv_contains() 2020-01-09 11:17:47 +01:00
Lennart Poettering 3841fee822 path-util: introduce path_strv_contains() helper
it's like strv_contains() but uses path_equal() rather than streq() to
compare strings.
2020-01-09 11:17:21 +01:00
Zbigniew Jędrzejewski-Szmek 06ae8800d0
Merge pull request #14465 from poettering/setprio-rework
When Nice= is used, clamp to RLIMIT_NICE
2020-01-08 11:06:46 +01:00
Lennart Poettering 983ffdb0bf
Merge pull request #14481 from yuwata/virt-string-table
virt: use string table to detect VM or container
2020-01-07 15:16:31 +01:00
Lennart Poettering 67861acdf3 locale-util: extend comments on unicode glyph use, and drop mdash (that actually was an ndash)
Let's add the actual unicode names of the glyphs we use. Let's also add
in comments what the width expectations of these glyphs are on the
console.

Also, remove the "mdash" definition. First of all it wasn't used, but
what's worse the glyph encoded was actually an "ndash"...

Fixes: #14075
2020-01-07 13:21:22 +01:00
Yu Watanabe 25454a0c34 virt: drop trailing white spaces 2020-01-07 11:50:36 +09:00