Skip to content

Commit 366ed84

Browse files
shirishpargaonkarsmfrench
authored andcommitted
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 <[email protected]> Signed-off-by: Steve French <[email protected]> Reviewed-by: Pavel Shilovsky <[email protected]>
1 parent dac9534 commit 366ed84

File tree

1 file changed

+60
-3
lines changed

1 file changed

+60
-3
lines changed

fs/cifs/smb2ops.c

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,63 @@ get_smb2_acl_by_path(struct cifs_sb_info *cifs_sb,
13701370
return pntsd;
13711371
}
13721372

1373+
#ifdef CONFIG_CIFS_ACL
1374+
static int
1375+
set_smb2_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
1376+
struct inode *inode, const char *path, int aclflag)
1377+
{
1378+
u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
1379+
unsigned int xid;
1380+
int rc, access_flags = 0;
1381+
struct cifs_tcon *tcon;
1382+
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
1383+
struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
1384+
struct cifs_fid fid;
1385+
struct cifs_open_parms oparms;
1386+
__le16 *utf16_path;
1387+
1388+
cifs_dbg(FYI, "set smb3 acl for path %s\n", path);
1389+
if (IS_ERR(tlink))
1390+
return PTR_ERR(tlink);
1391+
1392+
tcon = tlink_tcon(tlink);
1393+
xid = get_xid();
1394+
1395+
if (backup_cred(cifs_sb))
1396+
oparms.create_options = CREATE_OPEN_BACKUP_INTENT;
1397+
else
1398+
oparms.create_options = 0;
1399+
1400+
if (aclflag == CIFS_ACL_OWNER || aclflag == CIFS_ACL_GROUP)
1401+
access_flags = WRITE_OWNER;
1402+
else
1403+
access_flags = WRITE_DAC;
1404+
1405+
utf16_path = cifs_convert_path_to_utf16(path, cifs_sb);
1406+
if (!utf16_path)
1407+
return -ENOMEM;
1408+
1409+
oparms.tcon = tcon;
1410+
oparms.desired_access = access_flags;
1411+
oparms.disposition = FILE_OPEN;
1412+
oparms.path = path;
1413+
oparms.fid = &fid;
1414+
oparms.reconnect = false;
1415+
1416+
rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL);
1417+
kfree(utf16_path);
1418+
if (!rc) {
1419+
rc = SMB2_set_acl(xid, tlink_tcon(tlink), fid.persistent_fid,
1420+
fid.volatile_fid, pnntsd, acllen, aclflag);
1421+
SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
1422+
}
1423+
1424+
cifs_put_tlink(tlink);
1425+
free_xid(xid);
1426+
return rc;
1427+
}
1428+
#endif /* CIFS_ACL */
1429+
13731430
/* Retrieve an ACL from the server */
13741431
static struct cifs_ntsd *
13751432
get_smb2_acl(struct cifs_sb_info *cifs_sb,
@@ -2498,7 +2555,7 @@ struct smb_version_operations smb20_operations = {
24982555
#ifdef CONFIG_CIFS_ACL
24992556
.get_acl = get_smb2_acl,
25002557
.get_acl_by_fid = get_smb2_acl_by_fid,
2501-
/* .set_acl = set_smb3_acl, */
2558+
.set_acl = set_smb2_acl,
25022559
#endif /* CIFS_ACL */
25032560
};
25042561

@@ -2587,7 +2644,7 @@ struct smb_version_operations smb21_operations = {
25872644
#ifdef CONFIG_CIFS_ACL
25882645
.get_acl = get_smb2_acl,
25892646
.get_acl_by_fid = get_smb2_acl_by_fid,
2590-
/* .set_acl = set_smb3_acl, */
2647+
.set_acl = set_smb2_acl,
25912648
#endif /* CIFS_ACL */
25922649
};
25932650

@@ -2686,7 +2743,7 @@ struct smb_version_operations smb30_operations = {
26862743
#ifdef CONFIG_CIFS_ACL
26872744
.get_acl = get_smb2_acl,
26882745
.get_acl_by_fid = get_smb2_acl_by_fid,
2689-
/* .set_acl = set_smb3_acl, */
2746+
.set_acl = set_smb2_acl,
26902747
#endif /* CIFS_ACL */
26912748
};
26922749

0 commit comments

Comments
 (0)