1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #8170 from sylvestre/l10n-chroot

l10n: port chroot for translation + add french
This commit is contained in:
Daniel Hofstetter 2025-06-14 19:02:00 +02:00 committed by GitHub
commit 91f56ae5ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 97 additions and 29 deletions

View file

@ -1,2 +1,24 @@
chroot-about = Run COMMAND with root directory set to NEWROOT. chroot-about = Run COMMAND with root directory set to NEWROOT.
chroot-usage = chroot [OPTION]... NEWROOT [COMMAND [ARG]...] chroot-usage = chroot [OPTION]... NEWROOT [COMMAND [ARG]...]
# Help messages
chroot-help-groups = Comma-separated list of groups to switch to
chroot-help-userspec = Colon-separated user and group to switch to.
chroot-help-skip-chdir = Use this option to not change the working directory to / after changing the root directory to newroot, i.e., inside the chroot.
# Error messages
chroot-error-skip-chdir-only-permitted = option --skip-chdir only permitted if NEWROOT is old '/'
chroot-error-cannot-enter = cannot chroot to { $dir }: { $err }
chroot-error-command-failed = failed to run command { $cmd }: { $err }
chroot-error-command-not-found = failed to run command { $cmd }: { $err }
chroot-error-groups-parsing-failed = --groups parsing failed
chroot-error-invalid-group = invalid group: { $group }
chroot-error-invalid-group-list = invalid group list: { $list }
chroot-error-missing-newroot = Missing operand: NEWROOT\nTry '{ $util_name } --help' for more information.
chroot-error-no-group-specified = no group specified for unknown uid: { $uid }
chroot-error-no-such-user = invalid user
chroot-error-no-such-group = invalid group
chroot-error-no-such-directory = cannot change root directory to { $dir }: no such directory
chroot-error-set-gid-failed = cannot set gid to { $gid }: { $err }
chroot-error-set-groups-failed = cannot set groups: { $err }
chroot-error-set-user-failed = cannot set user to { $user }: { $err }

View file

@ -0,0 +1,24 @@
chroot-about = Exécuter COMMANDE avec le répertoire racine défini à NOUVRACINE.
chroot-usage = chroot [OPTION]... NOUVRACINE [COMMANDE [ARG]...]
# Messages d'aide
chroot-help-groups = Liste de groupes séparés par des virgules vers lesquels basculer
chroot-help-userspec = Utilisateur et groupe séparés par deux-points vers lesquels basculer.
chroot-help-skip-chdir = Utiliser cette option pour ne pas changer le répertoire de travail vers / après avoir changé le répertoire racine vers nouvracine, c.-à-d., à l'intérieur du chroot.
# Messages d'erreur
chroot-error-skip-chdir-only-permitted = l'option --skip-chdir n'est autorisée que si NOUVRACINE est l'ancien '/'
chroot-error-cannot-enter = impossible de faire chroot vers { $dir } : { $err }
chroot-error-command-failed = échec de l'exécution de la commande { $cmd } : { $err }
chroot-error-command-not-found = échec de l'exécution de la commande { $cmd } : { $err }
chroot-error-groups-parsing-failed = échec de l'analyse de --groups
chroot-error-invalid-group = groupe invalide : { $group }
chroot-error-invalid-group-list = liste de groupes invalide : { $list }
chroot-error-missing-newroot = Opérande manquant : NOUVRACINE\nEssayez '{ $util_name } --help' pour plus d'informations.
chroot-error-no-group-specified = aucun groupe spécifié pour l'uid inconnu : { $uid }
chroot-error-no-such-user = utilisateur invalide
chroot-error-no-such-group = groupe invalide
chroot-error-no-such-directory = impossible de changer le répertoire racine vers { $dir } : aucun répertoire de ce type
chroot-error-set-gid-failed = impossible de définir le gid à { $gid } : { $err }
chroot-error-set-groups-failed = impossible de définir les groupes : { $err }
chroot-error-set-user-failed = impossible de définir l'utilisateur à { $user } : { $err }

View file

@ -76,7 +76,7 @@ fn parse_group_list(list_str: &str) -> Result<Vec<String>, ChrootError> {
let name = split[0].trim(); let name = split[0].trim();
if name.is_empty() { if name.is_empty() {
// --groups=" " // --groups=" "
// chroot: invalid group // chroot: invalid group ' '
Err(ChrootError::InvalidGroup(name.to_string())) Err(ChrootError::InvalidGroup(name.to_string()))
} else { } else {
// --groups="blah" // --groups="blah"
@ -84,7 +84,7 @@ fn parse_group_list(list_str: &str) -> Result<Vec<String>, ChrootError> {
} }
} else if split.iter().all(|s| s.is_empty()) { } else if split.iter().all(|s| s.is_empty()) {
// --groups="," // --groups=","
// chroot: invalid group list , // chroot: invalid group list ','
Err(ChrootError::InvalidGroupList(list_str.to_string())) Err(ChrootError::InvalidGroupList(list_str.to_string()))
} else { } else {
let mut result = vec![]; let mut result = vec![];
@ -97,7 +97,7 @@ fn parse_group_list(list_str: &str) -> Result<Vec<String>, ChrootError> {
continue; continue;
} else { } else {
// --groups=", " // --groups=", "
// chroot: invalid group // chroot: invalid group ' '
show!(ChrootError::InvalidGroup(name.to_string())); show!(ChrootError::InvalidGroup(name.to_string()));
err = true; err = true;
} }
@ -107,7 +107,7 @@ fn parse_group_list(list_str: &str) -> Result<Vec<String>, ChrootError> {
&& trimmed_name.ends_with(|c: char| !c.is_numeric()) && trimmed_name.ends_with(|c: char| !c.is_numeric())
{ {
// --groups="0trail" // --groups="0trail"
// chroot: invalid group 0trail // chroot: invalid group '0trail'
show!(ChrootError::InvalidGroup(name.to_string())); show!(ChrootError::InvalidGroup(name.to_string()));
err = true; err = true;
} else { } else {
@ -176,7 +176,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
{ {
return Err(UUsageError::new( return Err(UUsageError::new(
125, 125,
"option --skip-chdir only permitted if NEWROOT is old '/'", get_message("chroot-error-skip-chdir-only-permitted"),
)); ));
} }
@ -251,23 +251,19 @@ pub fn uu_app() -> Command {
Arg::new(options::GROUPS) Arg::new(options::GROUPS)
.long(options::GROUPS) .long(options::GROUPS)
.overrides_with(options::GROUPS) .overrides_with(options::GROUPS)
.help("Comma-separated list of groups to switch to") .help(get_message("chroot-help-groups"))
.value_name("GROUP1,GROUP2..."), .value_name("GROUP1,GROUP2..."),
) )
.arg( .arg(
Arg::new(options::USERSPEC) Arg::new(options::USERSPEC)
.long(options::USERSPEC) .long(options::USERSPEC)
.help("Colon-separated user and group to switch to.") .help(get_message("chroot-help-userspec"))
.value_name("USER:GROUP"), .value_name("USER:GROUP"),
) )
.arg( .arg(
Arg::new(options::SKIP_CHDIR) Arg::new(options::SKIP_CHDIR)
.long(options::SKIP_CHDIR) .long(options::SKIP_CHDIR)
.help( .help(get_message("chroot-help-skip-chdir"))
"Use this option to not change the working directory \
to / after changing the root directory to newroot, \
i.e., inside the chroot.",
)
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(

View file

@ -4,68 +4,94 @@
// file that was distributed with this source code. // file that was distributed with this source code.
// spell-checker:ignore NEWROOT Userspec userspec // spell-checker:ignore NEWROOT Userspec userspec
//! Errors returned by chroot. //! Errors returned by chroot.
use std::collections::HashMap;
use std::io::Error; use std::io::Error;
use thiserror::Error; use thiserror::Error;
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::UError; use uucore::error::UError;
use uucore::libc; use uucore::libc;
use uucore::locale::{get_message, get_message_with_args};
/// Errors that can happen while executing chroot. /// Errors that can happen while executing chroot.
#[derive(Debug, Error)] #[derive(Debug, Error)]
pub enum ChrootError { pub enum ChrootError {
/// Failed to enter the specified directory. /// Failed to enter the specified directory.
#[error("cannot chroot to {dir}: {err}", dir = .0.quote(), err = .1)] #[error("{}", get_message_with_args("chroot-error-cannot-enter", HashMap::from([
("dir".to_string(), _0.quote().to_string()),
("err".to_string(), _1.to_string())
])))]
CannotEnter(String, #[source] Error), CannotEnter(String, #[source] Error),
/// Failed to execute the specified command. /// Failed to execute the specified command.
#[error("failed to run command {cmd}: {err}", cmd = .0.to_string().quote(), err = .1)] #[error("{}", get_message_with_args("chroot-error-command-failed", HashMap::from([
("cmd".to_string(), _0.to_string().quote().to_string()),
("err".to_string(), _1.to_string())
])))]
CommandFailed(String, #[source] Error), CommandFailed(String, #[source] Error),
/// Failed to find the specified command. /// Failed to find the specified command.
#[error("failed to run command {cmd}: {err}", cmd = .0.to_string().quote(), err = .1)] #[error("{}", get_message_with_args("chroot-error-command-not-found", HashMap::from([
("cmd".to_string(), _0.to_string().quote().to_string()),
("err".to_string(), _1.to_string())
])))]
CommandNotFound(String, #[source] Error), CommandNotFound(String, #[source] Error),
#[error("--groups parsing failed")] #[error("{}", get_message("chroot-error-groups-parsing-failed"))]
GroupsParsingFailed, GroupsParsingFailed,
#[error("invalid group: {group}", group = .0.quote())] #[error("{}", get_message_with_args("chroot-error-invalid-group", HashMap::from([
("group".to_string(), _0.quote().to_string())
])))]
InvalidGroup(String), InvalidGroup(String),
#[error("invalid group list: {list}", list = .0.quote())] #[error("{}", get_message_with_args("chroot-error-invalid-group-list", HashMap::from([
("list".to_string(), _0.quote().to_string())
])))]
InvalidGroupList(String), InvalidGroupList(String),
/// The new root directory was not given. /// The new root directory was not given.
#[error( #[error("{}", get_message_with_args("chroot-error-missing-newroot", HashMap::from([
"Missing operand: NEWROOT\nTry '{0} --help' for more information.", ("util_name".to_string(), uucore::execution_phrase().to_string())
uucore::execution_phrase() ])))]
)]
MissingNewRoot, MissingNewRoot,
#[error("no group specified for unknown uid: {0}")] #[error("{}", get_message_with_args("chroot-error-no-group-specified", HashMap::from([
("uid".to_string(), _0.to_string())
])))]
NoGroupSpecified(libc::uid_t), NoGroupSpecified(libc::uid_t),
/// Failed to find the specified user. /// Failed to find the specified user.
#[error("invalid user")] #[error("{}", get_message("chroot-error-no-such-user"))]
NoSuchUser, NoSuchUser,
/// Failed to find the specified group. /// Failed to find the specified group.
#[error("invalid group")] #[error("{}", get_message("chroot-error-no-such-group"))]
NoSuchGroup, NoSuchGroup,
/// The given directory does not exist. /// The given directory does not exist.
#[error("cannot change root directory to {dir}: no such directory", dir = .0.quote())] #[error("{}", get_message_with_args("chroot-error-no-such-directory", HashMap::from([
("dir".to_string(), _0.quote().to_string())
])))]
NoSuchDirectory(String), NoSuchDirectory(String),
/// The call to `setgid()` failed. /// The call to `setgid()` failed.
#[error("cannot set gid to {gid}: {err}", gid = .0, err = .1)] #[error("{}", get_message_with_args("chroot-error-set-gid-failed", HashMap::from([
("gid".to_string(), _0.to_string()),
("err".to_string(), _1.to_string())
])))]
SetGidFailed(String, #[source] Error), SetGidFailed(String, #[source] Error),
/// The call to `setgroups()` failed. /// The call to `setgroups()` failed.
#[error("cannot set groups: {0}")] #[error("{}", get_message_with_args("chroot-error-set-groups-failed", HashMap::from([
("err".to_string(), _0.to_string())
])))]
SetGroupsFailed(Error), SetGroupsFailed(Error),
/// The call to `setuid()` failed. /// The call to `setuid()` failed.
#[error("cannot set user to {user}: {err}", user = .0.maybe_quote(), err = .1)] #[error("{}", get_message_with_args("chroot-error-set-user-failed", HashMap::from([
("user".to_string(), _0.maybe_quote().to_string()),
("err".to_string(), _1.to_string())
])))]
SetUserFailed(String, #[source] Error), SetUserFailed(String, #[source] Error),
} }