mirror of
https://codeberg.org/icewind/cube.git
synced 2026-06-03 12:04:10 +02:00
fix serving files from readonly fs
This commit is contained in:
parent
c83037e32a
commit
3bd95c98d2
2 changed files with 15 additions and 10 deletions
|
|
@ -112,7 +112,7 @@
|
|||
environment.etc."nbs/nbs.toml".source = configFile;
|
||||
|
||||
networking.firewall.allowedTCPPorts = optional cfg.openPorts cfg.listen.port;
|
||||
|
||||
|
||||
systemd.services.nbs = {
|
||||
description = "NBD block server";
|
||||
|
||||
|
|
|
|||
|
|
@ -103,16 +103,21 @@ impl ExportConfig {
|
|||
err: e,
|
||||
path: self.path.clone(),
|
||||
})?;
|
||||
let file = OpenOptions::new()
|
||||
.read(true)
|
||||
.write(!self.readonly)
|
||||
.open(&self.path)
|
||||
.map_err(|e| HandshakeError::Open {
|
||||
err: e,
|
||||
path: self.path.clone(),
|
||||
})?;
|
||||
|
||||
let readonly = self.readonly || meta.permissions().readonly();
|
||||
let mut opt = OpenOptions::new();
|
||||
opt.read(true);
|
||||
if !readonly {
|
||||
opt.write(true);
|
||||
}
|
||||
|
||||
let file = opt.open(&self.path).map_err(|e| HandshakeError::Open {
|
||||
err: e,
|
||||
path: self.path.clone(),
|
||||
})?;
|
||||
|
||||
Ok(Export {
|
||||
readonly: self.readonly || meta.permissions().readonly(),
|
||||
readonly,
|
||||
size: meta.len(),
|
||||
data: file,
|
||||
resizeable: false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue