summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2004-10-29 08:31:27 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:05:00 -0500
commit659332794871c64470fd23b5a15e1f45fcb78a84 (patch)
treeb3641918b078973c2c675d5cdf5cfe566a310a14
parentdbf03959244c392073281c10badd2095397ad2f2 (diff)
downloadsamba-659332794871c64470fd23b5a15e1f45fcb78a84.tar.gz
samba-659332794871c64470fd23b5a15e1f45fcb78a84.tar.bz2
samba-659332794871c64470fd23b5a15e1f45fcb78a84.zip
r3358: Try to put all the basic struct dom_sid manipulation functions in one
place. (I always have trouble finding one half or the other). Andrew Bartlett (This used to be commit 224b59edba7c00ad515b4c5e3e9a886700247ad4)
-rw-r--r--source4/libcli/util/dom_sid.c57
-rw-r--r--source4/librpc/ndr/ndr_sec.c57
2 files changed, 57 insertions, 57 deletions
diff --git a/source4/libcli/util/dom_sid.c b/source4/libcli/util/dom_sid.c
index c2d188abec..1faf3debab 100644
--- a/source4/libcli/util/dom_sid.c
+++ b/source4/libcli/util/dom_sid.c
@@ -23,6 +23,39 @@
#include "includes.h"
/*
+ convert a dom_sid to a string
+*/
+char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid)
+{
+ int i, ofs, maxlen;
+ uint32_t ia;
+ char *ret;
+
+ if (!sid) {
+ return talloc_strdup(mem_ctx, "(NULL SID)");
+ }
+
+ maxlen = sid->num_auths * 11 + 25;
+ ret = talloc(mem_ctx, maxlen);
+ if (!ret) return talloc_strdup(mem_ctx, "(SID ERR)");
+
+ ia = (sid->id_auth[5]) +
+ (sid->id_auth[4] << 8 ) +
+ (sid->id_auth[3] << 16) +
+ (sid->id_auth[2] << 24);
+
+ ofs = snprintf(ret, maxlen, "S-%u-%lu",
+ (uint_t)sid->sid_rev_num, (unsigned long)ia);
+
+ for (i = 0; i < sid->num_auths; i++) {
+ ofs += snprintf(ret + ofs, maxlen - ofs, "-%lu", (unsigned long)sid->sub_auths[i]);
+ }
+
+ return ret;
+}
+
+
+/*
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)
@@ -121,3 +154,27 @@ struct dom_sid *dom_sid_dup(TALLOC_CTX *mem_ctx, struct dom_sid *dom_sid)
return ret;
}
+/*
+ add a rid to a domain dom_sid to make a full dom_sid
+*/
+struct dom_sid *dom_sid_add_rid(TALLOC_CTX *mem_ctx,
+ const struct dom_sid *domain_sid,
+ uint32_t rid)
+{
+ struct dom_sid *sid;
+
+ sid = talloc_p(mem_ctx, struct dom_sid);
+ if (!sid) return NULL;
+
+ *sid = *domain_sid;
+ /*TODO: use realloc! */
+ sid->sub_auths = talloc_array_p(mem_ctx, uint32_t, sid->num_auths+1);
+ if (!sid->sub_auths) {
+ return NULL;
+ }
+ memcpy(sid->sub_auths, domain_sid->sub_auths, sid->num_auths*sizeof(uint32_t));
+ sid->sub_auths[sid->num_auths] = rid;
+ sid->num_auths++;
+ return sid;
+}
+
diff --git a/source4/librpc/ndr/ndr_sec.c b/source4/librpc/ndr/ndr_sec.c
index f9169536ae..c91c2762c2 100644
--- a/source4/librpc/ndr/ndr_sec.c
+++ b/source4/librpc/ndr/ndr_sec.c
@@ -51,39 +51,6 @@ NTSTATUS ndr_push_dom_sid2(struct ndr_push *ndr, int ndr_flags, struct dom_sid *
/*
- convert a dom_sid to a string
-*/
-char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid)
-{
- int i, ofs, maxlen;
- uint32_t ia;
- char *ret;
-
- if (!sid) {
- return talloc_strdup(mem_ctx, "(NULL SID)");
- }
-
- maxlen = sid->num_auths * 11 + 25;
- ret = talloc(mem_ctx, maxlen);
- if (!ret) return talloc_strdup(mem_ctx, "(SID ERR)");
-
- ia = (sid->id_auth[5]) +
- (sid->id_auth[4] << 8 ) +
- (sid->id_auth[3] << 16) +
- (sid->id_auth[2] << 24);
-
- ofs = snprintf(ret, maxlen, "S-%u-%lu",
- (uint_t)sid->sid_rev_num, (unsigned long)ia);
-
- for (i = 0; i < sid->num_auths; i++) {
- ofs += snprintf(ret + ofs, maxlen - ofs, "-%lu", (unsigned long)sid->sub_auths[i]);
- }
-
- return ret;
-}
-
-
-/*
print a dom_sid
*/
void ndr_print_dom_sid(struct ndr_print *ndr, const char *name, struct dom_sid *sid)
@@ -106,30 +73,6 @@ size_t ndr_size_dom_sid(struct dom_sid *sid)
}
/*
- add a rid to a domain dom_sid to make a full dom_sid
-*/
-struct dom_sid *dom_sid_add_rid(TALLOC_CTX *mem_ctx,
- const struct dom_sid *domain_sid,
- uint32_t rid)
-{
- struct dom_sid *sid;
-
- sid = talloc_p(mem_ctx, struct dom_sid);
- if (!sid) return NULL;
-
- *sid = *domain_sid;
- /*TODO: use realloc! */
- sid->sub_auths = talloc_array_p(mem_ctx, uint32_t, sid->num_auths+1);
- if (!sid->sub_auths) {
- return NULL;
- }
- memcpy(sid->sub_auths, domain_sid->sub_auths, sid->num_auths*sizeof(uint32_t));
- sid->sub_auths[sid->num_auths] = rid;
- sid->num_auths++;
- return sid;
-}
-
-/*
return the wire size of a security_ace
*/
size_t ndr_size_security_ace(struct security_ace *ace)