mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-25 10:19:47 +00:00
cifs: Use smb 2 - 3 and cifsacl mount options setacl function
Added set acl function. Very similar to set cifs acl function for smb1. Signed-off-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com> Signed-off-by: Steve French <smfrench@gmail.com> Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
This commit is contained in:
parent
dac953401c
commit
366ed846df
1 changed files with 60 additions and 3 deletions
|
@ -1370,6 +1370,63 @@ get_smb2_acl_by_path(struct cifs_sb_info *cifs_sb,
|
||||||
return pntsd;
|
return pntsd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_CIFS_ACL
|
||||||
|
static int
|
||||||
|
set_smb2_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
|
||||||
|
struct inode *inode, const char *path, int aclflag)
|
||||||
|
{
|
||||||
|
u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
|
||||||
|
unsigned int xid;
|
||||||
|
int rc, access_flags = 0;
|
||||||
|
struct cifs_tcon *tcon;
|
||||||
|
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
|
||||||
|
struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
|
||||||
|
struct cifs_fid fid;
|
||||||
|
struct cifs_open_parms oparms;
|
||||||
|
__le16 *utf16_path;
|
||||||
|
|
||||||
|
cifs_dbg(FYI, "set smb3 acl for path %s\n", path);
|
||||||
|
if (IS_ERR(tlink))
|
||||||
|
return PTR_ERR(tlink);
|
||||||
|
|
||||||
|
tcon = tlink_tcon(tlink);
|
||||||
|
xid = get_xid();
|
||||||
|
|
||||||
|
if (backup_cred(cifs_sb))
|
||||||
|
oparms.create_options = CREATE_OPEN_BACKUP_INTENT;
|
||||||
|
else
|
||||||
|
oparms.create_options = 0;
|
||||||
|
|
||||||
|
if (aclflag == CIFS_ACL_OWNER || aclflag == CIFS_ACL_GROUP)
|
||||||
|
access_flags = WRITE_OWNER;
|
||||||
|
else
|
||||||
|
access_flags = WRITE_DAC;
|
||||||
|
|
||||||
|
utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
|
||||||
|
if (!utf16_path)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
oparms.tcon = tcon;
|
||||||
|
oparms.desired_access = access_flags;
|
||||||
|
oparms.disposition = FILE_OPEN;
|
||||||
|
oparms.path = path;
|
||||||
|
oparms.fid = &fid;
|
||||||
|
oparms.reconnect = false;
|
||||||
|
|
||||||
|
rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL);
|
||||||
|
kfree(utf16_path);
|
||||||
|
if (!rc) {
|
||||||
|
rc = SMB2_set_acl(xid, tlink_tcon(tlink), fid.persistent_fid,
|
||||||
|
fid.volatile_fid, pnntsd, acllen, aclflag);
|
||||||
|
SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
|
||||||
|
}
|
||||||
|
|
||||||
|
cifs_put_tlink(tlink);
|
||||||
|
free_xid(xid);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
#endif /* CIFS_ACL */
|
||||||
|
|
||||||
/* Retrieve an ACL from the server */
|
/* Retrieve an ACL from the server */
|
||||||
static struct cifs_ntsd *
|
static struct cifs_ntsd *
|
||||||
get_smb2_acl(struct cifs_sb_info *cifs_sb,
|
get_smb2_acl(struct cifs_sb_info *cifs_sb,
|
||||||
|
@ -2498,7 +2555,7 @@ struct smb_version_operations smb20_operations = {
|
||||||
#ifdef CONFIG_CIFS_ACL
|
#ifdef CONFIG_CIFS_ACL
|
||||||
.get_acl = get_smb2_acl,
|
.get_acl = get_smb2_acl,
|
||||||
.get_acl_by_fid = get_smb2_acl_by_fid,
|
.get_acl_by_fid = get_smb2_acl_by_fid,
|
||||||
/* .set_acl = set_smb3_acl, */
|
.set_acl = set_smb2_acl,
|
||||||
#endif /* CIFS_ACL */
|
#endif /* CIFS_ACL */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2587,7 +2644,7 @@ struct smb_version_operations smb21_operations = {
|
||||||
#ifdef CONFIG_CIFS_ACL
|
#ifdef CONFIG_CIFS_ACL
|
||||||
.get_acl = get_smb2_acl,
|
.get_acl = get_smb2_acl,
|
||||||
.get_acl_by_fid = get_smb2_acl_by_fid,
|
.get_acl_by_fid = get_smb2_acl_by_fid,
|
||||||
/* .set_acl = set_smb3_acl, */
|
.set_acl = set_smb2_acl,
|
||||||
#endif /* CIFS_ACL */
|
#endif /* CIFS_ACL */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2686,7 +2743,7 @@ struct smb_version_operations smb30_operations = {
|
||||||
#ifdef CONFIG_CIFS_ACL
|
#ifdef CONFIG_CIFS_ACL
|
||||||
.get_acl = get_smb2_acl,
|
.get_acl = get_smb2_acl,
|
||||||
.get_acl_by_fid = get_smb2_acl_by_fid,
|
.get_acl_by_fid = get_smb2_acl_by_fid,
|
||||||
/* .set_acl = set_smb3_acl, */
|
.set_acl = set_smb2_acl,
|
||||||
#endif /* CIFS_ACL */
|
#endif /* CIFS_ACL */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue