|
| 1 | +// Copyright (c) 2024 Files Community |
| 2 | +// Licensed under the MIT License. See the LICENSE. |
| 3 | + |
| 4 | +using Windows.Win32.Foundation; |
| 5 | + |
| 6 | +namespace Files.App.Data.Contracts |
| 7 | +{ |
| 8 | + /// <summary> |
| 9 | + /// Provides service to manage storage security objects on NTFS and ReFS. |
| 10 | + /// </summary> |
| 11 | + public interface IStorageSecurityService |
| 12 | + { |
| 13 | + /// <summary> |
| 14 | + /// Get the owner of the object specified by the path. |
| 15 | + /// </summary> |
| 16 | + /// <param name="path">The file full path</param> |
| 17 | + /// <returns>The SID string of the owner</returns> |
| 18 | + string GetOwner(string path); |
| 19 | + |
| 20 | + /// <summary> |
| 21 | + /// Set the owner of the object specified by the path. |
| 22 | + /// </summary> |
| 23 | + /// <param name="path">The file full path</param> |
| 24 | + /// <param name="sid">The owner security identifier (SID)</param> |
| 25 | + /// <returns></returns> |
| 26 | + bool SetOwner(string path, string sid); |
| 27 | + |
| 28 | + /// <summary> |
| 29 | + /// Get information about an access control list (ACL). |
| 30 | + /// </summary> |
| 31 | + /// <param name="path"></param> |
| 32 | + /// <param name="isFolder"></param> |
| 33 | + /// <returns>If the function succeeds, an instance of AccessControlList; otherwise, null. To get extended error information, call GetLastError.</returns> |
| 34 | + WIN32_ERROR GetAccessControlList(string path, bool isFolder, out AccessControlList acl); |
| 35 | + |
| 36 | + /// <summary> |
| 37 | + /// Get access control list (ACL) initialized with default data. |
| 38 | + /// </summary> |
| 39 | + /// <param name="isFolder"></param> |
| 40 | + /// <param name="ownerSid"></param> |
| 41 | + /// <returns>If the function succeeds, an instance of AccessControlList; otherwise, null.</returns> |
| 42 | + AccessControlEntry InitializeDefaultAccessControlEntry(bool isFolder, string ownerSid); |
| 43 | + |
| 44 | + /// <summary> |
| 45 | + /// Add an default Access Control Entry (ACE) to the specified object's DACL |
| 46 | + /// </summary> |
| 47 | + /// <param name="path">The object's path to add an new ACE to its DACL</param> |
| 48 | + /// <param name="sid">Principal's SID</param> |
| 49 | + /// <returns> If the function succeeds, the return value is ERROR_SUCCESS. If the function fails, the return value is a nonzero error code defined in WinError.h.</returns> |
| 50 | + WIN32_ERROR AddAccessControlEntry(string szPath, string szSid); |
| 51 | + |
| 52 | + /// <summary> |
| 53 | + /// Add an Access Control Entry (ACE) from the specified object's DACL |
| 54 | + /// </summary> |
| 55 | + /// <param name="szPath">The object's path to remove an ACE from its DACL</param> |
| 56 | + /// <param name="dwAceIndex"></param> |
| 57 | + /// <returns></returns> |
| 58 | + WIN32_ERROR RemoveAccessControlEntry(string szPath, uint dwAceIndex); |
| 59 | + } |
| 60 | +} |
0 commit comments