| 1 |
#[cfg(test)] |
| 2 |
mod tests; |
| 3 |
|
| 4 |
use std::path::Path; |
| 5 |
|
| 6 |
use crate::errors::Result; |
| 7 |
use crate::utils::get_static_path; |
| 8 |
|
| 9 |
/// Return the top-level SELinux configuration directory. |
| 10 |
/// |
| 11 |
/// See: `selinux_path()`. |
| 12 |
#[doc(alias = "selinux_path")] |
| 13 |
pub fn selinux() -> Result<&'static Path> { |
| 14 |
get_static_path(selinux_sys::selinux_path, "selinux_path()") |
| 15 |
} |
| 16 |
|
| 17 |
/// Return the context file mapping roles to default types. |
| 18 |
/// |
| 19 |
/// See: `selinux_default_type_path()`. |
| 20 |
#[doc(alias = "selinux_default_type_path")] |
| 21 |
pub fn default_type_path() -> Result<&'static Path> { |
| 22 |
let proc_name = "selinux_default_type_path()"; |
| 23 |
get_static_path(selinux_sys::selinux_default_type_path, proc_name) |
| 24 |
} |
| 25 |
|
| 26 |
/// Return the fail-safe context for emergency logins. |
| 27 |
/// |
| 28 |
/// See: `selinux_failsafe_context_path()`. |
| 29 |
#[doc(alias = "selinux_failsafe_context_path")] |
| 30 |
pub fn fail_safe_context() -> Result<&'static Path> { |
| 31 |
let proc_name = "selinux_failsafe_context_path()"; |
| 32 |
get_static_path(selinux_sys::selinux_failsafe_context_path, proc_name) |
| 33 |
} |
| 34 |
|
| 35 |
/// Return the file system context for removable media. |
| 36 |
/// |
| 37 |
/// See: `selinux_removable_context_path()`. |
| 38 |
#[doc(alias = "selinux_removable_context_path")] |
| 39 |
pub fn removable_context() -> Result<&'static Path> { |
| 40 |
let proc_name = "selinux_removable_context_path()"; |
| 41 |
get_static_path(selinux_sys::selinux_removable_context_path, proc_name) |
| 42 |
} |
| 43 |
|
| 44 |
/// Return the system-wide default contexts for user sessions. |
| 45 |
/// |
| 46 |
/// See: `selinux_default_context_path()`. |
| 47 |
#[doc(alias = "selinux_default_context_path")] |
| 48 |
pub fn default_context() -> Result<&'static Path> { |
| 49 |
let proc_name = "selinux_default_context_path()"; |
| 50 |
get_static_path(selinux_sys::selinux_default_context_path, proc_name) |
| 51 |
} |
| 52 |
|
| 53 |
/// Return the directory containing per-user default contexts. |
| 54 |
/// |
| 55 |
/// See: `selinux_user_contexts_path()`. |
| 56 |
#[doc(alias = "selinux_user_contexts_path")] |
| 57 |
pub fn user_contexts() -> Result<&'static Path> { |
| 58 |
let proc_name = "selinux_user_contexts_path()"; |
| 59 |
get_static_path(selinux_sys::selinux_user_contexts_path, proc_name) |
| 60 |
} |
| 61 |
|
| 62 |
/// Return the default system file contexts configuration. |
| 63 |
/// |
| 64 |
/// See: `selinux_file_context_path()`. |
| 65 |
#[doc(alias = "selinux_file_context_path")] |
| 66 |
pub fn file_context() -> Result<&'static Path> { |
| 67 |
let proc_name = "selinux_file_context_path()"; |
| 68 |
get_static_path(selinux_sys::selinux_file_context_path, proc_name) |
| 69 |
} |
| 70 |
|
| 71 |
/// Return the home directory file contexts configuration. |
| 72 |
/// |
| 73 |
/// See: `selinux_file_context_homedir_path()`. |
| 74 |
#[doc(alias = "selinux_file_context_homedir_path")] |
| 75 |
pub fn file_context_homedir() -> Result<&'static Path> { |
| 76 |
let proc_name = "selinux_file_context_homedir_path()"; |
| 77 |
get_static_path(selinux_sys::selinux_file_context_homedir_path, proc_name) |
| 78 |
} |
| 79 |
|
| 80 |
/// Return the local customization file contexts configuration. |
| 81 |
/// |
| 82 |
/// See: `selinux_file_context_local_path()`. |
| 83 |
#[doc(alias = "selinux_file_context_local_path")] |
| 84 |
pub fn file_context_local() -> Result<&'static Path> { |
| 85 |
let proc_name = "selinux_file_context_local_path()"; |
| 86 |
get_static_path(selinux_sys::selinux_file_context_local_path, proc_name) |
| 87 |
} |
| 88 |
|
| 89 |
/// See: `selinux_file_context_subs_path()`. |
| 90 |
#[doc(alias = "selinux_file_context_subs_path")] |
| 91 |
pub fn file_context_subs() -> Result<&'static Path> { |
| 92 |
let proc_name = "selinux_file_context_subs_path()"; |
| 93 |
get_static_path(selinux_sys::selinux_file_context_subs_path, proc_name) |
| 94 |
} |
| 95 |
|
| 96 |
/// See: `selinux_file_context_subs_dist_path()`. |
| 97 |
#[doc(alias = "selinux_file_context_subs_dist_path")] |
| 98 |
pub fn file_context_subs_dist() -> Result<&'static Path> { |
| 99 |
let proc_name = "selinux_file_context_subs_dist_path()"; |
| 100 |
get_static_path(selinux_sys::selinux_file_context_subs_dist_path, proc_name) |
| 101 |
} |
| 102 |
|
| 103 |
/// See: `selinux_homedir_context_path()`. |
| 104 |
#[doc(alias = "selinux_homedir_context_path")] |
| 105 |
pub fn home_dir_context() -> Result<&'static Path> { |
| 106 |
let proc_name = "selinux_homedir_context_path()"; |
| 107 |
get_static_path(selinux_sys::selinux_homedir_context_path, proc_name) |
| 108 |
} |
| 109 |
|
| 110 |
/// Return the file contexts for media device nodes. |
| 111 |
/// |
| 112 |
/// See: `selinux_media_context_path()`. |
| 113 |
#[doc(alias = "selinux_media_context_path")] |
| 114 |
pub fn media_context() -> Result<&'static Path> { |
| 115 |
let proc_name = "selinux_media_context_path()"; |
| 116 |
get_static_path(selinux_sys::selinux_media_context_path, proc_name) |
| 117 |
} |
| 118 |
|
| 119 |
/// See: `selinux_virtual_domain_context_path()`. |
| 120 |
#[doc(alias = "selinux_virtual_domain_context_path")] |
| 121 |
pub fn virtual_domain_context() -> Result<&'static Path> { |
| 122 |
let proc_name = "selinux_virtual_domain_context_path()"; |
| 123 |
get_static_path(selinux_sys::selinux_virtual_domain_context_path, proc_name) |
| 124 |
} |
| 125 |
|
| 126 |
/// See: `selinux_virtual_image_context_path()`. |
| 127 |
#[doc(alias = "selinux_virtual_image_context_path")] |
| 128 |
pub fn virtual_image_context() -> Result<&'static Path> { |
| 129 |
let proc_name = "selinux_virtual_image_context_path()"; |
| 130 |
get_static_path(selinux_sys::selinux_virtual_image_context_path, proc_name) |
| 131 |
} |
| 132 |
|
| 133 |
/// See: `selinux_lxc_contexts_path()`. |
| 134 |
#[doc(alias = "selinux_lxc_contexts_path")] |
| 135 |
pub fn lxc_contexts() -> Result<&'static Path> { |
| 136 |
let proc_name = "selinux_lxc_contexts_path()"; |
| 137 |
get_static_path(selinux_sys::selinux_lxc_contexts_path, proc_name) |
| 138 |
} |
| 139 |
|
| 140 |
/// Return the file containing configuration for XSELinux extension. |
| 141 |
/// |
| 142 |
/// See: `selinux_x_context_path()`. |
| 143 |
#[doc(alias = "selinux_x_context_path")] |
| 144 |
pub fn x_context() -> Result<&'static Path> { |
| 145 |
let proc_name = "selinux_x_context_path()"; |
| 146 |
get_static_path(selinux_sys::selinux_x_context_path, proc_name) |
| 147 |
} |
| 148 |
|
| 149 |
/// Return the file containing configuration for SE-PostgreSQL. |
| 150 |
/// |
| 151 |
/// See: `selinux_sepgsql_context_path()`. |
| 152 |
#[doc(alias = "selinux_sepgsql_context_path")] |
| 153 |
pub fn sepgsql_context() -> Result<&'static Path> { |
| 154 |
let proc_name = "selinux_sepgsql_context_path()"; |
| 155 |
get_static_path(selinux_sys::selinux_sepgsql_context_path, proc_name) |
| 156 |
} |
| 157 |
|
| 158 |
/// See: `selinux_openrc_contexts_path()`. |
| 159 |
#[doc(alias = "selinux_openrc_contexts_path")] |
| 160 |
pub fn openrc_contexts() -> Result<&'static Path> { |
| 161 |
let proc_name = "selinux_openrc_contexts_path()"; |
| 162 |
get_static_path(selinux_sys::selinux_openrc_contexts_path, proc_name) |
| 163 |
} |
| 164 |
|
| 165 |
/// See: `selinux_openssh_contexts_path()`. |
| 166 |
#[doc(alias = "selinux_openssh_contexts_path")] |
| 167 |
pub fn openssh_contexts() -> Result<&'static Path> { |
| 168 |
let proc_name = "selinux_openssh_contexts_path()"; |
| 169 |
get_static_path(selinux_sys::selinux_openssh_contexts_path, proc_name) |
| 170 |
} |
| 171 |
|
| 172 |
/// See: `selinux_snapperd_contexts_path()`. |
| 173 |
#[doc(alias = "selinux_snapperd_contexts_path")] |
| 174 |
pub fn snapperd_contexts() -> Result<&'static Path> { |
| 175 |
let proc_name = "selinux_snapperd_contexts_path()"; |
| 176 |
get_static_path(selinux_sys::selinux_snapperd_contexts_path, proc_name) |
| 177 |
} |
| 178 |
|
| 179 |
/// See: `selinux_systemd_contexts_path()`. |
| 180 |
#[doc(alias = "selinux_systemd_contexts_path")] |
| 181 |
pub fn systemd_contexts() -> Result<&'static Path> { |
| 182 |
let proc_name = "selinux_systemd_contexts_path()"; |
| 183 |
get_static_path(selinux_sys::selinux_systemd_contexts_path, proc_name) |
| 184 |
} |
| 185 |
|
| 186 |
/// Return the directory containing all of the context configuration files. |
| 187 |
/// |
| 188 |
/// See: `selinux_contexts_path()`. |
| 189 |
#[doc(alias = "selinux_contexts_path")] |
| 190 |
pub fn contexts() -> Result<&'static Path> { |
| 191 |
let proc_name = "selinux_contexts_path()"; |
| 192 |
get_static_path(selinux_sys::selinux_contexts_path, proc_name) |
| 193 |
} |
| 194 |
|
| 195 |
/// Return the defines tty types for newrole securettys. |
| 196 |
/// |
| 197 |
/// See: `selinux_securetty_types_path()`. |
| 198 |
#[doc(alias = "selinux_securetty_types_path")] |
| 199 |
pub fn securetty_types() -> Result<&'static Path> { |
| 200 |
let proc_name = "selinux_securetty_types_path()"; |
| 201 |
get_static_path(selinux_sys::selinux_securetty_types_path, proc_name) |
| 202 |
} |
| 203 |
|
| 204 |
/// See: `selinux_booleans_subs_path()`. |
| 205 |
#[doc(alias = "selinux_booleans_subs_path")] |
| 206 |
pub fn booleans_subs() -> Result<&'static Path> { |
| 207 |
let proc_name = "selinux_booleans_subs_path()"; |
| 208 |
get_static_path(selinux_sys::selinux_booleans_subs_path, proc_name) |
| 209 |
} |
| 210 |
|
| 211 |
/// See: `selinux_customizable_types_path()`. |
| 212 |
#[doc(alias = "selinux_customizable_types_path")] |
| 213 |
pub fn customizable_types() -> Result<&'static Path> { |
| 214 |
let proc_name = "selinux_customizable_types_path()"; |
| 215 |
get_static_path(selinux_sys::selinux_customizable_types_path, proc_name) |
| 216 |
} |
| 217 |
|
| 218 |
/// Return the file containing mapping between Linux users and SELinux users. |
| 219 |
/// |
| 220 |
/// See: `selinux_usersconf_path()`. |
| 221 |
#[doc(alias = "selinux_usersconf_path")] |
| 222 |
pub fn users_conf() -> Result<&'static Path> { |
| 223 |
let proc_name = "selinux_usersconf_path()"; |
| 224 |
get_static_path(selinux_sys::selinux_usersconf_path, proc_name) |
| 225 |
} |
| 226 |
|
| 227 |
/// See: `selinux_translations_path()`. |
| 228 |
#[doc(alias = "selinux_translations_path")] |
| 229 |
pub fn translations() -> Result<&'static Path> { |
| 230 |
let proc_name = "selinux_translations_path()"; |
| 231 |
get_static_path(selinux_sys::selinux_translations_path, proc_name) |
| 232 |
} |
| 233 |
|
| 234 |
/// See: `selinux_colors_path()`. |
| 235 |
#[doc(alias = "selinux_colors_path")] |
| 236 |
pub fn colors() -> Result<&'static Path> { |
| 237 |
get_static_path(selinux_sys::selinux_colors_path, "selinux_colors_path()") |
| 238 |
} |
| 239 |
|
| 240 |
/// Return the default netfilter context. |
| 241 |
/// |
| 242 |
/// See: `selinux_netfilter_context_path()`. |
| 243 |
#[doc(alias = "selinux_netfilter_context_path")] |
| 244 |
pub fn netfilter_context() -> Result<&'static Path> { |
| 245 |
let proc_name = "selinux_netfilter_context_path()"; |
| 246 |
get_static_path(selinux_sys::selinux_netfilter_context_path, proc_name) |
| 247 |
} |