diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-12-21 21:10:40 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-12-21 21:10:40 +0100 |
commit | 7e651c7ef3afb4effa045fa84ee3a87ab8226995 (patch) | |
tree | 150c341474848f8e2bcc39c78c64dfc8f7925db9 /source4/libcli | |
parent | 38a4749d2cf9266164527e2b3c14bc7e47b72326 (diff) | |
download | samba-7e651c7ef3afb4effa045fa84ee3a87ab8226995.tar.gz samba-7e651c7ef3afb4effa045fa84ee3a87ab8226995.tar.bz2 samba-7e651c7ef3afb4effa045fa84ee3a87ab8226995.zip |
Simplify customization of pidl-generated Python modules.
Diffstat (limited to 'source4/libcli')
-rw-r--r-- | source4/libcli/security/dom_sid.c | 40 |
1 files changed, 24 insertions, 16 deletions
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;i<num_sub_auths;i++) { if (sidstr[0] != '-') { - return NULL; + return false; } sidstr++; ret->sub_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; } |