Commit Graph

4819 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek aecdef08be shared/clean-ipc: improve error message a bit
Failed to enter shared memory directory multipath: Permission denied
→
Failed to enter shared memory directory /dev/shm/multipath: Permission denied

When looking at nested directories, we will print only the final two elements
of the path. That is still more useful than just the last component of the
path. To print the full path, we'd have to allocate the string, and since the
error occurs so very rarely, I think the current best-effort approach is
enough.
2020-10-20 18:06:28 +02:00
Lennart Poettering 67bd5620f6 util: make size macros unsigned
By making them unsigned comparing them with other sizes is less likely
to trigger compiler warnings regarding signed/unsigned comparisons.
After all sizes (i.e. size_t) are generally assumed to be unsigned, so
these should be too.

Prompted-by: https://github.com/systemd/systemd/pull/17345#issuecomment-709402332
2020-10-20 15:51:48 +09:00
Yu Watanabe 0ce8a9d6e5
Merge pull request #16939 from Rahix/robust-first-boot-machine-id
Make ConditionFirstBoot safe against power failures
2020-10-20 14:01:41 +09:00
Yu Watanabe 1586d324bd
Merge pull request #17352 from msekletar/ens-names-fix
udev/net_id: don't generate slot based names if multiple devices might claim the same slot
2020-10-20 13:49:29 +09:00
Yu Watanabe 4b28e50f9e
Merge pull request #17390 from keszybz/logind-notifications-and-links
Fix sd_notify() usage in various daemons and update some documentation links
2020-10-20 13:44:52 +09:00
Michal Sekletár 2c8ec0095e udev/net_id: don't generate slot based names if multiple devices might claim the same slot 2020-10-19 17:55:44 +02:00
Lennart Poettering 43e7dd70bc
Merge pull request #17344 from keszybz/bus-connect-more-logs
Add some debug logs to help diagnose bus connections
2020-10-19 17:39:37 +02:00
Harald Seiler ab763cb2be dissect-image: support "uninitialized" machine-id
If the first boot was aborted, /etc/machine-id might read as
"uninitialized" in some cases.  Add a separate case for this
instead of printing a confusing error message.
2020-10-19 16:28:22 +02:00
Zbigniew Jędrzejewski-Szmek 297fc20dc4 shared/daemon-util: fix notify_on_cleanup()
p itself is never null. Because of this, we would always
call sd_notify() in cleanup, even though the intention was to only
call it if notify_start() was executed.
2020-10-19 15:23:37 +02:00
Lennart Poettering dfc22cb472 bootspec: tweak error message
Clarify that the name of the entry failed validation, not the entry
itself.
2020-10-19 14:22:25 +02:00
Zbigniew Jędrzejewski-Szmek 69c0807432
Merge pull request #15206 from anitazha/systoomd-v0
systemd-oomd
2020-10-15 14:16:52 +02:00
Lennart Poettering b8f736b30e pager: lets check SYSTEMD_PAGERSECURE with secure_getenv()
I can't think of any real vulnerability about this, but it still feels
better to check a variable with "secure" in its name with
secure_getenv() rather than plain getenv().

Paranoia FTW!
2020-10-15 10:54:53 +02:00
Lennart Poettering 84fc961082
Merge pull request #17270 from keszybz/less-secure-mode
Use less in "secure" mode when under sudo
2020-10-14 18:33:10 +02:00
Zbigniew Jędrzejewski-Szmek ab4a88eb92 sd-bus: add custom return code when $XDG_RUNTIME_DIR is not set
We would return ENOENT, which is extremely confusing. Strace is not helpful because
no *file* is actually missing. So let's add some logs at debug level and also use
a custom return code. Let all user-facing utilities print a custom error message
in that case.
2020-10-14 18:28:30 +02:00
Lennart Poettering fc8bc57f6b
Merge pull request #16968 from yuwata/remove-old-device-on-move-event
core, udev: remove old device on move event
2020-10-14 17:49:37 +02:00
Lennart Poettering 6ea0d25c57 seccomp: allowlist close_range() by default in @basic-io 2020-10-14 10:40:06 +02:00
Zbigniew Jędrzejewski-Szmek 0a42426d79 pager: make pager secure when under euid is changed or explicitly requested
The variable is renamed to SYSTEMD_PAGERSECURE (because it's not just about
less now), and we automatically enable secure mode in certain cases, but not
otherwise.

This approach is more nuanced, but should provide a better experience for
users:

- Previusly we would set LESSSECURE=1 and trust the pager to make use of
  it. But this has an effect only on less. We need to not start pagers which
  are insecure when in secure mode. In particular more is like that and is a
  very popular pager.

- We don't enable secure mode always, which means that those other pagers can
  reasonably used.

- We do the right thing by default, but the user has ultimate control by
  setting SYSTEMD_PAGERSECURE.

Fixes #5666.

v2:
- also check $PKEXEC_UID

v3:
- use 'sd_pid_get_owner_uid() != geteuid()' as the condition
2020-10-14 10:04:12 +02:00
Lennart Poettering 656f7f8aa5
Merge pull request #17273 from mrc0mmand/coccinelle-check-for-bad-errno
coccinelle: resolve our own macros to avoid skipping functions
2020-10-12 11:39:25 +02:00
Zbigniew Jędrzejewski-Szmek 092f5d2ed3
Merge pull request #17292 from poettering/idn-dlsym
turn libidn/libidn2 dep into dlopen() one
2020-10-10 16:25:49 +02:00
Lennart Poettering 4917e7c727 shared: make libidn/libdidn2 dependency a dlopen() one 2020-10-09 15:47:09 +02:00
Frantisek Sumsal d46b79bbe0 tree-wide: drop if braces around single line expressions as well 2020-10-09 15:11:55 +02:00
Frantisek Sumsal d7a0f1f4f9 tree-wide: assorted coccinelle fixes 2020-10-09 15:02:23 +02:00
Lennart Poettering e13d96ca2c udev-util: ignore remove events, we care about initialization after all 2020-10-09 13:22:25 +02:00
Lennart Poettering e7bcecf0e4
Merge pull request #17279 from poettering/systemctl-split-up
systemctl: split huge .c file into smaller bits
2020-10-08 10:17:29 +02:00
Anita Zhang 9de5e32136 systemd-oomd: manager/daemon 2020-10-07 17:12:24 -07:00
Anita Zhang 61ff7397d0 systemd-oomd: unit testable helper functions
Helpers used by the systemd-oomd daemon to read/fill in various contexts and
make detection and kill decisions.

i.e. a simplified/less configurable version of
https://github.com/facebookincubator/oomd/tree/master/src/oomd.
2020-10-07 17:12:22 -07:00
Anita Zhang 42b83e8e33 shared: helpers to read pressure stats from cgroups 2020-10-07 16:17:24 -07:00
Anita Zhang e30bbc90c9 core: add varlink call to get cgroup paths of units using ManagedOOM*= 2020-10-07 16:17:23 -07:00
Anita Zhang e8e9227f5c varlink: add server write states to disconnect check
While a server is in the VARLINK_PENDING_METHOD or VARLINK_PENDING_METHOD_MORE
states and its write end is disconnected and it gets a POLLHUP, we
should disconnect since it can't write anymore.

In the case of systemd-oomd disconnecting while pid1 was pending-more, this
condition left pid1 in a state where it started throttling from
continually getting POLLHUP.
2020-10-07 16:17:23 -07:00
Anita Zhang 4d824a4e0b core: add ManagedOOM*= properties to configure systemd-oomd on the unit
This adds the hook ups so it can be read with the usual systemd
utilities. Used in later commits by sytemd-oomd.
2020-10-07 16:17:23 -07:00
Lennart Poettering 4dcc0653b5 systemctl: move compare_unit_info() to bus-unit-util.[ch]
It's an auxiliary function to the UnitInfo structures, and very generic.
Let's hence move it over to the other code operating with UnitInfo, even
if it's not used by code outside of systemctl (yet).
2020-10-07 22:19:37 +02:00
Lennart Poettering e2d839d316 pretty-print: don't abbreviate needlessly in user-facing string 2020-10-07 22:19:33 +02:00
Yu Watanabe bff94a84c2 util: make local_gateways() support RT_VIA and RT_MULTIPATH
Then, `networkctl status` correctly shows gateways.
2020-10-08 02:51:23 +09:00
Lennart Poettering bac0bfc1d0 udev-util: make use of sd-event's NULL callback support 2020-10-07 09:40:12 +02:00
Lennart Poettering 612ebf6c91 pager: set $LESSSECURE whenver we invoke a pager
Some extra safety when invoked via "sudo". With this we address a
genuine design flaw of sudo, and we shouldn't need to deal with this.
But it's still a good idea to disable this surface given how exotic it
is.

Prompted by #5666
2020-10-07 09:23:07 +02:00
Zbigniew Jędrzejewski-Szmek 12bab3579f
Merge pull request #17230 from mrc0mmand/coccinelle_fixes
coccinelle: fix the incorrect transformation/isomorphisms
2020-10-05 08:03:40 +02:00
Daan De Meyer 8e4a44c585
Merge pull request #17239 from ferivoz/typos
Fix typos
2020-10-04 18:19:26 +01:00
Frantisek Sumsal 1d6cc5d0e5 tree-wide: coccinelle fixes 2020-10-04 12:32:21 +02:00
Samanta Navarro 7b121df640 seccomp-util: fix typo in help message 2020-10-03 11:56:40 +00:00
Lennart Poettering 781fa474d8 ptyfwd: reopen stdin/sdout before setting O_NONBLOCK
If we set O_NONBLOCK on stdin/stdout directly this means the flag is
left set when we abort abnormally, as we don't get the chance to reset
it again on exit. This might confuse progrms invoking us. Moreover, if
programs invoking us continue to write to the stdout passed to us, they
might be confused by non-blocking mode too.

Hence, let's avoid this if possible: let's reopen stdin/stdout and set
O_NONBLOCK only on the reopend fds, leaving the original fds as they
are.

Prompted-by: https://github.com/systemd/systemd/pull/17070#issuecomment-702304802
2020-10-02 12:04:20 +02:00
Lennart Poettering c14ebe07a9
Merge pull request #17172 from keszybz/read-login-defs
Read /etc/login.defs
2020-10-02 11:01:30 +02:00
Zbigniew Jędrzejewski-Szmek aa25270cb2 sysusers: look at login.defs when setting the default range to allocate users
Also, even if login.defs are not present, don't start allocating at 1, but at
SYSTEM_UID_MIN.

Fixes #9769.

The test is adjusted. Actually, it was busted before, because sysusers would
never use SYSTEM_GID_MIN, so if SYSTEM_GID_MIN was different than
SYSTEM_UID_MIN, the tests would fail. On all "normal" systems the two are
equal, so we didn't notice. Since sysusers now always uses the minimum of the
two, we only need to substitute one value.
2020-10-01 19:53:45 +02:00
Zbigniew Jędrzejewski-Szmek 196b596867 shared/uid-range: reduce scope of iterator variables 2020-10-01 17:52:50 +02:00
Zbigniew Jędrzejewski-Szmek fc1a5d1a70 Also parse the minimum uid/gid values
We don't (and shouldn't I think) look at them when determining the type of the
user, but they should be used during user/group allocation. (For example, an
admin may specify SYS_UID_MIN==200 to allow statically numbered users that are
shared with other systems in the range 1–199.)
2020-10-01 17:52:41 +02:00
Zbigniew Jędrzejewski-Szmek 53393c894d Look at /etc/login.defs for the system_max_[ug]id values
It makes little sense to make the boundary between systemd and user guids
configurable. Nevertheless, a completely fixed compile-time define is not
enough in two scenarios:
- the systemd_uid_max boundary has moved over time. The default used to be
  500 for a long time. Systems which are upgraded over time might have users
  in the wrong range, but changing existing systems is complicated and
  expensive (offline disks, backups, remote systems, read-only media, etc.)
- systems are used in a heterogenous enviornment, where some vendors pick
  one value and others another.
So let's make this boundary overridable using /etc/login.defs.

Fixes #3855, #10184.
2020-10-01 17:49:31 +02:00
Franck Bui 8ce3de991b
Merge pull request #17214 from poettering/log-generator-fix
fix logging in generators
2020-10-01 10:51:19 +02:00
Lennart Poettering fabf877705
Merge pull request #17154 from keszybz/crypttab-commas
Allow escaping commas in crypttab
2020-10-01 10:26:24 +02:00
Lennart Poettering 7ea3024b50 bootspec: don't fail with EIO if searching for ESP and finding one without an enveloping partition table
If this happens this should just mean: we couldn't find the ESP.

Fixes: #17122
2020-10-01 10:21:02 +02:00
Lennart Poettering dee29aeb59 generator: use kmsg in system-level generators, journal otherwise
Fixes: #17129.
2020-09-30 16:28:34 +02:00
Lennart Poettering 8e24b1d23f seccomp-util: add cacheflush() syscall to @default syscall set
This is like membarrier() I guess and basically just exposes CPU
functionality via kernel syscall on some archs. Let's whitelist it for
everyone.

Fixes: #17197
2020-09-30 10:08:15 +02:00
Lennart Poettering a182fa895b
Merge pull request #17194 from poettering/dot-suffix
resolved: turn off search domain logic for queries for dot-suffixed domains
2020-09-29 15:50:06 +02:00
Lennart Poettering 64c82c25ab dns-domain: add helper that checks whether domain is dot suffixed 2020-09-29 12:09:16 +02:00
Lennart Poettering b9daaedbb9 udev-util: simplify device_is_renaming() error handling 2020-09-28 18:45:54 +02:00
Yu Watanabe fe2aeef816 ethtool: add several new link modes 2020-09-28 22:49:33 +09:00
Yu Watanabe 41f4269619 ethtool: convert underscore to hyphen 2020-09-28 22:44:05 +09:00
Yu Watanabe 7207d82c13 shared/linux: update ethtool.h 2020-09-28 22:42:44 +09:00
Luca Boccassi feee7f6288 libcrypt-util: use build-time check for crypt_preferred_method
After https://github.com/systemd/systemd/pull/16981 only the presence of crypt_gensalt_ra
is checked, but there are cases where that function is available but crypt_preferred_method
is not, and they are used in the same ifdef.
Add a check for the latter as well.
2020-09-28 10:23:48 +02:00
Lennart Poettering 3b493d94ae mount-util: show mount source in mount_verbose_full() debug output 2020-09-25 17:55:39 +02:00
Zbigniew Jędrzejewski-Szmek 98dcb8f4c7 Move {uid,gid}_is_*() from basic to shared
Those are functions that express policy, and nothing in basic/ uses
(or should use) them.
2020-09-25 17:18:56 +02:00
Lennart Poettering 77ad674b51 loop-util: apparently opening a loop device sometimes results in ENXIO, handle this 2020-09-25 16:03:05 +02:00
Lennart Poettering 0950526afd loop-util: use right flags field 2020-09-25 16:02:56 +02:00
Zbigniew Jędrzejewski-Szmek 7bb553bb98 fstab,crypttab: allow escaping of commas
Fixes #17035. We use "," as the separator between arguments in fstab and crypttab
options field, but the kernel started using "," within arguments. Users will need
to escape those nested commas.
2020-09-25 13:36:34 +02:00
Zbigniew Jędrzejewski-Szmek fe79f107ef tree-wide: drop assignments to r when we only need errno
If the whole call is simple and we don't need to look at the return value
apart from the conditional, let's use a form without assignment of the return
value. When the function call is more complicated, it still makes sense to
use a temporary variable.
2020-09-24 16:36:43 +02:00
Lennart Poettering bcaf20dc38
Merge pull request #17143 from keszybz/late-exec-resolution-alt
Late exec resolution (subset)
2020-09-24 09:38:36 +02:00
Lennart Poettering 30f5d10421 mount-util: rework umount_verbose() to take log level and flags arg
Let's make umount_verbose() more like mount_verbose_xyz(), i.e. take log
level and flags param. In particular the latter matters, since we
typically don't actually want to follow symlinks when unmounting.
2020-09-23 18:57:36 +02:00
Lennart Poettering 511a8cfe30 mount-util: switch most mount_verbose() code over to not follow symlinks 2020-09-23 18:57:36 +02:00
Lennart Poettering 5012d567a8 mount-util: make sure get_mount_flags() ever follows symlinks
It doesn't follow symlinks when we check for the mount flags via
libmount, hence it shouldn't do either when we go via statvfs().
2020-09-23 18:57:36 +02:00
Lennart Poettering 28126409b2 mount-util: add helpers for mount() without following symlinks 2020-09-23 18:57:36 +02:00
Lennart Poettering 6b6737119a
Merge pull request #17130 from keszybz/static-analyzer-cleanups
Trivial cleanups based on static analysis
2020-09-23 13:23:56 +02:00
Lennart Poettering 2d52f8c46c
Merge pull request #17124 from bluca/copypasta
dissect-image: use correct path variable when reading verity signatures, do not refuse verity GPT without /usr partition
2020-09-23 09:43:39 +02:00
Lennart Poettering 3cbf74652b
Merge pull request #17127 from poettering/errno-fixup
make more use of errno-util.h macros
2020-09-23 09:43:18 +02:00
Zbigniew Jędrzejewski-Szmek fec5929f8b shared/conf-parser: drop redundant cast to boolean
parse_boolean returns either 0 or 1 or error, and we checked for errors
earlier already.
2020-09-22 18:00:44 +02:00
Lennart Poettering fce93d7aa3 ptyfwd: use ERRNO_IS_DISCONNECT() when checking for disconnection on foreign fds 2020-09-22 16:25:22 +02:00
Lennart Poettering 065b47749d tree-wide: use ERRNO_IS_PRIVILEGE() whereever appropriate 2020-09-22 16:25:22 +02:00
Luca Boccassi c848516f3f dissect-image: do not refuse verity GPT without /usr partition
Only enforce that /usr verity partition is present if a /usr
partition is there
2020-09-22 15:24:59 +01:00
Luca Boccassi 7025fa8b1a dissect-image: use correct path variable when reading verity signatures
Copypasta slipped in via https://github.com/systemd/systemd/pull/17101
2020-09-22 13:19:19 +01:00
Lennart Poettering 3e0b54867e user-record: don't refuse login when last pw change time is in the future
The RTC is like just off, it's a weird system state, let's continue
without requiring pw change.
2020-09-21 18:02:35 +02:00
Lennart Poettering 61a29a020c homed: ignore ratelimiting counters when timestamp is from future
This likely indicates that the system clock is simply wrong, hence allow
access in this case.

Fixes: #15917
2020-09-21 18:02:35 +02:00
Lennart Poettering 51a95db6dc homed: don't block logins into accounts with future change time
This might happen if the system clock is wrong, and we should allow
access in this case (though certainly log about it).
2020-09-21 18:02:31 +02:00
Lennart Poettering aee36b4ea2 dissect-image: process /usr/ GPT partition type 2020-09-19 21:19:51 +02:00
Lennart Poettering 2bc181dae7 gpt: add new GPT partition types of /usr partitions 2020-09-19 21:19:23 +02:00
Lennart Poettering 3f440b13b7
Merge pull request #16981 from keszybz/use-crypt_ra
Use crypt_ra to allocate scratch area for password hashing
2020-09-18 19:46:08 +02:00
Zbigniew Jędrzejewski-Szmek f7bc0c324a Rename find_binary to find_executable
"executable" is more correct than "binary", since scripts are OK too.
2020-09-18 15:28:48 +02:00
Lennart Poettering 9434438543 dissect: use structured initialization, it's prettier 2020-09-17 18:02:45 +02:00
Lennart Poettering 3afda7c797 dissect: is_loop_device() returns negative on error, don't mistake that is true 2020-09-17 18:02:41 +02:00
Lennart Poettering 74cb2db9f4 dissect: always invalidate secondary arch partitions if we found primary arch
Let's suppress the secondary arch data, since we never ever want to
mount it if we found the primary arch.

Previously we only suppressed in the Verity case, but there's little
reason to entertain the idea of a secondary arch in non-Verity
environments either, we are not going to use them, and should not do
decryption or anything like that.
2020-09-17 18:02:37 +02:00
Lennart Poettering 220431724b dissect: three trivial fixes
Uppercase first char of log message, and indicate correct program name.

Reindent comment table at one place.

Use correct, specific, enum type at one more place.
2020-09-17 18:02:33 +02:00
Lennart Poettering 89e62e0bd3 dissect: wrap verity settings in new VeritySettings structure
Just some refactoring: let's place the various verity related parameters
in a common structure, and pass that around instead of the individual
parameters.

Also, let's load the PKCS#7 signature data when finding metadata
right-away, instead of delaying this until we need it. In all cases we
call this there's not much time difference between the metdata finding
and the loading, hence this simplifies things and makes sure root hash
data and its signature is now always acquired together.
2020-09-17 20:36:23 +09:00
Lennart Poettering eb5e26112e
Merge pull request #17076 from poettering/dissect-cleanup
minor cleanups to the dissector code
2020-09-16 18:42:12 +02:00
Lennart Poettering c796b91d2b
Merge pull request #16675 from topimiettinen/exec-syscall-error-action
SystemCallFilter, SystemCallErrorAction error actions kill and log
2020-09-16 17:01:44 +02:00
Lennart Poettering aa088f62d1 gpt: move GPT_LINUX_GENERIC definition next to the user GPT partition types
No code changes, just some reordering.
2020-09-16 16:31:16 +02:00
Lennart Poettering 569a0e42ec dissect: introduce PartitionDesignator as real type 2020-09-16 16:14:01 +02:00
Lennart Poettering f5215bc8d3 dissect: rename mount_options_from_part() → mount_options_from_designator()
After all, it actually takes a designator argument, not a partition
index or so.
2020-09-15 22:23:22 +02:00
Lennart Poettering b7b7ace4ea tests: try to allocate a delegated scope unit for our cgroup tests
Prompted-by: #16632
2020-09-15 13:32:15 +02:00
Topi Miettinen 9df2cdd8ec exec: SystemCallLog= directive
With new directive SystemCallLog= it's possible to list system calls to be
logged. This can be used for auditing or temporarily when constructing system
call filters.

---
v5: drop intermediary, update HASHMAP_FOREACH_KEY() use
v4: skip useless debug messages, actually parse directive
v3: don't declare unused variables with old libseccomp
v2: fix build without seccomp or old libseccomp
2020-09-15 12:54:17 +03:00
Topi Miettinen 005bfaf118 exec: Add kill action to system call filters
Define explicit action "kill" for SystemCallErrorNumber=.

In addition to errno code, allow specifying "kill" as action for
SystemCallFilter=.

---
v7: seccomp_parse_errno_or_action() returns -EINVAL if !HAVE_SECCOMP
v6: use streq_ptr(), let errno_to_name() handle bad values, kill processes,
 init syscall_errno
v5: actually use seccomp_errno_or_action_to_string(), don't fail bus unit
parsing without seccomp
v4: fix build without seccomp
v3: drop log action
v2: action -> number
2020-09-15 12:54:17 +03:00
Zbigniew Jędrzejewski-Szmek 35e22827a9 shared/libcrypt-util: do not refuse passwords if some other hash is unsupported 2020-09-15 11:52:30 +02:00
Zbigniew Jędrzejewski-Szmek 9de324c3c9 shared/libcrypt-util: add fallback for crypt_ra()
Following the style in missing_syscall.h, we use a non-conflicting name
for the function and use a macro to map to the real name to the replacement.
2020-09-15 11:52:30 +02:00
Zbigniew Jędrzejewski-Szmek 2b49f0ca83 Check for crypt_gensalt_ra() instead of relying on libxcrypt presence
Since the loop to check various xcrypt functions is already in place,
adding one more is cheap. And it is nicer to check for the function
directly. People like to backport things, so we might get lucky even
without having libxcrypt.
2020-09-15 11:52:30 +02:00
Zbigniew Jędrzejewski-Szmek 83764f8d00 shared/libcrypt-util: include fewer headers
Now that we wrap crypt_r/ra uses, we can include the header only in libcrypt-util.c.
2020-09-15 11:52:30 +02:00
Zbigniew Jędrzejewski-Szmek 999b49c818 Make test_password_{one,many} also use crypt_ra() 2020-09-15 11:52:30 +02:00
Zbigniew Jędrzejewski-Szmek 2ae297fe0d Move test_password_{one,many} to libcrypt-util.c
They are only used under src/home/, but I want to add tests in test-libcrypt-util.c.
And the functions are almost trivial, so I think it is OK to move them to shared.
2020-09-15 11:52:30 +02:00
Zbigniew Jędrzejewski-Szmek a937ce2d85 shared/libcrypt-util: use libcrypt_ra()
This lets the libc/xcrypt allocate as much storage area as it needs.
Should fix #16965:

testsuite-46.sh[74]: ==74==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7f3e972e1080 at pc 0x7f3e9be8deed bp 0x7ffce4f28530 sp 0x7ffce4f27ce0
testsuite-46.sh[74]: WRITE of size 131232 at 0x7f3e972e1080 thread T0
testsuite-46.sh[74]:     #0 0x7f3e9be8deec  (/usr/lib/clang/10.0.1/lib/linux/libclang_rt.asan-x86_64.so+0x9feec)
testsuite-46.sh[74]:     #1 0x559cd05a6412 in user_record_make_hashed_password /systemd-meson-build/../build/src/home/user-record-util.c:818:21
testsuite-46.sh[74]:     #2 0x559cd058fb03 in create_home /systemd-meson-build/../build/src/home/homectl.c:1112:29
testsuite-46.sh[74]:     #3 0x7f3e9b5b3058 in dispatch_verb /systemd-meson-build/../build/src/shared/verbs.c:103:24
testsuite-46.sh[74]:     #4 0x559cd058c101 in run /systemd-meson-build/../build/src/home/homectl.c:3325:16
testsuite-46.sh[74]:     #5 0x559cd058c00a in main /systemd-meson-build/../build/src/home/homectl.c:3328:1
testsuite-46.sh[74]:     #6 0x7f3e9a88b151 in __libc_start_main (/usr/lib/libc.so.6+0x28151)
testsuite-46.sh[74]:     #7 0x559cd0583e7d in _start (/usr/bin/homectl+0x24e7d)
testsuite-46.sh[74]: Address 0x7f3e972e1080 is located in stack of thread T0 at offset 32896 in frame
testsuite-46.sh[74]:     #0 0x559cd05a60df in user_record_make_hashed_password /systemd-meson-build/../build/src/home/user-record-util.c:789
testsuite-46.sh[74]:   This frame has 6 object(s):
testsuite-46.sh[74]:     [32, 40) 'priv' (line 790)
testsuite-46.sh[74]:     [64, 72) 'np' (line 791)
testsuite-46.sh[74]:     [96, 104) 'salt' (line 809)
testsuite-46.sh[74]:     [128, 32896) 'cd' (line 810)
testsuite-46.sh[74]:     [33152, 33168) '.compoundliteral' <== Memory access at offset 32896 partially underflows this variable
testsuite-46.sh[74]:     [33184, 33192) 'new_array' (line 832) <== Memory access at offset 32896 partially underflows this variable
testsuite-46.sh[74]: HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
testsuite-46.sh[74]:       (longjmp and C++ exceptions *are* supported)
testsuite-46.sh[74]: SUMMARY: AddressSanitizer: stack-buffer-overflow (/usr/lib/clang/10.0.1/lib/linux/libclang_rt.asan-x86_64.so+0x9feec)

It seems 'struct crypt_data' is 32896 bytes, but libclang_rt wants more, at least 33168?
2020-09-15 09:30:56 +02:00
Zbigniew Jędrzejewski-Szmek 0e98d17e77 Add a helper function that does make_salt+crypt_r
No functional change.
2020-09-15 09:30:56 +02:00
Yu Watanabe cadc7ed2e2 ethtool: constify arguments for ethtool_set_xxx() 2020-09-15 11:06:25 +09:00
Frantisek Sumsal 05827831a6 shared: drop a redundant if statement 2020-09-14 16:18:18 +02:00
Frantisek Sumsal 69e3234db7 tree-wide: fix typos found by codespell
Reported by Fossies.org
2020-09-14 15:32:37 +02:00
Lennart Poettering 6ae05c9b14
Merge pull request #16947 from keszybz/socket-parsing-rework
Socket parsing rework
2020-09-10 16:47:37 +02:00
Yu Watanabe 7a602af041 conf-parser: logs about OOM error 2020-09-10 14:14:19 +09:00
Yu Watanabe 3de39a1ad4 conf-parser: use SYNTHETIC_ERRNO() at one more place 2020-09-10 14:13:56 +09:00
Yu Watanabe 8add8b508d vlan: downgrade error level if the error will be ignored 2020-09-10 13:59:04 +09:00
Yu Watanabe 4c382a8772 ethtool: downgrade log level when the error will be ignored 2020-09-10 13:59:04 +09:00
Zbigniew Jędrzejewski-Szmek 08224f38ac Use sockaddr_un_set_path() in socket_address_parse()
Two functional changes:
- "/" is now refused. The test is adjusted.
- The trailing NUL is *not* included in the returned size for abstract size. The
  comments in sockaddr_un_set_path() indicate that this is the right thing to do,
  and the code in socket_address_parse() wasn't doing that.
2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek a73569f180 shared/socket-netlink: set output in socket_address_parse_netlink() only on success 2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek a07ab56a49 Allow interface scopes to be specified in ListenStream=
Closes #12624.

The formatting in systemd.socket.xml is updated a bit.

Currently in_addr_port_ifindex_name_to_string() always prints the ifindex
numerically. This is not super useful since the interface numbers are
semi-random. Should we use interface names in preference?
2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek 44ab234734 shared: don't unconditionally set SOCK_STREAM as type in socket_address_parse()
We would set .type to a fake value. All real callers (outside of tests)
immediately overwrite .type with a proper value after calling
socket_address_parse(). So let's not set it and adjust the few places
that relied on it being set to the fake value.

socket_address_parse() is modernized to only set the output argument on
success.
2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek 75af1666d7 shared: make socket_address_parse use the generic parser for IPv[46] addresses
One special syntax is not supported anymore: "iface:port" would be parsed as an
interface name plus numerical port, equivalent to "[::]%iface:port". This was
added in 542563babd, but was undocumented, and we had no tests for it. It seems
that this actually wasn't doing anything useful, because the kernel only uses the
scope identifier for link-local addresses.
2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek 222eaaf937 Get rid of in_addr_port_from_string_auto() again
With the commit "shared/socket-netlink: only allow ifindex if explicitly supported"
this helper is not necessary anymore.
2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek c1f848d73c shared: check interface name validity in in_addr_port_ifindex_name_from_string_auto()
We don't try to resolve invalid ifnames as all. A different return
code is used. This difference will be verified later in test_socket_address_parse()
when socket_address_parse() is converted to use
in_addr_port_ifindex_name_from_string_auto().
2020-09-10 00:46:44 +02:00
Zbigniew Jędrzejewski-Szmek 25b2d602b9 shared/socket-netlink: only allow ifindex if explicitly supported
Instead of ignoring ifindex if not wanted, refuse it is the caller
does not allow it.
2020-09-10 00:46:44 +02:00
Lennart Poettering d8ea7f838b ethtool-util: don't pass error value that isn't used to log_syntax 2020-09-09 23:43:20 +02:00
Mikael Szreder 664ad0f6f5
cryptsetup: Fix null pointer dereference (#16987)
cryptsetup: Fix null pointer dereference

Fix null pointer dereference in the pkcs11 related code of systemd-cryptsetup
2020-09-09 21:26:21 +02:00
Lennart Poettering 12ce0f4173
Merge pull request #16635 from keszybz/do-not-for-each-word
Drop FOREACH_WORD
2020-09-09 17:43:38 +02:00
Lennart Poettering 244d9793ee
Merge pull request #16984 from yuwata/make-log_xxx_error-void
Make log_xxx_error() or friends return void
2020-09-09 16:28:51 +02:00
Zbigniew Jędrzejewski-Szmek 90e30d767a Rename strv_split_extract() to strv_split_full()
Now that _full() is gone, we can rename _extract() to have the usual suffix
we use for the more featureful version.
2020-09-09 09:34:55 +02:00
Zbigniew Jędrzejewski-Szmek 45638a63c0 shared/fstab-util: replace FOREACH_WORD_SEPARATOR() with open-coded loop
The tricky part here is that the function is not allowed to fail in this code
path. Initially, I wanted to change the return value to allow it to fail, but
this cascades through all the places where fstab_test_option() and friends are
used; updating all those sites would be a lot of work. And since quoting is not
allowed here, a simple loop with strcspn() is easy to do.
2020-09-09 09:34:55 +02:00
Zbigniew Jędrzejewski-Szmek 0e8d185938 shared/fstab-util: use free_and_str[n]dup()
No functional change. I'm keeping this separate to make review easier.
2020-09-09 09:34:54 +02:00
Zbigniew Jędrzejewski-Szmek ecaf258eb4 Use extract_first_word() in generated conf parsers 2020-09-09 09:34:54 +02:00
Yu Watanabe d157714b68 network: make log_link_error() or friends return void 2020-09-09 02:34:38 +09:00
Lennart Poettering d161680e7a tree-wide: if get_block_device() returns zero devno, check for it in all cases
And add a comment for the existing cases where things aren't clear
already.
2020-09-08 18:10:26 +02:00
Zbigniew Jędrzejewski-Szmek 90e74a66e6 tree-wide: define iterator inside of the macro 2020-09-08 12:14:05 +02:00
Michal Sekletár 332d387f47 core: introduce support for setting NUMAMask= to special "all" value
Fixes #14113
2020-09-08 08:16:03 +02:00
Zbigniew Jędrzejewski-Szmek ad161cd6bb
Merge pull request #16951 from yuwata/resolve-follow-ups-for-extra-dns-stub-listener
resolve: follow-ups for extra DNS stub listener
2020-09-05 15:55:22 +02:00
Lennart Poettering 8d91b2206c varlink: properly allocate connection event source
Let's make sure we keep a reference to the event source

(Note that this code is currently not used, which is why this was never
used: in all cases we do not add listener fds after the event is
attached, but before. In that case this code is not called.)
2020-09-04 23:54:14 +02:00
Lennart Poettering 1ba37106b3 ptyfwd: don't set prio if event source that might not exist
We support read-only ptyfwd options, and on those the input event source
won't be allocated. Deal with that and don't invoke a function on it
that will then instantly fail.
2020-09-04 23:52:41 +02:00
Luca Boccassi 836540070d core: add [Enable|Disable]UnitFilesWithFlags DBUS methods
The new methods work as the unflavoured ones, but takes flags as a
single uint64_t DBUS parameters instead of different booleans, so
that it can be extended without breaking backward compatibility.
Add new flag to allow adding/removing symlinks in
[/etc|/run]/systemd/system.attached so that portable services
configuration files can be self-contained in those directories, without
affecting the system services directories.
Use the new methods and flags from portablectl --enable.

Useful in case /etc is read-only, with only the portable services
directories being mounted read-write.
2020-09-04 17:56:37 +02:00
Zbigniew Jędrzejewski-Szmek 434fef6de3 shared/sleep-config: more logging and port to extract_first_word() 2020-09-04 13:53:47 +02:00
Yu Watanabe fc7676e313 util: drop unused socket_addr_port_from_string_auto() 2020-09-04 20:05:58 +09:00
Yu Watanabe 355e884ded util: introduce in_addr_port_from_string_auto() 2020-09-04 20:05:58 +09:00
Zbigniew Jędrzejewski-Szmek 908dbc70d6
Merge pull request #16044 from ssahani/resolved-interface
systemd-resolved: allow configurable bind address
2020-09-03 19:06:05 +02:00
Lennart Poettering 0d12936d9a shared: make libcryptsetup dep dlopen
Let's make libcryptsetup a dlopen() style dep for PID 1 (i.e. for
RootImage= and stuff), systemd-growfs and systemd-repart. (But leave to
be a regulra dep in systemd-cryptsetup, systemd-veritysetup and
systemd-homed since for them the libcryptsetup support is not auxiliary
but pretty much at the core of what they do.)

This should be useful for container images that want systemd in the
payload but don't care for the cryptsetup logic since dm-crypt and stuff
isn't available in containers anyway.

Fixes: #8249
2020-09-02 15:04:06 +02:00
Lennart Poettering 1e2f32305c shared: rename crypt-util.c → cryptsetup-util.c
"crypt-util.c" is such a generic name, let's avoid that, in particular
as libc's/libcrypt's crypt() function is so generically named too that
one might thing this is about that. Let's hence be more precise, and
make clear that this is about cryptsetup, and nothing else.

We already had cryptsetup-util.[ch] in src/cryptsetup/ doing keyfile
management. To avoid the needless confusion, let's rename that file to
cryptsetup-keyfile.[ch].
2020-09-02 15:00:32 +02:00
Susant Sahani 1f1f3210c9 shared: Introduce socket_addr_port_from_string_auto 2020-09-02 03:25:17 +00:00
Zbigniew Jędrzejewski-Szmek 47b04ef632
Merge pull request #16925 from cgzones/selinux_create_label
selinux/core: create several file objects with default SELinux context
2020-09-01 22:19:52 +02:00
Lennart Poettering 004cfad218
Merge pull request #16911 from keszybz/userdb-json-invalid-utf8
Deal properly with invalid utf-8 in userdb entries
2020-09-01 20:34:22 +02:00
Renaud Métrich 3e5f04bf64 socket: New option 'FlushPending' (boolean) to flush socket before entering listening state
Disabled by default. When Enabled, before listening on the socket, flush the content.
Applies when Accept=no only.
2020-09-01 17:20:23 +02:00
Zbigniew Jędrzejewski-Szmek 5c0b738012 user-record-nss: check if strings from pwd/spwd/grp/sgrp are valid utf-8
strv_extend_strv_utf8_only() uses a temporary buffer to make the implementation
conscise. Otherwise we'd have to rewrite all of strv_extend_strv() which didn't
seem worth the trouble for this one use outside of a hot path.

If the data is not serializable, we just pretend it doesn't exists.
This fixes #16683 and https://bugs.gentoo.org/735072 in a second way.
2020-09-01 16:48:40 +02:00
Zbigniew Jędrzejewski-Szmek e60775cb7b shared: merge {user,group}-record-nss.{c,h}
They both are both short and contain similar parts and various helper will be
shared between both parts of the code so it's easier to use a single file.
2020-09-01 16:48:40 +02:00
Zbigniew Jędrzejewski-Szmek ea9afe0064 shared/json: reject non-utf-8 strings
JSON strings must be utf-8-clean. We also verify this in json_parse_string()
so we would reject a message with invalid utf-8 anyway.

It would probably be slightly cheaper to detect non-conformaning strings in
serialization, but then we'd have to fail serialization. By doing this early,
we give the caller a chance to handle the error nicely.

The test is adjusted to contain a valid utf-8 string after decoding of the
utf-32 encoding in json ("विवेकख्यातिरविप्लवा हानोपायः।", something about the
cessation of ignorance).
2020-09-01 16:48:40 +02:00
Christian Göttsche 63e00ccd8e selinux: create /run/systemd/userdb directory and sockets with default SELinux context 2020-09-01 16:26:12 +02:00
Zbigniew Jędrzejewski-Szmek e12b6e1951 json: split out string formatting to a separate function
It's complicated enough to deserve it's own function.

No functional change.
2020-09-01 10:48:10 +02:00
Zbigniew Jędrzejewski-Szmek 77472d06a4 varlink: do not parse invalid messages twice
Upon reception of a message which fails in json_parse(), we would proceed to
parse it again from a deferred callback and hang. Once we have realized that
the message is invalid, let's move the pointer in the buffer even if the
message is invalid. We don't want to look at this data again.

(before) $ build-rawhide/userdbctl --output=json user test.user
n/a: varlink: setting state idle-client
/run/systemd/userdb/io.systemd.Multiplexer: Sending message: {"method":"io.systemd.UserDatabase.GetUserRecord","parameters":{"userName":"test.user","service":"io.systemd.Multiplexer"}}
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state idle-client → awaiting-reply
/run/systemd/userdb/io.systemd.Multiplexer: New incoming message: {...}
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state awaiting-reply → pending-disconnect
/run/systemd/userdb/io.systemd.Multiplexer: New incoming message: {...}
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state pending-disconnect → disconnected
^C

(after) $ n/a: varlink: setting state idle-client
/run/systemd/userdb/io.systemd.Multiplexer: Sending message: {"method":"io.systemd.UserDatabase.GetUserRecord","parameters":{"userName":"test.user","service":"io.systemd.Multiplexer"}}
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state idle-client → awaiting-reply
/run/systemd/userdb/io.systemd.Multiplexer: New incoming message: {...}
/run/systemd/userdb/io.systemd.Multiplexer: Failed to parse JSON: Invalid argument
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state awaiting-reply → pending-disconnect
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state pending-disconnect → processing-disconnect
Got lookup error: io.systemd.Disconnected
/run/systemd/userdb/io.systemd.Multiplexer: varlink: changing state processing-disconnect → disconnected
Failed to find user test.user: Input/output error

This should fix #16683 and https://bugs.gentoo.org/735072.
2020-09-01 10:48:10 +02:00
Zbigniew Jędrzejewski-Szmek 52d3fbc83f shared: merge {user,group}-record-show.[ch]
It is natural to include both, and in total they declared three
functions. Let's merge them for simplicity.
2020-09-01 10:48:03 +02:00
Anita Zhang 0419dae715
Merge pull request #16885 from keszybz/rework-cache-timestamps
Rework cache timestamps
2020-08-31 23:21:12 -07:00
Lennart Poettering 4dc286658d dissect-image: generate nice error when we can't detect any file system 2020-08-31 22:11:53 +02:00
Zbigniew Jędrzejewski-Szmek 8f796e40a5 shared/{user,group}-record-nss: adjust filtering of "valid" passwords
We would reject various passwords that glibc accepts, for example ""
or any descrypted password. Accounts with empty password are definitely
useful, for example for testing or in scenarios where a password is not
needed. Also, using weak encryption methods is probably not a good idea,
it's not the job of our nss helpers to decide that: they should just
faithfully forward whatever data is there.

Also rename the function to make it more obvious that the returned answer
is not in any way certain.
2020-08-31 21:33:16 +02:00
Zbigniew Jędrzejewski-Szmek c2911d48ff Rework how we cache mtime to figure out if units changed
Instead of assuming that more-recently modified directories have higher mtime,
just look for any mtime changes, up or down. Since we don't want to remember
individual mtimes, hash them to obtain a single value.

This should help us behave properly in the case when the time jumps backwards
during boot: various files might have mtimes that in the future, but we won't
care. This fixes the following scenario:

We have /etc/systemd/system with T1. T1 is initially far in the past.
We have /run/systemd/generator with time T2.
The time is adjusted backwards, so T2 will be always in the future for a while.
Now the user writes new files to /etc/systemd/system, and T1 is updated to T1'.
Nevertheless, T1 < T1' << T2.
We would consider our cache to be up-to-date, falsely.
2020-08-31 20:53:38 +02:00
Lennart Poettering b519529104
Merge pull request #16841 from keszybz/acl-util-bitmask
Use a bitmask in fd_add_uid_acl_permission()
2020-08-31 16:45:13 +02:00
fangxiuning 6d95e7d9b2
tree-wide: drop pointless zero initialization (#16900) 2020-08-30 06:21:20 +09:00
Fabrice Fontaine 28e2641a1a
src/shared/dissect-image.c: fix build without blkdid (#16901)
N_DEVICE_NODE_LIST_ATTEMPTS is unconditionally used since version 246 and
ac1f3ad05f

However, this variable is only defined if HAVE_BLKID is set resulting in
the following build failure if cryptsetup is enabled but not libblkid:

../src/shared/dissect-image.c:1336:34: error: 'N_DEVICE_NODE_LIST_ATTEMPTS' undeclared (first use in this function)
 1336 |         for (unsigned i = 0; i < N_DEVICE_NODE_LIST_ATTEMPTS; i++) {
      |

Fixes:
 - http://autobuild.buildroot.org/results/67782c225c08387c1bbcbea9eee3ca12bc6577cd
2020-08-30 06:17:18 +09:00
Daniel Mack 5170afbc55 clock-util: read timestamp from /usr/lib/clock-epoch
On systems without an RTC, systemd currently sets the clock to a
compile-time epoch value, derived from the NEWS file in the
repository. This is not ideal as the initial clock hence depends
on the last time systemd was built, not when the image was compiled.

Let's provide a different way here and look at `/usr/lib/clock-epoch`.
If that file exists, it's timestamp for the last modification will be
used instead of the compile-time default.
2020-08-28 18:58:22 +02:00
fangxiuning c53aafb7b5
tree-wide: drop pointless zero initialization (#16884)
tree-wide: drop pointless zero initialization
2020-08-28 17:45:54 +02:00
Zbigniew Jędrzejewski-Szmek 567aeb5801 shared/acl-util: convert rd,wr,ex to a bitmask
I find this version much more readable.

Add replacement defines so that when acl/libacl.h is not available, the
ACL_{READ,WRITE,EXECUTE} constants are also defined. Those constants were
declared in the kernel headers already in 1da177e4c3f41524e886b7f1b8a0c1f,
so they should be the same pretty much everywhere.
2020-08-27 10:20:12 +02:00
Lennart Poettering 66bff73b4f tty-ask-pw-agent: the message string might not be set 2020-08-26 23:10:05 +02:00
Lennart Poettering b97e3e3d7a json: also add explicit dispatchers for 'int' and 'unsigned' 2020-08-26 16:47:32 +02:00
Lennart Poettering 0710343ce7 json: add support for byte arrays to json builder 2020-08-26 16:47:16 +02:00
Lennart Poettering 7466e94f13 varlink: add helper for generating errno errors 2020-08-26 16:46:57 +02:00
Zbigniew Jędrzejewski-Szmek b6abc2acb4
Merge pull request #16568 from poettering/creds-store
credentials logic to pass privileged data to services
2020-08-26 10:32:30 +02:00
Lennart Poettering bb0c0d6f29 core: add credentials logic
Fixes: #15778 #16060
2020-08-25 19:45:35 +02:00
Lennart Poettering 9db59d9283 acl-util: beef up add_acls_for_user()
Let's add support for controlling r/w/x bits separetely. This is useful
for using it to control access to directories, where r + x shall be
enabled.
2020-08-25 18:39:45 +02:00
Lennart Poettering 71281a7655 acl-util: make sure acl_find_uid() initializes return parameters on success
Let's follow our usual coding style and initialize return parameters on
success in all cases.
2020-08-25 18:39:45 +02:00
Lennart Poettering 9be99f81a7 homed: report a home directory as "dirty" if image file has dirty flag 2020-08-25 18:18:56 +02:00
Lennart Poettering da3920c3a4 journal: move qrcode printing code to src/shared/
That way we can make use of it in homctl, too.
2020-08-25 17:58:02 +02:00
Lennart Poettering b3a97fd3ae user-record: add recovery key fields to user record 2020-08-25 17:58:02 +02:00
Lennart Poettering 45374f6503
Merge pull request #15662 from Werkov/fix-cgroup-disable
Fix unsetting cgroup restrictions
2020-08-25 17:36:07 +02:00
Zbigniew Jędrzejewski-Szmek 3b9d671754
Merge pull request #16676 from poettering/repart-mkfs
repart: add new settings Format=, CopyFiles=, Encrypt= and teach --size= a new value "auto"
2020-08-25 12:19:46 +02:00
Zbigniew Jędrzejewski-Szmek b20f00599d
Merge pull request #16816 from keszybz/install-templated-presets
Fix preset operation for non-service templates
2020-08-25 09:20:07 +02:00
Zbigniew Jędrzejewski-Szmek 9f56c88aeb
Merge pull request #16819 from keszybz/seccomp-enosys
Return ENOSYS in nspawn for "unknown" syscalls
2020-08-25 09:18:46 +02:00
Zbigniew Jędrzejewski-Szmek d521e6993d
Merge pull request #16824 from keszybz/no-such-unit-error
Add sd_bus_error_has_names() and use it to catch BUS_ERROR_NO_SUCH_UNIT
2020-08-25 09:16:25 +02:00
Lennart Poettering bb2551bdcb loop-util: LOOP_CONFIGURE ignores lo_sizelimit
It appears LOOP_CONFIGURE in 5.8 is even more broken than initially
thought: it doesn't properly propgate lo_sizelimit to the block device
layer. :-(

Let's hence check the block device size immediately after issuing
LOOP_CONFIGURE, and if it doesn't match what we just set let's fallback
to the old ioctls.

This means LOOP_CONFIGURE currently works correctly only for the most
simply case: no partition table logic and no size limit. Sad!

(Kernel people should really be told about the concepts of tests and
even CI, one day!)
2020-08-24 22:01:13 +02:00
Lennart Poettering 1f0f82f131 dissect: create directories we want to mount on
This matches how we handle things everywhere else, i.e. in .mount units,
and similar: when a mount point dir is missing, we create it, let's do
so too when dealing with disk images.

This makes things a lot simpler, more robust, and systematic.
2020-08-24 22:00:35 +02:00
Lennart Poettering 0f2b2c483f mkfs-util: add support for making vfat partitions
fat is a bit more limited in volume name length and UUID support. Let's
add some special support for it.

This is particularly useful to generate EFI system partitions.
2020-08-24 22:00:17 +02:00
Lennart Poettering c95f9a2351 shared: introduce mkfs-util.c/.h
Let's move the "mkfs" code from homed there, plus other related code.

This way we can easily reuse it from other places.
2020-08-24 21:59:49 +02:00
Lennart Poettering 8dbc208cc1 loop-util: define API for syncing loopback device 2020-08-24 21:59:35 +02:00
Lennart Poettering 4e39995371 core: introduce ProtectProc= and ProcSubset= to expose hidepid= and subset= procfs mount options
Kernel 5.8 gained a hidepid= implementation that is truly per procfs,
which allows us to mount a distinct once into every unit, with
individual hidepid= settings. Let's expose this via two new settings:
ProtectProc= (wrapping hidpid=) and ProcSubset= (wrapping subset=).

Replaces: #11670
2020-08-24 20:11:02 +02:00
Zbigniew Jędrzejewski-Szmek 8694114b80 generate-syscall-list: require python3
Python3.4 works, but 2.7 returns a tuple from os.uname().
2020-08-24 20:05:32 +02:00
Zbigniew Jędrzejewski-Szmek 000c05207d shared/seccomp-util: added functionality to make list of filtred syscalls
While at it, start removing the "seccomp_" prefix from our
own functions. It is used by libseccomp.
2020-08-24 20:05:09 +02:00
Zbigniew Jędrzejewski-Szmek 752fedbea7 shared/syscall-list: filter out some obviously platform-specific syscalls 2020-08-24 20:05:02 +02:00
Zbigniew Jędrzejewski-Szmek 077e8fc0ca shared/seccomp: reduce scope of indexing variables 2020-08-24 20:04:54 +02:00
Zbigniew Jędrzejewski-Szmek 95aac01259 shared: add @known syscall list 2020-08-24 20:04:17 +02:00
Zbigniew Jędrzejewski-Szmek 73d3ac8e24 various: treat BUS_ERROR_NO_SUCH_UNIT the same as SD_BUS_ERROR_SERVICE_UNKNOWN
We return BUS_ERROR_NO_SUCH_UNIT a.k.a. org.freedesktop.systemd1.NoSuchUnit
in various places. In #16813:
Aug 22 06:14:48 core sudo[2769199]: pam_systemd_home(sudo:account): Failed to query user record: Unit dbus-org.freedesktop.home1.service not found.
Aug 22 06:14:48 core dbus-daemon[5311]: [system] Activation via systemd failed for unit 'dbus-org.freedesktop.home1.service': Unit dbus-org.freedesktop.home1.service not found.
Aug 22 06:14:48 core dbus-daemon[5311]: [system] Activating via systemd: service name='org.freedesktop.home1' unit='dbus-org.freedesktop.home1.service' requested by ':1.6564' (uid=0 pid=2769199 comm="sudo su ")

This particular error comes from bus_unit_validate_load_state() in pid1:
  case UNIT_NOT_FOUND:
       return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_UNIT, "Unit %s not found.", u->id);

It seems possible that we should return a different error, but it doesn't really
matter: if we change pid1 to return a different error, we still need to handle
BUS_ERROR_NO_SUCH_UNIT as in this patch to handle pid1 with current code.
2020-08-24 19:48:26 +02:00
Zbigniew Jędrzejewski-Szmek 47ab95fe43 shared/install: fix preset operations for non-service instantiated units
Fixes https://github.com/coreos/ignition/issues/1064.
2020-08-22 12:00:19 +02:00
Zbigniew Jędrzejewski-Szmek de8be28e03 shared/install: reduce scope of iterator variables 2020-08-22 12:00:19 +02:00
Lennart Poettering 9aab8d7a98
Merge pull request #16804 from keszybz/conditionals-and-spelling-fixes
Conditionals and spelling fixes
2020-08-21 13:36:30 +02:00
Steve Dodd 44aaddad06 Request seccomp logging if SYSTEMD_LOG_SECCOMP environment variable is set. 2020-08-21 11:24:53 +02:00
Zbigniew Jędrzejewski-Szmek 3fb01017ee
Merge pull request #16686 from bluca/mount_images_opts
core: add mount options support for MountImages
2020-08-21 10:11:08 +02:00
Aurelien Jarno f9252236c8 seccomp: add support for riscv64
This patch adds seccomp support to the riscv64 architecture. seccomp
support is available in the riscv64 kernel since version 5.5, and it
has just been added to the libseccomp library.

riscv64 uses generic syscalls like aarch64, so I used that architecture
as a reference to find which code has to be modified.

With this patch, the testsuite passes successfully, including the
test-seccomp test. The system boots and works fine with kernel 5.4 (i.e.
without seccomp support) and kernel 5.5 (i.e. with seccomp support). I
have also verified that the "SystemCallFilter=~socket" option prevents a
service to use the ping utility when running on kernel 5.5.
2020-08-21 10:10:29 +02:00
Zbigniew Jędrzejewski-Szmek 990307c3da
Merge pull request #16803 from poettering/analyze-condition-rework
support missing conditions/asserts everywhere
2020-08-20 18:18:13 +02:00
Lennart Poettering cbed1dc8af mount-util: tweak how we find inaccessible device nodes
On new kernels (>= 5.8) unprivileged users may create the 0:0 character
device node. Which is great, as we can use that as inaccessible device
nodes if we run unprivileged. Hence, change how we find the right
inaccessible device inodes: when the user asks for a block device node,
but we have none, try the char device node first. If that doesn't exist,
fall back to the socket node as before.

This means that:

1. in the best case we'll return a node if the right device node type
2. otherwise we hopefully at least can return a device node if one asked
   for even if the type doesn't match (i.e. we return char instead of
   the requested block device node)
3. in the worst case (old kernels…) we'll return a socket node
2020-08-20 18:15:29 +02:00
Zbigniew Jędrzejewski-Szmek 2aed63f427 tree-wide: fix spelling of "fallback"
Similarly to "setup" vs. "set up", "fallback" is a noun, and "fall back"
is the verb. (This is pretty clear when we construct a sentence in the
present continous: "we are falling back" not "we are fallbacking").
2020-08-20 17:45:32 +02:00