summaryrefslogtreecommitdiff
path: root/source3/winbindd
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2007-12-15 22:00:39 +0100
committerVolker Lendecke <vl@samba.org>2007-12-15 22:09:37 +0100
commit14ef4cdec1ab6be55c97d0f32780cbddbcdde218 (patch)
treee7cb94297496f758a7935aaec62c7dd772e96f3a /source3/winbindd
parentd899b8c56ad6556baf2d2374704cc8cd1b15d5ad (diff)
downloadsamba-14ef4cdec1ab6be55c97d0f32780cbddbcdde218.tar.gz
samba-14ef4cdec1ab6be55c97d0f32780cbddbcdde218.tar.bz2
samba-14ef4cdec1ab6be55c97d0f32780cbddbcdde218.zip
Replace sid_string_static with sid_to_string
This adds 28 fstrings on the stack, but I think an fstring on the stack is still far better than a static one. (This used to be commit c7c885078be8fd3024c186044ac28275d7609679)
Diffstat (limited to 'source3/winbindd')
-rw-r--r--source3/winbindd/idmap_cache.c5
-rw-r--r--source3/winbindd/idmap_tdb.c12
-rw-r--r--source3/winbindd/winbindd_async.c3
-rw-r--r--source3/winbindd/winbindd_cache.c36
-rw-r--r--source3/winbindd/winbindd_group.c6
5 files changed, 43 insertions, 19 deletions
diff --git a/source3/winbindd/idmap_cache.c b/source3/winbindd/idmap_cache.c
index 6455f5ee69..4e286f88c0 100644
--- a/source3/winbindd/idmap_cache.c
+++ b/source3/winbindd/idmap_cache.c
@@ -77,7 +77,10 @@ void idmap_cache_shutdown(struct idmap_cache_ctx *cache)
NTSTATUS idmap_cache_build_sidkey(TALLOC_CTX *ctx, char **sidkey, const struct id_map *id)
{
- *sidkey = talloc_asprintf(ctx, "IDMAP/SID/%s", sid_string_static(id->sid));
+ fstring sidstr;
+
+ *sidkey = talloc_asprintf(ctx, "IDMAP/SID/%s",
+ sid_to_string(sidstr, id->sid));
if ( ! *sidkey) {
DEBUG(1, ("failed to build sidkey, OOM?\n"));
return NT_STATUS_NO_MEMORY;
diff --git a/source3/winbindd/idmap_tdb.c b/source3/winbindd/idmap_tdb.c
index 1ec7085a3b..d693c357f7 100644
--- a/source3/winbindd/idmap_tdb.c
+++ b/source3/winbindd/idmap_tdb.c
@@ -712,8 +712,10 @@ static NTSTATUS idmap_tdb_sid_to_id(struct idmap_tdb_context *ctx, struct id_map
TDB_DATA data;
char *keystr;
unsigned long rec_id = 0;
+ fstring tmp;
- if ((keystr = talloc_asprintf(ctx, "%s", sid_string_static(map->sid))) == NULL) {
+ if ((keystr = talloc_asprintf(ctx, "%s",
+ sid_to_string(tmp, map->sid))) == NULL) {
DEBUG(0, ("Out of memory!\n"));
ret = NT_STATUS_NO_MEMORY;
goto done;
@@ -864,6 +866,7 @@ static NTSTATUS idmap_tdb_set_mapping(struct idmap_domain *dom, const struct id_
NTSTATUS ret;
TDB_DATA ksid, kid, data;
char *ksidstr, *kidstr;
+ fstring tmp;
/* make sure we initialized */
if ( ! dom->initialized) {
@@ -905,7 +908,8 @@ static NTSTATUS idmap_tdb_set_mapping(struct idmap_domain *dom, const struct id_
goto done;
}
- if ((ksidstr = talloc_asprintf(ctx, "%s", sid_string_static(map->sid))) == NULL) {
+ if ((ksidstr = talloc_asprintf(
+ ctx, "%s", sid_to_string(tmp, map->sid))) == NULL) {
DEBUG(0, ("Out of memory!\n"));
ret = NT_STATUS_NO_MEMORY;
goto done;
@@ -977,6 +981,7 @@ static NTSTATUS idmap_tdb_remove_mapping(struct idmap_domain *dom, const struct
NTSTATUS ret;
TDB_DATA ksid, kid, data;
char *ksidstr, *kidstr;
+ fstring tmp;
/* make sure we initialized */
if ( ! dom->initialized) {
@@ -1018,7 +1023,8 @@ static NTSTATUS idmap_tdb_remove_mapping(struct idmap_domain *dom, const struct
goto done;
}
- if ((ksidstr = talloc_asprintf(ctx, "%s", sid_string_static(map->sid))) == NULL) {
+ if ((ksidstr = talloc_asprintf(
+ ctx, "%s", sid_to_string(tmp, map->sid))) == NULL) {
DEBUG(0, ("Out of memory!\n"));
ret = NT_STATUS_NO_MEMORY;
goto done;
diff --git a/source3/winbindd/winbindd_async.c b/source3/winbindd/winbindd_async.c
index 1c30558058..0971476f44 100644
--- a/source3/winbindd/winbindd_async.c
+++ b/source3/winbindd/winbindd_async.c
@@ -458,8 +458,9 @@ bool print_sidlist(TALLOC_CTX *mem_ctx, const DOM_SID *sids,
*len = 0;
*result = NULL;
for (i=0; i<num_sids; i++) {
+ fstring tmp;
sprintf_append(mem_ctx, result, len, &buflen,
- "%s\n", sid_string_static(&sids[i]));
+ "%s\n", sid_to_string(tmp, &sids[i]));
}
if ((num_sids != 0) && (*result == NULL)) {
diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
index c4554a2ad4..31747dd4c8 100644
--- a/source3/winbindd/winbindd_cache.c
+++ b/source3/winbindd/winbindd_cache.c
@@ -951,7 +951,7 @@ NTSTATUS wcache_cached_creds_exist(struct winbindd_domain *domain, const DOM_SID
{
struct winbind_cache *cache = get_cache(domain);
TDB_DATA data;
- fstring key_str;
+ fstring key_str, tmp;
uint32 rid;
if (!cache->tdb) {
@@ -966,7 +966,7 @@ NTSTATUS wcache_cached_creds_exist(struct winbindd_domain *domain, const DOM_SID
return NT_STATUS_INVALID_SID;
}
- fstr_sprintf(key_str, "CRED/%s", sid_string_static(sid));
+ fstr_sprintf(key_str, "CRED/%s", sid_to_string(tmp, sid));
data = tdb_fetch(cache->tdb, string_tdb_data(key_str));
if (!data.dptr) {
@@ -991,6 +991,7 @@ NTSTATUS wcache_get_creds(struct winbindd_domain *domain,
NTSTATUS status;
time_t t;
uint32 rid;
+ fstring tmp;
if (!cache->tdb) {
return NT_STATUS_INTERNAL_DB_ERROR;
@@ -1007,7 +1008,8 @@ NTSTATUS wcache_get_creds(struct winbindd_domain *domain,
/* Try and get a salted cred first. If we can't
fall back to an unsalted cred. */
- centry = wcache_fetch(cache, domain, "CRED/%s", sid_string_static(sid));
+ centry = wcache_fetch(cache, domain, "CRED/%s",
+ sid_to_string(tmp, sid));
if (!centry) {
DEBUG(10,("wcache_get_creds: entry for [CRED/%s] not found\n",
sid_string_dbg(sid)));
@@ -1555,6 +1557,7 @@ static NTSTATUS rids_to_names(struct winbindd_domain *domain,
for (i=0; i<num_rids; i++) {
DOM_SID sid;
struct cache_entry *centry;
+ fstring tmp;
if (!sid_compose(&sid, domain_sid, rids[i])) {
result = NT_STATUS_INTERNAL_ERROR;
@@ -1562,7 +1565,7 @@ static NTSTATUS rids_to_names(struct winbindd_domain *domain,
}
centry = wcache_fetch(cache, domain, "SN/%s",
- sid_string_static(&sid));
+ sid_to_string(tmp, &sid));
if (!centry) {
goto do_query;
}
@@ -1678,11 +1681,13 @@ static NTSTATUS query_user(struct winbindd_domain *domain,
struct winbind_cache *cache = get_cache(domain);
struct cache_entry *centry = NULL;
NTSTATUS status;
+ fstring tmp;
if (!cache->tdb)
goto do_query;
- centry = wcache_fetch(cache, domain, "U/%s", sid_string_static(user_sid));
+ centry = wcache_fetch(cache, domain, "U/%s",
+ sid_to_string(tmp, user_sid));
/* If we have an access denied cache entry and a cached info3 in the
samlogon cache then do a query. This will force the rpc back end
@@ -1852,8 +1857,9 @@ static NTSTATUS lookup_useraliases(struct winbindd_domain *domain,
* resulting might come from any of the SIDs. */
for (i=0; i<num_sids; i++) {
+ fstring tmp;
sidlist = talloc_asprintf(mem_ctx, "%s/%s", sidlist,
- sid_string_static(&sids[i]));
+ sid_to_string(tmp, &sids[i]));
if (sidlist == NULL)
return NT_STATUS_NO_MEMORY;
}
@@ -2461,6 +2467,7 @@ bool lookup_cached_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
struct winbind_cache *cache;
struct cache_entry *centry = NULL;
NTSTATUS status;
+ fstring tmp;
domain = find_lookup_domain_from_sid(sid);
if (domain == NULL) {
@@ -2473,7 +2480,7 @@ bool lookup_cached_sid(TALLOC_CTX *mem_ctx, const DOM_SID *sid,
return False;
}
- centry = wcache_fetch(cache, domain, "SN/%s", sid_string_static(sid));
+ centry = wcache_fetch(cache, domain, "SN/%s", sid_to_string(tmp, sid));
if (centry == NULL) {
return False;
}
@@ -2679,11 +2686,11 @@ NTSTATUS wcache_remove_oldest_cached_creds(struct winbindd_domain *domain, const
/* we possibly already have an entry */
if (sid && NT_STATUS_IS_OK(wcache_cached_creds_exist(domain, sid))) {
- fstring key_str;
+ fstring key_str, tmp;
DEBUG(11,("we already have an entry, deleting that\n"));
- fstr_sprintf(key_str, "CRED/%s", sid_string_static(sid));
+ fstr_sprintf(key_str, "CRED/%s", sid_to_string(tmp, sid));
tdb_delete(cache->tdb, string_tdb_data(key_str));
@@ -3526,6 +3533,8 @@ static int pack_tdc_domains( struct winbindd_tdc_domain *domains,
/* now pack each domain trust record */
for ( i=0; i<num_domains; i++ ) {
+ fstring tmp;
+
if ( buflen > 0 ) {
DEBUG(10,("pack_tdc_domains: Packing domain %s (%s)\n",
domains[i].domain_name,
@@ -3535,7 +3544,7 @@ static int pack_tdc_domains( struct winbindd_tdc_domain *domains,
len += tdb_pack( buffer+len, buflen-len, "fffddd",
domains[i].domain_name,
domains[i].dns_name,
- sid_string_static(&domains[i].sid),
+ sid_to_string(tmp, &domains[i].sid),
domains[i].trust_flags,
domains[i].trust_attribs,
domains[i].trust_type );
@@ -3806,6 +3815,7 @@ static void wcache_save_user_pwinfo(struct winbindd_domain *domain,
uint32 gid)
{
struct cache_entry *centry;
+ fstring tmp;
if ( (centry = centry_start(domain, status)) == NULL )
return;
@@ -3815,7 +3825,7 @@ static void wcache_save_user_pwinfo(struct winbindd_domain *domain,
centry_put_string( centry, gecos );
centry_put_uint32( centry, gid );
- centry_end(centry, "NSS/PWINFO/%s", sid_string_static(user_sid) );
+ centry_end(centry, "NSS/PWINFO/%s", sid_to_string(tmp, user_sid) );
DEBUG(10,("wcache_save_user_pwinfo: %s\n", sid_string_dbg(user_sid) ));
@@ -3832,11 +3842,13 @@ NTSTATUS nss_get_info_cached( struct winbindd_domain *domain,
struct winbind_cache *cache = get_cache(domain);
struct cache_entry *centry = NULL;
NTSTATUS nt_status;
+ fstring tmp;
if (!cache->tdb)
goto do_query;
- centry = wcache_fetch(cache, domain, "NSS/PWINFO/%s", sid_string_static(user_sid));
+ centry = wcache_fetch(cache, domain, "NSS/PWINFO/%s",
+ sid_to_string(tmp, user_sid));
if (!centry)
goto do_query;
diff --git a/source3/winbindd/winbindd_group.c b/source3/winbindd/winbindd_group.c
index dc8cebf92f..49562a112c 100644
--- a/source3/winbindd/winbindd_group.c
+++ b/source3/winbindd/winbindd_group.c
@@ -1648,7 +1648,8 @@ static void getusersids_recv(void *private_data, bool success, DOM_SID *sids,
/* work out the response size */
for (i = 0; i < num_sids; i++) {
- const char *s = sid_string_static(&sids[i]);
+ fstring s;
+ sid_to_string(s, &sids[i]);
ret_size += strlen(s) + 1;
}
@@ -1661,7 +1662,8 @@ static void getusersids_recv(void *private_data, bool success, DOM_SID *sids,
}
ofs = 0;
for (i = 0; i < num_sids; i++) {
- const char *s = sid_string_static(&sids[i]);
+ fstring s;
+ sid_to_string(s, &sids[i]);
safe_strcpy(ret + ofs, s, ret_size - ofs - 1);
ofs += strlen(ret+ofs) + 1;
}