fixed segv on startup with trusted domains
authorAndrew Tridgell <tridge@samba.org>
Wed, 17 Sep 2008 06:15:40 +0000 (16:15 +1000)
committerMichael Adam <obnox@samba.org>
Mon, 29 Sep 2008 12:01:00 +0000 (14:01 +0200)
With some setups, idmap_tdb2_allocate_id can be called before the
allocate backend is initialised, leading to a segv. This change
ensures that the db is opened in all paths that use it

source3/winbindd/idmap_tdb2.c

index 3066db6f3b1e720c40b9efbe58f43207b5fd80c2..911f80c6a3e17e8dbfbe21121a6d4dea258033f1 100644 (file)
@@ -187,6 +187,10 @@ static NTSTATUS idmap_tdb2_allocate_id(struct unixid *xid)
        uint32_t high_hwm;
        uint32_t hwm;
        int res;
+       NTSTATUS status;
+
+       status = idmap_tdb2_open_db();
+       NT_STATUS_NOT_OK_RETURN(status);
 
        /* Get current high water mark */
        switch (xid->type) {
@@ -264,6 +268,10 @@ static NTSTATUS idmap_tdb2_get_hwm(struct unixid *xid)
        const char *hwmtype;
        uint32_t hwm;
        uint32_t high_hwm;
+       NTSTATUS status;
+
+       status = idmap_tdb2_open_db();
+       NT_STATUS_NOT_OK_RETURN(status);
 
        /* Get current high water mark */
        switch (xid->type) {
@@ -451,6 +459,10 @@ static NTSTATUS idmap_tdb2_id_to_sid(struct idmap_tdb2_context *ctx, struct id_m
        NTSTATUS ret;
        TDB_DATA data;
        char *keystr;
+       NTSTATUS status;
+
+       status = idmap_tdb2_open_db();
+       NT_STATUS_NOT_OK_RETURN(status);
 
        if (!ctx || !map) {
                return NT_STATUS_INVALID_PARAMETER;
@@ -546,6 +558,10 @@ static NTSTATUS idmap_tdb2_sid_to_id(struct idmap_tdb2_context *ctx, struct id_m
        TDB_DATA data;
        char *keystr;
        unsigned long rec_id = 0;
+       NTSTATUS status;
+
+       status = idmap_tdb2_open_db();
+       NT_STATUS_NOT_OK_RETURN(status);
 
        if ((keystr = sid_string_talloc(ctx, map->sid)) == NULL) {
                DEBUG(0, ("Out of memory!\n"));