Hi,

I would suggest using

chown --no-dereference instead of chown in the scripts for pre-existing files 
and replacing

                if mkdir -p /usr/local/share/asterisk/sounds 2>/dev/null ; then
                        chown root:staff /usr/local/share/asterisk/sounds
                        chmod 2775 /usr/local/share/asterisk/sounds
                fi

by the following command

                install -d -m 2775 -o root -g staff /usr/local/share/asterisk/

I prepared a pull request at
https://salsa.debian.org/pkg-voip-team/asterisk/-/merge_requests/6/diffs
(for convenience I also attach the same changes to this mail).

I checked whether the produced asterisk package still chowns files in 
/etc/asterisk and does no
longer affect files symlinked there.

Kind regards,
Benedikt
        
-- 
Benedikt Wildenhain, M.Sc., Research Assistant - Embedded Systems
Hochschule Bochum - Bochum University of Applied Sciences
Campus Velbert/Heiligenhaus - https://www.hs-bochum.de/cvh/
Kettwiger Str. 20, D-42579 Heiligenhaus, Room 2-37, Tel +49 2056 5848-
7744
diff --git a/debian/asterisk-config-custom b/debian/asterisk-config-custom
index 8aeedfbb..40d5a672 100644
--- a/debian/asterisk-config-custom
+++ b/debian/asterisk-config-custom
@@ -261,12 +261,12 @@ case "\$1" in
 	dpkg-query -W -f='\${Conffiles}\n' asterisk-config-custom 2>/dev/null | \\
 	  sed -nr -e 's; (/etc/asterisk/.*) [0-9a-f]*;\1;p' | \\
 	while read conffile; do
-		chown asterisk: \${conffile} 2>/dev/null
+		chown --no-dereference asterisk: \${conffile} 2>/dev/null
 	done
 
 	# handle them in the end with a glob since it's way faster
 	dpkg-statoverride --quiet --list '/etc/asterisk/*' | while read STAT; do
-		chown \`echo \$STAT | cut -d' ' -f 1,2,4 | sed 's/ /:/'\` \\
+		chown --no-dereference \`echo \$STAT | cut -d' ' -f 1,2,4 | sed 's/ /:/'\` \\
 			2>/dev/null
 	done
 
diff --git a/debian/asterisk.postinst b/debian/asterisk.postinst
index b7fe53d9..77792f37 100644
--- a/debian/asterisk.postinst
+++ b/debian/asterisk.postinst
@@ -37,7 +37,7 @@ case "$1" in
 	     /var/lib/asterisk \
 	     -type d | while read dir; do
 		if ! dpkg-statoverride --list "$dir" > /dev/null ; then
-			chown asterisk: "$dir"
+			chown --no-dereference asterisk: "$dir"
 		fi
 	done 
 	
@@ -47,24 +47,21 @@ case "$1" in
 	# we are doing the same for subdirectories, since we are not shipping
 	# any and it's supposed to be user-modifiable
 	if ! dpkg-statoverride --list "/etc/asterisk" > /dev/null ; then
-		chown asterisk: /etc/asterisk
+		chown --no-dereference asterisk: /etc/asterisk
 	fi
 
 	# these hold some sensitive information (e.g. monitor, voicemail etc.)
 	find /var/spool/asterisk /var/cache/asterisk -type d \
 		| while read dir; do
 		if ! dpkg-statoverride --list "$dir" > /dev/null ; then
-			chown asterisk: "$dir"
+			chown --no-dereference asterisk: "$dir"
 			chmod 750 "$dir"
 		fi
 	done
 
 	# Create /usr/local directory; policy 9.1.2
 	if [ ! -e /usr/local/share/asterisk/sounds ]; then
-		if mkdir -p /usr/local/share/asterisk/sounds 2>/dev/null ; then
-			chown root:staff /usr/local/share/asterisk/sounds
-			chmod 2775 /usr/local/share/asterisk/sounds
-		fi
+		install -d -m 2775 -o root -g staff /usr/local/share/asterisk/sounds/
 	fi
 
 	### this is done here in case asterisk-config was installed/upgraded first
@@ -81,12 +78,12 @@ case "$1" in
 	dpkg-query -W -f='${Conffiles}\n' $ASTERISK_CONFIG 2>/dev/null | \
 	  sed -nr -e 's; (/etc/asterisk/.*) [0-9a-f]*;\1;p' | \
 	while read conffile; do
-		chown asterisk: "$conffile" 2>/dev/null
+		chown --no-dereference asterisk: "$conffile" 2>/dev/null
 	done
 
 	# handle them in the end with a glob since it's way faster
 	dpkg-statoverride --quiet --list '/etc/asterisk/*' | while read STAT; do
-		chown `echo $STAT | cut -d' ' -f 1,2,4 | sed 's/ /:/'` \
+		chown --no-dereference `echo $STAT | cut -d' ' -f 1,2,4 | sed 's/ /:/'` \
 			2>/dev/null
 	done
 
diff --git a/debian/changelog b/debian/changelog
index c8d69c4b..5f46f2f8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-asterisk (1:22.11.0-rc2+dfsg+~cs6.17.60671434-2) UNRELEASED; urgency=medium
+asterisk (1:22.11.0-rc2+dfsg+~cs6.17.60671434-2~2.gbp09f9ef) UNRELEASED; urgency=medium
 
   [ Martin Rampersad ]
   * add patch 0001 to fix pjproject SDP parser out-of-bounds write
@@ -14,7 +14,12 @@ asterisk (1:22.11.0-rc2+dfsg+~cs6.17.60671434-2) UNRELEASED; urgency=medium
     CVE-2026-57164 CVE-2026-57165 CVE-2026-84975
     closes: bug#1146891,1148482
 
- -- Martin Rampersad <[email protected]>  Sat, 17 Oct 2026 14:21:37 -0400
+  [ Benedikt Wildenhain ]
+
+  * Do let chown modify targets of symlinks in postinst scripts
+    closes: bug#1156144
+
+ -- Benedikt Wildenhain <[email protected]>  Wed, 02 Dec 2026 18:18:15 +0100
 
 asterisk (1:22.11.0-rc2+dfsg+~cs6.17.60671434-1) experimental; urgency=medium
 

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to