From 6ae0791191df0253b35c8f062f9536e05b4f9f52 Mon Sep 17 00:00:00 2001 From: Flatcar Buildbot Date: Mon, 2 Feb 2026 07:27:23 +0000 Subject: [PATCH] eclass/fcaps: Sync with Gentoo It's from Gentoo commit 537f565690024195dab4e9973189ab648dc3e5cc. Signed-off-by: Flatcar Buildbot --- .../portage-stable/eclass/fcaps.eclass | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/sdk_container/src/third_party/portage-stable/eclass/fcaps.eclass b/sdk_container/src/third_party/portage-stable/eclass/fcaps.eclass index 81c1ca6236..0bbfc86771 100644 --- a/sdk_container/src/third_party/portage-stable/eclass/fcaps.eclass +++ b/sdk_container/src/third_party/portage-stable/eclass/fcaps.eclass @@ -87,9 +87,8 @@ esac # The caps mode is used to set the permission on the file if capabilities # were properly set on the file. No change is applied by default. # -# If the system is unable to set capabilities, it will use the specified user, -# group, and mode. The user and group default to 0. If mode is unspecified, no -# change is applied. +# If capabilities are not sucessfully applied, the permissions on the file are +# updated according to the owner, group, and mode options, if provided. # # For example, "-m u+s" may be used to enable suid as a fallback when file caps # are unavailable. This should be used with care, typically when the @@ -103,8 +102,8 @@ fcaps() { fi # Process the user options first. - local owner='0' - local group='0' + local owner= + local group= local mode= local caps_mode= @@ -183,12 +182,12 @@ fcaps() { fi fi - # If we're still here, setcaps failed. + # If we're still here, setcaps failed or filecaps are disabled. + if [[ -n ${owner} || -n ${group} ]]; then + debug-print "${FUNCNAME}: setting owner on '${file}'" + chown "${owner}${group:+:}${group}" "${file}" || die + fi if [[ -n ${mode} ]]; then - if [[ -n ${owner} || -n ${group} ]]; then - debug-print "${FUNCNAME}: setting owner on '${file}'" - chown "${owner}:${group}" "${file}" || die - fi debug-print "${FUNCNAME}: setting mode on '${file}'" chmod ${mode} "${file}" || die fi