- Ajout des droits pfx
This commit is contained in:
parent
a59d20fe6a
commit
f0b2715eae
|
|
@ -650,33 +650,38 @@ do_deb_sys_cert_install(){
|
|||
# 1. On s'assure que le groupe technique existe
|
||||
groupadd -f ssl-cert
|
||||
|
||||
# 2. On boucle proprement sur TA liste de services définie en config
|
||||
# 2. On boucle sur la liste de configuration
|
||||
for SVC in $CONFIG_DEB_INSTALL_DEFAULT_CA_SERVICES; do
|
||||
# On ne traite le service QUE s'il est actif sur CETTE machine
|
||||
if systemctl is-active --quiet "$SVC"; then
|
||||
# Récupération de l'utilisateur qui fait tourner le processus
|
||||
PID=$(pgrep -f "$SVC" | head -n1)
|
||||
if [ -n "$PID" ]; then
|
||||
SVC_USER=$(ps -o user= -p "$PID" | tr -d ' ')
|
||||
|
||||
if [ -n "$SVC_USER" ] && [ "$SVC_USER" != "root" ]; then
|
||||
msg_info "🔧 Configuration de $SVC (Utilisateur : $SVC_USER)"
|
||||
# TEST : Est-ce que le service existe physiquement sur cette machine ?
|
||||
if systemctl list-unit-files "$SVC.service" >/dev/null 2>&1; then
|
||||
|
||||
# Ajout au groupe et application des droits
|
||||
usermod -aG ssl-cert "$SVC_USER"
|
||||
# On ne traite que s'il est actif
|
||||
if systemctl is-active --quiet "$SVC"; then
|
||||
PID=$(pgrep -f "$SVC" | head -n1)
|
||||
if [ -n "$PID" ]; then
|
||||
SVC_USER=$(ps -o user= -p "$PID" | tr -d ' ')
|
||||
|
||||
# On applique les droits sur les fichiers générés
|
||||
chown root:ssl-cert /etc/ssl/wildcard/server.key /etc/ssl/wildcard/server.pfx
|
||||
chmod 640 /etc/ssl/wildcard/server.key /etc/ssl/wildcard/server.pfx
|
||||
chmod 644 /etc/ssl/wildcard/server.crt
|
||||
if [ -n "$SVC_USER" ] && [ "$SVC_USER" != "root" ]; then
|
||||
msg_info "🔧 Application des droits pour $SVC ($SVC_USER)"
|
||||
|
||||
# Redémarrage pour valider l'appartenance au groupe
|
||||
systemctl restart "$SVC"
|
||||
msg_success "Service $SVC redémarré avec succès."
|
||||
usermod -aG ssl-cert "$SVC_USER"
|
||||
|
||||
# Application des droits sur les fichiers
|
||||
chown root:ssl-cert /etc/ssl/wildcard/server.key /etc/ssl/wildcard/server.pfx
|
||||
chmod 640 /etc/ssl/wildcard/server.key /etc/ssl/wildcard/server.pfx
|
||||
chmod 644 /etc/ssl/wildcard/server.crt
|
||||
|
||||
# Redémarrage sécurisé
|
||||
systemctl restart "$SVC"
|
||||
msg_success "Service $SVC configuré et redémarré."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# Si le service n'existe pas, on ne dit rien, on passe juste au suivant
|
||||
continue
|
||||
fi
|
||||
# Si le service n'est pas actif, le script passe au suivant sans erreur.
|
||||
done
|
||||
|
||||
# ==================================================================
|
||||
|
|
|
|||
Loading…
Reference in New Issue