File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,8 +5,9 @@ edition = "2021"
55
66[dependencies ]
77
8- hickory-resolver = " 0.24.0"
9- local-ip-address = " 0.6.1"
10- serde = { version = " 1.0.197" , features = [" derive" ] }
11- serde_json = " 1.0.114"
12- sysinfo = " 0.30.5"
8+ hickory-resolver = " 0.24.1"
9+ local-ip-address = " 0.6.3"
10+ serde = { version = " 1.0.210" , features = [" derive" ] }
11+ serde_json = " 1.0.128"
12+ sysinfo = " 0.32.0"
13+ users = " 0.11.0"
Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ fn main() {
2424
2525 let system_network_information = get_network_info ( ) ;
2626
27+ let current_uid = users:: get_current_uid ( ) ;
28+ let current_gid = users:: get_current_gid ( ) ;
29+ let current_user = users:: get_user_by_uid ( current_uid) . unwrap ( ) ;
30+
31+
2732 let system_information = SystemInformation {
2833 cpu_count : sys. cpus ( ) . len ( ) ,
2934 physical_core_count : sys. physical_core_count ( ) ,
@@ -50,6 +55,12 @@ fn main() {
5055 disks,
5156
5257 network_information : system_network_information,
58+
59+
60+ // Adding current user, UID, and GID info
61+ current_user : current_user. name ( ) . to_str ( ) . unwrap ( ) . to_string ( ) ,
62+ current_uid,
63+ current_gid,
5364 } ;
5465
5566 let serialized = serde_json:: to_string_pretty ( & system_information) . unwrap ( ) ;
@@ -58,7 +69,6 @@ fn main() {
5869 // TODO:
5970 // Current time
6071 // SElinux/AppArmor
61- // Current user / User id, group id
6272 // Maybe env variables (may contain secrets)
6373 // dmesg/syslog?
6474 // capabilities?
Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ pub struct SystemInformation {
2626 pub host_name : Option < String > ,
2727 pub cpu_arch : Option < String > ,
2828
29+ pub current_user : String , // The name of the current user
30+ pub current_uid : u32 , // The user ID (UID)
31+ pub current_gid : u32 , // The group ID (GID)
32+
2933 pub disks : Vec < Disk > ,
3034 pub network_information : SystemNetworkInfo ,
3135}
You can’t perform that action at this time.
0 commit comments