|
#!/bin/bash
|
|
#
|
|
#Comprueba si el usuario tiene añadidos los certificados de la FNMT, si no lo están
|
|
#los añade a su perfil de Iceweasel / Firefox y Chromium / Chrome
|
|
#
|
|
#
|
|
# Licensed under the GNU GPL version 2, as publicshed by the FSF;
|
|
# see /usr/share/common-licenses/GPL-2 on Debian systems or visit
|
|
# www.fsf.org.
|
|
#
|
|
|
|
#
|
|
#Ricardo Salgado Cid IESO Galisteo
|
|
#15/10/2014
|
|
#18/03/2015 Añadido FNMT RCM y Componentes
|
|
#24/03/2015 Añadida gestión de chrome/chromium
|
|
|
|
FNMTDIR="/usr/local/share/ca-certificates/FNMT/"
|
|
|
|
if [ ! -d "$FMMTDIR" ] ; then
|
|
mkdir -p $FNMTDIR
|
|
fi
|
|
|
|
if [ ! -f "${FNMTDIR}AC_Raiz_FNMT-RCM.crt" ]; then
|
|
wget --no-check-certificate https://www.sede.fnmt.gob.es/documents/11614/116099/AC_Raiz_FNMT-RCM_SHA256.cer -O ${FNMTDIR}AC_Raiz_FNMT-RCM.crt
|
|
update-ca-certificates
|
|
fi
|
|
|
|
|
|
if [ ! -f "${FNMTDIR}FNMTClase2CA.crt" ]; then
|
|
wget https://www.sede.fnmt.gob.es/documents/11614/116099/FNMTClase2CA.cer -O ${FNMTDIR}FNMTClase2CA.crt
|
|
update-ca-certificates
|
|
fi
|
|
|
|
if [ ! -f "${FNMTDIR}AC_Componentes_Informaticos.crt" ]; then
|
|
wget https://www.sede.fnmt.gob.es/documents/11614/116099/AC_Componentes_Informaticos_SHA256.cer -O ${FNMTDIR}AC_Componentes_Informaticos.crt
|
|
update-ca-certificates
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ ! -f /usr/bin/certutil ]; then
|
|
echo "Archivo certutil no encontrdado. Instalando el paquete libnss3-tools."
|
|
apt-get -y install libnss3-tools
|
|
fi
|
|
|
|
echo > password-file
|
|
for pathusuario in $(find /home/profesor /home/alumnos -maxdepth 1 -type d); do
|
|
if [ "$pathusuario" \= "/home/profesor/dpto" -o "$pathusuario" \= "/home/profesor" -o "$pathusuario" \= "/home/alumnos" ]; then
|
|
continue
|
|
fi
|
|
usuario=$(echo $pathusuario | cut -d"/" -f4)
|
|
|
|
##Iceweasel/Firefox
|
|
if [ -d ${pathusuario}/.mozilla/firefox/ ]; then
|
|
pathmozilla="${pathusuario}/.mozilla/firefox/"
|
|
else
|
|
echo "El usuario $usuario no tiene perfil de iceweasel"
|
|
pathmozilla=""
|
|
fi
|
|
##Chromium/Chrome
|
|
pathchrome=${pathusuario}/.pki/nssdb
|
|
if [ ! -d "$pathchrome" ]; then
|
|
mkdir -p ${pathchrome}
|
|
#HACK:para la creación del repositorio de certificados hace falta un password
|
|
#Usamos un password vacio, como hasta ahora.
|
|
certutil -N -f password-file -@ password-file -d sql:${pathchrome}
|
|
chown -R ${usuario}:${usuario} ${pathusuario}/.pki
|
|
chmod 700 ${pathusuario}/.pki
|
|
fi
|
|
|
|
certfile=$(find ${pathmozilla} ${pathchrome} \( -name cert9.db -o -name cert8.db \))
|
|
for db in $certfile; do
|
|
certdir=$(dirname ${db})
|
|
tipo=$(basename ${db})
|
|
for certificado in ${FNMTDIR}* ; do
|
|
nombre_cert=$(basename $certificado .crt)
|
|
case "$tipo" in
|
|
"cert8.db")
|
|
if ! certutil -L -d $certdir | grep -q "${nombre_cert}"; then
|
|
echo Añadiendo ${nombre_cert} a $certdir
|
|
certutil -A -n "${nombre_cert}" -t 'C,,' -i $certificado -d $certdir
|
|
fi
|
|
;;
|
|
"cert9.db")
|
|
if ! certutil -L -d sql:${certdir} | grep -q "${nombre_cert}"; then
|
|
echo Añadiendo ${nombre_cert} a $certdir
|
|
certutil -A -n "${nombre_cert}" -t 'C,,' -i $certificado -d sql:${certdir}
|
|
fi
|
|
;;
|
|
|
|
esac
|
|
done
|
|
done
|
|
done
|
|
rm password-file
|
|
|