s3: smbd: Change uses of lp_unix_extensions() -> unix_extensions_enabled().
authorJeremy Allison <jra@samba.org>
Mon, 16 Jul 2018 22:51:09 +0000 (15:51 -0700)
committerJeremy Allison <jra@samba.org>
Mon, 25 Feb 2019 20:48:05 +0000 (12:48 -0800)
Will allow us to split this into smb1_unix_extensions() and
smb2_unix_extensions() later.

Signed-off-by: Jeremy Allison <jra@samba.org>
source3/param/loadparm.c
source3/smbd/negprot.c
source3/smbd/reply.c
source3/smbd/smb2_negprot.c
source3/smbd/trans2.c

index 1d580b0c04fc741bf465d22663f3d9142cae39ae..a34f19cb0c8e91e784c15046437787de7354e262 100644 (file)
@@ -4529,7 +4529,7 @@ void widelinks_warning(int snum)
                return;
        }
 
-       if (lp_unix_extensions() && lp_wide_links(snum)) {
+       if (unix_extensions_enabled() && lp_wide_links(snum)) {
                DBG_ERR("Share '%s' has wide links and unix extensions enabled. "
                        "These parameters are incompatible. "
                        "Wide links will be disabled for this share.\n",
@@ -4540,7 +4540,7 @@ void widelinks_warning(int snum)
 bool lp_widelinks(int snum)
 {
        /* wide links is always incompatible with unix extensions */
-       if (lp_unix_extensions()) {
+       if (unix_extensions_enabled()) {
                /*
                 * Unless we have "allow insecure widelinks"
                 * turned on.
index 2d5edf1282c0ce1edab8339eae4397e400d19fc3..a7a0bf662db1a0e2349895c70b8bf7c12275d13f 100644 (file)
@@ -318,7 +318,7 @@ static void reply_nt1(struct smb_request *req, uint16_t choice)
                capabilities |= CAP_UNICODE;
        }
 
-       if (lp_unix_extensions()) {
+       if (unix_extensions_enabled()) {
                capabilities |= CAP_UNIX;
        }
 
index 3e88f2a1583902f4c5cae8dd8a917f9f1b404c5f..3dc84d8173da649eed322536a0ed038ec9a8aa02 100644 (file)
@@ -4223,7 +4223,7 @@ static size_t calc_max_read_pdu(const struct smb_request *req)
                return 0x1FFFF;
        }
 
-       if (!lp_unix_extensions()) {
+       if (!unix_extensions_enabled()) {
                return 0x1FFFF;
        }
 
index ce1ebb260cf69745dfaf0da5ed11f7939373491d..e715249a882f3a75be049c01315797b1b033dd1e 100644 (file)
@@ -265,7 +265,7 @@ NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req)
                                        NT_STATUS_INVALID_PARAMETER);
                }
 
-               if (lp_unix_extensions()) {
+               if (unix_extensions_enabled()) {
                        in_posix = smb2_negotiate_context_find(&in_c,
                                        SMB2_POSIX_EXTENSIONS_AVAILABLE);
                }
index ba71bb1ad057898d40b45db4a8036cb38a4af712..5a2df10fd1e816122669c2f3c71f4764452f55b8 100644 (file)
@@ -1768,6 +1768,7 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx,
        int off;
        int pad = 0;
        NTSTATUS status;
+       DATA_BLOB blob = data_blob_null;
        struct readdir_attr_data *readdir_attr_data = NULL;
 
        if (!(mode & FILE_ATTRIBUTE_DIRECTORY)) {
@@ -2404,6 +2405,68 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx,
 
                break;
 
+       /* SMB2 UNIX Extension. */
+
+       case SMB2_FIND_POSIX_INFORMATION:
+               p+= 4;
+               SIVAL(p,0,reskey); p+= 4;    /* Used for continuing search. */
+
+               if (!(conn->sconn->using_smb2)) {
+                       return NT_STATUS_INVALID_LEVEL;
+               }
+               if (unix_extensions_enabled() == false) {
+                       return NT_STATUS_INVALID_LEVEL;
+               }
+               blob = store_smb2_posix_info(ctx,
+                                       conn,
+                                       &smb_fname->st,
+                                       0,
+                                       mode);
+               if (blob.data == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+               /* Space for the blob ? */
+               if (PTR_DIFF(end_data, p) < blob.length) {
+                       data_blob_free(&blob);
+                       /* Same error that srvstr_push returns. */
+                       return NT_STATUS_UNSUCCESSFUL;
+               }
+               memcpy(p, blob.data, blob.length);
+               p += blob.length;
+               data_blob_free(&blob);
+
+               /* Now add the filename string. */
+               nameptr = p;
+               p += 4;
+               status = srvstr_push(base_data, flags2, p, fname,
+                                 PTR_DIFF(end_data, p), 0, &len);
+               if (!NT_STATUS_IS_OK(status)) {
+                       return status;
+               }
+               SIVAL(nameptr, 0, len);
+
+               p += len;
+
+               len = PTR_DIFF(p, pdata);
+               pad = (len + (align-1)) & ~(align-1);
+               /*
+                * offset to the next entry, the caller
+                * will overwrite it for the last entry
+                * that's why we always include the padding
+                */
+               SIVAL(pdata,0,pad);
+               /*
+                * set padding to zero
+                */
+               if (do_pad) {
+                       memset(p, 0, pad - len);
+                       p = pdata + pad;
+               } else {
+                       p = pdata + len;
+               }
+
+               break;
+
        default:
                return NT_STATUS_INVALID_LEVEL;
        }
@@ -2692,7 +2755,7 @@ close_if_end = %d requires_resume_key = %d backup_priv = %d level = 0x%x, max_da
                case SMB_FIND_FILE_UNIX_INFO2:
                        /* Always use filesystem for UNIX mtime query. */
                        ask_sharemode = false;
-                       if (!lp_unix_extensions()) {
+                       if (!unix_extensions_enabled()) {
                                reply_nterror(req, NT_STATUS_INVALID_LEVEL);
                                goto out;
                        }
@@ -3146,7 +3209,7 @@ resume_key = %d resume name = %s continue=%d level = %d\n",
                case SMB_FIND_FILE_UNIX_INFO2:
                        /* Always use filesystem for UNIX mtime query. */
                        ask_sharemode = false;
-                       if (!lp_unix_extensions()) {
+                       if (!unix_extensions_enabled()) {
                                reply_nterror(req, NT_STATUS_INVALID_LEVEL);
                                return;
                        }
@@ -3856,7 +3919,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
                        bool large_read = !srv_is_signing_active(xconn);
                        int encrypt_caps = 0;
 
-                       if (!lp_unix_extensions()) {
+                       if (!unix_extensions_enabled()) {
                                return NT_STATUS_INVALID_LEVEL;
                        }
 
@@ -3902,7 +3965,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
                        int rc;
                        vfs_statvfs_struct svfs;
 
-                       if (!lp_unix_extensions()) {
+                       if (!unix_extensions_enabled()) {
                                return NT_STATUS_INVALID_LEVEL;
                        }
 
@@ -3936,7 +3999,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
                        uint32_t sid_bytes;
                        int i;
 
-                       if (!lp_unix_extensions()) {
+                       if (!unix_extensions_enabled()) {
                                return NT_STATUS_INVALID_LEVEL;
                        }
 
@@ -4237,7 +4300,7 @@ static void call_trans2setfsinfo(connection_struct *conn,
 
        switch(info_level) {
                case SMB_SET_CIFS_UNIX_INFO:
-                       if (!lp_unix_extensions()) {
+                       if (!unix_extensions_enabled()) {
                                DEBUG(2,("call_trans2setfsinfo: "
                                        "SMB_SET_CIFS_UNIX_INFO is invalid with "
                                        "unix extensions off\n"));
@@ -4293,7 +4356,7 @@ static void call_trans2setfsinfo(connection_struct *conn,
                                size_t param_len = 0;
                                size_t data_len = total_data;
 
-                               if (!lp_unix_extensions()) {
+                               if (!unix_extensions_enabled()) {
                                        reply_nterror(
                                                req,
                                                NT_STATUS_INVALID_LEVEL);
@@ -5044,7 +5107,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
        uint32_t access_mask = 0;
        size_t len = 0;
 
-       if (INFO_LEVEL_IS_UNIX(info_level) && !lp_unix_extensions()) {
+       if (INFO_LEVEL_IS_UNIX(info_level) && !unix_extensions_enabled()) {
                return NT_STATUS_INVALID_LEVEL;
        }
 
@@ -5850,7 +5913,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
                        if (!(conn->sconn->using_smb2)) {
                                return NT_STATUS_INVALID_LEVEL;
                        }
-                       if (lp_unix_extensions() == false) {
+                       if (unix_extensions_enabled() == false) {
                                return NT_STATUS_INVALID_LEVEL;
                        }
                        if (fsp == NULL) {
@@ -5938,7 +6001,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
 
                DEBUG(3,("call_trans2qfilepathinfo: TRANSACT2_QFILEINFO: level = %d\n", info_level));
 
-               if (INFO_LEVEL_IS_UNIX(info_level) && !lp_unix_extensions()) {
+               if (INFO_LEVEL_IS_UNIX(info_level) && !unix_extensions_enabled()) {
                        reply_nterror(req, NT_STATUS_INVALID_LEVEL);
                        return;
                }
@@ -6033,7 +6096,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
                DEBUG(3,("call_trans2qfilepathinfo: TRANSACT2_QPATHINFO: level = %d\n", info_level));
 
                if (INFO_LEVEL_IS_UNIX(info_level)) {
-                       if (!lp_unix_extensions()) {
+                       if (!unix_extensions_enabled()) {
                                reply_nterror(req, NT_STATUS_INVALID_LEVEL);
                                return;
                        }
@@ -8656,7 +8719,7 @@ NTSTATUS smbd_do_setfilepathinfo(connection_struct *conn,
 
        *ret_data_size = 0;
 
-       if (INFO_LEVEL_IS_UNIX(info_level) && !lp_unix_extensions()) {
+       if (INFO_LEVEL_IS_UNIX(info_level) && !unix_extensions_enabled()) {
                return NT_STATUS_INVALID_LEVEL;
        }