@@ -1370,6 +1370,63 @@ get_smb2_acl_by_path(struct cifs_sb_info *cifs_sb,
1370
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
1430
/* Retrieve an ACL from the server */
1374
1431
static struct cifs_ntsd *
1375
1432
get_smb2_acl (struct cifs_sb_info * cifs_sb ,
@@ -2498,7 +2555,7 @@ struct smb_version_operations smb20_operations = {
2498
2555
#ifdef CONFIG_CIFS_ACL
2499
2556
.get_acl = get_smb2_acl ,
2500
2557
.get_acl_by_fid = get_smb2_acl_by_fid ,
2501
- /* .set_acl = set_smb3_acl, */
2558
+ .set_acl = set_smb2_acl ,
2502
2559
#endif /* CIFS_ACL */
2503
2560
};
2504
2561
@@ -2587,7 +2644,7 @@ struct smb_version_operations smb21_operations = {
2587
2644
#ifdef CONFIG_CIFS_ACL
2588
2645
.get_acl = get_smb2_acl ,
2589
2646
.get_acl_by_fid = get_smb2_acl_by_fid ,
2590
- /* .set_acl = set_smb3_acl, */
2647
+ .set_acl = set_smb2_acl ,
2591
2648
#endif /* CIFS_ACL */
2592
2649
};
2593
2650
@@ -2686,7 +2743,7 @@ struct smb_version_operations smb30_operations = {
2686
2743
#ifdef CONFIG_CIFS_ACL
2687
2744
.get_acl = get_smb2_acl ,
2688
2745
.get_acl_by_fid = get_smb2_acl_by_fid ,
2689
- /* .set_acl = set_smb3_acl, */
2746
+ .set_acl = set_smb2_acl ,
2690
2747
#endif /* CIFS_ACL */
2691
2748
};
2692
2749
0 commit comments