67 lines
1.4 KiB
Bash
Executable File
67 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Vérifie qu'on est bien en root
|
|
if [ $(id -u) -ne 0 ]
|
|
then
|
|
echo "Ce script doit être executé en root" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Récupération de la configuration
|
|
test -f /etc/suidchecker.conf && . /etc/suidchecker.conf || . suidchecker.conf
|
|
|
|
export DATABASE
|
|
export INSTALL_PATH
|
|
|
|
# Récupération des paramètres
|
|
OPTS=$(getopt -o h -l init,reinit,add,check,help -- "$@")
|
|
eval set -- $OPTS
|
|
|
|
# On conserve le code de sortie des sous-scripts
|
|
set -e
|
|
|
|
usage() {
|
|
# Définition du message d'aide
|
|
echo "Utilisation du script :"
|
|
echo -e "\t--init : initialise la base de données"
|
|
echo -e "\t--reinit : réinitialise la base de données"
|
|
echo -e "\t--add : parcours l'arborescence et ajoute les fichiers ayant le bit SUID qui n'existent pas dans la base"
|
|
echo -e "\t--check : vérifie les fichiers répertoriés dans la base"
|
|
echo -e "\t--help, -h : affiche ce message"
|
|
}
|
|
|
|
# Initialisation
|
|
init() {
|
|
$INSTALL_PATH/init.sh
|
|
}
|
|
|
|
# Réinitialisation
|
|
reinit() {
|
|
rm $DATABASE
|
|
init
|
|
}
|
|
|
|
# Recherche et ajout de nouveaux fichiers
|
|
add() {
|
|
$INSTALL_PATH/add.sh
|
|
}
|
|
|
|
# Vérification des fichiers indexés
|
|
check() {
|
|
$INSTALL_PATH/check.sh
|
|
}
|
|
|
|
# Pris en compte des paramètres
|
|
while true ; do
|
|
case "$1" in
|
|
-h|--help) usage; exit 0;;
|
|
--init) init; shift;;
|
|
--reinit) reinit; shift;;
|
|
--add) add; shift;;
|
|
--check) check; shift;;
|
|
--) shift; break;;
|
|
esac
|
|
done
|
|
|
|
exit 0
|