You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added user and group checks. Auto create socket dir.
Parsec must be run as user `parsec` and `parsec` must be member of group `parsec-client`.
This is disabled if feature `testing` is specified.
Also auto created `/tmp/parsec` if it does not already exist.
Signed-off-by: Samuel Bailey <[email protected]>
// Although `parsec` has to be part of the `parsec_clients` group, it may not be the primary group. Therefore force group ownership to `parsec_clients`
109
+
ifunsafe{
110
+
let parent_dir_cstr = CString::new(parent_dir_str)
111
+
.expect("Failed to convert socket path parent to cstring");
112
+
{
113
+
libc::chown(
114
+
parent_dir_cstr.as_ptr(),
115
+
users::get_current_uid(),// To get to this point, user has to be `parsec`
116
+
users::get_group_by_name(PARSEC_GROUPNAME).unwrap().gid(),// `parsec_clients` exists by this point so should be safe
117
+
)
118
+
}
119
+
} != 0
120
+
{
121
+
error!(
122
+
"Changing ownership of {} to user {} and group {} failed.",
123
+
parent_dir_str,PARSEC_USERNAME,PARSEC_GROUPNAME
124
+
);
125
+
returnErr(Error::new(
126
+
ErrorKind::Other,
127
+
"Changing ownership of socket directory failed",
128
+
));
129
+
}
130
+
}else{
131
+
error!(
132
+
"Error converting {} parent directory to string.",
133
+
SOCKET_PATH
134
+
);
135
+
returnErr(Error::new(
136
+
ErrorKind::InvalidInput,
137
+
"Error retrieving parent directory for socket",
138
+
));
139
+
}
140
+
Ok(())
141
+
}
142
+
143
+
#[cfg(feature = "parsec-user-and-clients-group")]
144
+
fncheck_user_details() -> Result<()>{
145
+
// Check Parsec is running as parsec user
146
+
if users::get_current_username() != Some(PARSEC_USERNAME.into()){
147
+
error!(
148
+
"Incorrect user. Parsec should be run as user {}.",
149
+
PARSEC_USERNAME
150
+
);
151
+
returnErr(Error::new(
152
+
ErrorKind::PermissionDenied,
153
+
"Parsec run as incorrect user",
154
+
));
155
+
}
156
+
// Check Parsec client group exists and parsec user is a member of it
0 commit comments