From 251ddd1bcca2bf6fa90a24e8735fc477e6dfc84d Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Sat, 8 Jun 2024 09:12:04 +0200 Subject: [PATCH] Revert "builtins/path: Use fancy bitflags feature" This builds on my machine, but doesn't on CI. Rust 1.67 possibly needs to derive Eq as well as PartialEq? This reverts commit 2fa0f13db2a48dc869fc7429db2d2d5e780b6690. --- src/builtins/path.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/builtins/path.rs b/src/builtins/path.rs index 4e2fdd62b..efec75ad4 100644 --- a/src/builtins/path.rs +++ b/src/builtins/path.rs @@ -86,7 +86,7 @@ impl TryFrom<&wstr> for TypeFlags { } bitflags! { - #[derive(Copy, Clone, Default, PartialEq)] + #[derive(Copy, Clone, Default)] pub struct PermFlags: u32 { const READ = 1 << 0; const WRITE = 1 << 1; @@ -405,6 +405,7 @@ fn path_transform( if transformed != arg { n_transformed += 1; // Return okay if path wasn't already in this form + // TODO: Is that correct? if opts.quiet { return STATUS_CMD_OK; }; @@ -797,15 +798,26 @@ fn filter_path(opts: &Options, path: &wstr, uid: Option, gid: Option) if let Some(perm) = opts.perms { let mut amode = 0; + // TODO: Update bitflags so this works + /* for f in perm { amode |= match f { PermFlags::READ => R_OK, PermFlags::WRITE => W_OK, PermFlags::EXEC => X_OK, - _ => 0, + _ => PermFlags::empty(), } } - + */ + if perm.contains(PermFlags::READ) { + amode |= R_OK; + } + if perm.contains(PermFlags::WRITE) { + amode |= W_OK; + } + if perm.contains(PermFlags::EXEC) { + amode |= X_OK; + } // access returns 0 on success, // -1 on failure. Yes, C can't even keep its bools straight. // Skip this if we don't have a mode to check - the stat can do existence too.