Exemple #1
0
        private void ParseAcl(string acl)
        {
            //and example of a real acl string:
            //user::rw-,user:6b157067-78b0-4478-ba7b-ade5c66f1a9a:rwx,group::r--,mask::rwx,other::---

            Acl.Clear();

            if (acl == null)
            {
                return;
            }

            foreach (string textForm in acl.Split(','))
            {
                bool isDefault = textForm.StartsWith("default:");

                string processForm = isDefault ? textForm.Substring(8) : textForm;

                var entry = new AclEntry(processForm);

                if (entry.ObjectId == null)
                {
                    //special entry
                    if (entry.Type == "user")
                    {
                        OwningUserPermissions = entry;
                    }
                    else if (entry.Type == "group")
                    {
                        OwningGroupPermissions = entry;
                    }

                    //ignore other special objects as they're not important
                }
                else
                {
                    //push ID'd objects to the rest of the ACL
                    if (isDefault)
                    {
                        DefaultAcl.Add(entry);
                    }
                    else
                    {
                        Acl.Add(entry);
                    }
                }
            }
        }
Exemple #2
0
        public EditableAcl(AccessControl acl)
        {
            OwnerUser           = new EditableAclEntry(acl.OwningUserPermissions);
            OwnerGroup          = new EditableAclEntry(acl.OwningGroupPermissions);
            OwnerUser.Identity  = acl.OwnerUserId;
            OwnerGroup.Identity = acl.OwnerGroupId;

            foreach (AclEntry acle in acl.Acl)
            {
                Acl.Add(new EditableAclEntry(acle));
            }

            foreach (AclEntry acle in acl.DefaultAcl)
            {
                DefaultAcl.Add(new EditableAclEntry(acle));
            }
        }