Skip to content

Commit 66bbbf2

Browse files
committed
add read-only CLI arg
1 parent f6e501c commit 66bbbf2

File tree

3 files changed

+7
-55
lines changed

3 files changed

+7
-55
lines changed

java-bridge/Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/mount/linux.rs

+4-34
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ const FMODE_EXEC: i32 = 0x20;
5353

5454
// const MAX_NAME_LENGTH: u32 = 255 - ENCRYPT_FILENAME_OVERHEAD_CHARS as u32;
5555

56-
// Flags returned by the open request
57-
const FOPEN_DIRECT_IO: u32 = 1 << 0; // bypass page cache for this open file
58-
5956
pub struct DirectoryEntryIterator(crate::encryptedfs::DirectoryEntryIterator, u64);
6057

6158
impl Iterator for DirectoryEntryIterator {
@@ -133,34 +130,17 @@ impl Iterator for DirectoryEntryPlusIterator {
133130

134131
pub struct EncryptedFsFuse3 {
135132
fs: Arc<EncryptedFs>,
136-
direct_io: bool,
137-
suid_support: bool,
138133
}
139134

140135
impl EncryptedFsFuse3 {
141136
pub async fn new(
142137
data_dir: PathBuf,
143138
password_provider: Box<dyn PasswordProvider>,
144139
cipher: Cipher,
145-
direct_io: bool,
146-
#[allow(unused_variables)] suid_support: bool,
147140
) -> FsResult<Self> {
148-
// #[cfg(feature = "abi-7-26")]
149-
// {
150-
// Ok(Self {
151-
// fs: EncryptedFs::new(data_dir, password_provider, cipher).await?,
152-
// direct_io,
153-
// suid_support,
154-
// })
155-
// }
156-
// #[cfg(not(feature = "abi-7-26"))]
157-
// {
158141
Ok(Self {
159142
fs: EncryptedFs::new(data_dir, password_provider, cipher).await?,
160-
direct_io,
161-
suid_support,
162143
})
163-
// }
164144
}
165145

166146
fn get_fs(&self) -> Arc<EncryptedFs> {
@@ -169,11 +149,7 @@ impl EncryptedFsFuse3 {
169149

170150
#[allow(clippy::cast_possible_truncation)]
171151
const fn creation_mode(&self, mode: u32) -> u16 {
172-
if self.suid_support {
173-
mode as u16
174-
} else {
175-
(mode & !(libc::S_ISUID | libc::S_ISGID)) as u16
176-
}
152+
(mode & !(libc::S_ISUID | libc::S_ISGID)) as u16
177153
}
178154

179155
#[instrument(skip(self, name), fields(name = name.to_str().unwrap()), err(level = Level::WARN), ret(level = Level::DEBUG))]
@@ -933,7 +909,6 @@ impl Filesystem for EncryptedFsFuse3 {
933909
EIO
934910
})?;
935911
}
936-
let open_flags = if self.direct_io { FOPEN_DIRECT_IO } else { 0 };
937912
let fh = self
938913
.get_fs()
939914
.open(inode, read, write)
@@ -942,10 +917,7 @@ impl Filesystem for EncryptedFsFuse3 {
942917
error!(err = %err);
943918
EIO
944919
})?;
945-
Ok(ReplyOpen {
946-
fh,
947-
flags: open_flags,
948-
})
920+
Ok(ReplyOpen { fh, flags: 0 })
949921
} else {
950922
return Err(EACCES.into());
951923
}
@@ -1102,10 +1074,9 @@ impl Filesystem for EncryptedFsFuse3 {
11021074
};
11031075

11041076
if check_access(attr.uid, attr.gid, attr.perm, req.uid, req.gid, access_mask) {
1105-
let open_flags = if self.direct_io { FOPEN_DIRECT_IO } else { 0 };
11061077
Ok(ReplyOpen {
11071078
fh: 0, // we don't use handles for directories
1108-
flags: open_flags,
1079+
flags: 0,
11091080
})
11101081
} else {
11111082
return Err(EACCES.into());
@@ -1485,8 +1456,7 @@ async fn mount_fuse(
14851456
info!("Checking password and mounting FUSE filesystem");
14861457
Ok(Session::new(mount_options)
14871458
.mount_with_unprivileged(
1488-
EncryptedFsFuse3::new(data_dir, password_provider, cipher, direct_io, suid_support)
1489-
.await?,
1459+
EncryptedFsFuse3::new(data_dir, password_provider, cipher).await?,
14901460
mount_path,
14911461
)
14921462
.await?)

src/run.rs

+2-20
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ fn get_cli_args() -> ArgMatches {
155155
.arg(
156156
Arg::new("allow-root")
157157
.long("allow-root")
158-
.short('r')
158+
.short('s')
159159
.action(ArgAction::SetTrue)
160160
.requires("mount-point")
161161
.requires("data-dir")
@@ -170,28 +170,10 @@ fn get_cli_args() -> ArgMatches {
170170
.requires("data-dir")
171171
.help("Allow other user to access filesystem"),
172172
)
173-
.arg(
174-
Arg::new("direct-io")
175-
.long("direct-io")
176-
.short('i')
177-
.action(ArgAction::SetTrue)
178-
.requires("mount-point")
179-
.requires("data-dir")
180-
.help("Use direct I/O (bypass page cache for an open file)"),
181-
)
182-
.arg(
183-
Arg::new("suid")
184-
.long("suid")
185-
.short('s')
186-
.action(ArgAction::SetTrue)
187-
.requires("mount-point")
188-
.requires("data-dir")
189-
.help("If it should allow setting SUID and SGID when files are created. Default is false and it will unset those flags when creating files"),
190-
)
191173
.arg(
192174
Arg::new("read-only")
193175
.long("read-only")
194-
.short('e')
176+
.short('r')
195177
.action(ArgAction::SetTrue)
196178
.requires("mount-point")
197179
.requires("data-dir")

0 commit comments

Comments
 (0)