Control: tags -1 patch

Chris,

Thanks for this. I think you (and the new perl operator precedence warning) have
uncovered a longstanding bug.

Does this patch fix it for you?

Mark

commit 897ed6969cce556ebe48c81996e2dafc10b4b189
Author: Mark Hindley <[email protected]>
Date:   Mon Aug 17 17:07:21 2026 +0100

    Fix spurious negation operator before $) variable.
    
    Longstanding bug exposed by new operator precedence warning in perl 5.42:
    
      Possible precedence problem between ! and pattern match (m//) at
      /usr/share/apt-cacher/apt-cacher-cleanup.pl line 114.
    
    $) is a space separated string of group numbers. Intended test is whether 
first
    group is 0, i.e. getegid() is root.
    
    Closes: #1143251

diff --git a/apt-cacher-cleanup.pl b/apt-cacher-cleanup.pl
index 3e229dd..cec7e71 100755
--- a/apt-cacher-cleanup.pl
+++ b/apt-cacher-cleanup.pl
@@ -111,7 +111,7 @@ check_install(); # Before we give up rights
 
 # change uid and gid if root and another user/group configured
 if (($cfg->{user} && $cfg->{user} !~ 'root' && !$> )
-    || ($cfg->{group} && $cfg->{group} !~ 'root' && !$) =~ /^0/)){
+    || ($cfg->{group} && $cfg->{group} !~ 'root' && $) =~ /^0/)){
     printmsg("Invoked as root, changing to $cfg->{user}:$cfg->{group} and 
re-execing.\n");
     setup_ownership($cfg);
     # Rexec to ensure /proc/self/fd ownerships correct which are needed for red

Reply via email to