check if data folder is a writable directory #1963

Closed
opened 2026-04-06 02:45:29 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @stefan0xC on 10/11/2022

Adds a check if the data folder is a directory and also returns a more verbose error message if the permission was denied when creating a file.

I tried adding something like the following to check_data_folder() as well

let metadata = path.metadata().unwrap();
if metadata.permissions().readonly() {
    warn!("Data folder '{}' is read-only.", data_folder);
}

However, this does not really work because readonly() only checks if anyone has write permissions. 😖

*Originally created by @stefan0xC on 10/11/2022* Adds a check if the data folder is a directory and also returns a more verbose error message if the permission was denied when creating a file. I tried adding something like the following to `check_data_folder()` as well ```rust let metadata = path.metadata().unwrap(); if metadata.permissions().readonly() { warn!("Data folder '{}' is read-only.", data_folder); } ``` However, this does not really work because [`readonly()`](https://github.com/rust-lang/rust/blob/5237c4d83db0a04a0119918b174ee642acd82d9c/library/std/src/sys/unix/fs.rs#L510-L513) only checks if _anyone_ has write permissions. :confounded:
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/vaultwarden#1963