Skip to content

Commit 0c57212

Browse files
committed
file permissions fixes
1 parent 00af197 commit 0c57212

2 files changed

Lines changed: 418 additions & 3 deletions

File tree

src/fs.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,11 +1127,13 @@ impl FilesystemMT for EncFs {
11271127
let path = parent.join(name);
11281128
let (real_path, path_iv) = self.encrypt_path(&path)?;
11291129

1130+
use std::os::unix::fs::OpenOptionsExt;
11301131
let mut file = fs::OpenOptions::new()
11311132
.read(true)
11321133
.write(true)
11331134
.create(true)
11341135
.truncate(true)
1136+
.mode(mode)
11351137
.open(&real_path)
11361138
.map_err(|e| e.raw_os_error().unwrap_or(libc::EIO))?;
11371139

@@ -1194,11 +1196,16 @@ impl FilesystemMT for EncFs {
11941196
fs::remove_file(real_path).map_err(|e| e.raw_os_error().unwrap_or(libc::EIO))
11951197
}
11961198

1197-
fn mkdir(&self, req: RequestInfo, parent: &Path, name: &OsStr, _mode: u32) -> ResultEntry {
1199+
fn mkdir(&self, req: RequestInfo, parent: &Path, name: &OsStr, mode: u32) -> ResultEntry {
11981200
let path = parent.join(name);
1199-
debug!("mkdir: {:?}", path);
1201+
debug!("mkdir: {:?} mode={:o}", path, mode);
12001202
let (real_path, _) = self.encrypt_path(&path)?;
1201-
fs::create_dir(real_path).map_err(|e| e.raw_os_error().unwrap_or(libc::EIO))?;
1203+
1204+
use std::os::unix::fs::DirBuilderExt;
1205+
std::fs::DirBuilder::new()
1206+
.mode(mode)
1207+
.create(real_path)
1208+
.map_err(|e| e.raw_os_error().unwrap_or(libc::EIO))?;
12021209

12031210
self.getattr(req, &path, None)
12041211
}

0 commit comments

Comments
 (0)