fix: fixed release builds
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use std::net::Ipv4Addr;
|
||||
|
||||
use sparse_beacon::{
|
||||
use sparse_actions::{
|
||||
adapter::{BeaconAdapter, BeaconInterface, BeaconNetworkingInfo, BeaconRoute},
|
||||
error,
|
||||
};
|
||||
@@ -8,7 +8,7 @@ use sparse_beacon::{
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
pub enum FreeBsdAdapterError {}
|
||||
|
||||
impl sparse_beacon::error::AdapterError for FreeBsdAdapterError {}
|
||||
impl sparse_actions::error::AdapterError for FreeBsdAdapterError {}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct FreeBsdAdapter;
|
||||
@@ -17,6 +17,8 @@ pub struct FreeBsdAdapter;
|
||||
impl BeaconAdapter for FreeBsdAdapter {
|
||||
type Error = FreeBsdAdapterError;
|
||||
|
||||
const OPERATING_SYSTEM: &'static str = "Windows";
|
||||
|
||||
fn interface_name_from_interface(interface: &BeaconInterface) -> Vec<u8> {
|
||||
interface.name.clone()
|
||||
}
|
||||
@@ -27,4 +29,37 @@ impl BeaconAdapter for FreeBsdAdapter {
|
||||
interfaces: vec![],
|
||||
})
|
||||
}
|
||||
|
||||
async fn get_username(&self) -> Result<String, error::BeaconError<Self::Error>> {
|
||||
let passwd = tokio::fs::read_to_string("/etc/passwd").await?;
|
||||
let uid = unsafe { libc::getuid() };
|
||||
|
||||
Ok(passwd
|
||||
.split("\n")
|
||||
.find_map(|row| -> Option<String> {
|
||||
let mut entries = row.split(":");
|
||||
|
||||
let name = entries.next()?;
|
||||
entries.next()?;
|
||||
let euid = entries.next()?.parse::<u32>().ok()?;
|
||||
|
||||
if euid == uid {
|
||||
Some(name.to_string())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.unwrap_or("(unknown)".to_string()))
|
||||
}
|
||||
|
||||
async fn get_hostname(&self) -> Result<String, error::BeaconError<Self::Error>> {
|
||||
Ok(tokio::fs::read_to_string("/etc/rc.conf")
|
||||
.await?
|
||||
.split("\n")
|
||||
.map(|line| line.split("=").collect::<Vec<_>>())
|
||||
.find(|line| line.get(0) == Some(&"hostname"))
|
||||
.map(|line| line.get(1).map(|name| name.to_string()))
|
||||
.flatten()
|
||||
.unwrap_or("(unknown)".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user