Merge branch 'master' into f32

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-03-18 20:58:50 +01:00
commit a32a98a0fa
9 changed files with 66 additions and 370 deletions

View file

@ -1,53 +0,0 @@
From e3ba241cd4003ee6eb6704e8c53240687534d6ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Tue, 3 Mar 2020 10:18:32 +0100
Subject: [PATCH] sysusers: many different errnos to express one condition
See https://bugzilla.redhat.com/show_bug.cgi?id=1807768. It turns
out that sysusers cannot query if the group exists:
Failed to check if group dnsmasq already exists: No such process
...
Failed to check if group systemd-timesync already exists: No such process
When the same command is executed later, the issue does not occur. Not sure why
the behaviour in the initial transaction is different. But let's accept all
errors that the man pages list.
---
src/sysusers/sysusers.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index 2771fd959f..1b1f19e817 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -94,6 +94,12 @@ STATIC_DESTRUCTOR_REGISTER(database_groups, set_free_freep);
STATIC_DESTRUCTOR_REGISTER(uid_range, freep);
STATIC_DESTRUCTOR_REGISTER(arg_root, freep);
+static int errno_is_not_exists(int code) {
+ /* See getpwnam(3) and getgrnam(3): those codes and others can be returned if the user or group are
+ * not found. */
+ return IN_SET(code, 0, ENOENT, ESRCH, EBADF, EPERM);
+}
+
static int load_user_database(void) {
_cleanup_fclose_ FILE *f = NULL;
const char *passwd_path;
@@ -971,7 +977,7 @@ static int add_user(Item *i) {
return 0;
}
- if (!IN_SET(errno, 0, ENOENT))
+ if (!errno_is_not_exists(errno))
return log_error_errno(errno, "Failed to check if user %s already exists: %m", i->name);
}
@@ -1108,7 +1114,7 @@ static int get_gid_by_name(const char *name, gid_t *gid) {
*gid = g->gr_gid;
return 0;
}
- if (!IN_SET(errno, 0, ENOENT))
+ if (!errno_is_not_exists(errno))
return log_error_errno(errno, "Failed to check if group %s already exists: %m", name);
}

View file

@ -1,144 +0,0 @@
From 6cb356ca9fe063846cfb883ef484f7e7e411096c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Tue, 3 Mar 2020 11:51:50 +0100
Subject: [PATCH 2/3] basic/fs-util: add a version of chmod_and_chown that
doesn not use /proc
---
src/basic/fs-util.c | 46 +++++++++++++++++++++++++++++++++++++++++
src/basic/fs-util.h | 1 +
src/test/test-fs-util.c | 45 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 92 insertions(+)
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c
index f8095e85d8..558cafbcaf 100644
--- a/src/basic/fs-util.c
+++ b/src/basic/fs-util.c
@@ -272,6 +272,52 @@ int fchmod_and_chown(int fd, mode_t mode, uid_t uid, gid_t gid) {
return do_chown || do_chmod;
}
+int chmod_and_chown_unsafe(const char *path, mode_t mode, uid_t uid, gid_t gid) {
+ bool do_chown, do_chmod;
+ struct stat st;
+
+ assert(path);
+
+ /* Change ownership and access mode of the specified path, see description of fchmod_and_chown().
+ * Should only be used on trusted paths. */
+
+ if (lstat(path, &st) < 0)
+ return -errno;
+
+ do_chown =
+ (uid != UID_INVALID && st.st_uid != uid) ||
+ (gid != GID_INVALID && st.st_gid != gid);
+
+ do_chmod =
+ !S_ISLNK(st.st_mode) && /* chmod is not defined on symlinks */
+ ((mode != MODE_INVALID && ((st.st_mode ^ mode) & 07777) != 0) ||
+ do_chown); /* If we change ownership, make sure we reset the mode afterwards, since chown()
+ * modifies the access mode too */
+
+ if (mode == MODE_INVALID)
+ mode = st.st_mode; /* If we only shall do a chown(), save original mode, since chown() might break it. */
+ else if ((mode & S_IFMT) != 0 && ((mode ^ st.st_mode) & S_IFMT) != 0)
+ return -EINVAL; /* insist on the right file type if it was specified */
+
+ if (do_chown && do_chmod) {
+ mode_t minimal = st.st_mode & mode; /* the subset of the old and the new mask */
+
+ if (((minimal ^ st.st_mode) & 07777) != 0)
+ if (chmod(path, minimal & 07777) < 0)
+ return -errno;
+ }
+
+ if (do_chown)
+ if (lchown(path, uid, gid) < 0)
+ return -errno;
+
+ if (do_chmod)
+ if (chmod(path, mode & 07777) < 0)
+ return -errno;
+
+ return do_chown || do_chmod;
+}
+
int fchmod_umask(int fd, mode_t m) {
mode_t u;
int r;
diff --git a/src/basic/fs-util.h b/src/basic/fs-util.h
index 78d68be9fd..6b9ade2ec1 100644
--- a/src/basic/fs-util.h
+++ b/src/basic/fs-util.h
@@ -34,6 +34,7 @@ int readlink_and_make_absolute(const char *p, char **r);
int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid);
int fchmod_and_chown(int fd, mode_t mode, uid_t uid, gid_t gid);
+int chmod_and_chown_unsafe(const char *path, mode_t mode, uid_t uid, gid_t gid);
int fchmod_umask(int fd, mode_t mode);
int fchmod_opath(int fd, mode_t m);
diff --git a/src/test/test-fs-util.c b/src/test/test-fs-util.c
index d0c6fb82bf..d97ccfda3b 100644
--- a/src/test/test-fs-util.c
+++ b/src/test/test-fs-util.c
@@ -802,6 +802,50 @@ static void test_chmod_and_chown(void) {
assert_se(S_ISLNK(st.st_mode));
}
+static void test_chmod_and_chown_unsafe(void) {
+ _cleanup_(rm_rf_physical_and_freep) char *d = NULL;
+ _unused_ _cleanup_umask_ mode_t u = umask(0000);
+ struct stat st;
+ const char *p;
+
+ if (geteuid() != 0)
+ return;
+
+ log_info("/* %s */", __func__);
+
+ assert_se(mkdtemp_malloc(NULL, &d) >= 0);
+
+ p = strjoina(d, "/reg");
+ assert_se(mknod(p, S_IFREG | 0123, 0) >= 0);
+
+ assert_se(chmod_and_chown_unsafe(p, S_IFREG | 0321, 1, 2) >= 0);
+ assert_se(chmod_and_chown_unsafe(p, S_IFDIR | 0555, 3, 4) == -EINVAL);
+
+ assert_se(lstat(p, &st) >= 0);
+ assert_se(S_ISREG(st.st_mode));
+ assert_se((st.st_mode & 07777) == 0321);
+
+ p = strjoina(d, "/dir");
+ assert_se(mkdir(p, 0123) >= 0);
+
+ assert_se(chmod_and_chown_unsafe(p, S_IFDIR | 0321, 1, 2) >= 0);
+ assert_se(chmod_and_chown_unsafe(p, S_IFREG | 0555, 3, 4) == -EINVAL);
+
+ assert_se(lstat(p, &st) >= 0);
+ assert_se(S_ISDIR(st.st_mode));
+ assert_se((st.st_mode & 07777) == 0321);
+
+ p = strjoina(d, "/lnk");
+ assert_se(symlink("idontexist", p) >= 0);
+
+ assert_se(chmod_and_chown_unsafe(p, S_IFLNK | 0321, 1, 2) >= 0);
+ assert_se(chmod_and_chown_unsafe(p, S_IFREG | 0555, 3, 4) == -EINVAL);
+ assert_se(chmod_and_chown_unsafe(p, S_IFDIR | 0555, 3, 4) == -EINVAL);
+
+ assert_se(lstat(p, &st) >= 0);
+ assert_se(S_ISLNK(st.st_mode));
+}
+
int main(int argc, char *argv[]) {
test_setup_logging(LOG_INFO);
@@ -819,6 +863,7 @@ int main(int argc, char *argv[]) {
test_fsync_directory_of_file();
test_rename_noreplace();
test_chmod_and_chown();
+ test_chmod_and_chown_unsafe();
return 0;
}

View file

@ -1,113 +0,0 @@
From 1fb5a5edc7c175ea0cd85a1e3a5af8d54084a891 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Tue, 3 Mar 2020 11:58:07 +0100
Subject: [PATCH 3/3] sysusers: do not require /proc to be mounted
We're operating on known paths in root-owned directories here, so the detour
through toctou-safe methods that require /proc to be mounted is not necessary.
Should fix https://bugzilla.redhat.com/show_bug.cgi?id=1807768.
---
src/sysusers/sysusers.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index 1b1f19e817..f7cc7e0900 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -199,7 +199,7 @@ static int load_group_database(void) {
static int make_backup(const char *target, const char *x) {
_cleanup_close_ int src = -1;
_cleanup_fclose_ FILE *dst = NULL;
- _cleanup_free_ char *temp = NULL;
+ _cleanup_free_ char *dst_tmp = NULL;
char *backup;
struct timespec ts[2];
struct stat st;
@@ -216,7 +216,7 @@ static int make_backup(const char *target, const char *x) {
if (fstat(src, &st) < 0)
return -errno;
- r = fopen_temporary_label(target, x, &dst, &temp);
+ r = fopen_temporary_label(target, x, &dst, &dst_tmp);
if (r < 0)
return r;
@@ -230,7 +230,7 @@ static int make_backup(const char *target, const char *x) {
backup = strjoina(x, "-");
/* Copy over the access mask */
- r = fchmod_and_chown(fileno(dst), st.st_mode & 07777, st.st_uid, st.st_gid);
+ r = chmod_and_chown_unsafe(dst_tmp, st.st_mode & 07777, st.st_uid, st.st_gid);
if (r < 0)
log_warning_errno(r, "Failed to change access mode or ownership of %s: %m", backup);
@@ -243,7 +243,7 @@ static int make_backup(const char *target, const char *x) {
if (r < 0)
goto fail;
- if (rename(temp, backup) < 0) {
+ if (rename(dst_tmp, backup) < 0) {
r = -errno;
goto fail;
}
@@ -251,7 +251,7 @@ static int make_backup(const char *target, const char *x) {
return 0;
fail:
- (void) unlink(temp);
+ (void) unlink(dst_tmp);
return r;
}
@@ -345,13 +345,13 @@ static int putsgent_with_members(const struct sgrp *sg, FILE *gshadow) {
}
#endif
-static int sync_rights(FILE *from, FILE *to) {
+static int sync_rights(FILE *from, const char *to) {
struct stat st;
if (fstat(fileno(from), &st) < 0)
return -errno;
- return fchmod_and_chown(fileno(to), st.st_mode & 07777, st.st_uid, st.st_gid);
+ return chmod_and_chown_unsafe(to, st.st_mode & 07777, st.st_uid, st.st_gid);
}
static int rename_and_apply_smack(const char *temp_path, const char *dest_path) {
@@ -389,7 +389,7 @@ static int write_temporary_passwd(const char *passwd_path, FILE **tmpfile, char
original = fopen(passwd_path, "re");
if (original) {
- r = sync_rights(original, passwd);
+ r = sync_rights(original, passwd_tmp);
if (r < 0)
return r;
@@ -491,7 +491,7 @@ static int write_temporary_shadow(const char *shadow_path, FILE **tmpfile, char
original = fopen(shadow_path, "re");
if (original) {
- r = sync_rights(original, shadow);
+ r = sync_rights(original, shadow_tmp);
if (r < 0)
return r;
@@ -588,7 +588,7 @@ static int write_temporary_group(const char *group_path, FILE **tmpfile, char **
original = fopen(group_path, "re");
if (original) {
- r = sync_rights(original, group);
+ r = sync_rights(original, group_tmp);
if (r < 0)
return r;
@@ -687,7 +687,7 @@ static int write_temporary_gshadow(const char * gshadow_path, FILE **tmpfile, ch
if (original) {
struct sgrp *sg;
- r = sync_rights(original, gshadow);
+ r = sync_rights(original, gshadow_tmp);
if (r < 0)
return r;

View file

@ -1 +0,0 @@
disable *

View file

@ -1,33 +0,0 @@
From 99fdffaa194cbfed659b0c1bfd0ace4bfcd2a245 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Mon, 10 Feb 2020 17:19:52 +0100
Subject: [PATCH] Revert "Support Plugable UD-PRO8 dock"
This reverts commit 95f2b4dd237faa57fd3e93245d560e47cdedfc2c.
Unfortunately the same usb hub is used in other places, and causes
numerous regressions (#14822,
https://bugzilla.redhat.com/show_bug.cgi?id=1800820). Let's revert
until a non-regressing approach is found.
---
src/login/71-seat.rules.in | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/login/71-seat.rules.in b/src/login/71-seat.rules.in
index 2a9ddb93aa7..2bbd18363e6 100644
--- a/src/login/71-seat.rules.in
+++ b/src/login/71-seat.rules.in
@@ -32,12 +32,9 @@ SUBSYSTEM=="pci", ENV{ID_PCI_CLASS_FROM_DATABASE}=="Display controller", \
SUBSYSTEM=="drm", KERNEL=="card[0-9]*", TAG+="seat", TAG+="master-of-seat"
SUBSYSTEM=="usb", ATTR{bDeviceClass}=="09", TAG+="seat"
-# 'Plugable UD-160' USB hub, sound, network, graphics adapter
+# 'Plugable' USB hub, sound, network, graphics adapter
SUBSYSTEM=="usb", ATTR{idVendor}=="2230", ATTR{idProduct}=="000[13]", ENV{ID_AUTOSEAT}="1"
-# 'Plugable UD-PRO8' USB hub, sound, network, graphics adapter
-SUBSYSTEM=="usb", ATTR{idVendor}=="1a40", ATTR{idProduct}=="0201", ENV{ID_AUTOSEAT}="1"
-
# qemu (version 2.4+) has a PCI-PCI bridge (-device pci-bridge-seat) to group
# devices belonging to one seat. See:
# http://git.qemu.org/?p=qemu.git;a=blob;f=docs/multiseat.txt

View file

@ -1 +1 @@
SHA512 (systemd-245-rc1.tar.gz) = 2ef9a295f3897c6642a2fac2e3c73467ece9bc6fc196cc4f3707b9c23af2581eb9f74def78909d57513b67604bf1cf6dc5dbb31c6d435f7997677d09a73d006b
SHA512 (systemd-245.2.tar.gz) = 05e40d0b93ebd7b709d16b5f6d75f3da84417e9a401d7726fe7876328e1408c9c29818b5bcc3f5889f17f8e6af889f87dc2f78f348f2aa023e0d6bfed41b0554

View file

@ -77,6 +77,9 @@ for file in files(buildroot):
elif re.search(r'''udev(?!\.pc)|
hwdb|
bootctl|
sd-boot|systemd-boot\.|loader.conf|
bless-boot|
boot-system-token|
kernel-install|
vconsole|
backlight|
@ -87,14 +90,19 @@ for file in files(buildroot):
cryptsetup|
kmod|
quota|
pstore|
sleep|suspend|hibernate|
systemd-tmpfiles-setup-dev|
network/99-default.link|
growfs|makefs|makeswap|
growfs|makefs|makeswap|mkswap|
fsck|
repart|
gpt-auto|
volatile-root|
verity-setup|
remount-fs|
/boot$|
/boot/efi|
remount-fs|
/kernel/|
/kernel$|
/modprobe.d

View file

@ -1,7 +1,7 @@
#global commit ef677436aa203c24816021dd698b57f219f0ff64
%{?commit:%global shortcommit %(c=%{commit}; echo ${c:0:7})}
# %%global stable 1
%global stable 1
# We ship a .pc file but don't want to have a dep on pkg-config. We
# strip the automatically generated dep here and instead co-own the
@ -12,10 +12,12 @@
%global system_unit_dir %{pkgdir}/system
%global user_unit_dir %{pkgdir}/user
%bcond_without tests
Name: systemd
Url: https://www.freedesktop.org/wiki/Software/systemd
Version: 245~rc1
Release: 4%{?commit:.git%{shortcommit}}%{?dist}
Version: 245.2
Release: 1%{?commit:.git%{shortcommit}}%{?dist}
# For a breakdown of the licensing, see README
License: LGPLv2+ and MIT and GPLv2+
Summary: System and Service Manager
@ -50,10 +52,6 @@ Source10: systemd-udev-trigger-no-reload.conf
Source11: 20-grubby.install
Source12: systemd-user
# A stop-gap measure until
# https://src.fedoraproject.org/rpms/fedora-release/pull-request/80 is merged.
Source13: 99-default-disable-fallback.preset
Source21: macros.sysusers
Source22: sysusers.attr
Source23: sysusers.prov
@ -66,13 +64,7 @@ GIT_DIR=../../src/systemd/.git git diffab -M v233..master@{2017-06-15} -- hwdb/[
%endif
# https://bugzilla.redhat.com/show_bug.cgi?id=1738828
Patch0001: https://github.com/keszybz/systemd/commit/464a73411c13596a130a7a8f0ac00ca728e5f69e.patch
Patch0010: https://github.com/systemd/systemd/commit/99fdffaa194cbfed659b0c1bfd0ace4bfcd2a245.patch
Patch0002: 0001-sysusers-many-different-errnos-to-express-one-condit.patch
Patch0003: 0002-basic-fs-util-add-a-version-of-chmod_and_chown-that-.patch
Patch0004: 0003-sysusers-do-not-require-proc-to-be-mounted.patch
Patch0001: use-bfq-scheduler.patch
Patch0998: 0998-resolved-create-etc-resolv.conf-symlink-at-runtime.patch
@ -166,7 +158,7 @@ Conflicts: initscripts < 9.56.1
%if 0%{?fedora}
Conflicts: fedora-release < 23-0.12
%endif
Obsoletes: timedatex < 0.6-3
Obsoletes: timedatex < 0.6-3
Provides: timedatex = 0.6-3
# https://bugzilla.redhat.com/show_bug.cgi?id=1753381
@ -256,9 +248,9 @@ Provides: udev = %{version}
Provides: udev%{_isa} = %{version}
Obsoletes: udev < 183
# https://bugzilla.redhat.com/show_bug.cgi?id=1377733#c9
Recommends: systemd-bootchart
Suggests: systemd-bootchart
# https://bugzilla.redhat.com/show_bug.cgi?id=1408878
Recommends: kbd
Requires: kbd
License: LGPLv2+
%description udev
@ -473,8 +465,6 @@ install -D -t %{buildroot}/usr/lib/systemd/ %{SOURCE3}
sed -i 's|#!/usr/bin/env python3|#!%{__python3}|' %{buildroot}/usr/lib/systemd/tests/run-unit-tests.py
install -D -t %{buildroot}/usr/lib/systemd/user-preset/ %{SOURCE13}
install -m 0644 -D -t %{buildroot}%{_rpmconfigdir}/macros.d/ %{SOURCE21}
install -m 0644 -D -t %{buildroot}%{_rpmconfigdir}/fileattrs/ %{SOURCE22}
install -m 0755 -D -t %{buildroot}%{_rpmconfigdir}/ %{SOURCE23}
@ -520,7 +510,9 @@ python3 %{SOURCE2} %buildroot <<EOF
EOF
%check
meson test -C %{_vpath_builddir} -t 3
%if %{with tests}
meson test -C %{_vpath_builddir} -t 6
%endif
#############################################################################################
@ -547,7 +539,27 @@ getent passwd systemd-resolve &>/dev/null || useradd -r -u 193 -l -g systemd-res
%post
systemd-machine-id-setup &>/dev/null || :
systemctl daemon-reexec &>/dev/null || kill -TERM 1 &>/dev/null || :
systemctl daemon-reexec &>/dev/null || {
# systemd v239 had bug #9553 in D-Bus authentication of the private socket,
# which was later fixed in v240 by #9625.
#
# The end result is that a `systemctl daemon-reexec` call as root will fail
# when upgrading from systemd v239, which means the system will not start
# running the new version of systemd after this post install script runs.
#
# To work around this issue, let's fall back to using a `kill -TERM 1` to
# re-execute the daemon when the `systemctl daemon-reexec` call fails.
#
# In order to prevent issues when the reason why the daemon-reexec failed is
# not the aforementioned bug, let's only use this fallback when:
# - we're upgrading this RPM package; and
# - we confirm that systemd is running as PID1 on this system.
if [ $1 -gt 1 ] && [ -d /run/systemd/system ] ; then
kill -TERM 1 &>/dev/null || :
fi
}
journalctl --update-catalog &>/dev/null || :
systemd-tmpfiles --create &>/dev/null || :
@ -746,6 +758,25 @@ fi
%files tests -f .file-list-tests
%changelog
* Wed Mar 18 2020 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 245.2-1
- Update to latest stable version (a few bug fixes for random things)
(#1798776, #1807485)
- Modify the downstream udev rule to use bfq to only apply to disks (#1803500)
- "Upgrade" dependency on kbd package from Recommends to Requires (#1408878)
- Move systemd-bless-boot.service and systemd-boot-system-token.service to
systemd-udev subpackage (#1807462)
- Move a bunch of other services to systemd-udev:
systemd-pstore.service, all fsck-related functionality,
systemd-volatile-root.service, systemd-verity-setup.service, and a few
other related files.
- Fix namespace-related failure when starting systemd-homed (#1807465) and
group lookup failure in nss_systemd (#1809147)
- Drop autogenerated BOOT_IMAGE= parameter from stored kernel command lines
(#1716164)
- Update daemon-reexec fallback to check whether the system is booted with
systemd as PID 1 and check whether we're upgrading before using kill -TERM
on PID 1 (#1803240)
* Tue Mar 3 2020 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 245~rc1-4
- Don't require /proc to be mounted for systemd-sysusers to work (#1807768)
@ -753,7 +784,7 @@ fi
- Revert 097537f0 to fix plymouth etc. running when they shouldn't (#1803293)
* Fri Feb 7 2020 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 245~rc1-2
- Add default 'disable *' preset for user units (#1792474),
- Add default 'disable *' preset for user units (#1792474, #1468501),
see https://fedoraproject.org/wiki/Changes/Systemd_presets_for_user_units.
- Add macro to generate "compat" scriptlets based off sysusers.d format
and autogenerate user() and group() virtual provides (#1792462),

View file

@ -20,11 +20,12 @@ new file mode 100644
index 00000000000..480b941761f
--- /dev/null
+++ b/rules.d/60-block-scheduler.rules
@@ -0,0 +1,5 @@
@@ -0,0 +1,6 @@
+# do not edit this file, it will be overwritten on update
+
+ACTION=="add", SUBSYSTEM=="block", \
+ KERNEL=="mmcblk*[0-9]|msblk*[0-9]|mspblk*[0-9]|sd*[!0-9]|sr*", \
+ ENV{DEVTYPE}=="disk", \
+ ATTR{queue/scheduler}="bfq"
diff --git a/rules.d/meson.build b/rules.d/meson.build
index b6a32ba77e2..1da958b4d46 100644