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 / var / lib / dpkg / info / tcpd.postinst < prev    next >
Encoding:
Text File  |  2007-03-08  |  2.9 KB  |  101 lines

  1. #!/bin/sh -e
  2.  
  3. # must be sourced at the top level or $@ will be lost when $0 is executed
  4. if [ "$1" = "configure" ]; then
  5.   . /usr/share/debconf/confmodule
  6. fi
  7.  
  8. create_hosts_files() {
  9.   if [ -e /etc/hosts.allow -a -e /etc/hosts.deny ]; then
  10.     return 0
  11.   fi
  12.  
  13.   # The default paranoid mode, in order to avoid breaking expected 
  14.   # behaviour is 'false', however, if debconf is used to set this to
  15.   # true then we add a more restrictive definition
  16.   PARANOID="false"
  17.  
  18.   db_get tcpd/paranoid-mode || true
  19.   PARANOID="$RET"
  20.  
  21.   if [ ! -e /etc/hosts.allow ]; then
  22.     cat > /etc/hosts.allow <<EOF
  23. # /etc/hosts.allow: list of hosts that are allowed to access the system.
  24. #                   See the manual pages hosts_access(5), hosts_options(5)
  25. #                   and /usr/doc/netbase/portmapper.txt.gz
  26. #
  27. # Example:    ALL: LOCAL @some_netgroup
  28. #             ALL: .foobar.edu EXCEPT terminalserver.foobar.edu
  29. #
  30. # If you're going to protect the portmapper use the name "portmap" for the
  31. # daemon name. Remember that you can only use the keyword "ALL" and IP
  32. # addresses (NOT host or domain names) for the portmapper, as well as for
  33. # rpc.mountd (the NFS mount daemon). See portmap(8), rpc.mountd(8) and 
  34. # /usr/share/doc/portmap/portmapper.txt.gz for further information.
  35. #
  36. EOF
  37.  
  38.     if [ "$PARANOID" = "true" ]; then
  39.       cat >> /etc/hosts.allow <<EOF
  40.  
  41. ALL: 127.0.0.1
  42.  
  43. # Since all access will be restriced in hosts.deny you might want to give
  44. # access to some machines to some common (remote) services:
  45. # sshd: aaaa.bbbb.cccc.ddd
  46. EOF
  47.     fi
  48.   fi
  49.  
  50.   if [ ! -e /etc/hosts.deny ]; then
  51.     cat > /etc/hosts.deny <<EOF
  52. # /etc/hosts.deny: list of hosts that are _not_ allowed to access the system.
  53. #                  See the manual pages hosts_access(5), hosts_options(5)
  54. #                  and /usr/doc/netbase/portmapper.txt.gz
  55. #
  56. # Example:    ALL: some.host.name, .some.domain
  57. #             ALL EXCEPT in.fingerd: other.host.name, .other.domain
  58. #
  59. # If you're going to protect the portmapper use the name "portmap" for the
  60. # daemon name. Remember that you can only use the keyword "ALL" and IP
  61. # addresses (NOT host or domain names) for the portmapper. See portmap(8)
  62. # and /usr/doc/portmap/portmapper.txt.gz for further information.
  63. #
  64. # The PARANOID wildcard matches any host whose name does not match its
  65. # address.
  66. EOF
  67.  
  68.     if [ "$PARANOID" = "true" ]; then
  69.       cat >> /etc/hosts.deny <<EOF
  70.  
  71. # We don't trust anybody, so never allow access.
  72. ALL: ALL
  73. EOF
  74.     else
  75.       cat >> /etc/hosts.deny <<EOF
  76.  
  77. # You may wish to enable this to ensure any programs that don't
  78. # validate looked up hostnames still leave understandable logs. In past
  79. # versions of Debian this has been the default.
  80. # ALL: PARANOID
  81. EOF
  82.     fi
  83.   fi
  84. }
  85.  
  86. case "$1" in
  87.     configure)
  88.     create_hosts_files
  89.     ;;
  90.  
  91.     abort-upgrade|abort-remove|abort-deconfigure)
  92.     ;;
  93.  
  94.     *)
  95.     echo "postinst called with unknown argument '$1'" >&2
  96.     exit 1
  97.     ;;
  98. esac
  99.  
  100.  
  101.