Skip to content

Commit eaa188c

Browse files
committed
Revert "config: remount rw/ro during configuration saving process"
This reverts commit cfb5ee0.
1 parent 42bf94a commit eaa188c

File tree

1 file changed

+1
-40
lines changed

1 file changed

+1
-40
lines changed

src/config.rs

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@ use serde::{Deserialize, Serialize};
44
use simplelog::*;
55
use std::{
66
fmt::{self, Display},
7-
fs, io,
7+
fs,
88
path::PathBuf,
9-
process::{Command, Stdio},
109
str::FromStr,
1110
sync::Arc,
1211
};
1312
use tokio::sync::RwLock;
1413
use toml_edit::{value, DocumentMut};
1514

16-
// module name for logging engine
17-
const NAME: &str = "<i><bright-black> config: </>";
18-
1915
pub type SharedConfig = Arc<RwLock<AppConfig>>;
2016

2117
#[derive(
@@ -185,34 +181,6 @@ impl Default for AppConfig {
185181
}
186182
}
187183

188-
/// Remount `/` as readonly (`lock = true`) or read-write (`lock = false`)
189-
fn remount_root(lock: bool) -> io::Result<()> {
190-
let mode = if lock { "remount,ro" } else { "remount,rw" };
191-
192-
let status = Command::new("mount")
193-
.args(&["-o", mode, "/"])
194-
.stdout(Stdio::null())
195-
.stderr(Stdio::null())
196-
.status()?;
197-
198-
if status.success() {
199-
info!(
200-
"{} Remount as {} successful",
201-
NAME,
202-
if lock { "read-only" } else { "read-write" }
203-
);
204-
} else {
205-
error!(
206-
"{} Remount as {} failed: {:?}",
207-
NAME,
208-
if lock { "read-only" } else { "read-write" },
209-
status
210-
);
211-
}
212-
213-
Ok(())
214-
}
215-
216184
impl AppConfig {
217185
pub fn load(config_file: PathBuf) -> Result<Self, Box<dyn std::error::Error>> {
218186
use ::config::File;
@@ -280,13 +248,6 @@ impl AppConfig {
280248
doc["ev_connector_types"] = value(ev_connector_types);
281249
}
282250

283-
let _ = remount_root(false);
284-
info!(
285-
"{} Saving new configuration to file: {}",
286-
NAME,
287-
config_file.display()
288-
);
289251
let _ = fs::write(config_file, doc.to_string());
290-
let _ = remount_root(true);
291252
}
292253
}

0 commit comments

Comments
 (0)