3 # If no parameters are given, and no debian/suid files exists, scan for
4 # suid/sgid files and suidregister them.
6 # If there are parameters, or there is a debian/suid, register the files
9 BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
13 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
14 $TMP=tmpdir($PACKAGE);
15 $suid=pkgfile($PACKAGE,"suid");
19 @files=filearray($suid);
22 if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
26 if (! @files && ! $suid) {
27 # No files specified (and no empty debian/suid file), so
28 # guess what files to process.
29 @files=split(/\n/,`find $TMP -type f -perm +6000`);
31 # We will strip the debian working directory off of the
36 # We will strip leading /'s, so the user can feed this
37 # program either absolute filenames, or relative filenames,
38 # and it will do the right thing either way.
42 foreach $file (@files) {
43 # Strip leading $tostrip from $file.
46 # Create the sed string that will be used to
47 # fill in the blanks in the autoscript files.
48 # Fill with the owner, group, and perms of the file.
49 (undef,undef,$mode,undef,$uid,$gid,undef) = stat("$TMP/$file");
50 # Now come up with the user and group names for the uid and gid.
52 $group=getgrgid($gid);
53 # Note that I have to print mode in ocal, stripping file type.
54 $sedstr=sprintf("s:#FILE#:$file:;s/#PACKAGE#/$PACKAGE/;s/#OWNER#/$user/;s/#GROUP#/$group/;s/#PERMS#/%#o/",
57 autoscript($PACKAGE,"postinst","postinst-suid",$sedstr);
58 autoscript($PACKAGE,"postrm","postrm-suid","$sedstr");
60 if ( -e "$TMP/$file") {
61 doit("chmod","a-s","$TMP/$file");