1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-04 05:18:06 +03:00
Commit Graph

160 Commits

Author SHA1 Message Date
Tim Potter
1f007d3ed4 Renamed get_nt_error_msg() to nt_errstr(). 0001-01-01 00:00:00 +00:00
Andrew Bartlett
f81882fc95 Ensure we never use "" as a domain name (Win9X apparently does this for 'net use' duirng login).
Picked up from a post to a TNG list by Volker.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
ac8c24a9a8 Allow Samba to trust NT4 Domains.
This commit builds on the auth subsystem to give Samba support for trusting NT4
domains.  It is off by default, but is enabled by adding 'trustdomain' to the
'auth methods' smb.conf paramater.

Tested against NT4 only - there are still some issues with the join code for
Win2k servers (spnego stuff).

The main work TODO involves enumerating the trusted domains (including the RPC
calls to match), and getting winbind to run on the PDC correctly.

Similarly, work remains on getting NT4 to trust Samba domains.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
0242d0e178 SECURITY FIXES:
Remove a stray 'unbecome_root()' in the ntdomain an auth failure case.

Only allow trust accounts to request a challange in srv_netlogon_nt.c.
Currently any user can be the 'machine' for the domain logon.  MERGE for 2.2.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
3bf4b42771 Various comment fixes from Rafal Szczesniak <mimir@diament.ists.pwr.wroc.pl> 0001-01-01 00:00:00 +00:00
Jeremy Allison
8ed49fe0df Ensure that winbindd and smbd both use identical logic to find dc's.
Fix bug where zeroip addresses were being checked.
Jeremy.
0001-01-01 00:00:00 +00:00
Andrew Bartlett
339e3982bc "user doesn't exist" isn't worthy of a level 1 debug. Make it level 3. 0001-01-01 00:00:00 +00:00
Andrew Tridgell
eb196070e6 serialise all domain auth requests
this is needed because W2K will send a TCP reset to any open
connections that have not done a negprot when a second connection is
made. This meant that under heavy netlogon load a Samba domain member
would fail authentications.

Jeremy, you may wish to port this to 2.2.x
0001-01-01 00:00:00 +00:00
Andrew Bartlett
6c08c233e6 Fix use of uninitialsed variable in PAM code 0001-01-01 00:00:00 +00:00
Andrew Bartlett
dc1a72f896 Drastic impromvents to pam_winbind.
This adds code to do generic PAM -> NTSTATUS and NTSTATUS -> PAM error
conversions, and uses them to make the error handling in pam_winbind sane.

In particular, pam_winbind now uses PAM error codes, not silly '-1, -2 ...'
stuff, and logs the NTSTATUS error that winbind now sends over the pipe.

Added code to wbinfo to display these - makes a big difference in debugging
winbindd.

The main change here is the code to allow pam_winbind password changing to
correctly stack - This code ripped from pam_unix, and the copyright attached.
(Same as for all pam modules, including pam_winbind)

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Tim Potter
6a58c9bd06 Removed version number from file header.
Changed "SMB/Netbios" to "SMB/CIFS" in file header.
0001-01-01 00:00:00 +00:00
Andrew Bartlett
554842e0a5 Fix up a security issue with the way we handle domain groups retuned on the
info3.  These are RIDs, and it only makes sense to combine them with the domain
SID returned with them.  This is important for trusted domains, where that sid
might be other than the one we currently reterive from the secrets.tdb.

Also remove the become_root()/unbecome_root() wrapper from around both
remaining TDB users:  Both are now initialised at smbd startup.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
c796799afd Bring auth_winbind into line with the protocol changes
Andrew Bartlett
0001-01-01 00:00:00 +00:00
Tim Potter
b61e40a5be Remove check for passwordserver = "*" as we now initialise it.
Added TODO about perhaps doing a SAMLOGON udp/138 request before a
cli_full_connection in connect_to_domain_password_server()
0001-01-01 00:00:00 +00:00
Tim Potter
e67c7c5852 Spelling fixes. 0001-01-01 00:00:00 +00:00
Andrew Bartlett
ff354c99c5 This is another *BIG* change...
Samba now features a pluggable passdb interface, along the same lines as the
one in use in the auth subsystem.  In this case, only one backend may be active
at a time by the 'normal' interface, and only one backend per passdb_context is
permitted outside that.

This pluggable interface is designed to allow any number of passdb backends to
be compiled in, with the selection at runtime.  The 'passdb backend' paramater
has been created (and documented!) to support this.

As such, configure has been modfied to allow (for example) --with-ldap and the
old smbpasswd to be selected at the same time.

This patch also introduces two new backends:  smbpasswd_nua and tdbsam_nua.
These two backends accept 'non unix accounts', where the user does *not* exist
in /etc/passwd.  These accounts' don't have UIDs in the unix sense, but to
avoid conflicts in the algroitmic mapping of RIDs, they use the values
specified in the 'non unix account range' paramter - in the same way as the
winbind ranges are specifed.

While I was at it, I cleaned up some of the code in pdb_tdb (code copied
directly from smbpasswd and not really considered properly).  Most of this was
to do with % macro expansion on stored data.  It isn't easy to get the macros
into the tdb, and the first password change will 'expand' them.  tdbsam needs
to use a similar system to pdb_ldap in this regard.

This patch only makes minor adjustments to pdb_nisplus and pdb_ldap, becouse I
don't have the test facilities for these.  I plan to incoroprate at least
pdb_ldap into this scheme after consultation with Jerry.

Each (converted) passdb module now no longer has any 'static' variables, and
only exports 1 init function outside its .c file.

The non-unix-account support in this patch has been proven!  It is now possible
to join a win2k machine to a Samba PDC without an account in /etc/passwd!

Other changes:

Minor interface adjustments:
pdb_delete_sam_account() now takes a SAM_ACCOUNT, not a char*.

pdb_update_sam_account() no longer takes the 'override' argument that was being
ignored so often (every other passdb backend).  Extra checks have been added in
some places.

Minor code changes:
smbpasswd no longer attempts to initialise the passdb at startup, this is
now done on first use.

pdbedit has lost some of its 'machine account' logic, as this behaviour is now
controlled by the passdb subsystem directly.

The samr subsystem no longer calls 'local password change', but does the pdb
interactions directly.  This allow the ACB_ flags specifed to be transferred
direct to the backend, without interference.

Doco:

I've updated the doco to reflect some of the changes, and removed some paramters
no longer applicable to HEAD.
0001-01-01 00:00:00 +00:00
Andrew Bartlett
9e96f43805 Add a touch of 'const' to some auth components, and move the simple plaintext
password check into its own helper funciton.  (This will allow it to be called
from other places).

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
9bfe54a3d4 Don't do tridge's crazy 'am I a trusted domain' lookup for guests.
Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
1d86c7f942 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
0001-01-01 00:00:00 +00:00
Andrew Bartlett
5b4079f748 Commit the auth associated changes I missed from the last commit.
Also set the default value of all the allocated strings to "" to avoid changing
the interface (becouse pdb_get...() would point to a null string, rather than a
null pointer and parts of samba rely on that).

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
37ce763043 Fix a segfault in auth/auth_domain.c error cases.
This occured when the attempt to contact the PDC failed.  The connection code
has already shut down the connection, and 'free'ed the cli or has never
initialised it in the first place.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
80c2aefbe7 Many thanks to Alexander Bokovoy <a.bokovoy@sam-solutions.net>.
This work was sponsored by Optifacio Software Services, Inc.

Andrew Bartlett

(various e-mails announcements merged into some form of commit message below:)

This patch which adds basics of universal groups support
into Samba 3. Currently, only Winbind with RPC calls supports this, ADS
support requires additional (possibly huge) work on KRB5 PAC. However,
basic infrastructure is here.

This patch adds:

1. Storing of universal groups for particular user logged into Samba
software (smbd/ two winbind-pam methods) into netlogon_unigrp.tdb as array
of uint32 supplemental group rids keyed as DOMAIN_SID/USER_RID in tdb.

2. Fetching of unversal groups for given user rid and domain sid from
netlogon_unigrp.tdb.

Since this is used in both smbd and winbindd, main code is in
source/lib/netlogon_uingrp.c. Dependencies are added to AUTH_OBJ as
UNIGRP_OBJ and WINBINDD_OBJ as UNIGRP_OBJ.

This patch has had a few versions, the final version in particular:

Many thanks to Andrew Bartlett for critics and comments, and partly
rewritten code.

New:
- updated fetching code to changed byte order macros
- moved functions to proper namespace
- optimized memory usage by reusing caller's memory context
- enhanced code to more follow Samba coding rules

Todo:
- proper universal group expiration after timeout
0001-01-01 00:00:00 +00:00
Andrew Tridgell
0b0b937b58 fixed a crash bug in domain auth caused by an uninitialised nt_status 0001-01-01 00:00:00 +00:00
Andrew Bartlett
d7fca1806a The DC is meant to be sent the *unmapped* username...
Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
7f7a42c3e4 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
0001-01-01 00:00:00 +00:00
Martin Pool
391cbb6901 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)
0001-01-01 00:00:00 +00:00
Andrew Bartlett
12f5515f55 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
0001-01-01 00:00:00 +00:00
Jeremy Allison
eb66074665 debug statement fixups.
Merge SAFE_FREE fix in tdb from 2.2, and IRIX fix.
Jeremy.
0001-01-01 00:00:00 +00:00
Andrew Bartlett
3d812aacff Another touch of 'const' 0001-01-01 00:00:00 +00:00
Andrew Bartlett
5cdc67d0bd Allow usernames in the form of 'NT_STATUS_....' to map to that as the error
when using the 'name_to_ntstatus' auth module.

This could be useful in testing.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
6673fdda3c Now that winbind doesn't rely on this, we may as well remove it...
Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
d870edce76 A farily large commit:
- Move rpc_client/cli_trust.c to smbd/change_trust_pw.c
  - It hasn't been used by anything else since smbpasswd lost its -j

 - Add a TALLOC_CTX to the auth subsytem.  These are only valid for the length
   of the calls to the individual modules, if you want a longer context hide it
   in your private data.

   Similarly, all returns (like the server_info) should still be malloced.

 - Move the 'ntdomain' module (security=domain in oldspeak) over to use the new
   libsmb domain logon code.  Also rework much of the code to use some better
   helper functions for the connection - getting us much better error returns
   (the new code is NTSTATUS).

   The only remaining thing to do is to figure out if tpot's 0xdead 0xbeef for
   the LUID feilds is sufficient, or if we should do random LUIDs as per the old
   code.

   Similarly, I'll move winbind over to this when I get a chance.

This leaves the SPOOLSS code and some cli_pipe code as the only stuff still in
rpc_client, at least as far as smbd is concerned.

While I've given this a basic rundown, any testing is as always appriciated.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Tridgell
48aa90c48c - portablitity fixes for cc -64 on irix
- fixed gid* bug in rpc_server
0001-01-01 00:00:00 +00:00
Andrew Bartlett
2efae7cc52 Add a pile of doxygen style comments to various parts of Samba. Many of these
probably will never actually be genearted, but I like the style in any case.

Also fix a segfault in 'net rpc' when the login failed and a small memory leak
on failure in the auth_info.c code.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Jeremy Allison
7ce2d1fe37 Removed extra lp_adduser() call.
Fixed up error returns in get_correct_cversion().
Jeremy.
0001-01-01 00:00:00 +00:00
Andrew Tridgell
adf44a9bd0 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.
0001-01-01 00:00:00 +00:00
Jim McDonough
477309b1e6 make sure we pass the lm and nt data in the right order. They were swapped, and somehow this worked when both were provided, but not when only one was. 0001-01-01 00:00:00 +00:00
Jim McDonough
07ea83e6f0 If domain SID can't be fetched, we shouldn't return NT_STATUS_NO_MEMORY. It causes a confusing client error. Changed to NT_STATUS_CANT_ACCESS_DOMAIN_INFO. 0001-01-01 00:00:00 +00:00
Jean-François Micouleau
0a727afc66 added info level 3 to samrgetgroupinfo. I don't know what the value is.
It's just to keep usermanager happy ;-)

clean up a bit samr_query_aliasinfo to return the group description

added: samr_del_aliasmem, samr_del_groupmem and samr_del_domuser

with the correct scripts, you can now entirely manage the users from
usermanager ! Closer to full PDC every day ;-)

        J.F.
0001-01-01 00:00:00 +00:00
Andrew Bartlett
ff91131ef9 Fix segfault, and add a comment. 0001-01-01 00:00:00 +00:00
Jean-François Micouleau
fef52c4b96 again an intrusive patch:
- removed the ugly as hell sam_logon_in_ssb variable, I changed a bit the
definition of standard_sub_basic() to cope with that.

- removed the smb.conf: 'domain admin group' and 'domain guest group'
parameters ! We're not playing anymore with the user's group RIDs !

- in get_domain_user_groups(), if the user's gid is a group, put it first
in the group RID list.

I just have to write an HOWTO now ;-)

        J.F.
0001-01-01 00:00:00 +00:00
Tim Potter
4215048f7b I think the lookup_pdc_name() should be called lookup_dc_name() and the
name_status_find() call here should look up a #1c name instead of #1d.
This fixes some bugs currently with BDC authentication in winbindd and in
smbd as you can't query the #1d name with the ip address of a BDC.

Who is Uncle Tom Cobbley anyway?
0001-01-01 00:00:00 +00:00
Andrew Tridgell
e2ba2383c9 fix a bunch of places where we can double-free a cli structure 0001-01-01 00:00:00 +00:00
Andrew Tridgell
1bd3235744 fixed the panics on basicsmb-sharelist on sun1 0001-01-01 00:00:00 +00:00
Andrew Tridgell
8eb4277b12 fixed leak in free_user_info() 0001-01-01 00:00:00 +00:00
Andrew Tridgell
982d6d447a another memory leak bites the dust 0001-01-01 00:00:00 +00:00
Andrew Tridgell
1421f2fbcb fix sense of lp_allow_trusted_domains()
fix a memory leak
0001-01-01 00:00:00 +00:00
Andrew Bartlett
44224ae156 Fix debug 0001-01-01 00:00:00 +00:00
Andrew Bartlett
e89b47f65e A number of things to clean up the auth subsytem a bit...
We now default encrypt passwords = yes

We now check plaintext passwords (however aquired) with the 'sam' backend
rather than unix, if encrypt passwords = yes.

(this kills off the 'local' backed.  The sam backend may be renamed in its
place)

The new 'samstrict' wrapper backend checks that the user's domain is one of
our netbios aliases - this ensures that we don't get fallback crazies with
security = domain.

Similarly, the code in the 'ntdomain' and 'smbserver' backends now checks
that the user was not local before contacting the DC.

The default ordering has changed, we now check the local stuff first - but
becouse of the changes above, we will really only ever contact one
auth source.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Tridgell
b175c42080 add SEC_ADS auth method 0001-01-01 00:00:00 +00:00