cidr u hosts allow
[samba-cn.git] / debian / postinst
index 3c34409..1ea1c59 100755 (executable)
@@ -6,10 +6,23 @@
 # Load CARNet Tools
 . /usr/share/carnet-tools/functions.sh
 
-cp_check_and_sed ';   security = user' \
-                 's/;   security = user/   security = user/g' \
+cp_check_and_sed '#[[:space:]]*security = user' \
+                 's/#[[:space:]]*security = user/   security = user/g' \
                 /etc/samba/smb.conf || true
 
+cp_check_and_sed ';[[:space:]]*security = user' \
+                 's/;[[:space:]]*security = user/   security = user/g' \
+                /etc/samba/smb.conf || true
+
+cp_get_netaddr || true
+net="$RET"
+if ! grep -q '^[[:space:]]*hosts allow' /etc/samba/smb.conf; then
+        echo "   hosts allow = $net 127.0.0.1" >> /etc/samba/smb.conf
+fi
+if ! grep -q '^[[:space:]]*hosts deny' /etc/samba/smb.conf; then
+        echo "   hosts deny = ALL" >> /etc/samba/smb.conf
+fi
+
 # restart 
 if [ -x /usr/sbin/invoke-rc.d ]; then
   [ -x /etc/init.d/samba ] && invoke-rc.d samba restart