mirror of
https://github.com/lsd-rs/lsd.git
synced 2026-02-10 01:04:07 +02:00
chore(ci): fix lints (#1158)
Co-authored-by: Pochi <noreply@getpochi.com>
This commit is contained in:
2
.github/workflows/CICD.yml
vendored
2
.github/workflows/CICD.yml
vendored
@@ -188,7 +188,7 @@ jobs:
|
||||
sed -i.bk "s|date: <date>|date: $(date '+%Y-%m-%d')|" doc/lsd.md
|
||||
rm doc/lsd.md.bk
|
||||
- name: Setup pandoc
|
||||
uses: r-lib/actions/setup-pandoc@v1
|
||||
uses: r-lib/actions/setup-pandoc@v2
|
||||
- name: Generate Manpage
|
||||
run: pandoc --standalone --to man doc/lsd.md -o lsd.1
|
||||
- name: Install `rust` toolchain
|
||||
|
||||
@@ -65,7 +65,7 @@ impl<'de> de::Deserialize<'de> for ThemeOption {
|
||||
{
|
||||
struct ThemeOptionVisitor;
|
||||
|
||||
impl<'de> Visitor<'de> for ThemeOptionVisitor {
|
||||
impl Visitor<'_> for ThemeOptionVisitor {
|
||||
type Value = ThemeOption;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
|
||||
@@ -4,8 +4,8 @@ use std::mem::MaybeUninit;
|
||||
use std::os::windows::ffi::{OsStrExt, OsStringExt};
|
||||
use std::path::Path;
|
||||
|
||||
use windows::Win32::Foundation::PSID;
|
||||
use windows::Win32::Security::{self, ACL, Authorization::TRUSTEE_W};
|
||||
use windows::Win32::Foundation::HLOCAL;
|
||||
use windows::Win32::Security::{self, ACL, Authorization::TRUSTEE_W, PSID};
|
||||
|
||||
use super::{Owner, Permissions};
|
||||
|
||||
@@ -118,17 +118,17 @@ pub fn get_file_data(path: &Path) -> Result<(Owner, Permissions), io::Error> {
|
||||
let result = unsafe {
|
||||
Security::CreateWellKnownSid(
|
||||
Security::WinWorldSid,
|
||||
PSID::default(),
|
||||
world_sid_ptr,
|
||||
None,
|
||||
Some(world_sid_ptr),
|
||||
&mut world_sid_len,
|
||||
)
|
||||
};
|
||||
|
||||
if result.ok().is_err() {
|
||||
if result.is_err() {
|
||||
// Failed to create the SID
|
||||
// Assumptions: Same as the other identical calls
|
||||
unsafe {
|
||||
windows::Win32::System::Memory::LocalFree(sd_ptr.0 as _);
|
||||
windows::Win32::Foundation::LocalFree(Some(HLOCAL(sd_ptr.0 as isize)));
|
||||
}
|
||||
|
||||
// Assumptions: None (GetLastError shouldn't ever fail)
|
||||
@@ -155,9 +155,9 @@ pub fn get_file_data(path: &Path) -> Result<(Owner, Permissions), io::Error> {
|
||||
|
||||
let permissions = {
|
||||
use windows::Win32::Storage::FileSystem::{
|
||||
FILE_ACCESS_FLAGS, FILE_GENERIC_EXECUTE, FILE_GENERIC_READ, FILE_GENERIC_WRITE,
|
||||
FILE_ACCESS_RIGHTS, FILE_GENERIC_EXECUTE, FILE_GENERIC_READ, FILE_GENERIC_WRITE,
|
||||
};
|
||||
let has_bit = |field: u32, bit: FILE_ACCESS_FLAGS| field & bit.0 != 0;
|
||||
let has_bit = |field: u32, bit: FILE_ACCESS_RIGHTS| field & bit.0 != 0;
|
||||
Permissions {
|
||||
user_read: has_bit(owner_access_mask, FILE_GENERIC_READ),
|
||||
user_write: has_bit(owner_access_mask, FILE_GENERIC_WRITE),
|
||||
@@ -184,7 +184,7 @@ pub fn get_file_data(path: &Path) -> Result<(Owner, Permissions), io::Error> {
|
||||
// options. It's not much memory, so leaking it on failure is
|
||||
// *probably* fine)
|
||||
unsafe {
|
||||
windows::Win32::System::Memory::LocalFree(sd_ptr.0 as _);
|
||||
windows::Win32::Foundation::LocalFree(Some(HLOCAL(sd_ptr.0 as isize)));
|
||||
}
|
||||
|
||||
Ok((owner, permissions))
|
||||
@@ -205,8 +205,9 @@ unsafe fn get_acl_access_mask(
|
||||
// Assumptions:
|
||||
// - All function assumptions
|
||||
// - Result is not valid until return value is checked
|
||||
let err_code =
|
||||
Security::Authorization::GetEffectiveRightsFromAclW(acl_ptr, trustee_ptr, &mut access_mask);
|
||||
let err_code = unsafe {
|
||||
Security::Authorization::GetEffectiveRightsFromAclW(acl_ptr, trustee_ptr, &mut access_mask)
|
||||
};
|
||||
|
||||
if err_code.is_ok() {
|
||||
Ok(access_mask)
|
||||
@@ -226,7 +227,7 @@ unsafe fn get_acl_access_mask(
|
||||
unsafe fn trustee_from_sid<P: Into<PSID>>(sid_ptr: P) -> TRUSTEE_W {
|
||||
let mut trustee = TRUSTEE_W::default();
|
||||
|
||||
Security::Authorization::BuildTrusteeWithSidW(&mut trustee, sid_ptr);
|
||||
Security::Authorization::BuildTrusteeWithSidW(&mut trustee, Some(sid_ptr.into()));
|
||||
|
||||
trustee
|
||||
}
|
||||
@@ -253,17 +254,19 @@ unsafe fn lookup_account_sid(sid: PSID) -> Result<(Vec<u16>, Vec<u16>), std::io:
|
||||
// Assumptions:
|
||||
// - sid is a valid pointer to a SID data structure
|
||||
// - name_size and domain_size accurately reflect the sizes
|
||||
let result = Security::LookupAccountSidW(
|
||||
None,
|
||||
sid,
|
||||
windows::core::PWSTR(name.as_mut_ptr()),
|
||||
&mut name_size,
|
||||
windows::core::PWSTR(domain.as_mut_ptr()),
|
||||
&mut domain_size,
|
||||
sid_name_use.as_mut_ptr(),
|
||||
);
|
||||
let result = unsafe {
|
||||
Security::LookupAccountSidW(
|
||||
None,
|
||||
sid,
|
||||
Some(windows::core::PWSTR(name.as_mut_ptr())),
|
||||
&mut name_size,
|
||||
Some(windows::core::PWSTR(domain.as_mut_ptr())),
|
||||
&mut domain_size,
|
||||
sid_name_use.as_mut_ptr(),
|
||||
)
|
||||
};
|
||||
|
||||
if result.ok().is_ok() {
|
||||
if result.is_ok() {
|
||||
// Success!
|
||||
return Ok((name, domain));
|
||||
} else if name_size != old_name_size || domain_size != old_domain_size {
|
||||
@@ -274,9 +277,9 @@ unsafe fn lookup_account_sid(sid: PSID) -> Result<(Vec<u16>, Vec<u16>), std::io:
|
||||
// Unknown account and or system domain identification
|
||||
// Possibly foreign item originating from another machine
|
||||
// TODO: Calculate permissions since it has to be possible if Explorer knows.
|
||||
return Err(io::Error::from_raw_os_error(
|
||||
windows::Win32::Foundation::GetLastError().0 as i32,
|
||||
));
|
||||
return Err(io::Error::from_raw_os_error(unsafe {
|
||||
windows::Win32::Foundation::GetLastError().0 as i32
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user