[PATCH] Use dom_sid_str_buf in a few more places
Volker Lendecke
Volker.Lendecke at SerNet.DE
Fri Nov 9 11:54:54 UTC 2018
... More to come. If that's too many small patches, I'm happy to
squash a lot of them.
Review appreciated!
Thanks, Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 2965e7b065e088b2bfad6aa47f20c060a6dbecbb Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 26 Oct 2018 08:25:14 +0200
Subject: [PATCH 01/13] winbind: Use dom_sid_str_buf
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/winbindd/winbindd_pam.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/source3/winbindd/winbindd_pam.c b/source3/winbindd/winbindd_pam.c
index bed5a940282..a02926decb2 100644
--- a/source3/winbindd/winbindd_pam.c
+++ b/source3/winbindd/winbindd_pam.c
@@ -251,13 +251,15 @@ static NTSTATUS append_afs_token(TALLOC_CTX *mem_ctx,
{
struct dom_sid user_sid;
- fstring sidstr;
+ struct dom_sid_buf sidstr;
sid_compose(&user_sid, info3->base.domain_sid,
info3->base.rid);
- sid_to_fstring(sidstr, &user_sid);
- afsname = talloc_string_sub(mem_ctx, afsname,
- "%s", sidstr);
+ afsname = talloc_string_sub(
+ mem_ctx,
+ afsname,
+ "%s",
+ dom_sid_str_buf(&user_sid, &sidstr));
}
if (afsname == NULL) {
--
2.11.0
From 75d34926385f23bb4a83e3cf37bff72b0e2ce1d8 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 26 Oct 2018 08:25:14 +0200
Subject: [PATCH 02/13] winbind: Use dom_sid_str_buf
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/winbindd/winbindd_cache.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
index 2e2a04d09d8..c23ae62c403 100644
--- a/source3/winbindd/winbindd_cache.c
+++ b/source3/winbindd/winbindd_cache.c
@@ -854,8 +854,8 @@ static void centry_put_hash16(struct cache_entry *centry, const uint8_t val[16])
static void centry_put_sid(struct cache_entry *centry, const struct dom_sid *sid)
{
- fstring sid_string;
- centry_put_string(centry, sid_to_fstring(sid_string, sid));
+ struct dom_sid_buf sid_string;
+ centry_put_string(centry, dom_sid_str_buf(sid, &sid_string));
}
--
2.11.0
From 11bb0a306c5c5f6a99dbec2311ee24a35b0c50f7 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sat, 27 Oct 2018 22:01:03 +0200
Subject: [PATCH 03/13] winbind: Use dom_sid_str_buf
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/winbindd/winbindd_cache.c | 54 +++++++++++++++++++--------------------
1 file changed, 27 insertions(+), 27 deletions(-)
diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
index c23ae62c403..370475a90aa 100644
--- a/source3/winbindd/winbindd_cache.c
+++ b/source3/winbindd/winbindd_cache.c
@@ -2222,19 +2222,14 @@ static NTSTATUS wcache_query_user(struct winbindd_domain *domain,
struct winbind_cache *cache = get_cache(domain);
struct cache_entry *centry = NULL;
NTSTATUS status;
- char *sid_string;
+ struct dom_sid_buf sid_string;
if (cache->tdb == NULL) {
return NT_STATUS_NOT_FOUND;
}
- sid_string = sid_string_tos(user_sid);
- if (sid_string == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- centry = wcache_fetch(cache, domain, "U/%s", sid_string);
- TALLOC_FREE(sid_string);
+ centry = wcache_fetch(
+ cache, domain, "U/%s", dom_sid_str_buf(user_sid, &sid_string));
if (centry == NULL) {
return NT_STATUS_NOT_FOUND;
}
@@ -2322,14 +2317,17 @@ static NTSTATUS wcache_lookup_usergroups(struct winbindd_domain *domain,
NTSTATUS status;
uint32_t i, num_sids;
struct dom_sid *sids;
- fstring sid_string;
+ struct dom_sid_buf sid_string;
if (cache->tdb == NULL) {
return NT_STATUS_NOT_FOUND;
}
- centry = wcache_fetch(cache, domain, "UG/%s",
- sid_to_fstring(sid_string, user_sid));
+ centry = wcache_fetch(
+ cache,
+ domain,
+ "UG/%s",
+ dom_sid_str_buf(user_sid, &sid_string));
if (centry == NULL) {
return NT_STATUS_NOT_FOUND;
}
@@ -2380,7 +2378,7 @@ NTSTATUS wb_cache_lookup_usergroups(struct winbindd_domain *domain,
struct cache_entry *centry = NULL;
NTSTATUS status;
unsigned int i;
- fstring sid_string;
+ struct dom_sid_buf sid_string;
bool old_status;
old_status = domain->online;
@@ -2434,7 +2432,7 @@ NTSTATUS wb_cache_lookup_usergroups(struct winbindd_domain *domain,
centry_put_sid(centry, &(*user_gids)[i]);
}
- centry_end(centry, "UG/%s", sid_to_fstring(sid_string, user_sid));
+ centry_end(centry, "UG/%s", dom_sid_str_buf(user_sid, &sid_string));
centry_free(centry);
skip_save:
@@ -2605,19 +2603,17 @@ static NTSTATUS wcache_lookup_groupmem(struct winbindd_domain *domain,
struct cache_entry *centry = NULL;
NTSTATUS status;
unsigned int i;
- char *sid_string;
+ struct dom_sid_buf sid_string;
if (cache->tdb == NULL) {
return NT_STATUS_NOT_FOUND;
}
- sid_string = sid_string_tos(group_sid);
- if (sid_string == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- centry = wcache_fetch(cache, domain, "GM/%s", sid_string);
- TALLOC_FREE(sid_string);
+ centry = wcache_fetch(
+ cache,
+ domain,
+ "GM/%s",
+ dom_sid_str_buf(group_sid, &sid_string));
if (centry == NULL) {
return NT_STATUS_NOT_FOUND;
}
@@ -2671,7 +2667,7 @@ NTSTATUS wb_cache_lookup_groupmem(struct winbindd_domain *domain,
struct cache_entry *centry = NULL;
NTSTATUS status;
unsigned int i;
- fstring sid_string;
+ struct dom_sid_buf sid_string;
bool old_status;
old_status = domain->online;
@@ -2727,7 +2723,9 @@ NTSTATUS wb_cache_lookup_groupmem(struct winbindd_domain *domain,
centry_put_string(centry, (*names)[i]);
centry_put_uint32(centry, (*name_types)[i]);
}
- centry_end(centry, "GM/%s", sid_to_fstring(sid_string, group_sid));
+ centry_end(centry,
+ "GM/%s",
+ dom_sid_str_buf(group_sid, &sid_string));
centry_free(centry);
skip_save:
@@ -3015,7 +3013,8 @@ static int traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf,
void wcache_invalidate_samlogon(struct winbindd_domain *domain,
const struct dom_sid *sid)
{
- fstring key_str, sid_string;
+ fstring key_str;
+ struct dom_sid_buf sid_string;
struct winbind_cache *cache;
/* don't clear cached U/SID and UG/SID entries when we want to logon
@@ -3035,12 +3034,12 @@ void wcache_invalidate_samlogon(struct winbindd_domain *domain,
}
/* Clear U/SID cache entry */
- fstr_sprintf(key_str, "U/%s", sid_to_fstring(sid_string, sid));
+ fstr_sprintf(key_str, "U/%s", dom_sid_str_buf(sid, &sid_string));
DEBUG(10, ("wcache_invalidate_samlogon: clearing %s\n", key_str));
tdb_delete(cache->tdb, string_tdb_data(key_str));
/* Clear UG/SID cache entry */
- fstr_sprintf(key_str, "UG/%s", sid_to_fstring(sid_string, sid));
+ fstr_sprintf(key_str, "UG/%s", dom_sid_str_buf(sid, &sid_string));
DEBUG(10, ("wcache_invalidate_samlogon: clearing %s\n", key_str));
tdb_delete(cache->tdb, string_tdb_data(key_str));
@@ -4561,11 +4560,12 @@ bool wcache_tdc_add_domain( struct winbindd_domain *domain )
struct winbindd_tdc_domain *dom_list = NULL;
size_t num_domains = 0;
bool ret = false;
+ struct dom_sid_buf buf;
DEBUG(10,("wcache_tdc_add_domain: Adding domain %s (%s), SID %s, "
"flags = 0x%x, attributes = 0x%x, type = 0x%x\n",
domain->name, domain->alt_name,
- sid_string_dbg(&domain->sid),
+ dom_sid_str_buf(&domain->sid, &buf),
domain->domain_flags,
domain->domain_trust_attribs,
domain->domain_type));
--
2.11.0
From 9aa2807d656f7bc2316e67936efa97e5ff9026f1 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 26 Oct 2018 14:15:43 +0200
Subject: [PATCH 04/13] libcli: Use dom_sid_str_buf
Signed-off-by: Volker Lendecke <vl at samba.org>
---
libcli/security/display_sec.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/libcli/security/display_sec.c b/libcli/security/display_sec.c
index a8d173c6364..506ecf6d89d 100644
--- a/libcli/security/display_sec.c
+++ b/libcli/security/display_sec.c
@@ -180,7 +180,7 @@ static void disp_sec_ace_object(struct security_ace_object *object)
****************************************************************************/
void display_sec_ace(struct security_ace *ace)
{
- char *sid_str;
+ struct dom_sid_buf sid_str;
printf("\tACE\n\t\ttype: ");
switch (ace->type) {
@@ -219,9 +219,7 @@ void display_sec_ace(struct security_ace *ace)
printf(" (%d) flags: 0x%02x ", ace->type, ace->flags);
display_sec_ace_flags(ace->flags);
display_sec_access(&ace->access_mask);
- sid_str = dom_sid_string(NULL, &ace->trustee);
- printf("\t\tSID: %s\n\n", sid_str);
- talloc_free(sid_str);
+ printf("\t\tSID: %s\n\n", dom_sid_str_buf(&ace->trustee, &sid_str));
if (sec_ace_object(ace->type)) {
disp_sec_ace_object(&ace->object.object);
@@ -292,7 +290,7 @@ void display_acl_type(uint16_t type)
****************************************************************************/
void display_sec_desc(struct security_descriptor *sec)
{
- char *sid_str;
+ struct dom_sid_buf sid_str;
if (!sec) {
printf("NULL\n");
@@ -313,14 +311,12 @@ void display_sec_desc(struct security_descriptor *sec)
}
if (sec->owner_sid) {
- sid_str = dom_sid_string(NULL, sec->owner_sid);
- printf("\tOwner SID:\t%s\n", sid_str);
- talloc_free(sid_str);
+ printf("\tOwner SID:\t%s\n",
+ dom_sid_str_buf(sec->owner_sid, &sid_str));
}
if (sec->group_sid) {
- sid_str = dom_sid_string(NULL, sec->group_sid);
- printf("\tGroup SID:\t%s\n", sid_str);
- talloc_free(sid_str);
+ printf("\tGroup SID:\t%s\n",
+ dom_sid_str_buf(sec->group_sid, &sid_str));
}
}
--
2.11.0
From e17b65efa768df9ff9c3c983ecad0e8d63082e97 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 26 Oct 2018 15:43:30 +0200
Subject: [PATCH 05/13] passdb: Use dom_sid_str_buf
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/passdb/pdb_ldap_util.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/source3/passdb/pdb_ldap_util.c b/source3/passdb/pdb_ldap_util.c
index dc222031418..f9e6cbbc3a9 100644
--- a/source3/passdb/pdb_ldap_util.c
+++ b/source3/passdb/pdb_ldap_util.c
@@ -27,6 +27,7 @@
#include "passdb.h"
#include "passdb/pdb_ldap_util.h"
#include "passdb/pdb_ldap_schema.h"
+#include "libcli/security/dom_sid.h"
/**********************************************************************
Add the account-policies below the sambaDomain object to LDAP,
@@ -118,7 +119,7 @@ static NTSTATUS add_new_domain_account_policies(struct smbldap_state *ldap_state
static NTSTATUS add_new_domain_info(struct smbldap_state *ldap_state,
const char *domain_name)
{
- fstring sid_string;
+ struct dom_sid_buf sid_string;
fstring algorithmic_rid_base_string;
char *filter = NULL;
char *dn = NULL;
@@ -196,11 +197,10 @@ static NTSTATUS add_new_domain_info(struct smbldap_state *ldap_state,
/* If we don't have an entry, then ask secrets.tdb for what it thinks.
It may choose to make it up */
- sid_to_fstring(sid_string, get_global_sam_sid());
smbldap_set_mod(&mods, LDAP_MOD_ADD,
get_attr_key2string(dominfo_attr_list,
LDAP_ATTR_DOM_SID),
- sid_string);
+ dom_sid_str_buf(get_global_sam_sid(), &sid_string));
slprintf(algorithmic_rid_base_string,
sizeof(algorithmic_rid_base_string) - 1, "%i",
--
2.11.0
From c9566d555eff5da06aab04a1648aefcd47fdc6f4 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 26 Oct 2018 15:43:30 +0200
Subject: [PATCH 06/13] passdb: Use dom_sid_str_buf
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/passdb/pdb_interface.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index 315da52f01b..78ff2daafaf 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -741,7 +741,7 @@ static NTSTATUS pdb_default_create_dom_group(struct pdb_methods *methods,
{
struct dom_sid group_sid;
struct group *grp;
- fstring tmp;
+ struct dom_sid_buf tmp;
grp = getgrnam(name);
@@ -769,8 +769,12 @@ static NTSTATUS pdb_default_create_dom_group(struct pdb_methods *methods,
sid_compose(&group_sid, get_global_sam_sid(), *rid);
- return add_initial_entry(grp->gr_gid, sid_to_fstring(tmp, &group_sid),
- SID_NAME_DOM_GRP, name, NULL);
+ return add_initial_entry(
+ grp->gr_gid,
+ dom_sid_str_buf(&group_sid, &tmp),
+ SID_NAME_DOM_GRP,
+ name,
+ NULL);
}
NTSTATUS pdb_create_dom_group(TALLOC_CTX *mem_ctx, const char *name,
--
2.11.0
From 09988c43f31269c48d5106d5562da8c276d0dc82 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Nov 2018 20:58:59 +0100
Subject: [PATCH 07/13] passdb: Use dom_sid_str_buf
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/groupdb/mapping_tdb.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/source3/groupdb/mapping_tdb.c b/source3/groupdb/mapping_tdb.c
index b5b11767f27..6bb8c3269b2 100644
--- a/source3/groupdb/mapping_tdb.c
+++ b/source3/groupdb/mapping_tdb.c
@@ -732,7 +732,7 @@ static NTSTATUS del_aliasmem(const struct dom_sid *alias, const struct dom_sid *
bool found = False;
char *member_string;
char *key;
- fstring sid_string;
+ struct dom_sid_buf sid_string;
if (dbwrap_transaction_start(db) != 0) {
DEBUG(0, ("transaction_start failed\n"));
@@ -763,9 +763,11 @@ static NTSTATUS del_aliasmem(const struct dom_sid *alias, const struct dom_sid *
num -= 1;
- sid_to_fstring(sid_string, member);
-
- key = talloc_asprintf(sids, "%s%s", MEMBEROF_PREFIX, sid_string);
+ key = talloc_asprintf(
+ sids,
+ "%s%s",
+ MEMBEROF_PREFIX,
+ dom_sid_str_buf(member, &sid_string));
if (key == NULL) {
TALLOC_FREE(sids);
status = NT_STATUS_NO_MEMORY;
@@ -786,10 +788,10 @@ static NTSTATUS del_aliasmem(const struct dom_sid *alias, const struct dom_sid *
for (i=0; i<num; i++) {
- sid_to_fstring(sid_string, &sids[i]);
-
member_string = talloc_asprintf_append_buffer(
- member_string, " %s", sid_string);
+ member_string,
+ " %s",
+ dom_sid_str_buf(&sids[i], &sid_string));
if (member_string == NULL) {
TALLOC_FREE(sids);
--
2.11.0
From 92aae90e9ea1a1dfbffc54ae9e45e3098f2a37f7 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Nov 2018 20:58:59 +0100
Subject: [PATCH 08/13] passdb: Use dom_sid_str_buf
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/groupdb/mapping_tdb.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/source3/groupdb/mapping_tdb.c b/source3/groupdb/mapping_tdb.c
index 6bb8c3269b2..41b56be5ca3 100644
--- a/source3/groupdb/mapping_tdb.c
+++ b/source3/groupdb/mapping_tdb.c
@@ -451,7 +451,7 @@ static bool enum_group_mapping(const struct dom_sid *domsid,
static NTSTATUS one_alias_membership(const struct dom_sid *member,
struct dom_sid **sids, size_t *num)
{
- fstring tmp;
+ struct dom_sid_buf tmp;
fstring key;
char *string_sid;
TDB_DATA dbuf;
@@ -460,7 +460,7 @@ static NTSTATUS one_alias_membership(const struct dom_sid *member,
TALLOC_CTX *frame = talloc_stackframe();
slprintf(key, sizeof(key), "%s%s", MEMBEROF_PREFIX,
- sid_to_fstring(tmp, member));
+ dom_sid_str_buf(member, &tmp));
status = dbwrap_fetch_bystring(db, frame, key, &dbuf);
if (!NT_STATUS_IS_OK(status)) {
@@ -532,7 +532,7 @@ static NTSTATUS add_aliasmem(const struct dom_sid *alias, const struct dom_sid *
{
GROUP_MAP *map;
char *key;
- fstring string_sid;
+ struct dom_sid_buf string_sid;
char *new_memberstring;
struct db_record *rec;
NTSTATUS status;
@@ -559,10 +559,8 @@ static NTSTATUS add_aliasmem(const struct dom_sid *alias, const struct dom_sid *
if (is_aliasmem(alias, member))
return NT_STATUS_MEMBER_IN_ALIAS;
- sid_to_fstring(string_sid, member);
-
key = talloc_asprintf(talloc_tos(), "%s%s", MEMBEROF_PREFIX,
- string_sid);
+ dom_sid_str_buf(member, &string_sid));
if (key == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -583,13 +581,13 @@ static NTSTATUS add_aliasmem(const struct dom_sid *alias, const struct dom_sid *
value = dbwrap_record_get_value(rec);
- sid_to_fstring(string_sid, alias);
+ dom_sid_str_buf(alias, &string_sid);
if (value.dptr != NULL) {
new_memberstring = talloc_asprintf(
- key, "%s %s", (char *)(value.dptr), string_sid);
+ key, "%s %s", (char *)(value.dptr), string_sid.buf);
} else {
- new_memberstring = talloc_strdup(key, string_sid);
+ new_memberstring = talloc_strdup(key, string_sid.buf);
}
if (new_memberstring == NULL) {
--
2.11.0
From 25c452c8fccfbff95d22733498038612b02bc3e9 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 26 Oct 2018 15:43:30 +0200
Subject: [PATCH 09/13] idmap: Use dom_sid_str_buf
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/winbindd/idmap_ad.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/source3/winbindd/idmap_ad.c b/source3/winbindd/idmap_ad.c
index 8f1cb375dfb..664483ace78 100644
--- a/source3/winbindd/idmap_ad.c
+++ b/source3/winbindd/idmap_ad.c
@@ -689,6 +689,7 @@ static NTSTATUS idmap_ad_unixids_to_sids(struct idmap_domain *dom,
bool ok;
uint32_t atype, xid;
enum id_type type;
+ struct dom_sid_buf sidbuf;
if (tldap_msg_type(msg) != TLDAP_RES_SEARCH_ENTRY) {
continue;
@@ -746,14 +747,16 @@ static NTSTATUS idmap_ad_unixids_to_sids(struct idmap_domain *dom,
}
if (map == NULL) {
DBG_DEBUG("Got unexpected sid %s from object %s\n",
- sid_string_tos(&sid), dn);
+ dom_sid_str_buf(&sid, &sidbuf),
+ dn);
continue;
}
sid_copy(map->sid, &sid);
map->status = ID_MAPPED;
- DBG_DEBUG("Mapped %s -> %ju (%d)\n", sid_string_dbg(map->sid),
+ DBG_DEBUG("Mapped %s -> %ju (%d)\n",
+ dom_sid_str_buf(map->sid, &sidbuf),
(uintmax_t)map->xid.id, map->xid.type);
}
--
2.11.0
From c621319ebaa09f4dcd08d30e681b38d179f1f236 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Nov 2018 20:54:37 +0100
Subject: [PATCH 10/13] idmap: Use dom_sid_str_buf
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/idmap_cache.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/source3/lib/idmap_cache.c b/source3/lib/idmap_cache.c
index 4c65841fd9c..1d87bbdec45 100644
--- a/source3/lib/idmap_cache.c
+++ b/source3/lib/idmap_cache.c
@@ -36,7 +36,7 @@
bool idmap_cache_find_sid2unixid(const struct dom_sid *sid, struct unixid *id,
bool *expired)
{
- fstring sidstr;
+ struct dom_sid_buf sidstr;
char *key;
char *value = NULL;
char *endptr;
@@ -45,7 +45,7 @@ bool idmap_cache_find_sid2unixid(const struct dom_sid *sid, struct unixid *id,
struct unixid tmp_id;
key = talloc_asprintf(talloc_tos(), "IDMAP/SID2XID/%s",
- sid_to_fstring(sidstr, sid));
+ dom_sid_str_buf(sid, &sidstr));
if (key == NULL) {
return false;
}
@@ -289,11 +289,12 @@ void idmap_cache_set_sid2unixid(const struct dom_sid *sid, struct unixid *unix_i
{
time_t now = time(NULL);
time_t timeout;
- fstring sidstr, key, value;
+ fstring key, value;
if (!is_null_sid(sid)) {
+ struct dom_sid_buf sidstr;
fstr_sprintf(key, "IDMAP/SID2XID/%s",
- sid_to_fstring(sidstr, sid));
+ dom_sid_str_buf(sid, &sidstr));
switch (unix_id->type) {
case ID_TYPE_UID:
fstr_sprintf(value, "%d:U", (int)unix_id->id);
--
2.11.0
From 575f0a826ed6203be60292ac4f6af5212084c99c Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sat, 27 Oct 2018 21:50:34 +0200
Subject: [PATCH 11/13] idmap: Use dom_sid_str_buf
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/winbindd/idmap_ad.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/source3/winbindd/idmap_ad.c b/source3/winbindd/idmap_ad.c
index 664483ace78..9e6510f43d3 100644
--- a/source3/winbindd/idmap_ad.c
+++ b/source3/winbindd/idmap_ad.c
@@ -872,8 +872,10 @@ static NTSTATUS idmap_ad_sids_to_unixids(struct idmap_domain *dom,
}
}
if (map == NULL) {
+ struct dom_sid_buf buf;
DBG_DEBUG("Got unexpected sid %s from object %s\n",
- sid_string_tos(&sid), dn);
+ dom_sid_str_buf(&sid, &buf),
+ dn);
continue;
}
--
2.11.0
From 601f650c27a3e61be39d5c575bdcee973fac3653 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Nov 2018 21:28:59 +0100
Subject: [PATCH 12/13] libgpo: Use dom_sid_str_buf
Signed-off-by: Volker Lendecke <vl at samba.org>
---
libgpo/gpo_sec.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/libgpo/gpo_sec.c b/libgpo/gpo_sec.c
index 98ee8eb3cc9..82887bc7e19 100644
--- a/libgpo/gpo_sec.c
+++ b/libgpo/gpo_sec.c
@@ -103,16 +103,13 @@ static bool gpo_sd_check_read_access_bits(uint32_t access_mask)
static NTSTATUS gpo_sd_check_ace_denied_object(const struct security_ace *ace,
const struct security_token *token)
{
- char *sid_str;
-
if (gpo_sd_check_agp_object(ace) &&
gpo_sd_check_agp_access_bits(ace->access_mask) &&
security_token_has_sid(token, &ace->trustee)) {
- sid_str = dom_sid_string(NULL, &ace->trustee);
+ struct dom_sid_buf sid_str;
DEBUG(10,("gpo_sd_check_ace_denied_object: "
"Access denied as of ace for %s\n",
- sid_str));
- talloc_free(sid_str);
+ dom_sid_str_buf(&ace->trustee, &sid_str)));
return NT_STATUS_ACCESS_DENIED;
}
@@ -125,17 +122,13 @@ static NTSTATUS gpo_sd_check_ace_denied_object(const struct security_ace *ace,
static NTSTATUS gpo_sd_check_ace_allowed_object(const struct security_ace *ace,
const struct security_token *token)
{
- char *sid_str;
-
if (gpo_sd_check_agp_object(ace) &&
gpo_sd_check_agp_access_bits(ace->access_mask) &&
security_token_has_sid(token, &ace->trustee)) {
- sid_str = dom_sid_string(NULL, &ace->trustee);
+ struct dom_sid_buf sid_str;
DEBUG(10,("gpo_sd_check_ace_allowed_object: "
"Access granted as of ace for %s\n",
- sid_str));
- talloc_free(sid_str);
-
+ dom_sid_str_buf(&ace->trustee, &sid_str)));
return NT_STATUS_OK;
}
--
2.11.0
From 71ef54a17861359fe4432ebe211c4b96d753bef2 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 2 Nov 2018 20:48:07 +0100
Subject: [PATCH 13/13] lib: Use dom_sid_str_buf
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/lib/privileges.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/source3/lib/privileges.c b/source3/lib/privileges.c
index d3509c2267b..ec4e1893bda 100644
--- a/source3/lib/privileges.c
+++ b/source3/lib/privileges.c
@@ -74,7 +74,8 @@ static uint64_t map_old_SE_PRIV(unsigned char *dptr)
static bool get_privileges( const struct dom_sid *sid, uint64_t *mask )
{
struct db_context *db = get_account_pol_db();
- fstring tmp, keystr;
+ struct dom_sid_buf tmp;
+ fstring keystr;
TDB_DATA data;
NTSTATUS status;
@@ -89,7 +90,7 @@ static bool get_privileges( const struct dom_sid *sid, uint64_t *mask )
/* PRIV_<SID> (NULL terminated) as the key */
- fstr_sprintf(keystr, "%s%s", PRIVPREFIX, sid_to_fstring(tmp, sid));
+ fstr_sprintf(keystr, "%s%s", PRIVPREFIX, dom_sid_str_buf(sid, &tmp));
status = dbwrap_fetch_bystring(db, talloc_tos(), keystr, &data);
@@ -125,7 +126,8 @@ static bool set_privileges( const struct dom_sid *sid, uint64_t mask )
{
struct db_context *db = get_account_pol_db();
uint8_t privbuf[8];
- fstring tmp, keystr;
+ struct dom_sid_buf tmp;
+ fstring keystr;
TDB_DATA data;
if ( !lp_enable_privileges() )
@@ -141,7 +143,7 @@ static bool set_privileges( const struct dom_sid *sid, uint64_t mask )
/* PRIV_<SID> (NULL terminated) as the key */
- fstr_sprintf(keystr, "%s%s", PRIVPREFIX, sid_to_fstring(tmp, sid));
+ fstr_sprintf(keystr, "%s%s", PRIVPREFIX, dom_sid_str_buf(sid, &tmp));
/* This writes the 64 bit bitmask out in little endian format */
SBVAL(privbuf,0,mask);
@@ -469,7 +471,8 @@ NTSTATUS privilege_create_account(const struct dom_sid *sid )
NTSTATUS privilege_delete_account(const struct dom_sid *sid)
{
struct db_context *db = get_account_pol_db();
- fstring tmp, keystr;
+ struct dom_sid_buf tmp;
+ fstring keystr;
if (!lp_enable_privileges()) {
return NT_STATUS_OK;
@@ -485,7 +488,7 @@ NTSTATUS privilege_delete_account(const struct dom_sid *sid)
/* PRIV_<SID> (NULL terminated) as the key */
- fstr_sprintf(keystr, "%s%s", PRIVPREFIX, sid_to_fstring(tmp, sid));
+ fstr_sprintf(keystr, "%s%s", PRIVPREFIX, dom_sid_str_buf(sid, &tmp));
return dbwrap_delete_bystring(db, keystr);
}
--
2.11.0
More information about the samba-technical
mailing list