Table des matières
- 2026:
- 2025:
4 billet(s) pour septembre 2026
| Notes HTTP Strict Transport Security - HSTS | 2026/09/18 11:04 | Jean-Baptiste |
| Notes GNU Linux GPU carte graphiques | 2026/09/08 15:49 | Jean-Baptiste |
| Notes GNU Linux graphique | 2026/09/08 15:42 | Jean-Baptiste |
| Notes urlencoding - passer des mots de passe en HTTPS | 2026/09/03 17:58 | Jean-Baptiste |
Install de clamav sur redhat7 ou centos7
Remarque avant l'install
Ne pas activer le dépôt rpmforge, au risque d'avoir des conflits de /usr/lib64/libclamav.so.6 /usr/lib64/libclamav.so.7 lors de l'install des paquets liés à clam.
/etc/yum.repos.d/rpmforge.repo
[rpmforge] enabled = 0
Il est préférable de ne pas utiliser le vieux paquet clamd
Install
Source https://doc.owncloud.org/server/7.0/admin_manual/configuration/antivirus_configuration.html
yum install clamav clamav-scanner clamav-scanner-systemd clamav-server clamav-server-systemd clamav-update
/etc/freshclam.conf
DatabaseDirectory /var/lib/clamav UpdateLogFile /var/log/freshclam.log LogFileMaxSize 2M LogSyslog yes DNSDatabaseInfo current.cvd.clamav.net DatabaseMirror db.fr.clamav.net DatabaseMirror database.clamav.net
On met à jour la base de donnée antiviral
freshclam
/etc/clamd.d/scan.conf
LogFile /var/log/clamd.scan LogSyslog yes User clamscan AllowSupplementaryGroups yes LogFileMaxSize 0 LogTime yes TemporaryDirectory /var/tmp DatabaseDirectory /var/lib/clamav LocalSocket /tmp/clamd.socket TCPSocket 3310 TCPAddr 127.0.0.1 MaxThreads 50 #FixStaleSocket yes #MaxConnectionQueueLength 30 #ReadTimeout 300 #ScanPE yes #ScanELF yes #DetectBrokenExecutables yes #ScanOLE2 yes #ScanMail yes #ScanArchive yes #ArchiveBlockEncrypted no
touch /var/log/clamd.scan chown clamscan:clamscan /var/log/clamd.scan
systemctl enable clamd@scan.service systemctl start clamd@scan.service
Debug en cas de pb
Pour tester, si le service ne veut pas démarrer
On s'assure que le service soit bien stoppé
systemctl stop clamd@scan.service
Comme dans notre fichier de conf on a :
/etc/clamd.d/scan.conf
User clamscan
On utilise le compte clamscan
su - clamscan -s /bin/bash
On test
/usr/sbin/clamd -c /etc/clamd.d/scan.conf --nofork=yes
Inotify - Incrontab - Déclencher une action automatiquement à l'arrivé de nouveaux fichiers
Installation
apt-get install incron
Ajout de l’utilisateur jean à la liste des utilisateurs autorisé à faire des incron
echo jean >> /etc/incron.allow
Utiliser votre éditeur favori (vim, nano….)
su - jean export EDITOR=vim incrontab -e
/home/jean/partage/GO IN_CREATE /home/jean/partage/AUTOEXEC.sh
L'incron est enregistré dans /var/spool/incron/jean
L'ajout de n'importe quel fichier dans /home/jean/partage/GO lancera le script /home/jean/partage/AUTOEXEC.sh (le script doit être exécutable et la partition ne doit pas être en noexec)
Info site
Whois
Headers HTTP/HTTPS
Headers
curl -I www.cible.com
En ligne : https://securityheaders.com
Google safebrowsing
Alexa
Mesures d’audience. Amazon
TLS/SSL
Notes imprimante sous GNU/Linux
Voir :
system-config-printer
Voir aussi :
Si jamais CUPS n'est pas installé sur votre machine, installer les paquets cups et cups-client cups-bsd.
Pour une imprimante HP il faut le paquet hplip (CUPS à besoin de /usr/lib/cups/backend/hp)
Pour configurer une imprimante :
http://localhost:631
Voir https://wiki.archlinux.fr/CUPS
lsmod | grep usblp
Il se peut que l'imprimante ne soit pas reconnue dans l'interface de Cups (imprimantes locales). Ceci est dû au fait que le noyau cré un composant qui se trouve dans /dev/usb/lp0. Une règles udev résout ce problème et permet de faire un lien symbolique /dev/lp0 → /dev/usb/lp0.
/var/log/cups/
Ajout imprimante en ligne de commande
Exemple imprimante Zebra (langage ZPL)
Install paquets
apt-get install cups #lprng apt-get install cups-bsd # ou apt-get install lpr
Lister toutes les imprimantes connectées
lpinfo -v
L'imprimante connectées en USB apparait
network ipp network http network lpd serial serial:/dev/ttyS0?baud=115200 serial serial:/dev/ttyS1?baud=115200 serial serial:/dev/ttyS2?baud=115200 serial serial:/dev/ttyS3?baud=115200 network ipps network socket network https network ipp14 direct usb://Zebra%20Technologies/ZTC%20GK420d?serial=28J162400192 network smb
Ajout de l'imprimante
lpadmin -p GK420D -v usb://Zebra%20Technologies/ZTC%20GK420d?serial=28J162400192 -E
Ou
chown root:lp /etc/cups/ppd/GK420d.ppd chmod 640 /etc/cups/ppd/GK420d.ppd lpadmin -p GK420D -v usb://Zebra%20Technologies/ZTC%20GK420d?serial=28J162400192 -m /usr/share/cups/model/HP/DeskJet_882C-cdj880.ppd
Vérif
lpstat -p
printer GK420D is idle. enabled since Thu 04 May 2017 04:32:45 PM CEST
Impression
lp -d GK420D -o raw plop.zpl
Vérifier que l'impression est terminée et OK (Show completed job)
lpstat -W completed
GK420D-1 root 3072 Thu 04 May 2017 04:39:38 PM CEST
Lister toutes les impressions des utilisateurs
lpstat -W all -o
GK420D-2 unknown 3072 Thu 04 May 2017 04:55:46 PM CEST GK420D-1 root 3072 Thu 04 May 2017 04:39:38 PM CEST
La conf est ici
/etc/cups/printers.conf
# Printer configuration file for CUPS v1.7.5 # Written by cupsd # DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING <Printer GK420D> UUID urn:uuid:180e7105-f553-341a-6d6d-a8acdc5a89f4 Info GK420D DeviceURI usb://Zebra%20Technologies/ZTC%20GK420d?serial=28J162400192 State Idle StateTime 1493908365 Type 4 Accepting Yes Shared Yes JobSheets none none QuotaPeriod 0 PageLimit 0 KLimit 0 OpPolicy default ErrorPolicy stop-printer </Printer>
Supprimer une imprimante
Lister les imprimantes
lpstat -p
printer GK420D is idle. enabled since Tue 09 May 2017 01:12:32 PM CEST printer GK420DD is idle. enabled since Tue 09 May 2017 02:20:21 PM CEST
Effacement
lpadmin -x GK420DD
Réactiver l’imprimante
Source : http://superuser.com/questions/280396/how-to-resume-cups-printer-from-command-line
lpstat -p
printer DeskJet-3630-series is idle. enabled since mar. 12 juil. 2016 21:21:34 CEST
ready to print
cupsenable DeskJet-3630-series
lpc status
DeskJet-3630-series:
printer is on device 'hp' speed -1
queuing is enabled
printing is enabled
no entries
daemon present
Effacer et annuler toutes les impressions
cancel -a $NOM_DE_L_IMPRIMANTE # ou cancel -a -x
Administration
Ajouter l'utilisateur dans les groupes lp, lpadmin et sys ?
gpasswd -a jean lp gpasswd -a jean lpadmin
Supervision SNMP
snmpget -c public -v 1 192.168.1.250 hrPrinterDetectedErrorState.1
Autres
Voir /etc/printcap
smb.conf
[global] print command = lpr -r -h -P%p %s
Try adding the 'sf' option to the printer definition in /etc/printcap The 'sf' stands for 'suppress form feeds'.
Config client CUPS
cat > /etc/cups/client.conf << EOF ServerName 192.168.1.1 EOF
Diag
Voir
$ lp attestation-deplacement-fr.pdf lp: Error - ~/.cups/lpoptions file names default destination that does not exist. $ lpstat -p -d printer HP_DeskJet_3630_series is idle. enabled since mer. 06 mai 2020 19:34:55 CEST no system default destination
~/.cups/lpoptions
#Default DeskJet-3630-series Default HP_DeskJet_3630_series
Ou
lpoptions -d HP_DeskJet_3630_series
echo "Hello, world." | lp
sudo cupsctl --debug-logging #sudo cupsctl --no-debug-logging
Voir /var/log/cups/error_log
service cups restart journalctl -u cups.service -f
HTTP_STATE_WAITING Closing for error 32 (Broken pipe) A tester https://forum.manjaro.org/t/printer-doesnt-work-closing-for-error-32-broken-pipe/40678
cat attestation-deplacement-fr.pdf | /usr/lib/cups/filter/pdftopdf 1 1 1 1 ` >out.pdf DEBUG: pdftopdf: No PPD file specified, could not determine whether to log pages or not, so turned off page logging. DEBUG: PDF form flattening command line: pdftocairo -pdf - /tmp/032cf5ea697ad WARNING: temp file: file is damaged WARNING: temp file (object 6 0, offset 85): expected n n obj WARNING: temp file: Attempting to reconstruct cross-reference table WARNING: temp file: object 6 0 not found in file after regenerating cross reference table
pdftocairo -pdf original.pdf out.pdf
Hp
Installer / Reinstaller une imprimante HP
hp-setup -i
hp-check est fait pour RedHat. Pas très efficace.
Pb
Err invalid deviceid ret=-9: Resource temporarily unavailable
Suite à passage de Debian 9 à Debian 10
-- Boot b860f46144c6442c86d06b19bc47ea20 -- janv. 21 22:38:57 portable hpfax[131730]: [131730]: error: Failed to create /var/spool/cups/tmp/.hplip janv. 21 22:40:32 portable hp[136572]: io/hpmud/musb.c 770: invalid deviceid ret=-9: Resource temporarily unavailable déc. 28 18:20:35 portable hp[71827]: io/hpmud/musb.c 770: invalid deviceid ret=-9: Resource temporarily unavailable déc. 28 18:20:35 portable hp[71827]: io/hpmud/musb.c 561: released ff/4/1 interface déc. 28 18:20:35 portable hp[71827]: prnt/backend/hp.c 825: INFO: open device failed stat=12: hp:/usb/DeskJet_3630_series?serial=CN5CS2H5YV067P; will retry in 30 secon> déc. 28 18:21:05 portable hp[71827]: io/hpmud/musb.c 427: Found interface conf=0, iface=1, altset=0, index=1
Solution
Pas très clair, à vérif
apt-get purge ipp-usb apt-get install cups apt-get reinstall hplip hplip-data hp-setup -i
Ansible inventory script - inventaire dynamique 1
Voir :
Voir aussi :
In Ansible 2.10 and later, inventory scripts moved to their associated collections. Many are now in the ansible-community/contrib-scripts repository. We recommend you use Inventory plugins instead.
Nous allons coder un inventory script en bash en mode “hello world”
Voici le script bash avec des données codés en dures dedans, c'est moche mais c'est juste pour un PoC.
inv.sh
#! /bin/bash set -euo pipefail IFS=$' \t\n' export LANG=C SCRIPT_NAME="$(basename "$0")" trap 'rm -f "$TMP_INV_INI"' EXIT TMP_INV_INI="$(mktemp --suffix=_"${SCRIPT_NAME%%.*}".ini)" mk_ini_tmp_inv() { cat <<-EOF >"$TMP_INV_INI" [all:vars] os = linux [web] srv-web1 web=1 srv-web2 web=2 [db] srv-db1 db=1 srv-db2 db=2 [plop] test-ansible EOF } arg_list() { mk_ini_tmp_inv ansible-inventory -i "$TMP_INV_INI" --list } arg_host() { mk_ini_tmp_inv ansible-inventory -i "$TMP_INV_INI" --host "$1" } usage() { ansible-doc -t inventory script } while [ "${1-}" != "" ]; do case $1 in --list ) shift arg_list ;; --host ) shift arg_host "$1" ;; -h | --help ) usage exit 0 ;; --) # End of all options shift break ;; -*) echo "SCRIPT_NAME: invalid option" >&2 echo "Try '$SCRIPT_NAME --help' for more information." >&2 exit 1 ;; *) usage ;; esac shift done
Rendons le script exécutable
chmod +x inv.sh
Nous testons la sortie de notre script bash
./inv.sh --list
{ "_meta": { "hostvars": { "srv-db1": { "db": 1, "os": "linux" }, "srv-db2": { "db": 2, "os": "linux" }, "srv-web1": { "os": "linux", "web": 1 }, "srv-web2": { "os": "linux", "web": 2 }, "test-ansible": { "os": "linux" } } }, "all": { "children": [ "db", "plop", "ungrouped", "web" ] }, "db": { "hosts": [ "srv-db1", "srv-db2" ] }, "plop": { "hosts": [ "test-ansible" ] }, "web": { "hosts": [ "srv-web1", "srv-web2" ] } }
Nous testons de nouveau la sortie de notre script mais pour un host spécifique cette fois
./inv.sh --host srv-web1
{ "os": "linux", "web": 1 }
A présent testons avec Ansible :
$ ansible -i inv.sh -m ping plop [WARNING]: * Failed to parse /home/jean/tmp/inv.sh with script plugin: Inventory script (/home/jean/tmp/inv.sh) had an execution error: [WARNING]: * Failed to parse /home/jean/tmp/inv.sh with ini plugin: /home/jean/tmp/inv.sh:3: Expected key=value host variable assignment, got: -euo [WARNING]: Unable to parse /home/jean/tmp/inv.sh as an inventory source [WARNING]: No inventory was parsed, only implicit localhost is available [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all' [WARNING]: Could not match supplied host pattern, ignoring: plop
Ça ne marche pas. Ansible s'attend à trouver un inventaire au format ini et à la place il a du bash.
Les inventory script doivent être en Python. J'ai essayé de renommer ce script inv.sh en inv.py mais ça ne marche pas.
Nous allons coder un wrapper Python qui lance notre script bash.
inv.py
#! /usr/bin/env python3 import os import argparse parser = argparse.ArgumentParser() parser.add_argument('--list', action='store_true') parser.add_argument('--host') args = parser.parse_args() if args.list: os.system('bash ./inv.sh --list') elif args.host: os.system(f'bash ./inv.sh --host {args.host}')
Rendons ce script Python exécutable
chmod +x inv.py
Et ça marche :
$ ansible -i inv.py -m ping plop
test-ansible | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": false,
"ping": "pong"
}
Autres
Voir
Enabled Variable
Retrieve the enabled state from the given dict of host variables. The enabled variable may be specified using dot notation, e.g: 'foo.bar'
