out->clock_seq[0] = (out->clock_seq[0] & 0x3F) | 0x80;
out->time_hi_and_version = (out->time_hi_and_version & 0x0FFF) | 0x4000;
}
+
+BOOL uuid_all_zero(const struct GUID *u)
+{
+ if (u->time_low != 0 ||
+ u->time_mid != 0 ||
+ u->time_hi_and_version != 0 ||
+ u->clock_seq[0] != 0 ||
+ u->clock_seq[1] != 0 ||
+ !all_zero(u->node, 6)) {
+ return False;
+ }
+ return True;
+}
+
+BOOL uuid_equal(const struct GUID *u1, const struct GUID *u2)
+{
+ if (u1->time_low != u2->time_low ||
+ u1->time_mid != u2->time_mid ||
+ u1->time_hi_and_version != u2->time_hi_and_version ||
+ u1->clock_seq[0] != u2->clock_seq[0] ||
+ u1->clock_seq[1] != u2->clock_seq[1] ||
+ memcmp(u1->node, u2->node, 6) != 0) {
+ return False;
+ }
+ return True;
+}
[relative] security_acl *dacl; /* user (discretionary) ACL */
} security_descriptor;
- typedef [public, flag(NDR_PAHEX)] struct {
- uint8 data[20];
+ typedef [public] struct {
+ uint32 handle_type;
+ GUID uuid;
} policy_handle;
-
/* a 4 byte aligned 64-bit integer */
typedef [public] struct {
uint32 low;
h->mem_ctx = mem_ctx;
h->data = NULL;
- memset(h->wire_handle.data, 'H', sizeof(h->wire_handle.data));
- strncpy(h->wire_handle.data, dce->ndr->name, 11);
- h->wire_handle.data[11] = handle_type;
+ h->wire_handle.handle_type = handle_type;
+ uuid_generate_random(&h->wire_handle.uuid);
- /* TODO: check for wraparound here */
- SIVAL(&h->wire_handle.data, 12, random());
- dce->next_handle++;
- SIVAL(&h->wire_handle.data, 16, dce->next_handle);
-
DLIST_ADD(dce->handles, h);
return h;
{
struct dcesrv_handle *h;
- if (all_zero(p->data, sizeof(p->data))) {
+ if (p->handle_type == 0 && uuid_all_zero(&p->uuid)) {
return dcesrv_handle_new(dce, handle_type);
}
for (h=dce->handles; h; h=h->next) {
- if (memcmp(h->wire_handle.data, p->data, sizeof(p->data)) == 0) {
+ if (h->wire_handle.handle_type == p->handle_type &&
+ uuid_equal(&p->uuid, &h->wire_handle.uuid)) {
+ if (p->handle_type != handle_type) {
+ DEBUG(0,("client gave us the wrong handle type (%d should be %d)\n",
+ p->handle_type, handle_type));
+ return NULL;
+ }
return h;
}
}