1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-28 07:21:54 +03:00
Commit Graph

130 Commits

Author SHA1 Message Date
Gerald Carter
7d7a262f45 isolate ldap debug messages to the common smbldap_XXX() functions 0001-01-01 00:00:00 +00:00
Gerald Carter
e079c8842a fix more memory leaks in the LDAP backend code; patches from metze 0001-01-01 00:00:00 +00:00
Gerald Carter
ee272414e9 fix for bug 680 (heads up). This gist is to map the
UNIX entity foo to DOMAIN\foo instead of SERVER\foo
on members of a Samba domain when all UNIX accounts
are shared via NIS, et. al.

  * allow winbindd to match local accounts to domain SID
    when 'winbind trusted domains only = yes'

  * remove code in idmap_ldap that searches the user
    suffix and group suffix.  It's not needed and
    provides inconsistent functionality from the tdb backend.

This has been tested.  I'm still waiting on some more feedback
but This needs to be in 3.0.1pre2 for widespread use.
0001-01-01 00:00:00 +00:00
Jeremy Allison
b5d953bc26 Ensure we consistantly translate to/from utf8 for talking to LDAP.
Jeremy.
0001-01-01 00:00:00 +00:00
Herb Lewis
398bd14fc6 get rid of more compiler warnings 0001-01-01 00:00:00 +00:00
Gerald Carter
a030fa373a 2 fixes
* bug #280 (my fault) - initialize sambaNextUserRid and
   sambaNextGroupRid

 * Unix users shared vis LDAP or NIS between a samba domain member
   of a Samba domain are not seen as domain users on the member servers.
   not as local users.
0001-01-01 00:00:00 +00:00
Gerald Carter
d98a68e0eb rework winbindd_accountdb_init() to reduce error messages in the log 0001-01-01 00:00:00 +00:00
Jim McDonough
a2bd8f0bfa Update my copyrights according to my agreement with IBM 0001-01-01 00:00:00 +00:00
Jim McDonough
15d2bc4785 Fix copyright statements for various pieces of Anthony Liguori's work. 0001-01-01 00:00:00 +00:00
Tim Potter
165d1ae556 Some more [ug]id_t printf fixes. 0001-01-01 00:00:00 +00:00
Gerald Carter
9f835b85dd convert snprintf() calls using pstrings & fstrings
to pstr_sprintf() and fstr_sprintf() to try to standardize.
lots of snprintf() calls were using len-1; some were using
len.  At least this helps to be consistent.
0001-01-01 00:00:00 +00:00
Tim Potter
f93528ba00 Fixup a bunch of printf-style functions and debugs to use unsigned long when
displaying pid_t, uid_t and gid_t values.  This removes a whole lot of warnings
on some of the 64-bit build farm machines as well as help us out when 64-bit
uid/gid/pid values come along.
0001-01-01 00:00:00 +00:00
Gerald Carter
0463045cc7 moving more code around.
* move rid allocation into IDMAP.  See comments in _api_samr_create_user()
  * add winbind delete user/group functions

I'm checking this in to sync up with everyone.  But I'm going to split
the add a separate winbindd_allocate_rid() function for systems
that have an 'add user script' but need idmap to give them a RID.
Life would be so much simplier without 'enable rid algorithm'.
The current RID allocation is horrible due to this one fact.
Tested idmap_tdb but not idmap_ldap yet.  Will do that tomorrow.

Nothing has changed in the way a samba domain is represented, stored,
or search in the directory so things should be ok with previous installations.

going to bed now.
0001-01-01 00:00:00 +00:00
Gerald Carter
1111bc7b0c Large set of changes to add UNIX account/group management
to winbindd.  See README.idmap-and-winbind-changes for details.
0001-01-01 00:00:00 +00:00
Gerald Carter
6f0b5d474a fix some compile problems. Can't get IDMAP_OBJ our of proto.h
just yet.

`
0001-01-01 00:00:00 +00:00
Gerald Carter
688369c23c Cleaning up linking issues. sam/idmap*.c only links in
winbindd now.  Also removing an unused file.
0001-01-01 00:00:00 +00:00
Gerald Carter
8266dffab4 and so it begins....
* remove idmap_XX_to_XX calls from smbd.  Move back to the
  the winbind_XXX and local_XXX calls used in 2.2

* all uid/gid allocation must involve winbindd now

* move flags field around in winbindd_request struct

* add WBFLAG_QUERY_ONLY option to winbindd_sid_to_[ug]id()
  to prevent automatic allocation for unknown SIDs

* add 'winbind trusted domains only' parameter to force a domain member
  server to use matching users names from /etc/passwd for its domain
  (needed for domain member of a Samba domain)

* rename 'idmap only' to 'enable rid algorithm' for better clarity
  (defaults to "yes")

code has been tested on

  * domain member of native mode 2k domain
  * ads domain member of native mode 2k domain
  * domain member of NT4 domain
  * domain member of Samba domain
  * Samba PDC running winbindd with trusts

Logons tested using 2k clients and smbclient as domain users
and trusted users. Tested both 'winbind trusted domains only = [yes|no]'

This will be a long week of changes.  The next item on the list is
winbindd_passdb.c & machine trust accounts not in /etc/passwd (done
via winbindd_passdb)
0001-01-01 00:00:00 +00:00
Andrew Bartlett
32e455a714 This changes our Unix primary GID behaviour back to what most people expect:
Samba will now use the user's UNIX primary group, as the primary group when
dealing with the filesystem.  The NT primary group is ignored in unix.

For the NT_TOKEN, the primary group is the NT priamry group, and the unix
primary group is added to the NT_TOKEN as a supplementary group.

This should fix bug #109, but will need to be revisited when we get a full
NT group database.

Also in this commit:
 - Fix debug statements in service.c
 - Make idmap_ldap show if it's adding, or modifying an existing DN
 - Make idmap_ldap show both the error message and error string
0001-01-01 00:00:00 +00:00
Andrew Bartlett
6c48309cda Add some debug statments to our vampire code - try to make it easier to track
down failures.

Add a 'auto-add on modify' feature to guestsam

Fix some segfault bugs on no-op idmap modifications, and on new idmappings that
do not have a DN to tack onto.

Make the 'private data' a bit more robust.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
c7118cb31d Fixes to our LDAP/vampire codepaths:
- Try better to add the appropriate mapping between UID and SIDs, based
   on Get_Pwnam()
 - Look for previous users (lookup by SID) and correctly modify the existing
   entry in that case
 - Map the root user to the Admin SID as a 'well known user'
 - Save the LDAPMessage result on the SAM_ACCOUNT for use in the next 'update'
   call on that user.  This means that VL's very nice work on atomic LDAP
   updates now really gets used properly!
 - This also means that we know the right DN to update, without the extra
   round-trips to the server.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
b9ef4e1388 Allow modification of an existing entry.
We still have a lot of work to do to allow this in quite the same way as we
have in the TDB, but it certainly is getting closer.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
68245e9cfa Don't allow RIDs (in our domain) below 1000 (or algorithmic rid base) to be
mapped with the rid algorithm.

Instead, a uid/gid from the UID/GID range will be allocated for this RID.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
9c595c8c23 This patch cleans up some of our ldap code, for better behaviour:
We now always read the Domain SID out of LDAP.  If the local secrets.tdb
is ever different to LDAP, it is overwritten out of LDAP.   We also
store the 'algorithmic rid base' into LDAP, and assert if it changes.
(This ensures cross-host synchronisation, and allows for possible
integration with idmap).  If we fail to read/add the domain entry, we just
fallback to the old behaviour.

We always use an existing DN when adding IDMAP entries to LDAP, unless
no suitable entry is available.  This means that a user's posixAccount
will have a SID added to it, or a user's sambaSamAccount will have a UID
added.  Where we cannot us an existing DN, we use
'sambaSid=S-x-y-z,....' as the DN.

The code now allows modifications to the ID mapping in many cases.

Likewise, we now check more carefully when adding new user entires to LDAP,
to not duplicate SIDs (for users, at this stage), and to add the sambaSamAccount
onto the idmap entry for that user, if it is already established (ensuring
we do not duplicate sambaSid entries in the directory).

The allocated UID code has been expanded to take into account the space
between '1000 - algorithmic rid base'.  This much better fits into what
an NT4 does - allocating in the bottom part of the RID range.

On the code cleanup side of things, we now share as much code as
possible between idmap_ldap and pdb_ldap.

We also no longer use the race-prone 'enumerate all users' method for
finding the next RID to allocate.  Instead, we just start at the bottom
of the range, and increment again if the user already exists.  The first
time this is run, it may well take a long time, but next time will just
be able to use the next Rid.

Thanks to metze and AB for double-checking parts of this.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Jeremy Allison
16a5461dd3 Fix for idmap startup bug with remote ldap backend.
Jeremy.
0001-01-01 00:00:00 +00:00
Volker Lendecke
9d317fb533 Don't set a mapping that is already there.
Volker
0001-01-01 00:00:00 +00:00
Jeremy Allison
1714eb6bef Merge of Volkers patch to make the logic clearer (with my mod).
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
ba112bb3fd Fix missing ret = found by Volker.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
8f830c509a Some const correctness. Stop tdb being used as a remote backend. If an
idmap backend is specified cause smbd to ask winbindd (use winbindd if
you want a consistant remote backend solution).
Should work well enough for next beta now...
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
5b998cdc1d Add include guards around idmap.h, change ID_NOMAP to ID_QUERY_ONLY
and ID_CACHE to ID_CACHE_SAVE. Added locking around tdb writes & deletes
for multi-process access.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
030b35ca0f As has been pointed out, ordering here doesn't matter so use normal
add.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
a304bc5ff1 Fix immediate bug where the idmap can't tell the difference between an entry
not being present (and so allocate another) and an entry that is present but
of the wrong type. This code still has major problems...
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
dd9251e6f5 Ensure idmap backends are added in the correct order (DLIST_ADD puts
things at the *front* of the list). Add more debug. Still broken.. :-(.
Jeremy.
0001-01-01 00:00:00 +00:00
Volker Lendecke
fdcfefd7f1 Fix a warning in a DEBUG
Clean up the init a little bit, less nested if-statements.

Agreed upon with Simo.

Volker
0001-01-01 00:00:00 +00:00
Simo Sorce
e154e50fed Tought I already done.
Set back 3.0 to use only winbindd_idmap.tdb as idmap database as told on
samba-technical.
Tested and working so far.
0001-01-01 00:00:00 +00:00
Jeremy Allison
a118648d95 More debugs for this... (these should have been here already !).
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
705915d9f7 More instrumentation tracking down this bug...
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
bdffc81c9d Start to instrument this code as I try and track down a nasty bug that
causes mapping to dissapear...
Jeremy.
0001-01-01 00:00:00 +00:00
Simo Sorce
c501e84d41 Found out a good number of NT_STATUS_IS_ERR used the wrong way.
As abartlet rememberd me NT_STATUS_IS_ERR != !NT_STATUS_IS_OK

This patch will cure the problem.
Working on this one I found 16 functions where I think NT_STATUS_IS_ERR() is
used correctly, but I'm not 100% sure, coders should check the use of
NT_STATUS_IS_ERR() in samba is ok now.

Simo.
0001-01-01 00:00:00 +00:00
Andrew Bartlett
74709e159c This patch fixes some issues with idmap_tdb as raised by bug #181
The idea here is to eliminate the need to *set* the 'HWM' (High Water
Mark) in the tdb.  Instead, each caller wanting to add an item to the
TDB uses the fact that an insert will *fail* if entry already exists.

More importantly, this means that we don't need to know the value of the
idmap uid/gid values when setting arbitrary entries, which can occur on
an smb.conf without such values specified.

Then all we need to do is loop until we get an id that will insert.
This means that the HWM does not need to be accurate, and we can have
IDs allocates safely above the HWM.

Setting the HWM to an arbitrary value was racy in the past - now we
don't even do it.

This patch also adds paranoia in reading the tdb - both the entry, and
it's reverse entry must be present.  This means that we don't need to
'clean up' after an abnormal failure (which would probably fail too),
instead we rely on readers to ignore the half-completed entry.  The way
this is done will allow SIDs to then allocated an ID when things are
normal again.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
f93167a7e1 This patch works towards to goal of common code shared between idmap_ldap
and pdb_ldap.

So far, it's just a function rename, so that the next patch can be a very
simple matter of copying functions, without worrying about what changed
in the process.

Also removes the 'static' pointers for the rebind procedures, replacing them
with a linked list of value/key lookups.  (Only needed on older LDAP client
libs)

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Simo Sorce
e341e7c49f Ok, this patch removes the privilege stuff we had in, unused, for some time.
The code was nice, but put in the wrong place (group mapping) and not
supported by most of the code, thus useless.

We will put back most of the code when our infrastructure will be changed
so that privileges actually really make sense to be set.

This is a first patch of a set to enhance all our mapping code cleaness and
stability towards a sane next beta for 3.0 code base

Simo.
0001-01-01 00:00:00 +00:00
Volker Lendecke
5849053930 There's nothing particularly secret in idmap.tdb, so create it with
0644 as the other databases.

Volker
0001-01-01 00:00:00 +00:00
Volker Lendecke
2392f460ae And more other memory leaks. One new (idmap) and one ancient (groupdb).
Volker
0001-01-01 00:00:00 +00:00
Volker Lendecke
dcdb6683a7 Fix memory leak in idmap. Valgrind is soooo cool.
Volker
0001-01-01 00:00:00 +00:00
Volker Lendecke
c0575be936 Add 'net idmap restore'. This restores a broken idmap file
from the output of 'net idmap dump'.

'net idmap dump' now also prints the USER/GROUP HWM.

Volker
0001-01-01 00:00:00 +00:00
Volker Lendecke
d1eac2c758 Sorry idra for messing around with your stuff, but this was obviously not
tested.

Incrementing HWW_USER while allocating a GROUPID looked somewhat wrong.

Volker
0001-01-01 00:00:00 +00:00
Simo Sorce
df0df941d8 avoid races in getting high watermark 0001-01-01 00:00:00 +00:00
Jeremy Allison
6a07d19b63 Fix for crash bug noticed by Luke Howard | PADL Software Pty Ltd | www.padl.com.
Jeremy.
0001-01-01 00:00:00 +00:00
Gerald Carter
1665926281 * break out more common code used between pdb_ldap and idmap_ldap
* remove 'winbind uid' and 'winbind gid' parameters (replaced
  by current idmap parameter)
* create the sambaUnixIdPool entries automatically in the 'ldap
  idmap suffix'
* add new 'ldap idmap suffix' and 'ldap group suffix' parametrer
* "idmap backend = ldap" now accepts 'ldap:ldap://server/' format
  (parameters are passed to idmap init() function
0001-01-01 00:00:00 +00:00
Gerald Carter
8241758544 working draft of the idmap_ldap code.
Includes sambaUnixIdPool objectclass

Still needs cleaning up wrt to name space.
More changes to come, but at least we now have a
a working distributed winbindd solution.
0001-01-01 00:00:00 +00:00