Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/uu/chroot/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ chroot-error-missing-newroot = Missing operand: NEWROOT
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 }
1 change: 0 additions & 1 deletion src/uu/chroot/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ chroot-error-missing-newroot = Opérande manquant : NOUVRACINE
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 }
4 changes: 0 additions & 4 deletions src/uu/chroot/src/chroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
options.chroot_target = resolved;
}

if !options.newroot.is_dir() {
return Err(ChrootError::NoSuchDirectory(options.newroot).into());
}

let mut cmd_iter = matches
.get_many::<OsString>(options::COMMAND)
.into_iter()
Expand Down
4 changes: 0 additions & 4 deletions src/uu/chroot/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ pub enum ChrootError {
#[error("{}", translate!("chroot-error-no-such-group"))]
NoSuchGroup,

/// The given directory does not exist.
#[error("{}", translate!("chroot-error-no-such-directory", "dir" => _0.quote()))]
NoSuchDirectory(PathBuf),

/// The call to `setgid()` failed.
#[error("{}", translate!("chroot-error-set-gid-failed", "gid" => _0, "err" => _1))]
SetGidFailed(String, #[source] Error),
Expand Down
30 changes: 26 additions & 4 deletions tests/by-util/test_chroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,36 @@ fn test_enter_chroot_fails() {
}

#[test]
fn test_no_such_directory() {
let (at, mut ucmd) = at_and_ucmd!();
#[cfg(target_env = "gnu")] // todo: override by proper error message on other platforms
fn test_too_long_name() {
let (_at, mut ucmd) = at_and_ucmd!();
let long_name = "a".repeat(256);

at.touch(at.plus_as_string("a"));
ucmd.arg(&long_name)
.fails_with_code(125)
.stderr_contains(format!(
"chroot: cannot chroot to '{long_name}': File name too long", //todo strip errno
));
}

#[test]
#[cfg(target_env = "gnu")] // todo: override by proper error message on other platforms
fn test_no_such() {
let (_at, mut ucmd) = at_and_ucmd!();

ucmd.arg("missing")
.fails_with_code(125)
.stderr_contains("chroot: cannot chroot to 'missing': No such file or directory"); // todo: strip errno
}

#[test]
#[cfg(target_env = "gnu")] // todo: override by proper error message on other platforms
fn test_not_a_directory() {
let (at, mut ucmd) = at_and_ucmd!();
at.touch(at.plus_as_string("a"));
ucmd.arg("a")
.fails_with_code(125)
.stderr_is("chroot: cannot change root directory to 'a': no such directory\n");
.stderr_contains("chroot: cannot chroot to 'a': Not a directory"); // todo: strip errno
}

#[test]
Expand Down
Loading