[SCM] Samba Shared Repository - branch master updated
Ralph Böhme
slow at samba.org
Tue Oct 31 05:42:01 UTC 2023
The branch, master has been updated
via 7a5228ffce0 CI: smb3unix.py: check basic CreateContexts response
via b6301fd0d75 libsmb: add all fields from SMB2_FIND_POSIX_INFORMATION in list_posix_helper()
via d6c8b709edb libsmb: remove mode from struct file_info
via 3dc1911f7c4 libsmb: use K format for parsing unsigned long long
via f52a025ac48 libsmb: info-level SMB2_FIND_POSIX_INFORMATION doesn't return short name
via ea89dd0069e libsmb: infer posix context from info_level
via 6944aa7cafd CI: smb3unix.py: use libsmb.SMB2_FIND_POSIX_INFORMATION
via 4ff144c247a pylibsmb: add IO_REPARSE_TAG_RESERVED_ZERO
via 8a8f1f3c6c4 libcli/smb: add IO_REPARSE_TAG_RESERVED_ZERO
from 9313731e96c ctdb-scripts: Update detect_init_style to use /etc/os-release
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 7a5228ffce0fd6700df03812aeb5712e4eb88928
Author: Ralph Boehme <slow at samba.org>
Date: Fri Oct 27 18:50:48 2023 +0200
CI: smb3unix.py: check basic CreateContexts response
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: David Mulder <dmulder at samba.org>
Autobuild-User(master): Ralph Böhme <slow at samba.org>
Autobuild-Date(master): Tue Oct 31 05:41:17 UTC 2023 on atb-devel-224
commit b6301fd0d75575fd8c19a24c37b2f353dc871fd5
Author: Ralph Boehme <slow at samba.org>
Date: Sun Oct 29 15:31:33 2023 +0100
libsmb: add all fields from SMB2_FIND_POSIX_INFORMATION in list_posix_helper()
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: David Mulder <dmulder at samba.org>
commit d6c8b709edb9c648934587b7d0f6ef4f06c78c38
Author: Ralph Boehme <slow at samba.org>
Date: Sun Oct 29 15:27:08 2023 +0100
libsmb: remove mode from struct file_info
There's already the "attr" member and this is even used in list_posix_helper()
in pylibsmb.c. While at it, remove the cast in list_posix_helper() by using "I"
instead of "i" format.
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: David Mulder <dmulder at samba.org>
commit 3dc1911f7c434de9631ddd28beeac04aa7af9f87
Author: Ralph Boehme <slow at samba.org>
Date: Sun Oct 29 14:59:22 2023 +0100
libsmb: use K format for parsing unsigned long long
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: David Mulder <dmulder at samba.org>
commit f52a025ac485694441096edff910da58761df94a
Author: Ralph Boehme <slow at samba.org>
Date: Sun Oct 29 14:49:20 2023 +0100
libsmb: info-level SMB2_FIND_POSIX_INFORMATION doesn't return short name
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: David Mulder <dmulder at samba.org>
commit ea89dd0069e7df323208ddea91ea79cdad64700c
Author: Ralph Boehme <slow at samba.org>
Date: Sun Oct 29 11:21:47 2023 +0100
libsmb: infer posix context from info_level
No need for an explcit additional argument, we can just infer this from the
info_level.
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: David Mulder <dmulder at samba.org>
commit 6944aa7cafd536598053812ce6b66b4d8e284859
Author: Ralph Boehme <slow at samba.org>
Date: Sun Oct 29 11:09:04 2023 +0100
CI: smb3unix.py: use libsmb.SMB2_FIND_POSIX_INFORMATION
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: David Mulder <dmulder at samba.org>
commit 4ff144c247a8548a47743e197406e844038df1fc
Author: Ralph Boehme <slow at samba.org>
Date: Fri Oct 27 18:50:30 2023 +0200
pylibsmb: add IO_REPARSE_TAG_RESERVED_ZERO
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: David Mulder <dmulder at samba.org>
commit 8a8f1f3c6c46d4fa2fe473c93b1c14fae806274e
Author: Ralph Boehme <slow at samba.org>
Date: Fri Oct 27 18:50:06 2023 +0200
libcli/smb: add IO_REPARSE_TAG_RESERVED_ZERO
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: David Mulder <dmulder at samba.org>
-----------------------------------------------------------------------
Summary of changes:
libcli/smb/smb_constants.h | 1 +
python/samba/tests/smb3unix.py | 66 +++++++++++++++++++++++++++++++++++++++---
source3/include/client.h | 1 -
source3/libsmb/cli_smb2_fnum.c | 9 +++---
source3/libsmb/cli_smb2_fnum.h | 3 +-
source3/libsmb/clilist.c | 7 ++---
source3/libsmb/proto.h | 3 +-
source3/libsmb/pylibsmb.c | 45 ++++++++++++++++------------
8 files changed, 100 insertions(+), 35 deletions(-)
Changeset truncated at 500 lines:
diff --git a/libcli/smb/smb_constants.h b/libcli/smb/smb_constants.h
index 8d3dc998a10..ead047d924f 100644
--- a/libcli/smb/smb_constants.h
+++ b/libcli/smb/smb_constants.h
@@ -607,6 +607,7 @@ enum csc_policy {
* A few values from [MS-FSCC] 2.1.2.1 Reparse Tags
*/
+#define IO_REPARSE_TAG_RESERVED_ZERO 0x00000000
#define IO_REPARSE_TAG_SYMLINK 0xA000000C
#define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003
#define IO_REPARSE_TAG_HSM 0xC0000004
diff --git a/python/samba/tests/smb3unix.py b/python/samba/tests/smb3unix.py
index 7b25c4bcd68..a98109d096b 100644
--- a/python/samba/tests/smb3unix.py
+++ b/python/samba/tests/smb3unix.py
@@ -20,12 +20,21 @@ from samba import NTSTATUSError,ntstatus
import samba.tests.libsmb
from samba.dcerpc import security
from samba.common import get_string
+from samba.dcerpc import smb3posix
+from samba.ndr import ndr_unpack
+from samba.dcerpc.security import dom_sid
+import os
def posix_context(mode):
return (libsmb.SMB2_CREATE_TAG_POSIX, mode.to_bytes(4, 'little'))
class Smb3UnixTests(samba.tests.libsmb.LibsmbTests):
+ def setUp(self):
+ super(Smb3UnixTests, self).setUp()
+
+ self.samsid = os.environ["SAMSID"]
+
def test_negotiate_context_posix(self):
c = libsmb.Conn(
self.server_ip,
@@ -119,8 +128,7 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests):
self.assertNotEqual(expected_count, 0, 'No files were found')
actual_count = len(c.list('',
- info_level=libsmb.SMB2_FIND_POSIX_INFORMATION,
- posix=True))
+ info_level=libsmb.SMB2_FIND_POSIX_INFORMATION))
self.assertEqual(actual_count-2, expected_count,
'SMB2_FIND_POSIX_INFORMATION failed to list contents')
@@ -239,7 +247,7 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests):
CreateContexts=[posix_context(perm)])
c.close(f)
- res = c.list("", info_level=100, posix=True)
+ res = c.list("", info_level=libsmb.SMB2_FIND_POSIX_INFORMATION)
found_files = {get_string(i['name']): i['perms'] for i in res}
for fname, perm in test_files.items():
self.assertIn(get_string(fname), found_files.keys(),
@@ -262,7 +270,7 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests):
posix=True)
self.assertTrue(c.have_posix())
- res = c.list("", info_level=100, posix=True)
+ res = c.list("", info_level=libsmb.SMB2_FIND_POSIX_INFORMATION)
found_files = {get_string(i['name']): i for i in res}
dotdot = found_files['..']
self.assertEqual('S-1-0-0', dotdot['owner_sid'],
@@ -271,3 +279,53 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests):
'The group sid for .. was not NULL')
self.assertEqual(0, dotdot['ino'], 'The ino for .. was not 0')
self.assertEqual(0, dotdot['dev'], 'The dev for .. was not 0')
+
+ def test_create_context_basic1(self):
+ '''
+ Check basic CreateContexts response
+ '''
+ try:
+ c = libsmb.Conn(
+ self.server_ip,
+ "smb3_posix_share",
+ self.lp,
+ self.creds,
+ posix=True)
+ self.assertTrue(c.have_posix())
+
+ f,_,cc_out = c.create_ex('\\test_create_context_basic1_file',
+ DesiredAccess=security.SEC_STD_ALL,
+ CreateDisposition=libsmb.FILE_CREATE,
+ CreateContexts=[posix_context(0o600)])
+ c.close(f)
+
+ cc = ndr_unpack(smb3posix.smb3_posix_cc_info, cc_out[0][1])
+
+ self.assertEqual(cc.nlinks, 1)
+ self.assertEqual(cc.reparse_tag, libsmb.IO_REPARSE_TAG_RESERVED_ZERO)
+ self.assertEqual(cc.posix_perms, 0o600)
+ self.assertEqual(cc.owner, dom_sid(self.samsid + "-1000"))
+ self.assertTrue(str(cc.group).startswith("S-1-22-2-"))
+
+ f,_,cc_out = c.create_ex('\\test_create_context_basic1_dir',
+ DesiredAccess=security.SEC_STD_ALL,
+ CreateDisposition=libsmb.FILE_CREATE,
+ CreateOptions=libsmb.FILE_DIRECTORY_FILE,
+ CreateContexts=[posix_context(0o700)])
+
+ c.close(f)
+
+ cc = ndr_unpack(smb3posix.smb3_posix_cc_info, cc_out[0][1])
+
+ # Note: this fails on btrfs which always reports the link
+ # count of directories as one.
+ self.assertEqual(cc.nlinks, 2)
+
+ self.assertEqual(cc.reparse_tag, libsmb.IO_REPARSE_TAG_RESERVED_ZERO)
+ self.assertEqual(cc.posix_perms, 0o700)
+ self.assertEqual(cc.owner, dom_sid(self.samsid + "-1000"))
+ self.assertTrue(str(cc.group).startswith("S-1-22-2-"))
+
+ finally:
+ self.delete_test_file(c, '\\test_create_context_basic1_file')
+ self.delete_test_file(c, '\\test_create_context_basic1_dir')
diff --git a/source3/include/client.h b/source3/include/client.h
index 9634166428c..e1a394af4b5 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -109,7 +109,6 @@ struct file_info {
struct timespec ctime_ts;
char *name;
char *short_name;
- uint32_t mode;
uint32_t reparse_tag;
dev_t st_ex_dev;
mode_t st_ex_mode;
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index 2092fc55048..08d95cf3579 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -1266,7 +1266,7 @@ static NTSTATUS parse_finfo_posix_info(const uint8_t *dir_data,
finfo->ctime_ts = interpret_long_date(info.change_time);
finfo->allocated_size = info.allocation_size;
finfo->size = info.end_of_file;
- finfo->mode = info.file_attributes;
+ finfo->attr = info.file_attributes;
finfo->ino = info.inode;
finfo->st_ex_dev = info.device;
finfo->st_ex_nlink = info.cc.nlinks;
@@ -1453,8 +1453,7 @@ struct tevent_req *cli_smb2_list_send(
struct tevent_context *ev,
struct cli_state *cli,
const char *pathname,
- unsigned int info_level,
- bool posix)
+ unsigned int info_level)
{
struct tevent_req *req = NULL, *subreq = NULL;
struct cli_smb2_list_state *state = NULL;
@@ -1477,7 +1476,9 @@ struct tevent_req *cli_smb2_list_send(
return tevent_req_post(req, ev);
}
- if (smbXcli_conn_have_posix(cli->conn) && posix) {
+ if (smbXcli_conn_have_posix(cli->conn) &&
+ info_level == SMB2_FIND_POSIX_INFORMATION)
+ {
NTSTATUS status;
/* The mode MUST be 0 when opening an existing file/dir, and
diff --git a/source3/libsmb/cli_smb2_fnum.h b/source3/libsmb/cli_smb2_fnum.h
index cde6a3ac333..abac569385d 100644
--- a/source3/libsmb/cli_smb2_fnum.h
+++ b/source3/libsmb/cli_smb2_fnum.h
@@ -106,8 +106,7 @@ struct tevent_req *cli_smb2_list_send(
struct tevent_context *ev,
struct cli_state *cli,
const char *pathname,
- unsigned int info_level,
- bool posix);
+ unsigned int info_level);
NTSTATUS cli_smb2_list_recv(
struct tevent_req *req,
TALLOC_CTX *mem_ctx,
diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c
index 9ef3f73a24a..54b46b09e0e 100644
--- a/source3/libsmb/clilist.c
+++ b/source3/libsmb/clilist.c
@@ -1002,8 +1002,7 @@ struct tevent_req *cli_list_send(TALLOC_CTX *mem_ctx,
struct cli_state *cli,
const char *mask,
uint32_t attribute,
- uint16_t info_level,
- bool posix)
+ uint16_t info_level)
{
struct tevent_req *req = NULL;
struct cli_list_state *state;
@@ -1017,7 +1016,7 @@ struct tevent_req *cli_list_send(TALLOC_CTX *mem_ctx,
if (proto >= PROTOCOL_SMB2_02) {
state->subreq = cli_smb2_list_send(state, ev, cli, mask,
- info_level, posix);
+ info_level);
state->recv_fn = cli_smb2_list_recv;
} else if (proto >= PROTOCOL_LANMAN2) {
state->subreq = cli_list_trans_send(
@@ -1230,7 +1229,7 @@ NTSTATUS cli_list(struct cli_state *cli,
? SMB_FIND_FILE_BOTH_DIRECTORY_INFO : SMB_FIND_INFO_STANDARD;
}
- req = cli_list_send(frame, ev, cli, mask, attribute, info_level, false);
+ req = cli_list_send(frame, ev, cli, mask, attribute, info_level);
if (req == NULL) {
goto fail;
}
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index b5a0311469e..35b6577a4bd 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -772,8 +772,7 @@ struct tevent_req *cli_list_send(TALLOC_CTX *mem_ctx,
struct cli_state *cli,
const char *mask,
uint32_t attribute,
- uint16_t info_level,
- bool posix);
+ uint16_t info_level);
NTSTATUS cli_list_recv(
struct tevent_req *req,
TALLOC_CTX *mem_ctx,
diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c
index 3063283ecc1..3129a45374a 100644
--- a/source3/libsmb/pylibsmb.c
+++ b/source3/libsmb/pylibsmb.c
@@ -1886,31 +1886,41 @@ static NTSTATUS list_posix_helper(struct file_info *finfo,
{
PyObject *result = (PyObject *)state;
PyObject *file = NULL;
- PyObject *size = NULL;
int ret;
- size = PyLong_FromUnsignedLongLong(finfo->size);
/*
* Build a dictionary representing the file info.
- * Note: Windows does not always return short_name (so it may be None)
*/
- file = Py_BuildValue("{s:s,s:i,s:s,s:O,s:l,s:i,s:i,s:i,s:s,s:s}",
+ file = Py_BuildValue("{s:s,s:I,"
+ "s:K,s:K,"
+ "s:l,s:l,s:l,s:l,"
+ "s:i,s:K,s:i,s:i,s:I,"
+ "s:s,s:s}",
"name", finfo->name,
- "attrib", (int)finfo->attr,
- "short_name", finfo->short_name,
- "size", size,
+ "attrib", finfo->attr,
+
+ "size", finfo->size,
+ "allocaction_size", finfo->allocated_size,
+
+ "btime",
+ convert_timespec_to_time_t(finfo->btime_ts),
+ "atime",
+ convert_timespec_to_time_t(finfo->atime_ts),
"mtime",
convert_timespec_to_time_t(finfo->mtime_ts),
+ "ctime",
+ convert_timespec_to_time_t(finfo->ctime_ts),
+
"perms", finfo->st_ex_mode,
"ino", finfo->ino,
"dev", finfo->st_ex_dev,
+ "nlink", finfo->st_ex_nlink,
+ "reparse_tag", finfo->reparse_tag,
+
"owner_sid",
dom_sid_string(finfo, &finfo->owner_sid),
"group_sid",
dom_sid_string(finfo, &finfo->group_sid));
-
- Py_CLEAR(size);
-
if (file == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -2006,7 +2016,6 @@ static NTSTATUS do_listing(struct py_cli_state *self,
const char *base_dir, const char *user_mask,
uint16_t attribute,
unsigned int info_level,
- bool posix,
NTSTATUS (*callback_fn)(struct file_info *,
const char *, void *),
void *priv)
@@ -2032,7 +2041,7 @@ static NTSTATUS do_listing(struct py_cli_state *self,
dos_format(mask);
req = cli_list_send(NULL, self->ev, self->cli, mask, attribute,
- info_level, posix);
+ info_level);
if (req == NULL) {
status = NT_STATUS_NO_MEMORY;
goto done;
@@ -2062,18 +2071,17 @@ static PyObject *py_cli_list(struct py_cli_state *self,
char *user_mask = NULL;
unsigned int attribute = LIST_ATTRIBUTE_MASK;
unsigned int info_level = 0;
- bool posix = false;
NTSTATUS status;
enum protocol_types proto = smbXcli_conn_protocol(self->cli->conn);
PyObject *result = NULL;
- const char *kwlist[] = { "directory", "mask", "attribs", "posix",
+ const char *kwlist[] = { "directory", "mask", "attribs",
"info_level", NULL };
NTSTATUS (*callback_fn)(struct file_info *, const char *, void *) =
&list_helper;
- if (!ParseTupleAndKeywords(args, kwds, "z|sIpI:list", kwlist,
+ if (!ParseTupleAndKeywords(args, kwds, "z|sII:list", kwlist,
&base_dir, &user_mask, &attribute,
- &posix, &info_level)) {
+ &info_level)) {
return NULL;
}
@@ -2090,11 +2098,11 @@ static PyObject *py_cli_list(struct py_cli_state *self,
}
}
- if (posix) {
+ if (info_level == SMB2_FIND_POSIX_INFORMATION) {
callback_fn = &list_posix_helper;
}
status = do_listing(self, base_dir, user_mask, attribute,
- info_level, posix, callback_fn, result);
+ info_level, callback_fn, result);
if (!NT_STATUS_IS_OK(status)) {
Py_XDECREF(result);
@@ -2982,6 +2990,7 @@ MODULE_INIT_FUNC(libsmb_samba_cwrapper)
ADD_FLAGS(SYMLINK_TRUST_UNKNOWN);
ADD_FLAGS(SYMLINK_TRUST_MASK);
+ ADD_FLAGS(IO_REPARSE_TAG_RESERVED_ZERO);
ADD_FLAGS(IO_REPARSE_TAG_SYMLINK);
ADD_FLAGS(IO_REPARSE_TAG_MOUNT_POINT);
ADD_FLAGS(IO_REPARSE_TAG_HSM);
--
Samba Shared Repository
More information about the samba-cvs
mailing list