Skip to content

Commit

Permalink
Make allow_other and allow_root mutually exclusive (#475)
Browse files Browse the repository at this point in the history
Signed-off-by: Monthon Klongklaew <monthonk@amazon.com>
  • Loading branch information
monthonk authored Aug 24, 2023
1 parent b9f7e91 commit 6103a2f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mountpoint-s3/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ struct CliArgs {

#[clap(
long,
help = "Allow other non-root users to access file system",
help_heading = MOUNT_OPTIONS_HEADER
help = "Allow other users, including root, to access file system",
help_heading = MOUNT_OPTIONS_HEADER,
conflicts_with = "allow_root"
)]
pub allow_other: bool,

Expand Down
15 changes: 15 additions & 0 deletions mountpoint-s3/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,18 @@ fn validate_log_files_permissions() -> Result<(), Box<dyn std::error::Error>> {

Ok(())
}

#[test]
fn allow_other_conflict() -> Result<(), Box<dyn std::error::Error>> {
let dir = assert_fs::TempDir::new()?;
let mut cmd = Command::cargo_bin("mount-s3")?;

cmd.arg("test-bucket")
.arg(dir.path())
.arg("--allow-other")
.arg("--allow-root");
let error_message = "the argument '--allow-other' cannot be used with '--allow-root'";
cmd.assert().failure().stderr(predicate::str::contains(error_message));

Ok(())
}

0 comments on commit 6103a2f

Please sign in to comment.