summaryrefslogtreecommitdiff
path: root/src/persist.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/persist.rs')
-rw-r--r--src/persist.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/persist.rs b/src/persist.rs
index 7d47232..febd035 100644
--- a/src/persist.rs
+++ b/src/persist.rs
@@ -83,12 +83,13 @@ fn get_terminal_config() -> Option<Value> {
}
fn write_terminal_config(id: &i32, data: &str) -> Result<(), Box<dyn std::error::Error>> {
- std::fs::write(path(&id), data)?;
+ std::fs::write(path(&id), "")?;
unistd::chown(std::path::Path::new(&path(&id)), Some(unistd::Uid::from(0)), Some(unistd::Gid::from(0)))?;
let metadata = std::fs::metadata(path(&id))?;
let mut perms = metadata.permissions();
perms.set_mode(0o660);
fs::set_permissions(path(&id), perms)?;
+ std::fs::write(path(&id), data)?;
Ok(())
}
@@ -98,4 +99,4 @@ fn now() -> u64 {
fn path(id: &i32) -> String {
return format!("/tmp/crab-{}", id);
-} \ No newline at end of file
+}