-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(platform): windows version (#74)
* init checkin * tests now compile * Update linux.rs * fixed linux build * fmt * most tests pass * all tests pass * reinstate delete after test * remove old snaps * oops on the crossterm dep * fix fmt * add windows test to travis * travis windows tests linux messed up term after q * fmt * clean as per PR * more pr clean * tests done on windows * oops * non windows tests * more cleanup * fmt * one last clean * linux->unix * linux->unix * style(cleanup): minor fixes * style(cleanup): moar minor fixes Co-authored-by: Aram Drevekenin <aram@poor.dev>
- Loading branch information
Showing
27 changed files
with
748 additions
and
604 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
mod controls; | ||
mod signals; | ||
pub mod controls; | ||
|
||
pub use controls::*; | ||
pub use signals::*; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[cfg(target_os = "windows")] | ||
pub(crate) mod windows; | ||
|
||
#[cfg(not(target_os = "windows"))] | ||
pub(crate) mod unix; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
use nix::unistd::geteuid; | ||
|
||
pub(crate) fn is_user_admin() -> bool { | ||
geteuid().is_root() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#[cfg(not(test))] | ||
use winapi::um::winnt::{ | ||
DOMAIN_ALIAS_RID_ADMINS, PVOID, SECURITY_BUILTIN_DOMAIN_RID, SECURITY_NT_AUTHORITY, | ||
SID_IDENTIFIER_AUTHORITY, | ||
}; | ||
|
||
#[cfg(not(test))] | ||
use winapi::um::securitybaseapi::{AllocateAndInitializeSid, CheckTokenMembership}; | ||
// https://stackoverflow.com/questions/4230602/detect-if-program-is-running-with-full-administrator-rights | ||
#[cfg(not(test))] | ||
pub(crate) fn is_user_admin() -> bool { | ||
let mut auth_nt = SID_IDENTIFIER_AUTHORITY { | ||
Value: SECURITY_NT_AUTHORITY, | ||
}; | ||
let mut admingroup = 0 as PVOID; | ||
let ismember = unsafe { | ||
assert!( | ||
AllocateAndInitializeSid( | ||
&mut auth_nt, | ||
2, | ||
SECURITY_BUILTIN_DOMAIN_RID, | ||
DOMAIN_ALIAS_RID_ADMINS, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
&mut admingroup, | ||
) != 0 | ||
); | ||
let mut member: i32 = 0; | ||
assert!(CheckTokenMembership(0 as PVOID, admingroup, &mut member) != 0); | ||
member != 0 | ||
}; | ||
ismember | ||
} | ||
#[cfg(test)] | ||
pub(crate) fn is_user_admin() -> bool { | ||
false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.