From dbfdea52b691b83b968bafe055778da1b55e09d4 Mon Sep 17 00:00:00 2001 From: David Sardari Date: Tue, 22 Oct 2024 16:12:00 +0200 Subject: [PATCH 1/6] emerge-webrsync: Create repo location with portage:portage ownership Bug: https://bugs.gentoo.org/707980 Signed-off-by: David Sardari --- bin/emerge-webrsync | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync index caa4986da2..d7b399b306 100755 --- a/bin/emerge-webrsync +++ b/bin/emerge-webrsync @@ -696,7 +696,11 @@ main() { handle_pgp_setup - [[ -d ${repo_location} ]] || mkdir -p "${repo_location}" + if [[ ! -d ${repo_location} ]]; then + mkdir -p "${repo_location}" + chown portage:portage "${repo_location}" + fi + if [[ ! -w ${repo_location} ]] ; then die "Repository '${repo_name}' is not writable: ${repo_location}" fi From fd3e86d82fc926414b355e3f4945746006921d7f Mon Sep 17 00:00:00 2001 From: David Sardari Date: Tue, 22 Oct 2024 16:46:39 +0200 Subject: [PATCH 2/6] emerge-webrsync: Change ownership if FEATURES=usersync Bug: https://bugs.gentoo.org/707980 Signed-off-by: David Sardari --- bin/emerge-webrsync | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync index d7b399b306..4d12e34fa3 100755 --- a/bin/emerge-webrsync +++ b/bin/emerge-webrsync @@ -698,7 +698,10 @@ main() { if [[ ! -d ${repo_location} ]]; then mkdir -p "${repo_location}" - chown portage:portage "${repo_location}" + + if has usersync ${FEATURES} ; then + chown portage:portage "${repo_location}" + fi fi if [[ ! -w ${repo_location} ]] ; then From 157a7adbe9b018ac0c422966b4eea32bb50b3345 Mon Sep 17 00:00:00 2001 From: David Sardari Date: Tue, 22 Oct 2024 17:44:37 +0200 Subject: [PATCH 3/6] emerge-webrsync: Use PORTAGE_USERNAME and PORTAGE_GRPNAME (default: portage) Both variables default to "portage" according to "man make.conf". But, this isn't the case. Therefore, I make use of Posix parameter expansion. Signed-off-by: David Sardari --- bin/emerge-webrsync | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync index 4d12e34fa3..2de8d4646b 100755 --- a/bin/emerge-webrsync +++ b/bin/emerge-webrsync @@ -83,6 +83,7 @@ eval "$("${portageq}" envvar -v DISTDIR EPREFIX FEATURES \ PORTAGE_BIN_PATH PORTAGE_CONFIGROOT PORTAGE_GPG_DIR \ PORTAGE_NICENESS PORTAGE_REPOSITORIES PORTAGE_RSYNC_EXTRA_OPTS \ PORTAGE_RSYNC_OPTS PORTAGE_TEMP_GPG_DIR PORTAGE_TMPDIR \ + PORTAGE_USERNAME PORTAGE_GRPNAME \ USERLAND http_proxy https_proxy ftp_proxy)" export http_proxy https_proxy ftp_proxy @@ -700,7 +701,7 @@ main() { mkdir -p "${repo_location}" if has usersync ${FEATURES} ; then - chown portage:portage "${repo_location}" + chown "${PORTAGE_USERNAME:-portage}":"${PORTAGE_GRPNAME:-portage}" "${repo_location}" fi fi From 866239b874a0ad5690f7aff429ed1925b447658d Mon Sep 17 00:00:00 2001 From: David Sardari Date: Tue, 22 Oct 2024 18:09:27 +0200 Subject: [PATCH 4/6] emerge-webrsync: Remove Posix parameter expansion and add "die" function Both variables default to "portage" according to "man make.conf". This statement should hold true. Therefore, the parameter expansion is removed. Signed-off-by: David Sardari --- bin/emerge-webrsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync index 2de8d4646b..785b32069d 100755 --- a/bin/emerge-webrsync +++ b/bin/emerge-webrsync @@ -701,7 +701,7 @@ main() { mkdir -p "${repo_location}" if has usersync ${FEATURES} ; then - chown "${PORTAGE_USERNAME:-portage}":"${PORTAGE_GRPNAME:-portage}" "${repo_location}" + chown "${PORTAGE_USERNAME}":"${PORTAGE_GRPNAME}" "${repo_location}" || die fi fi From edbceb2dd9ee84bd80195b4fcfa43877c1f53121 Mon Sep 17 00:00:00 2001 From: David Sardari Date: Tue, 22 Oct 2024 18:13:31 +0200 Subject: [PATCH 5/6] emerge-webrsync: Add "die" function after mkdir Signed-off-by: David Sardari --- bin/emerge-webrsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync index 785b32069d..e61940523d 100755 --- a/bin/emerge-webrsync +++ b/bin/emerge-webrsync @@ -698,7 +698,7 @@ main() { handle_pgp_setup if [[ ! -d ${repo_location} ]]; then - mkdir -p "${repo_location}" + mkdir -p "${repo_location}" || die if has usersync ${FEATURES} ; then chown "${PORTAGE_USERNAME}":"${PORTAGE_GRPNAME}" "${repo_location}" || die From dcff0553f4d7965f6cdc8d97502c038b61a85f2d Mon Sep 17 00:00:00 2001 From: David Sardari Date: Tue, 22 Oct 2024 18:31:18 +0200 Subject: [PATCH 6/6] emerge-webrsync: Remove hardcoded portage:portage Signed-off-by: David Sardari --- bin/emerge-webrsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync index e61940523d..3a9ee03984 100755 --- a/bin/emerge-webrsync +++ b/bin/emerge-webrsync @@ -411,7 +411,7 @@ sync_local() { [[ ${PORTAGE_QUIET} -eq 1 ]] || einfo "Syncing local repository ..." - local ownership="portage:portage" + local ownership="${PORTAGE_USERNAME}:${PORTAGE_GRPNAME}" if has usersync ${FEATURES} ; then case "${USERLAND}" in BSD)