X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=dh_suidregister;h=7f6cd40fb96f66511fb922e91e4d7284a5fd0d5a;hb=18a0da8092ea9f3dc48bca92b36f592af25a608d;hp=b82bc7d229c2113fd0285b424f75b1777230306e;hpb=f2cb401a50f9f0dbc84195867c6f371b59333ad6;p=debhelper.git diff --git a/dh_suidregister b/dh_suidregister index b82bc7d..7f6cd40 100755 --- a/dh_suidregister +++ b/dh_suidregister @@ -1,36 +1,62 @@ #!/usr/bin/perl -w -# -# If no parameters are given, and no debian/suid files exists, scan for -# suid/sgid files and suidregister them. -# -# If there are parameters, or there is a debian/suid, register the files -# listed there. - -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; + +=head1 NAME + +dh_suidregister - suid registration program (deprecated) + +=head1 SYNOPSIS + +Do not run! + +=head1 DESCRIPTION + +This program used to register suid and sgid files with L, +but with the introduction of L, registration of files +in this way is unnecessary, and even harmful, so this program is deprecated +and should not be used. + +=head1 CONVERTING TO STATOVERRIDE + +Converting a package that uses this program to use the new statoverride +mechanism is easy. Just remove the call to B from +F, and add a versioned conflicts into your F file, as +follows: + + Conflicts: suidmanager (<< 0.50) + +The conflicts is only necessary if your package used to register things +with suidmanager; if it did not, you can just remove the call to this +program from your rules file. + +=cut + +use strict; +use Debian::Debhelper::Dh_Lib; init(); -foreach $PACKAGE (@{$dh{DOPACKAGES}}) { - $TMP=tmpdir($PACKAGE); - $suid=pkgfile($PACKAGE,"suid"); +my $notused=1; + +foreach my $package (@{$dh{DOPACKAGES}}) { + my $tmp=tmpdir($package); + my $suid=pkgfile($package,"suid"); + my $tostrip=''; - @files=(); + my @files; if ($suid) { - @files=filearray($suid); + @files=filearray($suid, $tmp); } - if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) { + if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) { push @files, @ARGV; } if (! @files && ! $suid) { # No files specified (and no empty debian/suid file), so # guess what files to process. - @files=split(/\n/,`find $TMP -type f -perm +6000`); + @files=split(/\n/,`find $tmp -type f -perm +6000`); - # We will strip the debian working directory off of the - # filenames. - $tostrip="$TMP/"; + # Strip the debian working directory off of the filenames. + $tostrip="$tmp/"; } else { # We will strip leading /'s, so the user can feed this @@ -40,43 +66,62 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) { } # Register files with suidregister. - foreach $file (@files) { + foreach my $file (@files) { # Strip leading $tostrip from $file. $file=~s/^$tostrip//; - if (! -e "$TMP/$file") { - error("\"$TMP/$file\" does not exist."); - } - - # Create the sed string that will be used to + # Create the sed string that will be used to # fill in the blanks in the autoscript files. # Fill with the owner, group, and perms of the file. - (undef,undef,$mode,undef,$uid,$gid,undef) = stat("$TMP/$file"); - # Now come up with the user and group names for the uid and gid. - $user=getpwuid($uid); + my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat("$tmp/$file"); + # Now come up with the user and group names for the uid and + # gid. + my $user=getpwuid($uid); if (! defined $user) { warning("$file has odd uid $uid, not in /etc/passwd"); $user=$uid; } - $group=getgrgid($gid); + my $group=getgrgid($gid); if (! defined $group) { warning("$file has odd gid $gid not in /etc/group"); $group=$gid; } - # Note that I have to print mode in ocal, stripping file type. - $sedstr=sprintf("s:#FILE#:$file:;s/#PACKAGE#/$PACKAGE/;s/#OWNER#/$user/;s/#GROUP#/$group/;s/#PERMS#/%#o/", - $mode & 07777); - - autoscript($PACKAGE,"postinst","postinst-suid",$sedstr); - autoscript($PACKAGE,"postrm","postrm-suid","$sedstr"); + # Note that I have to print mode in ocal, stripping file + # type. + my $sedstr=sprintf("s:#FILE#:$file:;s/#PACKAGE#/$package/;s/#OWNER#/$user/;s/#GROUP#/$group/;s/#PERMS#/%#o/", + $mode & 07777); + autoscript($package,"postinst","postinst-suid",$sedstr); + autoscript($package,"postrm","postrm-suid","$sedstr"); } # Remove suid bits from files. This is delayed to this point, because # of a situation with hard linked files if it is done earlier. # See changelog for 2.0.77. - foreach $file (@files) { - if ( -e "$TMP/$file") { - doit("chmod","a-s","$TMP/$file"); + foreach my $file (@files) { + if ( -e "$tmp/$file") { + doit("chmod","a-s","$tmp/$file"); } } + + if (@files) { + warning("This program should no longer be used. Please read the dh_suidregister(1) man page."); + $notused=0; + } +} + +# Although they called it, it's not going to do anything. +if ($notused) { + warning("This program is obsolete, does nothing, and may be safely removed from your rules file."); } + +=head1 SEE ALSO + +L + +This program is a part of debhelper. + +=head1 AUTHOR + +Joey Hess + +=cut