diff options
Diffstat (limited to 'fs/cifs/cifsacl.c')
-rw-r--r-- | fs/cifs/cifsacl.c | 91 |
1 files changed, 71 insertions, 20 deletions
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index 154cb8449b9b..14200bd45b30 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c | |||
@@ -97,7 +97,7 @@ int match_sid(struct cifs_sid *ctsid) | |||
97 | 97 | ||
98 | /* if the two SIDs (roughly equivalent to a UUID for a user or group) are | 98 | /* if the two SIDs (roughly equivalent to a UUID for a user or group) are |
99 | the same returns 1, if they do not match returns 0 */ | 99 | the same returns 1, if they do not match returns 0 */ |
100 | int compare_sids(struct cifs_sid *ctsid, struct cifs_sid *cwsid) | 100 | int compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid) |
101 | { | 101 | { |
102 | int i; | 102 | int i; |
103 | int num_subauth, num_sat, num_saw; | 103 | int num_subauth, num_sat, num_saw; |
@@ -129,28 +129,77 @@ int compare_sids(struct cifs_sid *ctsid, struct cifs_sid *cwsid) | |||
129 | return (1); /* sids compare/match */ | 129 | return (1); /* sids compare/match */ |
130 | } | 130 | } |
131 | 131 | ||
132 | void get_mode_from_acl(struct inode * inode, const char * path) | 132 | /* |
133 | change posix mode to reflect permissions | ||
134 | pmode is the existing mode (we only want to overwrite part of this | ||
135 | bits to set can be: S_IRWXU, S_IRWXG or S_IRWXO ie 00700 or 00070 or 00007 | ||
136 | */ | ||
137 | static void access_flags_to_mode(__u32 access_flags, umode_t * pmode, | ||
138 | umode_t bits_to_set) | ||
139 | { | ||
140 | |||
141 | #ifdef CONFIG_CIFS_DEBUG2 | ||
142 | cFYI(1, ("access flags 0x%x mode now 0x%x", access_flags, *pmode); | ||
143 | #endif | ||
144 | |||
145 | return; | ||
146 | } | ||
147 | |||
148 | /* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ | ||
149 | |||
150 | void acl_to_uid_mode(struct inode *inode, const char *path) | ||
133 | { | 151 | { |
152 | struct cifsFileInfo *open_file; | ||
153 | int unlock_file = FALSE; | ||
154 | int xid; | ||
155 | int rc = -EIO; | ||
156 | __u16 fid; | ||
157 | struct super_block *sb; | ||
158 | struct cifs_sb_info *cifs_sb; | ||
134 | 159 | ||
135 | cFYI(1, ("get mode from ACL for %s", path)); | 160 | cFYI(1, ("get mode from ACL for %s", path)); |
136 | 161 | ||
137 | if (inode == NULL) | 162 | if (inode == NULL) |
138 | return; | 163 | return; |
139 | 164 | ||
140 | /* find an open readable handle | 165 | xid = GetXid(); |
141 | if handle found | 166 | open_file = find_readable_file(CIFS_I(inode)); |
142 | lock handle | 167 | if (open_file) { |
143 | else open file | 168 | unlock_file = TRUE; |
144 | if no open file can not hurt to check if path is null | 169 | fid = open_file->netfid; |
145 | GetCIFSACL | 170 | } else { |
146 | for all ACEs in ACL { | 171 | int oplock = FALSE; |
147 | if U or G or O | 172 | /* open file */ |
148 | inode->i_mode = parse_ace(file_type, UG or O, ace->perms, inode->i_mode) | 173 | sb = inode->i_sb; |
149 | else continue | 174 | if (sb == NULL) { |
150 | } | 175 | FreeXid(xid); |
151 | if handle open close it | 176 | return; |
152 | else unlock handle */ | 177 | } |
178 | cifs_sb = CIFS_SB(sb); | ||
179 | rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN, | ||
180 | GENERIC_READ, 0, &fid, &oplock, NULL, | ||
181 | cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & | ||
182 | CIFS_MOUNT_MAP_SPECIAL_CHR); | ||
183 | if (rc != 0) { | ||
184 | cERROR(1, ("Unable to open file to get ACL")); | ||
185 | FreeXid(xid); | ||
186 | return; | ||
187 | } | ||
188 | } | ||
189 | |||
190 | /* rc = CIFSSMBGetCIFSACL(xid, cifs_sb->tcon, fid, pntsd, acllen, | ||
191 | ACL_TYPE_ACCESS); */ | ||
192 | |||
193 | if (unlock_file == TRUE) | ||
194 | atomic_dec(&open_file->wrtPending); | ||
195 | else | ||
196 | CIFSSMBClose(xid, cifs_sb->tcon, fid); | ||
197 | |||
198 | /* parse ACEs e.g. | ||
199 | rc = parse_sec_desc(pntsd, acllen, inode); | ||
200 | */ | ||
153 | 201 | ||
202 | FreeXid(xid); | ||
154 | return; | 203 | return; |
155 | } | 204 | } |
156 | 205 | ||
@@ -193,7 +242,8 @@ static void parse_ace(struct cifs_ace *pace, char *end_of_acl) | |||
193 | 242 | ||
194 | 243 | ||
195 | static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl, | 244 | static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl, |
196 | struct cifs_sid *pownersid, struct cifs_sid *pgrpsid) | 245 | struct cifs_sid *pownersid, struct cifs_sid *pgrpsid |
246 | struct inode *inode) | ||
197 | { | 247 | { |
198 | int i; | 248 | int i; |
199 | int num_aces = 0; | 249 | int num_aces = 0; |
@@ -281,7 +331,8 @@ static int parse_sid(struct cifs_sid *psid, char *end_of_acl) | |||
281 | 331 | ||
282 | 332 | ||
283 | /* Convert CIFS ACL to POSIX form */ | 333 | /* Convert CIFS ACL to POSIX form */ |
284 | int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len) | 334 | static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len, |
335 | struct inode *inode) | ||
285 | { | 336 | { |
286 | int rc; | 337 | int rc; |
287 | struct cifs_sid *owner_sid_ptr, *group_sid_ptr; | 338 | struct cifs_sid *owner_sid_ptr, *group_sid_ptr; |
@@ -310,14 +361,14 @@ int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len) | |||
310 | if (rc) | 361 | if (rc) |
311 | return rc; | 362 | return rc; |
312 | 363 | ||
313 | parse_dacl(dacl_ptr, end_of_acl, owner_sid_ptr, group_sid_ptr); | 364 | parse_dacl(dacl_ptr, end_of_acl, owner_sid_ptr, group_sid_ptr, inode); |
314 | 365 | ||
315 | /* cifscred->uid = owner_sid_ptr->rid; | 366 | /* cifscred->uid = owner_sid_ptr->rid; |
316 | cifscred->gid = group_sid_ptr->rid; | 367 | cifscred->gid = group_sid_ptr->rid; |
317 | memcpy((void *)(&(cifscred->osid)), (void *)owner_sid_ptr, | 368 | memcpy((void *)(&(cifscred->osid)), (void *)owner_sid_ptr, |
318 | sizeof (struct cifs_sid)); | 369 | sizeof(struct cifs_sid)); |
319 | memcpy((void *)(&(cifscred->gsid)), (void *)group_sid_ptr, | 370 | memcpy((void *)(&(cifscred->gsid)), (void *)group_sid_ptr, |
320 | sizeof (struct cifs_sid)); */ | 371 | sizeof(struct cifs_sid)); */ |
321 | 372 | ||
322 | 373 | ||
323 | return (0); | 374 | return (0); |