Skip to content

Commit be445d2

Browse files
authored
Merge pull request #35 from hug-dev/fix-permission-fs-check-feature
Fix the fs check on the socket folder feature
2 parents e7662a3 + 3227f89 commit be445d2

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/core/ipc_handler/unix_socket.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33
//! Handler for Unix domain sockets
44
use super::{Connect, ReadWrite};
55
use crate::error::{ClientErrorKind, Result};
6+
use std::os::unix::net::UnixStream;
7+
use std::path::PathBuf;
8+
use std::time::Duration;
9+
10+
#[cfg(not(feature = "no-fs-permission-check"))]
611
use log::error;
12+
#[cfg(not(feature = "no-fs-permission-check"))]
713
use std::ffi::OsStr;
14+
#[cfg(not(feature = "no-fs-permission-check"))]
815
use std::fs;
16+
#[cfg(not(feature = "no-fs-permission-check"))]
917
use std::io::{Error, ErrorKind};
18+
#[cfg(not(feature = "no-fs-permission-check"))]
1019
use std::os::unix::fs::MetadataExt;
11-
use std::os::unix::net::UnixStream;
12-
use std::path::PathBuf;
13-
use std::time::Duration;
1420

1521
const DEFAULT_SOCKET_PATH: &str = "/tmp/parsec/parsec.sock";
1622
const DEFAULT_TIMEOUT: Duration = Duration::from_secs(1);
@@ -26,7 +32,7 @@ pub struct Handler {
2632

2733
impl Connect for Handler {
2834
fn connect(&self) -> Result<Box<dyn ReadWrite>> {
29-
#[cfg(not(no_fs_permission_check))]
35+
#[cfg(not(feature = "no-fs-permission-check"))]
3036
self.secure_parsec_socket_folder()?;
3137

3238
let stream = UnixStream::connect(self.path.clone()).map_err(ClientErrorKind::Ipc)?;
@@ -54,7 +60,7 @@ impl Handler {
5460

5561
/// Checks if the socket is inside a folder with correct owners and permissions to make sure it
5662
/// is from the Parsec service.
57-
#[cfg(not(no_fs_permission_check))]
63+
#[cfg(not(feature = "no-fs-permission-check"))]
5864
fn secure_parsec_socket_folder(&self) -> Result<()> {
5965
let mut socket_dir = self.path.clone();
6066
if !socket_dir.pop() {

0 commit comments

Comments
 (0)