summaryrefslogtreecommitdiff
path: root/source3/winbindd/idmap_tdb_common.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2018-12-10 12:32:12 +0100
committerJeremy Allison <jra@samba.org>2018-12-11 00:40:31 +0100
commit939d64b9f830e9da88caf24d97299e379f3cdcd2 (patch)
tree89d641376da1b5fa4d7895ea7c30cf25cacf4ecd /source3/winbindd/idmap_tdb_common.c
parent6e55ca9e6f488d6996511e34e0fc7ffa1cb8fcac (diff)
downloadsamba-939d64b9f830e9da88caf24d97299e379f3cdcd2.tar.gz
winbind: Use dom_sid_str_buf
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/winbindd/idmap_tdb_common.c')
-rw-r--r--source3/winbindd/idmap_tdb_common.c33
1 files changed, 10 insertions, 23 deletions
diff --git a/source3/winbindd/idmap_tdb_common.c b/source3/winbindd/idmap_tdb_common.c
index ceb663c0ddd..e130be08245 100644
--- a/source3/winbindd/idmap_tdb_common.c
+++ b/source3/winbindd/idmap_tdb_common.c
@@ -221,7 +221,7 @@ NTSTATUS idmap_tdb_common_set_mapping(struct idmap_domain * dom,
struct idmap_tdb_common_context *ctx;
struct idmap_tdb_common_set_mapping_context state;
NTSTATUS ret;
- char *ksidstr = NULL;
+ struct dom_sid_buf ksidstr;
char *kidstr = NULL;
if (!map || !map->sid) {
@@ -257,21 +257,13 @@ NTSTATUS idmap_tdb_common_set_mapping(struct idmap_domain * dom,
goto done;
}
- ksidstr = sid_string_talloc(ctx, map->sid);
- if (ksidstr == NULL) {
- DEBUG(0, ("Out of memory!\n"));
- ret = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- state.ksidstr = ksidstr;
+ state.ksidstr = dom_sid_str_buf(map->sid, &ksidstr);
state.kidstr = kidstr;
ret = dbwrap_trans_do(ctx->db, idmap_tdb_common_set_mapping_action,
&state);
done:
- talloc_free(ksidstr);
talloc_free(kidstr);
return ret;
}
@@ -455,7 +447,7 @@ NTSTATUS idmap_tdb_common_sid_to_unixid(struct idmap_domain * dom,
{
NTSTATUS ret;
TDB_DATA data;
- char *keystr;
+ struct dom_sid_buf keystr;
unsigned long rec_id = 0;
struct idmap_tdb_common_context *ctx;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
@@ -469,19 +461,14 @@ NTSTATUS idmap_tdb_common_sid_to_unixid(struct idmap_domain * dom,
talloc_get_type_abort(dom->private_data,
struct idmap_tdb_common_context);
- keystr = sid_string_talloc(tmp_ctx, map->sid);
- if (keystr == NULL) {
- DEBUG(0, ("Out of memory!\n"));
- ret = NT_STATUS_NO_MEMORY;
- goto done;
- }
+ dom_sid_str_buf(map->sid, &keystr);
- DEBUG(10, ("Fetching record %s\n", keystr));
+ DEBUG(10, ("Fetching record %s\n", keystr.buf));
/* Check if sid is present in database */
- ret = dbwrap_fetch_bystring(ctx->db, tmp_ctx, keystr, &data);
+ ret = dbwrap_fetch_bystring(ctx->db, tmp_ctx, keystr.buf, &data);
if (!NT_STATUS_IS_OK(ret)) {
- DEBUG(10, ("Record %s not found\n", keystr));
+ DEBUG(10, ("Record %s not found\n", keystr.buf));
ret = NT_STATUS_NONE_MAPPED;
goto done;
}
@@ -492,7 +479,7 @@ NTSTATUS idmap_tdb_common_sid_to_unixid(struct idmap_domain * dom,
map->xid.id = rec_id;
map->xid.type = ID_TYPE_UID;
DEBUG(10,
- ("Found uid record %s -> %s \n", keystr,
+ ("Found uid record %s -> %s \n", keystr.buf,
(const char *)data.dptr));
ret = NT_STATUS_OK;
@@ -501,13 +488,13 @@ NTSTATUS idmap_tdb_common_sid_to_unixid(struct idmap_domain * dom,
map->xid.id = rec_id;
map->xid.type = ID_TYPE_GID;
DEBUG(10,
- ("Found gid record %s -> %s \n", keystr,
+ ("Found gid record %s -> %s \n", keystr.buf,
(const char *)data.dptr));
ret = NT_STATUS_OK;
} else { /* Unknown record type ! */
DEBUG(2,
- ("Found INVALID record %s -> %s\n", keystr,
+ ("Found INVALID record %s -> %s\n", keystr.buf,
(const char *)data.dptr));
ret = NT_STATUS_INTERNAL_DB_ERROR;
goto done;