Skip to content

Commit bb51db1

Browse files
Merge pull request #684 from tgonzalezorlandoarm/tg/remove-users-crate
Remove unmaintained 'users' crate
2 parents 5685ff9 + 9de02de commit bb51db1

File tree

4 files changed

+9
-18
lines changed

4 files changed

+9
-18
lines changed

Cargo.lock

-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ hex = { version = "0.4.2", optional = true }
3737
psa-crypto = { version = "0.10.0", default-features = false, features = ["operations"], optional = true }
3838
zeroize = { version = "1.2.0", features = ["zeroize_derive"] }
3939
picky-asn1-x509 = { version = "0.6.1", optional = true }
40-
users = "0.11.0"
4140
libc = "0.2.86"
4241
anyhow = "1.0.38"
4342
rust-cryptoauthlib = { version = "0.4.4", optional = true }

src/authenticators/unix_peer_credentials_authenticator/mod.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ mod test {
109109
use super::UnixPeerCredentialsAuthenticator;
110110
use crate::front::domain_socket::peer_credentials;
111111
use crate::front::listener::ConnectionMetadata;
112+
use libc::{getuid, uid_t};
112113
use parsec_interface::requests::request::RequestAuth;
113114
use parsec_interface::requests::ResponseStatus;
114115
use rand::Rng;
115116
use std::os::unix::net::UnixStream;
116-
use users::get_current_uid;
117117

118118
#[test]
119119
fn successful_authentication() {
@@ -143,7 +143,8 @@ mod test {
143143
.authenticate(&req_auth, conn_metadata)
144144
.expect("Failed to authenticate");
145145

146-
assert_eq!(application.identity.name, get_current_uid().to_string());
146+
let current_uid: uid_t = unsafe { getuid() };
147+
assert_eq!(application.identity.name, current_uid.to_string());
147148
assert!(!application.is_admin);
148149
}
149150

@@ -230,7 +231,8 @@ mod test {
230231
peer_credentials::peer_cred(&_sock_b).unwrap(),
231232
);
232233

233-
let admin = toml::from_str(&format!("name = '{}'", get_current_uid())).unwrap();
234+
let current_uid: uid_t = unsafe { getuid() };
235+
let admin = toml::from_str(&format!("name = '{}'", current_uid)).unwrap();
234236
let authenticator = UnixPeerCredentialsAuthenticator {
235237
admins: vec![admin].into(),
236238
};
@@ -247,7 +249,7 @@ mod test {
247249
.authenticate(&req_auth, conn_metadata)
248250
.expect("Failed to authenticate");
249251

250-
assert_eq!(application.identity.name, get_current_uid().to_string());
252+
assert_eq!(application.identity.name, current_uid.to_string());
251253
assert!(application.is_admin);
252254
}
253255

src/bin/main.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#![allow(clippy::multiple_crate_versions)]
4040

4141
use anyhow::Result;
42+
use libc::{getuid, uid_t};
4243
use log::{info, trace};
4344
use parsec_service::utils::cli::Opts;
4445
use parsec_service::utils::{config::ServiceConfig, ServiceBuilder};
@@ -50,7 +51,6 @@ use std::sync::{
5051
};
5152
use std::time::Duration;
5253
use structopt::StructOpt;
53-
use users::get_current_uid;
5454

5555
const MAIN_LOOP_DEFAULT_SLEEP: u64 = 10;
5656

@@ -82,7 +82,8 @@ fn main() -> Result<()> {
8282
// Guard against running as root. This check can be overridden by changing `allow_root` inside
8383
// the config file.
8484
let allow_root = config.core_settings.allow_root.unwrap_or(false);
85-
if !allow_root && get_current_uid() == 0 {
85+
let current_id: uid_t = unsafe { getuid() };
86+
if !allow_root && current_id == 0 {
8687
return Err(Error::new(
8788
ErrorKind::Other,
8889
"Insecure configuration; the Parsec service should not be running as root! You can \

0 commit comments

Comments
 (0)