From 7e651c7ef3afb4effa045fa84ee3a87ab8226995 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 21 Dec 2008 21:10:40 +0100 Subject: Simplify customization of pidl-generated Python modules. --- source4/libcli/security/dom_sid.c | 40 +++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'source4/libcli/security') diff --git a/source4/libcli/security/dom_sid.c b/source4/libcli/security/dom_sid.c index 36e3967910..a83ebb0aa1 100644 --- a/source4/libcli/security/dom_sid.c +++ b/source4/libcli/security/dom_sid.c @@ -84,31 +84,26 @@ bool dom_sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2) return dom_sid_compare(sid1, sid2) == 0; } - -/* - convert a string to a dom_sid, returning a talloc'd dom_sid -*/ -struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr) +bool dom_sid_parse(const char *sidstr, struct dom_sid *ret) { - struct dom_sid *ret; uint_t rev, ia, num_sub_auths, i; char *p; if (strncasecmp(sidstr, "S-", 2)) { - return NULL; + return false; } sidstr += 2; rev = strtol(sidstr, &p, 10); if (*p != '-') { - return NULL; + return false; } sidstr = p+1; ia = strtol(sidstr, &p, 10); if (p == sidstr) { - return NULL; + return false; } sidstr = p; @@ -117,11 +112,6 @@ struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr) if (sidstr[i] == '-') num_sub_auths++; } - ret = talloc(mem_ctx, struct dom_sid); - if (!ret) { - return NULL; - } - ret->sid_rev_num = rev; ret->id_auth[0] = 0; ret->id_auth[1] = 0; @@ -133,16 +123,34 @@ struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr) for (i=0;isub_auths[i] = strtoul(sidstr, &p, 10); if (p == sidstr) { - return NULL; + return false; } sidstr = p; } + return true; +} + +/* + convert a string to a dom_sid, returning a talloc'd dom_sid +*/ +struct dom_sid *dom_sid_parse_talloc(TALLOC_CTX *mem_ctx, const char *sidstr) +{ + struct dom_sid *ret; + ret = talloc(mem_ctx, struct dom_sid); + if (!ret) { + return NULL; + } + if (!dom_sid_parse(sidstr, ret)) { + talloc_free(ret); + return NULL; + } + return ret; } -- cgit