diff --git a/src/uu/chcon/locales/en-US.ftl b/src/uu/chcon/locales/en-US.ftl index 66c51f5af..0d18484b0 100644 --- a/src/uu/chcon/locales/en-US.ftl +++ b/src/uu/chcon/locales/en-US.ftl @@ -3,3 +3,56 @@ chcon-about = Change the SELinux security context of each FILE to CONTEXT. chcon-usage = chcon [OPTION]... CONTEXT FILE... chcon [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE... chcon [OPTION]... --reference=RFILE FILE... + +# Help messages +chcon-help-help = Print help information. +chcon-help-dereference = Affect the referent of each symbolic link (this is the default), rather than the symbolic link itself. +chcon-help-no-dereference = Affect symbolic links instead of any referenced file. +chcon-help-preserve-root = Fail to operate recursively on '/'. +chcon-help-no-preserve-root = Do not treat '/' specially (the default). +chcon-help-reference = Use security context of RFILE, rather than specifying a CONTEXT value. +chcon-help-user = Set user USER in the target security context. +chcon-help-role = Set role ROLE in the target security context. +chcon-help-type = Set type TYPE in the target security context. +chcon-help-range = Set range RANGE in the target security context. +chcon-help-recursive = Operate on files and directories recursively. +chcon-help-follow-arg-dir-symlink = If a command line argument is a symbolic link to a directory, traverse it. Only valid when -R is specified. +chcon-help-follow-dir-symlinks = Traverse every symbolic link to a directory encountered. Only valid when -R is specified. +chcon-help-no-follow-symlinks = Do not traverse any symbolic links (default). Only valid when -R is specified. +chcon-help-verbose = Output a diagnostic for every file processed. + +# Error messages - basic validation +chcon-error-no-context-specified = No context is specified +chcon-error-no-files-specified = No files are specified +chcon-error-data-out-of-range = Data is out of range +chcon-error-operation-failed = { $operation } failed +chcon-error-operation-failed-on = { $operation } failed on { $operand } + +# Error messages - argument validation +chcon-error-invalid-context = Invalid security context '{ $context }'. +chcon-error-recursive-no-dereference-require-p = '--recursive' with '--no-dereference' require '-P' +chcon-error-recursive-dereference-require-h-or-l = '--recursive' with '--dereference' require either '-H' or '-L' + +# Operation strings for error context +chcon-op-getting-security-context = Getting security context +chcon-op-file-name-validation = File name validation +chcon-op-getting-meta-data = Getting meta data +chcon-op-modifying-root-path = Modifying root path +chcon-op-accessing = Accessing +chcon-op-reading-directory = Reading directory +chcon-op-reading-cyclic-directory = Reading cyclic directory +chcon-op-applying-partial-context = Applying partial security context to unlabeled file +chcon-op-creating-security-context = Creating security context +chcon-op-setting-security-context-user = Setting security context user +chcon-op-setting-security-context = Setting security context + +# Verbose output +chcon-verbose-changing-context = { $util_name }: changing security context of { $file } + +# Warning messages +chcon-warning-dangerous-recursive-root = It is dangerous to operate recursively on '/'. Use --{ $option } to override this failsafe. +chcon-warning-dangerous-recursive-dir = It is dangerous to operate recursively on { $dir } (same as '/'). Use --{ $option } to override this failsafe. +chcon-warning-circular-directory = Circular directory structure. + This almost certainly means that you have a corrupted file system. + NOTIFY YOUR SYSTEM MANAGER. + The following directory is part of the cycle { $file }. diff --git a/src/uu/chcon/locales/fr-FR.ftl b/src/uu/chcon/locales/fr-FR.ftl new file mode 100644 index 000000000..3fd2cd09a --- /dev/null +++ b/src/uu/chcon/locales/fr-FR.ftl @@ -0,0 +1,58 @@ +chcon-about = Changer le contexte de sécurité SELinux de chaque FICHIER vers CONTEXTE. + Avec --reference, changer le contexte de sécurité de chaque FICHIER vers celui de RFICHIER. +chcon-usage = chcon [OPTION]... CONTEXTE FICHIER... + chcon [OPTION]... [-u UTILISATEUR] [-r RÔLE] [-l PLAGE] [-t TYPE] FICHIER... + chcon [OPTION]... --reference=RFICHIER FICHIER... + +# Messages d'aide +chcon-help-help = Afficher les informations d'aide. +chcon-help-dereference = Affecter la cible de chaque lien symbolique (par défaut), plutôt que le lien symbolique lui-même. +chcon-help-no-dereference = Affecter les liens symboliques au lieu de tout fichier référencé. +chcon-help-preserve-root = Échouer lors de l'opération récursive sur '/'. +chcon-help-no-preserve-root = Ne pas traiter '/' spécialement (par défaut). +chcon-help-reference = Utiliser le contexte de sécurité de RFICHIER, plutôt que de spécifier une valeur CONTEXTE. +chcon-help-user = Définir l'utilisateur UTILISATEUR dans le contexte de sécurité cible. +chcon-help-role = Définir le rôle RÔLE dans le contexte de sécurité cible. +chcon-help-type = Définir le type TYPE dans le contexte de sécurité cible. +chcon-help-range = Définir la plage PLAGE dans le contexte de sécurité cible. +chcon-help-recursive = Opérer sur les fichiers et répertoires de manière récursive. +chcon-help-follow-arg-dir-symlink = Si un argument de ligne de commande est un lien symbolique vers un répertoire, le traverser. Valide uniquement quand -R est spécifié. +chcon-help-follow-dir-symlinks = Traverser chaque lien symbolique vers un répertoire rencontré. Valide uniquement quand -R est spécifié. +chcon-help-no-follow-symlinks = Ne traverser aucun lien symbolique (par défaut). Valide uniquement quand -R est spécifié. +chcon-help-verbose = Afficher un diagnostic pour chaque fichier traité. + +# Messages d'erreur - validation de base +chcon-error-no-context-specified = Aucun contexte n'est spécifié +chcon-error-no-files-specified = Aucun fichier n'est spécifié +chcon-error-data-out-of-range = Données hors limites +chcon-error-operation-failed = { $operation } a échoué +chcon-error-operation-failed-on = { $operation } a échoué sur { $operand } + +# Messages d'erreur - validation des arguments +chcon-error-invalid-context = Contexte de sécurité invalide '{ $context }'. +chcon-error-recursive-no-dereference-require-p = '--recursive' avec '--no-dereference' nécessite '-P' +chcon-error-recursive-dereference-require-h-or-l = '--recursive' avec '--dereference' nécessite soit '-H' soit '-L' + +# Chaînes d'opération pour le contexte d'erreur +chcon-op-getting-security-context = Obtention du contexte de sécurité +chcon-op-file-name-validation = Validation du nom de fichier +chcon-op-getting-meta-data = Obtention des métadonnées +chcon-op-modifying-root-path = Modification du chemin racine +chcon-op-accessing = Accès +chcon-op-reading-directory = Lecture du répertoire +chcon-op-reading-cyclic-directory = Lecture du répertoire cyclique +chcon-op-applying-partial-context = Application d'un contexte de sécurité partiel à un fichier non étiqueté +chcon-op-creating-security-context = Création du contexte de sécurité +chcon-op-setting-security-context-user = Définition de l'utilisateur du contexte de sécurité +chcon-op-setting-security-context = Définition du contexte de sécurité + +# Sortie détaillée +chcon-verbose-changing-context = { $util_name } : changement du contexte de sécurité de { $file } + +# Messages d'avertissement +chcon-warning-dangerous-recursive-root = Il est dangereux d'opérer récursivement sur '/'. Utilisez --{ $option } pour outrepasser cette protection. +chcon-warning-dangerous-recursive-dir = Il est dangereux d'opérer récursivement sur { $dir } (identique à '/'). Utilisez --{ $option } pour outrepasser cette protection. +chcon-warning-circular-directory = Structure de répertoire circulaire. + Cela signifie presque certainement que vous avez un système de fichiers corrompu. + NOTIFIEZ VOTRE ADMINISTRATEUR SYSTÈME. + Le répertoire suivant fait partie du cycle { $file }. diff --git a/src/uu/chcon/src/chcon.rs b/src/uu/chcon/src/chcon.rs index be1bc2d5b..f9e3774c2 100644 --- a/src/uu/chcon/src/chcon.rs +++ b/src/uu/chcon/src/chcon.rs @@ -14,6 +14,7 @@ use clap::{Arg, ArgAction, Command}; use selinux::{OpaqueSecurityContext, SecurityContext}; use std::borrow::Cow; +use std::collections::HashMap; use std::ffi::{CStr, CString, OsStr, OsString}; use std::os::raw::c_int; use std::path::{Path, PathBuf}; @@ -24,7 +25,7 @@ mod fts; use errors::*; -use uucore::locale::get_message; +use uucore::locale::{get_message, get_message_with_args}; pub mod options { pub static HELP: &str = "help"; @@ -78,10 +79,17 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(None) => { let err = io::Error::from_raw_os_error(libc::ENODATA); - Err(Error::from_io1("Getting security context", reference, err)) + Err(Error::from_io1( + get_message("chcon-op-getting-security-context"), + reference, + err, + )) } - Err(r) => Err(Error::from_selinux("Getting security context", r)), + Err(r) => Err(Error::from_selinux( + get_message("chcon-op-getting-security-context"), + r, + )), }; match result { @@ -103,7 +111,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Err(_r) => { return Err(USimpleError::new( libc::EXIT_FAILURE, - format!("Invalid security context {}.", context.quote()), + get_message_with_args( + "chcon-error-invalid-context", + HashMap::from([("context".to_string(), context.quote().to_string())]), + ), )); } }; @@ -111,7 +122,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { if SecurityContext::from_c_str(&c_context, false).check() == Some(false) { return Err(USimpleError::new( libc::EXIT_FAILURE, - format!("Invalid security context {}.", context.quote()), + get_message_with_args( + "chcon-error-invalid-context", + HashMap::from([("context".to_string(), context.quote().to_string())]), + ), )); } @@ -158,37 +172,34 @@ pub fn uu_app() -> Command { .arg( Arg::new(options::HELP) .long(options::HELP) - .help("Print help information.") + .help(get_message("chcon-help-help")) .action(ArgAction::Help), ) .arg( Arg::new(options::dereference::DEREFERENCE) .long(options::dereference::DEREFERENCE) .overrides_with(options::dereference::NO_DEREFERENCE) - .help( - "Affect the referent of each symbolic link (this is the default), \ - rather than the symbolic link itself.", - ) + .help(get_message("chcon-help-dereference")) .action(ArgAction::SetTrue), ) .arg( Arg::new(options::dereference::NO_DEREFERENCE) .short('h') .long(options::dereference::NO_DEREFERENCE) - .help("Affect symbolic links instead of any referenced file.") + .help(get_message("chcon-help-no-dereference")) .action(ArgAction::SetTrue), ) .arg( Arg::new(options::preserve_root::PRESERVE_ROOT) .long(options::preserve_root::PRESERVE_ROOT) .overrides_with(options::preserve_root::NO_PRESERVE_ROOT) - .help("Fail to operate recursively on '/'.") + .help(get_message("chcon-help-preserve-root")) .action(ArgAction::SetTrue), ) .arg( Arg::new(options::preserve_root::NO_PRESERVE_ROOT) .long(options::preserve_root::NO_PRESERVE_ROOT) - .help("Do not treat '/' specially (the default).") + .help(get_message("chcon-help-no-preserve-root")) .action(ArgAction::SetTrue), ) .arg( @@ -197,10 +208,7 @@ pub fn uu_app() -> Command { .value_name("RFILE") .value_hint(clap::ValueHint::FilePath) .conflicts_with_all([options::USER, options::ROLE, options::TYPE, options::RANGE]) - .help( - "Use security context of RFILE, rather than specifying \ - a CONTEXT value.", - ) + .help(get_message("chcon-help-reference")) .value_parser(ValueParser::os_string()), ) .arg( @@ -209,7 +217,7 @@ pub fn uu_app() -> Command { .long(options::USER) .value_name("USER") .value_hint(clap::ValueHint::Username) - .help("Set user USER in the target security context.") + .help(get_message("chcon-help-user")) .value_parser(ValueParser::os_string()), ) .arg( @@ -217,7 +225,7 @@ pub fn uu_app() -> Command { .short('r') .long(options::ROLE) .value_name("ROLE") - .help("Set role ROLE in the target security context.") + .help(get_message("chcon-help-role")) .value_parser(ValueParser::os_string()), ) .arg( @@ -225,7 +233,7 @@ pub fn uu_app() -> Command { .short('t') .long(options::TYPE) .value_name("TYPE") - .help("Set type TYPE in the target security context.") + .help(get_message("chcon-help-type")) .value_parser(ValueParser::os_string()), ) .arg( @@ -233,14 +241,14 @@ pub fn uu_app() -> Command { .short('l') .long(options::RANGE) .value_name("RANGE") - .help("Set range RANGE in the target security context.") + .help(get_message("chcon-help-range")) .value_parser(ValueParser::os_string()), ) .arg( Arg::new(options::RECURSIVE) .short('R') .long(options::RECURSIVE) - .help("Operate on files and directories recursively.") + .help(get_message("chcon-help-recursive")) .action(ArgAction::SetTrue), ) .arg( @@ -251,10 +259,7 @@ pub fn uu_app() -> Command { options::sym_links::FOLLOW_DIR_SYM_LINKS, options::sym_links::NO_FOLLOW_SYM_LINKS, ]) - .help( - "If a command line argument is a symbolic link to a directory, \ - traverse it. Only valid when -R is specified.", - ) + .help(get_message("chcon-help-follow-arg-dir-symlink")) .action(ArgAction::SetTrue), ) .arg( @@ -265,10 +270,7 @@ pub fn uu_app() -> Command { options::sym_links::FOLLOW_ARG_DIR_SYM_LINK, options::sym_links::NO_FOLLOW_SYM_LINKS, ]) - .help( - "Traverse every symbolic link to a directory encountered. \ - Only valid when -R is specified.", - ) + .help(get_message("chcon-help-follow-dir-symlinks")) .action(ArgAction::SetTrue), ) .arg( @@ -279,17 +281,14 @@ pub fn uu_app() -> Command { options::sym_links::FOLLOW_ARG_DIR_SYM_LINK, options::sym_links::FOLLOW_DIR_SYM_LINKS, ]) - .help( - "Do not traverse any symbolic links (default). \ - Only valid when -R is specified.", - ) + .help(get_message("chcon-help-no-follow-symlinks")) .action(ArgAction::SetTrue), ) .arg( Arg::new(options::VERBOSE) .short('v') .long(options::VERBOSE) - .help("Output a diagnostic for every file processed.") + .help(get_message("chcon-help-verbose")) .action(ArgAction::SetTrue), ) .arg( @@ -319,30 +318,24 @@ fn parse_command_line(config: Command, args: impl uucore::Args) -> Result