diff options
author | Gerald Carter <jerry@samba.org> | 2005-06-08 22:10:34 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:57:08 -0500 |
commit | fed660877c16562265327c6093ea645cf4176b5c (patch) | |
tree | e92ae1356542ba095d806bbe1093fa56fbc8ddcc /source3/lib | |
parent | 66bb4f03c3466205488f72e4878e8801c5bbb295 (diff) | |
download | samba-fed660877c16562265327c6093ea645cf4176b5c.tar.gz samba-fed660877c16562265327c6093ea645cf4176b5c.tar.bz2 samba-fed660877c16562265327c6093ea645cf4176b5c.zip |
r7415: * big change -- volker's new async winbindd from trunk
(This used to be commit a0ac9a8ffd4af31a0ebc423b4acbb2f043d865b8)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util.c | 23 | ||||
-rw-r--r-- | source3/lib/util_sid.c | 8 | ||||
-rw-r--r-- | source3/lib/util_str.c | 66 |
3 files changed, 96 insertions, 1 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index 00b08af7c3..297eeb4d03 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -2668,6 +2668,29 @@ void name_to_fqdn(fstring fqdn, const char *name) } } +/********************************************************************** + Extension to talloc_get_type: Abort on type mismatch +***********************************************************************/ + +void *talloc_check_name_abort(const void *ptr, const char *name) +{ + void *result; + + if (ptr == NULL) + return NULL; + + result = talloc_check_name(ptr, name); + if (result != NULL) + return result; + + DEBUG(0, ("Talloc type mismatch, expected %s, got %s\n", + name, talloc_get_name(ptr))); + smb_panic("aborting"); + /* Keep the compiler happy */ + return NULL; +} + + #ifdef __INSURE__ /******************************************************************* diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c index 1838da1313..b9b4aff420 100644 --- a/source3/lib/util_sid.c +++ b/source3/lib/util_sid.c @@ -342,6 +342,12 @@ BOOL sid_append_rid(DOM_SID *sid, uint32 rid) return False; } +BOOL sid_compose(DOM_SID *dst, const DOM_SID *domain_sid, uint32 rid) +{ + sid_copy(dst, domain_sid); + return sid_append_rid(dst, rid); +} + /***************************************************************** Removes the last rid from the end of a sid *****************************************************************/ @@ -630,7 +636,7 @@ DOM_SID *sid_dup_talloc(TALLOC_CTX *ctx, const DOM_SID *src) Add SID to an array SIDs ********************************************************************/ -void add_sid_to_array(TALLOC_CTX *mem_ctx, const DOM_SID *sid, +void add_sid_to_array(TALLOC_CTX *mem_ctx, const DOM_SID *sid, DOM_SID **sids, int *num) { if (mem_ctx != NULL) diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index b13ec1f0da..f600d1704e 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -2128,3 +2128,69 @@ BOOL add_string_to_array(TALLOC_CTX *mem_ctx, *num += 1; return True; } + +/* Append an sprintf'ed string. Double buffer size on demand. Usable without + * error checking in between. The indiation that something weird happened is + * string==NULL */ + +void sprintf_append(TALLOC_CTX *mem_ctx, char **string, ssize_t *len, + size_t *bufsize, const char *fmt, ...) +{ + va_list ap; + char *newstr; + int ret; + BOOL increased; + + /* len<0 is an internal marker that something failed */ + if (*len < 0) + goto error; + + if (*string == NULL) { + if (*bufsize == 0) + *bufsize = 128; + + if (mem_ctx != NULL) + *string = TALLOC_ARRAY(mem_ctx, char, *bufsize); + else + *string = SMB_MALLOC_ARRAY(char, *bufsize); + + if (*string == NULL) + goto error; + } + + va_start(ap, fmt); + ret = vasprintf(&newstr, fmt, ap); + va_end(ap); + + if (ret < 0) + goto error; + + increased = False; + + while ((*len)+ret >= *bufsize) { + increased = True; + *bufsize *= 2; + if (*bufsize >= (1024*1024*256)) + goto error; + } + + if (increased) { + if (mem_ctx != NULL) + *string = TALLOC_REALLOC_ARRAY(mem_ctx, *string, char, + *bufsize); + else + *string = SMB_REALLOC_ARRAY(*string, char, *bufsize); + + if (*string == NULL) + goto error; + } + + StrnCpy((*string)+(*len), newstr, ret); + (*len) += ret; + free(newstr); + return; + + error: + *len = -1; + *string = NULL; +} |