5 [ "$1" = "configure" ] || exit 0
6 [ $DEBIAN_SCRIPT_DEBUG ] && set -vx
10 . /usr/share/debconf/confmodule
12 # Include CARNet functions
13 . /usr/share/carnet-tools/functions.sh
15 PKG="squirrelmail-change-pass-cn"
17 SQCONFDIR="/etc/squirrelmail"
18 SQCONF="$SQCONFDIR/config.php"
19 SQCPCONF="$SQCONFDIR/config_change_pass.php"
20 CPCONF="/usr/share/squirrelmail/plugins/change_pass/config.php"
25 set_min_pass_length () {
27 local sed_re conf_file
30 temp_files="$temp_files $conf_file.dpkg-tmp"
32 sed "$conf_re" "$conf_file" > "$conf_file.dpkg-tmp"
34 if ! cmp -s "$conf_file" "$conf_file.dpkg-tmp" 2>&1 >/dev/null; then
35 cp_mv "$conf_file.dpkg-tmp" "$conf_file"
38 rm -f "$conf_file.dpkg-tmp"
44 if [ -n "$temp_files" ]; then
45 for temp_item in $temp_files; do
46 if [ -e "$temp_item" ]; then
56 # Configure poppassd to refuse connection from all hosts
57 # but localhost (127.0.0.1).
59 if [ ! -f /etc/hosts.deny ]; then
62 if ! egrep -q '^poppassd:' /etc/hosts.deny; then
63 echo "poppassd: ALL" | cp-update "$PKG" /etc/hosts.deny
65 if [ ! -f /etc/hosts.allow ]; then
66 touch /etc/hosts.allow
68 if ! egrep -q '^poppassd:' /etc/hosts.allow; then
69 echo "poppassd: 127.0.0.1" | cp-update "$PKG" /etc/hosts.allow
73 # Configure SquirrelMail change_pass plugin - using defaults,
74 # no configuration files if earlier version is older than 3.0-1.
76 if [ "$2" ] && dpkg --compare-versions $2 lt 3.0-1; then
78 cp_echo "CN: This version of change_pass plugin contains major changes."
79 cp_echo "CN: For detailed description, see documentation in /usr/share/doc/$PKG/."
81 if [ -f "$SQCPCONF" ]; then
82 mv -f "$SQCPCONF" "$SQCPCONF.cn-old"
83 cp_echo "CN: Old $SQCPCONF disabled and renamed to $SQCPCONF.cn-old."
85 if [ -f "$CPCONF" ]; then
86 mv -f "$CPCONF" "$CPCONF.cn-old"
87 cp_echo "CN: Old $CPCONF disabled and renamed to $CPCONF.cn-old."
92 # Check for change_pass configuration file and notify user about
93 # minimum password length configuration.
95 if [ ! -f "$SQCPCONF" ] && [ ! -f "$CPCONF" ]; then
97 # Configuration file does not exist.
98 cp_echo "CN: Generating new file $CPCONF"
101 //// Begin - Generated by CARNet package $PKG
103 // REMOVE this whole block if you DON'T WANT $PKG
104 // to edit your configuration file.
106 //// End - Generated by CARNet package $PKG
107 \$min_pass_length = 8;
109 // The default server is the configured IMAP server
110 #\$poppass_server = 'localhost';
112 // The default port is 106
113 #\$poppass_port = 106;
115 \$max_pass_length = 9999999;
120 # Checking for configuration file/s and minimum password length.
121 echo "CN: Checking for minimum password length configuration."
122 cn_tag_re="^\/\/\/\/ Begin - Generated by CARNet package $PKG$"
124 for cpconf_file in $SQCPCONF $CPCONF; do
127 if [ -f "$cpconf_file" ]; then
129 seddef="/^[[:space:]]*\\\$min_pass_length[[:space:]]*=[^;]*;[[:space:]]*$/d;
130 s/\\\$min_pass_length[[:space:]]*=[^;]*;//g;"
132 if egrep -q "$cn_tag_re" "$cpconf_file"; then
134 # Configuration file is tagged by CARNet.
135 seddef="$seddef /^\/\/\/\/ End - Generated by CARNet package $PKG$/s/\(.*\)/\1\n"
136 seddef="$seddef \\\$min_pass_length = 8;/"
138 set_min_pass_length "$seddef" "$cpconf_file"
141 if [ "$2" ] && dpkg --compare-versions $2 lt 3.0-2; then
143 # Add CARNet package info lines to config's header and set up $min_pass_length.
144 seddef="$seddef 0,/?>/s/^[[:space:]]*\(<?php\|<?\)\(.*\)/\1\n"
145 seddef="$seddef\/\/\/\/ Begin - Generated by CARNet $PKG\n\/\/\n"
146 seddef="$seddef\/\/ REMOVE this whole block if you DON'T WANT $PKG\n"
147 seddef="$seddef\/\/ to edit your configuration file.\n\/\/\n"
148 seddef="$seddef\/\/\/\/ End - Generated by CARNet package $PKG\n"
149 seddef="$seddef \\\$min_pass_length = 8;\n\2/"
151 set_min_pass_length "$seddef" "$cpconf_file"
158 if [ $min_pass_changed -eq 1 ]; then
159 db_fset squirrelmail-change-pass-cn/min_pass_length seen false
160 db_title squirrelmail-change-pass-cn - konfiguracija
161 db_input critical squirrelmail-change-pass-cn/min_pass_length || true
163 cp_echo "CN: Minimum password length has been set to 8 characters."
169 # Enable change_pass plugin in SquirrelMail config.php.
171 if ! egrep -q '^\$plugins\[[0-9]+\][\ ]*=[\ ]*'\''change_pass'\' "$SQCONF"; then
173 if cp_check_and_backup "$SQCONF"; then
174 cp_echo "CN: Old $SQCONF saved as \"/var/backups/${SQCONF##*/}.bak\"."
177 cp_echo "CN: Enabling SquirrelMail change_pass plugin in $SQCONF"
178 /usr/sbin/squirrelmail-configure --install-plugin change_pass
182 # Convert poppassd service from inetd.conf to xinetd.conf type.
183 # Service configuration is saved in /etc/xinetd.d/ directory.
185 if [ -x /etc/init.d/xinetd -a -d /etc/xinetd.d -a -x /usr/sbin/itox ]; then
187 if egrep -q '^poppassd' /etc/inetd.conf && \
188 [ ! -f /etc/xinetd.d/poppassd ]; then
190 cp_echo "CN: Enabling poppassd in /etc/xinetd.d/poppassd"
192 touch /etc/xinetd.d/poppassd.$$
193 grep "^poppassd" /etc/inetd.conf | \
194 itox -daemon_dir /usr/sbin | cp-update "$PKG" /etc/xinetd.d/poppassd.$$
195 cp_mv /etc/xinetd.d/poppassd.$$ /etc/xinetd.d/poppassd
202 # Restart xinetd if needed.
204 if [ $need_restart -eq 1 ]; then
206 if [ -x "/etc/init.d/xinetd" ]; then
207 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
208 invoke-rc.d xinetd restart || exit $?
210 /etc/init.d/xinetd restart || exit $?