]> git.donarmstrong.com Git - debhelper.git/blob - dh_suidregister
r11: Initial revision
[debhelper.git] / dh_suidregister
1 #!/bin/sh -e
2 #
3 # If no parameters are given, and no debian/suid files exists, scan for 
4 # suid/sgid files and suidregister them. 
5 #
6 # If there are parameters, or there is a debian/suid, register the files
7 # listed there.
8
9 PATH=debian:$PATH:/usr/lib/debhelper
10 . dh_lib
11
12 for PACKAGE in $DH_DOPACKAGES; do
13         TMP=`tmpdir $PACKAGE`
14         EXT=`pkgext $PACKAGE`
15
16         files=""
17
18         if [ -e debian/${EXT}suid ]; then
19                 files=`tr "\n" " " < debian/${EXT}suid`
20         fi
21
22         if [ "$PACKAGE" = "$MAINPACKAGE" -a "$*" ]; then
23                 files="$* $files"
24         fi
25
26         if [ ! "$files" -a ! -e debian/${EXT}suid ]; then
27                 # No files specified (and no empty debian/suid file), so
28                 # guess what files to process.
29                 files=`find debian/$TMP -type f -perm +6000`
30
31                 # We will strip the debian working directory off of the
32                 # filenames.
33                 tostrip="debian/$TMP/"
34         else
35                 # We will strip leading /'s, so the user can feed this
36                 # program either absolute filenames, or relative filenames,
37                 # and it will do the right thing either way.
38                 tostrip="/"
39         fi
40
41         if [ "$files" ]; then
42                 for file in $files; do
43                         # Strip leading $tostrip from $file. If not there,
44                         # leave $file untouched.
45                         if [ `expr "$file" : "$tostrip\\(.*\\)"` ]; then
46                                 file=`expr "$file" : "$tostrip\\(.*\\)"`
47                         fi
48                         
49                         # Create the sed string that will be used to 
50                         # fill in the blanks in the autoscript files.
51                         # Fill with the owner, group, and perms of the file.
52                         sedstr=`find debian/$TMP/$file -printf "s:#FILE#:$file:;s/#PACKAGE#/$PACKAGE/;s/#OWNER#/%u/;s/#GROUP#/%g/;s/#PERMS#/%m/"`
53                         
54                         autoscript "postinst" "postinst-suid" "$sedstr"
55                         autoscript "postrm" "postrm-suid" "$sedstr"
56                 done
57         fi
58 done