static NTSTATUS one_alias_membership(const DOM_SID *member,
DOM_SID **sids, size_t *num)
{
+ fstring tmp;
fstring key;
char *string_sid;
TDB_DATA dbuf;
TALLOC_CTX *frame;
slprintf(key, sizeof(key), "%s%s", MEMBEROF_PREFIX,
- sid_string_static(member));
+ sid_to_string(tmp, member));
dbuf = tdb_fetch_bystring(tdb, key);
static bool get_privileges( const DOM_SID *sid, SE_PRIV *mask )
{
TDB_CONTEXT *tdb = get_account_pol_tdb();
- fstring keystr;
+ fstring tmp, keystr;
TDB_DATA data;
/* Fail if the admin has not enable privileges */
/* PRIV_<SID> (NULL terminated) as the key */
- fstr_sprintf( keystr, "%s%s", PRIVPREFIX, sid_string_static(sid) );
+ fstr_sprintf(keystr, "%s%s", PRIVPREFIX, sid_to_string(tmp, sid));
data = tdb_fetch_bystring( tdb, keystr );
static bool set_privileges( const DOM_SID *sid, SE_PRIV *mask )
{
TDB_CONTEXT *tdb = get_account_pol_tdb();
- fstring keystr;
+ fstring tmp, keystr;
TDB_DATA data;
if ( !lp_enable_privileges() )
/* PRIV_<SID> (NULL terminated) as the key */
- fstr_sprintf( keystr, "%s%s", PRIVPREFIX, sid_string_static(sid) );
+ fstr_sprintf(keystr, "%s%s", PRIVPREFIX, sid_to_string(tmp, sid));
/* no packing. static size structure, just write it out */
static char *longvar_domainsid( void )
{
DOM_SID sid;
+ fstring tmp;
char *sid_string;
if ( !secrets_fetch_domain_sid( lp_workgroup(), &sid ) ) {
return NULL;
}
- sid_string = SMB_STRDUP( sid_string_static( &sid ) );
+ sid_string = SMB_STRDUP( sid_to_string( tmp, &sid ) );
if ( !sid_string ) {
DEBUG(0,("longvar_domainsid: failed to dup SID string!\n"));
int i;
for (i=0; values[i]; i++) {
DOM_SID sid;
+ fstring tmp;
sid_parse(values[i]->bv_val, values[i]->bv_len, &sid);
- printf("%s: %s\n", field, sid_string_static(&sid));
+ printf("%s: %s\n", field, sid_to_string(tmp, &sid));
}
}
bool netsamlogon_cache_store( const char *username, NET_USER_INFO_3 *user )
{
TDB_DATA data;
- fstring keystr;
+ fstring keystr, tmp;
prs_struct ps;
bool result = False;
DOM_SID user_sid;
sid_append_rid( &user_sid, user->user_rid );
/* Prepare key as DOMAIN-SID/USER-RID string */
- slprintf(keystr, sizeof(keystr), "%s", sid_string_static(&user_sid));
+ slprintf(keystr, sizeof(keystr), "%s", sid_to_string(tmp, &user_sid));
DEBUG(10,("netsamlogon_cache_store: SID [%s]\n", keystr));
NET_USER_INFO_3 *user = NULL;
TDB_DATA data;
prs_struct ps;
- fstring keystr;
+ fstring keystr, tmp;
uint32 t;
if (!netsamlogon_cache_init()) {
}
/* Prepare key as DOMAIN-SID/USER-RID string */
- slprintf(keystr, sizeof(keystr), "%s", sid_string_static(user_sid));
+ slprintf(keystr, sizeof(keystr), "%s", sid_to_string(tmp, user_sid));
DEBUG(10,("netsamlogon_cache_get: SID [%s]\n", keystr));
data = tdb_fetch_bystring( netsamlogon_tdb, keystr );
{
DOM_SID group_sid;
struct group *grp;
+ fstring tmp;
grp = getgrnam(name);
sid_compose(&group_sid, get_global_sam_sid(), *rid);
- return add_initial_entry(grp->gr_gid, sid_string_static(&group_sid),
+ return add_initial_entry(grp->gr_gid, sid_to_string(tmp, &group_sid),
SID_NAME_DOM_GRP, name, NULL);
}
{
char *filter = NULL;
NTSTATUS status;
+ fstring tmp;
if (asprintf(&filter, "(&(objectClass=%s)(%s=%s))",
LDAP_OBJ_GROUPMAP,
get_attr_key2string(groupmap_attr_list, LDAP_ATTR_GROUP_SID),
- sid_string_static(&sid)) < 0) {
+ sid_to_string(tmp, &sid)) < 0) {
return NT_STATUS_NO_MEMORY;
}
LDAPMod **mods = NULL;
int rc;
enum lsa_SidType type = SID_NAME_USE_NONE;
+ fstring tmp;
char *filter = NULL;
if (asprintf(&filter,
"(&(objectClass=%s)(sambaSid=%s)(sambaGroupType=%d))",
- LDAP_OBJ_GROUPMAP, sid_string_static(alias),
+ LDAP_OBJ_GROUPMAP, sid_to_string(tmp, alias),
type) < 0) {
return NT_STATUS_NO_MEMORY;
}
smbldap_set_mod(&mods, modop,
get_attr_key2string(groupmap_attr_list,
LDAP_ATTR_SID_LIST),
- sid_string_static(member));
+ sid_to_string(tmp, member));
rc = smbldap_modify(ldap_state->smbldap_state, dn, mods);
char *filter = NULL;
size_t num_members = 0;
enum lsa_SidType type = SID_NAME_USE_NONE;
+ fstring tmp;
*pp_members = NULL;
*p_num_members = 0;
if (asprintf(&filter,
"(&(objectClass=%s)(sambaSid=%s)(sambaGroupType=%d))",
- LDAP_OBJ_GROUPMAP, sid_string_static(alias),
+ LDAP_OBJ_GROUPMAP, sid_to_string(tmp, alias),
type) < 0) {
return NT_STATUS_NO_MEMORY;
}
struct ldapsam_privates *ldap_state =
(struct ldapsam_privates *)methods->private_data;
struct ldap_search_state *state;
+ fstring tmp;
state = TALLOC_P(search->mem_ctx, struct ldap_search_state);
if (state == NULL) {
state->filter = talloc_asprintf(search->mem_ctx,
"(&(objectclass=sambaGroupMapping)"
"(sambaGroupType=%d)(sambaSID=%s*))",
- type, sid_string_static(sid));
+ type, sid_to_string(tmp, sid));
state->attrs = talloc_attrs(search->mem_ctx, "cn", "sambaSid",
"displayName", "description",
"sambaGroupType", NULL);
struct lsa_name_info *name = &name_infos[i];
if (name->type == SID_NAME_UNKNOWN) {
+ fstring tmp;
name->dom_idx = -1;
/* Unknown sids should return the string
* representation of the SID. Windows 2003 behaves
* SID. We (Jerry/VL) could not figure out which the
* hard cases are, so leave it with the SID. */
name->name = talloc_asprintf(p->mem_ctx, "%s",
- sid_string_static(sids[i]));
+ sid_to_string(tmp,
+ sids[i]));
if (name->name == NULL) {
return NT_STATUS_NO_MEMORY;
}
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;
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;
NTSTATUS ret;
TDB_DATA ksid, kid, data;
char *ksidstr, *kidstr;
+ fstring tmp;
/* make sure we initialized */
if ( ! dom->initialized) {
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;
NTSTATUS ret;
TDB_DATA ksid, kid, data;
char *ksidstr, *kidstr;
+ fstring tmp;
/* make sure we initialized */
if ( ! dom->initialized) {
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;
*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)) {
{
struct winbind_cache *cache = get_cache(domain);
TDB_DATA data;
- fstring key_str;
+ fstring key_str, tmp;
uint32 rid;
if (!cache->tdb) {
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) {
NTSTATUS status;
time_t t;
uint32 rid;
+ fstring tmp;
if (!cache->tdb) {
return NT_STATUS_INTERNAL_DB_ERROR;
/* 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)));
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;
}
centry = wcache_fetch(cache, domain, "SN/%s",
- sid_string_static(&sid));
+ sid_to_string(tmp, &sid));
if (!centry) {
goto do_query;
}
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
* 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;
}
struct winbind_cache *cache;
struct cache_entry *centry = NULL;
NTSTATUS status;
+ fstring tmp;
domain = find_lookup_domain_from_sid(sid);
if (domain == NULL) {
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;
}
/* 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));
/* 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,
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 );
uint32 gid)
{
struct cache_entry *centry;
+ fstring tmp;
if ( (centry = centry_start(domain, status)) == NULL )
return;
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) ));
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;
/* 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;
}
}
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;
}