]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
fixed segv on startup with trusted domains
authorAndrew Tridgell <tridge@samba.org>
Mon, 29 Sep 2008 18:24:00 +0000 (11:24 -0700)
committerJeremy Allison <jra@samba.org>
Mon, 29 Sep 2008 18:24:00 +0000 (11:24 -0700)
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

source/winbindd/idmap_tdb2.c

index ab89e615f780d98cd1e7b36d04d6a97c0a4a0c69..ffb10b4d346cdbd2863f94aff1af8bf896dee120 100644 (file)
@@ -235,7 +235,9 @@ static NTSTATUS idmap_tdb2_allocate_id(struct unixid *xid)
        NTSTATUS status;
 
        status = idmap_tdb2_open_perm_db();
-       NT_STATUS_NOT_OK_RETURN(status);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
 
        /* Get current high water mark */
        switch (xid->type) {
@@ -297,6 +299,12 @@ 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_perm_db();
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
 
        /* Get current high water mark */
        switch (xid->type) {
@@ -552,6 +560,12 @@ 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_perm_db();
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
 
        if (!ctx || !map) {
                return NT_STATUS_INVALID_PARAMETER;
@@ -647,6 +661,12 @@ 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_perm_db();
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
 
        if ((keystr = sid_string_talloc(ctx, map->sid)) == NULL) {
                DEBUG(0, ("Out of memory!\n"));