[debhelper-devel] [debhelper] 02/04: dh_usrlocal: Under R³, always use "root:staff" + mode 02775

Niels Thykier nthykier at moszumanska.debian.org
Wed Oct 18 21:04:51 UTC 2017


This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch support-rrr
in repository debhelper.

commit e91dbbfd5e3fcda5b1950a9bc9fcd9d1f326b167
Author: Niels Thykier <niels at thykier.net>
Date:   Sun Oct 15 14:39:25 2017 +0000

    dh_usrlocal: Under R³, always use "root:staff" + mode 02775
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 debian/changelog |  3 +++
 dh_usrlocal      | 39 +++++++++++++++++++++++++--------------
 2 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 7d610e3..b9f7ef5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -19,6 +19,9 @@ debhelper (10.9.3) UNRELEASED; urgency=medium
     R³ contains the "debhelper/upstream-make-install" keyword.
   * dh_builddeb: Pass --root-owner-group to dpkg-deb in packages
     with R³ (except for "binary-targets").
+  * dh_usrlocal: When R³ is enabled (and not "binary-targets"),
+    ignore the ownership/mode information on the directories.
+    Instead, the ownership "root:staff" and the mode 02775 is used.
 
  -- Niels Thykier <niels at thykier.net>  Sat, 14 Oct 2017 11:18:19 +0000
 
diff --git a/dh_usrlocal b/dh_usrlocal
index 9707f23..cd3dfbd 100755
--- a/dh_usrlocal
+++ b/dh_usrlocal
@@ -1,5 +1,7 @@
 #!/usr/bin/perl
 
+=encoding UTF-8
+
 =head1 NAME
 
 dh_usrlocal - migrate usr/local directories to maintainer scripts
@@ -31,12 +33,15 @@ snippets are inserted into the maintainer scripts by B<dh_installdeb>. See
 L<dh_installdeb(1)> for an explanation of debhelper maintainer script
 snippets.
 
-If the directories found in the build tree have unusual owners, groups, or
-permissions, then those values will be preserved in the directories made by
-the F<postinst> script. However, as a special exception, if a directory is owned
-by root.root, it will be treated as if it is owned by root.staff and is mode
-2775. This is useful, since that is the group and mode policy recommends for
-directories in F</usr/local>.
+In a R³-enabled build (and not set to "binary-targets"), the
+directories in F</usr/local> will have ownership root:staff and the
+mode will be 02775.  These values have been chosen to comply with the
+recommendations of the Debian policy for directories in F</usr/local>.
+
+In R³ legacy mode, the owners, groups and permissions will be preserved with
+one exception.  If the directory is owned by root:root, then ownership will
+be reset to root:staff and mode will be reset to 02775. This is useful, since
+that is the group and mode policy recommends for directories in F</usr/local>.
 
 =head1 OPTIONS
 
@@ -74,16 +79,22 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		      wanted => sub {
 			my $fn = $File::Find::name;
 			if (-d $fn) {
-				my $stat = stat $fn;
-				my $user = getpwuid $stat->uid;
-				my $group = getgrgid $stat->gid;
-				my $mode = sprintf "%04lo", ($stat->mode & 07777);
-
-				if ($stat->uid == 0 && $stat->gid == 0) {
-					$group = 'staff';
-					$mode = '2775';
+				my $user = 'root';
+				my $group = 'group';
+				my $mode = '02775';
+				if (not should_use_root()) {
+					my $stat = stat $fn;
+					$user = getpwuid $stat->uid;
+					$group = getgrgid $stat->gid;
+					$mode = sprintf "%04lo", ($stat->mode & 07777);
+					if ($stat->uid == 0 && $stat->gid == 0) {
+						$group = 'staff';
+						$mode = '02775';
+					}
 				}
 
+
+
 				$fn =~ s!^\Q$tmp\E!!;
 				return if $fn eq '/usr/local';
 				

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git




More information about the debhelper-devel mailing list