File: fdutilsconfig

package info (click to toggle)
fdutils 5.3-3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,004 kB
  • ctags: 621
  • sloc: ansic: 6,098; sh: 2,236; makefile: 279; sed: 4
file content (90 lines) | stat: -rw-r--r-- 2,889 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh
# /usr/sbin/fdutilsconfig - configuration script for suid bit of fdmount.
# Originally written by Tibor Simko <simko@debian.org> for gnuplot.
# Adapted by Anthony Fok <foka@debian.org> for fdmount in fdutils.
# note: this script modifies `/etc/fdmount.conf' configuration file.

set -e
set -C

if [ "root" != "`whoami`" ]
then 
   echo "Sorry, only root can run this script.  Exiting."
   exit 1
fi

echo "Fdmount suid configuration:"
echo

if [ ! -e /etc/fdmount.conf ] 
then 
   echo "Sorry, /etc/fdmount.conf not found.  Exiting."
   exit 1
fi

TMPFILE=`mktemp -q /tmp/fdmount.conf.tmp.XXXXXX`
if [ $? -ne 0 ]; then
    echo "$0: Can't create temp file, exiting..."
    exit 1
fi

if grep -q "^is_suid=y.*$" /etc/fdmount.conf; then old=y; else old=n; fi

while true; do

if [ "$old" = "y" ] 
then 
   echo "  Currently, fdmount is set up as setuid root, beware!"
else 
   echo "  Currently, fdmount is not set up as setuid root.  Good."
fi
echo -n "  Do you want to change it?  (y/n/?) [n] "
read yn
echo
test -n "$yn" || yn="n"
case "$yn" in
   [Nn]*)
          echo "Okay, keeping the old configuration."
          exit 0
          ;;
   [Yy]*)
          if [ "$old" = "n" ]
          then 
            sed -e "s/^is_suid=.*$/is_suid=yes/" </etc/fdmount.conf >>$TMPFILE
	    chmod 644 $TMPFILE
            mv $TMPFILE /etc/fdmount.conf
            if [ -e /etc/suid.conf -a -x /usr/sbin/suidregister ]; then
               echo "Hmm, you seem to have suidmanager installed.  Will use it."
               suidregister -s fdutils /usr/bin/fdmount root root 4755
               echo "Okay, fdmount is now set up and registered as setuid root."
            else
               echo "Hmm, you don't seem to have suidmanager installed."
               echo "Please consider installing suidmanager in the future."
               chown root.root /usr/bin/fdmount
               chmod 4755 /usr/bin/fdmount
               echo "Okay, fdmount is now manually set up as setuid root."
            fi
            exit 0
          else
            sed -e "s/^is_suid=.*$/is_suid=no/" </etc/fdmount.conf >>$TMPFILE
	    chmod 644 $TMPFILE
            mv $TMPFILE /etc/fdmount.conf
            chmod u-s /usr/bin/fdmount
            if [ -e /etc/suid.conf -a -x /usr/sbin/suidunregister ]; then
               echo "Unregistering fdmount from suidmanager database."
               suidunregister -s fdutils /usr/bin/fdmount
            fi
            echo "Okay, fdmount is not set up as setuid root anymore."
            exit 0
          fi
          ;;
      *)
          echo "    In order to enable ordinary users to mount a floppy to mount"
          echo "    a floppy disk using fdmount, fdmount needs to be set up as"
          echo "    setuid root.  Please note that this is usually considered to"
          echo "    be a security hazard."
          echo
          ;;
esac

done