home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / sbin / fdutilsconfig < prev    next >
Encoding:
Text File  |  2007-03-05  |  2.1 KB  |  78 lines

  1. #!/bin/sh
  2. # /usr/sbin/fdutilsconfig - configuration script for suid bit of fdmount.
  3. # Originally written by Tibor Simko <simko@debian.org> for gnuplot.
  4. # Adapted by Anthony Fok <foka@debian.org> for fdmount in fdutils.
  5. # note: this script modifies `/etc/fdmount.conf' configuration file.
  6.  
  7. set -e
  8. set -C
  9.  
  10. if [ "root" != "`whoami`" ]
  11. then 
  12.    echo "Sorry, only root can run this script.  Exiting."
  13.    exit 1
  14. fi
  15.  
  16. echo "Fdmount suid configuration:"
  17. echo
  18.  
  19. if [ ! -e /etc/fdmount.conf ] 
  20. then 
  21.    echo "Sorry, /etc/fdmount.conf not found.  Exiting."
  22.    exit 1
  23. fi
  24.  
  25. TMPFILE=`mktemp -q /tmp/fdmount.conf.tmp.XXXXXX`
  26. if [ $? -ne 0 ]; then
  27.     echo "$0: Can't create temp file, exiting..."
  28.     exit 1
  29. fi
  30.  
  31. if grep -q "^is_suid=y.*$" /etc/fdmount.conf; then old=y; else old=n; fi
  32.  
  33. while true; do
  34.  
  35. if [ "$old" = "y" ] 
  36. then 
  37.    echo "  Currently, fdmount is set up as setuid root, beware!"
  38. else 
  39.    echo "  Currently, fdmount is not set up as setuid root.  Good."
  40. fi
  41. echo -n "  Do you want to change it?  (y/n/?) [n] "
  42. read yn
  43. echo
  44. test -n "$yn" || yn="n"
  45. case "$yn" in
  46.    [Nn]*)
  47.           echo "Okay, keeping the old configuration."
  48.           exit 0
  49.           ;;
  50.    [Yy]*)
  51.           if [ "$old" = "n" ]
  52.           then 
  53.             sed -e "s/^is_suid=.*$/is_suid=yes/" </etc/fdmount.conf >>$TMPFILE
  54.         chmod 644 $TMPFILE
  55.             mv $TMPFILE /etc/fdmount.conf
  56.         dpkg-statoverride --update --add root floppy 4750 /usr/bin/fdmount
  57.             exit 0
  58.           else
  59.             sed -e "s/^is_suid=.*$/is_suid=no/" </etc/fdmount.conf >>$TMPFILE
  60.         chmod 644 $TMPFILE
  61.             mv $TMPFILE /etc/fdmount.conf
  62.             chmod u-s /usr/bin/fdmount
  63.         dpkg-statoverride --remove /usr/bin/fdmount
  64.             echo "Okay, fdmount is not set up as setuid root anymore."
  65.             exit 0
  66.           fi
  67.           ;;
  68.       *)
  69.           echo "    In order to enable ordinary users to mount a floppy disk"
  70.           echo "    using fdmount, fdmount needs to be set up as setuid root."
  71.           echo "    Please note that this is usually considered to"
  72.           echo "    be a security hazard."
  73.           echo
  74.           ;;
  75. esac
  76.  
  77. done
  78.