# Unix SMB/CIFS implementation. # Copyright © Catalyst IT 2023 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # """Fine-grained control over conditional ACE contents. This deliberately allows you to do broken things that SDDL doesn't. - token sequences that make no real sense - sequences that make sense which SDDL can't encode - strings that aren't proper utf-16 - etc. """ import struct from samba.dcerpc import security, conditional_ace as ca from samba.ndr import ndr_pack class Composite: token = ca.CONDITIONAL_ACE_TOKEN_COMPOSITE def __init__(self, *tokens): self.members = [] for t in tokens: self.members.append(dwim_one_token(t)) def __bytes__(self): v = [] for x in self.members: v.extend(bytes(x)) return (bytes([self.token]) + struct.pack(" 255 or min(self.value) < 0: raise ValueError("bytes do need to be bytes (0-255)") def __bytes__(self): header = struct.pack('