commit: b25dd2a6dc1f1df46bcc98ee7bf80648f1850651 Author: Piotr Karbowski <slashbeast <AT> gentoo <DOT> org> AuthorDate: Sat Jun 10 14:50:36 2023 +0000 Commit: Piotr Karbowski <slashbeast <AT> gentoo <DOT> org> CommitDate: Sat Jun 10 14:54:55 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b25dd2a6
sys-auth/elogind: 252.9 version bump. - Tested build with musl on hardened profile (+selinux). - Tested build, tests and runtime with glibc. - The musl patches sourced out of Alpine Linux. Closes: https://bugs.gentoo.org/907976 Signed-off-by: Piotr Karbowski <slashbeast <AT> gentoo.org> sys-auth/elogind/Manifest | 1 + sys-auth/elogind/elogind-252.9.ebuild | 167 +++++++++++++++++++++ .../files/elogind-252.9-musl-getdents.patch | 35 +++++ .../elogind/files/elogind-252.9-musl-gshadow.patch | 14 ++ .../files/elogind-252.9-musl-more-strerror_r.patch | 44 ++++++ .../files/elogind-252.9-musl-rlim-max.patch | 13 ++ .../files/elogind-252.9-musl-sigfillset.patch | 12 ++ .../elogind/files/elogind-252.9-musl-statx.patch | 26 ++++ .../files/elogind-252.9-musl-strerror_r.patch | 89 +++++++++++ sys-auth/elogind/files/elogind-252.9-nodocs.patch | 28 ++++ 10 files changed, 429 insertions(+) diff --git a/sys-auth/elogind/Manifest b/sys-auth/elogind/Manifest index 871cbc88d9f3..3ce9fb1e8ab7 100644 --- a/sys-auth/elogind/Manifest +++ b/sys-auth/elogind/Manifest @@ -1 +1,2 @@ DIST elogind-246.10.tar.gz 1559256 BLAKE2B 17a8146ee08c8ccf167f25d89b1d4525050ed0b0baaad0d36924ad3c40ffc820ef1528b33557cf285ad06c9ac9c440137428c5a235a2acf563e56f2f8f07e208 SHA512 9db0f068ed94ec07bab4d764ccb38840af3d05a4b7c9c539721906f5381b509cb9a3cbfb0453a978210d306136368de6162578c600d522416ef2a7ac1b9f348b +DIST elogind-252.9.tar.gz 1922777 BLAKE2B dd566125e407b3479a44b007890f97c9c87a325b3fed2d3505499d2163f113affd998e14b1c1fc50b9b86b0d155b51dae344dcc1cddafb6a48c631d0a0f00c9a SHA512 eed620cbc2f03bfeae6a80c9a421c21d3293fa40adffb96c7e4d86508c06712041f6623fb2bac15ecbb85faca4b5674ea6423b3067840809fb27d023fd9e5ffd diff --git a/sys-auth/elogind/elogind-252.9.ebuild b/sys-auth/elogind/elogind-252.9.ebuild new file mode 100644 index 000000000000..56680f91dd18 --- /dev/null +++ b/sys-auth/elogind/elogind-252.9.ebuild @@ -0,0 +1,167 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +if [[ ${PV} = *9999* ]]; then + EGIT_BRANCH="v241-stable" + EGIT_REPO_URI="https://github.com/elogind/elogind.git" + inherit git-r3 +else + SRC_URI="https://github.com/${PN}/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz" + KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86" +fi + +inherit linux-info meson pam udev xdg-utils + +DESCRIPTION="The systemd project's logind, extracted to a standalone package" +HOMEPAGE="https://github.com/elogind/elogind" + +LICENSE="CC0-1.0 LGPL-2.1+ public-domain" +SLOT="0" +IUSE="+acl audit +cgroup-hybrid debug doc +pam +policykit selinux test" +RESTRICT="!test? ( test )" + +BDEPEND=" + app-text/docbook-xml-dtd:4.2 + app-text/docbook-xml-dtd:4.5 + app-text/docbook-xsl-stylesheets + dev-util/gperf + virtual/pkgconfig +" +DEPEND=" + audit? ( sys-process/audit ) + sys-apps/util-linux + sys-libs/libcap + virtual/libudev:= + acl? ( sys-apps/acl ) + pam? ( sys-libs/pam ) + selinux? ( sys-libs/libselinux ) +" +RDEPEND="${DEPEND} + !sys-apps/systemd +" +PDEPEND=" + sys-apps/dbus + policykit? ( sys-auth/polkit ) +" + +DOCS=( README.md) + +PATCHES=( + "${FILESDIR}/${P}-nodocs.patch" +) + +pkg_setup() { + local CONFIG_CHECK="~CGROUPS ~EPOLL ~INOTIFY_USER ~SIGNALFD ~TIMERFD" + + use kernel_linux && linux-info_pkg_setup +} + +src_prepare() { + if use elibc_musl; then + # Some of musl-specific patches break build on the + # glibc systems (like getdents), therefore those are + # only used when the build is done for musl. + PATCHES+=( + "${FILESDIR}/${P}-musl-sigfillset.patch" + "${FILESDIR}/${P}-musl-statx.patch" + "${FILESDIR}/${P}-musl-rlim-max.patch" + "${FILESDIR}/${P}-musl-getdents.patch" + "${FILESDIR}/${P}-musl-gshadow.patch" + "${FILESDIR}/${P}-musl-strerror_r.patch" + "${FILESDIR}/${P}-musl-more-strerror_r.patch" + ) + fi + + default + xdg_environment_reset +} + +src_configure() { + if use cgroup-hybrid; then + cgroupmode="hybrid" + else + cgroupmode="unified" + fi + + local emesonargs=( + -Ddocdir="${EPREFIX}/usr/share/doc/${PF}" + -Dhtmldir="${EPREFIX}/usr/share/doc/${PF}/html" + -Dpamlibdir=$(getpam_mod_dir) + -Dudevrulesdir="${EPREFIX}$(get_udevdir)"/rules.d + --libdir="${EPREFIX}"/usr/$(get_libdir) + -Drootlibdir="${EPREFIX}"/$(get_libdir) + -Drootlibexecdir="${EPREFIX}"/$(get_libdir)/elogind + -Drootprefix="${EPREFIX}/" + -Dbashcompletiondir="${EPREFIX}/usr/share/bash-completion/completions" + -Dman=auto + -Dsmack=true + -Dcgroup-controller=openrc + -Ddefault-hierarchy=${cgroupmode} + -Ddefault-kill-user-processes=false + -Dacl=$(usex acl true false) + -Daudit=$(usex audit true false) + --buildtype $(usex debug debug release) + -Dhtml=$(usex doc auto false) + -Dpam=$(usex pam true false) + -Dselinux=$(usex selinux true false) + -Dtests=$(usex test true false) + -Dutmp=$(usex elibc_musl false true) + -Dmode=release + ) + + meson_src_configure +} + +src_install() { + meson_src_install + + newinitd "${FILESDIR}"/${PN}.init-r1 ${PN} + + sed -e "s|@libdir@|$(get_libdir)|" "${FILESDIR}"/${PN}.conf.in > ${PN}.conf || die + newconfd ${PN}.conf ${PN} +} + +pkg_postinst() { + if ! use pam; then + ewarn "${PN} will not be managing user logins/seats without USE=\"pam\"!" + ewarn "In other words, it will be useless for most applications." + ewarn + fi + if ! use policykit; then + ewarn "loginctl will not be able to perform privileged operations without" + ewarn "USE=\"policykit\"! That means e.g. no suspend or hibernate." + ewarn + fi + if [[ "$(rc-config list boot | grep elogind)" != "" ]]; then + elog "elogind is currently started from boot runlevel." + elif [[ "$(rc-config list default | grep elogind)" != "" ]]; then + ewarn "elogind is currently started from default runlevel." + ewarn "Please remove elogind from the default runlevel and" + ewarn "add it to the boot runlevel by:" + ewarn "# rc-update del elogind default" + ewarn "# rc-update add elogind boot" + else + elog "elogind is currently not started from any runlevel." + elog "You may add it to the boot runlevel by:" + elog "# rc-update add elogind boot" + elog + elog "Alternatively, you can leave elogind out of any" + elog "runlevel. It will then be started automatically" + if use pam; then + elog "when the first service calls it via dbus, or" + elog "the first user logs into the system." + else + elog "when the first service calls it via dbus." + fi + fi + + for version in ${REPLACING_VERSIONS}; do + if ver_test "${version}" -lt 252.9; then + elog "Starting with release 252.9 the sleep configuration is now done" + elog "in the /etc/elogind/sleep.conf. Should you use non-default sleep" + elog "configuration remember to migrate those to new configuration file." + fi + done +} diff --git a/sys-auth/elogind/files/elogind-252.9-musl-getdents.patch b/sys-auth/elogind/files/elogind-252.9-musl-getdents.patch new file mode 100644 index 000000000000..35b7670787a0 --- /dev/null +++ b/sys-auth/elogind/files/elogind-252.9-musl-getdents.patch @@ -0,0 +1,35 @@ +From dab02796780f00d689cc1c7a0ba81abe7c5f28d0 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Fri, 21 Jan 2022 15:15:11 -0800 +Subject: [PATCH] pass correct parameters to getdents64 + +Fixes +../git/src/basic/recurse-dir.c:57:40: error: incompatible pointer types passing 'uint8_t *' (aka 'unsigned char *') to parameter of type 'struct dirent *' [-Werror,-Wincompatible-pointer-types] + n = getdents64(dir_fd, (uint8_t*) de->buffer + de->buffer_size, bs - de->buffer_size); + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +../git/src/basic/stat-util.c:102:28: error: incompatible pointer types passing 'union (unnamed union at ../git/src/basic/stat-util.c:78:9) *' to parameter of type 'struct dirent *' [-Werror,-Wincompatible-pointer-types] + n = getdents64(fd, &buffer, sizeof(buffer)); + ^~~~~~~ + +Upstream-Status: Inappropriate [musl specific] +Signed-off-by: Khem Raj <[email protected]> +Signed-off-by: Jiaqing Zhao <[email protected]> + +--- + src/basic/recurse-dir.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/basic/recurse-dir.c b/src/basic/recurse-dir.c +index d16ca98..31f6154 100644 +--- a/src/basic/recurse-dir.c ++++ b/src/basic/recurse-dir.c +@@ -54,7 +54,7 @@ int readdir_all(int dir_fd, + bs = MIN(MALLOC_SIZEOF_SAFE(de) - offsetof(DirectoryEntries, buffer), (size_t) SSIZE_MAX); + assert(bs > de->buffer_size); + +- n = getdents64(dir_fd, (uint8_t*) de->buffer + de->buffer_size, bs - de->buffer_size); ++ n = getdents(dir_fd, (struct dirent*)((uint8_t*) de->buffer + de->buffer_size), bs - de->buffer_size); + if (n < 0) + return -errno; + if (n == 0) diff --git a/sys-auth/elogind/files/elogind-252.9-musl-gshadow.patch b/sys-auth/elogind/files/elogind-252.9-musl-gshadow.patch new file mode 100644 index 000000000000..95613cb66f6e --- /dev/null +++ b/sys-auth/elogind/files/elogind-252.9-musl-gshadow.patch @@ -0,0 +1,14 @@ +just like the other part it's already patched in, not actually used +-- +diff --git a/src/shared/user-record-nss.h b/src/shared/user-record-nss.h +index 7a41be7..3a970a6 100644 +--- a/src/shared/user-record-nss.h ++++ b/src/shared/user-record-nss.h +@@ -2,7 +2,6 @@ + #pragma once + + #include <grp.h> +-#include <gshadow.h> + #include <pwd.h> + #include <shadow.h> + diff --git a/sys-auth/elogind/files/elogind-252.9-musl-more-strerror_r.patch b/sys-auth/elogind/files/elogind-252.9-musl-more-strerror_r.patch new file mode 100644 index 000000000000..3cfafae4cbfe --- /dev/null +++ b/sys-auth/elogind/files/elogind-252.9-musl-more-strerror_r.patch @@ -0,0 +1,44 @@ +Patch-Source: https://github.com/chimera-linux/cports/blob/6ff62886181bc1325a1431157a80993497fd561b/main/udev/patches/0001-errno-util-Make-STRERROR-portable-for-musl.patch +-- +From f66b5c802ce0a3310f5580cfc1b02446f8087568 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Mon, 23 Jan 2023 23:39:46 -0800 +Subject: [PATCH] errno-util: Make STRERROR portable for musl + +Sadly, systemd has decided to use yet another GNU extention in a macro +lets make this such that we can use XSI compliant strerror_r() for +non-glibc hosts + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Khem Raj <[email protected]> +--- + src/basic/errno-util.h | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/src/basic/errno-util.h b/src/basic/errno-util.h +index 091f99c590..eb5c1f9961 100644 +--- a/src/basic/errno-util.h ++++ b/src/basic/errno-util.h +@@ -14,8 +14,16 @@ + * https://stackoverflow.com/questions/34880638/compound-literal-lifetime-and-if-blocks + * + * Note that we use the GNU variant of strerror_r() here. */ +-#define STRERROR(errnum) strerror_r(abs(errnum), (char[ERRNO_BUF_LEN]){}, ERRNO_BUF_LEN) +- ++static inline const char * STRERROR(int errnum); ++ ++static inline const char * STRERROR(int errnum) { ++#ifdef __GLIBC__ ++ return strerror_r(abs(errnum), (char[ERRNO_BUF_LEN]){}, ERRNO_BUF_LEN); ++#else ++ static __thread char buf[ERRNO_BUF_LEN]; ++ return strerror_r(abs(errnum), buf, ERRNO_BUF_LEN) ? "unknown error" : buf; ++#endif ++} + /* A helper to print an error message or message for functions that return 0 on EOF. + * Note that we can't use ({ … }) to define a temporary variable, so errnum is + * evaluated twice. */ +-- +2.39.1 + diff --git a/sys-auth/elogind/files/elogind-252.9-musl-rlim-max.patch b/sys-auth/elogind/files/elogind-252.9-musl-rlim-max.patch new file mode 100644 index 000000000000..de8f290f16b8 --- /dev/null +++ b/sys-auth/elogind/files/elogind-252.9-musl-rlim-max.patch @@ -0,0 +1,13 @@ +diff --git a/src/basic/rlimit-util.c b/src/basic/rlimit-util.c +index afd74ac..3a731f4 100644 +--- a/src/basic/rlimit-util.c ++++ b/src/basic/rlimit-util.c +@@ -44,7 +44,7 @@ int setrlimit_closest(int resource, const struct rlimit *rlim) { + fixed.rlim_max == highest.rlim_max) + return 0; + +- log_debug("Failed at setting rlimit " RLIM_FMT " for resource RLIMIT_%s. Will attempt setting value " RLIM_FMT " instead.", rlim->rlim_max, rlimit_to_string(resource), fixed.rlim_max); ++ log_debug("Failed at setting rlimit %ju for resource RLIMIT_%s. Will attempt setting value %ju instead.", (uintmax_t)rlim->rlim_max, rlimit_to_string(resource), (uintmax_t)fixed.rlim_max); + + return RET_NERRNO(setrlimit(resource, &fixed)); + } diff --git a/sys-auth/elogind/files/elogind-252.9-musl-sigfillset.patch b/sys-auth/elogind/files/elogind-252.9-musl-sigfillset.patch new file mode 100644 index 000000000000..787eeac9bc80 --- /dev/null +++ b/sys-auth/elogind/files/elogind-252.9-musl-sigfillset.patch @@ -0,0 +1,12 @@ +diff --git a/src/basic/async.h b/src/basic/async.h +index cf80acf..d22e77d 100644 +--- a/src/basic/async.h ++++ b/src/basic/async.h +@@ -2,6 +2,7 @@ + #pragma once + + #include <sys/types.h> ++#include <signal.h> + + #include "macro.h" + diff --git a/sys-auth/elogind/files/elogind-252.9-musl-statx.patch b/sys-auth/elogind/files/elogind-252.9-musl-statx.patch new file mode 100644 index 000000000000..60a8942161df --- /dev/null +++ b/sys-auth/elogind/files/elogind-252.9-musl-statx.patch @@ -0,0 +1,26 @@ +diff --git a/src/basic/mountpoint-util.c b/src/basic/mountpoint-util.c +index ab8744b..59ff466 100644 +--- a/src/basic/mountpoint-util.c ++++ b/src/basic/mountpoint-util.c +@@ -11,7 +11,7 @@ + //#include "filesystems.h" + #include "fs-util.h" + #include "missing_stat.h" +-//#include "missing_syscall.h" ++#include "missing_syscall.h" + //#include "mkdir.h" + #include "mountpoint-util.h" + #include "nulstr-util.h" +diff --git a/src/basic/stat-util.c b/src/basic/stat-util.c +index d8e0693..f8324ed 100644 +--- a/src/basic/stat-util.c ++++ b/src/basic/stat-util.c +@@ -18,7 +18,7 @@ + #include "macro.h" + //#include "missing_fs.h" + #include "missing_magic.h" +-//#include "missing_syscall.h" ++#include "missing_syscall.h" + #include "nulstr-util.h" + //#include "parse-util.h" + #include "stat-util.h" diff --git a/sys-auth/elogind/files/elogind-252.9-musl-strerror_r.patch b/sys-auth/elogind/files/elogind-252.9-musl-strerror_r.patch new file mode 100644 index 000000000000..04570f5fb3f4 --- /dev/null +++ b/sys-auth/elogind/files/elogind-252.9-musl-strerror_r.patch @@ -0,0 +1,89 @@ +fix strerror_r use instead of whatever this define is meant to be doing +-- +From 0542d27ebbb250c09bdcfcf9f2ea3d27426fe522 Mon Sep 17 00:00:00 2001 +From: Chen Qi <[email protected]> +Date: Tue, 10 Jul 2018 15:40:17 +0800 +Subject: [PATCH] distinguish XSI-compliant strerror_r from GNU-specifi + strerror_r + +XSI-compliant strerror_r and GNU-specifi strerror_r are different. + + int strerror_r(int errnum, char *buf, size_t buflen); + /* XSI-compliant */ + + char *strerror_r(int errnum, char *buf, size_t buflen); + /* GNU-specific */ + +We need to distinguish between them. Otherwise, we'll get an int value +assigned to (char *) variable, resulting in segment fault. + +Upstream-Status: Inappropriate [musl specific] + +Signed-off-by: Chen Qi <[email protected]> + +--- + src/libsystemd/sd-bus/bus-error.c | 5 +++++ + src/libsystemd/sd-journal/journal-send.c | 5 +++++ + 2 files changed, 10 insertions(+) + +diff --git a/src/basic/musl_missing.h b/src/basic/musl_missing.h +index 41c66c9..a2e1d7e 100644 +--- a/src/basic/musl_missing.h ++++ b/src/basic/musl_missing.h +@@ -26,8 +26,6 @@ void elogind_set_program_name(const char* pcall); + #include <unistd.h> + #include <pthread.h> /* for pthread_atfork */ + +-#define strerror_r(e, m, k) (strerror_r(e, m, k) < 0 ? strdup("strerror_r() failed") : m); +- + /* + * Possibly TODO according to http://man7.org/linux/man-pages/man3/getenv.3.html + * + test if the process's effective user ID does not match its real user ID or +diff --git a/src/libelogind/sd-bus/bus-error.c b/src/libelogind/sd-bus/bus-error.c +index 4d687cf..1459396 100644 +--- a/src/libelogind/sd-bus/bus-error.c ++++ b/src/libelogind/sd-bus/bus-error.c +@@ -409,7 +409,12 @@ static void bus_error_strerror(sd_bus_error *e, int error) { + return; + + errno = 0; ++#ifndef __GLIBC__ ++ strerror_r(error, m, k); ++ x = m; ++#else + x = strerror_r(error, m, k); ++#endif + if (errno == ERANGE || strlen(x) >= k - 1) { + free(m); + k *= 2; +@@ -594,8 +599,12 @@ const char* _bus_error_message(const sd_bus_error *e, int error, char buf[static + + if (e && e->message) + return e->message; +- ++#ifndef __GLIBC__ ++ strerror_r(abs(error), buf, ERRNO_BUF_LEN); ++ return buf; ++#else + return strerror_r(abs(error), buf, ERRNO_BUF_LEN); ++#endif + } + + static bool map_ok(const sd_bus_error_map *map) { +diff --git a/src/libelogind/sd-journal/journal-send.c b/src/libelogind/sd-journal/journal-send.c +index 4010197..1d49868 100644 +--- a/src/libelogind/sd-journal/journal-send.c ++++ b/src/libelogind/sd-journal/journal-send.c +@@ -444,7 +444,12 @@ static int fill_iovec_perror_and_send(const char *message, int skip, struct iove + char* j; + + errno = 0; ++#ifndef __GLIBC__ ++ strerror_r(_saved_errno_, buffer + 8 + k, n - 8 - k); ++ j = buffer + 8 + k; ++#else + j = strerror_r(_saved_errno_, buffer + 8 + k, n - 8 - k); ++#endif + if (errno == 0) { + char error[STRLEN("ERRNO=") + DECIMAL_STR_MAX(int) + 1]; + diff --git a/sys-auth/elogind/files/elogind-252.9-nodocs.patch b/sys-auth/elogind/files/elogind-252.9-nodocs.patch new file mode 100644 index 000000000000..4be92f95fa24 --- /dev/null +++ b/sys-auth/elogind/files/elogind-252.9-nodocs.patch @@ -0,0 +1,28 @@ +diff --git a/meson.build b/meson.build +index 694a2fd97..9b97cafef 100644 +--- a/meson.build ++++ b/meson.build +@@ -4528,15 +4528,11 @@ subdir('shell-completion/zsh') + # install_dir : xinitrcdir) + # endif + #endif // 0 +-install_data('LICENSE.GPL2', +- 'LICENSE.LGPL2.1', + #if 0 /// elogind has upgraded to markdown, and the NEWS file is useless + # 'NEWS', + # 'README', + #else // 0 +- 'README.md', + #endif // 0 +- 'docs/CODING_STYLE.md', + #if 0 /// irrelevant for elogind + # 'docs/DISTRO_PORTING.md', + # 'docs/ENVIRONMENT.md', +@@ -4545,7 +4541,6 @@ install_data('LICENSE.GPL2', + # 'docs/TRANSLATORS.md', + # 'docs/UIDS-GIDS.md', + #endif // 0 +- install_dir : docdir) + + #if 0 /// irrelevant for elogind + # install_subdir('LICENSES',
