Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(Security): Re-define AuthorizationExecuteWithPrivileges #712

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/objc2/src/topics/about_generated/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- `UserNotificationsUI` / `objc2-user-notifications-ui`.
* Added fallback for `MTLCopyAllDevices` on non-macOS platforms.

### Fixed
* **BREAKING**: Fixed the type of `AuthorizationExecuteWithPrivileges`'s
`arguments` parameter by changing it from `NonNull<NonNull<c_char>>` to
`NonNull<AuthorizationString>`, i.e. `NonNull<*const c_char>`. See #711
for more details.


## 0.3.0 - 2025-01-22

Expand Down
44 changes: 44 additions & 0 deletions framework-crates/objc2-security/src/authorization.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#[cfg(feature = "libc")]
use core::ffi::c_char;
#[cfg(feature = "libc")]
use core::ptr::NonNull;

#[cfg(feature = "libc")]
use crate::{AuthorizationFlags, AuthorizationRef, AuthorizationString, OSStatus};

// Manual re-definition: see #711.
extern "C-unwind" {
/// Run an executable tool with enhanced privileges after passing
/// suitable authorization procedures.
///
///
/// Parameter `authorization`: An authorization reference that is used to authorize
/// access to the enhanced privileges. It is also passed to the tool for
/// further access control.
///
/// Parameter `pathToTool`: Full pathname to the tool that should be executed
/// with enhanced privileges.
///
/// Parameter `options`: Option bits (reserved). Must be zero.
///
/// Parameter `arguments`: An argv-style vector of strings to be passed to the tool.
///
/// Parameter `communicationsPipe`: Assigned a UNIX stdio FILE pointer for
/// a bidirectional pipe to communicate with the tool. The tool will have
/// this pipe as its standard I/O channels (stdin/stdout). If NULL, do not
/// establish a communications pipe.
///
///
/// This function has been deprecated and should no longer be used.
/// Use a launchd-launched helper tool and/or the Service Mangement framework
/// for this functionality.
#[cfg(feature = "libc")]
#[deprecated]
pub fn AuthorizationExecuteWithPrivileges(
authorization: AuthorizationRef,
path_to_tool: NonNull<c_char>,
options: AuthorizationFlags,
arguments: NonNull<AuthorizationString>,
communications_pipe: *mut *mut libc::FILE,
) -> OSStatus;
}
4 changes: 4 additions & 0 deletions framework-crates/objc2-security/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ mod generated;
#[allow(unused_imports, unreachable_pub)]
pub use self::generated::*;

// Manual fixes.
mod authorization;
pub use authorization::*;

#[cfg(all(feature = "cssmtype", feature = "cssmconfig", feature = "objc2"))]
use objc2::encode::{Encode, Encoding, RefEncode};

Expand Down
3 changes: 3 additions & 0 deletions framework-crates/objc2-security/translation-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,6 @@ enum.anonymous.constants.callerSecuritySession.use-value = true
# CSSM_WORDID_VENDOR_START from i32 to CSSM_WORDID_KEYCHAIN_PROMPT which is
# u32). So let's just emit all constants directly for now.
enum.anonymous.use-value = true

# Manually re-defined: see #711.
fn.AuthorizationExecuteWithPrivileges.skipped = true
2 changes: 1 addition & 1 deletion generated
Loading