aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Grunert <mail@saschagrunert.de>2017-02-23 20:31:27 +0100
committerSascha Grunert <mail@saschagrunert.de>2017-02-23 20:31:27 +0100
commit2e6ac9d988aab42099a493a04842caf53ae55e8e (patch)
treebb4d746700f05846af45ec8642ac11c79fe9d99d
parentFixed license (diff)
downloadwireguard-rs-2e6ac9d988aab42099a493a04842caf53ae55e8e.tar.xz
wireguard-rs-2e6ac9d988aab42099a493a04842caf53ae55e8e.zip
Check for the existence of /run first
-rw-r--r--src/lib.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 7a6a6de..f8a8702 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -42,7 +42,12 @@ impl WireGuard {
debug!("Created socket.");
// Create the socket directory if not existing
- let mut socket_path = PathBuf::from("/var").join("run").join("wireguard");
+ let mut socket_path = if Path::new("/run").exists() {
+ PathBuf::from("/run")
+ } else {
+ PathBuf::from("/var").join("run")
+ };
+ socket_path.join("wireguard");
if !socket_path.exists() {
create_dir(&socket_path)?;
debug!("Created socket path: {}", socket_path.display());