aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/cifsacl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/cifsacl.c')
-rw-r--r--fs/cifs/cifsacl.c48
1 files changed, 28 insertions, 20 deletions
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index c9b4792ae825..c6ebea088ac7 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -560,7 +560,7 @@ static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
560 struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); 560 struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
561 561
562 if (IS_ERR(tlink)) 562 if (IS_ERR(tlink))
563 return NULL; 563 return ERR_CAST(tlink);
564 564
565 xid = GetXid(); 565 xid = GetXid();
566 rc = CIFSSMBGetCIFSACL(xid, tlink_tcon(tlink), fid, &pntsd, pacllen); 566 rc = CIFSSMBGetCIFSACL(xid, tlink_tcon(tlink), fid, &pntsd, pacllen);
@@ -568,7 +568,9 @@ static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
568 568
569 cifs_put_tlink(tlink); 569 cifs_put_tlink(tlink);
570 570
571 cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen); 571 cFYI(1, "%s: rc = %d ACL len %d", __func__, rc, *pacllen);
572 if (rc)
573 return ERR_PTR(rc);
572 return pntsd; 574 return pntsd;
573} 575}
574 576
@@ -583,7 +585,7 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,
583 struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); 585 struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
584 586
585 if (IS_ERR(tlink)) 587 if (IS_ERR(tlink))
586 return NULL; 588 return ERR_CAST(tlink);
587 589
588 tcon = tlink_tcon(tlink); 590 tcon = tlink_tcon(tlink);
589 xid = GetXid(); 591 xid = GetXid();
@@ -591,23 +593,22 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,
591 rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, READ_CONTROL, 0, 593 rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, READ_CONTROL, 0,
592 &fid, &oplock, NULL, cifs_sb->local_nls, 594 &fid, &oplock, NULL, cifs_sb->local_nls,
593 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 595 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
594 if (rc) { 596 if (!rc) {
595 cERROR(1, "Unable to open file to get ACL"); 597 rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen);
596 goto out; 598 CIFSSMBClose(xid, tcon, fid);
597 } 599 }
598 600
599 rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen);
600 cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen);
601
602 CIFSSMBClose(xid, tcon, fid);
603 out:
604 cifs_put_tlink(tlink); 601 cifs_put_tlink(tlink);
605 FreeXid(xid); 602 FreeXid(xid);
603
604 cFYI(1, "%s: rc = %d ACL len %d", __func__, rc, *pacllen);
605 if (rc)
606 return ERR_PTR(rc);
606 return pntsd; 607 return pntsd;
607} 608}
608 609
609/* Retrieve an ACL from the server */ 610/* Retrieve an ACL from the server */
610static struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb, 611struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb,
611 struct inode *inode, const char *path, 612 struct inode *inode, const char *path,
612 u32 *pacllen) 613 u32 *pacllen)
613{ 614{
@@ -695,7 +696,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
695} 696}
696 697
697/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ 698/* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */
698void 699int
699cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, 700cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
700 struct inode *inode, const char *path, const __u16 *pfid) 701 struct inode *inode, const char *path, const __u16 *pfid)
701{ 702{
@@ -711,17 +712,21 @@ cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
711 pntsd = get_cifs_acl(cifs_sb, inode, path, &acllen); 712 pntsd = get_cifs_acl(cifs_sb, inode, path, &acllen);
712 713
713 /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */ 714 /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */
714 if (pntsd) 715 if (IS_ERR(pntsd)) {
716 rc = PTR_ERR(pntsd);
717 cERROR(1, "%s: error %d getting sec desc", __func__, rc);
718 } else {
715 rc = parse_sec_desc(pntsd, acllen, fattr); 719 rc = parse_sec_desc(pntsd, acllen, fattr);
716 if (rc) 720 kfree(pntsd);
717 cFYI(1, "parse sec desc failed rc = %d", rc); 721 if (rc)
722 cERROR(1, "parse sec desc failed rc = %d", rc);
723 }
718 724
719 kfree(pntsd); 725 return rc;
720 return;
721} 726}
722 727
723/* Convert mode bits to an ACL so we can update the ACL on the server */ 728/* Convert mode bits to an ACL so we can update the ACL on the server */
724int mode_to_acl(struct inode *inode, const char *path, __u64 nmode) 729int mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode)
725{ 730{
726 int rc = 0; 731 int rc = 0;
727 __u32 secdesclen = 0; 732 __u32 secdesclen = 0;
@@ -736,7 +741,10 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode)
736 /* Add three ACEs for owner, group, everyone getting rid of 741 /* Add three ACEs for owner, group, everyone getting rid of
737 other ACEs as chmod disables ACEs and set the security descriptor */ 742 other ACEs as chmod disables ACEs and set the security descriptor */
738 743
739 if (pntsd) { 744 if (IS_ERR(pntsd)) {
745 rc = PTR_ERR(pntsd);
746 cERROR(1, "%s: error %d getting sec desc", __func__, rc);
747 } else {
740 /* allocate memory for the smb header, 748 /* allocate memory for the smb header,
741 set security descriptor request security descriptor 749 set security descriptor request security descriptor
742 parameters, and secuirty descriptor itself */ 750 parameters, and secuirty descriptor itself */