summaryrefslogtreecommitdiff
path: root/source4/passdb/secrets.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-12-16 09:02:58 +0000
committerAndrew Tridgell <tridge@samba.org>2003-12-16 09:02:58 +0000
commit24c22aef90d8534ee2d016b37b2b302f1367d106 (patch)
treececb9192f1a83f7232041cda58e83e1d94ac57b5 /source4/passdb/secrets.c
parent1413faae582949e7d12174df7102723eea914464 (diff)
downloadsamba-24c22aef90d8534ee2d016b37b2b302f1367d106.tar.gz
samba-24c22aef90d8534ee2d016b37b2b302f1367d106.tar.bz2
samba-24c22aef90d8534ee2d016b37b2b302f1367d106.zip
a fairly large commit!
This adds support for bigendian rpc in the client. I have installed SUN pcnetlink locally and am using it to test the samba4 rpc code. This allows us to easily find places where we have stuffed up the types (such as 2 uint16 versus a uint32), as testing both big-endian and little-endian easily shows which is correct. I have now used this to fix several bugs like that in the samba4 IDL. In order to make this work I also had to redefine a GUID as a true structure, not a blob. From the pcnetlink wire it is clear that it is indeed defined as a structure (the byte order changes). This required changing lots of Samba code to use a GUID as a structure. I also had to fix the if_version code in dcerpc syntax IDs, as it turns out they are a single uint32 not two uint16s. The big-endian support is a bit ugly at the moment, and breaks the layering in some places. More work is needed, especially on the server side. (This used to be commit bb1af644a5a7b188290ce36232f255da0e5d66d2)
Diffstat (limited to 'source4/passdb/secrets.c')
-rw-r--r--source4/passdb/secrets.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/source4/passdb/secrets.c b/source4/passdb/secrets.c
index 60e211e66f..486ccb8b11 100644
--- a/source4/passdb/secrets.c
+++ b/source4/passdb/secrets.c
@@ -141,25 +141,44 @@ BOOL secrets_fetch_domain_sid(const char *domain, DOM_SID *sid)
return True;
}
-BOOL secrets_store_domain_guid(const char *domain, GUID *guid)
+BOOL secrets_store_domain_guid(const char *domain, struct GUID *guid)
{
+ const char *s;
fstring key;
+ TALLOC_CTX *mem_ctx;
+ BOOL ret;
+
+ mem_ctx = talloc_init("secrets_store_domain_guid");
+ if (!mem_ctx) {
+ return False;
+ }
+
+ s = GUID_string(mem_ctx, guid);
+ if (!s) {
+ talloc_destroy(mem_ctx);
+ return False;
+ }
+
slprintf(key, sizeof(key)-1, "%s/%s", SECRETS_DOMAIN_GUID, domain);
strupper(key);
- return secrets_store(key, guid, sizeof(GUID));
+ ret = secrets_store(key, s, strlen(s)+1);
+
+ talloc_destroy(mem_ctx);
+ return ret;
}
-BOOL secrets_fetch_domain_guid(const char *domain, GUID *guid)
+BOOL secrets_fetch_domain_guid(const char *domain, struct GUID *guid)
{
- GUID *dyn_guid;
+ char *dyn_guid;
fstring key;
size_t size;
- GUID new_guid;
+ struct GUID new_guid;
+ NTSTATUS status;
slprintf(key, sizeof(key)-1, "%s/%s", SECRETS_DOMAIN_GUID, domain);
strupper(key);
- dyn_guid = (GUID *)secrets_fetch(key, &size);
+ dyn_guid = secrets_fetch(key, &size);
DEBUG(6,("key is %s, size is %d\n", key, (int)size));
@@ -167,19 +186,18 @@ BOOL secrets_fetch_domain_guid(const char *domain, GUID *guid)
uuid_generate_random(&new_guid);
if (!secrets_store_domain_guid(domain, &new_guid))
return False;
- dyn_guid = (GUID *)secrets_fetch(key, &size);
+ dyn_guid = secrets_fetch(key, &size);
if (dyn_guid == NULL)
return False;
}
- if (size != sizeof(GUID))
- {
- SAFE_FREE(dyn_guid);
+ status = GUID_from_string(dyn_guid, guid);
+ SAFE_FREE(dyn_guid);
+
+ if (!NT_STATUS_IS_OK(status)) {
return False;
}
- *guid = *dyn_guid;
- SAFE_FREE(dyn_guid);
return True;
}