5 dh_fixperms - fix permissions of files in package build directories
10 use Debian::Debhelper::Dh_Lib;
14 B<dh_fixperms> [S<I<debhelper options>>] [B<-X>I<item>]
18 dh_fixperms is a debhelper program that is responsible for setting the
19 permissions of files and directories in package build directories to a
20 sane state -- a state that complies with Debian policy.
22 dh_fixperms makes all files in usr/share/doc in the package build directory
23 (excluding files in the examples/ directory) be mode 644. It also changes
24 the permissions of all man pages to mode 644. It makes all files be owned by
25 root, and it removes group and other write permission from all files.
26 It removes execute permissions from any libraries that have it set. It makes
27 all files in bin/ directories and etc/init.d executable (v4 only). Finally,
28 it removes the setuid and setgid bits from all files in the package.
34 =item B<-X>I<item>, B<--exclude> I<item>
36 Exclude files that contain "item" anywhere in their filename from having
37 their permissions changed. You may use this option multiple times to build
38 up a list of things to exclude.
46 foreach my $package (@{$dh{DOPACKAGES}}) {
47 my $tmp=tmpdir($package);
50 if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
51 $find_options="! \\( $dh{EXCLUDE_FIND} \\)";
54 # General permissions fixing.
55 complex_doit("find $tmp $find_options -print0",
56 "2>/dev/null | xargs -0r chown --no-dereference 0.0");
57 complex_doit("find $tmp ! -type l $find_options -print0",
58 "2>/dev/null | xargs -0r chmod go=rX,u+rw,a-s");
60 # Fix up premissions in usr/share/doc, setting everything to not
61 # executable by default, but leave examples directories alone.
62 complex_doit("find $tmp/usr/share/doc $tmp/usr/doc -type f $find_options ! -regex '.*/examples/.*' -print0 2>/dev/null",
63 "| xargs -0r chmod 644");
64 complex_doit("find $tmp/usr/share/doc $tmp/usr/doc -type d $find_options -print0 2>/dev/null",
65 "| xargs -0r chmod 755");
67 # Executable man pages are a bad thing..
68 complex_doit("find $tmp/usr/share/man $tmp/usr/man/ $tmp/usr/X11*/man/ -type f",
69 "$find_options -print0 2>/dev/null | xargs -0r chmod 644");
73 # Programs in the bin and init.d dirs should be executable..
74 for my $dir (qw{usr/bin bin usr/sbin sbin etc/init.d}) {
76 complex_doit("find $tmp/$dir -type f $find_options -print0 2>/dev/null",
77 "| xargs -0r chmod +x");
82 # ..and so are executable shared and static libraries
83 # (and .la files from libtool)
84 complex_doit("find $tmp -perm -5 -type f",
85 "\\( -name '*.so*' -or -name '*.la' -or -name '*.a' \\) $find_options -print0",
86 "2>/dev/null | xargs -0r chmod a-X");
93 This program is a part of debhelper.
97 Joey Hess <joeyh@debian.org>