Skip to content

Commit bd4f32b

Browse files
committed
cargo fmt
1 parent 34817cd commit bd4f32b

File tree

14 files changed

+41
-39
lines changed

14 files changed

+41
-39
lines changed

src/control/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//! ### status Option<name>
99
//! * If the param is a string show status of the unit with that name (might get the same filtering as list-units in the future).
1010
//! * If no param is given, show status of all units
11-
//!
11+
//!
1212
//! ### restart name
1313
//! Restart unit with that name. If it was running first kill it. If it is already stopped start it.
1414
@@ -17,7 +17,7 @@
1717
1818
//! ### enable name
1919
//! Load new file with that name. Useful if you moved/copied a file in the unit-dirs and want to start it without restarting rustysd as a whole
20-
//!
20+
//!
2121
//! ### shutdown
2222
//! Shutdown rustysd by killing all services, closing all sockets and exiting
2323
//!

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ pub mod notification_handler;
3030
pub mod platform;
3131
pub mod services;
3232
pub mod signal_handler;
33+
pub mod socket_activation;
3334
pub mod sockets;
3435
pub mod units;
35-
pub mod socket_activation;
3636

3737
#[macro_use]
3838
extern crate log;

src/platform/grnam.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub struct GroupEntry {
44
pub gid: nix::unistd::Gid,
55
}
66

7-
#[cfg(any(target_os = "linux", target_os="freebsd"))]
7+
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
88
fn make_group_from_libc(groupname: &str, group: &libc::group) -> Result<GroupEntry, String> {
99
let gid = nix::unistd::Gid::from_raw(group.gr_gid);
1010
let pw = if !group.gr_passwd.is_null() {
@@ -45,7 +45,7 @@ fn getgrnam(groupname: &str) -> Result<GroupEntry, String> {
4545
make_group_from_libc(groupname, &res)
4646
}
4747

48-
#[cfg(any(target_os = "linux", target_os="freebsd"))]
48+
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
4949
pub fn getgrnam_r(groupname: &str) -> Result<GroupEntry, String> {
5050
let username_i8 = groupname.bytes().map(|x| x as i8).collect::<Vec<_>>();
5151
let pointer: *const i8 = username_i8.as_ptr();
@@ -92,7 +92,7 @@ pub fn getgrnam_r(groupname: &str) -> Result<GroupEntry, String> {
9292
}
9393
}
9494

95-
#[cfg(not(any(target_os = "linux", target_os="freebsd")))]
95+
#[cfg(not(any(target_os = "linux", target_os = "freebsd")))]
9696
pub fn getgrnam_r(_groupname: &str) -> Result<GroupEntry, String> {
9797
compile_error!("getgrnam_r is not yet implemented for this platform");
9898
}

src/platform/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
//! We'd also need to make some more functionality optional like subprocess reaping (which only matters if we are not PID1)
2222
//!
2323
24+
mod drop_privileges;
2425
mod eventfd;
2526
mod subreaper;
2627
mod unix_common;
27-
mod drop_privileges;
2828

29+
pub use drop_privileges::*;
2930
pub use eventfd::*;
3031
pub use subreaper::*;
31-
pub use drop_privileges::*;
32-
pub mod pwnam;
3332
pub mod grnam;
33+
pub mod pwnam;
3434

3535
#[cfg(any(
3636
target_os = "freebsd",

src/services/fork_child.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,20 +203,23 @@ pub fn after_fork_child(
203203
eprintln!("[FORK_CHILD {}] error while duping fds: {}", name, e);
204204
std::process::exit(1);
205205
}
206-
206+
207207
setup_env_vars(names, notify_socket_env_var);
208208
let (cmd, args) = prepare_exec_args(srvc);
209-
209+
210210
if nix::unistd::getuid().is_root() {
211211
match crate::platform::drop_privileges(srvc.gid, &srvc.supp_gids, srvc.uid) {
212-
Ok(()) => {/* Happy */},
213-
Err(e) => {
214-
eprintln!("[FORK_CHILD {}] could not drop privileges because: {}", name, e);
212+
Ok(()) => { /* Happy */ }
213+
Err(e) => {
214+
eprintln!(
215+
"[FORK_CHILD {}] could not drop privileges because: {}",
216+
name, e
217+
);
215218
std::process::exit(1);
216219
}
217220
}
218221
}
219-
222+
220223
eprintln!("EXECV: {:?} {:?}", &cmd, &args);
221224
match nix::unistd::execv(&cmd, &args) {
222225
Ok(_) => {

src/services/services.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ impl Service {
143143
return Err(ServiceErrorReason::AlreadyHasPID(pgid));
144144
}
145145
if self.service_config.accept {
146-
return Err(ServiceErrorReason::Generic("Inetd style activation is not supported".into()));
146+
return Err(ServiceErrorReason::Generic(
147+
"Inetd style activation is not supported".into(),
148+
));
147149
}
148150
if !allow_ignore || self.socket_names.is_empty() {
149151
trace!("Start service {}", name);

src/socket_activation.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,16 @@ pub fn start_socketactivation_thread(
4242
}
4343

4444
if let Some(srvc_unit_id) = srvc_unit_id {
45-
if let Some(status) = run_info
46-
.status_table
47-
.read()
48-
.unwrap()
49-
.get(&srvc_unit_id)
45+
if let Some(status) =
46+
run_info.status_table.read().unwrap().get(&srvc_unit_id)
5047
{
5148
let srvc_status = {
5249
let status_locked = status.lock().unwrap();
5350
status_locked.clone()
5451
};
5552

56-
if srvc_status != crate::units::UnitStatus::StartedWaitingForSocket {
53+
if srvc_status != crate::units::UnitStatus::StartedWaitingForSocket
54+
{
5755
trace!(
5856
"Ignore socket activation. Service has status: {:?}",
5957
srvc_status

src/sockets.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl UnixSocketConfig {
143143
std::fs::remove_file(&path)
144144
.map_err(|e| format!("Error removing file {:?}: {}", path, e))?;
145145
}
146-
146+
147147
close_raw_fd(rawfd);
148148
Ok(())
149149
}

src/units/activate.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
33
use super::units::*;
44
use crate::platform::EventFd;
5+
use crate::services::ServiceErrorReason;
56
use std::sync::{Arc, Mutex};
67
use threadpool::ThreadPool;
7-
use crate::services::ServiceErrorReason;
88

99
pub struct UnitOperationError {
1010
pub reason: UnitOperationErrorReason,
@@ -233,7 +233,8 @@ pub fn activate_unit(
233233
let mut status_locked = status.lock().unwrap();
234234
*status_locked = new_status;
235235
StartResult::Started(next_services_ids)
236-
}).map_err(|e| {
236+
})
237+
.map_err(|e| {
237238
// Update the status while we still lock the unit
238239
let status_table_locked = run_info.status_table.read().unwrap();
239240
let status = status_table_locked.get(&unit_locked.id).unwrap();

src/units/insert_new.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ pub fn load_new_unit(
3636
let content = fs::read_to_string(&unit_path).map_err(|e| {
3737
format!(
3838
"{}",
39-
units::ParsingError::new(units::ParsingErrorReason::from(Box::new(e)), unit_path.clone())
39+
units::ParsingError::new(
40+
units::ParsingErrorReason::from(Box::new(e)),
41+
unit_path.clone()
42+
)
4043
)
4144
})?;
4245
let parsed = units::parse_file(&content)

src/units/loading.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ pub enum LoadingError {
88
Dependency(DependencyError),
99
}
1010

11-
1211
#[derive(Debug)]
1312
pub struct DependencyError {
1413
msg: String,

src/units/unit_parsing/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ impl std::fmt::Display for ParsingError {
7070
)?;
7171
}
7272
ParsingErrorReason::UnknownSection(name) => {
73-
write!(
74-
f,
75-
"In file {:?}: Section {} is unknown",
76-
self.path, name
77-
)?;
73+
write!(f, "In file {:?}: Section {} is unknown", self.path, name)?;
7874
}
7975
ParsingErrorReason::SectionTooOften(name) => {
8076
write!(

src/units/unit_parsing/service_unit.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ pub fn parse_service(
3737
if let Ok(uid) = user.parse::<u32>() {
3838
Some(nix::unistd::Uid::from_raw(uid))
3939
} else {
40-
if let Ok(pwentry) =
41-
crate::platform::pwnam::getpwnam_r(&user).map_err(|e| ParsingErrorReason::Generic(e))
40+
if let Ok(pwentry) = crate::platform::pwnam::getpwnam_r(&user)
41+
.map_err(|e| ParsingErrorReason::Generic(e))
4242
{
4343
Some(pwentry.uid)
4444
} else {
@@ -58,8 +58,8 @@ pub fn parse_service(
5858
if let Ok(gid) = group.parse::<u32>() {
5959
Some(nix::unistd::Gid::from_raw(gid))
6060
} else {
61-
if let Ok(groupentry) =
62-
crate::platform::grnam::getgrnam_r(&group).map_err(|e| ParsingErrorReason::Generic(e))
61+
if let Ok(groupentry) = crate::platform::grnam::getgrnam_r(&group)
62+
.map_err(|e| ParsingErrorReason::Generic(e))
6363
{
6464
Some(groupentry.gid)
6565
} else {
@@ -79,8 +79,8 @@ pub fn parse_service(
7979
let gid = if let Ok(gid) = group.parse::<u32>() {
8080
nix::unistd::Gid::from_raw(gid)
8181
} else {
82-
if let Ok(groupentry) =
83-
crate::platform::grnam::getgrnam_r(&group).map_err(|e| ParsingErrorReason::Generic(e))
82+
if let Ok(groupentry) = crate::platform::grnam::getgrnam_r(&group)
83+
.map_err(|e| ParsingErrorReason::Generic(e))
8484
{
8585
groupentry.gid
8686
} else {

src/units/unit_parsing/unit_parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub fn string_to_bool(s: &str) -> bool {
6666
if s.len() == 0 {
6767
return false;
6868
}
69-
69+
7070
let s_upper = &s.to_uppercase();
7171
let c: char = s_upper.chars().nth(0).unwrap();
7272

0 commit comments

Comments
 (0)