- tostrip="/"
- fi
-
- if [ "$files" ]; then
- for file in $files; do
- # Strip leading $tostrip from $file. If not there,
- # leave $file untouched.
- if [ `expr "$file" : "$tostrip\\(.*\\)"` ]; then
- file=`expr "$file" : "$tostrip\\(.*\\)"`
- fi
-
- # 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.
- sedstr=`find debian/$TMP/$file -printf "s:#FILE#:$file:;s/#PACKAGE#/$PACKAGE/;s/#OWNER#/%u/;s/#GROUP#/%g/;s/#PERMS#/%m/"`
-
- autoscript "postinst" "postinst-suid" "$sedstr"
- autoscript "postrm" "postrm-suid" "$sedstr"
- done
- fi
-done
+ $tostrip="/";
+ }
+
+ # Register files with suidregister.
+ foreach my $file (@files) {
+ # Strip leading $tostrip from $file.
+ $file=~s/^$tostrip//;
+
+ # 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.
+ 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;
+ }
+ 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.
+ 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 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<debhelper(7)>
+
+This program is a part of debhelper.
+
+=head1 AUTHOR
+
+Joey Hess <joeyh@debian.org>
+
+=cut