[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Sat Jul 6 00:53:02 UTC 2024


The branch, master has been updated
       via  90c9d0d98d3 s3:ntlm_auth: make logs more consistent with length check
       via  09b91728d1a lib: Remove unused py_reparse_symlink_get
       via  93bde61f813 tests: Use the general py_reparse_get
       via  3a60fc5da4b tests: Remove a pointless ;
       via  6cfa3788339 lib: Add general py_reparse_get parsing routine
      from  e4d6a19e492 third_party/heimdal: Import lorikeet-heimdal-202407041740 (commit 42ba2a6e5dd1bc14a8b5ada8c9b8ace85956f6a0)

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


- Log -----------------------------------------------------------------
commit 90c9d0d98d3c80c77764dbcaf9c24d7c4ea31b4a
Author: Jones Syue <jonessyue at qnap.com>
Date:   Fri Jul 5 17:36:46 2024 +0800

    s3:ntlm_auth: make logs more consistent with length check
    
    Run ntlm_auth with options --lm-response/--nt-response/--challenge, and pass
    wrong length to these options, got error prompted logs about 'only got xxx
    bytes', which are not consistent with length check. This patch revise logs
    for length check to make it more consistent.
    
    For example --lm-response requires exact 24 hex, let us input three kinds
    of length 23 24 25, prompted logs said 'only got 25 bytes' seems confusing.
    
    script:
    for length in 23 24 25; \
    do \
        ntlm_auth --username=${un} --password=${pw} \
        --lm-response="`openssl rand -hex ${length}`"; \
    done;
    
    output:
    hex decode of 04db772593f5e6023d0ab4bc67a942c9179963477eb49d failed! (only got 23 bytes)
    NT_STATUS_OK: The operation completed successfully. (0x0)
    hex decode of 1e57749feb46bedcf969af6cbbe10e21d0232e35c27eb07294 failed! (only got 25 bytes)
    
    After patch it shows 'got 25 bytes, expected 24' seems more consistent:
    
    hex decode of e13e70c9cf2ac1e20015657c4bec53435b1b948febb63f failed! (got 23 bytes, expected 24)
    NT_STATUS_OK: The operation completed successfully. (0x0)
    hex decode of 64647005243092b036856f572faad262e0b69386d095d60f54 failed! (got 25 bytes, expected 24)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15677
    
    Signed-off-by: Jones Syue <jonessyue at qnap.com>
    Reviewed-by: David Mulder <dmulder at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Sat Jul  6 00:52:02 UTC 2024 on atb-devel-224

commit 09b91728d1a3bb71fa97f50685de7632ce72e078
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jul 4 13:48:37 2024 +0200

    lib: Remove unused py_reparse_symlink_get
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 93bde61f81381c70fe970a517246fc69bd7228c7
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jul 4 13:46:38 2024 +0200

    tests: Use the general py_reparse_get
    
    This was the only user of py_reparse_symlink_get
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3a60fc5da4bca13299d79757b77ccb96d7da6391
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jul 4 13:45:44 2024 +0200

    tests: Remove a pointless ;
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 6cfa37883392254da08cd603ae98c225df700c62
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jun 17 19:50:18 2024 +0200

    lib: Add general py_reparse_get parsing routine
    
    Will superseed py_reparse_symlink_get
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 libcli/smb/py_reparse_symlink.c   | 133 ++++++++++++++++++++++++--------------
 python/samba/tests/smb2symlink.py |   5 +-
 source3/utils/ntlm_auth.c         |   6 +-
 3 files changed, 90 insertions(+), 54 deletions(-)


Changeset truncated at 500 lines:

diff --git a/libcli/smb/py_reparse_symlink.c b/libcli/smb/py_reparse_symlink.c
index 5626e270803..d28a8fd8b93 100644
--- a/libcli/smb/py_reparse_symlink.c
+++ b/libcli/smb/py_reparse_symlink.c
@@ -71,6 +71,86 @@ static PyObject *py_reparse_put(PyObject *module, PyObject *args)
 	return result;
 }
 
+static PyObject *py_reparse_get(PyObject *module, PyObject *args)
+{
+	char *buf = NULL;
+	Py_ssize_t buflen;
+	PyObject *result = NULL;
+	struct reparse_data_buffer *rep = NULL;
+	bool ok;
+	NTSTATUS status;
+
+	ok = PyArg_ParseTuple(args, PYARG_BYTES_LEN ":get", &buf, &buflen);
+	if (!ok) {
+		return NULL;
+	}
+
+	rep = talloc(NULL, struct reparse_data_buffer);
+	if (rep == NULL) {
+		PyErr_NoMemory();
+		return NULL;
+	}
+
+	status = reparse_data_buffer_parse(rep, rep, (uint8_t *)buf, buflen);
+	if (!NT_STATUS_IS_OK(status)) {
+		TALLOC_FREE(rep);
+		PyErr_SetNTSTATUS(status);
+		return NULL;
+	}
+
+	switch (rep->tag) {
+	case IO_REPARSE_TAG_SYMLINK: {
+		const struct symlink_reparse_struct *lnk = &rep->parsed.lnk;
+		result = Py_BuildValue("s(ssII)",
+				       "IO_REPARSE_TAG_SYMLINK",
+				       lnk->substitute_name,
+				       lnk->print_name,
+				       (unsigned)lnk->unparsed_path_length,
+				       (unsigned)lnk->flags);
+		break;
+	}
+	case IO_REPARSE_TAG_NFS: {
+		const struct nfs_reparse_data_buffer *nfs = &rep->parsed.nfs;
+		switch (nfs->type) {
+		case NFS_SPECFILE_LNK:
+			result = Py_BuildValue("ss",
+					       "NFS_SPECFILE_LNK",
+					       nfs->data.lnk_target);
+			break;
+		case NFS_SPECFILE_BLK:
+			result = Py_BuildValue("sII",
+					       "NFS_SPECFILE_BLK",
+					       (unsigned)nfs->data.dev.major,
+					       (unsigned)nfs->data.dev.minor);
+			break;
+		case NFS_SPECFILE_CHR:
+			result = Py_BuildValue("sII",
+					       "NFS_SPECFILE_CHR",
+					       (unsigned)nfs->data.dev.major,
+					       (unsigned)nfs->data.dev.minor);
+			break;
+		case NFS_SPECFILE_FIFO:
+			result = Py_BuildValue("(s)", "NFS_SPECFILE_FIFO");
+			break;
+		case NFS_SPECFILE_SOCK:
+			result = Py_BuildValue("(s)", "NFS_SPECFILE_SOCK");
+			break;
+		}
+	}
+	}
+
+	if (result == NULL) {
+		result = Py_BuildValue("Iy#I",
+				       (unsigned)rep->tag,
+				       (const char *)rep->parsed.raw.data,
+				       (Py_ssize_t)rep->parsed.raw.length,
+				       (unsigned)rep->parsed.raw.reserved);
+	}
+
+	TALLOC_FREE(rep);
+	return result;
+}
+
 static PyObject *py_reparse_symlink_put(PyObject *module, PyObject *args)
 {
 	int unparsed = 0;
@@ -117,64 +197,19 @@ static PyObject *py_reparse_symlink_put(PyObject *module, PyObject *args)
 	return result;
 }
 
-static PyObject *py_reparse_symlink_get(PyObject *module, PyObject *args)
-{
-	char *buf = NULL;
-	Py_ssize_t buflen;
-	struct reparse_data_buffer *syml = NULL;
-	struct symlink_reparse_struct *lnk = NULL;
-	PyObject *result = NULL;
-	NTSTATUS status;
-	bool ok;
-
-	ok = PyArg_ParseTuple(args, PYARG_BYTES_LEN ":get", &buf, &buflen);
-	if (!ok) {
-		return NULL;
-	}
-
-	syml = talloc(NULL, struct reparse_data_buffer);
-	if (syml == NULL) {
-		PyErr_NoMemory();
-		return NULL;
-	}
-
-	status = reparse_data_buffer_parse(syml, syml, (uint8_t *)buf, buflen);
-	if (!NT_STATUS_IS_OK(status)) {
-		TALLOC_FREE(syml);
-		PyErr_SetNTSTATUS(status);
-		return NULL;
-	}
-
-	if (syml->tag != IO_REPARSE_TAG_SYMLINK) {
-		TALLOC_FREE(syml);
-		PyErr_SetNTSTATUS(NT_STATUS_INVALID_NETWORK_RESPONSE);
-		return NULL;
-	}
-	lnk = &syml->parsed.lnk;
-
-	result = Py_BuildValue("ssII",
-			       lnk->substitute_name,
-			       lnk->print_name,
-			       (unsigned)lnk->unparsed_path_length,
-			       (unsigned)lnk->flags);
-
-	TALLOC_FREE(syml);
-	return result;
-}
-
 static PyMethodDef py_reparse_symlink_methods[] = {
 	{ "put",
 	  PY_DISCARD_FUNC_SIG(PyCFunction, py_reparse_put),
 	  METH_VARARGS,
 	  "Create a reparse point blob"},
+	{ "get",
+	  PY_DISCARD_FUNC_SIG(PyCFunction, py_reparse_get),
+	  METH_VARARGS,
+	  "Parse a reparse point blob"},
 	{ "symlink_put",
 	  PY_DISCARD_FUNC_SIG(PyCFunction, py_reparse_symlink_put),
 	  METH_VARARGS,
 	  "Create a reparse symlink blob"},
-	{ "symlink_get",
-	  PY_DISCARD_FUNC_SIG(PyCFunction, py_reparse_symlink_get),
-	  METH_VARARGS,
-	  "Parse a reparse symlink blob"},
 	{0},
 };
 
diff --git a/python/samba/tests/smb2symlink.py b/python/samba/tests/smb2symlink.py
index 83df78e8bb6..a2b34aee639 100644
--- a/python/samba/tests/smb2symlink.py
+++ b/python/samba/tests/smb2symlink.py
@@ -182,11 +182,12 @@ class Smb2SymlinkTests(samba.tests.libsmb.LibsmbTests):
                b'\x72\x00\x62\x00\x61\x00\x72\x00')
 
         try:
-            syml = reparse_symlink.symlink_get(buf);
+            (tag,syml) = reparse_symlink.get(buf)
         except:
             self.fail("Could not parse symlink buffer")
 
-        self.assertEqual(syml, ('bar', 'bar', 0, 1));
+        self.assertEqual(tag, "IO_REPARSE_TAG_SYMLINK")
+        self.assertEqual(syml, ('bar', 'bar', 0, 1))
 
     def test_bug15505(self):
         """Test an absolute intermediate symlink inside the share"""
diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c
index a9e21298f25..e9b644724d9 100644
--- a/source3/utils/ntlm_auth.c
+++ b/source3/utils/ntlm_auth.c
@@ -2733,7 +2733,7 @@ enum {
 			opt_challenge = strhex_to_data_blob(NULL, hex_challenge);
 			if (opt_challenge.length != 8) {
 				fprintf(stderr, "hex decode of %s failed! "
-					"(only got %d bytes)\n",
+					"(got %d bytes, expected 8)\n",
 					hex_challenge,
 					(int)opt_challenge.length);
 				exit(1);
@@ -2743,7 +2743,7 @@ enum {
 			opt_lm_response = strhex_to_data_blob(NULL, hex_lm_response);
 			if (opt_lm_response.length != 24) {
 				fprintf(stderr, "hex decode of %s failed! "
-					"(only got %d bytes)\n",
+					"(got %d bytes, expected 24)\n",
 					hex_lm_response,
 					(int)opt_lm_response.length);
 				exit(1);
@@ -2754,7 +2754,7 @@ enum {
 			opt_nt_response = strhex_to_data_blob(NULL, hex_nt_response);
 			if (opt_nt_response.length < 24) {
 				fprintf(stderr, "hex decode of %s failed! "
-					"(only got %d bytes)\n",
+					"(only got %d bytes, needed at least 24)\n",
 					hex_nt_response,
 					(int)opt_nt_response.length);
 				exit(1);


-- 
Samba Shared Repository



More information about the samba-cvs mailing list