summaryrefslogtreecommitdiff
path: root/dh_suidregister
diff options
context:
space:
mode:
authorjoey <joey>1999-08-17 04:34:24 +0000
committerjoey <joey>1999-08-17 04:34:24 +0000
commit1e6dea44772a0c1f57e7cd50ff12e35a1cff0b96 (patch)
tree212e56dc8ea32cf27cd2a33ac901a92a701f063f /dh_suidregister
parentface7b5d7df5fb2b8f434bc7135f27b38329a5c5 (diff)
r11: Initial revision
Diffstat (limited to 'dh_suidregister')
-rwxr-xr-xdh_suidregister58
1 files changed, 58 insertions, 0 deletions
diff --git a/dh_suidregister b/dh_suidregister
new file mode 100755
index 0000000..4ca72a1
--- /dev/null
+++ b/dh_suidregister
@@ -0,0 +1,58 @@
+#!/bin/sh -e
+#
+# 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.
+
+PATH=debian:$PATH:/usr/lib/debhelper
+. dh_lib
+
+for PACKAGE in $DH_DOPACKAGES; do
+ TMP=`tmpdir $PACKAGE`
+ EXT=`pkgext $PACKAGE`
+
+ files=""
+
+ if [ -e debian/${EXT}suid ]; then
+ files=`tr "\n" " " < debian/${EXT}suid`
+ fi
+
+ if [ "$PACKAGE" = "$MAINPACKAGE" -a "$*" ]; then
+ files="$* $files"
+ fi
+
+ if [ ! "$files" -a ! -e debian/${EXT}suid ]; then
+ # No files specified (and no empty debian/suid file), so
+ # guess what files to process.
+ files=`find debian/$TMP -type f -perm +6000`
+
+ # We will strip the debian working directory off of the
+ # filenames.
+ tostrip="debian/$TMP/"
+ else
+ # We will strip leading /'s, so the user can feed this
+ # program either absolute filenames, or relative filenames,
+ # and it will do the right thing either way.
+ 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