tdbsam serious problem when migrating from 3.0.32 to 3.3.2

Alexander Zagrebin alexz at visp.ru
Tue Mar 17 12:58:16 GMT 2009


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...

Any suggestions?

-- 
Alexander Zagrebin



More information about the samba-technical mailing list