#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;
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;
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;
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;
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;
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);
{
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)