hook
This commit is contained in:
@@ -137,6 +137,7 @@ user $SMTP_USER
|
|||||||
password $SMTP_PASS
|
password $SMTP_PASS
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
||||||
# 2. Comparaison avec le fichier existant
|
# 2. Comparaison avec le fichier existant
|
||||||
MSMTP_CONF="/etc/msmtprc"
|
MSMTP_CONF="/etc/msmtprc"
|
||||||
SHOULD_UPDATE=false
|
SHOULD_UPDATE=false
|
||||||
@@ -145,7 +146,7 @@ if [ ! -f "$MSMTP_CONF" ]; then
|
|||||||
echo "📜 Le fichier $MSMTP_CONF n'existe pas. Création..."
|
echo "📜 Le fichier $MSMTP_CONF n'existe pas. Création..."
|
||||||
SHOULD_UPDATE=true
|
SHOULD_UPDATE=true
|
||||||
else
|
else
|
||||||
# Comparaison du contenu (diff ignore les différences de droits, uniquement le texte)
|
# Comparaison du contenu
|
||||||
if ! diff -q "$TMP_MSMTP" "$MSMTP_CONF" > /dev/null; then
|
if ! diff -q "$TMP_MSMTP" "$MSMTP_CONF" > /dev/null; then
|
||||||
echo "🔄 La configuration a changé. Mise à jour de $MSMTP_CONF..."
|
echo "🔄 La configuration a changé. Mise à jour de $MSMTP_CONF..."
|
||||||
SHOULD_UPDATE=true
|
SHOULD_UPDATE=true
|
||||||
@@ -154,17 +155,31 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 3. Application si nécessaire
|
|
||||||
|
# 3. Application et sécurisation
|
||||||
if [ "$SHOULD_UPDATE" = true ]; then
|
if [ "$SHOULD_UPDATE" = true ]; then
|
||||||
cp "$TMP_MSMTP" "$MSMTP_CONF"
|
cp "$TMP_MSMTP" "$MSMTP_CONF"
|
||||||
chmod 600 "$MSMTP_CONF"
|
|
||||||
chown root:root "$MSMTP_CONF"
|
# --- CORRECTIONS DES DROITS ---
|
||||||
|
# On donne le fichier au groupe msmtp pour permettre l'accès au binaire
|
||||||
|
chown root:msmtp "$MSMTP_CONF"
|
||||||
|
# 640 : Root lit/écrit, le groupe msmtp lit, les autres rien (sécurité du mot de passe)
|
||||||
|
chmod 640 "$MSMTP_CONF"
|
||||||
|
|
||||||
|
# On s'assure que le binaire msmtp peut lire ce fichier quel que soit l'utilisateur
|
||||||
|
# Le bit 's' (setgid) permet à msmtp de prendre l'identité du groupe 'msmtp'
|
||||||
|
chmod g+s /usr/bin/msmtp
|
||||||
|
|
||||||
|
# On règle le problème du log une fois pour toutes (lecture/écriture pour tous)
|
||||||
|
touch /var/log/msmtp.log
|
||||||
|
chown root:msmtp /var/log/msmtp.log
|
||||||
|
chmod 666 /var/log/msmtp.log
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Nettoyage du fichier temporaire
|
# Nettoyage du fichier temporaire
|
||||||
rm -f "$TMP_MSMTP"
|
rm -f "$TMP_MSMTP"
|
||||||
|
|
||||||
|
h flo
|
||||||
# --- 6. INTERCEPTION GLOBALE (LE WRAPPER) ---
|
# --- 6. INTERCEPTION GLOBALE (LE WRAPPER) ---
|
||||||
echo "--- 6. Création du wrapper sendmail pour préfixer les objets ---"
|
echo "--- 6. Création du wrapper sendmail pour préfixer les objets ---"
|
||||||
# On crée un script qui va modifier le sujet à la volée
|
# On crée un script qui va modifier le sujet à la volée
|
||||||
|
|||||||
42
servers/linux/config_services.php
Normal file
42
servers/linux/config_services.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
$configFile = 'services_to_check.conf';
|
||||||
|
|
||||||
|
// Sauvegarde si le formulaire est envoyé
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$selected = $_POST['services'] ?? [];
|
||||||
|
file_put_contents($configFile, implode("\n", $selected));
|
||||||
|
echo "✅ Configuration mise à jour !<br><a href='/'>Retour</a>";
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Récupération de tous les services installés
|
||||||
|
$allServices = [];
|
||||||
|
exec("systemctl list-unit-files --type=service --no-legend", $output);
|
||||||
|
foreach ($output as $line) {
|
||||||
|
$parts = preg_split('/\s+/', $line);
|
||||||
|
if (isset($parts[0])) $allServices[] = str_replace('.service', '', $parts[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lecture de la config actuelle
|
||||||
|
$currentConfig = file_exists($configFile) ? explode("\n", trim(file_get_contents($configFile))) : ["ssh", "fail2ban"];
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head><title>Config Services</title></head>
|
||||||
|
<body>
|
||||||
|
<h2>Services à surveiller</h2>
|
||||||
|
<form method="post">
|
||||||
|
<div style="height: 300px; overflow-y: scroll; border: 1px solid #ccc; padding: 10px;">
|
||||||
|
<?php foreach ($allServices as $svc): ?>
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" name="services[]" value="<?= $svc ?>" <?= in_array($svc, $currentConfig) ? 'checked' : '' ?>>
|
||||||
|
<?= $svc ?>
|
||||||
|
</label><br>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<button type="submit">Enregistrer la configuration</button>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user