From: Ralph Boehme Date: Sun, 29 Oct 2023 10:21:47 +0000 (+0100) Subject: libsmb: infer posix context from info_level X-Git-Tag: talloc-2.4.2~965 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ea89dd0069e7df323208ddea91ea79cdad64700c;p=thirdparty%2Fsamba.git 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 Reviewed-by: David Mulder --- diff --git a/python/samba/tests/smb3unix.py b/python/samba/tests/smb3unix.py index bdca1e5d41a..5281f906099 100644 --- a/python/samba/tests/smb3unix.py +++ b/python/samba/tests/smb3unix.py @@ -119,8 +119,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 +238,7 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests): CreateContexts=[posix_context(perm)]) c.close(f) - res = c.list("", info_level=libsmb.SMB2_FIND_POSIX_INFORMATION, 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 +261,7 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests): posix=True) self.assertTrue(c.have_posix()) - res = c.list("", info_level=libsmb.SMB2_FIND_POSIX_INFORMATION, 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'], diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c index 2092fc55048..c2cca874b65 100644 --- a/source3/libsmb/cli_smb2_fnum.c +++ b/source3/libsmb/cli_smb2_fnum.c @@ -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 2a51a2a158c..efaed925ff0 100644 --- a/source3/libsmb/pylibsmb.c +++ b/source3/libsmb/pylibsmb.c @@ -2006,7 +2006,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 +2031,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 +2061,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 +2088,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);