File indexing completed on 2025-01-05 04:35:35
0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0002 // SPDX-FileCopyrightText: 2020-2022 Harald Sitter <sitter@kde.org> 0003 0004 #pragma once 0005 0006 #include <memory> 0007 0008 #include <QObject> 0009 0010 #include "acccrtl.h" 0011 #include "ace.h" 0012 #include "debug.h" 0013 #include "winnt.h" 0014 0015 class ACEObject : public QObject 0016 { 0017 Q_OBJECT 0018 public: 0019 enum class Type { 0020 Deny = ACCESS_DENIED_ACE_TYPE, 0021 Allow = ACCESS_ALLOWED_ACE_TYPE, 0022 // Audit = SYSTEM_AUDIT_ACE_TYPE, 0023 // Alarm = SYSTEM_ALARM_ACE_TYPE, 0024 // MandatoryLabel = SYSTEM_MANDATORY_LABEL_ACE_TYPE, 0025 }; 0026 Q_ENUM(Type) 0027 0028 enum class Inheritance { 0029 // NB: order by amount of flags, a match for a|b|c should outscore a|b 0030 SubfoldersFiles = INHERIT_ONLY_ACE | CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE, 0031 Subfolders = INHERIT_ONLY_ACE | CONTAINER_INHERIT_ACE, 0032 Files = INHERIT_ONLY_ACE | OBJECT_INHERIT_ACE, 0033 FolderSubfoldersFiles = CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE, 0034 FolderSubfolders = CONTAINER_INHERIT_ACE, 0035 FolderFiles = OBJECT_INHERIT_ACE, 0036 None = 0x0, 0037 }; 0038 Q_ENUM(Inheritance) 0039 0040 explicit ACEObject(const std::shared_ptr<ACE> &ace, QObject *parent = nullptr); 0041 0042 std::shared_ptr<ACE> m_ace; 0043 0044 Q_PROPERTY(bool inherited MEMBER m_inherited CONSTANT) 0045 const bool m_inherited; 0046 0047 Q_PROPERTY(unsigned int type READ type WRITE setType NOTIFY typeChanged) 0048 unsigned int type() const; 0049 void setType(unsigned int type); 0050 Q_SIGNAL void typeChanged(); 0051 0052 Q_PROPERTY(int inheritance READ inheritance WRITE setInheritance NOTIFY inheritanceChanged) 0053 int inheritance() const; 0054 void setInheritance(int intInheritance); 0055 Q_SIGNAL void inheritanceChanged(); 0056 0057 Q_PROPERTY(bool noPropagate READ noPropagate WRITE setNoPropagate NOTIFY noPropagateChanged) 0058 bool noPropagate() const; 0059 void setNoPropagate(bool noPropagate); 0060 Q_SIGNAL void noPropagateChanged(); 0061 0062 #define MASK_PROPERTY(name, value) \ 0063 Q_PROPERTY(bool name READ name WRITE set_##name NOTIFY name##Changed) \ 0064 \ 0065 public: \ 0066 Q_SIGNAL void name##Changed(); \ 0067 [[nodiscard]] bool name() { return (m_ace->mask & (value)); } \ 0068 void set_##name(bool check) { \ 0069 fprintf_binary(stderr, m_ace->mask); \ 0070 m_ace->mask = check ? (m_ace->mask | (value)) : (m_ace->mask ^ (value)); \ 0071 fprintf_binary(stderr, m_ace->mask); \ 0072 Q_EMIT name##Changed(); \ 0073 } 0074 0075 MASK_PROPERTY(takeOwnership, WRITE_OWNER) 0076 MASK_PROPERTY(changePermissions, WRITE_DAC) 0077 MASK_PROPERTY(readPermissions, READ_CONTROL) 0078 MASK_PROPERTY(canDelete, DELETE) 0079 MASK_PROPERTY(canDeleteData, ACTRL_DIR_DELETE_CHILD) // not a thing for files 0080 MASK_PROPERTY(writeExtendedAttributes, ACTRL_FILE_WRITE_PROP) 0081 MASK_PROPERTY(writeAttributes, ACTRL_FILE_WRITE_ATTRIB) 0082 MASK_PROPERTY(appendData, ACTRL_FILE_APPEND) // aka ACTRL_DIR_CREATE_CHILD 0083 MASK_PROPERTY(writeData, ACTRL_FILE_WRITE) 0084 MASK_PROPERTY(readExtendedAttributes, ACTRL_FILE_READ_PROP) 0085 MASK_PROPERTY(readAttributes, ACTRL_FILE_READ_ATTRIB) 0086 MASK_PROPERTY(readData, ACTRL_FILE_READ) // aka ACTRL_DIR_LIS 0087 MASK_PROPERTY(execute, ACTRL_FILE_EXECUTE) // aka ACTRL_DIR_TRAVERSE 0088 0089 #undef MASK_PROPERTY 0090 0091 };