]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
3 years agosmbd: Save a few lines by using tevent_req_nterror()'s retval
Volker Lendecke [Thu, 1 Sep 2022 10:30:57 +0000 (12:30 +0200)] 
smbd: Save a few lines by using tevent_req_nterror()'s retval

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosamba-tool ntacl: better messages for missing files
Douglas Bagnall [Wed, 10 Aug 2022 23:26:44 +0000 (11:26 +1200)] 
samba-tool ntacl: better messages for missing files

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14937

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Wed Sep  7 06:02:20 UTC 2022 on sn-devel-184

3 years agopysmbd: set_nt_acl() can raise FileNotFoundError
Douglas Bagnall [Thu, 1 Sep 2022 01:18:12 +0000 (01:18 +0000)] 
pysmbd: set_nt_acl() can raise FileNotFoundError

rather than an NTStatusError, which is harder to decipher, and which
carries less information (namely, not the name of the problematic file).

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14937

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopysmbd: get_nt_acl() raises FileNotFoundError if appropriate
Douglas Bagnall [Wed, 31 Aug 2022 23:25:26 +0000 (11:25 +1200)] 
pysmbd: get_nt_acl() raises FileNotFoundError if appropriate

rather than an NTStatusError, which is harder to decipher, and which
carries less information (namely, not the name of the problematic
file).

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14937

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopysmbd: avoid leaks in get_nt_acl()
Douglas Bagnall [Wed, 31 Aug 2022 23:06:03 +0000 (11:06 +1200)] 
pysmbd: avoid leaks in get_nt_acl()

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14937

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopybindings: xattr_native raises OSError not TypeError
Douglas Bagnall [Wed, 7 Sep 2022 00:56:37 +0000 (12:56 +1200)] 
pybindings: xattr_native raises OSError not TypeError

Most likely it is a bad filename or attribute, not the wrong type of
argument.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14937

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopytest: posixacl getntacl should raise OSError
Douglas Bagnall [Wed, 7 Sep 2022 00:46:42 +0000 (12:46 +1200)] 
pytest: posixacl getntacl should raise OSError

Not TypeError, which is supposed to be about Python data types. This
way we get to check/see an errno and strerror, and will allow us to
set the filename which will be useful for some errors.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopytest: samba-tool ntacl should report errors better
Douglas Bagnall [Wed, 31 Aug 2022 22:29:59 +0000 (10:29 +1200)] 
pytest: samba-tool ntacl should report errors better

We want `samba-tool ntacl sysvolreset` and `samba-tool ntacl
sysvolcheck` to fail when the Policies folder is not in place, but not
to produce an inscrutable stacktrace.

https://bugzilla.samba.org/show_bug.cgi?id=14937

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool domain: use string_to_level helper()
Douglas Bagnall [Wed, 31 Aug 2022 02:40:46 +0000 (14:40 +1200)] 
samba-tool domain: use string_to_level helper()

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org>
Autobuild-Date(master): Tue Sep  6 22:07:23 UTC 2022 on sn-devel-184

3 years agosamba-tool domain: add string_to_level() helper
Douglas Bagnall [Wed, 31 Aug 2022 01:47:45 +0000 (13:47 +1200)] 
samba-tool domain: add string_to_level() helper

Reverse transform of level_to_string(), obviously.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool domain: expand string_version_to_constant range
Douglas Bagnall [Wed, 31 Aug 2022 01:35:57 +0000 (13:35 +1200)] 
samba-tool domain: expand string_version_to_constant range

This won't actually have any effect yet -- the new values are
inaccessible in the place it is used because the range is limited by
the --function-level option config.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool domain show: report level 2016
Douglas Bagnall [Wed, 31 Aug 2022 01:13:20 +0000 (13:13 +1200)] 
samba-tool domain show: report level 2016

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool domain show: use level_to_string()
Douglas Bagnall [Wed, 31 Aug 2022 01:28:50 +0000 (13:28 +1200)] 
samba-tool domain show: use level_to_string()

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool domain: helper function for domain level names
Douglas Bagnall [Wed, 31 Aug 2022 01:12:06 +0000 (13:12 +1200)] 
samba-tool domain: helper function for domain level names

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool ldapcmp: use CommandError on auth failure
Douglas Bagnall [Wed, 17 Aug 2022 23:53:29 +0000 (11:53 +1200)] 
samba-tool ldapcmp: use CommandError on auth failure

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool ldapcmp: use CommandError, not assertion
Douglas Bagnall [Wed, 17 Aug 2022 23:52:54 +0000 (11:52 +1200)] 
samba-tool ldapcmp: use CommandError, not assertion

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool ldapcmp: do not assume common attributes
Douglas Bagnall [Wed, 17 Aug 2022 23:38:35 +0000 (11:38 +1200)] 
samba-tool ldapcmp: do not assume common attributes

This has caused numerous reports of

ERROR(<class 'KeyError'>): uncaught exception - 'serverReferenceBL'
  File /usr/lib/python3/dist-packages/samba/netcmd/__init__.py, line 185, in _run
    return self.run(*args, **kwargs)
  File /usr/lib/python3/dist-packages/samba/netcmd/ldapcmp.py, line 957, in run
    if b1.diff(b2):
  File /usr/lib/python3/dist-packages/samba/netcmd/ldapcmp.py, line 781, in diff
    if object1 == object2:
  File /usr/lib/python3/dist-packages/samba/netcmd/ldapcmp.py, line 549, in __eq__
    return self.cmp_attrs(other)
  File /usr/lib/python3/dist-packages/samba/netcmd/ldapcmp.py, line 590, in cmp_attrs
    if isinstance(self.attributes[x], list) and isinstance(other.attributes[x], list):

because other does not have attribute 'x'.

It is better to assume other.attributes[x] is None, which will compare
as unequal to whatever self.attributes[x] is, showing up as a diff
rather than a crash.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool ldapcmp: use shorter names in cmp_attrs
Douglas Bagnall [Wed, 17 Aug 2022 23:34:53 +0000 (11:34 +1200)] 
samba-tool ldapcmp: use shorter names in cmp_attrs

This simplifies a fix in the next commit.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool ldapcmp: use ValueError, not Exception
Douglas Bagnall [Wed, 17 Aug 2022 23:32:25 +0000 (11:32 +1200)] 
samba-tool ldapcmp: use ValueError, not Exception

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool dns: catch werror.WERR_ACCESS_DENIED
Douglas Bagnall [Wed, 17 Aug 2022 22:58:54 +0000 (10:58 +1200)] 
samba-tool dns: catch werror.WERR_ACCESS_DENIED

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool dns: use DnsconnWrapper in zonecreate
Douglas Bagnall [Sat, 13 Aug 2022 00:55:01 +0000 (12:55 +1200)] 
samba-tool dns: use DnsconnWrapper in zonecreate

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool dns: update_record uses DnsConnWrapper
Douglas Bagnall [Wed, 17 Aug 2022 21:21:39 +0000 (09:21 +1200)] 
samba-tool dns: update_record uses DnsConnWrapper

The special thing about this one is the dns_conn is also used in the
dns_record_match() library function, which wants a real dns
connection.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool dns: delete uses DnsConnWrapper messages
Douglas Bagnall [Fri, 12 Aug 2022 05:17:16 +0000 (17:17 +1200)] 
samba-tool dns: delete uses DnsConnWrapper messages

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool dns: add uses DnsConnWrapper messages
Douglas Bagnall [Fri, 12 Aug 2022 04:51:25 +0000 (16:51 +1200)] 
samba-tool dns: add uses DnsConnWrapper messages

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool dns: query uses DnsConnWrapper messages
Douglas Bagnall [Fri, 12 Aug 2022 04:46:03 +0000 (16:46 +1200)] 
samba-tool dns: query uses DnsConnWrapper messages

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool dns: zonedelete uses DnsConnWrapper messages
Douglas Bagnall [Fri, 12 Aug 2022 04:44:31 +0000 (16:44 +1200)] 
samba-tool dns: zonedelete uses DnsConnWrapper messages

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool dns: NAME_DOES_NOT_EXIST errors; add docstring
Douglas Bagnall [Wed, 17 Aug 2022 05:59:50 +0000 (17:59 +1200)] 
samba-tool dns: NAME_DOES_NOT_EXIST errors; add docstring

In practice, these always refer to zones.

We're adding the docstring now, because it made no sense when
default_messages was empty.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool dns: RECORD_DOES_NOT_EXIST errors as CommandErrors
Douglas Bagnall [Wed, 17 Aug 2022 05:58:50 +0000 (17:58 +1200)] 
samba-tool dns: RECORD_DOES_NOT_EXIST errors as CommandErrors

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool dns: catch ZONE_ALREADY_EXISTS errors as CommandErrors
Douglas Bagnall [Wed, 17 Aug 2022 05:58:03 +0000 (17:58 +1200)] 
samba-tool dns: catch ZONE_ALREADY_EXISTS errors as CommandErrors

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool dns: catch DS_UNAVAILABLE errors as CommandErrors
Douglas Bagnall [Wed, 17 Aug 2022 05:57:16 +0000 (17:57 +1200)] 
samba-tool dns: catch DS_UNAVAILABLE errors as CommandErrors

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool dns: use DnsConnWrapper widely
Douglas Bagnall [Fri, 12 Aug 2022 04:40:03 +0000 (16:40 +1200)] 
samba-tool dns: use DnsConnWrapper widely

This covers all the cases where there are no existing CommandError
messages, and no other uses of the dns_conn (i.e., not cmd_update).

Forthcoming commits will introduce default messages for these.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool dns: add a wrapper for better error messages
Douglas Bagnall [Fri, 12 Aug 2022 04:38:59 +0000 (16:38 +1200)] 
samba-tool dns: add a wrapper for better error messages

This will help turn simple common errors into CommandError messages.

At this stage, no messages are intercepted.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool domain: fix error string for account lockout duration
Douglas Bagnall [Tue, 27 Oct 2020 20:51:06 +0000 (09:51 +1300)] 
samba-tool domain: fix error string for account lockout duration

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool dbcheck: improve --help for --reset-well-known-acls
Douglas Bagnall [Thu, 11 Aug 2022 03:18:02 +0000 (15:18 +1200)] 
samba-tool dbcheck: improve --help for --reset-well-known-acls

This option is for updating from pre-4.0.4 when something went wrong
with ACLs.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=9872

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool domain provision: better message if tdbbackup missing
Douglas Bagnall [Sun, 21 Aug 2022 23:48:53 +0000 (11:48 +1200)] 
samba-tool domain provision: better message if tdbbackup missing

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12893

Reported-by: Jeff Sadowski <jeff.sadowski@gmail.com>
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool: do not force a traceback on CommandError
Douglas Bagnall [Thu, 1 Sep 2022 01:16:53 +0000 (01:16 +0000)] 
samba-tool: do not force a traceback on CommandError

When a CommandError has an 'inner exception', we have been printing
drowning out the error message with a long traceback of the exception
we tried to catch.

People who really want to see tracebacks can use -d3.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool: avoid traceback for NT_STATUS_NETWORK_UNREACHABLE
Douglas Bagnall [Fri, 19 Aug 2022 05:06:48 +0000 (17:06 +1200)] 
samba-tool: avoid traceback for NT_STATUS_NETWORK_UNREACHABLE

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopy/getopt: allow --option arguments to contain '='
Douglas Bagnall [Fri, 19 Aug 2022 04:53:40 +0000 (16:53 +1200)] 
py/getopt: allow --option arguments to contain '='

smb.conf lines can have = on the right hand side. For example, in
st/ad_dc/etc/smb.conf we have 3 examples, including:

 gpo update command = python3 source4/scripting/bin/samba-gpupdate [...] --target=Computer

If we tried to provide the same line via --option, it would split on
both '=', and the set value would end at '--target'.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopy/getopt: improve messages for bad --realm
Douglas Bagnall [Fri, 19 Aug 2022 04:50:54 +0000 (16:50 +1200)] 
py/getopt: improve messages for bad --realm

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agopy/getopt: improve messages for bad --debug arg
Douglas Bagnall [Fri, 19 Aug 2022 04:49:24 +0000 (16:49 +1200)] 
py/getopt: improve messages for bad --debug arg

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool: avoid traceback for options errors
Douglas Bagnall [Thu, 1 Sep 2022 03:32:07 +0000 (15:32 +1200)] 
samba-tool: avoid traceback for options errors

What option? None yet, but see the next two commits.

We use a local reference to optparse.OptionValueError, to save typing
and make the eventual switch to argparse easier.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agosamba-tool: reduce repetitious jargon on credentials failure
Douglas Bagnall [Thu, 18 Aug 2022 22:12:07 +0000 (10:12 +1200)] 
samba-tool: reduce repetitious jargon on credentials failure

We already print the following due to DBG_ERR()s:

  cli_credentials_failed_kerberos_login: krb5_cc_get_principal failed: No such file or directory
  Failed to bind - LDAP error 49 LDAP_INVALID_CREDENTIALS -  <8009030C: LdapErr: DSID-0C0904DC, comment: AcceptSecurityContext error, data 52e, v1db1> <>
  Failed to connect to 'ldap://10.53.57.30' with backend 'ldap': LDAP error 49 LDAP_INVALID_CREDENTIALS -  <8009030C: LdapErr: DSID-0C0904DC, comment: AcceptSecurityContext error, data 52e, v1db1> <>

We don't *really* need to follow that with:

  ERROR(ldb): LDAP connection to ldap://10.53.57.30 failed  - LDAP error 49 LDAP_INVALID_CREDENTIALS -  <8009030C: LdapErr: DSID-0C0904DC, comment: AcceptSecurityContext error, data 52e, v1db1> <>

rather we can say:

  Bad username or password.

Also, we don't really need to print a traceback, which we seem to do
for some commands and not others.

Maybe *sometimes* "bad username or password" might be technically
incorrect (e.g. --simple-bind-dn), but in those cases the user is
already behaving strangely, and they will still see the
LDAP_INVALID_CREDENTIALS twice. Kerberos failures don't come this way.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=9608

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agos4/tests/samba-tool drs showrepl: test NO_COLOR and --color variants
Douglas Bagnall [Wed, 17 Aug 2022 02:28:15 +0000 (14:28 +1200)] 
s4/tests/samba-tool drs showrepl: test NO_COLOR and --color variants

"--color variants" meaning --color=always instead of --color=yes, etc.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
3 years agos4/tests/samba-tool drs showrepl: use vars for common strings
Douglas Bagnall [Wed, 17 Aug 2022 02:26:29 +0000 (14:26 +1200)] 
s4/tests/samba-tool drs showrepl: use vars for common strings

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
3 years agosamba-tool: respect NO_COLOR env variable and --color options
Douglas Bagnall [Tue, 6 Jul 2021 22:43:59 +0000 (10:43 +1200)] 
samba-tool: respect NO_COLOR env variable and --color options

This allows the NO_COLOR environment variable and --color=never to
work for samba-tool commands that use this method. So far that means
some parts of drs showrepl.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
3 years agopy/samba/logger: respect NO_COLOR env variable
Douglas Bagnall [Tue, 6 Jul 2021 22:43:17 +0000 (10:43 +1200)] 
py/samba/logger: respect NO_COLOR env variable

As per https://no-color.org/

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
3 years agopython/colour: helper functions to read all signs
Douglas Bagnall [Wed, 19 Jan 2022 23:32:48 +0000 (12:32 +1300)] 
python/colour: helper functions to read all signs

The accepted hints are presumably arguments to --color.
We follow the behaviour of `ls` in what we accept.

`git` is stricter, accepting only {always,never,auto}.
`grep` is looser accepting mixed case variants.
historically we have used {yes,no,auto}.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
3 years agosamba-tool visualise: expand set of --color switches
Douglas Bagnall [Wed, 17 Aug 2022 01:15:15 +0000 (13:15 +1200)] 
samba-tool visualise: expand set of --color switches

To match convention, and elsewhere.

We can't easily use colour.is_colour_wanted() because we could (via
--output) be intending to write to a file that isn't open yet, so we
have no .isatty() to query.

Also, because --color-scheme implies --color (as documented in
--help), it trumps most 'auto' checks, but not NO_COLOR.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
3 years agopytest/samba-tool visualize: test '--color' aliases
Douglas Bagnall [Tue, 16 Aug 2022 23:50:55 +0000 (11:50 +1200)] 
pytest/samba-tool visualize: test '--color' aliases

By convention, 'tty' is a common alias for 'auto', 'always' and
'force' mean 'yes', and 'never' means no. It seems 'never; and
'always' are more common than 'yes' and 'no'.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
3 years agosamba-tool visualize: remove py2 compat for colour calculations
Douglas Bagnall [Tue, 16 Aug 2022 23:57:00 +0000 (11:57 +1200)] 
samba-tool visualize: remove py2 compat for colour calculations

io.StringIO has .isatty(); the old cStringIO did not,

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
3 years agosamba-tool visualize: respect $NO_COLOR
Douglas Bagnall [Tue, 16 Aug 2022 23:51:40 +0000 (11:51 +1200)] 
samba-tool visualize: respect $NO_COLOR

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
3 years agopytest samba-tool visualize: extend colour tests for $NO_COLOR
Douglas Bagnall [Tue, 16 Aug 2022 02:04:57 +0000 (14:04 +1200)] 
pytest samba-tool visualize: extend colour tests for $NO_COLOR

As described at https://no-color.org/, the NO_COLOR environment
variable is a widely used defacto-ish standard for asking for no
colour. If someone goes

                NO_COLOR=whatever samba-tool ...

we want to assume they want no ANSI colour codes, as if they had used
--color=no. But first we want to test that, so here we are.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
3 years agopytest/samba-tool visualize: fix docstring
Douglas Bagnall [Tue, 16 Aug 2022 23:48:58 +0000 (11:48 +1200)] 
pytest/samba-tool visualize: fix docstring

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
3 years agopytest: SambaToolCmdTest allows easier StringIO replacement
Douglas Bagnall [Sun, 14 Aug 2022 00:08:16 +0000 (12:08 +1200)] 
pytest: SambaToolCmdTest allows easier StringIO replacement

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
3 years agopytests: move ValidNetbiosNameTests to samba.tests.netbios
Douglas Bagnall [Thu, 9 Jun 2022 03:16:44 +0000 (15:16 +1200)] 
pytests: move ValidNetbiosNameTests to samba.tests.netbios

These were the only tests in __init__.py.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
3 years agopytest/samba_tool_drs_no_dns: use TestCaseInTempDir.rm_files/.rm_dirs
Douglas Bagnall [Wed, 15 Jun 2022 01:23:32 +0000 (13:23 +1200)] 
pytest/samba_tool_drs_no_dns: use TestCaseInTempDir.rm_files/.rm_dirs

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
3 years agopytest/samba_tool_drs: use TestCaseInTempDir.rm_files/.rm_dirs
Douglas Bagnall [Wed, 8 Jun 2022 07:53:57 +0000 (19:53 +1200)] 
pytest/samba_tool_drs: use TestCaseInTempDir.rm_files/.rm_dirs

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
3 years agopytest/samdb: use TestCaseInTempDir.rm_files/.rm_dirs
Douglas Bagnall [Wed, 15 Jun 2022 01:22:24 +0000 (13:22 +1200)] 
pytest/samdb: use TestCaseInTempDir.rm_files/.rm_dirs

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
3 years agopytest/join: use TestCaseInTempDir.rm_files/dirs
Douglas Bagnall [Wed, 15 Jun 2022 01:21:16 +0000 (13:21 +1200)] 
pytest/join: use TestCaseInTempDir.rm_files/dirs

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
3 years agopytest/samdb_api: use TestCaseInTempDir.rm_files
Douglas Bagnall [Wed, 15 Jun 2022 01:20:41 +0000 (13:20 +1200)] 
pytest/samdb_api: use TestCaseInTempDir.rm_files

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
3 years agopytest/downgradedatabase: use TestCaseInTempDir.rm_files
Douglas Bagnall [Wed, 15 Jun 2022 01:19:28 +0000 (13:19 +1200)] 
pytest/downgradedatabase: use TestCaseInTempDir.rm_files

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
3 years agopytest: add file removal helpers for TestCaseInTempDir
Douglas Bagnall [Thu, 9 Jun 2022 01:16:31 +0000 (13:16 +1200)] 
pytest: add file removal helpers for TestCaseInTempDir

In several places we end a test by deleting a number of files and
directories, but we do it rather haphazardly with unintentionally
differing error handling. For example, in some tests we currently have
something like:

        try:
            shutil.rmtree(os.path.join(self.tempdir, "a"))
            os.remove(os.path.join(self.tempdir, "b"))
            shutil.rmtree(os.path.join(self.tempdir, "c"))
        except Exception:
            pass

where if, for example, the removal of "b" fails, the removal of "c" will
not be attempted. That will result in the tearDown method raising an
exception, and we're no better off. If the above code is replaced with

        self.rm_files('b')
        self.rm_dirs('a', 'c')

the failure to remove 'b' will cause a test error, *unless* the failure
was due to a FileNotFoundError (a.k.a. an OSError with errno ENOENT),
in which case we ignore it, as was probably the original intention.

If on the other hand, we have

        self.rm_files('b', must_exist=True)
        self.rm_dirs('a', 'c')

then the FileNotFoundError causes a failure (not an error).

We take a little bit of care to stay within self.tempdir, to protect
test authors who accidentally write something like `self.rm_dirs('/')`.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
3 years agonsswitch:libwbclient - fix leak in wbcCtxPingDc2
Andrew Walker [Fri, 2 Sep 2022 20:31:32 +0000 (16:31 -0400)] 
nsswitch:libwbclient - fix leak in wbcCtxPingDc2

Memory allocated for response is never freed.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15164

Signed-off-by: Andrew Walker <awalker@ixsystems.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Sep  6 20:10:17 UTC 2022 on sn-devel-184

3 years agosmbXsrv_client: notify a different node to drop a connection by client guid.
Stefan Metzmacher [Tue, 30 Aug 2022 18:45:50 +0000 (20:45 +0200)] 
smbXsrv_client: notify a different node to drop a connection by client guid.

If a client disconnected all its interfaces and reconnects when
the come back, it will likely start from any ip address returned
dns, which means it can try to connect to a different ctdb node.
The old node may not have noticed the disconnect and still holds
the client_guid based smbd.

Up unil now the new node returned NT_STATUS_NOT_SUPPORTED to
the SMB2 Negotiate request, as messaging_send_iov[_from]() will
return -1/ENOSYS if a file descriptor os passed to a process on
a different node.

Now we tell the other node to teardown all client connections
belonging to the client-guid.

Note that this is not authenticated, but if an attacker can
capture the client-guid, he can also inject TCP resets anyway,
to get the same effect.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15159

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Sep  2 20:59:15 UTC 2022 on sn-devel-184

3 years agosmbXsrv_client: correctly check in negotiate_request.length smbXsrv_client_connection...
Stefan Metzmacher [Tue, 30 Aug 2022 14:56:12 +0000 (16:56 +0200)] 
smbXsrv_client: correctly check in negotiate_request.length smbXsrv_client_connection_pass[ed]_*

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15159

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agos3:tests: add test_smbXsrv_client_cross_node.sh
Stefan Metzmacher [Wed, 31 Aug 2022 12:04:10 +0000 (14:04 +0200)] 
s3:tests: add test_smbXsrv_client_cross_node.sh

This demonstrates that a client-guid connected to ctdb node 0
caused a connection with the same client-guid to be rejected by
ctdb node 1. Node 1 rejects the SMB2 Negotiate with
NT_STATUS_NOT_SUPPORTED, because passing the multi-channel connection
to a different node is not supported.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15159

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agos3:tests: let test_smbXsrv_client_dead_rec.sh cleanup the correct files
Stefan Metzmacher [Wed, 31 Aug 2022 11:55:19 +0000 (13:55 +0200)] 
s3:tests: let test_smbXsrv_client_dead_rec.sh cleanup the correct files

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15159

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agoCleanup and bug fixes in vxfs vfs code.
Saurabh Singh [Thu, 3 Mar 2022 14:13:24 +0000 (19:43 +0530)] 
Cleanup and bug fixes in vxfs vfs code.

1) Added debug messages in lib_vxfs.c for get, set and list attr functions
2) Removed vxfs_clearwxattr_fd and vxfs_clearwxattr_path code since it is no longer required now.
3) Replaced strcasecmp with vxfs_strcasecmp
4) Changed vxfs_fset_xattr to retain security.NTACL attribute
5) Fixed deny permissions not retained for a file created on CIFS share in vxfs_set_xattr

Signed-off-by: Saurabh Singh <saurabh.singh@veritas.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Sep  2 17:40:00 UTC 2022 on sn-devel-184

3 years agos3: torture: Add a comprehensive SMB1 DFS path torture tester.
Jeremy Allison [Tue, 30 Aug 2022 22:26:12 +0000 (15:26 -0700)] 
s3: torture: Add a comprehensive SMB1 DFS path torture tester.

smbtorture3 test is: SMB1-DFS-PATHS

Tests open, and then all 4 methods of renaming/hardlinking
files:

1). SMBmv
2). SMBtrans2 SETPATHINFO
3). SMBtrans2 SETFILEINFO
4). SMBntrename

Also added a test for SMB1findfirst.

smbtorture3 test is: SMB1-DFS-SEARCH-PATHS.

What this shows is that Windows strips off the
SMB1findfirst mask *before* calling the DFS path
parser (smbd currently does not).

Added so we know how to fix the server code to match Windows
behavior in parsing DFS paths in different calls going forward.

Passes fully against Windows. Adds knownfails for smbd.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
3 years agosmbd: Catch streams on non-stream shares
Volker Lendecke [Fri, 2 Sep 2022 09:46:53 +0000 (11:46 +0200)] 
smbd: Catch streams on non-stream shares

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15161

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Fri Sep  2 15:56:56 UTC 2022 on sn-devel-184

3 years agosmbd: return NT_STATUS_OBJECT_NAME_INVALID if a share doesn't support streams
Ralph Boehme [Fri, 2 Sep 2022 10:09:53 +0000 (12:09 +0200)] 
smbd: return NT_STATUS_OBJECT_NAME_INVALID if a share doesn't support streams

This is what a Windows server returns. Tested with a share residing on a FAT
formatted drive, a Windows filesystem that doesn't support streams.

Combinations tested:

  file::$DATA
  file:stream
  file:stream:$DATA

All three fail with NT_STATUS_OBJECT_NAME_INVALID.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15161

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
3 years agosmbtorture: add a test trying to create a stream on share without streams support
Ralph Boehme [Thu, 1 Sep 2022 16:55:23 +0000 (18:55 +0200)] 
smbtorture: add a test trying to create a stream on share without streams support

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15161

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
3 years agotests: Test basic handling of SMB2_CREATE_TAG_POSIX
Volker Lendecke [Wed, 31 Aug 2022 10:38:23 +0000 (12:38 +0200)] 
tests: Test basic handling of SMB2_CREATE_TAG_POSIX

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Fri Sep  2 14:31:25 UTC 2022 on sn-devel-184

3 years agosmbd: Handle SMB2_CREATE_TAG_POSIX at the smb2 layer
Volker Lendecke [Thu, 1 Sep 2022 10:17:44 +0000 (12:17 +0200)] 
smbd: Handle SMB2_CREATE_TAG_POSIX at the smb2 layer

We're not doing anything with this yet, this is just to provide a test
counterpart. Protected by -DDEVELOPER and "smb3 unix extensions = yes"

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Introduce helper var in smbd_smb2_create_fetch_create_ctx()
Volker Lendecke [Wed, 31 Aug 2022 13:37:03 +0000 (15:37 +0200)] 
smbd: Introduce helper var in smbd_smb2_create_fetch_create_ctx()

xconn will be used in another place soon

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agopylibsmb: Add create_ex()
Volker Lendecke [Mon, 29 Aug 2022 15:02:25 +0000 (17:02 +0200)] 
pylibsmb: Add create_ex()

This is an extension of the create() function allowing smb2 create
contexts to be passed back and forth and also returning the
smb_create_returns. A new function seemed necessary for me because we
need to return not just the fnum. So I chose a 3-tuple, see the test
for an example how to use this.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agopylibsmb: Add smb2 create tag strings
Volker Lendecke [Wed, 31 Aug 2022 09:37:54 +0000 (11:37 +0200)] 
pylibsmb: Add smb2 create tag strings

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agotests: Test invalid smb3 unix negotiate contexts
Volker Lendecke [Fri, 26 Aug 2022 14:29:32 +0000 (16:29 +0200)] 
tests: Test invalid smb3 unix negotiate contexts

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agopylibsmb: Allow passing negotiate contexts
Volker Lendecke [Fri, 26 Aug 2022 13:38:04 +0000 (15:38 +0200)] 
pylibsmb: Allow passing negotiate contexts

Pass in a list of tuples with (type, bytes)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agolibsmb: Allow smb2 neg ctx in cli_full_connection_creds_send()
Volker Lendecke [Fri, 26 Aug 2022 12:17:26 +0000 (14:17 +0200)] 
libsmb: Allow smb2 neg ctx in cli_full_connection_creds_send()

Will be used to test smb3 posix contexts

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agotests: Add smb3 posix negotiate tests
Volker Lendecke [Fri, 26 Aug 2022 12:00:28 +0000 (14:00 +0200)] 
tests: Add smb3 posix negotiate tests

Make sure we do and don't announce posix depending on "smb3 unix
extensions" parameter

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agoparam: Add "smb3 unix extensions"
Volker Lendecke [Thu, 25 Aug 2022 14:42:37 +0000 (16:42 +0200)] 
param: Add "smb3 unix extensions"

Only available in DEVELOPER builds. Adding now to get some testing
step by step done.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agopylibsmb: Add "have_posix" function
Volker Lendecke [Thu, 25 Aug 2022 14:28:04 +0000 (16:28 +0200)] 
pylibsmb: Add "have_posix" function

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agopylibsmb: Allow requesting Posix extensions
Volker Lendecke [Thu, 25 Aug 2022 14:27:42 +0000 (16:27 +0200)] 
pylibsmb: Allow requesting Posix extensions

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agolibsmb: Allow to request SMB311 posix in source3/libsmb
Volker Lendecke [Thu, 25 Aug 2022 10:20:26 +0000 (12:20 +0200)] 
libsmb: Allow to request SMB311 posix in source3/libsmb

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbXcli: Detect the SMB311 posix negotiate context
Volker Lendecke [Thu, 25 Aug 2022 13:16:10 +0000 (15:16 +0200)] 
smbXcli: Detect the SMB311 posix negotiate context

The server will only return this if the client requested in via
smbXcli_negprot_send()'s in_ctx parameter. This adds knowledge about
SMB2_CREATE_TAG_POSIX to smbXcli_base.c with a function to query
it. The alternative would have been to detect this in the caller, but
this would have meant that we also would need a
smbXcli_conn_set_have_posix() function or something similar.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Convert store_smb2_posix_info() to use an existing blob
Volker Lendecke [Thu, 1 Sep 2022 12:49:33 +0000 (14:49 +0200)] 
smbd: Convert store_smb2_posix_info() to use an existing blob

Less malloc

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Convert smb2_posix_cc_info() to use an existing blob
Volker Lendecke [Thu, 1 Sep 2022 12:49:33 +0000 (14:49 +0200)] 
smbd: Convert smb2_posix_cc_info() to use an existing blob

Less malloc

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agosmbd: Introduce "conn" helper var in smbd_smb2_create_after_exec()
Volker Lendecke [Thu, 1 Sep 2022 12:46:39 +0000 (14:46 +0200)] 
smbd: Introduce "conn" helper var in smbd_smb2_create_after_exec()

Will be used more in the future

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
3 years agos3/winbindd: Fix bad access to sid array (with debug level >= info)
Noel Power [Wed, 31 Aug 2022 11:27:53 +0000 (12:27 +0100)] 
s3/winbindd: Fix bad access to sid array (with debug level >= info)

==6436==    at 0xA85F95B: dom_sid_string_buf (dom_sid.c:444)
==6436==    by 0xA85FBF2: dom_sid_str_buf (dom_sid.c:515)
==6436==    by 0x17EDF8: wb_lookupusergroups_recv (wb_lookupusergroups.c:115)
==6436==    by 0x17F964: wb_gettoken_gotgroups (wb_gettoken.c:123)
==6436==    by 0x56AD332: _tevent_req_notify_callback (tevent_req.c:141)
==6436==    by 0x56AD493: tevent_req_finish (tevent_req.c:193)
==6436==    by 0x56AD5C0: tevent_req_trigger (tevent_req.c:250)
==6436==    by 0x56AC119: tevent_common_invoke_immediate_handler (tevent_immediate.c:190)
==6436==    by 0x56AC268: tevent_common_loop_immediate (tevent_immediate.c:236)
==6436==    by 0x56B678A: epoll_event_loop_once (tevent_epoll.c:919)
==6436==    by 0x56B31C3: std_event_loop_once (tevent_standard.c:110)
==6436==    by 0x56AA621: _tevent_loop_once (tevent.c:825)
==6436==
==6436== Invalid read of size 1
==6436==    at 0xA85F95B: dom_sid_string_buf (dom_sid.c:444)
==6436==    by 0xA85FBF2: dom_sid_str_buf (dom_sid.c:515)
==6436==    by 0x17EDF8: wb_lookupusergroups_recv (wb_lookupusergroups.c:115)
==6436==    by 0x17F964: wb_gettoken_gotgroups (wb_gettoken.c:123)
==6436==    by 0x56AD332: _tevent_req_notify_callback (tevent_req.c:141)
==6436==    by 0x56AD493: tevent_req_finish (tevent_req.c:193)
==6436==    by 0x56AD5C0: tevent_req_trigger (tevent_req.c:250)
==6436==    by 0x56AC119: tevent_common_invoke_immediate_handler (tevent_immediate.c:190)
==6436==    by 0x56AC268: tevent_common_loop_immediate (tevent_immediate.c:236)
==6436==    by 0x56B678A: epoll_event_loop_once (tevent_epoll.c:919)
==6436==    by 0x56B31C3: std_event_loop_once (tevent_standard.c:110)
==6436==    by 0x56AA621: _tevent_loop_once (tevent.c:825)

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15160
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Aug 31 15:07:31 UTC 2022 on sn-devel-184

3 years agos3: torture: Add a comprehensive SMB2 DFS path torture tester.
Jeremy Allison [Mon, 29 Aug 2022 21:37:35 +0000 (14:37 -0700)] 
s3: torture: Add a comprehensive SMB2 DFS path torture tester.

Passes fully against Windows.

This shows that DFS paths on Windows on SMB2 must
be of the form:

SERVER\SHARE\PATH

but the actual contents of the strings SERVER and
SHARE don't need to match the given server or share.

The algorithm the Windows server uses is the following:

Look for a '\\' character, and assign anything before
that to the SERVER component. The characters in this
component are not checked for validity.

Look for a second '\\' character and assign anything
between the first and second '\\' characters to the
SHARE component. The characters in the share component
are checked for validity, but only ':' is flagged as
an illegal sharename character despite what:

[MS-FSCC] https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/dc9978d7-6299-4c5a-a22d-a039cdc716ea

says.

Anything after the second '\\' character is assigned
to the PATH component and becomes the share-relative
path.

If there aren't two '\\' characters it removes
everything and ends up with the empty string as
the share relative path.

To give some examples, the following pathnames all map
to the directory at the root of the DFS share:

SERVER\SHARE
SERVER
""
ANY\NAME
ANY
::::\NAME

the name:

SERVER\:

is illegal (sharename contains ':') and the name:

ANY\NAME\file

maps to a share-relative pathname of "file",
despite "ANY" not being the server name, and
"NAME" not being the DFS share name we are
connected to.

Adds a knownfail for smbd as our current code
in parse_dfs_path() is completely incorrect
here and tries to map "incorrect" DFS names
into local paths. I will work on fixing this
later, but we should be able to remove parse_dfs_path()
entirely and move the DFS pathname logic before
the call to filename_convert_dirfsp() in the
same way Volker suggested and was able to achieve
for extract_snapshot_token() and the @GMT pathname
processing.

Also proves the "target" paths for SMB2_SETINFO
rename and hardlink must *not* be DFS-paths.

Next I will work on a torture tester for SMB1
DFS paths.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reivewed-by: Noel Power <npower@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Aug 30 17:10:33 UTC 2022 on sn-devel-184

3 years agosmbd: fix opening a READ-ONLY file with SEC_FLAG_MAXIMUM_ALLOWED
Ralph Boehme [Fri, 19 Aug 2022 10:02:43 +0000 (12:02 +0200)] 
smbd: fix opening a READ-ONLY file with SEC_FLAG_MAXIMUM_ALLOWED

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14215

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Aug 29 18:20:20 UTC 2022 on sn-devel-184

3 years agosmbd: cache DOS attributes in struct smb_filename.cached_dos_attributes
Ralph Boehme [Wed, 24 Aug 2022 09:40:41 +0000 (11:40 +0200)] 
smbd: cache DOS attributes in struct smb_filename.cached_dos_attributes

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14215

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: update smb_fname->st btime with the rounded value with NTTIME granularity
Ralph Boehme [Sun, 21 Aug 2022 11:39:02 +0000 (13:39 +0200)] 
smbd: update smb_fname->st btime with the rounded value with NTTIME granularity

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14215

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbd: remove const from smb_fname arg of set_ea_dos_attribute()
Ralph Boehme [Sun, 21 Aug 2022 11:38:16 +0000 (13:38 +0200)] 
smbd: remove const from smb_fname arg of set_ea_dos_attribute()

We need to update the btime of fsp->fsp_name->st.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14215

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbtorture: add a test opening a READ-ONLY file with SEC_FLAG_MAXIMUM_ALLOWED
Ralph Boehme [Fri, 19 Aug 2022 09:01:31 +0000 (11:01 +0200)] 
smbtorture: add a test opening a READ-ONLY file with SEC_FLAG_MAXIMUM_ALLOWED

Passes against Windows, currently fails against Samba.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14215
RN: Requesting maximum allowed permission of file with DOS read-only attribute results in access denied error

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbtorture: turn maximum_allowed test into a test suite
Ralph Boehme [Fri, 19 Aug 2022 08:45:10 +0000 (10:45 +0200)] 
smbtorture: turn maximum_allowed test into a test suite

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14215

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agosmbtorture: close handle and delete file in tree_base()
Ralph Boehme [Sun, 21 Aug 2022 16:55:29 +0000 (18:55 +0200)] 
smbtorture: close handle and delete file in tree_base()

Otherwise the session might still be around with the open handle when the next
test starts and then fails to delete the testfile.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14215

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
3 years agos3: smbd: parse_dfs_path() - Fix comment explaining where this is called from and...
Jeremy Allison [Thu, 18 Aug 2022 05:51:26 +0000 (22:51 -0700)] 
s3: smbd: parse_dfs_path() - Fix comment explaining where this is called from and with what kind of path.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sun Aug 28 20:58:57 UTC 2022 on sn-devel-184

3 years agos3: smbd: Remove allow_broken_path parameter from parse_dfs_path().
Jeremy Allison [Thu, 11 Aug 2022 04:52:34 +0000 (21:52 -0700)] 
s3: smbd: Remove allow_broken_path parameter from parse_dfs_path().

Nothing now looks at it.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>