]> git.donarmstrong.com Git - debhelper.git/blob - dh_suidregister
Updated French man page translation. Closes: #685560
[debhelper.git] / dh_suidregister
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_suidregister - suid registration program (deprecated)
6
7 =head1 SYNOPSIS
8
9 Do not run!
10
11 =head1 DESCRIPTION
12
13 This program used to register suid and sgid files with L<suidregister(1)>,
14 but with the introduction of L<dpkg-statoverride(8)>, registration of files
15 in this way is unnecessary, and even harmful, so this program is deprecated
16 and should not be used.
17
18 =head1 CONVERTING TO STATOVERRIDE
19
20 Converting a package that uses this program to use the new statoverride
21 mechanism is easy. Just remove the call to B<dh_suidregister> from
22 F<debian/rules>, and add a versioned conflicts into your F<control> file, as
23 follows:
24
25   Conflicts: suidmanager (<< 0.50)
26
27 The conflicts is only necessary if your package used to register things
28 with suidmanager; if it did not, you can just remove the call to this
29 program from your rules file.
30
31 =cut
32
33 use strict;
34 use Debian::Debhelper::Dh_Lib;
35 init();
36
37 my $notused=1;
38
39 foreach my $package (@{$dh{DOPACKAGES}}) {
40         my $tmp=tmpdir($package);
41         my $suid=pkgfile($package,"suid");
42         my $tostrip='';
43
44         my @files;
45         if ($suid) {
46                 @files=filearray($suid, $tmp);
47         }
48
49         if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
50                 push @files, @ARGV;
51         }
52
53         if (! @files && ! $suid) {
54                 # No files specified (and no empty debian/suid file), so
55                 # guess what files to process.
56                 @files=split(/\n/,`find $tmp -type f -perm +6000`);
57
58                 # Strip the debian working directory off of the filenames.
59                 $tostrip="$tmp/";
60         }
61         else {
62                 # We will strip leading /'s, so the user can feed this
63                 # program either absolute filenames, or relative filenames,
64                 # and it will do the right thing either way.
65                 $tostrip="/";
66         }
67
68         # Register files with suidregister.
69         foreach my $file (@files) {
70                 # Strip leading $tostrip from $file.
71                 $file=~s/^$tostrip//;
72
73                 # Create the sed string that will be used to
74                 # fill in the blanks in the autoscript files.
75                 # Fill with the owner, group, and perms of the file.
76                 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat("$tmp/$file");
77                 # Now come up with the user and group names for the uid and
78                 # gid.
79                 my $user=getpwuid($uid);
80                 if (! defined $user) {
81                         warning("$file has odd uid $uid, not in /etc/passwd");
82                         $user=$uid;
83                 }
84                 my $group=getgrgid($gid);
85                 if (! defined $group) {
86                         warning("$file has odd gid $gid not in /etc/group");
87                         $group=$gid;
88                 }
89                 # Note that I have to print mode in ocal, stripping file
90                 # type.
91                 my $sedstr=sprintf("s:#FILE#:$file:;s/#PACKAGE#/$package/;s/#OWNER#/$user/;s/#GROUP#/$group/;s/#PERMS#/%#o/",
92                                    $mode & 07777);
93                 autoscript($package,"postinst","postinst-suid",$sedstr);
94                 autoscript($package,"postrm","postrm-suid","$sedstr");
95         }
96
97         # Remove suid bits from files. This is delayed to this point, because
98         # of a situation with hard linked files if it is done earlier.
99         # See changelog for 2.0.77.
100         foreach my $file (@files) {
101                 if ( -e "$tmp/$file") {
102                         doit("chmod","a-s","$tmp/$file");
103                 }
104         }
105
106         if (@files) {
107                 warning("This program should no longer be used. Please read the dh_suidregister(1) man page.");
108                 $notused=0;
109         }
110 }
111
112 # Although they called it, it's not going to do anything.
113 if ($notused) {
114         warning("This program is obsolete, does nothing, and may be safely removed from your rules file.");
115 }
116
117 =head1 SEE ALSO
118
119 L<debhelper(7)>
120
121 This program is a part of debhelper.
122
123 =head1 AUTHOR
124
125 Joey Hess <joeyh@debian.org>
126
127 =cut