[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Thu Oct 12 17:52:02 UTC 2023


The branch, master has been updated
       via  4b9b7f70f25 libsmb: Use cli_smb2_qpathinfo_send() for SMB_QUERY_FILE_ALT_NAME_INFO
       via  051492c178e examples: Enable posix for teststat
       via  6a4413c65c9 libsmbclient: Read the file type from the server with posix enabled
       via  feb78035558 libsmbclient: Add smbc_[gs]etOptionPosixExtensions()
       via  9e3856ecf8c libsmb: Parse reparse tag in query_directory response
       via  4c44b6e199f libsmb: Query reparse tag in cli_qpathinfo2
       via  30f4129e860 libsmb: Add placeholder "mode" parameter to cli_qpathinfo2()
       via  214eef0ff31 examples: Print file type as part of teststat
       via  77001b258f0 libsmb: Ask for posix semantics if requested
       via  8de01c31f31 smbclient: Always ask for SMB311 posix in negprot
      from  027332cee56 s3:winbindd: Call winbind_add_failed_connection_entry() for the correct dc name

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 4b9b7f70f25b2260334664393e788e8a74da9252
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jun 30 23:21:13 2023 +0200

    libsmb: Use cli_smb2_qpathinfo_send() for SMB_QUERY_FILE_ALT_NAME_INFO
    
    Remove one sync-only wrapper
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Böhme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Oct 12 17:51:44 UTC 2023 on atb-devel-224

commit 051492c178e36b8866a58f7d83cd26ca0c1e1d61
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Sep 14 13:45:04 2023 +0200

    examples: Enable posix for teststat
    
    Show that we can properly detect non-regular files created by the
    Windows NFS server. Tested manually against Windows 2022.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Böhme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 6a4413c65c980e54c2010f0adb0722d1b8972f85
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Aug 23 16:04:00 2023 +0200

    libsmbclient: Read the file type from the server with posix enabled
    
    This does not really request posix extensions, but it depends on them
    being activated because it changes behaviour.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Böhme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit feb78035558cba9f4e1f0733b68a805c80e1bec4
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Aug 16 09:13:50 2023 +0200

    libsmbclient: Add smbc_[gs]etOptionPosixExtensions()
    
    This is an obvious part of MR2888, not used anywhere yet. It will
    eventually result in us requesting SMB311 posix semantics, but for now
    it will just allow to change behaviour of libsmbclient that could
    break unsuspecting applications.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Böhme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 9e3856ecf8c34bcaa68fa0278872eb76dc063797
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jan 2 14:28:44 2023 +0100

    libsmb: Parse reparse tag in query_directory response
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Böhme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4c44b6e199f62d02ae2f163b95b284eb5a849138
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Aug 23 15:07:29 2023 +0200

    libsmb: Query reparse tag in cli_qpathinfo2
    
    Convert what we find to a file type
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Böhme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 30f4129e860b36c42d8d00048e1b98b23dc0cb2c
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Aug 23 13:47:20 2023 +0200

    libsmb: Add placeholder "mode" parameter to cli_qpathinfo2()
    
    Unused so far: Patch stripped out to not clutter the real patches that
    follow.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Böhme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 214eef0ff31b21c3d32ee46fed8874cff56801b8
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Aug 14 17:30:24 2023 +0200

    examples: Print file type as part of teststat
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Böhme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 77001b258f0be2a94a31a40c34ea0da51868ac47
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Sep 19 12:29:11 2023 -0700

    libsmb: Ask for posix semantics if requested
    
    This is so far only for the getattr-style smb311 calls to request
    case-sensitive semantics when "posix" was requested over smb311.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Böhme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8de01c31f317485c8466db95d8487c253a70fd31
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Sep 19 11:55:32 2023 -0700

    smbclient: Always ask for SMB311 posix in negprot
    
    This does not mean that we're actually using it (yet). We just probe
    whether the server is willing to do it.
    
    Enable the posix cli command for smb311 posix extensions.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Böhme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 examples/libsmbclient/teststat.c                   |  37 +++++-
 source3/client/client.c                            |   7 +-
 source3/include/client.h                           |   2 +
 source3/include/libsmb_internal.h                  |   8 ++
 source3/include/libsmbclient.h                     |   6 +
 .../{smbclient-0.6.0.sigs => smbclient-0.8.0.sigs} |   2 +
 source3/libsmb/cli_smb2_fnum.c                     | 114 +++--------------
 source3/libsmb/cli_smb2_fnum.h                     |   3 -
 source3/libsmb/clidfs.c                            |  31 ++++-
 source3/libsmb/clifile.c                           |  46 +++++++
 source3/libsmb/clirap.c                            | 141 ++++++++++++++++++---
 source3/libsmb/clirap.h                            |  15 ++-
 source3/libsmb/libsmb_context.c                    |   1 +
 source3/libsmb/libsmb_file.c                       |   8 +-
 source3/libsmb/libsmb_setget.c                     |  14 ++
 source3/libsmb/wscript                             |   2 +-
 source3/torture/torture.c                          |  60 +++++++--
 17 files changed, 358 insertions(+), 139 deletions(-)
 copy source3/libsmb/ABI/{smbclient-0.6.0.sigs => smbclient-0.8.0.sigs} (98%)


Changeset truncated at 500 lines:

diff --git a/examples/libsmbclient/teststat.c b/examples/libsmbclient/teststat.c
index c8973e6ad0d..079ac8974ad 100644
--- a/examples/libsmbclient/teststat.c
+++ b/examples/libsmbclient/teststat.c
@@ -3,8 +3,34 @@
 #include <string.h>
 #include <time.h>
 #include <libsmbclient.h>
+#include <stdbool.h>
 #include "get_auth_data_fn.h"
 
+static const char *filetypestr(mode_t mode)
+{
+	if (S_ISREG(mode)) {
+		return "regular file";
+	}
+	if (S_ISDIR(mode)) {
+		return "directory";
+	}
+	if (S_ISFIFO(mode)) {
+		return "fifo";
+	}
+	if (S_ISLNK(mode)) {
+		return "symbolic link";
+	}
+	if (S_ISSOCK(mode)) {
+		return "socket";
+	}
+	if (S_ISCHR(mode)) {
+		return "character special file";
+	}
+	if (S_ISBLK(mode)) {
+		return "block special file";
+	}
+	return "unknown file type";
+}
 
 int main(int argc, char * argv[])
 {
@@ -46,6 +72,7 @@ int main(int argc, char * argv[])
 	smbc_setDebug(ctx, debug);
 	smbc_init_context(ctx);
 	smbc_setFunctionAuthData(ctx, get_auth_data_fn);
+	smbc_setOptionPosixExtensions(ctx, true);
 
 	ret = smbc_getFunctionStat(ctx)(ctx, pSmbPath, &st);
 	if (ret < 0) {
@@ -53,13 +80,14 @@ int main(int argc, char * argv[])
 		return 1;
 	}
 
-	printf("\nSAMBA\n mtime:%jd/%s ctime:%jd/%s atime:%jd/%s\n",
+	printf("\nSAMBA\n mtime:%jd/%s ctime:%jd/%s atime:%jd/%s %s\n",
 	       (intmax_t)st.st_mtime,
 	       ctime_r(&st.st_mtime, m_time),
 	       (intmax_t)st.st_ctime,
 	       ctime_r(&st.st_ctime, c_time),
 	       (intmax_t)st.st_atime,
-	       ctime_r(&st.st_atime, a_time));
+	       ctime_r(&st.st_atime, a_time),
+	       filetypestr(st.st_mode));
 
 	if (pLocalPath != NULL) {
 		ret = stat(pLocalPath, &st);
@@ -68,13 +96,14 @@ int main(int argc, char * argv[])
 			return 1;
 		}
 
-		printf("LOCAL\n mtime:%jd/%s ctime:%jd/%s atime:%jd/%s\n",
+		printf("LOCAL\n mtime:%jd/%s ctime:%jd/%s atime:%jd/%s %s\n",
 		       (intmax_t)st.st_mtime,
 		       ctime_r(&st.st_mtime, m_time),
 		       (intmax_t)st.st_ctime,
 		       ctime_r(&st.st_ctime, c_time),
 		       (intmax_t)st.st_atime,
-		       ctime_r(&st.st_atime, a_time));
+		       ctime_r(&st.st_atime, a_time),
+		       filetypestr(st.st_mode));
 	}
 
 	return 0;
diff --git a/source3/client/client.c b/source3/client/client.c
index f14e3f4130e..d8b939ab3bd 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -3164,11 +3164,16 @@ static int cmd_posix(void)
 	char *caps;
 	NTSTATUS status;
 
-	if (!SERVER_HAS_UNIX_CIFS(cli)) {
+	if (!(SERVER_HAS_UNIX_CIFS(cli) || cli->smb2.server_smb311_posix)) {
 		d_printf("Server doesn't support UNIX CIFS extensions.\n");
 		return 1;
 	}
 
+	if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB3_11) {
+		cli->smb2.client_smb311_posix = true;
+		return 0;
+	}
+
 	status = cli_unix_extensions_version(cli, &major, &minor, &caplow,
 					     &caphigh);
 	if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/include/client.h b/source3/include/client.h
index 5ac9d649142..3644e40ca50 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -91,6 +91,8 @@ struct cli_state {
 		struct smbXcli_session *session;
 		struct smbXcli_tcon *tcon;
 		struct idr_context *open_handles;
+		bool server_smb311_posix;
+		bool client_smb311_posix;
 	} smb2;
 };
 
diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h
index e30bfeb6690..113111532e0 100644
--- a/source3/include/libsmb_internal.h
+++ b/source3/include/libsmb_internal.h
@@ -159,6 +159,14 @@ struct SMBC_internal_data {
          */
         bool                                    full_time_names;
 
+        /*
+         * Enable POSIX extensions before opening files/directories
+         * Will silently ignore if the server does not support the POSIX
+         * extensions
+         */
+
+        bool                                     posix_extensions;
+
         /*
          * The share mode of a file being opened.  To match POSIX semantics
          * (and maintain backward compatibility), DENY_NONE is the default.
diff --git a/source3/include/libsmbclient.h b/source3/include/libsmbclient.h
index 47eae80ca17..619feab6392 100644
--- a/source3/include/libsmbclient.h
+++ b/source3/include/libsmbclient.h
@@ -588,7 +588,13 @@ smbc_getPort(SMBCCTX *c);
 void
 smbc_setPort(SMBCCTX *c, uint16_t port);
 
+/** Get whether to enable POSIX extensions if available */
+smbc_bool
+smbc_getOptionPosixExtensions(SMBCCTX *c);
 
+/** Set whether to enable POSIX extensions if available */
+void
+smbc_setOptionPosixExtensions(SMBCCTX *c, smbc_bool b);
 
 /***********************************
  * Getters and setters for OPTIONS *
diff --git a/source3/libsmb/ABI/smbclient-0.6.0.sigs b/source3/libsmb/ABI/smbclient-0.8.0.sigs
similarity index 98%
copy from source3/libsmb/ABI/smbclient-0.6.0.sigs
copy to source3/libsmb/ABI/smbclient-0.8.0.sigs
index ee758e21b50..fc7e79fec17 100644
--- a/source3/libsmb/ABI/smbclient-0.6.0.sigs
+++ b/source3/libsmb/ABI/smbclient-0.8.0.sigs
@@ -64,6 +64,7 @@ smbc_getOptionFullTimeNames: smbc_bool (SMBCCTX *)
 smbc_getOptionNoAutoAnonymousLogin: smbc_bool (SMBCCTX *)
 smbc_getOptionOneSharePerServer: smbc_bool (SMBCCTX *)
 smbc_getOptionOpenShareMode: smbc_share_mode (SMBCCTX *)
+smbc_getOptionPosixExtensions: smbc_bool (SMBCCTX *)
 smbc_getOptionSmbEncryptionLevel: smbc_smb_encrypt_level (SMBCCTX *)
 smbc_getOptionUrlEncodeReaddirEntries: smbc_bool (SMBCCTX *)
 smbc_getOptionUseCCache: smbc_bool (SMBCCTX *)
@@ -159,6 +160,7 @@ smbc_setOptionFullTimeNames: void (SMBCCTX *, smbc_bool)
 smbc_setOptionNoAutoAnonymousLogin: void (SMBCCTX *, smbc_bool)
 smbc_setOptionOneSharePerServer: void (SMBCCTX *, smbc_bool)
 smbc_setOptionOpenShareMode: void (SMBCCTX *, smbc_share_mode)
+smbc_setOptionPosixExtensions: void (SMBCCTX *, smbc_bool)
 smbc_setOptionProtocols: smbc_bool (SMBCCTX *, const char *, const char *)
 smbc_setOptionSmbEncryptionLevel: void (SMBCCTX *, smbc_smb_encrypt_level)
 smbc_setOptionUrlEncodeReaddirEntries: void (SMBCCTX *, smbc_bool)
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 1939db1b711..2092fc55048 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -246,6 +246,24 @@ struct tevent_req *cli_smb2_create_fnum_send(
 		create_options |= FILE_OPEN_FOR_BACKUP_INTENT;
 	}
 
+	if (cli->smb2.client_smb311_posix) {
+		uint8_t modebuf[4] = {
+			0,
+		};
+
+		status =
+			smb2_create_blob_add(state,
+					     &state->in_cblobs,
+					     SMB2_CREATE_TAG_POSIX,
+					     (DATA_BLOB){
+						     .data = modebuf,
+						     .length = sizeof(modebuf),
+					     });
+		if (tevent_req_nterror(req, status)) {
+			return tevent_req_post(req, ev);
+		}
+	}
+
 	/* Check for @GMT- paths. Remove the @GMT and turn into TWrp if so. */
 	have_twrp = clistr_smb2_extract_snapshot_token(fname, &ntt);
 	if (have_twrp) {
@@ -1334,6 +1352,7 @@ static NTSTATUS parse_finfo_id_both_directory_info(const uint8_t *dir_data,
 	if (namelen > (dir_data_length - 104)) {
 		return NT_STATUS_INFO_LENGTH_MISMATCH;
 	}
+	finfo->reparse_tag = IVAL(dir_data + 64, 0);
 	slen = CVAL(dir_data + 68, 0);
 	if (slen > 24) {
 		return NT_STATUS_INFO_LENGTH_MISMATCH;
@@ -2164,101 +2183,6 @@ static NTSTATUS get_fnum_from_path(struct cli_state *cli,
 	return status;
 }
 
-/***************************************************************
- Wrapper that allows SMB2 to query a path info (ALTNAME level).
- Synchronous only.
-***************************************************************/
-
-NTSTATUS cli_smb2_qpathinfo_alt_name(struct cli_state *cli,
-				const char *name,
-				fstring alt_name)
-{
-	NTSTATUS status;
-	DATA_BLOB outbuf = data_blob_null;
-	uint16_t fnum = 0xffff;
-	uint32_t altnamelen = 0;
-	TALLOC_CTX *frame = talloc_stackframe();
-
-	if (smbXcli_conn_has_async_calls(cli->conn)) {
-		/*
-		 * Can't use sync call while an async call is in flight
-		 */
-		status = NT_STATUS_INVALID_PARAMETER;
-		goto fail;
-	}
-
-	status = get_fnum_from_path(cli,
-				name,
-				FILE_READ_ATTRIBUTES,
-				&fnum);
-
-	if (!NT_STATUS_IS_OK(status)) {
-		goto fail;
-	}
-
-	status = cli_smb2_query_info_fnum(
-		cli,
-		fnum,
-		1, /* in_info_type */
-		(SMB_FILE_ALTERNATE_NAME_INFORMATION - 1000), /* in_file_info_class */
-		0xFFFF, /* in_max_output_length */
-		NULL, /* in_input_buffer */
-		0, /* in_additional_info */
-		0, /* in_flags */
-		frame,
-		&outbuf);
-
-	if (!NT_STATUS_IS_OK(status)) {
-		goto fail;
-	}
-
-	/* Parse the reply. */
-	if (outbuf.length < 4) {
-		status = NT_STATUS_INVALID_NETWORK_RESPONSE;
-		goto fail;
-	}
-
-	altnamelen = IVAL(outbuf.data, 0);
-	if (altnamelen > outbuf.length - 4) {
-		status = NT_STATUS_INVALID_NETWORK_RESPONSE;
-		goto fail;
-	}
-
-	if (altnamelen > 0) {
-		size_t ret = 0;
-		char *short_name = NULL;
-		ret = pull_string_talloc(frame,
-				outbuf.data,
-				FLAGS2_UNICODE_STRINGS,
-				&short_name,
-				outbuf.data + 4,
-				altnamelen,
-				STR_UNICODE);
-		if (ret == (size_t)-1) {
-			/* Bad conversion. */
-			status = NT_STATUS_INVALID_NETWORK_RESPONSE;
-			goto fail;
-		}
-
-	        fstrcpy(alt_name, short_name);
-	} else {
-		alt_name[0] = '\0';
-	}
-
-	status = NT_STATUS_OK;
-
-  fail:
-
-	if (fnum != 0xffff) {
-		cli_smb2_close_fnum(cli, fnum);
-	}
-
-	cli->raw_status = status;
-
-	TALLOC_FREE(frame);
-	return status;
-}
-
 struct cli_smb2_qpathinfo_state {
 	struct tevent_context *ev;
 	struct cli_state *cli;
diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h
index 7f3d7c2be1b..cde6a3ac333 100644
--- a/source3/libsmb/cli_smb2_fnum.h
+++ b/source3/libsmb/cli_smb2_fnum.h
@@ -116,9 +116,6 @@ NTSTATUS cli_smb2_qpathinfo_basic(struct cli_state *cli,
 			const char *name,
 			SMB_STRUCT_STAT *sbuf,
 			uint32_t *attributes);
-NTSTATUS cli_smb2_qpathinfo_alt_name(struct cli_state *cli,
-			const char *name,
-			fstring alt_name);
 struct tevent_req *cli_smb2_qpathinfo_send(TALLOC_CTX *mem_ctx,
 					   struct tevent_context *ev,
 					   struct cli_state *cli,
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c
index 1437844b427..7bc733492ce 100644
--- a/source3/libsmb/clidfs.c
+++ b/source3/libsmb/clidfs.c
@@ -28,6 +28,7 @@
 #include "../libcli/smb/smbXcli_base.h"
 #include "auth/credentials/credentials.h"
 #include "lib/param/param.h"
+#include "libcli/smb/smb2_negotiate_context.h"
 
 /********************************************************************
  Important point.
@@ -148,6 +149,8 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
 		cli_credentials_get_smb_signing(creds);
 	enum smb_encryption_setting encryption_state =
 		cli_credentials_get_smb_encryption(creds);
+	struct smb2_negotiate_contexts *in_contexts = NULL;
+	struct smb2_negotiate_contexts *out_contexts = NULL;
 
 	if (encryption_state >= SMB_ENCRYPTION_DESIRED) {
 		signing_state = SMB_SIGNING_REQUIRED;
@@ -193,13 +196,29 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
 
 	DEBUG(4,(" session request ok\n"));
 
+	in_contexts = talloc_zero(ctx, struct smb2_negotiate_contexts);
+	if (in_contexts == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	status = smb2_negotiate_context_add(
+		in_contexts,
+		in_contexts,
+		SMB2_POSIX_EXTENSIONS_AVAILABLE,
+		(const uint8_t *)SMB2_CREATE_TAG_POSIX,
+		strlen(SMB2_CREATE_TAG_POSIX));
+	if (!NT_STATUS_IS_OK(status)) {
+		return status;
+	}
+
 	status = smbXcli_negprot(c->conn,
 				 c->timeout,
 				 lp_client_min_protocol(),
 				 lp_client_max_protocol(),
-				 NULL,
-				 NULL,
-				 NULL);
+				 in_contexts,
+				 ctx,
+				 &out_contexts);
+	TALLOC_FREE(in_contexts);
 
 	if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
 		d_printf("Protocol negotiation (with timeout %d ms) timed out against server %s\n",
@@ -226,6 +245,12 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
 		smb2cli_conn_set_max_credits(c->conn, DEFAULT_SMB2_MAX_CREDITS);
 	}
 
+	if ((protocol >= PROTOCOL_SMB3_11) && (out_contexts != NULL)) {
+		c->smb2.server_smb311_posix = smb2_negotiate_context_find(
+			out_contexts,
+			SMB2_POSIX_EXTENSIONS_AVAILABLE);
+	}
+
 	status = cli_session_setup_creds(c, creds);
 	if (!NT_STATUS_IS_OK(status)) {
 		/* If a password was not supplied then
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 6f1625ce190..5dc11f69458 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -6759,6 +6759,7 @@ struct cli_qpathinfo_state {
 };
 
 static void cli_qpathinfo_done(struct tevent_req *subreq);
+static void cli_qpathinfo_done2(struct tevent_req *subreq);
 
 struct tevent_req *cli_qpathinfo_send(TALLOC_CTX *mem_ctx,
 				      struct tevent_context *ev,
@@ -6775,6 +6776,33 @@ struct tevent_req *cli_qpathinfo_send(TALLOC_CTX *mem_ctx,
 	if (req == NULL) {
 		return NULL;
 	}
+
+	if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
+		uint16_t smb2_level = 0;
+
+		switch (level) {
+		case SMB_QUERY_FILE_ALT_NAME_INFO:
+			smb2_level = FSCC_FILE_ALTERNATE_NAME_INFORMATION;
+			break;
+		default:
+			tevent_req_nterror(req, NT_STATUS_INVALID_LEVEL);
+			return tevent_req_post(req, ev);
+		}
+
+		subreq = cli_smb2_qpathinfo_send(state,
+						 ev,
+						 cli,
+						 fname,
+						 smb2_level,
+						 min_rdata,
+						 max_rdata);
+		if (tevent_req_nomem(subreq, req)) {
+			return tevent_req_post(req, ev);
+		}
+		tevent_req_set_callback(subreq, cli_qpathinfo_done2, req);
+		return req;
+	}
+
 	state->min_rdata = min_rdata;
 	SSVAL(state->setup, 0, TRANSACT2_QPATHINFO);
 
@@ -6849,6 +6877,24 @@ static void cli_qpathinfo_done(struct tevent_req *subreq)
 	tevent_req_done(req);
 }
 
+static void cli_qpathinfo_done2(struct tevent_req *subreq)
+{
+	struct tevent_req *req =
+		tevent_req_callback_data(subreq, struct tevent_req);
+	struct cli_qpathinfo_state *state =
+		tevent_req_data(req, struct cli_qpathinfo_state);
+	NTSTATUS status;
+
+	status = cli_smb2_qpathinfo_recv(subreq,
+					 state,
+					 &state->rdata,
+					 &state->num_rdata);
+	if (tevent_req_nterror(req, status)) {
+		return;
+	}
+	tevent_req_done(req);
+}
+
 NTSTATUS cli_qpathinfo_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
 			    uint8_t **rdata, uint32_t *num_rdata)
 {
diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c
index 7944eeb847c..21ee346e0aa 100644
--- a/source3/libsmb/clirap.c
+++ b/source3/libsmb/clirap.c
@@ -28,6 +28,7 @@
 #include "libsmb/clirap.h"
 #include "trans2.h"
 #include "../libcli/smb/smbXcli_base.h"
+#include "libcli/smb/reparse.h"
 #include "cli_smb2_fnum.h"
 #include "lib/util/string_wrappers.h"
 
@@ -777,6 +778,9 @@ NTSTATUS cli_setfileinfo_ext(
 ****************************************************************************/
 
 struct cli_qpathinfo2_state {
+	struct tevent_context *ev;
+	struct cli_state *cli;
+	const char *fname;
 	struct timespec create_time;
 	struct timespec access_time;
 	struct timespec write_time;
@@ -784,10 +788,12 @@ struct cli_qpathinfo2_state {
 	off_t size;
 	uint32_t attr;
 	SMB_INO_T ino;
+	mode_t mode;
 };
 
 static void cli_qpathinfo2_done2(struct tevent_req *subreq);
 static void cli_qpathinfo2_done(struct tevent_req *subreq);
+static void cli_qpathinfo2_got_reparse(struct tevent_req *subreq);
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list