smb_dtyp/security/
security_descriptor.rs1use binrw::prelude::*;
4
5use crate::binrw_util::prelude::*;
6
7use super::{ACL, SID};
8
9#[binrw::binrw]
11#[derive(Debug, PartialEq, Eq, Clone)]
12#[brw(little)]
13pub struct SecurityDescriptor {
14 #[bw(calc = PosMarker::default())]
15 #[br(temp)]
16 _sd_begin: PosMarker<()>,
17
18 #[bw(calc = 1)]
19 #[br(temp)]
20 #[br(assert(_revision == 1))]
21 _revision: u8,
22 pub sbz1: u8,
23 #[brw(assert(control.self_relative()))]
24 pub control: SecurityDescriptorControl,
25
26 #[bw(calc = PosMarker::default())]
27 #[br(temp)]
28 offset_owner: PosMarker<u32>,
29 #[bw(calc = PosMarker::default())]
30 #[br(temp)]
31 offset_group: PosMarker<u32>,
32 #[bw(calc = PosMarker::default())]
33 #[br(temp)]
34 offset_sacl: PosMarker<u32>,
35 #[bw(calc = PosMarker::default())]
36 #[br(temp)]
37 offset_dacl: PosMarker<u32>,
38
39 #[br(if(offset_owner.value != 0))]
40 #[bw(if(owner_sid.is_some()))]
41 #[bw(write_with = PosMarker::write_roff_b, args(&offset_owner, &_sd_begin))]
42 pub owner_sid: Option<SID>,
43
44 #[br(if(offset_group.value != 0))]
45 #[bw(if(group_sid.is_some()))]
46 #[bw(write_with = PosMarker::write_roff_b, args(&offset_group, &_sd_begin))]
47 pub group_sid: Option<SID>,
48
49 #[bw(assert(sacl.is_some() == control.sacl_present()))]
50 #[br(assert((offset_sacl.value != 0) == (control.sacl_present())))]
51 #[bw(if(sacl.is_some()))]
52 #[bw(write_with = PosMarker::write_roff_b, args(&offset_sacl, &_sd_begin))]
53 #[br(if(offset_sacl.value != 0))]
54 pub sacl: Option<ACL>,
55
56 #[bw(assert(dacl.is_some() == control.dacl_present()))]
57 #[br(assert((offset_dacl.value != 0) == control.dacl_present()))]
58 #[bw(if(dacl.is_some()))]
59 #[bw(write_with = PosMarker::write_roff_b, args(&offset_dacl, &_sd_begin))]
60 #[br(if(offset_dacl.value != 0))]
61 pub dacl: Option<ACL>,
62}
63
64#[smb_dtyp_derive::mbitfield]
65pub struct SecurityDescriptorControl {
66 pub owner_defaulted: bool,
67 pub group_defaulted: bool,
68 pub dacl_present: bool,
69 pub dacl_defaulted: bool,
70
71 pub sacl_present: bool,
72 pub sacl_defaulted: bool,
73 pub dacl_trusted: bool,
74 pub server_security: bool,
75
76 pub dacl_computed: bool,
77 pub sacl_computed: bool,
78 pub dacl_auto_inherited: bool,
79 pub sacl_auto_inherited: bool,
80
81 pub dacl_protected: bool,
82 pub sacl_protected: bool,
83 pub rm_control_valid: bool,
84 pub self_relative: bool,
85}