diff options
author | Shirish Pargaonkar <shirishpargaonkar@gmail.com> | 2017-06-28 23:37:32 -0400 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2017-07-08 18:23:10 -0400 |
commit | 366ed846df607a79b4d9b52b097c01f9d53b9d2a (patch) | |
tree | d77f272f9ddbbcecacad0f3e49889244d05626b2 | |
parent | dac953401c9722cca04a4a884e82e32fe82c0dad (diff) |
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>
-rw-r--r-- | fs/cifs/smb2ops.c | 63 |
1 files changed, 60 insertions, 3 deletions
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index ccbb397debbc..ed98daa0891c 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c | |||
@@ -1370,6 +1370,63 @@ get_smb2_acl_by_path(struct cifs_sb_info *cifs_sb, | |||
1370 | return pntsd; | 1370 | return pntsd; |
1371 | } | 1371 | } |
1372 | 1372 | ||
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 | |||
1373 | /* Retrieve an ACL from the server */ | 1430 | /* Retrieve an ACL from the server */ |
1374 | static struct cifs_ntsd * | 1431 | static struct cifs_ntsd * |
1375 | get_smb2_acl(struct cifs_sb_info *cifs_sb, | 1432 | get_smb2_acl(struct cifs_sb_info *cifs_sb, |
@@ -2498,7 +2555,7 @@ struct smb_version_operations smb20_operations = { | |||
2498 | #ifdef CONFIG_CIFS_ACL | 2555 | #ifdef CONFIG_CIFS_ACL |
2499 | .get_acl = get_smb2_acl, | 2556 | .get_acl = get_smb2_acl, |
2500 | .get_acl_by_fid = get_smb2_acl_by_fid, | 2557 | .get_acl_by_fid = get_smb2_acl_by_fid, |
2501 | /* .set_acl = set_smb3_acl, */ | 2558 | .set_acl = set_smb2_acl, |
2502 | #endif /* CIFS_ACL */ | 2559 | #endif /* CIFS_ACL */ |
2503 | }; | 2560 | }; |
2504 | 2561 | ||
@@ -2587,7 +2644,7 @@ struct smb_version_operations smb21_operations = { | |||
2587 | #ifdef CONFIG_CIFS_ACL | 2644 | #ifdef CONFIG_CIFS_ACL |
2588 | .get_acl = get_smb2_acl, | 2645 | .get_acl = get_smb2_acl, |
2589 | .get_acl_by_fid = get_smb2_acl_by_fid, | 2646 | .get_acl_by_fid = get_smb2_acl_by_fid, |
2590 | /* .set_acl = set_smb3_acl, */ | 2647 | .set_acl = set_smb2_acl, |
2591 | #endif /* CIFS_ACL */ | 2648 | #endif /* CIFS_ACL */ |
2592 | }; | 2649 | }; |
2593 | 2650 | ||
@@ -2686,7 +2743,7 @@ struct smb_version_operations smb30_operations = { | |||
2686 | #ifdef CONFIG_CIFS_ACL | 2743 | #ifdef CONFIG_CIFS_ACL |
2687 | .get_acl = get_smb2_acl, | 2744 | .get_acl = get_smb2_acl, |
2688 | .get_acl_by_fid = get_smb2_acl_by_fid, | 2745 | .get_acl_by_fid = get_smb2_acl_by_fid, |
2689 | /* .set_acl = set_smb3_acl, */ | 2746 | .set_acl = set_smb2_acl, |
2690 | #endif /* CIFS_ACL */ | 2747 | #endif /* CIFS_ACL */ |
2691 | }; | 2748 | }; |
2692 | 2749 | ||