Example #1
0
        /// <inheritdoc/>
        public override NtStatus SetFileSecurity(string path, FileSystemSecurity security, AccessControlSections sections, LVFSContextInfo info)
        {
            if (ControlsFile(path))
            {
                FileSystemSecurity actualSecurity;
                if (info.IsDirectory)
                {
                    actualSecurity = Directory.GetAccessControl(ConvertPath(path), sections);
                }
                else
                {
                    actualSecurity = File.GetAccessControl(ConvertPath(path), sections);
                }

                var desiredSddlForm = security.GetSecurityDescriptorSddlForm(sections);
                actualSecurity.SetSecurityDescriptorSddlForm(desiredSddlForm, sections);

                if (info.IsDirectory)
                {
                    Directory.SetAccessControl(ConvertPath(path), actualSecurity as DirectorySecurity);
                }
                else
                {
                    File.SetAccessControl(ConvertPath(path), actualSecurity as FileSecurity);
                }
                return(DokanResult.Success);
            }
            else
            {
                return(PredecessorSetFileSecurity(path, security, sections, info));
            }
        }
Example #2
0
        internal static void SetRemoteWindowsAccessControlList(SshClient ssh, string path, FileSystemSecurity accessControlList)
        {
            var command = ssh.RunCommand(string.Format("setfattr -n user.WinACL -v '{0}' $'{1}'", accessControlList.GetSecurityDescriptorSddlForm(AccessControlSections.All), path));

            if (command.ExitStatus != 0)
            {
                throw new RemoteCommandException(string.Format("setfattr failed with exit code {0} while processing {1}", command.ExitStatus, path));
            }
        }
Example #3
0
 public static string AsString(this FileSystemSecurity security) => security.GetSecurityDescriptorSddlForm(AccessControlSections.Access | AccessControlSections.Owner | AccessControlSections.Group);
 public virtual string GetSecurityDescriptorSddlForm(AccessControlSections includeSections)
 {
     return(_fileSystemSecurity.GetSecurityDescriptorSddlForm(includeSections));
 }