tdbsam serious problem when migrating from 3.0.32 to 3.3.2

Jeremy Allison jra at samba.org
Wed Mar 18 00:22:00 GMT 2009


On Tue, Mar 17, 2009 at 03:58:16PM +0300, Alexander Zagrebin wrote:
> I have tried to migrate from samba version 3.0.32 to 3.3.2 and found
> the serious problem: samba can't convert my passdb.tdb from version 3 to
> version 4.
> 
> For example, when running "pdbedit -L" I receive:
> 
> # pdbedit -L
> tdbsam_open: Converting version 3 database to version 4.
> Could not store the new record: NT_STATUS_UNSUCCESSFUL
> Converting records failed
> tdbsam_open: Error when trying to convert tdbsam
> [/usr/local/etc/samba/passdb.tdb]
> tdbsam_getsampwnam: failed to open /usr/local/etc/samba/passdb.tdb!
> Could not start searching users
> Segmentation fault (core dumped)
> 
> With debugging (-d5) the output contains:
> ...
> Finding user тест
> Trying _Get_Pwnam(), username as lowercase is тест
> Get_Pwnam_internals did find user [тест]!
> Could not store the new record: NT_STATUS_UNSUCCESSFUL
> Converting records failed
> ...
> 
> This problem exists only for user names, containing characters with codes
> from
> range 128...255 (with high bit set).
> After doing some debugging, I have found that:
> 
> 1. Possible the "break" is missed at source/passdb/pdb_tdb.c:
> 
> --- source/passdb/pdb_tdb.c.orig        2009-02-24 10:38:16.000000000 +0300
> +++ source/passdb/pdb_tdb.c             2009-03-14 23:47:41.000000000 +0300
> @@ -102,6 +102,7 @@
>                 ret = init_samu_from_buffer(user, SAMU_BUFFER_V3,
>                                             (uint8 *)rec->value.dptr,
>                                             rec->value.dsize);
> +               break;
>         case 4:
>                 ret = init_samu_from_buffer(user, SAMU_BUFFER_V4,
>                                             (uint8 *)rec->value.dptr,
> 
> 2. The reason of the above described problem is in default_tdb_hash
> (source/lib/tdb/common/open.c)
> This function returns different results on 3.0.* and 3.3.* for same data,
> containing non-ascii
> characters. The code is the same, but definition of TDB_DATA
> (source/lib/tdb/include/tdb.h)
> was changed. Early the TDB_DATA.dptr was signed, but now it is unsigned. So
> the hash calculation
> makes a different result now and pdbedit can't store the new (upgraded)
> record.
> 
> I see 2 possible solutions.
> 1. Migrate the passdb data via another backend (export at 3.0.*/import at
> 3.3.*). Which?
> 2. Temporary rename users, but pdbedit doesn't has such functionality...

Ok, I think a workaround for your situation should be:

1). Add the patch you have sent above.
2). Run tdbbackup from Samba 3.3 on the passdb.tdb to
create a new version with the newer hash values (still
at version 3).
3). Replace the old passdb.tdb with the backed up
version.
4). Run the (patched) 3.3.2 smbd - this should now
correctly update your passdb.tdb including the
users with the high bit set in their names.

Let me know if this fixes the problem for you, and
I'll investigate adding a version of this into
smbd as part of the upgrade process.

Thanks a *LOT* for raising this problem, I hadn't
seen it before.

Jeremy.



More information about the samba-technical mailing list