Changeset 988 for vendor/current/libcli/security/secace.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/libcli/security/secace.c
r740 r988 68 68 69 69 t->trustee = *sid; 70 }71 72 /*******************************************************************73 adds new SID with its permissions to ACE list74 ********************************************************************/75 76 NTSTATUS sec_ace_add_sid(TALLOC_CTX *ctx, struct security_ace **pp_new, struct security_ace *old, unsigned *num, const struct dom_sid *sid, uint32_t mask)77 {78 unsigned int i = 0;79 80 if (!ctx || !pp_new || !old || !sid || !num) return NT_STATUS_INVALID_PARAMETER;81 82 *num += 1;83 84 if((pp_new[0] = talloc_zero_array(ctx, struct security_ace, *num )) == 0)85 return NT_STATUS_NO_MEMORY;86 87 for (i = 0; i < *num - 1; i ++)88 sec_ace_copy(&(*pp_new)[i], &old[i]);89 90 (*pp_new)[i].type = SEC_ACE_TYPE_ACCESS_ALLOWED;91 (*pp_new)[i].flags = 0;92 (*pp_new)[i].size = SEC_ACE_HEADER_SIZE + ndr_size_dom_sid(sid, 0);93 (*pp_new)[i].access_mask = mask;94 (*pp_new)[i].trustee = *sid;95 return NT_STATUS_OK;96 }97 98 /*******************************************************************99 modify SID's permissions at ACL100 ********************************************************************/101 102 NTSTATUS sec_ace_mod_sid(struct security_ace *ace, size_t num, const struct dom_sid *sid, uint32_t mask)103 {104 unsigned int i = 0;105 106 if (!ace || !sid) return NT_STATUS_INVALID_PARAMETER;107 108 for (i = 0; i < num; i ++) {109 if (dom_sid_equal(&ace[i].trustee, sid)) {110 ace[i].access_mask = mask;111 return NT_STATUS_OK;112 }113 }114 return NT_STATUS_NOT_FOUND;115 }116 117 /*******************************************************************118 delete SID from ACL119 ********************************************************************/120 121 NTSTATUS sec_ace_del_sid(TALLOC_CTX *ctx, struct security_ace **pp_new, struct security_ace *old, uint32_t *num, const struct dom_sid *sid)122 {123 unsigned int i = 0;124 unsigned int n_del = 0;125 126 if (!ctx || !pp_new || !old || !sid || !num) return NT_STATUS_INVALID_PARAMETER;127 128 if (*num) {129 if((pp_new[0] = talloc_zero_array(ctx, struct security_ace, *num )) == 0)130 return NT_STATUS_NO_MEMORY;131 } else {132 pp_new[0] = NULL;133 }134 135 for (i = 0; i < *num; i ++) {136 if (!dom_sid_equal(&old[i].trustee, sid))137 sec_ace_copy(&(*pp_new)[i], &old[i]);138 else139 n_del ++;140 }141 if (n_del == 0)142 return NT_STATUS_NOT_FOUND;143 else {144 *num -= n_del;145 return NT_STATUS_OK;146 }147 }148 149 /*******************************************************************150 Compares two struct security_ace structures151 ********************************************************************/152 153 bool sec_ace_equal(const struct security_ace *s1, const struct security_ace *s2)154 {155 /* Trivial case */156 157 if (!s1 && !s2) {158 return true;159 }160 161 if (!s1 || !s2) {162 return false;163 }164 165 /* Check top level stuff */166 167 if (s1->type != s2->type || s1->flags != s2->flags ||168 s1->access_mask != s2->access_mask) {169 return false;170 }171 172 /* Check SID */173 174 if (!dom_sid_equal(&s1->trustee, &s2->trustee)) {175 return false;176 }177 178 return true;179 70 } 180 71
Note:
See TracChangeset
for help on using the changeset viewer.