Add docker-fence v1 with tests and docs
This commit is contained in:
commit
305cb562f8
46 files changed
+5473
No files matched your search
+486
@@ -0,0 +1,486 @@
|
||||
# shellcheck shell=bash
|
||||
# Every message of the tool, in English and French. Each value is a
|
||||
# printf format: a literal "%" is written "%%". Values from outside are
|
||||
# always passed as arguments, never inside the format.
|
||||
|
||||
declare -gA MSG_en=(
|
||||
[e_prefix]='error:'
|
||||
[w_prefix]='warning:'
|
||||
[block_header]='managed by docker-fence, do not edit by hand'
|
||||
|
||||
[v_int]='invalid value "%s": integer expected between %s'
|
||||
[v_ipv4]='invalid IPv4 address: "%s"'
|
||||
[v_ipv4_any]='"%s" covers every address: use "any" in allow, never in admin'
|
||||
[v_ipv4_hostbits]='"%s": host bits are set outside the mask (network address expected)'
|
||||
[v_port]='invalid port: "%s" (1 to 65535, or range a-b)'
|
||||
[v_port_range]='invalid port range: "%s" (a must be lower than b)'
|
||||
[v_proto]='invalid protocol: "%s" (tcp or udp)'
|
||||
[v_iface]='invalid interface name: "%s" (at most 15 characters among A-Z a-z 0-9 _ . -, trailing "+" accepted)'
|
||||
[v_path]='invalid path: "%s" (absolute path, characters A-Z a-z 0-9 _ . / -)'
|
||||
[v_bin]='invalid command: "%s" (plain name or absolute path)'
|
||||
[v_rate]='invalid rate: "%s" (for example 20/min)'
|
||||
[v_prefix]='invalid log prefix: "%s" (at most %s characters among A-Z a-z 0-9 _ . : -)'
|
||||
[v_chain]='invalid chain name: "%s" (at most %s characters among A-Z a-z 0-9 _ -)'
|
||||
[v_chain_reserved]='reserved chain name: "%s" (no DOCKER*, ufw-*, nor a kernel chain or target name)'
|
||||
[v_marker]='invalid block marker: "%s" (at most 40 characters among A-Z a-z 0-9 _ -)'
|
||||
[v_unit]='invalid unit name: "%s" (at most 64 characters among A-Z a-z 0-9 _ -)'
|
||||
[v_since]='invalid date: "%s" (for example "24 hours ago" or "2026-01-31 08:00")'
|
||||
[v_mode]='invalid mode: "%s" (observe or enforce)'
|
||||
[v_lang]='invalid language: "%s" (fr or en)'
|
||||
[v_unknown]='unknown setting: "%s"'
|
||||
|
||||
[e_syntax]='expected syntax: %s'
|
||||
[e_comment]='"#" must follow a blank to start a comment'
|
||||
[e_charset]='forbidden character: "%s" (nothing is interpreted by the shell)'
|
||||
[e_unknown_directive]='unknown directive: "%s"'
|
||||
[e_one_value]='"%s" takes exactly one value'
|
||||
[e_duplicate]='same rule as line %s'
|
||||
[e_no_admin]='at least one "admin" directive is required'
|
||||
[e_same_prefix]='log_prefix_observe and log_prefix_drop must differ'
|
||||
[e_no_config]='configuration file missing or unreadable: %s (see "docker-fence init")'
|
||||
[e_perm_owner]='%s must be owned by root (or by the user running the tool)'
|
||||
[e_perm_mode]='%s is writable by group or others (mode %s): chmod go-w'
|
||||
[e_env]='invalid variable %s: "%s"'
|
||||
[e_option]='invalid option: %s'
|
||||
[e_usage]='invalid usage: %s (see "docker-fence --help")'
|
||||
|
||||
[i_versions]='bash %s; docker %s; %s; %s'
|
||||
[w_missing_bin]='command not found: %s'
|
||||
[e_missing_bin]='command not found: %s'
|
||||
[e_docker_no_iptables]='%s disables iptables in Docker: not supported'
|
||||
[e_docker_nftables]='%s enables the native nftables firewall backend of Docker: not supported'
|
||||
[w_ipv6]='%s enables IPv6: IPv6 traffic is not filtered by docker-fence'
|
||||
[w_macvlan]='%s networks found (%s): their traffic bypasses DOCKER-USER and is not filtered'
|
||||
[w_no_docker]='docker unreachable: containers will not be named'
|
||||
|
||||
[e_no_rules]='rules file missing or unreadable: %s'
|
||||
[e_block_twice]='%s contains the start of block "%s" twice'
|
||||
[e_block_end]='%s contains an end of block "%s" without a start'
|
||||
[e_block_unclosed]='%s contains a block "%s" without an end'
|
||||
[e_legacy_present]='%s contains the original ufw-docker block (below): run again with --replace-legacy to replace it'
|
||||
[w_legacy_unknown]='the original block differs from the known version (differences below)'
|
||||
[e_legacy_unknown]='unknown original block: review the differences, then run again with --replace-legacy --force'
|
||||
[e_legacy_already]='%s already contains an original ufw-docker block'
|
||||
[e_no_legacy_saved]='no saved original block: %s'
|
||||
[i_legacy_saved]='original block saved: %s'
|
||||
[e_backup]='cannot write a backup in %s'
|
||||
[i_backup]='backup: %s'
|
||||
[e_write]='cannot write: %s'
|
||||
[i_written]='written: %s'
|
||||
[i_unchanged]='%s is already up to date, nothing to write'
|
||||
[i_install_done]='block installed; it loads on the next "ufw reload" (or use "docker-fence apply")'
|
||||
[i_log_unwritable]='log not writable: %s'
|
||||
[i_running]='running: %s'
|
||||
[i_config_ok]='configuration valid: %s (mode %s; %s admin, %s allow, %s container_to_host)'
|
||||
|
||||
[e_pending]='an automatic rollback is pending (%s): run "docker-fence confirm" or "docker-fence rollback" first'
|
||||
[e_ufw_inactive]='UFW is inactive: "ufw reload" would load nothing'
|
||||
[e_timer]='cannot schedule the rollback (%s): file restored, nothing was reloaded'
|
||||
[i_timer]='automatic rollback scheduled in %s s (unit %s)'
|
||||
[e_reload]='"ufw reload" failed'
|
||||
[e_verify_jump]='after reload, DOCKER-USER does not jump to %s'
|
||||
[e_verify_empty]='after reload, chain %s is empty'
|
||||
[e_verify_c2h]='after reload, container_to_host rule %s %s is missing from ufw-after-input'
|
||||
[e_apply_failed]='apply cancelled: rollback done'
|
||||
[i_apply_done]='block loaded (mode %s)'
|
||||
[i_confirm]='Confirm with "docker-fence confirm" within %s seconds, or the change rolls back automatically.'
|
||||
[i_nothing_pending]='no rollback pending (already confirmed, or already rolled back: see "docker-fence status")'
|
||||
[w_timer_stop]='cannot stop the timer: %s'
|
||||
[i_confirmed]='confirmed: the automatic rollback is cancelled'
|
||||
[e_no_backup]='backup missing or unreadable: %s'
|
||||
[e_no_backups]='no backup in %s'
|
||||
[i_restored]='restored: %s -> %s'
|
||||
[i_kernel_cleaned]='chain %s removed from the kernel'
|
||||
|
||||
[i_not_installed]='no managed block in %s'
|
||||
[i_uninstalled]='block removed (UFW inactive: nothing reloaded)'
|
||||
[i_uninstalled_reloaded]='block removed and UFW reloaded'
|
||||
[w_rules_unreadable]='rules file unreadable: %s'
|
||||
[i_status_block]='block installed in %s (mode %s)'
|
||||
[i_status_noblock]='no block installed in %s'
|
||||
[i_status_pending]='rollback pending (%s), backup: %s'
|
||||
[i_status_jump_yes]='jump DOCKER-USER -> %s: present'
|
||||
[i_status_jump_no]='jump DOCKER-USER -> %s: missing'
|
||||
[i_status_counters]='counters:'
|
||||
[i_status_log]='last log lines:'
|
||||
|
||||
[i_report_head]='report since "%s": %s logged packets'
|
||||
[r_count]='count'
|
||||
[r_source]='source'
|
||||
[r_target]='container:internal port'
|
||||
[r_published]='published port'
|
||||
[r_suggestions]='suggested allow lines (port published on the host):'
|
||||
[r_no_published]='%s -> %s: published port not found'
|
||||
|
||||
[p_intro]='ufw commands for host rules, in a safe order. docker-fence runs none of them.'
|
||||
[p_never_run]='Keep an admin session open and test each access from another session.'
|
||||
[p_admin]='Admin access to the host (first)'
|
||||
[p_allow]='allow exceptions: only for a port served by the host or a host-network container (a port published by Docker is covered by docker-fence)'
|
||||
[p_c2h]='container_to_host fallback, only if these rules are not loaded in ufw-after-input (one command per Docker network)'
|
||||
[p_no_subnets]='no Docker subnet found (docker unreachable?)'
|
||||
[p_delete]='Removal of old, too broad rules (last, review one by one)'
|
||||
[p_ssh_warning]='Never remove the SSH access rule before testing every admin address.'
|
||||
[p_no_added]='no rule read ("ufw show added" needs root)'
|
||||
[p_host_network]='Containers in network_mode: host bypass docker-fence: their ports are covered by the ufw rules above.'
|
||||
|
||||
[e_exists]='%s already exists (use --force to overwrite it)'
|
||||
[i_init_done]='template written: %s'
|
||||
[t_title]='docker-fence: configuration (one directive per line, see README)'
|
||||
[t_format]='Format: directive value...; "#" starts a comment; nothing is interpreted by the shell.'
|
||||
[t_defaults]='Commented settings show their default value.'
|
||||
[t_admin]='Source allowed to every published port (at least one).'
|
||||
[t_admin_doc]='192.0.2.10 is a documentation address: replace it.'
|
||||
[t_allow]='Exception: port published on the host and allowed source.'
|
||||
[t_c2h]='A container reaches this host port (INPUT rule; default interface br-+).'
|
||||
[t_trusted]='Trusted container interfaces (default br-+ and docker0).'
|
||||
[t_settings]='Settings'
|
||||
[o_header]='effective configuration, read from %s'
|
||||
[o_default]='default'
|
||||
[o_option]='option'
|
||||
[o_env]='environment'
|
||||
[o_file]='line %s'
|
||||
|
||||
[d_mode]='mode: observe logs what would be blocked; enforce blocks'
|
||||
[d_rollback_seconds]='delay before automatic rollback after apply (seconds, 30 to 86400)'
|
||||
[d_lang]='message language: fr or en'
|
||||
[d_log_rate_observe]='log rate in observe mode'
|
||||
[d_log_burst_observe]='log burst in observe mode'
|
||||
[d_log_rate_enforce]='log rate in enforce mode'
|
||||
[d_log_burst_enforce]='log burst in enforce mode'
|
||||
[d_log_prefix_observe]='log prefix in observe mode (at most 28 characters)'
|
||||
[d_log_prefix_drop]='log prefix in enforce mode (at most 28 characters)'
|
||||
[d_log_level]='kernel log level (0 to 7)'
|
||||
[d_log_file]='log of the actions of the tool'
|
||||
[d_chain]='chain name; the reject chain is <name>-deny'
|
||||
[d_block_marker]='marker of the # BEGIN and # END lines of the block'
|
||||
[d_unit_name]='systemd unit of the automatic rollback'
|
||||
[d_ufw_after_rules]='rules file to edit'
|
||||
[d_docker_daemon_json]='Docker daemon configuration (environment checks)'
|
||||
[d_backup_dir]='backup directory'
|
||||
[d_backup_keep]='number of backups kept'
|
||||
[d_report_since]='default report period (journalctl --since syntax)'
|
||||
[d_bin_iptables]='iptables command'
|
||||
[d_bin_ufw]='ufw command'
|
||||
[d_bin_docker]='docker command'
|
||||
[d_bin_journalctl]='journalctl command'
|
||||
[d_bin_systemd_run]='systemd-run command'
|
||||
[d_bin_systemctl]='systemctl command'
|
||||
|
||||
[usage]='Usage: docker-fence [options] <command> [command options]
|
||||
|
||||
Commands:
|
||||
check validate the configuration and print the generated block
|
||||
status state of the block, the kernel and the log
|
||||
install [--replace-legacy] [--force]
|
||||
write the block into after.rules, without reloading UFW
|
||||
apply [--replace-legacy] [--force]
|
||||
install, then reload with automatic rollback
|
||||
confirm cancel the automatic rollback
|
||||
rollback [--auto] [file] restore the latest backup (or the given one)
|
||||
uninstall [--restore-legacy]
|
||||
remove the managed block
|
||||
report [--since date] observation report
|
||||
ufw-plan print the ufw commands for host rules
|
||||
rules [--color auto|always|never]
|
||||
table of every rule: native UFW and docker-fence
|
||||
init [--output file] [--force]
|
||||
write a configuration template ("-": standard output)
|
||||
show-config effective configuration and origin of each value
|
||||
|
||||
Options:
|
||||
-c, --config file configuration file
|
||||
--mode observe|enforce override the mode of the file
|
||||
--lang fr|en message language
|
||||
--set directive=value override a setting of the file
|
||||
-q, --quiet print errors only
|
||||
-v, --verbose print the commands that run
|
||||
-h, --help this help
|
||||
--version version
|
||||
|
||||
Exit codes: 0 success; 1 configuration or usage; 2 unsupported environment;
|
||||
3 original ufw-docker block present; 4 apply failed (rollback done).'
|
||||
|
||||
[l_origin]='ORIGIN'
|
||||
[l_traffic]='TRAFFIC'
|
||||
[l_action]='ACTION'
|
||||
[l_to]='TO'
|
||||
[l_from]='FROM'
|
||||
[l_state]='STATE'
|
||||
[l_note]='NOTE'
|
||||
[l_any]='any'
|
||||
[l_on]='on %s'
|
||||
[l_iface]='iface %s'
|
||||
[l_host_in]='host input'
|
||||
[l_host_out]='host output'
|
||||
[l_routed]='routed'
|
||||
[l_published]='published ports'
|
||||
[l_c2h]='container -> host'
|
||||
[l_all_published]='all published ports'
|
||||
[l_other_published]='other published ports'
|
||||
[l_active]='active'
|
||||
[l_loaded]='loaded'
|
||||
[l_not_loaded]='not loaded'
|
||||
[l_unknown]='unknown (root?)'
|
||||
[l_default_policy]='default policy'
|
||||
[l_replies]='replies to established connections'
|
||||
[l_containers]='trusted containers'
|
||||
[l_final_observe]='observe mode: logged, not blocked'
|
||||
[l_final_enforce]='enforce mode: logged and dropped'
|
||||
[w_ufw_unreadable]='cannot read "ufw status verbose" (root needed): UFW rules not listed'
|
||||
[w_ufw_inactive_rules]='UFW is inactive: no UFW rule applies, and "docker-fence apply" needs UFW active'
|
||||
)
|
||||
|
||||
declare -gA MSG_fr=(
|
||||
[e_prefix]='erreur :'
|
||||
[w_prefix]='attention :'
|
||||
[block_header]='géré par docker-fence, ne pas modifier à la main'
|
||||
|
||||
# Value validation (argument 1: value; 2: detail).
|
||||
[v_int]='valeur « %s » invalide : entier attendu entre %s'
|
||||
[v_ipv4]='adresse IPv4 invalide : « %s »'
|
||||
[v_ipv4_any]='« %s » couvre toutes les adresses : utilisez « any » dans allow, jamais dans admin'
|
||||
[v_ipv4_hostbits]='« %s » : des bits d'"'"'hôte sont posés hors du masque (adresse de réseau attendue)'
|
||||
[v_port]='port invalide : « %s » (1 à 65535, ou plage a-b)'
|
||||
[v_port_range]='plage de ports invalide : « %s » (a doit être inférieur à b)'
|
||||
[v_proto]='protocole invalide : « %s » (tcp ou udp)'
|
||||
[v_iface]='nom d'"'"'interface invalide : « %s » (15 caractères au plus parmi A-Z a-z 0-9 _ . -, « + » final accepté)'
|
||||
[v_path]='chemin invalide : « %s » (chemin absolu, caractères A-Z a-z 0-9 _ . / -)'
|
||||
[v_bin]='commande invalide : « %s » (nom simple ou chemin absolu)'
|
||||
[v_rate]='cadence invalide : « %s » (par exemple 20/min)'
|
||||
[v_prefix]='préfixe de journal invalide : « %s » (%s caractères au plus parmi A-Z a-z 0-9 _ . : -)'
|
||||
[v_chain]='nom de chaîne invalide : « %s » (%s caractères au plus parmi A-Z a-z 0-9 _ -)'
|
||||
[v_chain_reserved]='nom de chaîne réservé : « %s » (pas de DOCKER*, ufw-*, ni de nom de chaîne ou de cible du noyau)'
|
||||
[v_marker]='marqueur de bloc invalide : « %s » (40 caractères au plus parmi A-Z a-z 0-9 _ -)'
|
||||
[v_unit]='nom d'"'"'unité invalide : « %s » (64 caractères au plus parmi A-Z a-z 0-9 _ -)'
|
||||
[v_since]='date invalide : « %s » (par exemple « 24 hours ago » ou « 2026-01-31 08:00 »)'
|
||||
[v_mode]='mode invalide : « %s » (observe ou enforce)'
|
||||
[v_lang]='langue invalide : « %s » (fr ou en)'
|
||||
[v_unknown]='réglage inconnu : « %s »'
|
||||
|
||||
# File parsing.
|
||||
[e_syntax]='syntaxe attendue : %s'
|
||||
[e_comment]='« # » doit être précédé d'"'"'un blanc pour commencer un commentaire'
|
||||
[e_charset]='caractère interdit : « %s » (rien n'"'"'est interprété par le shell)'
|
||||
[e_unknown_directive]='directive inconnue : « %s »'
|
||||
[e_one_value]='« %s » attend une seule valeur'
|
||||
[e_duplicate]='règle identique à celle de la ligne %s'
|
||||
[e_no_admin]='au moins une directive « admin » est obligatoire'
|
||||
[e_same_prefix]='log_prefix_observe et log_prefix_drop doivent être différents'
|
||||
[e_no_config]='fichier de configuration introuvable ou illisible : %s (voir « docker-fence init »)'
|
||||
[e_perm_owner]='%s doit appartenir à root (ou à l'"'"'utilisateur qui lance l'"'"'outil)'
|
||||
[e_perm_mode]='%s est modifiable par le groupe ou les autres (droits %s) : chmod go-w'
|
||||
[e_env]='variable %s invalide : « %s »'
|
||||
[e_option]='option invalide : %s'
|
||||
[e_usage]='usage invalide : %s (voir « docker-fence --help »)'
|
||||
|
||||
# Environment.
|
||||
[i_versions]='bash %s ; docker %s ; %s ; %s'
|
||||
[w_missing_bin]='commande introuvable : %s'
|
||||
[e_missing_bin]='commande introuvable : %s'
|
||||
[e_docker_no_iptables]='%s désactive iptables dans Docker : non supporté'
|
||||
[e_docker_nftables]='%s active le pare-feu nftables natif de Docker : non supporté'
|
||||
[w_ipv6]='%s active IPv6 : le trafic IPv6 n'"'"'est pas filtré par docker-fence'
|
||||
[w_macvlan]='réseaux %s présents (%s) : leur trafic ne passe pas par DOCKER-USER et n'"'"'est pas filtré'
|
||||
[w_no_docker]='docker injoignable : les conteneurs ne seront pas nommés'
|
||||
|
||||
# Rules file.
|
||||
[e_no_rules]='fichier de règles introuvable ou illisible : %s'
|
||||
[e_block_twice]='%s contient deux fois le début du bloc « %s »'
|
||||
[e_block_end]='%s contient une fin du bloc « %s » sans début'
|
||||
[e_block_unclosed]='%s contient un bloc « %s » sans fin'
|
||||
[e_legacy_present]='%s contient le bloc d'"'"'origine d'"'"'ufw-docker (ci-dessous) : relancez avec --replace-legacy pour le remplacer'
|
||||
[w_legacy_unknown]='le bloc d'"'"'origine diffère de la version connue (différences ci-dessous)'
|
||||
[e_legacy_unknown]='bloc d'"'"'origine inconnu : vérifiez les différences, puis relancez avec --replace-legacy --force'
|
||||
[e_legacy_already]='%s contient déjà un bloc d'"'"'origine d'"'"'ufw-docker'
|
||||
[e_no_legacy_saved]='aucun bloc d'"'"'origine sauvegardé : %s'
|
||||
[i_legacy_saved]='bloc d'"'"'origine sauvegardé : %s'
|
||||
[e_backup]='sauvegarde impossible dans %s'
|
||||
[i_backup]='sauvegarde : %s'
|
||||
[e_write]='écriture impossible : %s'
|
||||
[i_written]='écrit : %s'
|
||||
[i_unchanged]='%s est déjà à jour, rien à écrire'
|
||||
[i_install_done]='bloc installé ; il sera chargé au prochain « ufw reload » (ou utilisez « docker-fence apply »)'
|
||||
[i_log_unwritable]='journal non modifiable : %s'
|
||||
[i_running]='exécution : %s'
|
||||
[i_config_ok]='configuration valide : %s (mode %s ; %s admin, %s allow, %s container_to_host)'
|
||||
|
||||
# apply, confirm, rollback.
|
||||
[e_pending]='un retour arrière automatique est en attente (%s) : « docker-fence confirm » ou « docker-fence rollback » d'"'"'abord'
|
||||
[e_ufw_inactive]='UFW est inactif : « ufw reload » ne chargerait rien'
|
||||
[e_timer]='impossible de programmer le retour arrière (%s) : fichier restauré, rien n'"'"'a été rechargé'
|
||||
[i_timer]='retour arrière automatique programmé dans %s s (unité %s)'
|
||||
[e_reload]='échec de « ufw reload »'
|
||||
[e_verify_jump]='après rechargement, DOCKER-USER ne saute pas vers %s'
|
||||
[e_verify_empty]='après rechargement, la chaîne %s est vide'
|
||||
[e_verify_c2h]='après rechargement, la règle container_to_host %s %s est absente de ufw-after-input'
|
||||
[e_apply_failed]='application annulée : retour arrière effectué'
|
||||
[i_apply_done]='bloc chargé (mode %s)'
|
||||
[i_confirm]='Confirmez avec « docker-fence confirm » avant %s secondes, sinon retour arrière automatique.'
|
||||
[i_nothing_pending]='aucun retour arrière en attente (déjà confirmé, ou déjà effectué : voir « docker-fence status »)'
|
||||
[w_timer_stop]='arrêt du minuteur impossible : %s'
|
||||
[i_confirmed]='confirmé : le retour arrière automatique est annulé'
|
||||
[e_no_backup]='sauvegarde introuvable ou illisible : %s'
|
||||
[e_no_backups]='aucune sauvegarde dans %s'
|
||||
[i_restored]='restauré : %s -> %s'
|
||||
[i_kernel_cleaned]='chaîne %s retirée du noyau'
|
||||
|
||||
# uninstall, status.
|
||||
[i_not_installed]='aucun bloc géré dans %s'
|
||||
[i_uninstalled]='bloc retiré (UFW inactif : rien rechargé)'
|
||||
[i_uninstalled_reloaded]='bloc retiré et UFW rechargé'
|
||||
[w_rules_unreadable]='fichier de règles illisible : %s'
|
||||
[i_status_block]='bloc installé dans %s (mode %s)'
|
||||
[i_status_noblock]='aucun bloc installé dans %s'
|
||||
[i_status_pending]='retour arrière en attente (%s), sauvegarde : %s'
|
||||
[i_status_jump_yes]='saut DOCKER-USER -> %s : présent'
|
||||
[i_status_jump_no]='saut DOCKER-USER -> %s : absent'
|
||||
[i_status_counters]='compteurs :'
|
||||
[i_status_log]='dernières lignes du journal :'
|
||||
|
||||
# report.
|
||||
[i_report_head]='rapport depuis « %s » : %s paquets journalisés'
|
||||
[r_count]='nombre'
|
||||
[r_source]='source'
|
||||
[r_target]='conteneur:port interne'
|
||||
[r_published]='port publié'
|
||||
[r_suggestions]='lignes allow proposées (port publié sur l'"'"'hôte) :'
|
||||
[r_no_published]='%s -> %s : port publié introuvable'
|
||||
|
||||
# ufw-plan.
|
||||
[p_intro]='Commandes ufw pour les règles d'"'"'hôte, dans l'"'"'ordre sûr. Rien n'"'"'est exécuté par docker-fence.'
|
||||
[p_never_run]='Gardez une session d'"'"'administration ouverte et testez chaque accès depuis une autre session.'
|
||||
[p_admin]='Accès d'"'"'administration à l'"'"'hôte (en premier)'
|
||||
[p_allow]='Exceptions allow : seulement pour un port servi par l'"'"'hôte ou un conteneur en réseau hôte (un port publié par Docker est couvert par docker-fence)'
|
||||
[p_c2h]='Repli container_to_host, seulement si ces règles ne sont pas chargées dans ufw-after-input (une commande par réseau Docker)'
|
||||
[p_no_subnets]='aucun sous-réseau Docker trouvé (docker injoignable ?)'
|
||||
[p_delete]='Suppression des anciennes règles trop larges (en dernier, à examiner une par une)'
|
||||
[p_ssh_warning]='Ne retirez jamais la règle d'"'"'accès SSH avant d'"'"'avoir testé chaque adresse d'"'"'administration.'
|
||||
[p_no_added]='aucune règle lue (« ufw show added » demande les droits root)'
|
||||
[p_host_network]='Les conteneurs en network_mode: host ne passent pas par docker-fence : leurs ports relèvent des règles ufw ci-dessus.'
|
||||
|
||||
# init, show-config.
|
||||
[e_exists]='%s existe déjà (utilisez --force pour l'"'"'écraser)'
|
||||
[i_init_done]='modèle écrit : %s'
|
||||
[t_title]='docker-fence : configuration (une directive par ligne, voir README)'
|
||||
[t_format]='Format : directive valeur… ; « # » commence un commentaire ; rien n'"'"'est interprété par le shell.'
|
||||
[t_defaults]='Les réglages commentés montrent leur valeur par défaut.'
|
||||
[t_admin]='Source autorisée vers tous les ports publiés (au moins une).'
|
||||
[t_admin_doc]='192.0.2.10 est une adresse de documentation : remplacez-la.'
|
||||
[t_allow]='Exception : port publié sur l'"'"'hôte et source autorisée.'
|
||||
[t_c2h]='Un conteneur joint ce port de l'"'"'hôte (règle INPUT ; interface par défaut br-+).'
|
||||
[t_trusted]='Interfaces de conteneurs de confiance (par défaut br-+ et docker0).'
|
||||
[t_settings]='Réglages'
|
||||
[o_header]='configuration effective, lue dans %s'
|
||||
[o_default]='défaut'
|
||||
[o_option]='option'
|
||||
[o_env]='environnement'
|
||||
[o_file]='ligne %s'
|
||||
|
||||
[d_mode]='mode : observe journalise ce qui serait bloqué ; enforce bloque'
|
||||
[d_rollback_seconds]='délai avant retour arrière automatique après apply (secondes, 30 à 86400)'
|
||||
[d_lang]='langue des messages : fr ou en'
|
||||
[d_log_rate_observe]='cadence du journal en observation'
|
||||
[d_log_burst_observe]='rafale du journal en observation'
|
||||
[d_log_rate_enforce]='cadence du journal en application'
|
||||
[d_log_burst_enforce]='rafale du journal en application'
|
||||
[d_log_prefix_observe]='préfixe de journal en observation (28 caractères au plus)'
|
||||
[d_log_prefix_drop]='préfixe de journal en application (28 caractères au plus)'
|
||||
[d_log_level]='niveau de journal du noyau (0 à 7)'
|
||||
[d_log_file]='journal des actions de l'"'"'outil'
|
||||
[d_chain]='nom de la chaîne ; la chaîne de rejet est <nom>-deny'
|
||||
[d_block_marker]='marqueur des lignes # BEGIN et # END du bloc'
|
||||
[d_unit_name]='unité systemd du retour arrière automatique'
|
||||
[d_ufw_after_rules]='fichier de règles modifié'
|
||||
[d_docker_daemon_json]='configuration du démon Docker (contrôles d'"'"'environnement)'
|
||||
[d_backup_dir]='répertoire des sauvegardes'
|
||||
[d_backup_keep]='nombre de sauvegardes conservées'
|
||||
[d_report_since]='période par défaut du rapport (syntaxe de journalctl --since)'
|
||||
[d_bin_iptables]='commande iptables'
|
||||
[d_bin_ufw]='commande ufw'
|
||||
[d_bin_docker]='commande docker'
|
||||
[d_bin_journalctl]='commande journalctl'
|
||||
[d_bin_systemd_run]='commande systemd-run'
|
||||
[d_bin_systemctl]='commande systemctl'
|
||||
|
||||
[usage]='Usage : docker-fence [options] <commande> [options de la commande]
|
||||
|
||||
Commandes :
|
||||
check valide la configuration et affiche le bloc généré
|
||||
status état du bloc, du noyau et du journal
|
||||
install [--replace-legacy] [--force]
|
||||
écrit le bloc dans after.rules, sans recharger UFW
|
||||
apply [--replace-legacy] [--force]
|
||||
install, puis rechargement avec retour arrière automatique
|
||||
confirm annule le retour arrière automatique
|
||||
rollback [--auto] [fichier] restaure la dernière sauvegarde (ou celle indiquée)
|
||||
uninstall [--restore-legacy]
|
||||
retire le bloc géré
|
||||
report [--since date] rapport d'"'"'observation
|
||||
ufw-plan imprime les commandes ufw pour les règles d'"'"'hôte
|
||||
rules [--color auto|always|never]
|
||||
tableau de toutes les règles : UFW natives et docker-fence
|
||||
init [--output fichier] [--force]
|
||||
écrit un modèle de configuration (« - » : sortie standard)
|
||||
show-config configuration effective et origine de chaque valeur
|
||||
|
||||
Options :
|
||||
-c, --config fichier fichier de configuration
|
||||
--mode observe|enforce remplace le mode du fichier
|
||||
--lang fr|en langue des messages
|
||||
--set directive=valeur remplace un réglage du fichier
|
||||
-q, --quiet n'"'"'affiche que les erreurs
|
||||
-v, --verbose affiche les commandes exécutées
|
||||
-h, --help cette aide
|
||||
--version version
|
||||
|
||||
Codes de retour : 0 succès ; 1 configuration ou usage ; 2 environnement non supporté ;
|
||||
3 bloc d'"'"'origine d'"'"'ufw-docker présent ; 4 échec à l'"'"'application (retour arrière fait).'
|
||||
|
||||
[l_origin]='ORIGINE'
|
||||
[l_traffic]='TRAFIC'
|
||||
[l_action]='ACTION'
|
||||
[l_to]='VERS'
|
||||
[l_from]='DEPUIS'
|
||||
[l_state]='ÉTAT'
|
||||
[l_note]='NOTE'
|
||||
[l_any]='tout'
|
||||
[l_on]='via %s'
|
||||
[l_iface]='interface %s'
|
||||
[l_host_in]='entrant hôte'
|
||||
[l_host_out]='sortant hôte'
|
||||
[l_routed]='routé'
|
||||
[l_published]='ports publiés'
|
||||
[l_c2h]='conteneur -> hôte'
|
||||
[l_all_published]='tous les ports publiés'
|
||||
[l_other_published]='autres ports publiés'
|
||||
[l_active]='actif'
|
||||
[l_loaded]='chargée'
|
||||
[l_not_loaded]='non chargée'
|
||||
[l_unknown]='inconnu (root ?)'
|
||||
[l_default_policy]='politique par défaut'
|
||||
[l_replies]='réponses aux connexions établies'
|
||||
[l_containers]='conteneurs de confiance'
|
||||
[l_final_observe]='mode observe : journalisé, non bloqué'
|
||||
[l_final_enforce]='mode enforce : journalisé et rejeté'
|
||||
[w_ufw_unreadable]='lecture de « ufw status verbose » impossible (root nécessaire) : règles UFW non listées'
|
||||
[w_ufw_inactive_rules]='UFW est inactif : aucune règle UFW ne s'"'"'applique, et « docker-fence apply » exige UFW actif'
|
||||
)
|
||||
|
||||
# fence_fmt KEY [ARGS...]: without arguments, prints the raw format; with
|
||||
# arguments, prints it formatted.
|
||||
fence_fmt() {
|
||||
local key="$1" lang="${CFG[lang]:-en}" f
|
||||
shift
|
||||
if [[ "$lang" == fr ]]; then
|
||||
f="${MSG_fr[$key]-}"
|
||||
else
|
||||
f="${MSG_en[$key]-}"
|
||||
fi
|
||||
[[ -n "$f" ]] || f="$key"
|
||||
if (( $# == 0 )); then
|
||||
printf '%s' "$f"
|
||||
else
|
||||
# shellcheck disable=SC2059
|
||||
printf "$f" "$@"
|
||||
fi
|
||||
}
|
||||
Reference in new issue
Block a user