illumos_priv/privileges.rs
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5// Copyright 2019 Joyent, Inc.
6
7//! The definitions below are sourced from an illumos system in `/usr/include/sys/priv_names.h`
8
9use std::ffi::CStr;
10use std::os::raw::c_char;
11
12#[derive(Debug)]
13/// Mapping to the various illumos PRIVILEGES(5).
14pub enum Privilege {
15 /// Allows a process to request critical events without limitation.
16 /// Allows a process to request reliable delivery of all events on
17 /// any event queue.
18 ContractEvent,
19
20 /// Allows a process to set the service FMRI value of a process
21 /// contract template.
22 ContractIdentity,
23
24 /// Allows a process to observe contract events generated by
25 /// contracts created and owned by users other than the process's
26 /// effective user ID.
27 /// Allows a process to open contract event endpoints belonging to
28 /// contracts created and owned by users other than the process's
29 /// effective user ID.
30 ContractObserver,
31
32 /// Allow a process to access per-CPU hardware performance counters.
33 CpcCpu,
34
35 /// Allows DTrace kernel-level tracing.
36 DtraceKernel,
37
38 /// Allows DTrace process-level tracing.
39 /// Allows process-level tracing probes to be placed and enabled in
40 /// processes to which the user has permissions.
41 DtraceProc,
42
43 /// Allows DTrace user-level tracing.
44 /// Allows use of the syscall and profile DTrace providers to
45 /// examine processes to which the user has permissions.
46 DtraceUser,
47
48 /// Allows a process to change a file's owner user ID.
49 /// Allows a process to change a file's group ID to one other than
50 /// the process' effective group ID or one of the process'
51 /// supplemental group IDs.
52 FileChown,
53
54 /// Allows a process to give away its files; a process with this
55 /// privilege will run as if {_POSIX_CHOWN_RESTRICTED} is not
56 /// in effect.
57 FileChownSelf,
58
59 /// Allows a process to execute an executable file whose permission
60 /// bits or ACL do not allow the process execute permission.
61 FileDacExecute,
62
63 /// Allows a process to read a file or directory whose permission
64 /// bits or ACL do not allow the process read permission.
65 FileDacRead,
66
67 /// Allows a process to search a directory whose permission bits or
68 /// ACL do not allow the process search permission.
69 FileDacSearch,
70
71 /// Allows a process to write a file or directory whose permission
72 /// bits or ACL do not allow the process write permission.
73 /// In order to write files owned by uid 0 in the absence of an
74 /// effective uid of 0 ALL privileges are required.
75 FileDacWrite,
76
77 /// Allows a process to set the sensitivity label of a file or
78 /// directory to a sensitivity label that does not dominate the
79 /// existing sensitivity label.
80 /// This privilege is interpreted only if the system is configured
81 /// with Trusted Extensions.
82 FileDowngradeSl,
83
84 /// Allows a process to set immutable, nounlink or appendonly
85 /// file attributes.
86 FileFlagSet,
87
88 /// Allows a process to create hardlinks to files owned by a uid
89 /// different from the process' effective uid.
90 FileLinkAny,
91
92 /// Allows a process which is not the owner of a file or directory
93 /// to perform the following operations that are normally permitted
94 /// only for the file owner: modify that file's access and
95 /// modification times; remove or rename a file or directory whose
96 /// parent directory has the ``save text image after execution''
97 /// (sticky) bit set; mount a ``namefs'' upon a file; modify
98 /// permission bits or ACL except for the set-uid and set-gid
99 /// bits.
100 FileOwner,
101
102 /// Allows a process to read objects in the filesystem.
103 FileRead,
104
105 /// Allows a process to change the ownership of a file or write to
106 /// a file without the set-user-ID and set-group-ID bits being
107 /// cleared.
108 /// Allows a process to set the set-group-ID bit on a file or
109 /// directory whose group is not the process' effective group or
110 /// one of the process' supplemental groups.
111 /// Allows a process to set the set-user-ID bit on a file with
112 /// different ownership in the presence of PRIV_FILE_OWNER.
113 /// Additional restrictions apply when creating or modifying a
114 /// set-uid 0 file.
115 FileSetid,
116
117 /// Allows a process to set the sensitivity label of a file or
118 /// directory to a sensitivity label that dominates the existing
119 /// sensitivity label.
120 /// This privilege is interpreted only if the system is configured
121 /// with Trusted Extensions.
122 FileUpgradeSl,
123
124 /// Allows a process to modify objects in the filesystem.
125 FileWrite,
126
127 /// Allows a process to make privileged ioctls to graphics devices.
128 /// Typically only xserver process needs to have this privilege.
129 /// A process with this privilege is also allowed to perform
130 /// privileged graphics device mappings.
131 GraphicsAccess,
132
133 /// Allows a process to perform privileged mappings through a
134 /// graphics device.
135 GraphicsMap,
136
137 /// Allows a process to manage hyprlofs entries.
138 HyprlofsControl,
139
140 /// Allows a process to read a System V IPC
141 /// Message Queue, Semaphore Set, or Shared Memory Segment whose
142 /// permission bits do not allow the process read permission.
143 /// Allows a process to read remote shared memory whose
144 /// permission bits do not allow the process read permission.
145 IpcDacRead,
146
147 /// Allows a process to write a System V IPC
148 /// Message Queue, Semaphore Set, or Shared Memory Segment whose
149 /// permission bits do not allow the process write permission.
150 /// Allows a process to read remote shared memory whose
151 /// permission bits do not allow the process write permission.
152 /// Additional restrictions apply if the owner of the object has uid 0
153 /// and the effective uid of the current process is not 0.
154 IpcDacWrite,
155
156 /// Allows a process which is not the owner of a System
157 /// V IPC Message Queue, Semaphore Set, or Shared Memory Segment to
158 /// remove, change ownership of, or change permission bits of the
159 /// Message Queue, Semaphore Set, or Shared Memory Segment.
160 /// Additional restrictions apply if the owner of the object has uid 0
161 /// and the effective uid of the current process is not 0.
162 IpcOwner,
163
164 /// Allows a process to open a TCP, UDP, SDP or SCTP network endpoint.
165 NetAccess,
166
167 /// Allow a process to bind to a port that is configured as a
168 /// multi-level port(MLP) for the process's zone. This privilege
169 /// applies to both shared address and zone-specific address MLPs.
170 /// See tnzonecfg(4) from the Trusted Extensions manual pages for
171 /// information on configuring MLP ports.
172 /// This privilege is interpreted only if the system is configured
173 /// with Trusted Extensions.
174 NetBindmlp,
175
176 /// Allows a process to send and receive ICMP packets.
177 NetIcmpaccess,
178
179 /// Allows a process to set NET_MAC_AWARE process flag by using
180 /// setpflags(2). This privilege also allows a process to set
181 /// SO_MAC_EXEMPT socket option by using setsockopt(3SOCKET).
182 /// The NET_MAC_AWARE process flag and the SO_MAC_EXEMPT socket
183 /// option both allow a local process to communicate with an
184 /// unlabeled peer if the local process' label dominates the
185 /// peer's default label, or if the local process runs in the
186 /// global zone.
187 /// This privilege is interpreted only if the system is configured
188 /// with Trusted Extensions.
189 NetMacAware,
190
191 /// Allows a process to set SO_MAC_IMPLICIT option by using
192 /// setsockopt(3SOCKET). This allows a privileged process to
193 /// transmit implicitly-labeled packets to a peer.
194 /// This privilege is interpreted only if the system is configured
195 /// with Trusted Extensions.
196 NetMacImplicit,
197
198 /// Allows a process to access /dev/lo0 and the devices in /dev/ipnet/
199 /// while not requiring them to need PRIV_NET_RAWACCESS.
200 NetObservability,
201
202 /// Allows a process to bind to a privileged port
203 /// number. The privilege port numbers are 1-1023 (the traditional
204 /// UNIX privileged ports) as well as those ports marked as
205 /// "udp/tcp_extra_priv_ports" with the exception of the ports
206 /// reserved for use by NFS.
207 NetPrivaddr,
208
209 /// Allows a process to have direct access to the network layer.
210 NetRawaccess,
211
212 /// Allows a process to generate audit records.
213 /// Allows a process to get its own audit pre-selection information.
214 ProcAudit,
215
216 /// Allows a process to change its root directory.
217 ProcChroot,
218
219 /// Allows a process to use high resolution timers.
220 ProcClockHighres,
221
222 /// Allows a process to call execve().
223 ProcExec,
224
225 /// Allows a process to call fork1()/forkall()/vfork()
226 ProcFork,
227
228 /// Allows a process to examine the status of processes other
229 /// than those it can send signals to. Processes which cannot
230 /// be examined cannot be seen in /proc and appear not to exist.
231 ProcInfo,
232
233 /// Allows a process to lock pages in physical memory.
234 ProcLockMemory,
235
236 /// Allows a process to access physical memory information.
237 ProcMeminfo,
238
239 /// Allows a process to send signals to other processes, inspect
240 /// and modify process state to other processes regardless of
241 /// ownership. When modifying another process, additional
242 /// restrictions apply: the effective privilege set of the
243 /// attaching process must be a superset of the target process'
244 /// effective, permitted and inheritable sets; the limit set must
245 /// be a superset of the target's limit set; if the target process
246 /// has any uid set to 0 all privilege must be asserted unless the
247 /// effective uid is 0.
248 /// Allows a process to bind arbitrary processes to CPUs.
249 ProcOwner,
250
251 /// Allows a process to elevate its priority above its current level.
252 ProcPrioup,
253
254 /// Allows all that PRIV_PROC_PRIOUP allows.
255 /// Allows a process to change its scheduling class to any scheduling class,
256 /// including the RT class.
257 ProcPriocntl,
258
259 /// Allows a process to manipulate the secflags of processes (subject to,
260 /// additionally, the ability to signal that process)
261 ProcSecflags,
262
263 /// Allows a process to send signals or trace processes outside its
264 /// session.
265 ProcSession,
266
267 /// Allows a process to set its uids at will.
268 /// Assuming uid 0 requires all privileges to be asserted.
269 ProcSetid,
270
271 /// Allows a process to assign a new task ID to the calling process.
272 ProcTaskid,
273
274 /// Allows a process to trace or send signals to processes in
275 /// other zones.
276 ProcZone,
277
278 /// Allows a process to enable and disable and manage accounting through
279 /// acct(2), getacct(2), putacct(2) and wracct(2).
280 SysAcct,
281
282 /// Allows a process to perform system administration tasks such
283 /// as setting node and domain name and specifying nscd and coreadm
284 /// settings.
285 SysAdmin,
286
287 /// Allows a process to start the (kernel) audit daemon.
288 /// Allows a process to view and set audit state (audit user ID,
289 /// audit terminal ID, audit sessions ID, audit pre-selection mask).
290 /// Allows a process to turn off and on auditing.
291 /// Allows a process to configure the audit parameters (cache and
292 /// queue sizes, event to class mappings, policy options).
293 SysAudit,
294
295 /// Allows a process to perform various system configuration tasks.
296 /// Allows a process to add and remove swap devices; when adding a swap
297 /// device, a process must also have sufficient privileges to read from
298 /// and write to the swap device.
299 SysConfig,
300
301 /// Allows a process to successfully call a kernel module that
302 /// calls the kernel drv_priv(9F) function to check for allowed
303 /// access.
304 /// Allows a process to open the real console device directly.
305 /// Allows a process to open devices that have been exclusively opened.
306 SysDevices,
307
308 /// Allows a process to import a potentially untrusted file system.
309 SysFsImport,
310
311 /// Allows a process to increase the size of a System V IPC Message
312 /// Queue buffer.
313 SysIpcConfig,
314
315 /// Allows a process to unlink and link directories.
316 SysLinkdir,
317
318 /// Allows filesystem specific administrative procedures, such as
319 /// filesystem configuration ioctls, quota calls and creation/deletion
320 /// of snapshots.
321 /// Allows a process to mount and unmount filesystems which would
322 /// otherwise be restricted (i.e., most filesystems except
323 /// namefs).
324 /// A process performing a mount operation needs to have
325 /// appropriate access to the device being mounted (read-write for
326 /// "rw" mounts, read for "ro" mounts).
327 /// A process performing any of the aforementioned
328 /// filesystem operations needs to have read/write/owner
329 /// access to the mount point.
330 /// Only regular files and directories can serve as mount points
331 /// for processes which do not have all zone privileges asserted.
332 /// Unless a process has all zone privileges, the mount(2)
333 /// system call will force the "nosuid" and "restrict" options, the
334 /// latter only for autofs mountpoints.
335 /// Regardless of privileges, a process running in a non-global zone may
336 /// only control mounts performed from within said zone.
337 /// Outside the global zone, the "nodevices" option is always forced.
338 SysMount,
339
340 /// Allows a process to configure IP tunnel links.
341 SysIptunConfig,
342
343 /// Allows a process to configure all classes of datalinks, including
344 /// configuration allowed by PRIV_SYS_IPTUN_CONFIG.
345 SysDlConfig,
346
347 /// Allows a process to configure a system's IP interfaces and routes.
348 /// Allows a process to configure network parameters using ndd.
349 /// Allows a process access to otherwise restricted information using ndd.
350 /// Allows a process to configure IPsec.
351 /// Allows a process to pop anchored STREAMs modules with matching zoneid.
352 SysIpConfig,
353
354 /// Allows all that PRIV_SYS_IP_CONFIG, PRIV_SYS_DL_CONFIG, and
355 /// PRIV_SYS_PPP_CONFIG allow.
356 /// Allows a process to push the rpcmod STREAMs module.
357 /// Allows a process to INSERT/REMOVE STREAMs modules on locations other
358 /// than the top of the module stack.
359 SysNetConfig,
360
361 /// Allows a process to perform Sun private NFS specific system calls.
362 /// Allows a process to bind to ports reserved by NFS: ports 2049 (nfs)
363 /// and port 4045 (lockd).
364 SysNfs,
365
366 /// Allows a process to create and destroy PPP (sppp) interfaces.
367 /// Allows a process to configure PPP tunnels (sppptun).
368 SysPppConfig,
369
370 /// Allows a process to bind processes to processor sets.
371 SysResBind,
372
373 /// Allows all that PRIV_SYS_RES_BIND allows.
374 /// Allows a process to create and delete processor sets, assign
375 /// CPUs to processor sets and override the PSET_NOESCAPE property.
376 /// Allows a process to change the operational status of CPUs in
377 /// the system using p_online(2).
378 /// Allows a process to configure resource pools and to bind
379 /// processes to pools
380 SysResConfig,
381
382 /// Allows a process to modify the resource limits specified
383 /// by setrlimit(2) and setrctl(2) without restriction.
384 /// Allows a process to exceed the per-user maximum number of
385 /// processes.
386 /// Allows a process to extend or create files on a filesystem that
387 /// has less than minfree space in reserve.
388 SysResource,
389
390 /// Allows a process to access the Sun private SMB kernel module.
391 /// Allows a process to bind to ports reserved by NetBIOS and SMB:
392 /// ports 137 (NBNS), 138 (NetBIOS Datagram Service), 139 (NetBIOS
393 /// Session Service and SMB-over-NBT) and 445 (SMB-over-TCP).
394 SysSmb,
395
396 /// Allows a process to successfully call a third party loadable module
397 /// that calls the kernel suser() function to check for allowed access.
398 /// This privilege exists only for third party loadable module
399 /// compatibility and is not used by Solaris proper.
400 SysSuserCompat,
401
402 /// Allows a process to manipulate system time using any of the
403 /// appropriate system calls: stime, adjtime, ntp_adjtime and
404 /// the IA specific RTC calls.
405 SysTime,
406
407 /// Allows a process to translate labels that are not dominated
408 /// by the process' sensitivity label to and from an external
409 /// string form.
410 /// This privilege is interpreted only if the system is configured
411 /// with Trusted Extensions.
412 SysTransLabel,
413
414 /// Allows a process to manage virtualized environments such as
415 /// xVM(5).
416 VirtManage,
417
418 /// Allows a process to override colormap restrictions.
419 /// Allows a process to install or remove colormaps.
420 /// Allows a process to retrieve colormap cell entries allocated
421 /// by other processes.
422 /// This privilege is interpreted only if the system is configured
423 /// with Trusted Extensions.
424 WinColormap,
425
426 /// Allows a process to configure or destroy resources that are
427 /// permanently retained by the X server.
428 /// Allows a process to use SetScreenSaver to set the screen
429 /// saver timeout value.
430 /// Allows a process to use ChangeHosts to modify the display
431 /// access control list.
432 /// Allows a process to use GrabServer.
433 /// Allows a process to use the SetCloseDownMode request which
434 /// may retain window, pixmap, colormap, property, cursor, font,
435 /// or graphic context resources.
436 /// This privilege is interpreted only if the system is configured
437 /// with Trusted Extensions.
438 WinConfig,
439
440 /// Allows a process to read from a window resource that it does
441 /// not own (has a different user ID).
442 /// This privilege is interpreted only if the system is configured
443 /// with Trusted Extensions.
444 WinDacRead,
445
446 /// Allows a process to write to or create a window resource that
447 /// it does not own (has a different user ID). A newly created
448 /// window property is created with the window's user ID.
449 /// This privilege is interpreted only if the system is configured
450 /// with Trusted Extensions.
451 WinDacWrite,
452
453 /// Allows a process to perform operations on window input devices.
454 /// Allows a process to get and set keyboard and pointer controls.
455 /// Allows a process to modify pointer button and key mappings.
456 /// This privilege is interpreted only if the system is configured
457 /// with Trusted Extensions.
458 WinDevices,
459
460 /// Allows a process to use the direct graphics access (DGA) X protocol
461 /// extensions. Direct process access to the frame buffer is still
462 /// required. Thus the process must have MAC and DAC privileges that
463 /// allow access to the frame buffer, or the frame buffer must be
464 /// allocated to the process.
465 /// This privilege is interpreted only if the system is configured
466 /// with Trusted Extensions.
467 WinDga,
468
469 /// Allows a process to set the sensitivity label of a window resource
470 /// to a sensitivity label that does not dominate the existing
471 /// sensitivity label.
472 /// This privilege is interpreted only if the system is configured
473 /// with Trusted Extensions.
474 WinDowngradeSl,
475
476 /// Allows a process to set a font path.
477 /// This privilege is interpreted only if the system is configured
478 /// with Trusted Extensions.
479 WinFontpath,
480
481 /// Allows a process to read from a window resource whose sensitivity
482 /// label is not equal to the process sensitivity label.
483 /// This privilege is interpreted only if the system is configured
484 /// with Trusted Extensions.
485 WinMacRead,
486
487 /// Allows a process to create a window resource whose sensitivity
488 /// label is not equal to the process sensitivity label.
489 /// A newly created window property is created with the window's
490 /// sensitivity label.
491 /// This privilege is interpreted only if the system is configured
492 /// with Trusted Extensions.
493 WinMacWrite,
494
495 /// Allows a process to request inter-window data moves without the
496 /// intervention of the selection confirmer.
497 /// This privilege is interpreted only if the system is configured
498 /// with Trusted Extensions.
499 WinSelection,
500
501 /// Allows a process to set the sensitivity label of a window
502 /// resource to a sensitivity label that dominates the existing
503 /// sensitivity label.
504 /// This privilege is interpreted only if the system is configured
505 /// with Trusted Extensions.
506 WinUpgradeSl,
507
508 /// Allows a process access to the xVM(5) control devices for
509 /// managing guest domains and the hypervisor. This privilege is
510 /// used only if booted into xVM on x86 platforms.
511 XvmControl,
512}
513
514impl Privilege {
515 fn as_str(&self) -> &'static str {
516 match self {
517 Privilege::ContractEvent => "contract_event\0",
518 Privilege::ContractIdentity => "contract_identity\0",
519 Privilege::ContractObserver => "contract_observer\0",
520 Privilege::CpcCpu => "cpc_cpu\0",
521 Privilege::DtraceKernel => "dtrace_kernel\0",
522 Privilege::DtraceProc => "dtrace_proc\0",
523 Privilege::DtraceUser => "dtrace_user\0",
524 Privilege::FileChown => "file_chown\0",
525 Privilege::FileChownSelf => "file_chown_self\0",
526 Privilege::FileDacExecute => "file_dac_execute\0",
527 Privilege::FileDacRead => "file_dac_read\0",
528 Privilege::FileDacSearch => "file_dac_search\0",
529 Privilege::FileDacWrite => "file_dac_write\0",
530 Privilege::FileDowngradeSl => "file_downgrade_sl\0",
531 Privilege::FileFlagSet => "file_flag_set\0",
532 Privilege::FileLinkAny => "file_link_any\0",
533 Privilege::FileOwner => "file_owner\0",
534 Privilege::FileRead => "file_read\0",
535 Privilege::FileSetid => "file_setid\0",
536 Privilege::FileUpgradeSl => "file_upgrade_sl\0",
537 Privilege::FileWrite => "file_write\0",
538 Privilege::GraphicsAccess => "graphics_access\0",
539 Privilege::GraphicsMap => "graphics_map\0",
540 Privilege::HyprlofsControl => "hyprlofs_control\0",
541 Privilege::IpcDacRead => "ipc_dac_read\0",
542 Privilege::IpcDacWrite => "ipc_dac_write\0",
543 Privilege::IpcOwner => "ipc_owner\0",
544 Privilege::NetAccess => "net_access\0",
545 Privilege::NetBindmlp => "net_bindmlp\0",
546 Privilege::NetIcmpaccess => "net_icmpaccess\0",
547 Privilege::NetMacAware => "net_mac_aware\0",
548 Privilege::NetMacImplicit => "net_mac_implicit\0",
549 Privilege::NetObservability => "net_observability\0",
550 Privilege::NetPrivaddr => "net_privaddr\0",
551 Privilege::NetRawaccess => "net_rawaccess\0",
552 Privilege::ProcAudit => "proc_audit\0",
553 Privilege::ProcChroot => "proc_chroot\0",
554 Privilege::ProcClockHighres => "proc_clock_highres\0",
555 Privilege::ProcExec => "proc_exec\0",
556 Privilege::ProcFork => "proc_fork\0",
557 Privilege::ProcInfo => "proc_info\0",
558 Privilege::ProcLockMemory => "proc_lock_memory\0",
559 Privilege::ProcMeminfo => "proc_meminfo\0",
560 Privilege::ProcOwner => "proc_owner\0",
561 Privilege::ProcPrioup => "proc_prioup\0",
562 Privilege::ProcPriocntl => "proc_priocntl\0",
563 Privilege::ProcSecflags => "proc_secflags\0",
564 Privilege::ProcSession => "proc_session\0",
565 Privilege::ProcSetid => "proc_setid\0",
566 Privilege::ProcTaskid => "proc_taskid\0",
567 Privilege::ProcZone => "proc_zone\0",
568 Privilege::SysAcct => "sys_acct\0",
569 Privilege::SysAdmin => "sys_admin\0",
570 Privilege::SysAudit => "sys_audit\0",
571 Privilege::SysConfig => "sys_config\0",
572 Privilege::SysDevices => "sys_devices\0",
573 Privilege::SysFsImport => "sys_fs_import\0",
574 Privilege::SysIpcConfig => "sys_ipc_config\0",
575 Privilege::SysLinkdir => "sys_linkdir\0",
576 Privilege::SysMount => "sys_mount\0",
577 Privilege::SysIptunConfig => "sys_iptun_config\0",
578 Privilege::SysDlConfig => "sys_dl_config\0",
579 Privilege::SysIpConfig => "sys_ip_config\0",
580 Privilege::SysNetConfig => "sys_net_config\0",
581 Privilege::SysNfs => "sys_nfs\0",
582 Privilege::SysPppConfig => "sys_ppp_config\0",
583 Privilege::SysResBind => "sys_res_bind\0",
584 Privilege::SysResConfig => "sys_res_config\0",
585 Privilege::SysResource => "sys_resource\0",
586 Privilege::SysSmb => "sys_smb\0",
587 Privilege::SysSuserCompat => "sys_suser_compat\0",
588 Privilege::SysTime => "sys_time\0",
589 Privilege::SysTransLabel => "sys_trans_label\0",
590 Privilege::VirtManage => "virt_manage\0",
591 Privilege::WinColormap => "win_colormap\0",
592 Privilege::WinConfig => "win_config\0",
593 Privilege::WinDacRead => "win_dac_read\0",
594 Privilege::WinDacWrite => "win_dac_write\0",
595 Privilege::WinDevices => "win_devices\0",
596 Privilege::WinDga => "win_dga\0",
597 Privilege::WinDowngradeSl => "win_downgrade_sl\0",
598 Privilege::WinFontpath => "win_fontpath\0",
599 Privilege::WinMacRead => "win_mac_read\0",
600 Privilege::WinMacWrite => "win_mac_write\0",
601 Privilege::WinSelection => "win_selection\0",
602 Privilege::WinUpgradeSl => "win_upgrade_sl\0",
603 Privilege::XvmControl => "xvm_control\0",
604 }
605 }
606
607 /// Get the correct mapping as a `*const c_char` from a `Privilege`
608 pub(crate) fn as_ptr(&self) -> *const c_char {
609 // This works because the lifetime of the mapped value is 'static.
610 // Otherwise we would have to ensure that the ptr does not outlive the value.
611 CStr::from_bytes_with_nul(self.as_str().as_bytes())
612 .expect("all variants should be nul terminated")
613 .as_ptr()
614 }
615}