Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 1873 → Rev 1874

/alcasar.sh
1707,10 → 1707,13
*/18 * * * * root $DIR_DEST_BIN/alcasar-daemon.sh > /dev/null 2>&1
EOF
 
# Enabling category update from rsync
cat << EOF > /etc/cron.d/alcasar-update-cat
# activation de la mise a jour des categories. Si le fichier /usr/local/etc/update_cat.conf est vide. On ne met pas à jour.
0 */12 * * * /usr/local/bin/alcasar-bl.sh --update_cat > /dev/null 2>&1
EOF
 
touch /etc/cron.d/alcasar-update-cat
chown root:apache /etc/cron.d/alcasar-update-cat
chmod 660 /etc/cron.d/alcasar-update-cat
chmod 644 /etc/cron.d/alcasar-update-cat
 
# removing the users crons
rm -f /var/spool/cron/*
/scripts/alcasar-bl.sh
258,23 → 258,23
#mise a jour d'une categorie avec rsync
-update_cat | --update_cat)
if [ $(cat /usr/local/etc/update_cat.conf | wc -l) -ne 0 ]
then
echo -n "Updating categories in /usr/local/etc/update_cat.conf ..."
 
for LIGNE_RSYNC in $(cat /usr/local/etc/update_cat.conf)
cat /usr/local/etc/update_cat.conf | while read LIGNE_RSYNC
do
 
$CATEGORIE=$(echo $LIGNE_RSYNC | cut -d' ' -f0)
$URL=$(echo $LIGNE_RSYNC | cut -d' ' -f1)
CATEGORIE=$(echo $LIGNE_RSYNC | cut -d' ' -f1)
URL=$(echo $LIGNE_RSYNC | cut -d' ' -f2)
PATH_FILE=$(find $DIR_DG_BL/ -type d -name $CATEGORIE) # retrieve directory name of the category
echo "rsync -rv $URL $(dirname $PATH_FILE )" #rsync inside of the blacklist directory
echo $PATH_FILE
rsync -rv $URL $(dirname $PATH_FILE ) #rsync inside of the blacklist directory
# Creation of DNSMASQ and Iptables BL and WL
DOMAINE=$(basename $PATH_FILE)
$SED "s/\.\{2,10\}/\./g" $PATH_FILE/domains $PATH_FILE/urls # correct some syntax errors
 
#correct some synthaxes
$SED "s/\.\{2,10\}/\./g" $PATH_FILE/domains $PATH_FILE/urls
# extract ip addresses for iptables
awk '/^([0-9]{1,3}\.){3}[0-9]{1,3}$/{print "add bl_ip_blocked " $0}' $PATH_FILE/domains > $FILE_ip_tmp
# for dnsmask, remove IP addesses, accented characters and commented lines.
302,9 → 302,12
/usr/bin/systemctl restart dnsmasq-blacklist
/usr/bin/systemctl restart dansguardian
/usr/local/bin/alcasar-iptables.sh
else
echo -n "/usr/local/etc/update_cat.conf is empty ..."
fi
echo "MAJ RSYNC réussie"
echo
;;
# reload when categories are changed
-reload | --reload)
337,3 → 340,4
 
 
 
 
/web/acc/admin/bl_categories_help.php
65,8 → 65,8
{
if(isset($ossi))
{
$bl_categorie_domain_file = $bl_dnsmasq_dir."-enabled/".$categorie;
$bl_categorie_ip_file = $bl_iptables_dir.$categorie;
$bl_categorie_domain_file = "/usr/local/share/dnsmasq-bl-enabled/".$categorie;
$bl_categorie_ip_file = "/usr/local/share/iptables-bl-enabled/".$categorie;
if(isset($_GET['nb_domains']) && isset($_GET['nb_urls']) && isset($_GET['nb_ip']))
{
$nb_domains = $_GET['nb_domains'];
/web/acc/admin/bl_filter.php
133,10 → 133,8
$l_nbUrl="Url :";
$l_nbIp="Ip :";
$l_update_cat="Mise a jour des catégories automatiquement?";
$l_no_update_cat = "désactiver";
$l_1_update_cat = "toutes les 12 heures";
$l_2_update_cat = "toutes les semaines";
$l_3_update_cat = "tous les mois";
$l_no_update_cat = "Désactiver";
$l_yes_update_cat = "Activer (Toutes les 12 heures)";
}
else {
$l_bl="BlackList";
185,9 → 183,7
$l_nbIp="Ip :";
$l_update_cat="Mise a jour des catégories automatiquement?";
$l_no_update_cat = "Disable";
$l_1_update_cat = "every 12 hours";
$l_2_update_cat = "every weeks";
$l_3_update_cat = "every month";
$l_yes_update_cat = "Enable (Every 12 hours)";
}
$dir_etc="/usr/local/etc/";
$dir_dg="/etc/dansguardian/lists/";
201,35 → 197,9
$dir_tmp="/tmp/blacklists";
$upload_dir_ip = "/usr/local/share/iptables-bl-enabled/";
$upload_dir_domain_names = "/usr/local/share/dnsmasq-bl-enabled/";
$cron_apache = "/etc/cron.d/alcasar-update-cat";
$update_file_cat="/usr/local/etc/update_cat.conf";
if(isset($_POST['update_cat']))
{
 
$fichier=fopen($cron_apache,"w+");
$update_mode = $_POST['update_cat'];
switch($update_mode){
case 0:
fputs($fichier, "#0 update with rsync categories is disabled\n");
break;
case 1:
fputs($fichier, "#1 update with rsync every 12 hours\n");
fputs($fichier, "0 0-23/12 * * * /usr/local/bin/alcasar-bl.sh --update_cat \n");
break;
case 2:
fputs($fichier, "#2 update with rsync every week (Sunday) at 00:00\n");
fputs($fichier, "0 0 * * 0 /usr/local/bin/alcasar-bl.sh --update_cat \n");
break;
case 3:
fputs($fichier, "#3 update with rsync every month (1st) at 00:00\n");
fputs($fichier, "0 0 1 * * /usr/local/bin/alcasar-bl.sh --update_cat \n");
break;
}
 
 
fclose($fichier);
}
 
# default values
if (is_file ($conf_file))
{
248,6 → 218,16
}
}
}
#update categories via rsync
$update_select = array();
$update_select[0] = "";
$update_select[1] = "";
 
if ( 0 == filesize( $update_file_cat ) ) $update_select[0] = "checked";
else $update_select[1] = "checked";
else { echo "$l_error_open_file $conf_file";}
if (isset($_POST['choix'])){ $choix=$_POST['choix']; } else { $choix=""; }
switch ($choix)
265,6 → 245,7
case 'MAJ_cat_bl' :
if (file_exists($bl_categories_enabled))
{
$fichier=fopen($update_file_cat,"w+");
$pointeur=fopen($bl_categories_enabled, "w+");
foreach ($_POST as $key => $value)
{
272,9 → 253,8
{
$line=str_replace('chk-','',$key)."\n";
fwrite($pointeur,$line);
if(trim($line) == 'malware' && $update_mode > 0)
if(trim($line) == 'malware' && $update_select[1] == "checked")
{
$fichier=fopen($update_file_cat,"w+");
fputs($fichier, "malware rsync://ftp.ut-capitole.fr/blacklist/dest/malware\n");
}
}
441,35 → 421,13
echo "$l_error_open_file $bl_categories";
}
 
#update categories via rsync
$update_select = array();
$update_select[0] = "";
$update_select[1] = "";
$update_select[2] = "";
$update_select[3] = "";
 
$pointeur=fopen($cron_apache,'r');
while (!feof ($pointeur))
{
$line=fgets($pointeur,1024);
if(explode(' ',$line)[0] === "#0")
$update_select[0]="checked";
if(explode(' ',$line)[0] === "#1")
$update_select[1]="checked";
if(explode(' ',$line)[0] === "#2")
$update_select[2]="checked";
if(explode(' ',$line)[0] === "#3")
$update_select[3]="checked";
}
fclose($pointeur);
 
echo "</td></tr>";
echo "<tr><td valign='middle' align='left' colspan=10>";
echo "<center>$l_update_cat
<input type='radio' name='update_cat' value=0 $update_select[0]> $l_no_update_cat
<input type='radio' name='update_cat' value=1 $update_select[1]> $l_1_update_cat
<input type='radio' name='update_cat' value=2 $update_select[2]> $l_2_update_cat
<input type='radio' name='update_cat' value=3 $update_select[3]> $l_3_update_cat
<input type='radio' name='update_cat' value=1 $update_select[1]> $l_yes_update_cat
<input type='submit' value='$l_record'></center>";
echo "</td></tr>";
echo "<tr><td valign='middle' align='left' colspan=10>";
/web/acc/manager/htdocs/user_new.php
98,7 → 98,8
include("../lib/$config[general_lib_type]/create_user.php");
/* Petit traitement pré-impression pour la lisibilité */
/* Récupération des attributs du groupe le cas échéant */
if (isset($group) && $group!=''){
if (isset($_POST['Fgroup']) && $_POST['Fgroup']!=''){
$group = $_POST['Fgroup'];
$saved_login = $login;
$login = $group;
if (is_file("../lib/sql/group_info.php"))