1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-07 17:18:11 +03:00
Commit Graph

80 Commits

Author SHA1 Message Date
Andrew Bartlett
58fe4d9c20 Refactor the NTLMSSP code again - this time we use function pointers to
eliminate the dependency on the auth subsystem.  The next step is to add
the required code to 'ntlm_auth', for export to Squid etc.

Andrew Bartlett
(This used to be commit 9e48ab86da)
2003-01-15 12:52:38 +00:00
Andrew Bartlett
e3293c7181 Updates to our NTLMSSP code:
This tries to extract our server-side code out of sessetup.c, and into a more
general lib.  I hope this is only a temporay resting place - I indend to
refactor it again into an auth-subsystem independent lib, using callbacks.

Move some of our our NTLMSSP #defines into a new file, and add two that I found
in the COMsource docs - we seem to have a double-up, but I've verified from
traces that the NTLMSSP_TARGET_TYPE_{DOMAIN,SERVER} is real.

This code also copes with ASCII clients - not that we will ever see any here,
but I hope to use this for HTTP, were we can get them.  Win2k authenticates
fine under forced ASCII, btw.

Tested with Win2k, NTLMv2 and Samba's smbclient.

Andrew Bartlett
(This used to be commit b6641badcb)
2003-01-13 12:48:37 +00:00
Andrew Bartlett
674c750df7 No point having this for both parts of the 'if' statement.
Andrew Bartlett
(This used to be commit 3b2e5f68cd)
2003-01-11 03:23:16 +00:00
Jeremy Allison
1afa539299 pstring/fstring missmatches found by Andrew Bartlett.
Jeremy.
(This used to be commit 585a73b810)
2003-01-02 20:43:27 +00:00
Andrew Tridgell
18e55a69ff a better for for using %U in smb.conf
this follows the method used for remote_machine and also fixes the
problem of anonymous connections clobbering the string
(This used to be commit 9ead4fc3c3)
2002-11-19 23:44:24 +00:00
Jeremy Allison
250c980119 Removed global_myworkgroup, global_myname, global_myscope. Added liberal
dashes of const. This is a rather large check-in, some things may break.
It does compile though :-).
Jeremy.
(This used to be commit 82b8f749a3)
2002-11-12 23:15:52 +00:00
Andrew Bartlett
d386b71d32 Metze claims that without this his win2k server gets horribly confused looking
for all sorts of AD things in lp_realm().  We need to get some non-Win2k
NTLMSSP and chase this up a bit, but this will do for now.

(Hmm, this might affect NTLMv2 as well)

Andrew Bartlett
(This used to be commit 0e6babc306)
2002-09-25 12:09:56 +00:00
Andrew Bartlett
8a3bb8b36b Kill of Get_Pwnam_Modify and smb_getpwnam(). The latter assumes some things
that just don't apply any more - now that we always keep username and domain
seperate.  Also, the policy it was trying to permit is now implemented by the
auth code.

Andrew Bartlett
(This used to be commit 760c0740ca)
2002-09-25 09:55:41 +00:00
Jeremy Allison
e633122fae "@" is valid in NetBIOS domain names.
Jeremy.
(This used to be commit 5c4857d8e0)
2002-09-20 19:09:28 +00:00
Andrew Bartlett
789d51b42c This is the 'easy' parts of the trusted domains patch n+3 patch from
Rafal Szczesniak <mimir@diament.ists.pwr.wroc.pl>

It includes a conversion of make_user_info*() to NTSTATUS and some minor
changes to other files.

It also picks up on a nasty segfault that can occour in some security=domain
cases.

Andrew Bartlett
(This used to be commit d1e1fc3e4b)
2002-09-06 13:37:11 +00:00
Andrew Bartlett
a92724025a Revert accidental commit - I'll need to do a fair bit more testing before I
commit changes to NTLMSSP flags.
(This used to be commit d200770796)
2002-09-06 11:49:16 +00:00
Andrew Bartlett
eec38ee3bb Patch from "Stefan (metze) Metzmacher" <metze@metzemix.de>
to extend the ADS_STATUS system to include NTSTATUS, and to provide a better
general infrustructure for his sam_ads work.

I've also added some extra failure mode DEBUG()s to parts of the code.

NOTE:  The ADS_ERR_OK() macro is rather sensitive to braketing issues - without
the final set of brakets, the test is essentially inverted - causing some
intersting 'error = success' messages...

Andrew Bartlett
(This used to be commit 5b9a7ab901)
2002-09-06 11:46:59 +00:00
Andrew Bartlett
7aca67c3e9 Add a bit of 'const' and move a lot of our 'repeditive' DEBUG() statements to
'DEBUGADD', so we don't repeat headers.  (Makes them much easier to read).

(Based on patch by kai)

Andrew Bartlett
(This used to be commit 9deada345c)
2002-08-31 06:59:00 +00:00
Andrew Bartlett
8674440d81 Based orginally by work by Kai, this patch moves our NT_TOKEN generation into
our authenticaion code - removing some of the duplication from the current
code.

This also gets us *much* closer to supporting a real SAM backend, becouse the
SAM can give us the right info then.

This also changes our service.c code, so that we do a VUID (rather than uid)
cache on the connection struct, and do full NT ACL/NT_TOKEN checks (or cached
equivilant) on every packet, for the same r or rw mode the whole share was open
for.

Andrew Bartlett
(This used to be commit d8122cee05)
2002-08-20 01:54:28 +00:00
Andrew Bartlett
8f5f2eb454 Change which session key we negotiate. This uses the NT-based session key that
we previously expected, rather than the LM based key.

A Win2k SPNEGO enabled join goes a *lot* further with this option on.

Andrew Bartlett
(This used to be commit b224938e4e)
2002-08-17 07:31:54 +00:00
Jim McDonough
51f62926b3 Re-add the last empty item to the NTLMSSP info list, but this time do it
with an empty string, not a NULL pointer...

Also, check for security=ads before giving a kerberos spnego response.
(This used to be commit 6eca417d1c)
2002-08-16 08:09:55 +00:00
Andrew Bartlett
54e964a0fb Fix segfault in the new NTLMSSP code. jmcd: can you look at this - what
exactly were you trying to do here?

Andrew Bartlett
(This used to be commit 81b675b54d)
2002-08-16 07:04:37 +00:00
Jim McDonough
ec7927a144 Fix NTLMSSP challenge command and auth response. We can now service joins
from win2k AND still use SPNEGO (provided you don't build with kerberos...I
still have to fix that, as we are not properly falling back).
(This used to be commit 1f9b3d46c7)
2002-08-15 12:18:25 +00:00
Andrew Bartlett
dd5615c042 Make 'remote_machine' private to lib/substitute.c, and fix all the user to use
the new accessor functions.

Andrew Bartlett
(This used to be commit f393de2310)
2002-08-11 02:30:35 +00:00
Andrew Bartlett
6ddba1e99b Fix the %m security bug again - and try to make it harder to reintroduce in
future.

This moves us from fstrcpy() and global variables to 'get' and 'set' functions.

In particular, the 'set' function sainity-checks the input, in the same way as
we always have.

Andrew Bartlett
(This used to be commit e57a896f06)
2002-08-10 23:20:04 +00:00
Andrew Tridgell
ab9ff0fa73 This fixes a number of ADS problems, particularly with netbiosless
setups.

- split up the ads structure into logical pieces. This makes it much
  easier to keep things like the authentication realm and the server
  realm separate (they can be different).

- allow ads callers to specify that no sasl bind should be performed
(used by "net ads info" for example)

- fix an error with handing ADS_ERROR_SYSTEM() when errno is 0

- completely rewrote the code for finding the LDAP server. Now try DNS
  methods first, and try all DNS servers returned from the SRV DNS
  query, sorted by closeness to our interfaces (using the same sort code
  as we use in replies from WINS servers). This allows us to cope with
  ADS DCs that are down, and ensures we don't pick one that is on the
  other side of the country unless absolutely necessary.

- recognise dnsRecords as binary when displaying them

- cope with the realm not being configured in smb.conf (work it out
  from the LDAP server)

- look at the trustDirection when looking up trusted domains and don't
  include trusts that trust our domains but we don't trust
  theirs.

- use LDAP to query the alternate (netbios) name for a realm, and make
  sure that both and long and short forms of the name are accepted by
  winbindd. Use the short form by default for listing users/groups.

- rescan the list of trusted domains every 5 minutes in case new trust
  relationships are added while winbindd is running

- include transient trust relationships (ie. C trusts B, B trusts A,
  so C trusts A) in winbindd.

- don't do a gratuituous node status lookup when finding an ADS DC (we
  don't need it and it could fail)

- remove unused sid_to_distinguished_name function

- make sure we find the allternate name of our primary domain when
  operating with a netbiosless ADS DC (using LDAP to do the lookup)

- fixed the rpc trusted domain enumeration to support up to approx
  2000 trusted domains (the old limit was 3)

- use the IP for the remote_machine (%m) macro when the client doesn't
  supply us with a name via a netbios session request (eg. port 445)

- if the client uses SPNEGO then use the machine name from the SPNEGO
  auth packet for remote_machine (%m) macro

- add new 'net ads workgroup' command to find the netbios workgroup
  name for a realm
(This used to be commit e358d7b24c)
2002-08-05 02:47:46 +00:00
Andrew Tridgell
a4e3bdbbee make sure we null terminate plaintext passwords
(This used to be commit cf2abf677e)
2002-08-01 03:38:21 +00:00
Andrew Bartlett
2307a6f504 Rework parinioa to ensure we never get passwords longer than MAX_PASS_LEN, nor
longer than the buffer they claim to be in.

Many thanks to tridge for explaining the macros.

Andrew Bartlett
(This used to be commit 3efd462bf2)
2002-07-31 11:57:56 +00:00
Andrew Tridgell
f5a85fe247 fixed the length checking for plaintext passwords (thanks to andrewb
for spotting this)
(This used to be commit d4c905e5a0)
2002-07-31 10:47:26 +00:00
Andrew Tridgell
9edc1cd4cf this fixes plaintext passwords with win2000
there were 2 bugs:

1) we were sending a null challenge when we should have sent an empty
   challenge

2) the password can be in unicode if unicode is negotiated. This means
   our client code was wrong too :(
(This used to be commit 1a6dfddf67)
2002-07-30 15:03:14 +00:00
Jeremy Allison
b5053d0a5f Removed some unused variables - tidy up some formating, add struct to
client state to implement smb signing - this is a test at present.
Jeremy.
(This used to be commit a234e30355)
2002-05-31 22:18:07 +00:00
Andrew Bartlett
069e6fb9eb Add support for NTLMv2 (tested!) with NTLMSSP.
The problem was the NTLMv2 uses extra data in order to make reply/lookup
more difficult.  That extra data includes the hostname, and the domain.

This matches Win2k (sort of) by sending this information.

Win2k connects with LMCompatibilityLevel=5 without a problem.

We can change the negotiation bits if we want, this should allow us to make
NTLMv2 the default for other clients as well.

Some of the extra #defines were found in the squid source.

Andrew Bartlett
(This used to be commit 17a5f67b3d)
2002-05-26 14:59:57 +00:00
Andrew Tridgell
c0a9919430 fixed the fallback to a BDC for ADS connections
(This used to be commit 3e58a1ee83)
2002-04-18 06:56:44 +00:00
Andrew Tridgell
e7b729e0d9 make sure we don't walk past the end of the current SMB buffer when
pulling a string
this might explain a serious filename corruption bug that Quantum QA spotted
(This used to be commit a877eae24b)
2002-04-16 06:15:28 +00:00
Andrew Tridgell
a99e810bda it looks like it is possible for a w2k client to send a spnego auth without sending the negotiate - try to cope
(This used to be commit 95278aa41f)
2002-04-14 09:00:05 +00:00
Tim Potter
cd68afe312 Removed version number from file header.
Changed "SMB/Netbios" to "SMB/CIFS" in file header.
(This used to be commit 6a58c9bd06)
2002-01-30 06:08:46 +00:00
Andrew Bartlett
c311d24ce3 A nice *big* change to the fundemental way we do things.
Samba (ab)uses the returns from getpwnam() a lot - in particular it keeps
them around for a long time - often past the next call...

This adds a getpwnam_alloc and a getpwuid_alloc to the collection.

These function as expected, returning a malloced structure that can be
free()ed with passwd_free(&passwd).

This patch also cuts down on the number of calls to getpwnam - mostly by
taking advantage of the fact that the passdb interface is already
case-insensiteve.

With this patch most of the recursive cases have been removed (that I know
of) and the problems are reduced further by not using the sys_ interface
in the new code.  This means that pointers to the cache won't be affected.
(This is a tempoary HACK, I intend to kill the password cache entirly).

The only change I'm a little worried about is the change to
rpc_server/srv_samr_nt.c for private groups.  In this case we are getting
groups from the new group mapping DB.  Do we still need to check for private
groups?  I've toned down the check to a case sensitve match with the new code,
but we might be able to kill it entirly.

I've also added a make_modifyable_passwd() function, that copies a passwd
struct into the form that the old sys_getpw* code provided.  As far as I can
tell this is only actually used in the pass_check.c crazies, where I moved
the final 'special case' for shadow passwords (out of _Get_Pwnam()).

The matching case for getpwent() is dealt with already, in lib/util_getent.c

Also included in here is a small change to register the [homes] share at vuid
creation rather than just in one varient of the session setup.  (This picks
up the SPNEGO cases).  The home directory is now stored on the vuid, and I
am hoping this might provide a saner way to do %H substitions.

TODO:  Kill off remaining Get_Pwnam_Modify calls (they are not needed), change
the remaining sys_getpwnam() callers to use getpwnam_alloc() and move
Get_Pwnam to return an allocated struct.

Andrew Bartlett
(This used to be commit 1d86c7f942)
2002-01-17 08:45:58 +00:00
Andrew Bartlett
5047a66d39 Back out the crazy notion that the NTLMSSP flags actually mean anything...
Replace this with some flags that *we* define.  We can do a mapping later
if we actually get some more reliable info about what passwords are actually
valid.

Andrew Bartlett
(This used to be commit 7f7a42c3e4)
2002-01-11 05:29:09 +00:00
Martin Pool
f5bc0e92a6 Better explanation message for dmalloc.
Also more insertion of parenthesis to handle struct members called
'free'.

You can now get useful dmalloc output, as long as it is compatible
with your C library.  On RH7.1 it looks like you have to rebuild
dmalloc to allow free(0) by default, because something in libcrypt
does that. (sigh)
(This used to be commit 391cbb6901)
2002-01-09 07:52:51 +00:00
Andrew Bartlett
b8b228d961 Get this code back to where it belongs...
Apparently (and I will doublecheck) its legal to do an annoymous session setup
when we negoitiated SPNEGO, but we can't do an authenticated one becouse we
didn't give a challange.

Andrew Bartlett
(This used to be commit 08a5c5bf94)
2002-01-06 01:37:14 +00:00
Andrew Bartlett
b283dba09d Some more SPNEGO fixes.
(This used to be commit 0e564cb32a)
2002-01-06 00:49:23 +00:00
Andrew Bartlett
341f87090b Fix up the SPNEGO segfault.
(This used to be commit 17b1c83dd0)
2002-01-05 12:04:33 +00:00
Andrew Bartlett
2e28f8ff0e I've decided to move the auth code around a bit more...
The auth_authsupplied_info typedef is now just a plain struct - auth_context,
but it has been modified to contain the function pointers to the rest
of the auth subsystem's components.

(Who needs non-static functions anyway?)

In working all this mess out, I fixed a number of memory leaks and moved the
entire auth subsystem over to talloc().

Note that the TALLOC_CTX attached to the auth_context can be rather long-lived,
it is provided for things that are intended to live as long.  (The
global_negprot_auth_context lasts the whole life of the smbd).

I've also adjusted a few things in auth_domain.c, mainly passing the domain as
a paramater to a few functions instead of looking up lp_workgroup().  I'm
hopign to make this entire thing a bit more trusted domains (as PDC) freindly
in the near future.

Other than that, I moved a bit of the code around, hence the rather messy diff.

Andrew Bartlett
(This used to be commit 12f5515f55)
2002-01-05 04:55:41 +00:00
Jeremy Allison
4178f211d1 debug statement fixups.
Merge SAFE_FREE fix in tdb from 2.2, and IRIX fix.
Jeremy.
(This used to be commit eb66074665)
2002-01-02 23:28:55 +00:00
Andrew Tridgell
eb4e101153 - portablitity fixes for cc -64 on irix
- fixed gid* bug in rpc_server
(This used to be commit 48aa90c48c)
2001-12-31 13:46:26 +00:00
Andrew Tridgell
9eebd31e2c check for a winbindd username when doing a kerberos auth
(This used to be commit 39f2e2e162)
2001-12-20 23:36:39 +00:00
Andrew Tridgell
01a382480a don't use server_info after its been freed
(This used to be commit ee161a5728)
2001-12-20 09:32:03 +00:00
Andrew Tridgell
1a242b6fd9 support "map to guest" with spnego
(This used to be commit e873d0ff1e)
2001-12-20 09:06:53 +00:00
Andrew Tridgell
9126a40e2c added trusted realm support to ADS authentication
the method used for checking if a domain is a trusted domain is very
crude, we should really call a backend fn of some sort. For now I'm
using winbindd to do the dirty work.
(This used to be commit adf44a9bd0)
2001-12-19 09:53:30 +00:00
Andrew Bartlett
9220fd730c Ensure that 'use spnego' restricts, rather than just advises our clients.
This means that if a hole is found in the spnego code, we can tell people
to just set 'use spengo' in their config file while we sort it out.

Other than that, preventing 'unusual' behaviour is always a good thing.

Andrew Bartlett
(This used to be commit a8a53c08f7)
2001-12-08 02:12:17 +00:00
Andrew Bartlett
3f387d1971 Ensure we fill in the %U for NTLMSSP connections
(This used to be commit d15ea4fa8e)
2001-12-05 10:50:26 +00:00
Andrew Tridgell
9421ad4a7a added a REALLY gross hack into kerberos_kinit_password so that
winbindd can do a kinit
this will be removed once we have code that gets a tgt
and puts it in a place where cyrus-sasl can see it
(This used to be commit 7d94f1b736)
2001-12-05 09:46:53 +00:00
Andrew Bartlett
fe64484824 Make better use of the ads_init() function to get the kerberos relam etc.
This allows us to use automagically obtained values in future, and the value
from krb5.conf now.

Also fix mem leaks etc.

Andrew Bartlett
(This used to be commit 8f9ce71781)
2001-11-29 06:21:56 +00:00
Andrew Tridgell
f6b962fba3 fixed some krb5 ifdefs
(This used to be commit 23ef22f117)
2001-11-28 23:54:07 +00:00
Andrew Tridgell
67b3473780 fixed another memory leak
(This used to be commit 37aa2873e5)
2001-11-27 03:54:15 +00:00