diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index cd21d5f..519fb09 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -188,7 +188,7 @@ jobs: sed -i.bk "s|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 diff --git a/src/flags/color.rs b/src/flags/color.rs index 005f62d..f8505e1 100644 --- a/src/flags/color.rs +++ b/src/flags/color.rs @@ -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 { diff --git a/src/meta/windows_utils.rs b/src/meta/windows_utils.rs index 2916cd5..4e18f39 100644 --- a/src/meta/windows_utils.rs +++ b/src/meta/windows_utils.rs @@ -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>(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, Vec), 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, Vec), 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 + })); } } }