diff options
author | Paul Mackerras <paulus@samba.org> | 2008-03-13 00:26:33 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-03-13 00:26:33 -0400 |
commit | bed04a4413376265746053be2a9cfbfc80c98ec9 (patch) | |
tree | 8f582294a655f70496cd08aedeb86de31dbad140 /fs/cifs/cifsacl.c | |
parent | e37c772e36a7943b2e0bd8f48312e78474c0df15 (diff) | |
parent | c463be3520065ef8c05e3cbdf946c69604e91ceb (diff) |
Merge branch 'linux-2.6'
Diffstat (limited to 'fs/cifs/cifsacl.c')
-rw-r--r-- | fs/cifs/cifsacl.c | 57 |
1 files changed, 15 insertions, 42 deletions
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index a7035bd18e4e..f93932c21772 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c | |||
@@ -46,8 +46,7 @@ static struct cifs_wksid wksidarr[NUM_WK_SIDS] = { | |||
46 | static const struct cifs_sid sid_everyone = { | 46 | static const struct cifs_sid sid_everyone = { |
47 | 1, 1, {0, 0, 0, 0, 0, 1}, {0} }; | 47 | 1, 1, {0, 0, 0, 0, 0, 1}, {0} }; |
48 | /* group users */ | 48 | /* group users */ |
49 | static const struct cifs_sid sid_user = | 49 | static const struct cifs_sid sid_user = {1, 2 , {0, 0, 0, 0, 0, 5}, {} }; |
50 | {1, 2 , {0, 0, 0, 0, 0, 5}, {} }; | ||
51 | 50 | ||
52 | 51 | ||
53 | int match_sid(struct cifs_sid *ctsid) | 52 | int match_sid(struct cifs_sid *ctsid) |
@@ -195,9 +194,9 @@ static void access_flags_to_mode(__le32 ace_flags, int type, umode_t *pmode, | |||
195 | /* For deny ACEs we change the mask so that subsequent allow access | 194 | /* For deny ACEs we change the mask so that subsequent allow access |
196 | control entries do not turn on the bits we are denying */ | 195 | control entries do not turn on the bits we are denying */ |
197 | if (type == ACCESS_DENIED) { | 196 | if (type == ACCESS_DENIED) { |
198 | if (flags & GENERIC_ALL) { | 197 | if (flags & GENERIC_ALL) |
199 | *pbits_to_set &= ~S_IRWXUGO; | 198 | *pbits_to_set &= ~S_IRWXUGO; |
200 | } | 199 | |
201 | if ((flags & GENERIC_WRITE) || | 200 | if ((flags & GENERIC_WRITE) || |
202 | ((flags & FILE_WRITE_RIGHTS) == FILE_WRITE_RIGHTS)) | 201 | ((flags & FILE_WRITE_RIGHTS) == FILE_WRITE_RIGHTS)) |
203 | *pbits_to_set &= ~S_IWUGO; | 202 | *pbits_to_set &= ~S_IWUGO; |
@@ -216,9 +215,7 @@ static void access_flags_to_mode(__le32 ace_flags, int type, umode_t *pmode, | |||
216 | 215 | ||
217 | if (flags & GENERIC_ALL) { | 216 | if (flags & GENERIC_ALL) { |
218 | *pmode |= (S_IRWXUGO & (*pbits_to_set)); | 217 | *pmode |= (S_IRWXUGO & (*pbits_to_set)); |
219 | #ifdef CONFIG_CIFS_DEBUG2 | 218 | cFYI(DBG2, ("all perms")); |
220 | cFYI(1, ("all perms")); | ||
221 | #endif | ||
222 | return; | 219 | return; |
223 | } | 220 | } |
224 | if ((flags & GENERIC_WRITE) || | 221 | if ((flags & GENERIC_WRITE) || |
@@ -231,9 +228,7 @@ static void access_flags_to_mode(__le32 ace_flags, int type, umode_t *pmode, | |||
231 | ((flags & FILE_EXEC_RIGHTS) == FILE_EXEC_RIGHTS)) | 228 | ((flags & FILE_EXEC_RIGHTS) == FILE_EXEC_RIGHTS)) |
232 | *pmode |= (S_IXUGO & (*pbits_to_set)); | 229 | *pmode |= (S_IXUGO & (*pbits_to_set)); |
233 | 230 | ||
234 | #ifdef CONFIG_CIFS_DEBUG2 | 231 | cFYI(DBG2, ("access flags 0x%x mode now 0x%x", flags, *pmode)); |
235 | cFYI(1, ("access flags 0x%x mode now 0x%x", flags, *pmode)); | ||
236 | #endif | ||
237 | return; | 232 | return; |
238 | } | 233 | } |
239 | 234 | ||
@@ -262,9 +257,7 @@ static void mode_to_access_flags(umode_t mode, umode_t bits_to_use, | |||
262 | if (mode & S_IXUGO) | 257 | if (mode & S_IXUGO) |
263 | *pace_flags |= SET_FILE_EXEC_RIGHTS; | 258 | *pace_flags |= SET_FILE_EXEC_RIGHTS; |
264 | 259 | ||
265 | #ifdef CONFIG_CIFS_DEBUG2 | 260 | cFYI(DBG2, ("mode: 0x%x, access flags now 0x%x", mode, *pace_flags)); |
266 | cFYI(1, ("mode: 0x%x, access flags now 0x%x", mode, *pace_flags)); | ||
267 | #endif | ||
268 | return; | 261 | return; |
269 | } | 262 | } |
270 | 263 | ||
@@ -358,11 +351,9 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl, | |||
358 | return; | 351 | return; |
359 | } | 352 | } |
360 | 353 | ||
361 | #ifdef CONFIG_CIFS_DEBUG2 | 354 | cFYI(DBG2, ("DACL revision %d size %d num aces %d", |
362 | cFYI(1, ("DACL revision %d size %d num aces %d", | ||
363 | le16_to_cpu(pdacl->revision), le16_to_cpu(pdacl->size), | 355 | le16_to_cpu(pdacl->revision), le16_to_cpu(pdacl->size), |
364 | le32_to_cpu(pdacl->num_aces))); | 356 | le32_to_cpu(pdacl->num_aces))); |
365 | #endif | ||
366 | 357 | ||
367 | /* reset rwx permissions for user/group/other. | 358 | /* reset rwx permissions for user/group/other. |
368 | Also, if num_aces is 0 i.e. DACL has no ACEs, | 359 | Also, if num_aces is 0 i.e. DACL has no ACEs, |
@@ -381,10 +372,6 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl, | |||
381 | ppace = kmalloc(num_aces * sizeof(struct cifs_ace *), | 372 | ppace = kmalloc(num_aces * sizeof(struct cifs_ace *), |
382 | GFP_KERNEL); | 373 | GFP_KERNEL); |
383 | 374 | ||
384 | /* cifscred->cecount = pdacl->num_aces; | ||
385 | cifscred->aces = kmalloc(num_aces * | ||
386 | sizeof(struct cifs_ace *), GFP_KERNEL);*/ | ||
387 | |||
388 | for (i = 0; i < num_aces; ++i) { | 375 | for (i = 0; i < num_aces; ++i) { |
389 | ppace[i] = (struct cifs_ace *) (acl_base + acl_size); | 376 | ppace[i] = (struct cifs_ace *) (acl_base + acl_size); |
390 | #ifdef CONFIG_CIFS_DEBUG2 | 377 | #ifdef CONFIG_CIFS_DEBUG2 |
@@ -437,7 +424,7 @@ static int set_chmod_dacl(struct cifs_acl *pndacl, struct cifs_sid *pownersid, | |||
437 | &sid_everyone, nmode, S_IRWXO); | 424 | &sid_everyone, nmode, S_IRWXO); |
438 | 425 | ||
439 | pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl)); | 426 | pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl)); |
440 | pndacl->num_aces = 3; | 427 | pndacl->num_aces = cpu_to_le32(3); |
441 | 428 | ||
442 | return (0); | 429 | return (0); |
443 | } | 430 | } |
@@ -495,13 +482,11 @@ static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len, | |||
495 | le32_to_cpu(pntsd->gsidoffset)); | 482 | le32_to_cpu(pntsd->gsidoffset)); |
496 | dacloffset = le32_to_cpu(pntsd->dacloffset); | 483 | dacloffset = le32_to_cpu(pntsd->dacloffset); |
497 | dacl_ptr = (struct cifs_acl *)((char *)pntsd + dacloffset); | 484 | dacl_ptr = (struct cifs_acl *)((char *)pntsd + dacloffset); |
498 | #ifdef CONFIG_CIFS_DEBUG2 | 485 | cFYI(DBG2, ("revision %d type 0x%x ooffset 0x%x goffset 0x%x " |
499 | cFYI(1, ("revision %d type 0x%x ooffset 0x%x goffset 0x%x " | ||
500 | "sacloffset 0x%x dacloffset 0x%x", | 486 | "sacloffset 0x%x dacloffset 0x%x", |
501 | pntsd->revision, pntsd->type, le32_to_cpu(pntsd->osidoffset), | 487 | pntsd->revision, pntsd->type, le32_to_cpu(pntsd->osidoffset), |
502 | le32_to_cpu(pntsd->gsidoffset), | 488 | le32_to_cpu(pntsd->gsidoffset), |
503 | le32_to_cpu(pntsd->sacloffset), dacloffset)); | 489 | le32_to_cpu(pntsd->sacloffset), dacloffset)); |
504 | #endif | ||
505 | /* cifs_dump_mem("owner_sid: ", owner_sid_ptr, 64); */ | 490 | /* cifs_dump_mem("owner_sid: ", owner_sid_ptr, 64); */ |
506 | rc = parse_sid(owner_sid_ptr, end_of_acl); | 491 | rc = parse_sid(owner_sid_ptr, end_of_acl); |
507 | if (rc) | 492 | if (rc) |
@@ -636,9 +621,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, | |||
636 | struct super_block *sb; | 621 | struct super_block *sb; |
637 | struct cifs_sb_info *cifs_sb; | 622 | struct cifs_sb_info *cifs_sb; |
638 | 623 | ||
639 | #ifdef CONFIG_CIFS_DEBUG2 | 624 | cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode)); |
640 | cFYI(1, ("set ACL for %s from mode 0x%x", path, inode->i_mode)); | ||
641 | #endif | ||
642 | 625 | ||
643 | if (!inode) | 626 | if (!inode) |
644 | return (rc); | 627 | return (rc); |
@@ -669,9 +652,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, | |||
669 | } | 652 | } |
670 | 653 | ||
671 | rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen); | 654 | rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen); |
672 | #ifdef CONFIG_CIFS_DEBUG2 | 655 | cFYI(DBG2, ("SetCIFSACL rc = %d", rc)); |
673 | cFYI(1, ("SetCIFSACL rc = %d", rc)); | ||
674 | #endif | ||
675 | if (unlock_file == TRUE) | 656 | if (unlock_file == TRUE) |
676 | atomic_dec(&open_file->wrtPending); | 657 | atomic_dec(&open_file->wrtPending); |
677 | else | 658 | else |
@@ -689,9 +670,7 @@ void acl_to_uid_mode(struct inode *inode, const char *path) | |||
689 | u32 acllen = 0; | 670 | u32 acllen = 0; |
690 | int rc = 0; | 671 | int rc = 0; |
691 | 672 | ||
692 | #ifdef CONFIG_CIFS_DEBUG2 | 673 | cFYI(DBG2, ("converting ACL to mode for %s", path)); |
693 | cFYI(1, ("converting ACL to mode for %s", path)); | ||
694 | #endif | ||
695 | pntsd = get_cifs_acl(&acllen, inode, path); | 674 | pntsd = get_cifs_acl(&acllen, inode, path); |
696 | 675 | ||
697 | /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */ | 676 | /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */ |
@@ -712,9 +691,7 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode) | |||
712 | struct cifs_ntsd *pntsd = NULL; /* acl obtained from server */ | 691 | struct cifs_ntsd *pntsd = NULL; /* acl obtained from server */ |
713 | struct cifs_ntsd *pnntsd = NULL; /* modified acl to be sent to server */ | 692 | struct cifs_ntsd *pnntsd = NULL; /* modified acl to be sent to server */ |
714 | 693 | ||
715 | #ifdef CONFIG_CIFS_DEBUG2 | 694 | cFYI(DBG2, ("set ACL from mode for %s", path)); |
716 | cFYI(1, ("set ACL from mode for %s", path)); | ||
717 | #endif | ||
718 | 695 | ||
719 | /* Get the security descriptor */ | 696 | /* Get the security descriptor */ |
720 | pntsd = get_cifs_acl(&acllen, inode, path); | 697 | pntsd = get_cifs_acl(&acllen, inode, path); |
@@ -736,16 +713,12 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode) | |||
736 | 713 | ||
737 | rc = build_sec_desc(pntsd, pnntsd, acllen, inode, nmode); | 714 | rc = build_sec_desc(pntsd, pnntsd, acllen, inode, nmode); |
738 | 715 | ||
739 | #ifdef CONFIG_CIFS_DEBUG2 | 716 | cFYI(DBG2, ("build_sec_desc rc: %d", rc)); |
740 | cFYI(1, ("build_sec_desc rc: %d", rc)); | ||
741 | #endif | ||
742 | 717 | ||
743 | if (!rc) { | 718 | if (!rc) { |
744 | /* Set the security descriptor */ | 719 | /* Set the security descriptor */ |
745 | rc = set_cifs_acl(pnntsd, acllen, inode, path); | 720 | rc = set_cifs_acl(pnntsd, acllen, inode, path); |
746 | #ifdef CONFIG_CIFS_DEBUG2 | 721 | cFYI(DBG2, ("set_cifs_acl rc: %d", rc)); |
747 | cFYI(1, ("set_cifs_acl rc: %d", rc)); | ||
748 | #endif | ||
749 | } | 722 | } |
750 | 723 | ||
751 | kfree(pnntsd); | 724 | kfree(pnntsd); |