1 diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c
2 index fa301b9fa18..98750754036 100644
3 --- a/source3/libsmb/libsmb_file.c
4 +++ b/source3/libsmb/libsmb_file.c
5 @@ -464,6 +464,7 @@ SMBC_getatr(SMBCCTX * context,
6 struct timespec access_time_ts = {0};
7 struct timespec write_time_ts = {0};
8 struct timespec change_time_ts = {0};
9 + struct timespec w_time_ts = {0};
10 time_t write_time = 0;
12 struct cli_credentials *creds = NULL;
13 @@ -506,6 +507,7 @@ SMBC_getatr(SMBCCTX * context,
16 if (!srv->no_pathinfo2) {
17 + bool not_supported_error = false;
18 status = cli_qpathinfo2(targetcli,
21 @@ -518,11 +520,21 @@ SMBC_getatr(SMBCCTX * context,
22 if (NT_STATUS_IS_OK(status)) {
25 + if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_LEVEL) ||
26 + NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
27 + not_supported_error = true;
29 + if (!not_supported_error) {
30 + /* "Normal error". Just return it to caller. */
36 srv->no_pathinfo2 = True;
38 if (!srv->no_pathinfo3) {
39 + bool not_supported_error = false;
40 status = cli_qpathinfo3(targetcli,
43 @@ -535,6 +547,15 @@ SMBC_getatr(SMBCCTX * context,
44 if (NT_STATUS_IS_OK(status)) {
47 + if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_LEVEL) ||
48 + NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
49 + not_supported_error = true;
51 + if (!not_supported_error) {
52 + /* "Normal error". Just return it to caller. */
58 srv->no_pathinfo3 = True;
59 @@ -545,14 +566,11 @@ SMBC_getatr(SMBCCTX * context,
62 status = cli_getatr(targetcli, targetpath, &attr, &size, &write_time);
63 - if (NT_STATUS_IS_OK(status)) {
64 - struct timespec w_time_ts =
65 - convert_time_t_to_timespec(write_time);
67 - access_time_ts = change_time_ts = write_time_ts = w_time_ts;
70 + if (!NT_STATUS_IS_OK(status)) {
73 + w_time_ts = convert_time_t_to_timespec(write_time);
74 + access_time_ts = change_time_ts = write_time_ts = w_time_ts;
78 @@ -573,7 +591,7 @@ all_failed:
79 srv->no_pathinfo3 = False;
82 - return NT_STATUS_ACCESS_DENIED;