s3-clusapi: add helper functions for manipulating a clusapi_PROPERTY_LIST.
authorGünther Deschner <gd@samba.org>
Fri, 17 Jul 2015 12:12:38 +0000 (14:12 +0200)
committerGünther Deschner <gd@samba.org>
Sun, 3 Feb 2019 09:26:15 +0000 (10:26 +0100)
Guenther

Signed-off-by: Günther Deschner <gd@samba.org>
source3/rpc_server/clusapi/srv_clusapi_nt.c

index f4b38ffaa57c016cb097607c4ed48bd849e41c47..8beb7d832978dca67a9d338823e93a72df5a67b3 100644 (file)
@@ -1824,6 +1824,95 @@ static const uint8_t group_control_data[] = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 };
 
+#if 0
+static bool add_property_to_array(TALLOC_CTX *mem_ctx,
+                                 struct clusapi_propertyValue property,
+                                 struct clusapi_propertyValue **array,
+                                 uint32_t *count)
+{
+       *array = talloc_realloc(mem_ctx, *array, struct clusapi_propertyValue,
+                               *count+1);
+       if (*array == NULL) {
+               *count = 0;
+               return false;
+       }
+       (*array)[*count] = property;
+       *count += 1;
+
+       return true;
+}
+
+static bool add_reg_sz_to_property_list(TALLOC_CTX *mem_ctx,
+                                       struct clusapi_PROPERTY_LIST *list,
+                                       const char *name,
+                                       const char *value)
+{
+       struct clusapi_propertyValue p;
+       bool ok;
+       ZERO_STRUCT(p);
+       p.buffer = talloc_strdup(mem_ctx, name);
+       if (p.buffer == NULL) {
+               return false;
+       }
+       p.PropertyValues.Syntax = CLUSPROP_SYNTAX_LIST_VALUE_SZ;
+
+       ok = push_reg_sz(mem_ctx, &p.PropertyValues.Buffer, value);
+       if (!ok) {
+               return false;
+       }
+       p.PropertyValues.Size = p.PropertyValues.Buffer.length;
+
+       return add_property_to_array(mem_ctx, p,
+                                    &list->propertyValues,
+                                    &list->propertyCount);
+}
+
+static bool add_reg_dword_to_property_list(TALLOC_CTX *mem_ctx,
+                                          struct clusapi_PROPERTY_LIST *list,
+                                          const char *name,
+                                          uint32_t value)
+{
+       struct clusapi_propertyValue p;
+       ZERO_STRUCT(p);
+       p.buffer = talloc_strdup(mem_ctx, name);
+       if (p.buffer == NULL) {
+               return false;
+       }
+       p.PropertyValues.Syntax = CLUSPROP_SYNTAX_LIST_VALUE_DWORD;
+
+       p.PropertyValues.Buffer = data_blob_talloc(mem_ctx, NULL, 4);
+       SIVAL(p.PropertyValues.Buffer.data, 0, value);
+
+       p.PropertyValues.Size = p.PropertyValues.Buffer.length;
+
+       return add_property_to_array(mem_ctx, p,
+                                    &list->propertyValues,
+                                    &list->propertyCount);
+}
+
+static bool add_reg_qword_to_property_list(TALLOC_CTX *mem_ctx,
+                                          struct clusapi_PROPERTY_LIST *list,
+                                          const char *name,
+                                          uint64_t value)
+{
+       struct clusapi_propertyValue p;
+       ZERO_STRUCT(p);
+       p.buffer = talloc_strdup(mem_ctx, name);
+       if (p.buffer == NULL) {
+               return false;
+       }
+       p.PropertyValues.Syntax = CLUSPROP_SYNTAX_LIST_VALUE_ULARGE_INTEGER;
+
+       p.PropertyValues.Buffer = data_blob_talloc(mem_ctx, NULL, 8);
+       SBVAL(p.PropertyValues.Buffer.data, 0, value);
+
+       p.PropertyValues.Size = p.PropertyValues.Buffer.length;
+
+       return add_property_to_array(mem_ctx, p,
+                                    &list->propertyValues,
+                                    &list->propertyCount);
+}
+#endif
 WERROR _clusapi_GroupControl(struct pipes_struct *p,
                             struct clusapi_GroupControl *r)
 {