From 79a245808cc61ad3396e246680d9d3ce9d230096 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Fri, 11 Apr 2014 18:20:01 +0200 Subject: [PATCH] autorid: more explicitly and reasonably set map->state in idmap_autorid_sid_to_id_alloc Signed-off-by: Michael Adam Reviewed-by: Stefan Metzmacher --- source3/winbindd/idmap_autorid.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c index 0e7d6d676e4..8cdc37e20fb 100644 --- a/source3/winbindd/idmap_autorid.c +++ b/source3/winbindd/idmap_autorid.c @@ -348,6 +348,8 @@ static NTSTATUS idmap_autorid_sid_to_id_alloc(struct idmap_domain *dom, NTSTATUS ret; int res; + map->status = ID_UNKNOWN; + /* see if we already have a mapping */ ret = idmap_tdb_common_sid_to_unixid(dom, map); @@ -366,6 +368,7 @@ static NTSTATUS idmap_autorid_sid_to_id_alloc(struct idmap_domain *dom, if (dom->read_only) { DEBUG(3, ("Not allocating new mapping for %s, because backend " "is read-only\n", sid_string_dbg(map->sid))); + map->status = ID_UNMAPPED; return NT_STATUS_NONE_MAPPED; } @@ -380,18 +383,17 @@ static NTSTATUS idmap_autorid_sid_to_id_alloc(struct idmap_domain *dom, } ret = idmap_tdb_common_new_mapping(dom, map); - - map->status = (NT_STATUS_IS_OK(ret))?ID_MAPPED:ID_UNMAPPED; - if (!NT_STATUS_IS_OK(ret)) { if (dbwrap_transaction_cancel(ctx->db) != 0) { smb_panic("Cancelling transaction failed"); } + map->status = ID_UNMAPPED; return ret; } res = dbwrap_transaction_commit(ctx->db); if (res == 0) { + map->status = ID_MAPPED; return ret; } -- 2.11.4.GIT