r15356: Remove unused 'flags' argument from socket_send() and friends.
[bbaumbach/samba-autobuild/.git] / source4 / lib / registry / reg_backend_dir.c
index c004be5a064ebbcbae1fd8e093898de8a3b84c41..beedc0615b68aadcc6d94c103432eee3bd3d98e7 100644 (file)
@@ -21,8 +21,9 @@
 #include "includes.h"
 #include "registry.h"
 #include "system/dir.h"
+#include "system/filesys.h"
 
-static WERROR reg_dir_add_key(TALLOC_CTX *mem_ctx, struct registry_key *parent, const char *name, uint32_t access_mask, SEC_DESC *desc, struct registry_key **result)
+static WERROR reg_dir_add_key(TALLOC_CTX *mem_ctx, const struct registry_key *parent, const char *name, uint32_t access_mask, struct security_descriptor *desc, struct registry_key **result)
 {
        char *path;
        int ret;
@@ -34,12 +35,19 @@ static WERROR reg_dir_add_key(TALLOC_CTX *mem_ctx, struct registry_key *parent,
        return WERR_INVALID_PARAM;
 }
 
-static WERROR reg_dir_del_key(struct registry_key *k)
+static WERROR reg_dir_del_key(const struct registry_key *k, const char *name)
 {
-       return (rmdir((char *)k->backend_data) == 0)?WERR_OK:WERR_GENERAL_FAILURE;
+       char *child = talloc_asprintf(NULL, "%s/%s", (char *)k->backend_data, name);
+       WERROR ret;
+
+       if (rmdir(child) == 0) ret = WERR_OK; else ret = WERR_GENERAL_FAILURE;
+
+       talloc_free(child);
+
+       return ret;
 }
 
-static WERROR reg_dir_open_key(TALLOC_CTX *mem_ctx, struct registry_key *p, const char *name, struct registry_key **subkey)
+static WERROR reg_dir_open_key(TALLOC_CTX *mem_ctx, const struct registry_key *p, const char *name, struct registry_key **subkey)
 {
        DIR *d;
        char *fullpath, *unixpath;
@@ -60,7 +68,7 @@ static WERROR reg_dir_open_key(TALLOC_CTX *mem_ctx, struct registry_key *p, cons
                return WERR_BADFILE;
        }
        closedir(d);
-       ret = talloc_p(mem_ctx, struct registry_key);
+       ret = talloc(mem_ctx, struct registry_key);
        ret->hive = p->hive;
        ret->path = fullpath;
        ret->backend_data = unixpath;
@@ -68,7 +76,7 @@ static WERROR reg_dir_open_key(TALLOC_CTX *mem_ctx, struct registry_key *p, cons
        return WERR_OK;
 }
 
-static WERROR reg_dir_key_by_index(TALLOC_CTX *mem_ctx, struct registry_key *k, int idx, struct registry_key **key)
+static WERROR reg_dir_key_by_index(TALLOC_CTX *mem_ctx, const struct registry_key *k, int idx, struct registry_key **key)
 {
        struct dirent *e;
        char *fullpath = k->backend_data;
@@ -80,8 +88,7 @@ static WERROR reg_dir_key_by_index(TALLOC_CTX *mem_ctx, struct registry_key *k,
        if(!d) return WERR_INVALID_PARAM;
        
        while((e = readdir(d))) {
-               if( strcmp(e->d_name, ".") &&
-                  strcmp(e->d_name, "..")) {
+               if(!ISDOT(e->d_name) && !ISDOTDOT(e->d_name)) {
                        struct stat stbuf;
                        char *thispath;
                        
@@ -91,7 +98,7 @@ static WERROR reg_dir_key_by_index(TALLOC_CTX *mem_ctx, struct registry_key *k,
 
                        if(S_ISDIR(stbuf.st_mode)) {
                                if(i == idx) {
-                                       (*key) = talloc_p(mem_ctx, struct registry_key);
+                                       (*key) = talloc(mem_ctx, struct registry_key);
                                        (*key)->name = e->d_name;
                                        (*key)->path = NULL;
                                        (*key)->backend_data = talloc_strdup(mem_ctx, thispath);
@@ -115,32 +122,18 @@ static WERROR reg_dir_open(struct registry_hive *h, struct registry_key **key)
 {
        if(!h->location) return WERR_INVALID_PARAM;
 
-       *key = talloc_p(h, struct registry_key);
+       *key = talloc(h, struct registry_key);
        (*key)->backend_data = talloc_strdup(*key, h->location);
        return WERR_OK;
 }
 
-static WERROR reg_dir_set_value(struct registry_key *p, const char *name, int type, void *data, int len)
-{
-       /* FIXME */
-       return WERR_NOT_SUPPORTED;
-}
-
-static WERROR reg_dir_del_value(struct registry_value *v)
-{
-       /* FIXME*/
-       return WERR_NOT_SUPPORTED;
-}
-
 static struct hive_operations reg_backend_dir = {
        .name = "dir",
        .open_hive = reg_dir_open,
        .open_key = reg_dir_open_key,
        .add_key = reg_dir_add_key,
        .del_key = reg_dir_del_key,
-       .get_subkey_by_index = reg_dir_key_by_index,
-       .set_value = reg_dir_set_value,
-       .del_value = reg_dir_del_value,
+       .get_subkey_by_index = reg_dir_key_by_index
 };
 
 NTSTATUS registry_dir_init(void)