[debhelper-devel] [debhelper] 03/03: dh_usrlocal: Under R³, always use "root:staff" + mode 02775
Niels Thykier
nthykier at moszumanska.debian.org
Sun Oct 15 19:12:31 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 6137de0987a0dca64fe6c2eac2581a089891ff3f
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 7a0e1e7..18efda4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -24,6 +24,9 @@ debhelper (10.9.3) UNRELEASED; urgency=medium
"root:root".
* dh_builddeb: Pass --root-owner-group to dpkg-deb when the
rootless-build-nulling-ownership sequence is activated.
+ * dh_usrlocal: When R³ is enabled, ignore the ownership/mode
+ information on the directories. Instead, the ownership
+ "root:staff" and the mode 02775 is used instead.
-- Niels Thykier <niels at thykier.net> Sat, 14 Oct 2017 11:18:19 +0000
diff --git a/dh_usrlocal b/dh_usrlocal
index 9707f23..80ab900 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, 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 (in_rrr_legacy_mode()) {
+ 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