security_translocate_sys/
bindings.rs

1use crate::annotations::{_Nonnull, _Nullable};
2use core_foundation::dictionary::CFDictionaryRef;
3use core_foundation::error::CFErrorRef;
4use core_foundation::url::CFURLRef;
5use libc::pid_t;
6
7#[link(name = "Security", kind = "framework")]
8extern "C" {
9    /// Initialize the SecTranslocate Library as the XPC Server, Disk Arbitration Listener, and Launch Services Notification listener
10    ///
11    /// # Arguments
12    /// * `error` - On error will be populated with an error object describing the failure (a posix domain error such as EINVAL)
13    ///
14    /// # Return
15    /// true on success false on failure
16    pub fn SecTranslocateStartListening(error: _Nullable<*mut CFErrorRef>) -> bool; // __OSX_AVAILABLE(10.12)
17
18    /// Initialize the SecTranslocate Library as the XPC Server, Disk Arbitration Listener, and Launch Services Notification listener
19    ///
20    /// # Arguments
21    /// * `options` - (currently unused) A dictionary of options that could impact server startup
22    /// * `out_error` - On error will be populated with an error object describing the failure (a posix domain error such as EINVAL)
23    ///
24    /// # Return
25    /// true on success false on failure
26    pub fn SecTranslocateStartListeningWithOptions(
27        options: _Nonnull<CFDictionaryRef>,
28        out_error: _Nullable<*mut CFErrorRef>,
29    ) -> bool; // __OSX_AVAILABLE(10.12)
30
31    /// Create a CFURL pointing to a translocated location from which to access the directory specified by pathToTranslocate.
32    ///
33    /// # Arguments
34    /// * `path_to_translocate` - URL of the directory to be accessed from a translocated location.
35    /// * `destination_path` - URL where the directory of interest should be translocated, or NULL for a random UUID location
36    /// * `error` - On error will be populated with an error object describing the failure (a posix domain error such as EINVAL)
37    ///
38    /// # Return
39    /// A CFURL pointing to the translocated location of the directory.
40    ///
41    /// # Discussion
42    /// <https://github.com/apple-oss-distributions/Security/blob/rel/Security-59754/OSX/libsecurity_translocate/lib/SecTranslocate.h#L71-L96>
43    pub fn SecTranslocateCreateSecureDirectoryForURL(
44        path_to_translocate: _Nonnull<CFURLRef>,
45        destination_path: _Nullable<CFURLRef>,
46        error: _Nullable<*mut CFErrorRef>,
47    ) -> _Nullable<CFURLRef>; // __OSX_AVAILABLE(10.12)
48
49    /// Create a CFURL pointing to a translocated location from which to access the directory specified by pathToTranslocate.
50    ///
51    /// # Arguments
52    /// * `path_to_translocate` - URL of the directory to be accessed from a translocated location.
53    /// * `destination_path` - URL where the directory of interest should be translocated
54    /// * `error` - On error will be populated with an error object describing the failure (a posix domain error such as EINVAL)
55    ///
56    /// # Return
57    /// A CFURL pointing to the translocated location of the directory.
58    ///
59    /// # Discussion
60    /// <https://github.com/apple-oss-distributions/Security/blob/rel/Security-59754/OSX/libsecurity_translocate/lib/SecTranslocate.h#L112-L123>
61    pub fn SecTranslocateCreateGeneric(
62        path_to_translocate: _Nonnull<CFURLRef>,
63        destination_path: _Nonnull<CFURLRef>,
64        error: _Nullable<*mut CFErrorRef>,
65    ) -> _Nullable<CFURLRef>; // __OSX_AVAILABLE(10.16)
66
67    /// Register that a translocated pid is running
68    ///
69    /// # Arguments
70    /// * `pid` - the pid to register
71    ///
72    /// # Discussion
73    /// <https://github.com/apple-oss-distributions/Security/blob/rel/Security-59754/OSX/libsecurity_translocate/lib/SecTranslocate.h#L135-L137>
74    pub fn SecTranslocateAppLaunchCheckin(pid: pid_t); // __OSX_AVAILABLE(10.12)
75
76    /// Implements policy to decide whether the entity defined by path should be run translocated
77    ///
78    /// # Arguments
79    /// * `path` - URL to the entity in question
80    /// * `should_translocate` - true if the path should be translocated, false otherwise
81    /// * `error` - On error will be populated with an error object describing the failure (a posix domain error such as EINVAL)
82    ///
83    /// # Return
84    /// true on success, false on failure (on failure error is set if provided). shouldTranslocate gives the answer
85    ///
86    /// # Discussion
87    /// <https://github.com/apple-oss-distributions/Security/blob/rel/Security-59754/OSX/libsecurity_translocate/lib/SecTranslocate.h#L155-L161>
88    pub fn SecTranslocateURLShouldRunTranslocated(
89        path: _Nonnull<CFURLRef>,
90        should_translocate: _Nonnull<*mut bool>,
91        error: _Nullable<*mut CFErrorRef>,
92    ) -> bool; // __OSX_AVAILABLE(10.12)
93
94    /// indicates whether the provided path is an original path or a translocated path
95    ///
96    /// # Arguments
97    /// * `path` - path to check
98    /// * `is_translocated` - true if the path is translocated, false otherwise
99    /// * `error` - On error will be populated with an error object describing the failure (a posix domain error such as EINVAL)
100    ///
101    /// # Return
102    /// true on success, false on failure (on failure error is set if provided). isTranslocated gives the answer
103    ///
104    /// # Discussion
105    /// <https://github.com/apple-oss-distributions/Security/blob/rel/Security-59754/OSX/libsecurity_translocate/lib/SecTranslocate.h#L179-L188>
106    pub fn SecTranslocateIsTranslocatedURL(
107        path: _Nonnull<CFURLRef>,
108        is_translocated: _Nonnull<*mut bool>,
109        error: _Nullable<*mut CFErrorRef>,
110    ) -> bool; // __OSX_AVAILABLE(10.12)
111
112    /// finds the original path to a file given a translocated path
113    ///
114    /// # Arguments
115    /// * `translocated_path` - the path to look up
116    /// * `error` - On error will be populated with an error object describing the failure (a posix domain error such as EINVAL)
117    ///
118    /// # Return
119    /// A valid, existant path, or NULL on error
120    ///
121    /// # Discussion
122    /// <https://github.com/apple-oss-distributions/Security/blob/rel/Security-59754/OSX/libsecurity_translocate/lib/SecTranslocate.h#L204-L213>
123    pub fn SecTranslocateCreateOriginalPathForURL(
124        translocated_path: _Nonnull<CFURLRef>,
125        error: _Nullable<*mut CFErrorRef>,
126    ) -> _Nullable<CFURLRef>; // __OSX_AVAILABLE(10.12)
127
128    /// Unmount the translocated directory structure and delete the mount point directory.
129    ///
130    /// # Arguments
131    /// * `translocated_path` - a CFURL pointing to a translocated location.
132    /// * `error` - On error will be populated with an error object describing the failure (a posix domain error such as EINVAL).
133    ///
134    /// # Return
135    /// true on success, false on error.
136    ///
137    /// # Discussion
138    /// <https://github.com/apple-oss-distributions/Security/blob/rel/Security-59754/OSX/libsecurity_translocate/lib/SecTranslocate.h#L229-L232>
139    pub fn SecTranslocateDeleteSecureDirectory(
140        translocated_path: _Nonnull<CFURLRef>,
141        error: _Nullable<*mut CFErrorRef>,
142    ) -> bool; // __OSX_AVAILABLE(10.12)
143}