]> git.ipfire.org Git - pakfire.git/commitdiff
strip: Apply hack to preserve capabilities
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 19 Mar 2023 19:53:44 +0000 (19:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 19 Mar 2023 19:53:44 +0000 (19:53 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/scripts/strip

index 6fa9aaf07f216a3edd1dde76c96f4cbc8be33c94..3d82beb5a066514b5ed7017dc65c0ed3974c7e74 100644 (file)
@@ -80,6 +80,10 @@ process_file() {
                fi
        fi
 
+       # Fetch any capabilities
+       local capabilities="$(getfattr --no-dereference --name="security.capability" \
+               --absolute-names --dump "${file}" 2>/dev/null)"
+
        # Extract sources
        if ! extract_sources "${file}"; then
                error "Could not extract sources from ${file}"
@@ -143,6 +147,11 @@ process_file() {
        cat "${tempfile}" > "${file}"
        rm -f "${tempfile}"
 
+       # Restore capabilities
+       if [ -n "${capabilities}" ]; then
+               setfattr --no-dereference --restore=<(echo "${capabilities}")
+       fi
+
        return 0
 }