chiark / gitweb /
dgit-repos-policy-debian: Fix mode calculation
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 4 May 2015 16:23:37 +0000 (17:23 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 31 May 2015 10:54:10 +0000 (11:54 +0100)
infra/dgit-repos-policy-debian

index 2e0bcc79af7034e9a253a3f532ad5d3003cb1bba..ce98cd72e46bfa104cf57182037dfb09d8f8a51b 100755 (executable)
@@ -376,7 +376,10 @@ END
            my $oldmode = ((stat _)[2]);
            my $oldwrites = $oldmode & 0222;
            # remove r and x bits which have corresponding w bits clear
-           my $newmode = $oldmode & ($oldwrites << 1) & ($oldwrites > 1);
+           my $newmode = $oldmode &
+               (~0555 | ($oldwrites << 1) | ($oldwrites >> 1));
+           printdebug sprintf "chmod %#o (was %#o) %s\n",
+               $newmode, $oldmode, $freshrepo;
            chmod $newmode, $freshrepo or die $!;
        }
     }