The Samba-Bugzilla – Attachment 17583 Details for
Bug 15195
Permission denied calling SMBC_getatr when file not exists
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch for 4.17
v4-17-test.patch (text/plain), 6.88 KB, created by
Pavel Filipenský
on 2022-10-19 09:13:46 UTC
(
hide
)
Description:
patch for 4.17
Filename:
MIME Type:
Creator:
Pavel Filipenský
Created:
2022-10-19 09:13:46 UTC
Size:
6.88 KB
patch
obsolete
>From cedb8d2f11c2c0358fe83890bb4df43551c0ece1 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Mon, 17 Oct 2022 13:14:41 -0700 >Subject: [PATCH 1/2] s4: torture: libsmbclient: Add a torture test to ensure > smbc_stat() returns ENOENT on a non-existent file. >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Add knownfail. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15195 > >Signed-off-by: Jeremy Allison <jra@samba.org> >Reviewed-by: Pavel Filipenský <pfilipensky@samba.org> >(cherry picked from commit 9eda432836bfff3d3d4a365a08a5ecb54f0f2e34) >--- > selftest/knownfail.d/libsmb_getatr | 2 + > source4/torture/libsmbclient/libsmbclient.c | 63 +++++++++++++++++++++ > 2 files changed, 65 insertions(+) > create mode 100644 selftest/knownfail.d/libsmb_getatr > >diff --git a/selftest/knownfail.d/libsmb_getatr b/selftest/knownfail.d/libsmb_getatr >new file mode 100644 >index 00000000000..d5fd1e9df3e >--- /dev/null >+++ b/selftest/knownfail.d/libsmb_getatr >@@ -0,0 +1,2 @@ >+^samba4.libsmbclient.getatr.NT1.getatr\(nt4_dc_smb1_done\) >+^samba4.libsmbclient.getatr.SMB3.getatr\(nt4_dc\) >diff --git a/source4/torture/libsmbclient/libsmbclient.c b/source4/torture/libsmbclient/libsmbclient.c >index 82f64c38b69..d335cad3a4e 100644 >--- a/source4/torture/libsmbclient/libsmbclient.c >+++ b/source4/torture/libsmbclient/libsmbclient.c >@@ -1412,6 +1412,67 @@ static bool torture_libsmbclient_rename(struct torture_context *tctx) > return success; > } > >+static bool torture_libsmbclient_getatr(struct torture_context *tctx) >+{ >+ const char *smburl = torture_setting_string(tctx, "smburl", NULL); >+ SMBCCTX *ctx = NULL; >+ char *getatr_name = NULL; >+ struct stat st = {0}; >+ bool ok; >+ int ret = 0; >+ int err = 0; >+ >+ if (smburl == NULL) { >+ torture_fail(tctx, >+ "option --option=torture:smburl=" >+ "smb://user:password@server missing\n"); >+ } >+ >+ ok = torture_libsmbclient_init_context(tctx, &ctx); >+ torture_assert(tctx, ok, "Failed to init context"); >+ smbc_set_context(ctx); >+ >+ getatr_name = talloc_asprintf(tctx, >+ "%s/noexist", >+ smburl); >+ if (getatr_name == NULL) { >+ torture_result(tctx, >+ TORTURE_FAIL, >+ __location__": %s", >+ "talloc fail\n"); >+ return false; >+ } >+ /* Ensure the file doesn't exist. */ >+ smbc_unlink(getatr_name); >+ /* >+ * smbc_stat() internally uses SMBC_getatr(). >+ * Make sure doing getatr on a non-existent file gives >+ * an error of -1, errno = ENOENT. >+ */ >+ >+ ret = smbc_stat(getatr_name, &st); >+ if (ret == -1) { >+ err = errno; >+ } >+ torture_assert_int_equal(tctx, >+ ret, >+ -1, >+ talloc_asprintf(tctx, >+ "smbc_stat on '%s' should " >+ "get -1, got %d\n", >+ getatr_name, >+ ret)); >+ torture_assert_int_equal(tctx, >+ err, >+ ENOENT, >+ talloc_asprintf(tctx, >+ "smbc_stat on '%s' should " >+ "get errno = ENOENT, got %s\n", >+ getatr_name, >+ strerror(err))); >+ return true; >+} >+ > NTSTATUS torture_libsmbclient_init(TALLOC_CTX *ctx) > { > struct torture_suite *suite; >@@ -1438,6 +1499,8 @@ NTSTATUS torture_libsmbclient_init(TALLOC_CTX *ctx) > torture_suite_add_simple_test(suite, > "rename", > torture_libsmbclient_rename); >+ torture_suite_add_simple_test(suite, "getatr", >+ torture_libsmbclient_getatr); > > suite->description = talloc_strdup(suite, "libsmbclient interface tests"); > >-- >2.37.3 > > >From 95ecaa62062db018f0c384688993944cc89195d0 Mon Sep 17 00:00:00 2001 >From: Jeremy Allison <jra@samba.org> >Date: Mon, 17 Oct 2022 13:24:27 -0700 >Subject: [PATCH 2/2] s3: libsmbclient: Fix smbc_stat() to return ENOENT on a > non-existent file. >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Remove knownfail. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15195 > >Signed-off-by: Jeremy Allison <jra@samba.org> >Reviewed-by: Pavel Filipenský <pfilipensky@samba.org> > >Autobuild-User(master): Jeremy Allison <jra@samba.org> >Autobuild-Date(master): Wed Oct 19 00:13:56 UTC 2022 on sn-devel-184 > >(cherry picked from commit fd0c01da1c744ae6fd9d8675616d8b6d3531e469) >--- > selftest/knownfail.d/libsmb_getatr | 2 -- > source3/libsmb/libsmb_file.c | 34 +++++++++++++++++++++++------- > 2 files changed, 26 insertions(+), 10 deletions(-) > delete mode 100644 selftest/knownfail.d/libsmb_getatr > >diff --git a/selftest/knownfail.d/libsmb_getatr b/selftest/knownfail.d/libsmb_getatr >deleted file mode 100644 >index d5fd1e9df3e..00000000000 >--- a/selftest/knownfail.d/libsmb_getatr >+++ /dev/null >@@ -1,2 +0,0 @@ >-^samba4.libsmbclient.getatr.NT1.getatr\(nt4_dc_smb1_done\) >-^samba4.libsmbclient.getatr.SMB3.getatr\(nt4_dc\) >diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c >index fa301b9fa18..98750754036 100644 >--- a/source3/libsmb/libsmb_file.c >+++ b/source3/libsmb/libsmb_file.c >@@ -464,6 +464,7 @@ SMBC_getatr(SMBCCTX * context, > struct timespec access_time_ts = {0}; > struct timespec write_time_ts = {0}; > struct timespec change_time_ts = {0}; >+ struct timespec w_time_ts = {0}; > time_t write_time = 0; > SMB_INO_T ino = 0; > struct cli_credentials *creds = NULL; >@@ -506,6 +507,7 @@ SMBC_getatr(SMBCCTX * context, > } > > if (!srv->no_pathinfo2) { >+ bool not_supported_error = false; > status = cli_qpathinfo2(targetcli, > targetpath, > &create_time_ts, >@@ -518,11 +520,21 @@ SMBC_getatr(SMBCCTX * context, > if (NT_STATUS_IS_OK(status)) { > goto setup_stat; > } >+ if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_LEVEL) || >+ NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) { >+ not_supported_error = true; >+ } >+ if (!not_supported_error) { >+ /* "Normal error". Just return it to caller. */ >+ TALLOC_FREE(frame); >+ return status; >+ } > } > > srv->no_pathinfo2 = True; > > if (!srv->no_pathinfo3) { >+ bool not_supported_error = false; > status = cli_qpathinfo3(targetcli, > targetpath, > &create_time_ts, >@@ -535,6 +547,15 @@ SMBC_getatr(SMBCCTX * context, > if (NT_STATUS_IS_OK(status)) { > goto setup_stat; > } >+ if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_LEVEL) || >+ NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) { >+ not_supported_error = true; >+ } >+ if (!not_supported_error) { >+ /* "Normal error". Just return it to caller. */ >+ TALLOC_FREE(frame); >+ return status; >+ } > } > > srv->no_pathinfo3 = True; >@@ -545,14 +566,11 @@ SMBC_getatr(SMBCCTX * context, > } > > status = cli_getatr(targetcli, targetpath, &attr, &size, &write_time); >- if (NT_STATUS_IS_OK(status)) { >- struct timespec w_time_ts = >- convert_time_t_to_timespec(write_time); >- >- access_time_ts = change_time_ts = write_time_ts = w_time_ts; >- >- goto setup_stat; >+ if (!NT_STATUS_IS_OK(status)) { >+ goto all_failed; > } >+ w_time_ts = convert_time_t_to_timespec(write_time); >+ access_time_ts = change_time_ts = write_time_ts = w_time_ts; > > setup_stat: > setup_stat(sb, >@@ -573,7 +591,7 @@ all_failed: > srv->no_pathinfo3 = False; > > TALLOC_FREE(frame); >- return NT_STATUS_ACCESS_DENIED; >+ return status; > } > > /* >-- >2.37.3 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
asn
:
review+
Actions:
View
Attachments on
bug 15195
:
17546
| 17583 |
17585
|
17603
|
17604