forked from obhq/obliteration
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements sys_get_proc_type_info (obhq#794)
- Loading branch information
1 parent
1cbc0ef
commit 69a6ab2
Showing
4 changed files
with
201 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,64 @@ | ||
use std::fmt::{Display, Formatter}; | ||
|
||
/// Privilege identifier. | ||
/// | ||
/// See https://github.com/freebsd/freebsd-src/blob/release/9.1.0/sys/sys/priv.h for standard | ||
/// FreeBSD privileges. | ||
#[repr(transparent)] | ||
#[derive(Clone, Copy, PartialEq, Eq)] | ||
pub struct Privilege(i32); | ||
macro_rules! privileges { | ||
( | ||
$( #[$attr:meta] )* | ||
pub enum $name:ident { | ||
$( | ||
$( #[$var_attr:meta] )* | ||
$variant:ident = $value:expr, | ||
)* | ||
} | ||
) => { | ||
$( #[$attr] )* | ||
pub enum $name { | ||
$( | ||
$( #[$var_attr] )* | ||
#[allow(non_camel_case_types)] | ||
$variant = $value | ||
),* | ||
} | ||
|
||
impl Privilege { | ||
pub const MAXFILES: Self = Self(3); | ||
pub const PROC_SETLOGIN: Self = Self(161); | ||
pub const VFS_READ: Self = Self(310); | ||
pub const VFS_WRITE: Self = Self(311); | ||
pub const VFS_ADMIN: Self = Self(312); | ||
pub const VFS_EXEC: Self = Self(313); | ||
pub const VFS_LOOKUP: Self = Self(314); | ||
pub const SCE680: Self = Self(680); | ||
pub const SCE683: Self = Self(683); | ||
pub const SCE685: Self = Self(685); | ||
pub const SCE686: Self = Self(686); | ||
impl std::fmt::Display for $name { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match *self { | ||
$( | ||
Self::$variant => f.write_str(stringify!($variant)), | ||
)* | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
|
||
impl Display for Privilege { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
match *self { | ||
Self::MAXFILES => f.write_str("PRIV_MAXFILES"), | ||
Self::PROC_SETLOGIN => f.write_str("PRIV_PROC_SETLOGIN"), | ||
Self::VFS_READ => f.write_str("PRIV_VFS_READ"), | ||
Self::VFS_WRITE => f.write_str("PRIV_VFS_WRITE"), | ||
Self::VFS_ADMIN => f.write_str("PRIV_VFS_ADMIN"), | ||
Self::VFS_EXEC => f.write_str("PRIV_VFS_EXEC"), | ||
Self::VFS_LOOKUP => f.write_str("PRIV_VFS_LOOKUP"), | ||
Self::SCE680 => f.write_str("SCE680"), | ||
Self::SCE683 => f.write_str("SCE683"), | ||
Self::SCE685 => f.write_str("SCE685"), | ||
Self::SCE686 => f.write_str("SCE686"), | ||
v => v.0.fmt(f), | ||
} | ||
privileges! { | ||
/// Privilege identifier. | ||
/// | ||
/// See https://github.com/freebsd/freebsd-src/blob/release/9.1.0/sys/sys/priv.h for standard | ||
/// FreeBSD privileges. | ||
#[repr(i32)] | ||
#[derive(Clone, Copy, PartialEq, Eq)] | ||
pub enum Privilege { | ||
/// Exceed system open files limit. | ||
#[allow(unused)] | ||
MAXFILES = 3, | ||
/// Can call setlogin. | ||
PROC_SETLOGIN = 161, | ||
/// Override vnode DAC read perm. | ||
VFS_READ = 310, | ||
/// Override vnode DAC write perm. | ||
VFS_WRITE = 311, | ||
/// Override vnode DAC admin perm. | ||
VFS_ADMIN = 312, | ||
/// Override vnode DAC exec perm. | ||
VFS_EXEC = 313, | ||
/// Override vnode DAC lookup perm. | ||
VFS_LOOKUP = 314, | ||
/// Currently unknown. | ||
SCE680 = 680, | ||
/// Currently unknown. | ||
SCE683 = 683, | ||
/// Currently unknown. | ||
SCE685 = 685, | ||
/// Currently unknown. | ||
SCE686 = 686, | ||
} | ||
} |