From patchwork Thu Jun 29 03:37:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shirish Pargaonkar X-Patchwork-Id: 9815881 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6634E602B1 for ; Thu, 29 Jun 2017 03:37:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57D5727F85 for ; Thu, 29 Jun 2017 03:37:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C6082858E; Thu, 29 Jun 2017 03:37:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA73A27F85 for ; Thu, 29 Jun 2017 03:37:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751607AbdF2Dhm (ORCPT ); Wed, 28 Jun 2017 23:37:42 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:32849 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751557AbdF2Dhl (ORCPT ); Wed, 28 Jun 2017 23:37:41 -0400 Received: by mail-oi0-f66.google.com with SMTP id f134so315526oig.0 for ; Wed, 28 Jun 2017 20:37:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=m/guYZvdv0KWx2hlkhk8lWCso26nQzNgGL6nVfVvShs=; b=cavDFqhLrhVchAdzCGSZYOByhE53jQ+PEufgqZVLyW8yDg2gu0UM8bhIQTPoCIYgvE Qy+LbLzZZ4z7qNMCLtoCOEyHDzxqk93wgUB2/VPZBFgJ1rbReBtU+PQ5DMA7GQjI+jDs oqv8Ac9j+3b/VjALovBDUbGRUe96hWTEa+wcOz93QiXpAx/ptv5y3gQnK77FIGDpIClO V+yOAvCetOGyGva22ZWFGqaCNDaby2K7+M7c0hbGObjn3oT2ytCAWeredpOdUc+0gZ+S IJfCLtqfV+EhPw1njX3WuY7aehegrZTtROKgCyGA8JJNL7XK/Bn5TUp4DOIw/Wv1FLyv 3SkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=m/guYZvdv0KWx2hlkhk8lWCso26nQzNgGL6nVfVvShs=; b=d1FlxgRQEVIcjHllqRGwcKXq65B/WKFzxcdO+DG7Zd3omKQ5vwqkz2END/Wh13Ki2z fn77BLkBIcZqEQ7VrZHYjABNGzZ0p+1QM/l8TzcM/7p3Fv5Y7meIOrys9+yfZQilx04W 7gCzBN39ZO8HLWkH8SE/bKHwt9UMNj+kKLIJbDuzX8OyDjXrG9JUG0YIwPbVWLGIGeN1 mfnMc3NhpGsAq5e9t0DV2j4REK95wsTIkYrLy2XLDSZloNbZMfN82WyP8ljTAIvA59fK fQbTA+1qXOT5EKIXO6zz19K5tDK9C7V4Ka0u6j/O+KLE2dsbjPBuR2sOIbDwalqX81y/ PsWg== X-Gm-Message-State: AKS2vOwSxLsfm7JF1Lkp5HFACM8NC/6o3FP1kduWSB4f71pDWyCisfVh Z5CYZuvLD8oO5g== X-Received: by 10.202.84.80 with SMTP id i77mr2516568oib.44.1498707461076; Wed, 28 Jun 2017 20:37:41 -0700 (PDT) Received: from shirish-ThinkPad-T400.attlocal.net (75-13-85-90.lightspeed.austtx.sbcglobal.net. [75.13.85.90]) by smtp.gmail.com with ESMTPSA id v125sm7220193oif.14.2017.06.28.20.37.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Jun 2017 20:37:39 -0700 (PDT) From: shirishpargaonkar@gmail.com To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, Shirish Pargaonkar Subject: [PATCH 2/2] cifs: Use smb 2 - 3 and cifsacl mount options setacl function Date: Wed, 28 Jun 2017 22:37:32 -0500 Message-Id: <1498707452-8745-1-git-send-email-shirishpargaonkar@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Shirish Pargaonkar Added set acl function. Very similar to set cifs acl function for smb1. Signed-off-by: Shirish Pargaonkar --- fs/cifs/smb2ops.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 6b1ef79..490737c 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -1369,6 +1369,63 @@ static bool smb2_set_sparse(const unsigned int xid, struct cifs_tcon *tcon, return pntsd; } +#ifdef CONFIG_CIFS_ACL +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, create_options = 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; + + 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.create_options = create_options; + 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 */ static struct cifs_ntsd * get_smb2_acl(struct cifs_sb_info *cifs_sb, @@ -2495,7 +2552,7 @@ struct smb_version_operations smb20_operations = { #ifdef CONFIG_CIFS_ACL .get_acl = get_smb2_acl, .get_acl_by_fid = get_smb2_acl_by_fid, -/* .set_acl = set_smb3_acl, */ + .set_acl = set_smb2_acl, #endif /* CIFS_ACL */ }; @@ -2584,7 +2641,7 @@ struct smb_version_operations smb21_operations = { #ifdef CONFIG_CIFS_ACL .get_acl = get_smb2_acl, .get_acl_by_fid = get_smb2_acl_by_fid, -/* .set_acl = set_smb3_acl, */ + .set_acl = set_smb2_acl, #endif /* CIFS_ACL */ }; @@ -2683,7 +2740,7 @@ struct smb_version_operations smb30_operations = { #ifdef CONFIG_CIFS_ACL .get_acl = get_smb2_acl, .get_acl_by_fid = get_smb2_acl_by_fid, -/* .set_acl = set_smb3_acl, */ + .set_acl = set_smb2_acl, #endif /* CIFS_ACL */ }; @@ -2783,7 +2840,7 @@ struct smb_version_operations smb311_operations = { #ifdef CONFIG_CIFS_ACL .get_acl = get_smb2_acl, .get_acl_by_fid = get_smb2_acl_by_fid, -/* .set_acl = set_smb3_acl, */ + .set_acl = set_smb2_acl, #endif /* CIFS_ACL */ }; #endif /* CIFS_SMB311 */