r25544: Cleanup some more indents in lib/registry.
authorGünther Deschner <gd@samba.org>
Sat, 6 Oct 2007 00:17:44 +0000 (00:17 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 20:07:51 +0000 (15:07 -0500)
Guenther
(This used to be commit 0d9826dc54057db2cfebcb806e5442c4dcf60daa)

16 files changed:
source4/lib/registry/dir.c
source4/lib/registry/hive.c
source4/lib/registry/hive.h
source4/lib/registry/interface.c
source4/lib/registry/ldb.c
source4/lib/registry/local.c
source4/lib/registry/patchfile.c
source4/lib/registry/patchfile.h
source4/lib/registry/patchfile_dotreg.c
source4/lib/registry/patchfile_preg.c
source4/lib/registry/regf.c
source4/lib/registry/registry.h
source4/lib/registry/rpc.c
source4/lib/registry/samba.c
source4/lib/registry/util.c
source4/lib/registry/wine.c

index 146c5197fd76ff0aef8d645ed1a5f61b203a378b..532770bcaf04fb23e2b4d0d6203a4d3d55c2c7af 100644 (file)
@@ -1,18 +1,18 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Registry interface
-   Copyright (C) Jelmer Vernooij                                         2004-2007.
-   
+   Copyright (C) Jelmer Vernooij                                 2004-2007.
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -29,11 +29,11 @@ struct dir_key {
 
 static struct hive_operations reg_backend_dir;
 
-static WERROR reg_dir_add_key(TALLOC_CTX *mem_ctx, 
-                                                         const struct hive_key *parent, 
-                                                         const char *name, const char *classname,
-                                                         struct security_descriptor *desc, 
-                                                         struct hive_key **result)
+static WERROR reg_dir_add_key(TALLOC_CTX *mem_ctx,
+                             const struct hive_key *parent,
+                             const char *name, const char *classname,
+                             struct security_descriptor *desc,
+                             struct hive_key **result)
 {
        struct dir_key *dk = talloc_get_type(parent, struct dir_key);
        char *path;
@@ -61,8 +61,8 @@ static WERROR reg_dir_del_key(const struct hive_key *k, const char *name)
        char *child = talloc_asprintf(NULL, "%s/%s", dk->path, name);
        WERROR ret;
 
-       if (rmdir(child) == 0) 
-               ret = WERR_OK; 
+       if (rmdir(child) == 0)
+               ret = WERR_OK;
        else if (errno == ENOENT)
                ret = WERR_NOT_FOUND;
        else
@@ -73,25 +73,26 @@ static WERROR reg_dir_del_key(const struct hive_key *k, const char *name)
        return ret;
 }
 
-static WERROR reg_dir_open_key(TALLOC_CTX *mem_ctx, 
-                                                          const struct hive_key *parent, 
-                                                          const char *name, struct hive_key **subkey)
+static WERROR reg_dir_open_key(TALLOC_CTX *mem_ctx,
+                              const struct hive_key *parent,
+                              const char *name, struct hive_key **subkey)
 {
        DIR *d;
        char *fullpath;
        const struct dir_key *p = talloc_get_type(parent, struct dir_key);
        struct dir_key *ret;
-       
+
        if (name == NULL) {
                DEBUG(0, ("NULL pointer passed as directory name!"));
                return WERR_INVALID_PARAM;
        }
-       
+
        fullpath = talloc_asprintf(mem_ctx, "%s/%s", p->path, name);
-       
+
        d = opendir(fullpath);
        if (d == NULL) {
-               DEBUG(3,("Unable to open '%s': %s\n", fullpath, strerror(errno)));
+               DEBUG(3,("Unable to open '%s': %s\n", fullpath,
+                       strerror(errno)));
                return WERR_BADFILE;
        }
        closedir(d);
@@ -102,11 +103,11 @@ static WERROR reg_dir_open_key(TALLOC_CTX *mem_ctx,
        return WERR_OK;
 }
 
-static WERROR reg_dir_key_by_index(TALLOC_CTX *mem_ctx, 
-                                                                  const struct hive_key *k, uint32_t idx, 
-                                                                  const char **name,
-                                                                  const char **classname,
-                                                                  NTTIME *last_mod_time)
+static WERROR reg_dir_key_by_index(TALLOC_CTX *mem_ctx,
+                                  const struct hive_key *k, uint32_t idx,
+                                  const char **name,
+                                  const char **classname,
+                                  NTTIME *last_mod_time)
 {
        struct dirent *e;
        const struct dir_key *dk = talloc_get_type(k, struct dir_key);
@@ -115,14 +116,14 @@ static WERROR reg_dir_key_by_index(TALLOC_CTX *mem_ctx,
 
        d = opendir(dk->path);
 
-       if (d == NULL) 
+       if (d == NULL)
                return WERR_INVALID_PARAM;
-       
+
        while((e = readdir(d))) {
                if(!ISDOT(e->d_name) && !ISDOTDOT(e->d_name)) {
                        struct stat stbuf;
                        char *thispath;
-                       
+
                        /* Check if file is a directory */
                        asprintf(&thispath, "%s/%s", dk->path, e->d_name);
                        stat(thispath, &stbuf);
@@ -153,12 +154,12 @@ static WERROR reg_dir_key_by_index(TALLOC_CTX *mem_ctx,
        return WERR_NO_MORE_ITEMS;
 }
 
-WERROR reg_open_directory(TALLOC_CTX *parent_ctx, 
-                                                 const char *location, struct hive_key **key)
+WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
+                         const char *location, struct hive_key **key)
 {
        struct dir_key *dk;
 
-       if (location == NULL) 
+       if (location == NULL)
                return WERR_INVALID_PARAM;
 
        dk = talloc(parent_ctx, struct dir_key);
@@ -168,8 +169,8 @@ WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
        return WERR_OK;
 }
 
-WERROR reg_create_directory(TALLOC_CTX *parent_ctx, 
-                                                       const char *location, struct hive_key **key)
+WERROR reg_create_directory(TALLOC_CTX *parent_ctx,
+                           const char *location, struct hive_key **key)
 {
        if (mkdir(location, 0700) != 0) {
                *key = NULL;
@@ -179,11 +180,11 @@ WERROR reg_create_directory(TALLOC_CTX *parent_ctx,
        return reg_open_directory(parent_ctx, location, key);
 }
 
-static WERROR reg_dir_get_info(TALLOC_CTX *ctx, const struct hive_key *key, 
-                                                          const char **classname,
-                                                          uint32_t *num_subkeys,
-                                                          uint32_t *num_values,
-                                                          NTTIME *lastmod)
+static WERROR reg_dir_get_info(TALLOC_CTX *ctx, const struct hive_key *key,
+                              const char **classname,
+                              uint32_t *num_subkeys,
+                              uint32_t *num_values,
+                              NTTIME *lastmod)
 {
        DIR *d;
        const struct dir_key *dk = talloc_get_type(key, struct dir_key);
@@ -196,7 +197,7 @@ static WERROR reg_dir_get_info(TALLOC_CTX *ctx, const struct hive_key *key,
                *classname = NULL;
 
        d = opendir(dk->path);
-       if (d == NULL) 
+       if (d == NULL)
                return WERR_INVALID_PARAM;
 
        if (num_subkeys != NULL)
@@ -207,10 +208,12 @@ static WERROR reg_dir_get_info(TALLOC_CTX *ctx, const struct hive_key *key,
 
        while((e = readdir(d))) {
                if(!ISDOT(e->d_name) && !ISDOTDOT(e->d_name)) {
-                       char *path = talloc_asprintf(ctx, "%s/%s", dk->path, e->d_name);
+                       char *path = talloc_asprintf(ctx, "%s/%s",
+                                                    dk->path, e->d_name);
 
                        if (stat(path, &st) < 0) {
-                               DEBUG(0, ("Error statting %s: %s\n", path, strerror(errno)));
+                               DEBUG(0, ("Error statting %s: %s\n", path,
+                                       strerror(errno)));
                                continue;
                        }
 
@@ -231,8 +234,8 @@ static WERROR reg_dir_get_info(TALLOC_CTX *ctx, const struct hive_key *key,
        return WERR_OK;
 }
 
-static WERROR reg_dir_set_value (struct hive_key *key, const char *name, 
-                                                uint32_t type, const DATA_BLOB data)
+static WERROR reg_dir_set_value(struct hive_key *key, const char *name,
+                               uint32_t type, const DATA_BLOB data)
 {
        const struct dir_key *dk = talloc_get_type(key, struct dir_key);
        char *path = talloc_asprintf(dk, "%s/%s", dk->path, name);
@@ -245,9 +248,9 @@ static WERROR reg_dir_set_value (struct hive_key *key, const char *name,
        return WERR_OK;
 }
 
-static WERROR reg_dir_get_value (TALLOC_CTX *mem_ctx, 
-                                                                struct hive_key *key, const char *name, 
-                                                                uint32_t *type, DATA_BLOB *data)
+static WERROR reg_dir_get_value(TALLOC_CTX *mem_ctx,
+                               struct hive_key *key, const char *name,
+                               uint32_t *type, DATA_BLOB *data)
 {
        const struct dir_key *dk = talloc_get_type(key, struct dir_key);
        char *path = talloc_asprintf(mem_ctx, "%s/%s", dk->path, name);
@@ -256,7 +259,7 @@ static WERROR reg_dir_get_value (TALLOC_CTX *mem_ctx,
 
        contents = file_load(path, &size, mem_ctx);
        talloc_free(path);
-       if (contents == NULL) 
+       if (contents == NULL)
                return WERR_NOT_FOUND;
 
        if (type != NULL)
@@ -267,11 +270,11 @@ static WERROR reg_dir_get_value (TALLOC_CTX *mem_ctx,
 
        return WERR_OK;
 }
-       
-static WERROR reg_dir_enum_value (TALLOC_CTX *mem_ctx, 
-                                                                const struct hive_key *key, int idx, 
-                                                                const char **name, 
-                                                                uint32_t *type, DATA_BLOB *data)
+
+static WERROR reg_dir_enum_value(TALLOC_CTX *mem_ctx,
+                                const struct hive_key *key, int idx,
+                                const char **name,
+                                uint32_t *type, DATA_BLOB *data)
 {
        const struct dir_key *dk = talloc_get_type(key, struct dir_key);
        DIR *d;
@@ -280,19 +283,22 @@ static WERROR reg_dir_enum_value (TALLOC_CTX *mem_ctx,
 
        d = opendir(dk->path);
        if (d == NULL) {
-               DEBUG(3,("Unable to open '%s': %s\n", dk->path, strerror(errno)));
+               DEBUG(3,("Unable to open '%s': %s\n", dk->path,
+                       strerror(errno)));
                return WERR_BADFILE;
        }
 
        i = 0;
        while((e = readdir(d))) {
-               if (ISDOT(e->d_name) || ISDOTDOT(e->d_name)) 
+               if (ISDOT(e->d_name) || ISDOTDOT(e->d_name))
                        continue;
 
                if (i == idx) {
                        if (name != NULL)
                                *name = talloc_strdup(mem_ctx, e->d_name);
-                       W_ERROR_NOT_OK_RETURN(reg_dir_get_value(mem_ctx, key, *name, type, data));
+                       W_ERROR_NOT_OK_RETURN(reg_dir_get_value(mem_ctx, key,
+                                                               *name, type,
+                                                               data));
                        return WERR_OK;
                }
 
@@ -315,7 +321,7 @@ static WERROR reg_dir_del_value (struct hive_key *key, const char *name)
                return WERR_GENERAL_FAILURE;
        }
        talloc_free(path);
-               
+
        return WERR_OK;
 }
 
index 97ce883e66349164e556ad2495f533d3ab6129a5..16534aac9c5718bea51b2283f92c782d2ed27171 100644 (file)
@@ -1,19 +1,19 @@
 
-/* 
+/*
    Unix SMB/CIFS implementation.
    Registry hive interface
-   Copyright (C) Jelmer Vernooij                                         2003-2007.
-   
+   Copyright (C) Jelmer Vernooij                                 2003-2007.
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 #include "system/filesys.h"
 
 /** Open a registry file/host/etc */
-_PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location, 
-                                                         struct auth_session_info *session_info, 
-                                                         struct cli_credentials *credentials, 
-                                                         struct hive_key **root)
+_PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
+                             struct auth_session_info *session_info,
+                             struct cli_credentials *credentials,
+                             struct hive_key **root)
 {
        int fd, num;
        char peek[20];
@@ -54,28 +54,33 @@ _PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
                return reg_open_regf_file(parent_ctx, location, root);
        } else if (!strncmp(peek, "TDB file", 8)) {
                close(fd);
-               return reg_open_ldb_file(parent_ctx, location, session_info, credentials, root);
+               return reg_open_ldb_file(parent_ctx, location, session_info,
+                                        credentials, root);
        }
 
        return WERR_BADFILE;
 }
 
-_PUBLIC_ WERROR hive_key_get_info(TALLOC_CTX *mem_ctx, const struct hive_key *key,
-                                                const char **classname, uint32_t *num_subkeys, 
-                                                uint32_t *num_values,
-                                                NTTIME *last_change_time)
+_PUBLIC_ WERROR hive_key_get_info(TALLOC_CTX *mem_ctx,
+                                 const struct hive_key *key,
+                                 const char **classname, uint32_t *num_subkeys,
+                                 uint32_t *num_values,
+                                 NTTIME *last_change_time)
 {
-       return key->ops->get_key_info(mem_ctx, key, classname, num_subkeys, 
-                                                                       num_values, last_change_time);
+       return key->ops->get_key_info(mem_ctx, key, classname, num_subkeys,
+                                     num_values, last_change_time);
 }
 
-_PUBLIC_ WERROR hive_key_add_name(TALLOC_CTX *ctx, const struct hive_key *parent_key,
-                                                const char *name, const char *classname, struct security_descriptor *desc,
-                                                struct hive_key **key)
+_PUBLIC_ WERROR hive_key_add_name(TALLOC_CTX *ctx,
+                                 const struct hive_key *parent_key,
+                                 const char *name, const char *classname,
+                                 struct security_descriptor *desc,
+                                 struct hive_key **key)
 {
        SMB_ASSERT(strchr(name, '\\') == NULL);
 
-       return parent_key->ops->add_key(ctx, parent_key, name, classname, desc, key);
+       return parent_key->ops->add_key(ctx, parent_key, name, classname,
+                                       desc, key);
 }
 
 _PUBLIC_ WERROR hive_key_del(const struct hive_key *key, const char *name)
@@ -84,20 +89,21 @@ _PUBLIC_ WERROR hive_key_del(const struct hive_key *key, const char *name)
 }
 
 _PUBLIC_ WERROR hive_get_key_by_name(TALLOC_CTX *mem_ctx,
-                                                          const struct hive_key *key, const char *name, 
-                                                          struct hive_key **subkey)
+                                    const struct hive_key *key,
+                                    const char *name,
+                                    struct hive_key **subkey)
 {
        return key->ops->get_key_by_name(mem_ctx, key, name, subkey);
 }
 
 WERROR hive_enum_key(TALLOC_CTX *mem_ctx,
-                                       const struct hive_key *key, uint32_t idx, 
-                                       const char **name,
-                                       const char **classname,
-                                       NTTIME *last_mod_time)
+                    const struct hive_key *key, uint32_t idx,
+                    const char **name,
+                    const char **classname,
+                    NTTIME *last_mod_time)
 {
-       return key->ops->enum_key(mem_ctx, key, idx, name, classname, 
-                                                         last_mod_time);
+       return key->ops->enum_key(mem_ctx, key, idx, name, classname,
+                                 last_mod_time);
 }
 
 WERROR hive_set_value(struct hive_key *key, const char *name, uint32_t type,
@@ -109,9 +115,9 @@ WERROR hive_set_value(struct hive_key *key, const char *name, uint32_t type,
        return key->ops->set_value(key, name, type, data);
 }
 
-WERROR hive_get_value (TALLOC_CTX *mem_ctx, 
-                                          struct hive_key *key, const char *name, 
-                                          uint32_t *type, DATA_BLOB *data)
+WERROR hive_get_value(TALLOC_CTX *mem_ctx,
+                     struct hive_key *key, const char *name,
+                     uint32_t *type, DATA_BLOB *data)
 {
        if (key->ops->get_value_by_name == NULL)
                return WERR_NOT_SUPPORTED;
@@ -119,9 +125,10 @@ WERROR hive_get_value (TALLOC_CTX *mem_ctx,
        return key->ops->get_value_by_name(mem_ctx, key, name, type, data);
 }
 
-WERROR hive_get_value_by_index (TALLOC_CTX *mem_ctx, 
-                                          struct hive_key *key, uint32_t idx, const char **name, 
-                                          uint32_t *type, DATA_BLOB *data)
+WERROR hive_get_value_by_index(TALLOC_CTX *mem_ctx,
+                              struct hive_key *key, uint32_t idx,
+                              const char **name,
+                              uint32_t *type, DATA_BLOB *data)
 {
        if (key->ops->enum_value == NULL)
                return WERR_NOT_SUPPORTED;
@@ -130,7 +137,7 @@ WERROR hive_get_value_by_index (TALLOC_CTX *mem_ctx,
 }
 
 
-WERROR hive_del_value (struct hive_key *key, const char *name)
+WERROR hive_del_value(struct hive_key *key, const char *name)
 {
        if (key->ops->delete_value == NULL)
                return WERR_NOT_SUPPORTED;
index 5a5356dfd2eadaeb79a057bbf7289bb80bb876ed..2f783dd15d4886275757029022c0ae849c265fcb 100644 (file)
@@ -1,18 +1,18 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Registry hive interface
    Copyright (C) Jelmer Vernooij                                         2003-2007.
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 #include "libcli/util/ntstatus.h"
 
 /**
- * This file contains the hive API. This API is generally used for 
- * reading a specific file that contains just one hive. 
+ * This file contains the hive API. This API is generally used for
+ * reading a specific file that contains just one hive.
  *
  * Good examples are .DAT (NTUSER.DAT) files.
  *
- * This API does not have any notification support (that 
- * should be provided by the registry implementation), nor 
+ * This API does not have any notification support (that
+ * should be provided by the registry implementation), nor
  * does it understand what predefined keys are.
  */
 
@@ -41,31 +41,32 @@ struct hive_key {
 };
 
 struct hive_operations {
-       const char *name;       
+       const char *name;
 
        /**
         * Open a specific subkey
         */
        WERROR (*enum_key) (TALLOC_CTX *mem_ctx,
-                                               const struct hive_key *key, uint32_t idx, 
-                                               const char **name,
-                                               const char **classname,
-                                               NTTIME *last_mod_time);
+                           const struct hive_key *key, uint32_t idx,
+                           const char **name,
+                           const char **classname,
+                           NTTIME *last_mod_time);
 
        /**
         * Open a subkey by name
         */
        WERROR (*get_key_by_name) (TALLOC_CTX *mem_ctx,
-                                                          const struct hive_key *key, const char *name, 
-                                                          struct hive_key **subkey);
-       
+                                  const struct hive_key *key, const char *name,
+                                  struct hive_key **subkey);
+
        /**
         * Add a new key.
         */
        WERROR (*add_key) (TALLOC_CTX *ctx,
-                                          const struct hive_key *parent_key, const char *name, 
-                                          const char *classname, struct security_descriptor *desc, 
-                                          struct hive_key **key);
+                          const struct hive_key *parent_key, const char *name,
+                          const char *classname,
+                          struct security_descriptor *desc,
+                          struct hive_key **key);
        /**
         * Remove an existing key.
         */
@@ -80,22 +81,22 @@ struct hive_operations {
         * Retrieve a registry value with a specific index.
         */
        WERROR (*enum_value) (TALLOC_CTX *mem_ctx,
-                                                 const struct hive_key *key, int idx, 
-                                                 const char **name, uint32_t *type, 
-                                                 DATA_BLOB *data);
+                             const struct hive_key *key, int idx,
+                             const char **name, uint32_t *type,
+                             DATA_BLOB *data);
 
        /**
         * Retrieve a registry value with the specified name
         */
-       WERROR (*get_value_by_name) (TALLOC_CTX *mem_ctx, 
-                                                                struct hive_key *key, const char *name, 
-                                                                uint32_t *type, DATA_BLOB *data);
-       
+       WERROR (*get_value_by_name) (TALLOC_CTX *mem_ctx,
+                                    struct hive_key *key, const char *name,
+                                    uint32_t *type, DATA_BLOB *data);
+
        /**
         * Set a value on the specified registry key.
         */
-       WERROR (*set_value) (struct hive_key *key, const char *name, 
-                                                uint32_t type, const DATA_BLOB data);
+       WERROR (*set_value) (struct hive_key *key, const char *name,
+                            uint32_t type, const DATA_BLOB data);
 
        /**
         * Remove a value.
@@ -107,91 +108,93 @@ struct hive_operations {
        /**
         * Change the security descriptor on a registry key.
         *
-        * This should return WERR_NOT_SUPPORTED if the underlying 
-        * format does not have a mechanism for storing 
+        * This should return WERR_NOT_SUPPORTED if the underlying
+        * format does not have a mechanism for storing
         * security descriptors.
         */
-       WERROR (*set_sec_desc) (struct hive_key *key, 
-                                                       const struct security_descriptor *desc);
+       WERROR (*set_sec_desc) (struct hive_key *key,
+                               const struct security_descriptor *desc);
 
        /**
         * Retrieve the security descriptor on a registry key.
         *
-        * This should return WERR_NOT_SUPPORTED if the underlying 
-        * format does not have a mechanism for storing 
+        * This should return WERR_NOT_SUPPORTED if the underlying
+        * format does not have a mechanism for storing
         * security descriptors.
         */
        WERROR (*get_sec_desc) (TALLOC_CTX *ctx,
-                                                       const struct hive_key *key, 
-                                                       struct security_descriptor **desc);
-       
+                               const struct hive_key *key,
+                               struct security_descriptor **desc);
+
        /**
         * Retrieve general information about a key.
         */
        WERROR (*get_key_info) (TALLOC_CTX *mem_ctx,
-                                                       const struct hive_key *key,
-                                                       const char **classname,
-                                                       uint32_t *num_subkeys,
-                                                       uint32_t *num_values,
-                                                       NTTIME *last_change_time);
+                               const struct hive_key *key,
+                               const char **classname,
+                               uint32_t *num_subkeys,
+                               uint32_t *num_values,
+                               NTTIME *last_change_time);
 };
 
 struct cli_credentials;
 struct auth_session_info;
 
-WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location, 
-                                                         struct auth_session_info *session_info, 
-                                                         struct cli_credentials *credentials, 
-                                                         struct hive_key **root);
+WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
+                    struct auth_session_info *session_info,
+                    struct cli_credentials *credentials,
+                    struct hive_key **root);
 WERROR hive_key_get_info(TALLOC_CTX *mem_ctx, const struct hive_key *key,
-                                                const char **classname, uint32_t *num_subkeys, 
-                                                uint32_t *num_values,
-                                                NTTIME *last_change_time);
+                        const char **classname, uint32_t *num_subkeys,
+                        uint32_t *num_values,
+                        NTTIME *last_change_time);
 WERROR hive_key_add_name(TALLOC_CTX *ctx, const struct hive_key *parent_key,
-                                                const char *name, const char *classname, struct security_descriptor *desc,
-                                                struct hive_key **key);
+                        const char *name, const char *classname,
+                        struct security_descriptor *desc,
+                        struct hive_key **key);
 WERROR hive_key_del(const struct hive_key *key, const char *name);
 WERROR hive_get_key_by_name(TALLOC_CTX *mem_ctx,
-                                                          const struct hive_key *key, const char *name, 
-                                                          struct hive_key **subkey);
+                           const struct hive_key *key, const char *name,
+                           struct hive_key **subkey);
 WERROR hive_enum_key(TALLOC_CTX *mem_ctx,
-                                       const struct hive_key *key, uint32_t idx, 
-                                       const char **name,
-                                       const char **classname,
-                                       NTTIME *last_mod_time);
+                    const struct hive_key *key, uint32_t idx,
+                    const char **name,
+                    const char **classname,
+                    NTTIME *last_mod_time);
 
-WERROR hive_set_value (struct hive_key *key, const char *name, 
-                                          uint32_t type, const DATA_BLOB data);
+WERROR hive_set_value(struct hive_key *key, const char *name,
+                     uint32_t type, const DATA_BLOB data);
 
-WERROR hive_get_value (TALLOC_CTX *mem_ctx, 
-                                          struct hive_key *key, const char *name, 
-                                          uint32_t *type, DATA_BLOB *data);
-WERROR hive_get_value_by_index (TALLOC_CTX *mem_ctx, 
-                                          struct hive_key *key, uint32_t idx, const char **name, 
-                                          uint32_t *type, DATA_BLOB *data);
+WERROR hive_get_value(TALLOC_CTX *mem_ctx,
+                     struct hive_key *key, const char *name,
+                     uint32_t *type, DATA_BLOB *data);
+WERROR hive_get_value_by_index(TALLOC_CTX *mem_ctx,
+                              struct hive_key *key, uint32_t idx,
+                              const char **name,
+                              uint32_t *type, DATA_BLOB *data);
 
-WERROR hive_del_value (struct hive_key *key, const char *name);
+WERROR hive_del_value(struct hive_key *key, const char *name);
 
 WERROR hive_key_flush(struct hive_key *key);
 
 
 /* Individual backends */
-WERROR reg_open_directory(TALLOC_CTX *parent_ctx, 
-                       const char *location, struct hive_key **key);
-WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx, 
-                                                 const char *location, struct hive_key **key);
-WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location, 
-                                                               struct auth_session_info *session_info,
-                                                               struct cli_credentials *credentials,
-                                                               struct hive_key **k);
-
-
-WERROR reg_create_directory(TALLOC_CTX *parent_ctx, 
-                       const char *location, struct hive_key **key);
-WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, 
-                                                        const char *location, 
-                                                        int major_version, 
-                                                        struct hive_key **key);
+WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
+                         const char *location, struct hive_key **key);
+WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
+                         const char *location, struct hive_key **key);
+WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
+                        struct auth_session_info *session_info,
+                        struct cli_credentials *credentials,
+                        struct hive_key **k);
+
+
+WERROR reg_create_directory(TALLOC_CTX *parent_ctx,
+                           const char *location, struct hive_key **key);
+WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx,
+                           const char *location,
+                           int major_version,
+                           struct hive_key **key);
 
 
 #endif /* __REGISTRY_HIVE_H__ */
index 98c72c79402a983e634a1f3e18428cbca16139af..8f60a55ae9bdc745214f297e7c256f915cab422b 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Transparent registry backend handling
    Copyright (C) Jelmer Vernooij                       2003-2007.
@@ -47,7 +47,7 @@ _PUBLIC_ const char *reg_get_predef_name(uint32_t hkey)
 {
        int i;
        for (i = 0; reg_predefined_keys[i].name; i++) {
-               if (reg_predefined_keys[i].handle == hkey) 
+               if (reg_predefined_keys[i].handle == hkey)
                        return reg_predefined_keys[i].name;
        }
 
@@ -55,40 +55,42 @@ _PUBLIC_ const char *reg_get_predef_name(uint32_t hkey)
 }
 
 /** Get predefined key by name. */
-_PUBLIC_ WERROR reg_get_predefined_key_by_name(struct registry_context *ctx, 
-                                                                                          const char *name, 
-                                                                                          struct registry_key **key)
+_PUBLIC_ WERROR reg_get_predefined_key_by_name(struct registry_context *ctx,
+                                              const char *name,
+                                              struct registry_key **key)
 {
        int i;
-       
+
        for (i = 0; reg_predefined_keys[i].name; i++) {
-               if (!strcasecmp(reg_predefined_keys[i].name, name)) 
-                       return reg_get_predefined_key(ctx, reg_predefined_keys[i].handle, 
-                                                                                 key);
+               if (!strcasecmp(reg_predefined_keys[i].name, name))
+                       return reg_get_predefined_key(ctx,
+                                                     reg_predefined_keys[i].handle,
+                                                     key);
        }
 
        DEBUG(1, ("No predefined key with name '%s'\n", name));
-       
+
        return WERR_BADFILE;
 }
 
 /** Get predefined key by id. */
-_PUBLIC_ WERROR reg_get_predefined_key(const struct registry_context *ctx, 
-                                                                          uint32_t hkey, struct registry_key **key)
+_PUBLIC_ WERROR reg_get_predefined_key(const struct registry_context *ctx,
+                                      uint32_t hkey, struct registry_key **key)
 {
        return ctx->ops->get_predefined_key(ctx, hkey, key);
 }
 
 /**
- * Open a key 
+ * Open a key
  * First tries to use the open_key function from the backend
- * then falls back to get_subkey_by_name and later get_subkey_by_index 
+ * then falls back to get_subkey_by_name and later get_subkey_by_index
  */
-_PUBLIC_ WERROR reg_open_key(TALLOC_CTX *mem_ctx, struct registry_key *parent, 
-                                                        const char *name, struct registry_key **result)
+_PUBLIC_ WERROR reg_open_key(TALLOC_CTX *mem_ctx, struct registry_key *parent,
+                            const char *name, struct registry_key **result)
 {
        if (parent == NULL) {
-               DEBUG(0, ("Invalid parent key specified for open of '%s'\n", name));
+               DEBUG(0, ("Invalid parent key specified for open of '%s'\n",
+                       name));
                return WERR_INVALID_PARAM;
        }
 
@@ -103,69 +105,71 @@ _PUBLIC_ WERROR reg_open_key(TALLOC_CTX *mem_ctx, struct registry_key *parent,
 /**
  * Get value by index
  */
-_PUBLIC_ WERROR reg_key_get_value_by_index(TALLOC_CTX *mem_ctx, 
-                                          const struct registry_key *key, 
+_PUBLIC_ WERROR reg_key_get_value_by_index(TALLOC_CTX *mem_ctx,
+                                          const struct registry_key *key,
                                           uint32_t idx, const char **name,
                                           uint32_t *type, DATA_BLOB *data)
 {
-       if (key == NULL) 
+       if (key == NULL)
                return WERR_INVALID_PARAM;
 
        if (key->context->ops->enum_value == NULL)
                return WERR_NOT_SUPPORTED;
 
-       return key->context->ops->enum_value(mem_ctx, key, idx, name, type, 
-                                                                                                       data);
+       return key->context->ops->enum_value(mem_ctx, key, idx, name,
+                                            type, data);
 }
 
-/** 
+/**
  * Get the number of subkeys.
  */
-_PUBLIC_ WERROR reg_key_get_info(TALLOC_CTX *mem_ctx, 
-                                                                const struct registry_key *key, 
-                                                                const char **classname,
-                                                                uint32_t *num_subkeys,
-                                                                uint32_t *num_values,
-                                                                NTTIME *last_change_time)
+_PUBLIC_ WERROR reg_key_get_info(TALLOC_CTX *mem_ctx,
+                                const struct registry_key *key,
+                                const char **classname,
+                                uint32_t *num_subkeys,
+                                uint32_t *num_values,
+                                NTTIME *last_change_time)
 {
-       if (key == NULL) 
+       if (key == NULL)
                return WERR_INVALID_PARAM;
-       
+
        if (key->context->ops->get_key_info == NULL)
                return WERR_NOT_SUPPORTED;
 
        return key->context->ops->get_key_info(mem_ctx,
-                                                                                  key, classname, num_subkeys, 
-                                                                                  num_values, last_change_time);
+                                              key, classname, num_subkeys,
+                                              num_values, last_change_time);
 }
 
 /**
  * Get subkey by index.
  */
-_PUBLIC_ WERROR reg_key_get_subkey_by_index(TALLOC_CTX *mem_ctx, 
-               const struct registry_key *key, int idx, const char **name,
-               const char **keyclass, NTTIME *last_changed_time)
+_PUBLIC_ WERROR reg_key_get_subkey_by_index(TALLOC_CTX *mem_ctx,
+                                           const struct registry_key *key,
+                                           int idx, const char **name,
+                                           const char **keyclass,
+                                           NTTIME *last_changed_time)
 {
-       if (key == NULL) 
+       if (key == NULL)
                return WERR_INVALID_PARAM;
 
        if (key->context->ops->enum_key == NULL)
                return WERR_NOT_SUPPORTED;
 
        return key->context->ops->enum_key(mem_ctx, key, idx, name,
-                                                                                 keyclass, last_changed_time);
+                                          keyclass, last_changed_time);
 }
 
 /**
  * Get value by name.
  */
-_PUBLIC_ WERROR reg_key_get_value_by_name(TALLOC_CTX *mem_ctx, 
-                                                                                 const struct registry_key *key, 
-                                                                                 const char *name, 
-                                                                                 uint32_t *type,
-                                                                                 DATA_BLOB *data)
+_PUBLIC_ WERROR reg_key_get_value_by_name(TALLOC_CTX *mem_ctx,
+                                         const struct registry_key *key,
+                                         const char *name,
+                                         uint32_t *type,
+                                         DATA_BLOB *data)
 {
-       if (key == NULL) 
+       if (key == NULL)
                return WERR_INVALID_PARAM;
 
        if (key->context->ops->get_value == NULL)
@@ -179,49 +183,49 @@ _PUBLIC_ WERROR reg_key_get_value_by_name(TALLOC_CTX *mem_ctx,
  */
 _PUBLIC_ WERROR reg_key_del(struct registry_key *parent, const char *name)
 {
-       if (parent == NULL) 
+       if (parent == NULL)
                return WERR_INVALID_PARAM;
-       
+
        if (parent->context->ops->delete_key == NULL)
                return WERR_NOT_SUPPORTED;
-       
+
        return parent->context->ops->delete_key(parent, name);
 }
 
 /**
  * Add a key.
  */
-_PUBLIC_ WERROR reg_key_add_name(TALLOC_CTX *mem_ctx, 
-                                                                struct registry_key *parent, 
-                                                                const char *name, const char *key_class, 
-                                                                struct security_descriptor *desc, 
-                                                                struct registry_key **newkey)
+_PUBLIC_ WERROR reg_key_add_name(TALLOC_CTX *mem_ctx,
+                                struct registry_key *parent,
+                                const char *name, const char *key_class,
+                                struct security_descriptor *desc,
+                                struct registry_key **newkey)
 {
-       if (parent == NULL) 
+       if (parent == NULL)
                return WERR_INVALID_PARAM;
-       
+
        if (parent->context->ops->create_key == NULL) {
-               DEBUG(1, ("Backend '%s' doesn't support method add_key\n", 
+               DEBUG(1, ("Backend '%s' doesn't support method add_key\n",
                                  parent->context->ops->name));
                return WERR_NOT_SUPPORTED;
        }
 
-       return parent->context->ops->create_key(mem_ctx, parent, name, 
-                                                                                       key_class, desc, newkey);
+       return parent->context->ops->create_key(mem_ctx, parent, name,
+                                               key_class, desc, newkey);
 }
 
 /**
  * Set a value.
  */
-_PUBLIC_ WERROR reg_val_set(struct registry_key *key, const char *value, 
-                                                       uint32_t type, const DATA_BLOB data)
+_PUBLIC_ WERROR reg_val_set(struct registry_key *key, const char *value,
+                           uint32_t type, const DATA_BLOB data)
 {
        if (key == NULL)
                return WERR_INVALID_PARAM;
 
        /* A 'real' set function has preference */
        if (key->context->ops->set_value == NULL) {
-               DEBUG(1, ("Backend '%s' doesn't support method set_value\n", 
+               DEBUG(1, ("Backend '%s' doesn't support method set_value\n",
                                  key->context->ops->name));
                return WERR_NOT_SUPPORTED;
        }
@@ -232,15 +236,15 @@ _PUBLIC_ WERROR reg_val_set(struct registry_key *key, const char *value,
 /**
  * Get the security descriptor on a key.
  */
-_PUBLIC_ WERROR reg_get_sec_desc(TALLOC_CTX *ctx, 
-                                                                const struct registry_key *key, 
-                                                                struct security_descriptor **secdesc)
+_PUBLIC_ WERROR reg_get_sec_desc(TALLOC_CTX *ctx,
+                                const struct registry_key *key,
+                                struct security_descriptor **secdesc)
 {
        if (key == NULL)
                return WERR_INVALID_PARAM;
 
        /* A 'real' set function has preference */
-       if (key->context->ops->get_security == NULL)  
+       if (key->context->ops->get_security == NULL)
                return WERR_NOT_SUPPORTED;
 
        return key->context->ops->get_security(ctx, key, secdesc);
@@ -267,32 +271,32 @@ _PUBLIC_ WERROR reg_key_flush(struct registry_key *key)
 {
        if (key == NULL)
                return WERR_INVALID_PARAM;
-       
+
        if (key->context->ops->flush_key == NULL)
                return WERR_NOT_SUPPORTED;
 
        return key->context->ops->flush_key(key);
 }
 
-_PUBLIC_ WERROR reg_get_security(TALLOC_CTX *mem_ctx, 
-                                                                const struct registry_key *key, 
-                                                                struct security_descriptor **security)
+_PUBLIC_ WERROR reg_get_security(TALLOC_CTX *mem_ctx,
+                                const struct registry_key *key,
+                                struct security_descriptor **security)
 {
        if (key == NULL)
                return WERR_INVALID_PARAM;
-       
+
        if (key->context->ops->get_security == NULL)
                return WERR_NOT_SUPPORTED;
 
        return key->context->ops->get_security(mem_ctx, key, security);
 }
 
-_PUBLIC_ WERROR reg_set_security(struct registry_key *key, 
-                                                                struct security_descriptor *security)
+_PUBLIC_ WERROR reg_set_security(struct registry_key *key,
+                                struct security_descriptor *security)
 {
        if (key == NULL)
                return WERR_INVALID_PARAM;
-       
+
        if (key->context->ops->set_security == NULL)
                return WERR_NOT_SUPPORTED;
 
index e9daf31f9bc3dd86453dc8d72a2f3b194ab0c3ac..4a6ef65bc4da988282ca1cab73d52f402ce5470b 100644 (file)
@@ -1,18 +1,18 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Registry interface
    Copyright (C) Jelmer Vernooij  2004-2007.
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -27,7 +27,7 @@
 
 static struct hive_operations reg_backend_ldb;
 
-struct ldb_key_data 
+struct ldb_key_data
 {
        struct hive_key key;
        struct ldb_context *ldb;
@@ -36,12 +36,15 @@ struct ldb_key_data
        int subkey_count, value_count;
 };
 
-static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg, const char **name, 
-                                                                uint32_t *type, DATA_BLOB *data)
+static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+                                const char **name, uint32_t *type,
+                                DATA_BLOB *data)
 {
        const struct ldb_val *val;
        if (name != NULL)
-               *name = talloc_strdup(mem_ctx, ldb_msg_find_attr_as_string(msg, "value", NULL));
+               *name = talloc_strdup(mem_ctx,
+                                     ldb_msg_find_attr_as_string(msg, "value",
+                                     NULL));
 
        if (type != NULL)
                *type = ldb_msg_find_attr_as_uint(msg, "type", 0);
@@ -51,8 +54,9 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg, c
        {
        case REG_SZ:
        case REG_EXPAND_SZ:
-               data->length = convert_string_talloc(mem_ctx, CH_UTF8, CH_UTF16, 
-                                                                                        val->data, val->length, (void **)&data->data);
+               data->length = convert_string_talloc(mem_ctx, CH_UTF8, CH_UTF16,
+                                                    val->data, val->length,
+                                                    (void **)&data->data);
                break;
 
        case REG_DWORD: {
@@ -67,9 +71,10 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, struct ldb_message *msg, c
        }
 }
 
-static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx, 
-                                               TALLOC_CTX *mem_ctx, const char *name, 
-                                               uint32_t type, DATA_BLOB data)
+static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
+                                             TALLOC_CTX *mem_ctx,
+                                             const char *name,
+                                             uint32_t type, DATA_BLOB data)
 {
        struct ldb_val val;
        struct ldb_message *msg = talloc_zero(mem_ctx, struct ldb_message);
@@ -80,13 +85,17 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
        switch (type) {
        case REG_SZ:
        case REG_EXPAND_SZ:
-               val.length = convert_string_talloc(mem_ctx, CH_UTF16, CH_UTF8, 
-                                                                                  (void *)data.data, data.length, (void **)&val.data);
+               val.length = convert_string_talloc(mem_ctx, CH_UTF16, CH_UTF8,
+                                                  (void *)data.data,
+                                                  data.length,
+                                                  (void **)&val.data);
                ldb_msg_add_value(msg, "data", &val, NULL);
                break;
 
        case REG_DWORD:
-               ldb_msg_add_string(msg, "data", talloc_asprintf(mem_ctx, "0x%x", IVAL(data.data, 0)));
+               ldb_msg_add_string(msg, "data",
+                                  talloc_asprintf(mem_ctx, "0x%x",
+                                                  IVAL(data.data, 0)));
                break;
        default:
                ldb_msg_add_value(msg, "data", &data, NULL);
@@ -94,7 +103,7 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
 
 
        type_s = talloc_asprintf(mem_ctx, "%u", type);
-       ldb_msg_add_string(msg, "type", type_s); 
+       ldb_msg_add_string(msg, "type", type_s);
 
        return msg;
 }
@@ -103,20 +112,20 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
 static int reg_close_ldb_key(struct ldb_key_data *key)
 {
        if (key->subkeys != NULL) {
-               talloc_free(key->subkeys); 
+               talloc_free(key->subkeys);
                key->subkeys = NULL;
        }
 
        if (key->values != NULL) {
-               talloc_free(key->values); 
+               talloc_free(key->values);
                key->values = NULL;
        }
        return 0;
 }
 
-static struct ldb_dn *reg_path_to_ldb(TALLOC_CTX *mem_ctx, 
-                                                                         const struct hive_key *from, 
-                                                                         const char *path, const char *add)
+static struct ldb_dn *reg_path_to_ldb(TALLOC_CTX *mem_ctx,
+                                     const struct hive_key *from,
+                                     const char *path, const char *add)
 {
        TALLOC_CTX *local_ctx;
        struct ldb_dn *ret;
@@ -173,7 +182,8 @@ static WERROR cache_subkeys(struct ldb_key_data *kd)
        ret = ldb_search(c, kd->dn, LDB_SCOPE_ONELEVEL, "(key=*)", NULL, &res);
 
        if (ret != LDB_SUCCESS) {
-               DEBUG(0, ("Error getting subkeys for '%s': %s\n", ldb_dn_get_linearized(kd->dn), ldb_errstring(c)));
+               DEBUG(0, ("Error getting subkeys for '%s': %s\n",
+                       ldb_dn_get_linearized(kd->dn), ldb_errstring(c)));
                return WERR_FOOBAR;
        }
 
@@ -190,10 +200,12 @@ static WERROR cache_values(struct ldb_key_data *kd)
        struct ldb_result *res;
        int ret;
 
-       ret = ldb_search(c, kd->dn, LDB_SCOPE_ONELEVEL, "(value=*)", NULL, &res);
+       ret = ldb_search(c, kd->dn, LDB_SCOPE_ONELEVEL,
+                        "(value=*)", NULL, &res);
 
        if (ret != LDB_SUCCESS) {
-               DEBUG(0, ("Error getting values for '%s': %s\n", ldb_dn_get_linearized(kd->dn), ldb_errstring(c)));
+               DEBUG(0, ("Error getting values for '%s': %s\n",
+                       ldb_dn_get_linearized(kd->dn), ldb_errstring(c)));
                return WERR_FOOBAR;
        }
        kd->value_count = res->count;
@@ -203,11 +215,11 @@ static WERROR cache_values(struct ldb_key_data *kd)
 }
 
 
-static WERROR ldb_get_subkey_by_id(TALLOC_CTX *mem_ctx, 
-                                                  const struct hive_key *k, uint32_t idx, 
-                                                  const char **name,
-                                                  const char **classname,
-                                                  NTTIME *last_mod_time)
+static WERROR ldb_get_subkey_by_id(TALLOC_CTX *mem_ctx,
+                                  const struct hive_key *k, uint32_t idx,
+                                  const char **name,
+                                  const char **classname,
+                                  NTTIME *last_mod_time)
 {
        struct ldb_message_element *el;
        struct ldb_key_data *kd = talloc_get_type(k, struct ldb_key_data);
@@ -215,21 +227,21 @@ static WERROR ldb_get_subkey_by_id(TALLOC_CTX *mem_ctx,
        /* Do a search if necessary */
        if (kd->subkeys == NULL) {
                W_ERROR_NOT_OK_RETURN(cache_subkeys(kd));
-       } 
+       }
 
-       if (idx >= kd->subkey_count) 
+       if (idx >= kd->subkey_count)
                return WERR_NO_MORE_ITEMS;
 
        el = ldb_msg_find_element(kd->subkeys[idx], "key");
        SMB_ASSERT(el != NULL);
        SMB_ASSERT(el->num_values != 0);
-       
+
        if (name != NULL)
                *name = talloc_strdup(mem_ctx, (char *)el->values[0].data);
 
        if (classname != NULL)
                *classname = NULL; /* TODO: Store properly */
-       
+
        if (last_mod_time != NULL)
                *last_mod_time = 0; /* TODO: we need to add this to the
                                                ldb backend properly */
@@ -237,8 +249,9 @@ static WERROR ldb_get_subkey_by_id(TALLOC_CTX *mem_ctx,
        return WERR_OK;
 }
 
-static WERROR ldb_get_value_by_id(TALLOC_CTX *mem_ctx, const struct hive_key *k, int idx, 
-                                                                 const char **name, uint32_t *data_type, DATA_BLOB *data)
+static WERROR ldb_get_value_by_id(TALLOC_CTX *mem_ctx, const struct hive_key *k,
+                                 int idx, const char **name,
+                                 uint32_t *data_type, DATA_BLOB *data)
 {
        struct ldb_key_data *kd = talloc_get_type(k, struct ldb_key_data);
 
@@ -247,16 +260,18 @@ static WERROR ldb_get_value_by_id(TALLOC_CTX *mem_ctx, const struct hive_key *k,
                W_ERROR_NOT_OK_RETURN(cache_values(kd));
        }
 
-       if(idx >= kd->value_count) return WERR_NO_MORE_ITEMS;
+       if (idx >= kd->value_count)
+               return WERR_NO_MORE_ITEMS;
 
-       reg_ldb_unpack_value(mem_ctx, kd->values[idx], 
-                                                name, data_type, data);
+       reg_ldb_unpack_value(mem_ctx, kd->values[idx],
+                            name, data_type, data);
 
        return WERR_OK;
 }
 
-static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k, 
-                                       const char *name, uint32_t *data_type, DATA_BLOB *data)
+static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k,
+                           const char *name, uint32_t *data_type,
+                           DATA_BLOB *data)
 {
        struct ldb_key_data *kd = talloc_get_type(k, struct ldb_key_data);
        struct ldb_context *c = kd->ldb;
@@ -269,7 +284,8 @@ static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k,
        talloc_free(query);
 
        if (ret != LDB_SUCCESS) {
-               DEBUG(0, ("Error getting values for '%s': %s\n", ldb_dn_get_linearized(kd->dn), ldb_errstring(c)));
+               DEBUG(0, ("Error getting values for '%s': %s\n",
+                       ldb_dn_get_linearized(kd->dn), ldb_errstring(c)));
                return WERR_FOOBAR;
        }
 
@@ -281,8 +297,8 @@ static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k,
        return WERR_OK;
 }
 
-static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h, 
-                                                  const char *name, struct hive_key **key)
+static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
+                          const char *name, struct hive_key **key)
 {
        struct ldb_result *res;
        struct ldb_dn *ldap_path;
@@ -296,11 +312,12 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
        ret = ldb_search(c, ldap_path, LDB_SCOPE_BASE, "(key=*)", NULL, &res);
 
        if (ret != LDB_SUCCESS) {
-               DEBUG(3, ("Error opening key '%s': %s\n", 
-                                 ldb_dn_get_linearized(ldap_path), ldb_errstring(c)));
+               DEBUG(3, ("Error opening key '%s': %s\n",
+                       ldb_dn_get_linearized(ldap_path), ldb_errstring(c)));
                return WERR_FOOBAR;
        } else if (res->count == 0) {
-               DEBUG(3, ("Key '%s' not found\n", ldb_dn_get_linearized(ldap_path)));
+               DEBUG(3, ("Key '%s' not found\n",
+                       ldb_dn_get_linearized(ldap_path)));
                talloc_free(res);
                return WERR_NOT_FOUND;
        }
@@ -308,7 +325,7 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
        newkd = talloc_zero(mem_ctx, struct ldb_key_data);
        newkd->key.ops = &reg_backend_ldb;
        newkd->ldb = talloc_reference(newkd, kd->ldb);
-       newkd->dn = ldb_dn_copy(mem_ctx, res->msgs[0]->dn); 
+       newkd->dn = ldb_dn_copy(mem_ctx, res->msgs[0]->dn);
 
        *key = (struct hive_key *)newkd;
 
@@ -317,7 +334,7 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
        return WERR_OK;
 }
 
-WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location, 
+WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
                         struct auth_session_info *session_info,
                         struct cli_credentials *credentials,
                         struct hive_key **k)
@@ -325,10 +342,10 @@ WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
        struct ldb_key_data *kd;
        struct ldb_context *wrap;
 
-       if (location == NULL) 
+       if (location == NULL)
                return WERR_INVALID_PARAM;
 
-       wrap = ldb_wrap_connect(parent_ctx, global_loadparm, 
+       wrap = ldb_wrap_connect(parent_ctx, global_loadparm,
                                location, session_info, credentials, 0, NULL);
 
        if (wrap == NULL) {
@@ -349,10 +366,10 @@ WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
        return WERR_OK;
 }
 
-static WERROR ldb_add_key (TALLOC_CTX *mem_ctx, const struct hive_key *parent, 
-                                                  const char *name, const char *classname,
-                                                  struct security_descriptor *sd, 
-                                                  struct hive_key **newkey)
+static WERROR ldb_add_key(TALLOC_CTX *mem_ctx, const struct hive_key *parent,
+                         const char *name, const char *classname,
+                         struct security_descriptor *sd,
+                         struct hive_key **newkey)
 {
        const struct ldb_key_data *parentkd = (const struct ldb_key_data *)parent;
        struct ldb_message *msg;
@@ -365,13 +382,14 @@ static WERROR ldb_add_key (TALLOC_CTX *mem_ctx, const struct hive_key *parent,
 
        ldb_msg_add_string(msg, "key", talloc_strdup(mem_ctx, name));
        if (classname != NULL)
-               ldb_msg_add_string(msg, "classname", talloc_strdup(mem_ctx, classname));
+               ldb_msg_add_string(msg, "classname",
+                                  talloc_strdup(mem_ctx, classname));
 
        ret = ldb_add(parentkd->ldb, msg);
        if (ret < 0) {
                DEBUG(1, ("ldb_msg_add: %s\n", ldb_errstring(parentkd->ldb)));
                return WERR_FOOBAR;
-       } 
+       }
 
        DEBUG(2, ("key added: %s\n", ldb_dn_get_linearized(msg->dn)));
 
@@ -385,7 +403,7 @@ static WERROR ldb_add_key (TALLOC_CTX *mem_ctx, const struct hive_key *parent,
        return WERR_OK;
 }
 
-static WERROR ldb_del_key (const struct hive_key *key, const char *child)
+static WERROR ldb_del_key(const struct hive_key *key, const char *child)
 {
        int ret;
        struct ldb_key_data *parentkd = talloc_get_type(key, struct ldb_key_data);
@@ -431,9 +449,9 @@ static WERROR ldb_del_value (struct hive_key *key, const char *child)
        return WERR_OK;
 }
 
-static WERROR ldb_set_value(struct hive_key *parent, 
-                                                       const char *name, uint32_t type, 
-                                                       const DATA_BLOB data)
+static WERROR ldb_set_value(struct hive_key *parent,
+                           const char *name, uint32_t type,
+                           const DATA_BLOB data)
 {
        struct ldb_message *msg;
        struct ldb_key_data *kd = talloc_get_type(parent, struct ldb_key_data);
@@ -454,17 +472,17 @@ static WERROR ldb_set_value(struct hive_key *parent,
                        return WERR_FOOBAR;
                }
        }
-       
+
        talloc_free(mem_ctx);
        return WERR_OK;
 }
 
-static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx, 
-                                                          const struct hive_key *key,
-                                                          const char **classname, 
-                                                          uint32_t *num_subkeys,
-                                                          uint32_t *num_values,
-                                                          NTTIME *last_change_time)
+static WERROR ldb_get_key_info(TALLOC_CTX *mem_ctx,
+                              const struct hive_key *key,
+                              const char **classname,
+                              uint32_t *num_subkeys,
+                              uint32_t *num_values,
+                              NTTIME *last_change_time)
 {
        struct ldb_key_data *kd = talloc_get_type(key, struct ldb_key_data);
 
index a52feaaed5f7a98638fe03f63c041430cfc4ed70..b54f0cf30adae906ade88677aa305dc0165e77fe 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Transparent registry backend handling
    Copyright (C) Jelmer Vernooij                       2003-2007.
@@ -38,7 +38,7 @@ struct registry_local {
                struct mountpoint *prev, *next;
        } *mountpoints;
 
-       struct auth_session_info *session_info; 
+       struct auth_session_info *session_info;
        struct cli_credentials *credentials;
 };
 
@@ -49,9 +49,9 @@ struct local_key {
 };
 
 
-struct registry_key *reg_import_hive_key(struct registry_context *ctx, 
-                                        struct hive_key *hive, 
-                                        uint32_t predefined_key, 
+struct registry_key *reg_import_hive_key(struct registry_context *ctx,
+                                        struct hive_key *hive,
+                                        uint32_t predefined_key,
                                         const char **elements)
 {
        struct local_key *local_key;
@@ -70,25 +70,26 @@ struct registry_key *reg_import_hive_key(struct registry_context *ctx,
 
 
 static WERROR local_open_key(TALLOC_CTX *mem_ctx,
-                                                  struct registry_key *parent, 
-                                                  const char *path,
-                                                  struct registry_key **result)
+                            struct registry_key *parent,
+                            const char *path,
+                            struct registry_key **result)
 {
        char *orig = talloc_strdup(mem_ctx, path),
-                *curbegin = orig, 
+                *curbegin = orig,
                 *curend = strchr(orig, '\\');
-       struct local_key *local_parent = talloc_get_type(parent, struct local_key);
+       struct local_key *local_parent = talloc_get_type(parent,
+                                                        struct local_key);
        struct hive_key *curkey = local_parent->hive_key;
        WERROR error;
        const char **elements = NULL;
        int el;
 
        if (local_parent->path.elements != NULL) {
-               elements = talloc_array(mem_ctx, const char *, 
-                                                       str_list_length(local_parent->path.elements) + 1);
+               elements = talloc_array(mem_ctx, const char *,
+                                       str_list_length(local_parent->path.elements) + 1);
                for (el = 0; local_parent->path.elements[el] != NULL; el++) {
-                       elements[el] = talloc_reference(elements, 
-                                                                                       local_parent->path.elements[el]);
+                       elements[el] = talloc_reference(elements,
+                                                       local_parent->path.elements[el]);
                }
                elements[el] = NULL;
        } else {
@@ -103,67 +104,69 @@ static WERROR local_open_key(TALLOC_CTX *mem_ctx,
                elements[el] = talloc_strdup(elements, curbegin);
                el++;
                elements[el] = NULL;
-               error = hive_get_key_by_name(mem_ctx, curkey, curbegin, &curkey);
+               error = hive_get_key_by_name(mem_ctx, curkey,
+                                            curbegin, &curkey);
                if (!W_ERROR_IS_OK(error)) {
-                       DEBUG(2, ("Opening key %s failed: %s\n", curbegin, win_errstr(error)));
+                       DEBUG(2, ("Opening key %s failed: %s\n", curbegin,
+                               win_errstr(error)));
                        talloc_free(orig);
                        return error;
                }
-               if (curend == NULL) 
+               if (curend == NULL)
                        break;
                curbegin = curend + 1;
                curend = strchr(curbegin, '\\');
        }
        talloc_free(orig);
 
-       *result = reg_import_hive_key(local_parent->global.context, curkey, 
-                                                                 local_parent->path.predefined_key,
-                                                                 talloc_steal(curkey, elements));
-       
+       *result = reg_import_hive_key(local_parent->global.context, curkey,
+                                     local_parent->path.predefined_key,
+                                     talloc_steal(curkey, elements));
+
        return WERR_OK;
 }
 
-WERROR local_get_predefined_key (const struct registry_context *ctx, 
-         uint32_t key_id, struct registry_key **key) 
-{      
-       struct registry_local *rctx = talloc_get_type(ctx, 
+WERROR local_get_predefined_key(const struct registry_context *ctx,
+                               uint32_t key_id, struct registry_key **key)
+{
+       struct registry_local *rctx = talloc_get_type(ctx,
                                                      struct registry_local);
        struct mountpoint *mp;
 
        for (mp = rctx->mountpoints; mp != NULL; mp = mp->next) {
-               if (mp->path.predefined_key == key_id && 
+               if (mp->path.predefined_key == key_id &&
                        mp->path.elements == NULL)
                        break;
        }
 
        if (mp == NULL)
                return WERR_NOT_FOUND;
-       
-       *key = reg_import_hive_key(ctx, mp->key, 
-                                  mp->path.predefined_key, 
+
+       *key = reg_import_hive_key(ctx, mp->key,
+                                  mp->path.predefined_key,
                                   mp->path.elements);
 
        return WERR_OK;
 }
 
 static WERROR local_enum_key(TALLOC_CTX *mem_ctx,
-                                         const struct registry_key *key, uint32_t idx,
-                                         const char **name,
-                                         const char **keyclass,
-                                         NTTIME *last_changed_time)
+                            const struct registry_key *key, uint32_t idx,
+                            const char **name,
+                            const char **keyclass,
+                            NTTIME *last_changed_time)
 {
        const struct local_key *local = (const struct local_key *)key;
 
-       return hive_enum_key(mem_ctx, local->hive_key, idx, name, keyclass, 
-                                                 last_changed_time);
+       return hive_enum_key(mem_ctx, local->hive_key, idx, name, keyclass,
+                            last_changed_time);
 }
 
-static WERROR local_create_key (TALLOC_CTX *mem_ctx, 
-                                                               struct registry_key *parent_key, 
-                                                               const char *name,
-                                                               const char *key_class,
-                                                               struct security_descriptor *security,
-                                                               struct registry_key **key)
+static WERROR local_create_key(TALLOC_CTX *mem_ctx,
+                              struct registry_key *parent_key,
+                              const char *name,
+                              const char *key_class,
+                              struct security_descriptor *security,
+                              struct registry_key **key)
 {
        const struct local_key *local_parent;
        struct hive_key *hivekey;
@@ -176,21 +179,22 @@ static WERROR local_create_key (TALLOC_CTX *mem_ctx,
                last_part = name;
                local_parent = (const struct local_key *)parent_key;
        } else {
-               W_ERROR_NOT_OK_RETURN(reg_open_key(mem_ctx, parent_key, 
-                                                         talloc_strndup(mem_ctx, name, last_part-name),
-                                                         &local_parent));
+               W_ERROR_NOT_OK_RETURN(reg_open_key(mem_ctx, parent_key,
+                                                  talloc_strndup(mem_ctx, name, last_part-name),
+                                                  &local_parent));
                last_part++;
        }
 
-       W_ERROR_NOT_OK_RETURN(hive_key_add_name(mem_ctx, local_parent->hive_key, 
-                                                               last_part, key_class, security, &hivekey));
+       W_ERROR_NOT_OK_RETURN(hive_key_add_name(mem_ctx, local_parent->hive_key,
+                                               last_part, key_class, security,
+                                               &hivekey));
 
        if (local_parent->path.elements != NULL) {
-               elements = talloc_array(hivekey, const char *, 
-                                                               str_list_length(local_parent->path.elements)+2);
+               elements = talloc_array(hivekey, const char *,
+                                       str_list_length(local_parent->path.elements)+2);
                for (i = 0; local_parent->path.elements[i] != NULL; i++) {
-                       elements[i] = talloc_reference(elements, 
-                                                                                  local_parent->path.elements[i]);
+                       elements[i] = talloc_reference(elements,
+                                                      local_parent->path.elements[i]);
                }
        } else {
                elements = talloc_array(hivekey, const char *, 2);
@@ -200,75 +204,75 @@ static WERROR local_create_key (TALLOC_CTX *mem_ctx,
        elements[i] = talloc_strdup(elements, name);
        elements[i+1] = NULL;
 
-       *key = reg_import_hive_key(local_parent->global.context, hivekey, 
-                                                          local_parent->path.predefined_key,
-                                                          elements);
+       *key = reg_import_hive_key(local_parent->global.context, hivekey,
+                                  local_parent->path.predefined_key,
+                                  elements);
 
        return WERR_OK;
 }
 
-static WERROR local_set_value (struct registry_key *key, const char *name,
-                                               uint32_t type, const DATA_BLOB data)
+static WERROR local_set_value(struct registry_key *key, const char *name,
+                             uint32_t type, const DATA_BLOB data)
 {
        struct local_key *local = (struct local_key *)key;
 
        return hive_set_value(local->hive_key, name, type, data);
 }
 
-static WERROR local_get_value (TALLOC_CTX *mem_ctx,
-                                                const struct registry_key *key,
-                                                const char *name, uint32_t *type, DATA_BLOB *data)
+static WERROR local_get_value(TALLOC_CTX *mem_ctx,
+                             const struct registry_key *key,
+                             const char *name, uint32_t *type, DATA_BLOB *data)
 {
        const struct local_key *local = (const struct local_key *)key;
 
        return hive_get_value(mem_ctx, local->hive_key, name, type, data);
 }
 
-static WERROR local_enum_value (TALLOC_CTX *mem_ctx,
-                                                 const struct registry_key *key, uint32_t idx,
-                                                 const char **name,
-                                                 uint32_t *type,
-                                                 DATA_BLOB *data)
+static WERROR local_enum_value(TALLOC_CTX *mem_ctx,
+                              const struct registry_key *key, uint32_t idx,
+                              const char **name,
+                              uint32_t *type,
+                              DATA_BLOB *data)
 {
        const struct local_key *local = (const struct local_key *)key;
 
-       return hive_get_value_by_index(mem_ctx, local->hive_key, idx, 
-                                                                  name, type, data);
+       return hive_get_value_by_index(mem_ctx, local->hive_key, idx,
+                                      name, type, data);
 }
 
-static WERROR local_delete_key (struct registry_key *key, const char *name)
+static WERROR local_delete_key(struct registry_key *key, const char *name)
 {
        const struct local_key *local = (const struct local_key *)key;
 
        return hive_key_del(local->hive_key, name);
 }
 
-static WERROR local_delete_value (struct registry_key *key, const char *name)
+static WERROR local_delete_value(struct registry_key *key, const char *name)
 {
        const struct local_key *local = (const struct local_key *)key;
 
        return hive_del_value(local->hive_key, name);
 }
 
-static WERROR local_flush_key (struct registry_key *key)
+static WERROR local_flush_key(struct registry_key *key)
 {
        const struct local_key *local = (const struct local_key *)key;
 
        return hive_key_flush(local->hive_key);
 }
 
-static WERROR local_get_key_info (TALLOC_CTX *mem_ctx,
-                                               const struct registry_key *key,
-                                               const char **classname,
-                                               uint32_t *num_subkeys,
-                                               uint32_t *num_values,
-                                               NTTIME *last_change_time)
+static WERROR local_get_key_info(TALLOC_CTX *mem_ctx,
+                                const struct registry_key *key,
+                                const char **classname,
+                                uint32_t *num_subkeys,
+                                uint32_t *num_values,
+                                NTTIME *last_change_time)
 {
        const struct local_key *local = (const struct local_key *)key;
 
-       return hive_key_get_info(mem_ctx, local->hive_key, 
-                                                        classname, num_subkeys, num_values, 
-                                                        last_change_time);
+       return hive_key_get_info(mem_ctx, local->hive_key,
+                                classname, num_subkeys, num_values,
+                                last_change_time);
 }
 
 const static struct registry_operations local_ops = {
@@ -286,11 +290,12 @@ const static struct registry_operations local_ops = {
        .get_key_info = local_get_key_info,
 };
 
-WERROR reg_open_local(TALLOC_CTX *mem_ctx, struct registry_context **ctx, 
-                               struct auth_session_info *session_info, 
-                               struct cli_credentials *credentials)
+WERROR reg_open_local(TALLOC_CTX *mem_ctx, struct registry_context **ctx,
+                     struct auth_session_info *session_info,
+                     struct cli_credentials *credentials)
 {
-       struct registry_local *ret = talloc_zero(mem_ctx, struct registry_local);
+       struct registry_local *ret = talloc_zero(mem_ctx,
+                                                struct registry_local);
 
        W_ERROR_HAVE_NO_MEMORY(ret);
 
@@ -299,16 +304,17 @@ WERROR reg_open_local(TALLOC_CTX *mem_ctx, struct registry_context **ctx,
        ret->credentials = credentials;
 
        *ctx = (struct registry_context *)ret;
-       
+
        return WERR_OK;
 }
 
-WERROR reg_mount_hive(struct registry_context *rctx, 
-                                         struct hive_key *hive_key,
-                                         uint32_t key_id,
-                                         const char **elements) 
+WERROR reg_mount_hive(struct registry_context *rctx,
+                     struct hive_key *hive_key,
+                     uint32_t key_id,
+                     const char **elements)
 {
-       struct registry_local *reg_local = talloc_get_type(rctx, struct registry_local);
+       struct registry_local *reg_local = talloc_get_type(rctx,
+                                                          struct registry_local);
        struct mountpoint *mp = talloc(rctx, struct mountpoint);
        int i = 0;
 
@@ -316,11 +322,11 @@ WERROR reg_mount_hive(struct registry_context *rctx,
        mp->prev = mp->next = NULL;
        mp->key = hive_key;
        if (elements != NULL) {
-               mp->path.elements = talloc_array(mp, const char *, 
-                                                                                str_list_length(elements));
+               mp->path.elements = talloc_array(mp, const char *,
+                                                str_list_length(elements));
                for (i = 0; elements[i] != NULL; i++) {
-                       mp->path.elements[i] = talloc_reference(mp->path.elements, 
-                                                                                                       elements[i]);
+                       mp->path.elements[i] = talloc_reference(mp->path.elements,
+                                                               elements[i]);
                }
                mp->path.elements[i] = NULL;
        } else {
index 99887c67bfa42a65c6a83c9f1e9bd4d17947f1b6..e5d9a26618fc24b45ab85b2b8e4a8de69f3f45c6 100644 (file)
@@ -1,7 +1,7 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Reading registry patch files
-   
+
    Copyright (C) Jelmer Vernooij 2004-2007
    Copyright (C) Wilco Baan Hofman 2006
 
@@ -9,12 +9,12 @@
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 #include "system/filesys.h"
 
 
-_PUBLIC_ WERROR reg_preg_diff_load(int fd, const struct reg_diff_callbacks *callbacks, void *callback_data);
+_PUBLIC_ WERROR reg_preg_diff_load(int fd,
+                                  const struct reg_diff_callbacks *callbacks,
+                                  void *callback_data);
 
-_PUBLIC_ WERROR reg_dotreg_diff_load(int fd, const struct reg_diff_callbacks *callbacks, void *callback_data);
+_PUBLIC_ WERROR reg_dotreg_diff_load(int fd,
+                                    const struct reg_diff_callbacks *callbacks,
+                                    void *callback_data);
 
 /*
  * Generate difference between two keys
  */
-WERROR reg_generate_diff_key(struct registry_key *oldkey, 
-                                                        struct registry_key *newkey,
-                                                        const char *path,
-                                                        const struct reg_diff_callbacks *callbacks,
-                                                        void *callback_data)
+WERROR reg_generate_diff_key(struct registry_key *oldkey,
+                            struct registry_key *newkey,
+                            const char *path,
+                            const struct reg_diff_callbacks *callbacks,
+                            void *callback_data)
 {
        int i;
        struct registry_key *t1, *t2;
@@ -48,11 +52,12 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
                         new_num_subkeys, new_num_values;
 
        if (oldkey != NULL) {
-               error = reg_key_get_info(mem_ctx, oldkey, NULL, &old_num_subkeys, &old_num_values,
-                                                                NULL);
+               error = reg_key_get_info(mem_ctx, oldkey, NULL,
+                                        &old_num_subkeys, &old_num_values,
+                                        NULL);
                if (!W_ERROR_IS_OK(error)) {
-                       DEBUG(0, ("Error occured while getting key info: %s\n", 
-                                         win_errstr(error)));
+                       DEBUG(0, ("Error occured while getting key info: %s\n",
+                               win_errstr(error)));
                        return error;
                }
        } else {
@@ -62,11 +67,12 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
 
        /* Subkeys that were deleted */
        for (i = 0; i < old_num_subkeys; i++) {
-               error1 = reg_key_get_subkey_by_index(mem_ctx, oldkey, i, &keyname1,
-                                                                                        NULL, NULL);
+               error1 = reg_key_get_subkey_by_index(mem_ctx, oldkey, i,
+                                                    &keyname1,
+                                                    NULL, NULL);
                if (!W_ERROR_IS_OK(error1)) {
-                       DEBUG(0, ("Error occured while getting subkey by index: %s\n", 
-                                         win_errstr(error2)));
+                       DEBUG(0, ("Error occured while getting subkey by index: %s\n",
+                               win_errstr(error2)));
                        continue;
                }
 
@@ -81,8 +87,8 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
                }
 
                if (!W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) {
-                       DEBUG(0, ("Error occured while getting subkey by name: %s\n", 
-                                         win_errstr(error2)));
+                       DEBUG(0, ("Error occured while getting subkey by name: %s\n",
+                               win_errstr(error2)));
                        talloc_free(mem_ctx);
                        return error2;
                }
@@ -90,15 +96,16 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
                /* newkey didn't have such a subkey, add del diff */
                tmppath = talloc_asprintf(mem_ctx, "%s\\%s", path, keyname1);
                callbacks->del_key(callback_data, tmppath);
-               talloc_free(tmppath);   
+               talloc_free(tmppath);
        }
 
        if (newkey != NULL) {
-               error = reg_key_get_info(mem_ctx, newkey, NULL, &new_num_subkeys, &new_num_values,
-                                                                NULL);
+               error = reg_key_get_info(mem_ctx, newkey, NULL,
+                                        &new_num_subkeys, &new_num_values,
+                                        NULL);
                if (!W_ERROR_IS_OK(error)) {
-                       DEBUG(0, ("Error occured while getting key info: %s\n", 
-                                         win_errstr(error)));
+                       DEBUG(0, ("Error occured while getting key info: %s\n",
+                               win_errstr(error)));
                        return error;
                }
        } else {
@@ -108,28 +115,29 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
 
        /* Subkeys that were added */
        for(i = 0; i < new_num_subkeys; i++) {
-               error1 = reg_key_get_subkey_by_index(mem_ctx, newkey, i, &keyname1, 
-                                                                                        NULL, NULL);
+               error1 = reg_key_get_subkey_by_index(mem_ctx, newkey,
+                                                    i, &keyname1,
+                                                    NULL, NULL);
                if (!W_ERROR_IS_OK(error1)) {
-                       DEBUG(0, ("Error occured while getting subkey by index: %s\n", 
-                                         win_errstr(error1)));
+                       DEBUG(0, ("Error occured while getting subkey by index: %s\n",
+                               win_errstr(error1)));
                        talloc_free(mem_ctx);
                        return error1;
                }
 
                if (oldkey != NULL) {
                        error2 = reg_open_key(mem_ctx, oldkey, keyname1, &t1);
-                               
+
                        if (W_ERROR_IS_OK(error2))
                                continue;
                } else {
                        t1 = NULL;
                        error2 = WERR_DEST_NOT_FOUND;
                }
-                       
+
                if (!W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) {
-                       DEBUG(0, ("Error occured while getting subkey by name: %s\n", 
-                                         win_errstr(error2)));
+                       DEBUG(0, ("Error occured while getting subkey by name: %s\n",
+                               win_errstr(error2)));
                        talloc_free(mem_ctx);
                        return error2;
                }
@@ -141,7 +149,8 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
                W_ERROR_NOT_OK_RETURN(
                                reg_open_key(mem_ctx, newkey, keyname1, &t2));
 
-               reg_generate_diff_key(t1, t2, tmppath, callbacks, callback_data);
+               reg_generate_diff_key(t1, t2, tmppath,
+                                     callbacks, callback_data);
                talloc_free(tmppath);
        }
 
@@ -151,56 +160,59 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
                uint32_t type1, type2;
                DATA_BLOB contents1, contents2;
 
-               error1 = reg_key_get_value_by_index(mem_ctx, newkey, i, 
-                                                                                       &name, &type1, &contents1);
+               error1 = reg_key_get_value_by_index(mem_ctx, newkey, i,
+                                                   &name, &type1, &contents1);
                if (!W_ERROR_IS_OK(error1)) {
-                       DEBUG(0, ("Unable to get key by index: %s\n", 
-                                         win_errstr(error1)));
+                       DEBUG(0, ("Unable to get key by index: %s\n",
+                               win_errstr(error1)));
                        talloc_free(mem_ctx);
                        return error1;
                }
 
                if (oldkey != NULL) {
-                       error2 = reg_key_get_value_by_name(mem_ctx, oldkey, name, 
-                                                                                  &type2, &contents2);
-               } else 
+                       error2 = reg_key_get_value_by_name(mem_ctx, oldkey,
+                                                          name, &type2,
+                                                          &contents2);
+               } else
                        error2 = WERR_DEST_NOT_FOUND;
-       
-               if(!W_ERROR_IS_OK(error2) && 
+
+               if(!W_ERROR_IS_OK(error2) &&
                   !W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) {
-                       DEBUG(0, ("Error occured while getting value by name: %s\n", 
-                                         win_errstr(error2)));
+                       DEBUG(0, ("Error occured while getting value by name: %s\n",
+                               win_errstr(error2)));
                        talloc_free(mem_ctx);
                        return error2;
                }
 
-               if (W_ERROR_IS_OK(error2) && data_blob_cmp(&contents1, &contents2) == 0)
+               if (W_ERROR_IS_OK(error2) &&
+                   data_blob_cmp(&contents1, &contents2) == 0)
                        continue;
 
-               callbacks->set_value(callback_data, path, name, type1, contents1);
+               callbacks->set_value(callback_data, path, name,
+                                    type1, contents1);
        }
 
        /* Values that were deleted */
        for (i = 0; i < old_num_values; i++) {
                const char *name;
-               error1 = reg_key_get_value_by_index(mem_ctx, oldkey, i, &name, 
-                                                                                       NULL, NULL);
+               error1 = reg_key_get_value_by_index(mem_ctx, oldkey, i, &name,
+                                                   NULL, NULL);
                if (!W_ERROR_IS_OK(error1)) {
-                       DEBUG(0, ("Error ocurred getting value by index: %s\n", 
-                                         win_errstr(error1)));
+                       DEBUG(0, ("Error ocurred getting value by index: %s\n",
+                               win_errstr(error1)));
                        talloc_free(mem_ctx);
                        return error1;
                }
 
-               error2 = reg_key_get_value_by_name(mem_ctx, newkey, name, NULL, 
-                                                                                  NULL);
+               error2 = reg_key_get_value_by_name(mem_ctx, newkey, name, NULL,
+                                                  NULL);
 
                if (W_ERROR_IS_OK(error2))
                        continue;
 
                if (!W_ERROR_EQUAL(error2, WERR_DEST_NOT_FOUND)) {
-                       DEBUG(0, ("Error occured while getting value by name: %s\n", 
-                                         win_errstr(error2)));
+                       DEBUG(0, ("Error occured while getting value by name: %s\n",
+                               win_errstr(error2)));
                        return error2;
                }
 
@@ -212,10 +224,10 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
 }
 
 /**
- * Generate diff between two registry contexts 
+ * Generate diff between two registry contexts
  */
-_PUBLIC_ WERROR reg_generate_diff(struct registry_context *ctx1, 
-                                 struct registry_context *ctx2, 
+_PUBLIC_ WERROR reg_generate_diff(struct registry_context *ctx1,
+                                 struct registry_context *ctx2,
                                  const struct reg_diff_callbacks *callbacks,
                                  void *callback_data)
 {
@@ -225,21 +237,27 @@ _PUBLIC_ WERROR reg_generate_diff(struct registry_context *ctx1,
        for(i = HKEY_FIRST; i <= HKEY_LAST; i++) {
                struct registry_key *r1 = NULL, *r2 = NULL;
                error = reg_get_predefined_key(ctx1, i, &r1);
-               if (!W_ERROR_IS_OK(error) && !W_ERROR_EQUAL(error, WERR_NOT_FOUND)) {
-                       DEBUG(0, ("Unable to open hive %s for backend 1\n", reg_get_predef_name(i)));
+               if (!W_ERROR_IS_OK(error) &&
+                   !W_ERROR_EQUAL(error, WERR_NOT_FOUND)) {
+                       DEBUG(0, ("Unable to open hive %s for backend 1\n",
+                               reg_get_predef_name(i)));
                }
-               
+
                error = reg_get_predefined_key(ctx2, i, &r2);
-               if (!W_ERROR_IS_OK(error) && !W_ERROR_EQUAL(error, WERR_NOT_FOUND)) {
-                       DEBUG(0, ("Unable to open hive %s for backend 2\n", reg_get_predef_name(i)));
+               if (!W_ERROR_IS_OK(error) &&
+                   !W_ERROR_EQUAL(error, WERR_NOT_FOUND)) {
+                       DEBUG(0, ("Unable to open hive %s for backend 2\n",
+                               reg_get_predef_name(i)));
                }
 
                if (r1 == NULL && r2 == NULL)
                        continue;
 
-               error = reg_generate_diff_key(r1, r2, reg_get_predef_name(i), callbacks, callback_data);
+               error = reg_generate_diff_key(r1, r2, reg_get_predef_name(i),
+                                             callbacks, callback_data);
                if (!W_ERROR_IS_OK(error)) {
-                       DEBUG(0, ("Unable to determine diff: %s\n", win_errstr(error)));
+                       DEBUG(0, ("Unable to determine diff: %s\n",
+                               win_errstr(error)));
                        return error;
                }
        }
@@ -252,21 +270,23 @@ _PUBLIC_ WERROR reg_generate_diff(struct registry_context *ctx1,
 /**
  * Load diff file
  */
-_PUBLIC_ WERROR reg_diff_load(const char *filename, 
-                             const struct reg_diff_callbacks *callbacks, 
+_PUBLIC_ WERROR reg_diff_load(const char *filename,
+                             const struct reg_diff_callbacks *callbacks,
                              void *callback_data)
 {
        int fd;
        char hdr[4];
-       
+
        fd = open(filename, O_RDONLY, 0);
        if (fd == -1) {
-               DEBUG(0, ("Error opening registry patch file `%s'\n", filename));
+               DEBUG(0, ("Error opening registry patch file `%s'\n",
+                       filename));
                return WERR_GENERAL_FAILURE;
        }
 
        if (read(fd, &hdr, 4) != 4) {
-               DEBUG(0, ("Error reading registry patch file `%s'\n", filename));
+               DEBUG(0, ("Error reading registry patch file `%s'\n",
+                       filename));
                return WERR_GENERAL_FAILURE;
        }
 
@@ -279,8 +299,8 @@ _PUBLIC_ WERROR reg_diff_load(const char *filename,
        } else if (strncmp(hdr, "regf", 4) == 0) {
                /* Must be a REGF NTConfig.pol file */
                return reg_regf_diff_load(diff, fd);
-       } else 
-#endif 
+       } else
+#endif
        if (strncmp(hdr, "PReg", 4) == 0) {
                /* Must be a GPO Registry.pol file */
                return reg_preg_diff_load(fd, callbacks, callback_data);
@@ -293,7 +313,7 @@ _PUBLIC_ WERROR reg_diff_load(const char *filename,
 /**
  * The reg_diff_apply functions
  */
-static WERROR reg_diff_apply_add_key(void *_ctx, const char *key_name) 
+static WERROR reg_diff_apply_add_key(void *_ctx, const char *key_name)
 {
        struct registry_context *ctx = (struct registry_context *)_ctx;
        struct registry_key *tmp;
@@ -301,14 +321,16 @@ static WERROR reg_diff_apply_add_key(void *_ctx, const char *key_name)
 
        error = reg_key_add_abs(ctx, ctx, key_name, 0, NULL, &tmp);
 
-       if (!W_ERROR_EQUAL(error, WERR_ALREADY_EXISTS) && !W_ERROR_IS_OK(error)) {
-               DEBUG(0, ("Error adding new key '%s': %s\n", key_name, win_errstr(error)));
+       if (!W_ERROR_EQUAL(error, WERR_ALREADY_EXISTS) &&
+           !W_ERROR_IS_OK(error)) {
+               DEBUG(0, ("Error adding new key '%s': %s\n",
+                       key_name, win_errstr(error)));
                return error;
        }
        return WERR_OK;
 }
 
-static WERROR reg_diff_apply_del_key(void *_ctx, const char *key_name) 
+static WERROR reg_diff_apply_del_key(void *_ctx, const char *key_name)
 {
        struct registry_context *ctx = (struct registry_context *)_ctx;
        WERROR error;
@@ -319,16 +341,18 @@ static WERROR reg_diff_apply_del_key(void *_ctx, const char *key_name)
                DEBUG(0, ("Unable to delete key '%s'\n", key_name));
                return error;
        }
-       
+
        return WERR_OK;
 }
 
-static WERROR reg_diff_apply_set_value(void *_ctx, const char *path, const char *value_name, uint32_t value_type, DATA_BLOB value)
+static WERROR reg_diff_apply_set_value(void *_ctx, const char *path,
+                                      const char *value_name,
+                                      uint32_t value_type, DATA_BLOB value)
 {
        struct registry_context *ctx = (struct registry_context *)_ctx;
        struct registry_key *tmp;
        WERROR error;
-       
+
        /* Open key */
        error = reg_open_key_abs(ctx, ctx, path, &tmp);
 
@@ -338,22 +362,23 @@ static WERROR reg_diff_apply_set_value(void *_ctx, const char *path, const char
        }
 
        /* Set value */
-       error = reg_val_set(tmp, value_name, 
+       error = reg_val_set(tmp, value_name,
                                 value_type, value);
        if (!W_ERROR_IS_OK(error)) {
                DEBUG(0, ("Error setting value '%s'\n", value_name));
                return error;
-       }       
-       
+       }
+
        return WERR_OK;
 }
 
-static WERROR reg_diff_apply_del_value (void *_ctx, const char *key_name, const char *value_name)
+static WERROR reg_diff_apply_del_value(void *_ctx, const char *key_name,
+                                      const char *value_name)
 {
        struct registry_context *ctx = (struct registry_context *)_ctx;
        struct registry_key *tmp;
        WERROR error;
-       
+
        /* Open key */
        error = reg_open_key_abs(ctx, ctx, key_name, &tmp);
 
@@ -367,7 +392,7 @@ static WERROR reg_diff_apply_del_value (void *_ctx, const char *key_name, const
                DEBUG(0, ("Error deleting value '%s'\n", value_name));
                return error;
        }
-       
+
 
        return WERR_OK;
 }
@@ -387,26 +412,28 @@ static WERROR reg_diff_apply_del_all_values(void *_ctx, const char *key_name)
                return error;
        }
 
-       W_ERROR_NOT_OK_RETURN(reg_key_get_info(ctx, key, 
-                                                                                  NULL, 
-                                                                                  NULL,
-                                                                                  &num_values, 
-                                                                                  NULL));
+       W_ERROR_NOT_OK_RETURN(reg_key_get_info(ctx, key,
+                                              NULL,
+                                              NULL,
+                                              &num_values,
+                                              NULL));
 
        for (i = 0; i < num_values; i++) {
                const char *name;
-               W_ERROR_NOT_OK_RETURN(reg_key_get_value_by_index(ctx, key, i, &name, 
-                                                                                                                NULL, NULL));
+               W_ERROR_NOT_OK_RETURN(reg_key_get_value_by_index(ctx, key, i,
+                                                                &name,
+                                                                NULL, NULL));
                W_ERROR_NOT_OK_RETURN(reg_del_value(key, name));
        }
 
        return WERR_OK;
 }
 
-/** 
- * Apply diff to a registry context 
+/**
+ * Apply diff to a registry context
  */
-_PUBLIC_ WERROR reg_diff_apply (const char *filename, struct registry_context *ctx)
+_PUBLIC_ WERROR reg_diff_apply(const char *filename,
+                              struct registry_context *ctx)
 {
        struct reg_diff_callbacks callbacks;
 
index 1c0b195a8c91b8fe6369229df6c6f5a6172fdb5c..4c0599b2f3bd8c712289d5177d5eb990e22fb409 100644 (file)
@@ -1,52 +1,55 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Patchfile interface
    Copyright (C) Jelmer Vernooij 2006
    Copyright (C) Wilco Baan Hofman 2006
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 #ifndef _PATCHFILE_H
-#define _PATCHFILE_H 
+#define _PATCHFILE_H
 
 #include "lib/registry/registry.h"
 
 struct reg_diff_callbacks {
        WERROR (*add_key) (void *callback_data, const char *key_name);
-       WERROR (*set_value) (void *callback_data, const char *key_name, 
-                                                const char *value_name, uint32_t value_type, DATA_BLOB value);
-       WERROR (*del_value) (void *callback_data, const char *key_name, const char *value_name);
+       WERROR (*set_value) (void *callback_data, const char *key_name,
+                            const char *value_name, uint32_t value_type,
+                            DATA_BLOB value);
+       WERROR (*del_value) (void *callback_data, const char *key_name,
+                            const char *value_name);
        WERROR (*del_key) (void *callback_data, const char *key_name);
        WERROR (*del_all_values) (void *callback_data, const char *key_name);
        WERROR (*done) (void *callback_data);
 };
 
-WERROR reg_diff_apply (const char *filename, 
-                                                               struct registry_context *ctx);
-
-WERROR reg_generate_diff(struct registry_context *ctx1, 
-                                 struct registry_context *ctx2, 
-                                 const struct reg_diff_callbacks *callbacks,
-                                 void *callback_data);
-WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename, 
-                               struct reg_diff_callbacks **callbacks, void **callback_data);
-WERROR reg_generate_diff_key(struct registry_key *oldkey, 
-                                   struct registry_key *newkey,
-                                   const char *path,
-                                   const struct reg_diff_callbacks *callbacks,
-                                   void *callback_data);
+WERROR reg_diff_apply (const char *filename,
+                      struct registry_context *ctx);
+
+WERROR reg_generate_diff(struct registry_context *ctx1,
+                        struct registry_context *ctx2,
+                        const struct reg_diff_callbacks *callbacks,
+                        void *callback_data);
+WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
+                           struct reg_diff_callbacks **callbacks,
+                           void **callback_data);
+WERROR reg_generate_diff_key(struct registry_key *oldkey,
+                            struct registry_key *newkey,
+                            const char *path,
+                            const struct reg_diff_callbacks *callbacks,
+                            void *callback_data);
 
 #endif /* _PATCHFILE_H */
index 85cf8ab2519aa744b35fe5bd386ca21837708f2e..ebcafc92af4b9f1f2a0fb379644a687d08f41132 100644 (file)
@@ -1,7 +1,7 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Reading .REG files
-   
+
    Copyright (C) Jelmer Vernooij 2004-2007
    Copyright (C) Wilco Baan Hofman 2006
 
@@ -9,12 +9,12 @@
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -43,7 +43,7 @@ static WERROR reg_dotreg_diff_add_key(void *_data, const char *key_name)
        struct dotreg_data *data = (struct dotreg_data *)_data;
 
        fdprintf(data->fd, "\n[%s]\n", key_name);
-       
+
        return WERR_OK;
 }
 
@@ -52,23 +52,25 @@ static WERROR reg_dotreg_diff_del_key(void *_data, const char *key_name)
        struct dotreg_data *data = (struct dotreg_data *)_data;
 
        fdprintf(data->fd, "\n[-%s]\n", key_name);
-       
+
        return WERR_OK;
 }
 
-static WERROR reg_dotreg_diff_set_value(void *_data, const char *path, 
-                                                                               const char *value_name, uint32_t value_type, DATA_BLOB value)
+static WERROR reg_dotreg_diff_set_value(void *_data, const char *path,
+                                       const char *value_name,
+                                       uint32_t value_type, DATA_BLOB value)
 {
        struct dotreg_data *data = (struct dotreg_data *)_data;
 
        fdprintf(data->fd, "\"%s\"=%s:%s\n",
-                       value_name, str_regtype(value_type), 
+                       value_name, str_regtype(value_type),
                        reg_val_data_string(NULL, value_type, value));
-               
+
        return WERR_OK;
 }
 
-static WERROR reg_dotreg_diff_del_value(void *_data, const char *path, const char *value_name)
+static WERROR reg_dotreg_diff_del_value(void *_data, const char *path,
+                                       const char *value_name)
 {
        struct dotreg_data *data = (struct dotreg_data *)_data;
 
@@ -87,7 +89,8 @@ static WERROR reg_dotreg_diff_done(void *_data)
        return WERR_OK;
 }
 
-static WERROR reg_dotreg_diff_del_all_values (void *callback_data, const char *key_name)
+static WERROR reg_dotreg_diff_del_all_values(void *callback_data,
+                                            const char *key_name)
 {
        return WERR_NOT_SUPPORTED;
 }
@@ -95,8 +98,9 @@ static WERROR reg_dotreg_diff_del_all_values (void *callback_data, const char *k
 /**
  * Save registry diff
  */
-_PUBLIC_ WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename, 
-                                                                        struct reg_diff_callbacks **callbacks, void **callback_data)
+_PUBLIC_ WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
+                                    struct reg_diff_callbacks **callbacks,
+                                    void **callback_data)
 {
        struct dotreg_data *data;
 
@@ -125,13 +129,14 @@ _PUBLIC_ WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
        (*callbacks)->done = reg_dotreg_diff_done;
 
        return WERR_OK;
-}      
+}
 
 /**
  * Load diff file
  */
-_PUBLIC_ WERROR reg_dotreg_diff_load(int fd, 
-               const struct reg_diff_callbacks *callbacks, void *callback_data)
+_PUBLIC_ WERROR reg_dotreg_diff_load(int fd,
+                                    const struct reg_diff_callbacks *callbacks,
+                                    void *callback_data)
 {
        char *line, *p, *q;
        char *curkey = NULL;
@@ -152,8 +157,8 @@ _PUBLIC_ WERROR reg_dotreg_diff_load(int fd,
                /* Ignore comments and empty lines */
                if (strlen(line) == 0 || line[0] == ';') {
                        talloc_free(line);
-                       
-                       if (curkey) {   
+
+                       if (curkey) {
                                talloc_free(curkey);
                        }
                        curkey = NULL;
@@ -171,9 +176,11 @@ _PUBLIC_ WERROR reg_dotreg_diff_load(int fd,
                        if (line[1] == '-') {
                                curkey = talloc_strndup(line, line+2, strlen(line)-3);
 
-                               error = callbacks->del_key(callback_data, curkey);
+                               error = callbacks->del_key(callback_data,
+                                                          curkey);
                                if (!W_ERROR_IS_OK(error)) {
-                                       DEBUG(0,("Error deleting key %s\n", curkey));
+                                       DEBUG(0,("Error deleting key %s\n",
+                                               curkey));
                                        talloc_free(mem_ctx);
                                        return error;
                                }
@@ -213,9 +220,11 @@ _PUBLIC_ WERROR reg_dotreg_diff_load(int fd,
 
                /* Delete value */
                if (strcmp(p, "-") == 0) {
-                       error = callbacks->del_value(callback_data, curkey, line);
+                       error = callbacks->del_value(callback_data,
+                                                    curkey, line);
                        if (!W_ERROR_IS_OK(error)) {
-                               DEBUG(0, ("Error deleting value %s in key %s\n", line, curkey));
+                               DEBUG(0, ("Error deleting value %s in key %s\n",
+                                       line, curkey));
                                talloc_free(mem_ctx);
                                return error;
                        }
@@ -223,18 +232,21 @@ _PUBLIC_ WERROR reg_dotreg_diff_load(int fd,
                        talloc_free(line);
                        continue;
                }
-               
+
                q = strchr_m(p, ':');
                if (q) {
-                       *q = '\0'; 
+                       *q = '\0';
                        q++;
                }
 
-               reg_string_to_val(line, q?p:"REG_SZ", q?q:p, &value_type, &value);
-               
-               error = callbacks->set_value(callback_data, curkey, line, value_type, value); 
+               reg_string_to_val(line, q?p:"REG_SZ", q?q:p,
+                                 &value_type, &value);
+
+               error = callbacks->set_value(callback_data, curkey, line,
+                                            value_type, value);
                if (!W_ERROR_IS_OK(error)) {
-                       DEBUG(0, ("Error setting value for %s in %s\n", line, curkey));
+                       DEBUG(0, ("Error setting value for %s in %s\n",
+                               line, curkey));
                        talloc_free(mem_ctx);
                        return error;
                }
index 20bd2fad0dcb0e9bec16094024c1921d4cd4a245..90a4f2529a0c38c06f486d3b64f2aecaaba5308a 100644 (file)
@@ -1,19 +1,19 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Reading Registry.pol PReg registry files
-   
+
    Copyright (C) Wilco Baan Hofman 2006
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -53,13 +53,16 @@ static WERROR reg_preg_diff_del_key(void *_data, const char *key_name)
        return WERR_OK;
 }
 
-static WERROR reg_preg_diff_set_value(void *_data, const char *key_name, const char *value_name, uint32_t value_type, DATA_BLOB value_data)
+static WERROR reg_preg_diff_set_value(void *_data, const char *key_name,
+                                     const char *value_name,
+                                     uint32_t value_type, DATA_BLOB value_data)
 {
        struct preg_data *data = (struct preg_data *)_data;
        return WERR_OK;
 }
 
-static WERROR reg_preg_diff_del_value(void *_data, const char *key_name, const char *value_name)
+static WERROR reg_preg_diff_del_value(void *_data, const char *key_name,
+                                     const char *value_name)
 {
        struct preg_data *data = (struct preg_data *)_data;
        return WERR_OK;
@@ -83,14 +86,16 @@ static WERROR reg_preg_diff_done(void *_data)
 /**
  * Save registry diff
  */
-_PUBLIC_ WERROR reg_preg_diff_save(TALLOC_CTX *ctx, const char *filename, struct reg_diff_callbacks **callbacks, void **callback_data)
+_PUBLIC_ WERROR reg_preg_diff_save(TALLOC_CTX *ctx, const char *filename,
+                                  struct reg_diff_callbacks **callbacks,
+                                  void **callback_data)
 {
        struct preg_data *data;
        struct {
                char hdr[4];
                uint32_t version;
        } preg_header;
-               
+
 
        data = talloc_zero(ctx, struct preg_data);
        *callback_data = data;
@@ -106,23 +111,25 @@ _PUBLIC_ WERROR reg_preg_diff_save(TALLOC_CTX *ctx, const char *filename, struct
        }
        snprintf(preg_header.hdr, 4, "PReg");
        SIVAL(&preg_header, 4, 1);
-       write(data->fd, (uint8_t *)&preg_header,8); 
+       write(data->fd, (uint8_t *)&preg_header,8);
 
        *callbacks = talloc(ctx, struct reg_diff_callbacks);
-       
+
        (*callbacks)->add_key = reg_preg_diff_add_key;
        (*callbacks)->del_key = reg_preg_diff_del_key;
        (*callbacks)->set_value = reg_preg_diff_set_value;
        (*callbacks)->del_value = reg_preg_diff_del_value;
        (*callbacks)->del_all_values = reg_preg_diff_del_all_values;
        (*callbacks)->done = reg_preg_diff_done;
-       
+
        return WERR_OK;
 }
 /**
  * Load diff file
  */
-_PUBLIC_ WERROR reg_preg_diff_load(int fd, const struct reg_diff_callbacks *callbacks, void *callback_data)
+_PUBLIC_ WERROR reg_preg_diff_load(int fd,
+                                  const struct reg_diff_callbacks *callbacks,
+                                  void *callback_data)
 {
        struct {
                char hdr[4];
@@ -132,7 +139,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd, const struct reg_diff_callbacks *call
        char *buf_ptr = buf;
        TALLOC_CTX *mem_ctx = talloc_init("reg_preg_diff_load");
 
-       
+
        /* Read first 8 bytes (the header) */
        if (read(fd, &preg_header, 8) != 8) {
                DEBUG(0, ("Could not read PReg file: %s\n",
@@ -147,14 +154,14 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd, const struct reg_diff_callbacks *call
        }
        if (preg_header.version > 1) {
                DEBUG(0, ("Warning: file format version is higher than expected.\n"));
-       }               
+       }
 
        /* Read the entries */
        while(1) {
                char *key, *value_name;
                uint32_t value_type, length;
                DATA_BLOB data;
-               
+
                if (!W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr))) {
                        break;
                }
@@ -163,17 +170,19 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd, const struct reg_diff_callbacks *call
                        close(fd);
                        return WERR_GENERAL_FAILURE;
                }
-       
+
                /* Get the path */
                buf_ptr = buf;
-               while (W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) && *buf_ptr != ';' && buf_ptr-buf < sizeof(buf)) { 
+               while (W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
+                      *buf_ptr != ';' && buf_ptr-buf < sizeof(buf)) {
                        buf_ptr++;
                }
                key = talloc_asprintf(mem_ctx, "\\%s", buf);
-       
+
                /* Get the name */
                buf_ptr = buf;
-               while (W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) && *buf_ptr != ';' && buf_ptr-buf < sizeof(buf)) { 
+               while (W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
+                      *buf_ptr != ';' && buf_ptr-buf < sizeof(buf)) {
                        buf_ptr++;
                }
                value_name = talloc_strdup(mem_ctx, buf);
@@ -186,7 +195,8 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd, const struct reg_diff_callbacks *call
                }
                /* Read past delimiter */
                buf_ptr = buf;
-               if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) && *buf_ptr == ';') && buf_ptr-buf < sizeof(buf)) {
+               if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
+                   *buf_ptr == ';') && buf_ptr-buf < sizeof(buf)) {
                        DEBUG(0, ("Error in PReg file.\n"));
                        close(fd);
                        return WERR_GENERAL_FAILURE;
@@ -199,39 +209,43 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd, const struct reg_diff_callbacks *call
                }
                /* Read past delimiter */
                buf_ptr = buf;
-               if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) && *buf_ptr == ';') && buf_ptr-buf < sizeof(buf)) {
+               if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
+                   *buf_ptr == ';') && buf_ptr-buf < sizeof(buf)) {
                        DEBUG(0, ("Error in PReg file.\n"));
                        close(fd);
                        return WERR_GENERAL_FAILURE;
-               }       
+               }
                /* Get the data */
                buf_ptr = buf;
-               if (length < sizeof(buf) && read(fd, buf_ptr, length) != length) {
+               if (length < sizeof(buf) &&
+                   read(fd, buf_ptr, length) != length) {
                        DEBUG(0, ("Error while reading PReg\n"));
                        close(fd);
                        return WERR_GENERAL_FAILURE;
                }
                data = data_blob_talloc(mem_ctx, buf, length);
-               
+
                /* Check if delimiter is in place (whine if it isn't) */
                buf_ptr = buf;
-               if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) && *buf_ptr == ']') && buf_ptr-buf < sizeof(buf)) {
-                       DEBUG(0, ("Warning: Missing ']' in PReg file, expected ']', got '%c' 0x%x.\n",*buf_ptr, *buf_ptr));
+               if (!(W_ERROR_IS_OK(preg_read_utf16(fd, buf_ptr)) &&
+                   *buf_ptr == ']') && buf_ptr-buf < sizeof(buf)) {
+                       DEBUG(0, ("Warning: Missing ']' in PReg file, expected ']', got '%c' 0x%x.\n",
+                               *buf_ptr, *buf_ptr));
                }
 
                if (strcasecmp(value_name, "**DelVals") == 0) {
                        callbacks->del_all_values(callback_data, key);
                } else if (strncasecmp(value_name, "**Del.",6) == 0) {
                        char *p = value_name+6;
-                       
+
                        callbacks->del_value(callback_data, key, p);
                } else  if (strcasecmp(value_name, "**DeleteValues") == 0) {
                        char *p, *q;
 
                        p = (char *) data.data;
-                       
+
                        while ((q = strchr_m(p, ';'))) {
-                               *q = '\0'; 
+                               *q = '\0';
                                q++;
 
                                callbacks->del_value(callback_data, key, p);
@@ -243,28 +257,30 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd, const struct reg_diff_callbacks *call
                        char *p, *q, *full_key;
 
                        p = (char *) data.data;
-                       
+
                        while ((q = strchr_m(p, ';'))) {
                                *q = '\0';
                                q++;
-       
-                               full_key = talloc_asprintf(mem_ctx, "%s\\%s", key, p);
+
+                               full_key = talloc_asprintf(mem_ctx, "%s\\%s",
+                                                          key, p);
                                callbacks->del_key(callback_data, full_key);
                                talloc_free(full_key);
 
-                               p = q; 
+                               p = q;
                        }
                        full_key = talloc_asprintf(mem_ctx, "%s\\%s", key, p);
                        callbacks->del_key(callback_data, full_key);
                        talloc_free(full_key);
                } else {
                        callbacks->add_key(callback_data, key);
-                       callbacks->set_value(callback_data, key, value_name, value_type, data);
+                       callbacks->set_value(callback_data, key, value_name,
+                                            value_type, data);
                }
                talloc_free(key);
                talloc_free(value_name);
                talloc_free(data.data);
        }
-       close(fd);      
+       close(fd);
        return WERR_OK;
 }
index 17914a8f7cf2af8912bb4279bcef29c2d5b7fef5..2dd27ca33dc4c706d5f93965e75fd8e832760715 100644 (file)
@@ -8,15 +8,15 @@
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
 #include "includes.h"
 #include "lib/registry/hive.h"
 #include "system/filesys.h"
@@ -28,7 +28,7 @@
 static struct hive_operations reg_backend_regf;
 
 /**
- * There are several places on the web where the REGF format is explained; 
+ * There are several places on the web where the REGF format is explained;
  *
  * TODO: Links
  */
@@ -53,18 +53,18 @@ static WERROR regf_save_hbin(struct regf_data *data);
 
 struct regf_key_data {
        struct hive_key key;
-       struct regf_data *hive; 
+       struct regf_data *hive;
        uint32_t offset;
        struct nk_block *nk;
 };
 
-static struct hbin_block *hbin_by_offset(const struct regf_data *data, 
-                                                                                uint32_t offset, uint32_t *rel_offset)
+static struct hbin_block *hbin_by_offset(const struct regf_data *data,
+                                        uint32_t offset, uint32_t *rel_offset)
 {
        int i;
 
        for (i = 0; data->hbins[i]; i++) {
-               if (offset >= data->hbins[i]->offset_from_first && 
+               if (offset >= data->hbins[i]->offset_from_first &&
                        offset < data->hbins[i]->offset_from_first+
                                         data->hbins[i]->offset_to_next) {
                        if (rel_offset != NULL)
@@ -84,7 +84,7 @@ static uint32_t regf_hdr_checksum(const uint8_t *buffer)
 {
        uint32_t checksum = 0, x;
        int i;
-       
+
        for (i = 0; i < 0x01FB; i+= 4) {
                x = IVAL(buffer, i);
                checksum ^= x;
@@ -122,14 +122,14 @@ static DATA_BLOB hbin_get(const struct regf_data *data, uint32_t offset)
        ret.length = (ret.length ^ 0xffffffff) + 1;
 
        ret.length -= 4; /* 4 bytes for the length... */
-       ret.data = hbin->data + 
+       ret.data = hbin->data +
                (offset - hbin->offset_from_first - 0x20) + 4;
-       
+
        return ret;
 }
 
-static bool hbin_get_tdr (struct regf_data *regf, uint32_t offset, 
-                                                 TALLOC_CTX *ctx, tdr_pull_fn_t pull_fn, void *p)
+static bool hbin_get_tdr(struct regf_data *regf, uint32_t offset,
+                        TALLOC_CTX *ctx, tdr_pull_fn_t pull_fn, void *p)
 {
        struct tdr_pull pull;
 
@@ -140,9 +140,10 @@ static bool hbin_get_tdr (struct regf_data *regf, uint32_t offset,
                DEBUG(1, ("Unable to get data at 0x%04x\n", offset));
                return false;
        }
-       
+
        if (NT_STATUS_IS_ERR(pull_fn(&pull, ctx, p))) {
-               DEBUG(1, ("Error parsing record at 0x%04x using tdr\n", offset));
+               DEBUG(1, ("Error parsing record at 0x%04x using tdr\n",
+                       offset));
                return false;
        }
 
@@ -150,8 +151,8 @@ static bool hbin_get_tdr (struct regf_data *regf, uint32_t offset,
 }
 
 /* Allocate some new data */
-static DATA_BLOB hbin_alloc(struct regf_data *data, uint32_t size, 
-                                                       uint32_t *offset)
+static DATA_BLOB hbin_alloc(struct regf_data *data, uint32_t size,
+                           uint32_t *offset)
 {
        DATA_BLOB ret;
        uint32_t rel_offset = -1; /* Relative offset ! */
@@ -190,13 +191,15 @@ static DATA_BLOB hbin_alloc(struct regf_data *data, uint32_t size,
                                my_size = -my_size;
                        } else if (my_size == size) { /* exact match */
                                rel_offset = j;
-                               DEBUG(4, ("Found free block of exact size %d in middle of HBIN\n", size));
+                               DEBUG(4, ("Found free block of exact size %d in middle of HBIN\n",
+                                       size));
                                break;
                        } else if (my_size > size) { /* data will remain */
                                rel_offset = j;
                                /* Split this block and mark the next block as free */
-                               SIVAL(hbin->data, rel_offset+size, my_size-size); 
-                               DEBUG(4, ("Found free block of size %d (needing %d) in middle of HBIN\n", my_size, size));
+                               SIVAL(hbin->data, rel_offset+size, my_size-size);
+                               DEBUG(4, ("Found free block of size %d (needing %d) in middle of HBIN\n",
+                                       my_size, size));
                                break;
                        }
                }
@@ -204,12 +207,14 @@ static DATA_BLOB hbin_alloc(struct regf_data *data, uint32_t size,
                if (rel_offset != -1)
                        break;
        }
-       
-       /* No space available in previous hbins, 
+
+       /* No space available in previous hbins,
         * allocate new one */
-       if (data->hbins[i] == NULL) { 
-               DEBUG(4, ("No space available in other HBINs for block of size %d, allocating new HBIN\n", size));
-               data->hbins = talloc_realloc(data, data->hbins, struct hbin_block *, i+2);
+       if (data->hbins[i] == NULL) {
+               DEBUG(4, ("No space available in other HBINs for block of size %d, allocating new HBIN\n",
+                       size));
+               data->hbins = talloc_realloc(data, data->hbins,
+                                            struct hbin_block *, i+2);
                hbin = talloc(data->hbins, struct hbin_block);
                SMB_ASSERT(hbin != NULL);
 
@@ -255,11 +260,12 @@ static uint32_t hbin_store (struct regf_data *data, DATA_BLOB blob)
        return ret;
 }
 
-static uint32_t hbin_store_tdr (struct regf_data *data, tdr_push_fn_t push_fn, void *p)
+static uint32_t hbin_store_tdr(struct regf_data *data,
+                              tdr_push_fn_t push_fn, void *p)
 {
        struct tdr_push *push = talloc_zero(data, struct tdr_push);
        uint32_t ret;
-       
+
        if (NT_STATUS_IS_ERR(push_fn(push, p))) {
                DEBUG(0, ("Error during push\n"));
                return -1;
@@ -278,26 +284,27 @@ static void hbin_free (struct regf_data *data, uint32_t offset)
 {
        int32_t size;
        uint32_t rel_offset;
-       int32_t next_size; 
+       int32_t next_size;
        struct hbin_block *hbin;
 
        SMB_ASSERT (offset > 0);
-       
+
        hbin = hbin_by_offset(data, offset, &rel_offset);
 
        if (hbin == NULL)
                return;
-       
+
        /* Get original size */
        size = IVALS(hbin->data, rel_offset);
 
        if (size > 0) {
-               DEBUG(1, ("Trying to free already freed block at 0x%04x\n", offset));
+               DEBUG(1, ("Trying to free already freed block at 0x%04x\n",
+                       offset));
                return;
        }
        /* Mark as unused */
        size = -size;
-       
+
        /* If the next block is free, merge into big free block */
        if (rel_offset + size < hbin->offset_to_next) {
                next_size = IVALS(hbin->data, rel_offset+size);
@@ -312,13 +319,14 @@ static void hbin_free (struct regf_data *data, uint32_t offset)
 
 /**
  * Store a data blob data was already stored, but has changed in size
- * Will try to save it at the current location if possible, otherwise 
+ * Will try to save it at the current location if possible, otherwise
  * does a free + store */
-static uint32_t hbin_store_resize(struct regf_data *data, 
-                                                                 uint32_t orig_offset, DATA_BLOB blob)
+static uint32_t hbin_store_resize(struct regf_data *data,
+                                 uint32_t orig_offset, DATA_BLOB blob)
 {
        uint32_t rel_offset;
-       struct hbin_block *hbin = hbin_by_offset(data, orig_offset, &rel_offset);
+       struct hbin_block *hbin = hbin_by_offset(data, orig_offset,
+                                                &rel_offset);
        int32_t my_size;
        int32_t orig_size;
        int32_t needed_size;
@@ -343,7 +351,8 @@ static uint32_t hbin_store_resize(struct regf_data *data,
                 * and free/merge it */
                if (orig_size - needed_size > 0x4) {
                        SIVALS(hbin->data, rel_offset, -needed_size);
-                       SIVALS(hbin->data, rel_offset + needed_size, needed_size-orig_size);
+                       SIVALS(hbin->data, rel_offset + needed_size,
+                              needed_size-orig_size);
                        hbin_free(data, orig_offset + needed_size);
                }
                return orig_offset;
@@ -357,7 +366,7 @@ static uint32_t hbin_store_resize(struct regf_data *data,
                        break;
 
                my_size = IVALS(hbin->data, i);
-               
+
                if (my_size == 0x0) {
                        DEBUG(0, ("Invalid zero-length block! File is corrupt.\n"));
                        break;
@@ -367,7 +376,8 @@ static uint32_t hbin_store_resize(struct regf_data *data,
 
                if (possible_size >= blob.length) {
                        SIVAL(hbin->data, rel_offset, -possible_size);
-                       memcpy(hbin->data + rel_offset + 0x4, blob.data, blob.length);
+                       memcpy(hbin->data + rel_offset + 0x4,
+                              blob.data, blob.length);
                        return orig_offset;
                }
        }
@@ -376,12 +386,13 @@ static uint32_t hbin_store_resize(struct regf_data *data,
        return hbin_store(data, blob);
 }
 
-static uint32_t hbin_store_tdr_resize (struct regf_data *regf, tdr_push_fn_t push_fn, 
-                                                                          uint32_t orig_offset, void *p)
+static uint32_t hbin_store_tdr_resize(struct regf_data *regf,
+                                     tdr_push_fn_t push_fn,
+                                     uint32_t orig_offset, void *p)
 {
        struct tdr_push *push = talloc_zero(regf, struct tdr_push);
        uint32_t ret;
-       
+
        if (NT_STATUS_IS_ERR(push_fn(push, p))) {
                DEBUG(0, ("Error during push\n"));
                return -1;
@@ -394,13 +405,13 @@ static uint32_t hbin_store_tdr_resize (struct regf_data *regf, tdr_push_fn_t pus
        return ret;
 }
 
-static uint32_t regf_create_lh_hash(const char *name) 
+static uint32_t regf_create_lh_hash(const char *name)
 {
        char *hash_name;
        uint32_t ret = 0;
        uint16_t i;
 
-       hash_name = strupper_talloc(NULL, name);                
+       hash_name = strupper_talloc(NULL, name);
        for (i = 0; *(hash_name + i) != 0; i++) {
                ret *= 37;
                ret += *(hash_name + i);
@@ -409,14 +420,14 @@ static uint32_t regf_create_lh_hash(const char *name)
        return ret;
 }
 
-static WERROR regf_get_info (TALLOC_CTX *mem_ctx,
-                                                        const struct hive_key *key, 
-                                                        const char **classname,
-                                                        uint32_t *num_subkeys,
-                                                        uint32_t *num_values,
-                                                        NTTIME *last_mod_time)
+static WERROR regf_get_info(TALLOC_CTX *mem_ctx,
+                           const struct hive_key *key,
+                           const char **classname,
+                           uint32_t *num_subkeys,
+                           uint32_t *num_values,
+                           NTTIME *last_mod_time)
 {
-       const struct regf_key_data *private_data = 
+       const struct regf_key_data *private_data =
                (const struct regf_key_data *)key;
 
        if (num_subkeys != NULL)
@@ -427,22 +438,23 @@ static WERROR regf_get_info (TALLOC_CTX *mem_ctx,
 
        if (classname != NULL) {
                if (private_data->nk->clsname_offset != -1) {
-                       DATA_BLOB data = hbin_get(private_data->hive, 
-                                                                         private_data->nk->clsname_offset);
-                       *classname = talloc_strndup(mem_ctx, 
-                                                        (char*)data.data, private_data->nk->clsname_length);
-               } else 
+                       DATA_BLOB data = hbin_get(private_data->hive,
+                                                 private_data->nk->clsname_offset);
+                       *classname = talloc_strndup(mem_ctx,
+                                                   (char*)data.data,
+                                                   private_data->nk->clsname_length);
+               } else
                        *classname = NULL;
        }
 
        /* TODO: Last mod time */
-       
+
        return WERR_OK;
 }
 
-static struct regf_key_data *regf_get_key(TALLOC_CTX *ctx, 
-                                                                                 struct regf_data *regf, 
-                                                                                 uint32_t offset)
+static struct regf_key_data *regf_get_key(TALLOC_CTX *ctx,
+                                         struct regf_data *regf,
+                                         uint32_t offset)
 {
        struct nk_block *nk;
        struct regf_key_data *ret;
@@ -457,7 +469,8 @@ static struct regf_key_data *regf_get_key(TALLOC_CTX *ctx,
 
        ret->nk = nk;
 
-       if (!hbin_get_tdr(regf, offset, nk, (tdr_pull_fn_t)tdr_pull_nk_block, nk)) {
+       if (!hbin_get_tdr(regf, offset, nk,
+                         (tdr_pull_fn_t)tdr_pull_nk_block, nk)) {
                DEBUG(0, ("Unable to find HBIN data for offset %d\n", offset));
                return NULL;
        }
@@ -472,11 +485,11 @@ static struct regf_key_data *regf_get_key(TALLOC_CTX *ctx,
 }
 
 
-static WERROR regf_get_value(TALLOC_CTX *ctx, const struct hive_key *key, 
-                                                         int idx, const char **name, 
-                                                         uint32_t *data_type, DATA_BLOB *data)
+static WERROR regf_get_value(TALLOC_CTX *ctx, const struct hive_key *key,
+                            int idx, const char **name,
+                            uint32_t *data_type, DATA_BLOB *data)
 {
-       const struct regf_key_data *private_data = 
+       const struct regf_key_data *private_data =
                        (const struct regf_key_data *)key;
        struct vk_block *vk;
        struct regf_data *regf = private_data->hive;
@@ -500,8 +513,9 @@ static WERROR regf_get_value(TALLOC_CTX *ctx, const struct hive_key *key,
 
        vk = talloc(NULL, struct vk_block);
        W_ERROR_HAVE_NO_MEMORY(vk);
-       
-       if (!hbin_get_tdr(regf, vk_offset, vk, (tdr_pull_fn_t)tdr_pull_vk_block, vk)) {
+
+       if (!hbin_get_tdr(regf, vk_offset, vk,
+                         (tdr_pull_fn_t)tdr_pull_vk_block, vk)) {
                DEBUG(0, ("Unable to get VK block at %d\n", vk_offset));
                talloc_free(vk);
                return WERR_GENERAL_FAILURE;
@@ -514,7 +528,7 @@ static WERROR regf_get_value(TALLOC_CTX *ctx, const struct hive_key *key,
        if (data_type != NULL)
                *data_type = vk->data_type;
 
-       if (vk->data_length & 0x80000000) { 
+       if (vk->data_length & 0x80000000) {
                vk->data_length &=~0x80000000;
                data->data = (uint8_t *)&vk->data_offset;
                data->length = vk->data_length;
@@ -527,13 +541,13 @@ static WERROR regf_get_value(TALLOC_CTX *ctx, const struct hive_key *key,
        }
 
        talloc_free(vk);
-       
+
        return WERR_OK;
 }
 
-static WERROR regf_get_value_by_name (TALLOC_CTX *mem_ctx, 
-                                                                struct hive_key *key, const char *name, 
-                                                                uint32_t *type, DATA_BLOB *data)
+static WERROR regf_get_value_by_name(TALLOC_CTX *mem_ctx,
+                                    struct hive_key *key, const char *name,
+                                    uint32_t *type, DATA_BLOB *data)
 {
        int i;
        const char *vname;
@@ -541,24 +555,25 @@ static WERROR regf_get_value_by_name (TALLOC_CTX *mem_ctx,
 
        /* FIXME: Do binary search? Is this list sorted at all? */
 
-       for (i = 0; W_ERROR_IS_OK(error = regf_get_value(mem_ctx, key, i, 
-                                                                                        &vname, type, data)); i++) {
+       for (i = 0; W_ERROR_IS_OK(error = regf_get_value(mem_ctx, key, i,
+                                                        &vname, type, data));
+                                                        i++) {
                if (!strcmp(vname, name))
                        return WERR_OK;
-    }
+       }
 
        if (W_ERROR_EQUAL(error, WERR_NO_MORE_ITEMS))
                return WERR_NOT_FOUND;
 
        return error;
 }
-       
 
-static WERROR regf_get_subkey_by_index (TALLOC_CTX *ctx, 
-                                                                               const struct hive_key *key, 
-                                                                               uint32_t idx, const char **name,
-                                                                               const char **classname,
-                                                                               NTTIME *last_mod_time)
+
+static WERROR regf_get_subkey_by_index(TALLOC_CTX *ctx,
+                                      const struct hive_key *key,
+                                      uint32_t idx, const char **name,
+                                      const char **classname,
+                                      NTTIME *last_mod_time)
 {
        DATA_BLOB data;
        struct regf_key_data *ret;
@@ -594,7 +609,7 @@ static WERROR regf_get_subkey_by_index (TALLOC_CTX *ctx,
                        return WERR_GENERAL_FAILURE;
                }
                key_off = li.nk_offset[idx];
-       
+
        } else if (!strncmp((char *)data.data, "lf", 2)) {
                struct lf_block lf;
                struct tdr_pull pull;
@@ -618,17 +633,17 @@ static WERROR regf_get_subkey_by_index (TALLOC_CTX *ctx,
        } else if (!strncmp((char *)data.data, "lh", 2)) {
                struct lh_block lh;
                struct tdr_pull pull;
-               
+
                DEBUG(10, ("Subkeys in LH list\n"));
                ZERO_STRUCT(pull);
                pull.data = data;
-               
+
                if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull, nk, &lh))) {
                        DEBUG(0, ("Error parsing LH list\n"));
                        return WERR_GENERAL_FAILURE;
                }
                SMB_ASSERT(!strncmp(lh.header, "lh", 2));
-               
+
                if (lh.key_count != nk->num_subkeys) {
                        DEBUG(0, ("Subkey counts don't match\n"));
                        return WERR_GENERAL_FAILURE;
@@ -639,41 +654,43 @@ static WERROR regf_get_subkey_by_index (TALLOC_CTX *ctx,
                struct tdr_pull pull;
                uint16_t i;
                uint16_t sublist_count = 0;
-               
+
                DEBUG(10, ("Subkeys in RI list\n"));
                ZERO_STRUCT(pull);
                pull.data = data;
-               
+
                if (NT_STATUS_IS_ERR(tdr_pull_ri_block(&pull, nk, &ri))) {
                        DEBUG(0, ("Error parsing RI list\n"));
                        return WERR_GENERAL_FAILURE;
                }
                SMB_ASSERT(!strncmp(ri.header, "ri", 2));
-               
+
                for (i = 0; i < ri.key_count; i++) {
                        DATA_BLOB list_data;
-                       
+
                        /* Get sublist data blob */
                        list_data = hbin_get(private_data->hive, ri.offset[i]);
                        if (!list_data.data) {
                                DEBUG(0, ("Error getting RI list."));
                                return WERR_GENERAL_FAILURE;
                        }
-                       
+
                        ZERO_STRUCT(pull);
                        pull.data = list_data;
-                       
+
                        if (!strncmp((char *)list_data.data, "li", 2)) {
                                struct li_block li;
 
                                DEBUG(10, ("Subkeys in RI->LI list\n"));
 
-                               if (NT_STATUS_IS_ERR(tdr_pull_li_block(&pull, nk, &li))) {
+                               if (NT_STATUS_IS_ERR(tdr_pull_li_block(&pull,
+                                                                      nk,
+                                                                      &li))) {
                                        DEBUG(0, ("Error parsing LI list from RI\n"));
                                        return WERR_GENERAL_FAILURE;
                                }
                                SMB_ASSERT(!strncmp(li.header, "li", 2));
-                               
+
                                /* Advance to next sublist if necessary */
                                if (idx >= sublist_count + li.key_count) {
                                        sublist_count += li.key_count;
@@ -684,10 +701,12 @@ static WERROR regf_get_subkey_by_index (TALLOC_CTX *ctx,
                                break;
                        } else if (!strncmp((char *)list_data.data, "lh", 2)) {
                                struct lh_block lh;
-                               
+
                                DEBUG(10, ("Subkeys in RI->LH list\n"));
 
-                               if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull, nk, &lh))) {
+                               if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull,
+                                                                      nk,
+                                                                      &lh))) {
                                        DEBUG(0, ("Error parsing LH list from RI\n"));
                                        return WERR_GENERAL_FAILURE;
                                }
@@ -706,15 +725,15 @@ static WERROR regf_get_subkey_by_index (TALLOC_CTX *ctx,
 
                                return WERR_GENERAL_FAILURE;
                        }
-                       
+
                }
-       
+
                if (idx > sublist_count) {
                        return WERR_NO_MORE_ITEMS;
                }
 
        } else {
-               DEBUG(0, ("Unknown type for subkey list (0x%04x): %c%c\n", 
+               DEBUG(0, ("Unknown type for subkey list (0x%04x): %c%c\n",
                                  nk->subkeys_offset, data.data[0], data.data[1]));
                return WERR_GENERAL_FAILURE;
        }
@@ -723,11 +742,12 @@ static WERROR regf_get_subkey_by_index (TALLOC_CTX *ctx,
 
        if (classname != NULL) {
                if (ret->nk->clsname_offset != -1) {
-                       DATA_BLOB db = hbin_get(ret->hive, 
-                                                                         ret->nk->clsname_offset);
-                       *classname = talloc_strndup(ctx, 
-                                                        (char*)db.data, ret->nk->clsname_length);
-               } else 
+                       DATA_BLOB db = hbin_get(ret->hive,
+                                               ret->nk->clsname_offset);
+                       *classname = talloc_strndup(ctx,
+                                                   (char*)db.data,
+                                                   ret->nk->clsname_length);
+               } else
                        *classname = NULL;
        }
 
@@ -742,16 +762,17 @@ static WERROR regf_get_subkey_by_index (TALLOC_CTX *ctx,
        return WERR_OK;
 }
 
-static WERROR regf_match_subkey_by_name(TALLOC_CTX *ctx, 
-                                               const struct hive_key *key, uint32_t offset, 
-                                               const char *name, uint32_t *ret) 
+static WERROR regf_match_subkey_by_name(TALLOC_CTX *ctx,
+                                       const struct hive_key *key,
+                                       uint32_t offset,
+                                       const char *name, uint32_t *ret)
 {
        DATA_BLOB subkey_data;
        struct nk_block subkey;
        struct tdr_pull pull;
-       const struct regf_key_data *private_data = 
+       const struct regf_key_data *private_data =
                (const struct regf_key_data *)key;
-       
+
        subkey_data = hbin_get(private_data->hive, offset);
        if (!subkey_data.data) {
                DEBUG(0, ("Unable to retrieve subkey HBIN\n"));
@@ -760,7 +781,7 @@ static WERROR regf_match_subkey_by_name(TALLOC_CTX *ctx,
 
        ZERO_STRUCT(pull);
        pull.data = subkey_data;
-       
+
        if (NT_STATUS_IS_ERR(tdr_pull_nk_block(&pull, ctx, &subkey))) {
                DEBUG(0, ("Error parsing NK structure.\n"));
                return WERR_GENERAL_FAILURE;
@@ -778,14 +799,14 @@ static WERROR regf_match_subkey_by_name(TALLOC_CTX *ctx,
        }
        return WERR_OK;
 }
-       
-static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx, 
-                                                                         const struct hive_key *key, 
-                                                                         const char *name, 
-                                                                         struct hive_key **ret)
+
+static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
+                                     const struct hive_key *key,
+                                     const char *name,
+                                     struct hive_key **ret)
 {
        DATA_BLOB data;
-       const struct regf_key_data *private_data = 
+       const struct regf_key_data *private_data =
                (const struct regf_key_data *)key;
        struct nk_block *nk = private_data->nk;
        uint32_t key_off = 0;
@@ -804,7 +825,7 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
                DEBUG(10, ("Subkeys in LI list\n"));
                ZERO_STRUCT(pull);
                pull.data = data;
-               
+
                if (NT_STATUS_IS_ERR(tdr_pull_li_block(&pull, nk, &li))) {
                        DEBUG(0, ("Error parsing LI list\n"));
                        return WERR_GENERAL_FAILURE;
@@ -815,9 +836,12 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
                        DEBUG(0, ("Subkey counts don't match\n"));
                        return WERR_GENERAL_FAILURE;
                }
-               
+
                for (i = 0; i < li.key_count; i++) {
-                       W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk, key, li.nk_offset[i], name, &key_off));
+                       W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk, key,
+                                                                       li.nk_offset[i],
+                                                                       name,
+                                                                       &key_off));
                        if (key_off != 0)
                                break;
                }
@@ -831,7 +855,7 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
                DEBUG(10, ("Subkeys in LF list\n"));
                ZERO_STRUCT(pull);
                pull.data = data;
-               
+
                if (NT_STATUS_IS_ERR(tdr_pull_lf_block(&pull, nk, &lf))) {
                        DEBUG(0, ("Error parsing LF list\n"));
                        return WERR_GENERAL_FAILURE;
@@ -842,12 +866,16 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
                        DEBUG(0, ("Subkey counts don't match\n"));
                        return WERR_GENERAL_FAILURE;
                }
-               
+
                for (i = 0; i < lf.key_count; i++) {
                        if (strncmp(lf.hr[i].hash, name, 4)) {
                                continue;
                        }
-                       W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk, key, lf.hr[i].nk_offset, name, &key_off));
+                       W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk,
+                                                                       key,
+                                                                       lf.hr[i].nk_offset,
+                                                                       name,
+                                                                       &key_off));
                        if (key_off != 0)
                                break;
                }
@@ -862,7 +890,7 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
                DEBUG(10, ("Subkeys in LH list\n"));
                ZERO_STRUCT(pull);
                pull.data = data;
-               
+
                if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull, nk, &lh))) {
                        DEBUG(0, ("Error parsing LH list\n"));
                        return WERR_GENERAL_FAILURE;
@@ -873,16 +901,20 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
                        DEBUG(0, ("Subkey counts don't match\n"));
                        return WERR_GENERAL_FAILURE;
                }
-               
+
                hash = regf_create_lh_hash(name);
                for (i = 0; i < lh.key_count; i++) {
                        if (lh.hr[i].base37 != hash) {
                                continue;
                        }
-                       W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk, key, lh.hr[i].nk_offset, name, &key_off));
+                       W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk,
+                                                                       key,
+                                                                       lh.hr[i].nk_offset,
+                                                                       name,
+                                                                       &key_off));
                        if (key_off != 0)
                                break;
-               }       
+               }
                if (key_off == 0)
                        return WERR_NOT_FOUND;
        } else if (!strncmp((char *)data.data, "ri", 2)) {
@@ -893,46 +925,52 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
                DEBUG(10, ("Subkeys in RI list\n"));
                ZERO_STRUCT(pull);
                pull.data = data;
-               
+
                if (NT_STATUS_IS_ERR(tdr_pull_ri_block(&pull, nk, &ri))) {
                        DEBUG(0, ("Error parsing RI list\n"));
                        return WERR_GENERAL_FAILURE;
                }
                SMB_ASSERT(!strncmp(ri.header, "ri", 2));
-                       
+
                for (i = 0; i < ri.key_count; i++) {
                        DATA_BLOB list_data;
-                       
+
                        /* Get sublist data blob */
                        list_data = hbin_get(private_data->hive, ri.offset[i]);
                        if (list_data.data == NULL) {
                                DEBUG(0, ("Error getting RI list."));
                                return WERR_GENERAL_FAILURE;
                        }
-                               
+
                        ZERO_STRUCT(pull);
                        pull.data = list_data;
-                       
+
                        if (!strncmp((char *)list_data.data, "li", 2)) {
                                struct li_block li;
-       
-                               if (NT_STATUS_IS_ERR(tdr_pull_li_block(&pull, nk, &li))) {
+
+                               if (NT_STATUS_IS_ERR(tdr_pull_li_block(&pull,
+                                                                      nk,
+                                                                      &li))) {
                                        DEBUG(0, ("Error parsing LI list from RI\n"));
                                        return WERR_GENERAL_FAILURE;
                                }
                                SMB_ASSERT(!strncmp(li.header, "li", 2));
-                               
+
                                for (j = 0; j < li.key_count; j++) {
-                                       W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk, key, 
-                                                               li.nk_offset[j], name, &key_off));
+                                       W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk, key,
+                                                                                       li.nk_offset[j],
+                                                                                       name,
+                                                                                       &key_off));
                                        if (key_off)
                                                break;
                                }
                        } else if (!strncmp((char *)list_data.data, "lh", 2)) {
                                struct lh_block lh;
                                uint32_t hash;
-                               
-                               if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull, nk, &lh))) {
+
+                               if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull,
+                                                                      nk,
+                                                                      &lh))) {
                                        DEBUG(0, ("Error parsing LH list from RI\n"));
                                        return WERR_GENERAL_FAILURE;
                                }
@@ -943,8 +981,10 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
                                        if (lh.hr[j].base37 != hash) {
                                                continue;
                                        }
-                                       W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk, key, 
-                                                               lh.hr[j].nk_offset, name, &key_off));
+                                       W_ERROR_NOT_OK_RETURN(regf_match_subkey_by_name(nk, key,
+                                                                                       lh.hr[j].nk_offset,
+                                                                                       name,
+                                                                                       &key_off));
                                        if (key_off)
                                                break;
                                }
@@ -959,14 +999,15 @@ static WERROR regf_get_subkey_by_name(TALLOC_CTX *ctx,
                return WERR_GENERAL_FAILURE;
        }
 
-       *ret = (struct hive_key *)regf_get_key (ctx, private_data->hive, key_off);
+       *ret = (struct hive_key *)regf_get_key(ctx, private_data->hive,
+                                              key_off);
        return WERR_OK;
 }
 
-static WERROR regf_set_sec_desc (struct hive_key *key, 
-                                                                const struct security_descriptor *sec_desc)
+static WERROR regf_set_sec_desc(struct hive_key *key,
+                               const struct security_descriptor *sec_desc)
 {
-       const struct regf_key_data *private_data = 
+       const struct regf_key_data *private_data =
                (const struct regf_key_data *)key;
        struct sk_block cur_sk, sk, new_sk;
        struct regf_data *regf = private_data->hive;
@@ -976,47 +1017,51 @@ static WERROR regf_set_sec_desc (struct hive_key *key,
        bool update_cur_sk = false;
 
        /* Get the root nk */
-       hbin_get_tdr(regf, regf->header->data_offset, regf, 
-                                (tdr_pull_fn_t) tdr_pull_nk_block, &root);
+       hbin_get_tdr(regf, regf->header->data_offset, regf,
+                    (tdr_pull_fn_t) tdr_pull_nk_block, &root);
 
        /* Push the security descriptor to a blob */
-       if (NT_STATUS_IS_ERR(ndr_push_struct_blob(&data, regf, sec_desc, 
-                                       (ndr_push_flags_fn_t)ndr_push_security_descriptor))) {
+       if (NT_STATUS_IS_ERR(ndr_push_struct_blob(&data, regf, sec_desc,
+                            (ndr_push_flags_fn_t)ndr_push_security_descriptor))) {
                DEBUG(0, ("Unable to push security descriptor\n"));
                return WERR_GENERAL_FAILURE;
        }
 
-       /* Get the current security descriptor for the key */   
-       if (!hbin_get_tdr(regf, private_data->nk->sk_offset, regf, 
-                                         (tdr_pull_fn_t) tdr_pull_sk_block, &cur_sk)) {
+       /* Get the current security descriptor for the key */
+       if (!hbin_get_tdr(regf, private_data->nk->sk_offset, regf,
+                         (tdr_pull_fn_t) tdr_pull_sk_block, &cur_sk)) {
                DEBUG(0, ("Unable to find security descriptor for current key\n"));
                return WERR_BADFILE;
        }
        /* If there's no change, change nothing. */
-       if (memcmp(data.data, cur_sk.sec_desc, MIN(data.length, cur_sk.rec_size)) == 0) {
+       if (memcmp(data.data, cur_sk.sec_desc,
+                  MIN(data.length, cur_sk.rec_size)) == 0) {
                return WERR_OK;
        }
 
-       /* Delete the current sk if only this key is using it */        
+       /* Delete the current sk if only this key is using it */
        if (cur_sk.ref_cnt == 1) {
-               /* Get the previous security descriptor for the key */  
-               if (!hbin_get_tdr(regf, cur_sk.prev_offset, regf, 
-                                                 (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
+               /* Get the previous security descriptor for the key */
+               if (!hbin_get_tdr(regf, cur_sk.prev_offset, regf,
+                                 (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
                        DEBUG(0, ("Unable to find prev security descriptor for current key\n"));
                        return WERR_BADFILE;
                }
                /* Change and store the previous security descriptor */
                sk.next_offset = cur_sk.next_offset;
-               hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_sk_block, cur_sk.prev_offset, &sk);
-               
-               /* Get the next security descriptor for the key */      
-               if (!hbin_get_tdr(regf, cur_sk.next_offset, regf, (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
+               hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_sk_block,
+                                     cur_sk.prev_offset, &sk);
+
+               /* Get the next security descriptor for the key */
+               if (!hbin_get_tdr(regf, cur_sk.next_offset, regf,
+                                 (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
                        DEBUG(0, ("Unable to find next security descriptor for current key\n"));
                        return WERR_BADFILE;
                }
                /* Change and store the next security descriptor */
                sk.prev_offset = cur_sk.prev_offset;
-               hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_sk_block, cur_sk.next_offset, &sk);
+               hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_sk_block,
+                                     cur_sk.next_offset, &sk);
 
                hbin_free(regf, private_data->nk->sk_offset);
        } else {
@@ -1029,20 +1074,26 @@ static WERROR regf_set_sec_desc (struct hive_key *key,
 
        do {
                cur_sk_offset = sk_offset;
-               if (!hbin_get_tdr(regf, sk_offset, regf, (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
+               if (!hbin_get_tdr(regf, sk_offset, regf,
+                                 (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
                        DEBUG(0, ("Unable to find security descriptor\n"));
                        return WERR_BADFILE;
                }
                if (memcmp(data.data, sk.sec_desc, MIN(data.length, sk.rec_size)) == 0) {
                        private_data->nk->sk_offset = sk_offset;
                        sk.ref_cnt++;
-                       hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_sk_block, sk_offset, &sk);
-                       hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_nk_block, private_data->offset, private_data->nk);
+                       hbin_store_tdr_resize(regf,
+                                             (tdr_push_fn_t) tdr_push_sk_block,
+                                             sk_offset, &sk);
+                       hbin_store_tdr_resize(regf,
+                                             (tdr_push_fn_t) tdr_push_nk_block,
+                                             private_data->offset,
+                                             private_data->nk);
                        return WERR_OK;
                }
                sk_offset = sk.next_offset;
        } while (sk_offset != root.sk_offset);
-       
+
        ZERO_STRUCT(new_sk);
        new_sk.header = "sk";
        new_sk.prev_offset = cur_sk_offset;
@@ -1050,8 +1101,10 @@ static WERROR regf_set_sec_desc (struct hive_key *key,
        new_sk.ref_cnt = 1;
        new_sk.rec_size = data.length;
        new_sk.sec_desc = data.data;
-       
-       sk_offset = hbin_store_tdr(regf, (tdr_push_fn_t) tdr_push_sk_block, &new_sk);
+
+       sk_offset = hbin_store_tdr(regf,
+                                  (tdr_push_fn_t) tdr_push_sk_block,
+                                  &new_sk);
        if (sk_offset == -1) {
                DEBUG(0, ("Error storing sk block\n"));
                return WERR_GENERAL_FAILURE;
@@ -1059,47 +1112,58 @@ static WERROR regf_set_sec_desc (struct hive_key *key,
        private_data->nk->sk_offset = sk_offset;
 
        if (update_cur_sk) {
-               hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_sk_block, private_data->nk->sk_offset, &cur_sk);
+               hbin_store_tdr_resize(regf,
+                                     (tdr_push_fn_t) tdr_push_sk_block,
+                                     private_data->nk->sk_offset, &cur_sk);
        }
 
-       /* Get the previous security descriptor for the key */  
-       if (!hbin_get_tdr(regf, new_sk.prev_offset, regf, (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
+       /* Get the previous security descriptor for the key */
+       if (!hbin_get_tdr(regf, new_sk.prev_offset, regf,
+                         (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
                DEBUG(0, ("Unable to find security descriptor for previous key\n"));
                return WERR_BADFILE;
        }
        /* Change and store the previous security descriptor */
        sk.next_offset = sk_offset;
-       hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_sk_block, cur_sk.prev_offset, &sk);
-       
-       /* Get the next security descriptor for the key (always root, as we append) */  
-       if (!hbin_get_tdr(regf, new_sk.next_offset, regf, (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
+       hbin_store_tdr_resize(regf,
+                             (tdr_push_fn_t) tdr_push_sk_block,
+                             cur_sk.prev_offset, &sk);
+
+       /* Get the next security descriptor for the key (always root, as we append) */
+       if (!hbin_get_tdr(regf, new_sk.next_offset, regf,
+                         (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
                DEBUG(0, ("Unable to find security descriptor for current key\n"));
                return WERR_BADFILE;
        }
        /* Change and store the next security descriptor (always root, as we append) */
        sk.prev_offset = sk_offset;
-       hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_sk_block, root.sk_offset, &sk);
+       hbin_store_tdr_resize(regf,
+                             (tdr_push_fn_t) tdr_push_sk_block,
+                             root.sk_offset, &sk);
 
 
        /* Store the nk. */
-       hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_sk_block, private_data->offset, private_data->nk);
+       hbin_store_tdr_resize(regf,
+                             (tdr_push_fn_t) tdr_push_sk_block,
+                             private_data->offset, private_data->nk);
        return WERR_OK;
 }
 
-static WERROR regf_get_sec_desc(TALLOC_CTX *ctx, const struct hive_key *key, 
-                                                               struct security_descriptor **sd)
+static WERROR regf_get_sec_desc(TALLOC_CTX *ctx, const struct hive_key *key,
+                               struct security_descriptor **sd)
 {
-       const struct regf_key_data *private_data = 
+       const struct regf_key_data *private_data =
                (const struct regf_key_data *)key;
        struct sk_block sk;
        struct regf_data *regf = private_data->hive;
        DATA_BLOB data;
 
-       if (!hbin_get_tdr(regf, private_data->nk->sk_offset, ctx, (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
+       if (!hbin_get_tdr(regf, private_data->nk->sk_offset, ctx,
+                         (tdr_pull_fn_t) tdr_pull_sk_block, &sk)) {
                DEBUG(0, ("Unable to find security descriptor\n"));
                return WERR_GENERAL_FAILURE;
        }
-               
+
        if (strcmp(sk.header, "sk") != 0) {
                DEBUG(0, ("Expected 'sk', got '%s'\n", sk.header));
                return WERR_GENERAL_FAILURE;
@@ -1110,7 +1174,8 @@ static WERROR regf_get_sec_desc(TALLOC_CTX *ctx, const struct hive_key *key,
 
        data.data = sk.sec_desc;
        data.length = sk.rec_size;
-       if (NT_STATUS_IS_ERR(ndr_pull_struct_blob(&data, ctx, *sd, (ndr_pull_flags_fn_t)ndr_pull_security_descriptor))) {
+       if (NT_STATUS_IS_ERR(ndr_pull_struct_blob(&data, ctx, *sd,
+                                                 (ndr_pull_flags_fn_t)ndr_pull_security_descriptor))) {
                DEBUG(0, ("Error parsing security descriptor\n"));
                return WERR_GENERAL_FAILURE;
        }
@@ -1118,45 +1183,51 @@ static WERROR regf_get_sec_desc(TALLOC_CTX *ctx, const struct hive_key *key,
        return WERR_OK;
 }
 
-static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset, 
-                                       const char *name, uint32_t key_offset, uint32_t *ret)
+static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset,
+                               const char *name,
+                               uint32_t key_offset, uint32_t *ret)
 {
        DATA_BLOB data;
 
        /* Create a new key if necessary */
-       if (list_offset == -1) { 
+       if (list_offset == -1) {
                if (regf->header->version.major != 1) {
                        DEBUG(0, ("Can't store keys in unknown registry format\n"));
                        return WERR_NOT_SUPPORTED;
                }
-               if (regf->header->version.minor < 3) { 
+               if (regf->header->version.minor < 3) {
                        /* Store LI */
                        struct li_block li;
                        ZERO_STRUCT(li);
                        li.header = "li";
-                       li.key_count = 1; 
+                       li.key_count = 1;
 
                        li.nk_offset = talloc_array(regf, uint32_t, 1);
                        W_ERROR_HAVE_NO_MEMORY(li.nk_offset);
                        li.nk_offset[0] = key_offset;
 
-                       *ret = hbin_store_tdr(regf, (tdr_push_fn_t) tdr_push_li_block, &li);
+                       *ret = hbin_store_tdr(regf,
+                                             (tdr_push_fn_t) tdr_push_li_block,
+                                             &li);
 
                        talloc_free(li.nk_offset);
-               } else if (regf->header->version.minor == 3 || regf->header->version.minor == 4) {
+               } else if (regf->header->version.minor == 3 ||
+                          regf->header->version.minor == 4) {
                        /* Store LF */
                        struct lf_block lf;
                        ZERO_STRUCT(lf);
                        lf.header = "lf";
                        lf.key_count = 1;
-                       
+
                        lf.hr = talloc_array(regf, struct hash_record, 1);
                        W_ERROR_HAVE_NO_MEMORY(lf.hr);
                        lf.hr[0].nk_offset = key_offset;
                        lf.hr[0].hash = talloc_strndup(lf.hr, name, 4);
                        W_ERROR_HAVE_NO_MEMORY(lf.hr[0].hash);
 
-                       *ret = hbin_store_tdr(regf, (tdr_push_fn_t) tdr_push_lf_block, &lf);
+                       *ret = hbin_store_tdr(regf,
+                                             (tdr_push_fn_t) tdr_push_lf_block,
+                                             &lf);
 
                        talloc_free(lf.hr);
                } else if (regf->header->version.minor == 5) {
@@ -1165,19 +1236,21 @@ static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset,
                        ZERO_STRUCT(lh);
                        lh.header = "lh";
                        lh.key_count = 1;
-                       
+
                        lh.hr = talloc_array(regf, struct lh_hash, 1);
                        W_ERROR_HAVE_NO_MEMORY(lh.hr);
                        lh.hr[0].nk_offset = key_offset;
                        lh.hr[0].base37 = regf_create_lh_hash(name);
 
-                       *ret = hbin_store_tdr(regf, (tdr_push_fn_t) tdr_push_lh_block, &lh);
+                       *ret = hbin_store_tdr(regf,
+                                             (tdr_push_fn_t) tdr_push_lh_block,
+                                             &lh);
 
                        talloc_free(lh.hr);
                }
                return WERR_OK;
-       } 
-       
+       }
+
        data = hbin_get(regf, list_offset);
        if (!data.data) {
                DEBUG(0, ("Unable to find subkey list\n"));
@@ -1187,7 +1260,7 @@ static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset,
        if (!strncmp((char *)data.data, "li", 2)) {
                struct tdr_pull pull;
                struct li_block li;
-       
+
                ZERO_STRUCT(pull);
                pull.data = data;
 
@@ -1201,13 +1274,16 @@ static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset,
                        DEBUG(0, ("LI header corrupt\n"));
                        return WERR_BADFILE;
                }
-               
-               li.nk_offset = talloc_realloc(regf, li.nk_offset, uint32_t, li.key_count+1);
+
+               li.nk_offset = talloc_realloc(regf, li.nk_offset,
+                                             uint32_t, li.key_count+1);
                W_ERROR_HAVE_NO_MEMORY(li.nk_offset);
                li.nk_offset[li.key_count] = key_offset;
                li.key_count++;
-               *ret = hbin_store_tdr_resize(regf, (tdr_push_fn_t)tdr_push_li_block, list_offset, &li);
-               
+               *ret = hbin_store_tdr_resize(regf,
+                                            (tdr_push_fn_t)tdr_push_li_block,
+                                            list_offset, &li);
+
                talloc_free(li.nk_offset);
        } else if (!strncmp((char *)data.data, "lf", 2)) {
                struct tdr_pull pull;
@@ -1221,14 +1297,17 @@ static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset,
                        return WERR_BADFILE;
                }
                SMB_ASSERT(!strncmp(lf.header, "lf", 2));
-               
-               lf.hr = talloc_realloc(regf, lf.hr, struct hash_record, lf.key_count+1);
+
+               lf.hr = talloc_realloc(regf, lf.hr, struct hash_record,
+                                      lf.key_count+1);
                W_ERROR_HAVE_NO_MEMORY(lf.hr);
                lf.hr[lf.key_count].nk_offset = key_offset;
                lf.hr[lf.key_count].hash = talloc_strndup(lf.hr, name, 4);
                W_ERROR_HAVE_NO_MEMORY(lf.hr[lf.key_count].hash);
                lf.key_count++;
-               *ret = hbin_store_tdr_resize(regf, (tdr_push_fn_t)tdr_push_lf_block, list_offset, &lf);
+               *ret = hbin_store_tdr_resize(regf,
+                                            (tdr_push_fn_t)tdr_push_lf_block,
+                                            list_offset, &lf);
 
                talloc_free(lf.hr);
        } else if (!strncmp((char *)data.data, "lh", 2)) {
@@ -1243,13 +1322,16 @@ static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset,
                        return WERR_BADFILE;
                }
                SMB_ASSERT(!strncmp(lh.header, "lh", 2));
-               
-               lh.hr = talloc_realloc(regf, lh.hr, struct lh_hash, lh.key_count+1);
+
+               lh.hr = talloc_realloc(regf, lh.hr, struct lh_hash,
+                                      lh.key_count+1);
                W_ERROR_HAVE_NO_MEMORY(lh.hr);
                lh.hr[lh.key_count].nk_offset = key_offset;
                lh.hr[lh.key_count].base37 = regf_create_lh_hash(name);
                lh.key_count++;
-               *ret = hbin_store_tdr_resize(regf, (tdr_push_fn_t)tdr_push_lh_block, list_offset, &lh);
+               *ret = hbin_store_tdr_resize(regf,
+                                            (tdr_push_fn_t)tdr_push_lh_block,
+                                            list_offset, &lh);
 
                talloc_free(lh.hr);
        } else if (!strncmp((char *)data.data, "ri", 2)) {
@@ -1260,12 +1342,12 @@ static WERROR regf_sl_add_entry(struct regf_data *regf, uint32_t list_offset,
                DEBUG(0, ("Cannot add to unknown subkey list\n"));
                return WERR_BADFILE;
        }
-       
+
        return WERR_OK;
 }
 
-static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset, 
-                                                               uint32_t key_offset, uint32_t *ret) 
+static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
+                               uint32_t key_offset, uint32_t *ret)
 {
        DATA_BLOB data;
 
@@ -1280,17 +1362,17 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
                struct tdr_pull pull;
                uint16_t i;
                bool found_offset = false;
-       
+
                DEBUG(10, ("Subkeys in LI list\n"));
-               
+
                ZERO_STRUCT(pull);
-               pull.data = data;       
-               
+               pull.data = data;
+
                if (NT_STATUS_IS_ERR(tdr_pull_li_block(&pull, regf, &li))) {
                        DEBUG(0, ("Error parsing LI list\n"));
                        return WERR_BADFILE;
                }
-               
+
                SMB_ASSERT(!strncmp(li.header, "li", 2));
 
                for (i = 0; i < li.key_count; i++) {
@@ -1315,23 +1397,25 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
                }
 
                /* Store li block */
-               *ret = hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_li_block, list_offset, &li);
+               *ret = hbin_store_tdr_resize(regf,
+                                            (tdr_push_fn_t) tdr_push_li_block,
+                                            list_offset, &li);
        } else if (strncmp((char *)data.data, "lf", 2) == 0) {
                struct lf_block lf;
                struct tdr_pull pull;
                uint16_t i;
                bool found_offset = false;
-               
+
                DEBUG(10, ("Subkeys in LF list\n"));
-               
+
                ZERO_STRUCT(pull);
-               pull.data = data;       
-               
+               pull.data = data;
+
                if (NT_STATUS_IS_ERR(tdr_pull_lf_block(&pull, regf, &lf))) {
                        DEBUG(0, ("Error parsing LF list\n"));
                        return WERR_BADFILE;
                }
-               
+
                SMB_ASSERT(!strncmp(lf.header, "lf", 2));
 
                for (i = 0; i < lf.key_count; i++) {
@@ -1349,7 +1433,7 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
                        return WERR_NOT_FOUND;
                }
                lf.key_count--;
-               
+
                /* If the there are no entries left, free the subkey list */
                if (lf.key_count == 0) {
                        hbin_free(regf, list_offset);
@@ -1358,23 +1442,25 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
                }
 
                /* Store lf block */
-               *ret = hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_lf_block, list_offset, &lf);
+               *ret = hbin_store_tdr_resize(regf,
+                                            (tdr_push_fn_t) tdr_push_lf_block,
+                                            list_offset, &lf);
        } else if (strncmp((char *)data.data, "lh", 2) == 0) {
                struct lh_block lh;
                struct tdr_pull pull;
                uint16_t i;
                bool found_offset = false;
-               
+
                DEBUG(10, ("Subkeys in LH list\n"));
-               
+
                ZERO_STRUCT(pull);
-               pull.data = data;       
-               
+               pull.data = data;
+
                if (NT_STATUS_IS_ERR(tdr_pull_lh_block(&pull, regf, &lh))) {
                        DEBUG(0, ("Error parsing LF list\n"));
                        return WERR_BADFILE;
                }
-               
+
                SMB_ASSERT(!strncmp(lh.header, "lh", 2));
 
                for (i = 0; i < lh.key_count; i++) {
@@ -1392,7 +1478,7 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
                        return WERR_NOT_FOUND;
                }
                lh.key_count--;
-               
+
                /* If the there are no entries left, free the subkey list */
                if (lh.key_count == 0) {
                        hbin_free(regf, list_offset);
@@ -1401,7 +1487,9 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
                }
 
                /* Store lh block */
-               *ret = hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_lh_block, list_offset, &lh);
+               *ret = hbin_store_tdr_resize(regf,
+                                            (tdr_push_fn_t) tdr_push_lh_block,
+                                            list_offset, &lh);
        } else if (strncmp((char *)data.data, "ri", 2) == 0) {
                /* FIXME */
                DEBUG(0, ("Sorry, deletion from ri block is not supported yet.\n"));
@@ -1415,7 +1503,7 @@ static WERROR regf_sl_del_entry(struct regf_data *regf, uint32_t list_offset,
 
 static WERROR regf_del_value (struct hive_key *key, const char *name)
 {
-       const struct regf_key_data *private_data = 
+       const struct regf_key_data *private_data =
                (const struct regf_key_data *)key;
        struct regf_data *regf = private_data->hive;
        struct nk_block *nk = private_data->nk;
@@ -1436,11 +1524,13 @@ static WERROR regf_del_value (struct hive_key *key, const char *name)
                        ((uint32_t *)values.data)[i-1] = ((uint32_t *) values.data)[i];
                } else {
                        vk_offset = IVAL(values.data, i * 4);
-                       if (!hbin_get_tdr(regf, vk_offset, private_data, 
-                                                         (tdr_pull_fn_t)tdr_pull_vk_block, &vk)) {
-                               DEBUG(0, ("Unable to get VK block at %d\n", vk_offset));
+                       if (!hbin_get_tdr(regf, vk_offset, private_data,
+                                         (tdr_pull_fn_t)tdr_pull_vk_block,
+                                         &vk)) {
+                               DEBUG(0, ("Unable to get VK block at %d\n",
+                                       vk_offset));
                                return WERR_BADFILE;
-                       } 
+                       }
                        if (strcmp(vk.data_name, name) == 0) {
                                hbin_free(regf, vk_offset);
                                found_offset = true;
@@ -1458,10 +1548,13 @@ static WERROR regf_del_value (struct hive_key *key, const char *name)
        if (nk->num_values == 0) {
                hbin_free(regf, nk->values_offset);
                nk->values_offset = -1;
-       } else {        
-               nk->values_offset = hbin_store_resize(regf, nk->values_offset, values);
+       } else {
+               nk->values_offset = hbin_store_resize(regf,
+                                                     nk->values_offset,
+                                                     values);
        }
-       hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_nk_block, private_data->offset, nk);
+       hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_nk_block,
+                             private_data->offset, nk);
 
        return regf_save_hbin(private_data->hive);
 }
@@ -1469,14 +1562,14 @@ static WERROR regf_del_value (struct hive_key *key, const char *name)
 
 static WERROR regf_del_key(const struct hive_key *parent, const char *name)
 {
-       const struct regf_key_data *private_data = 
+       const struct regf_key_data *private_data =
                (const struct regf_key_data *)parent;
        struct regf_key_data *key;
        struct nk_block *parent_nk;
        WERROR error;
 
        SMB_ASSERT(private_data);
-       
+
        parent_nk = private_data->nk;
 
        if (parent_nk->subkeys_offset == -1) {
@@ -1485,21 +1578,21 @@ static WERROR regf_del_key(const struct hive_key *parent, const char *name)
        }
 
        /* Find the key */
-       if (!W_ERROR_IS_OK(regf_get_subkey_by_name(parent_nk, parent, name, 
-                                                                          (struct hive_key **)&key))) {
+       if (!W_ERROR_IS_OK(regf_get_subkey_by_name(parent_nk, parent, name,
+                                                  (struct hive_key **)&key))) {
                DEBUG(2, ("Key '%s' not found\n", name));
                return WERR_NOT_FOUND;
        }
-       
-       if (key->nk->subkeys_offset != -1 || 
+
+       if (key->nk->subkeys_offset != -1 ||
                key->nk->values_offset != -1) {
                DEBUG(0, ("Key '%s' is not empty.\n", name));
                return WERR_FILE_EXISTS;
        }
-       
+
        /* Delete it from the subkey list. */
-       error = regf_sl_del_entry(private_data->hive, parent_nk->subkeys_offset, 
-                                                         key->offset, &parent_nk->subkeys_offset);
+       error = regf_sl_del_entry(private_data->hive, parent_nk->subkeys_offset,
+                                 key->offset, &parent_nk->subkeys_offset);
        if (!W_ERROR_IS_OK(error)) {
                DEBUG(0, ("Can't store new subkey list for parent key. Won't delete.\n"));
                return error;
@@ -1507,9 +1600,9 @@ static WERROR regf_del_key(const struct hive_key *parent, const char *name)
 
        /* Re-store parent key */
        parent_nk->num_subkeys--;
-       hbin_store_tdr_resize(private_data->hive, 
-                                                 (tdr_push_fn_t) tdr_push_nk_block, 
-                                                 private_data->offset, parent_nk);
+       hbin_store_tdr_resize(private_data->hive,
+                             (tdr_push_fn_t) tdr_push_nk_block,
+                             private_data->offset, parent_nk);
 
        if (key->nk->clsname_offset != -1) {
                hbin_free(private_data->hive, key->nk->clsname_offset);
@@ -1519,12 +1612,12 @@ static WERROR regf_del_key(const struct hive_key *parent, const char *name)
        return regf_save_hbin(private_data->hive);
 }
 
-static WERROR regf_add_key(TALLOC_CTX *ctx, const struct hive_key *parent, 
-                                                  const char *name, const char *classname,
-                                                  struct security_descriptor *sec_desc, 
-                                                  struct hive_key **ret)
+static WERROR regf_add_key(TALLOC_CTX *ctx, const struct hive_key *parent,
+                          const char *name, const char *classname,
+                          struct security_descriptor *sec_desc,
+                          struct hive_key **ret)
 {
-       const struct regf_key_data *private_data = 
+       const struct regf_key_data *private_data =
                (const struct regf_key_data *)parent;
        struct nk_block *parent_nk = private_data->nk, nk;
        struct nk_block *root;
@@ -1547,32 +1640,33 @@ static WERROR regf_add_key(TALLOC_CTX *ctx, const struct hive_key *parent,
        nk.clsname_offset = -1; /* FIXME: fill in */
        nk.clsname_length = 0;
        nk.key_name = name;
-       
+
        /* Get the security descriptor of the root key */
        root = talloc_zero(ctx, struct nk_block);
        W_ERROR_HAVE_NO_MEMORY(root);
 
-       if (!hbin_get_tdr(regf, regf->header->data_offset, root, 
-                                         (tdr_pull_fn_t)tdr_pull_nk_block, root)) {
+       if (!hbin_get_tdr(regf, regf->header->data_offset, root,
+                         (tdr_pull_fn_t)tdr_pull_nk_block, root)) {
                DEBUG(0, ("Unable to find HBIN data for offset %d\n", offset));
                return WERR_GENERAL_FAILURE;
        }
        nk.sk_offset = root->sk_offset;
        talloc_free(root);
-       
+
        /* Store the new nk key */
        offset = hbin_store_tdr(regf, (tdr_push_fn_t) tdr_push_nk_block, &nk);
-       
-       error = regf_sl_add_entry(regf, parent_nk->subkeys_offset, name, offset, &parent_nk->subkeys_offset);
+
+       error = regf_sl_add_entry(regf, parent_nk->subkeys_offset, name, offset,
+                                 &parent_nk->subkeys_offset);
        if (!W_ERROR_IS_OK(error)) {
                hbin_free(regf, offset);
                return error;
        }
-       
+
        parent_nk->num_subkeys++;
 
        /* Since the subkey offset of the parent can change, store it again */
-       hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_nk_block, 
+       hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_nk_block,
                                                  nk.parent_offset, parent_nk);
 
        *ret = (struct hive_key *)regf_get_key(ctx, regf, offset);
@@ -1580,10 +1674,10 @@ static WERROR regf_add_key(TALLOC_CTX *ctx, const struct hive_key *parent,
        return regf_save_hbin(private_data->hive);
 }
 
-static WERROR regf_set_value(struct hive_key *key, const char *name, 
-                                                        uint32_t type, const DATA_BLOB data)
+static WERROR regf_set_value(struct hive_key *key, const char *name,
+                            uint32_t type, const DATA_BLOB data)
 {
-       const struct regf_key_data *private_data = 
+       const struct regf_key_data *private_data =
                (const struct regf_key_data *)key;
        struct regf_data *regf = private_data->hive;
        struct nk_block *nk = private_data->nk;
@@ -1600,9 +1694,11 @@ static WERROR regf_set_value(struct hive_key *key, const char *name,
 
                for (i = 0; i < nk->num_values; i++) {
                        tmp_vk_offset = IVAL(values.data, i * 4);
-                       if (!hbin_get_tdr(regf, tmp_vk_offset, private_data, 
-                                                         (tdr_pull_fn_t)tdr_pull_vk_block, &vk)) {
-                               DEBUG(0, ("Unable to get VK block at %d\n", tmp_vk_offset));
+                       if (!hbin_get_tdr(regf, tmp_vk_offset, private_data,
+                                         (tdr_pull_fn_t)tdr_pull_vk_block,
+                                         &vk)) {
+                               DEBUG(0, ("Unable to get VK block at %d\n",
+                                       tmp_vk_offset));
                                return WERR_GENERAL_FAILURE;
                        }
                        if (strcmp(vk.data_name, name) == 0) {
@@ -1612,7 +1708,7 @@ static WERROR regf_set_value(struct hive_key *key, const char *name,
                }
                /* Free data, if any */
                if (!(vk.data_length & 0x80000000)) {
-                       hbin_free(regf, vk.data_offset);        
+                       hbin_free(regf, vk.data_offset);
                }
        }
        if (old_vk_offset == -1) {
@@ -1638,15 +1734,21 @@ static WERROR regf_set_value(struct hive_key *key, const char *name,
        }
        if (old_vk_offset == -1) {
                /* Store new vk */
-               vk_offset = hbin_store_tdr(regf, (tdr_push_fn_t) tdr_push_vk_block, &vk);
+               vk_offset = hbin_store_tdr(regf,
+                                          (tdr_push_fn_t) tdr_push_vk_block,
+                                          &vk);
        } else {
                /* Store vk at offset */
-               vk_offset = hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_vk_block, old_vk_offset ,&vk);
+               vk_offset = hbin_store_tdr_resize(regf,
+                                                 (tdr_push_fn_t) tdr_push_vk_block,
+                                                 old_vk_offset ,&vk);
        }
 
        /* Re-allocate the value list */
        if (nk->values_offset == -1) {
-               nk->values_offset = hbin_store_tdr(regf, (tdr_push_fn_t) tdr_push_uint32, &vk_offset);
+               nk->values_offset = hbin_store_tdr(regf,
+                                                  (tdr_push_fn_t) tdr_push_uint32,
+                                                  &vk_offset);
                nk->num_values = 1;
        } else {
 
@@ -1664,17 +1766,23 @@ static WERROR regf_set_value(struct hive_key *key, const char *name,
                        DATA_BLOB value_list;
 
                        value_list.length = (nk->num_values+1)*4;
-                       value_list.data = (uint8_t *)talloc_array(private_data, uint32_t, nk->num_values+1);
+                       value_list.data = (uint8_t *)talloc_array(private_data,
+                                                                 uint32_t,
+                                                                 nk->num_values+1);
                        W_ERROR_HAVE_NO_MEMORY(value_list.data);
                        memcpy(value_list.data, values.data, nk->num_values * 4);
 
                        SIVAL(value_list.data, nk->num_values * 4, vk_offset);
                        nk->num_values++;
-                       nk->values_offset = hbin_store_resize(regf, nk->values_offset, value_list);
+                       nk->values_offset = hbin_store_resize(regf,
+                                                             nk->values_offset,
+                                                             value_list);
                }
-               
+
        }
-       hbin_store_tdr_resize(regf, (tdr_push_fn_t) tdr_push_nk_block, private_data->offset, nk);
+       hbin_store_tdr_resize(regf,
+                             (tdr_push_fn_t) tdr_push_nk_block,
+                             private_data->offset, nk);
        return regf_save_hbin(private_data->hive);
 }
 
@@ -1698,8 +1806,9 @@ static WERROR regf_save_hbin(struct regf_data *regf)
        regf->header->chksum = regf_hdr_checksum(push->data.data);
        talloc_free(push);
 
-       if (NT_STATUS_IS_ERR(tdr_push_to_fd(regf->fd, 
-                                               (tdr_push_fn_t)tdr_push_regf_hdr, regf->header))) {
+       if (NT_STATUS_IS_ERR(tdr_push_to_fd(regf->fd,
+                                           (tdr_push_fn_t)tdr_push_regf_hdr,
+                                           regf->header))) {
                DEBUG(0, ("Error writing registry file header\n"));
                return WERR_GENERAL_FAILURE;
        }
@@ -1707,13 +1816,13 @@ static WERROR regf_save_hbin(struct regf_data *regf)
        if (lseek(regf->fd, 0x1000, SEEK_SET) == -1) {
                DEBUG(0, ("Error lseeking to 0x1000 in regf file\n"));
                return WERR_GENERAL_FAILURE;
-       }       
+       }
 
        for (i = 0; regf->hbins[i]; i++) {
-               if (NT_STATUS_IS_ERR(tdr_push_to_fd(regf->fd, 
-                                                                                       (tdr_push_fn_t)tdr_push_hbin_block, 
-                                                                                       regf->hbins[i]))) {
-                       DEBUG(0, ("Error writing HBIN block\n"));       
+               if (NT_STATUS_IS_ERR(tdr_push_to_fd(regf->fd,
+                                                   (tdr_push_fn_t)tdr_push_hbin_block,
+                                                   regf->hbins[i]))) {
+                       DEBUG(0, ("Error writing HBIN block\n"));
                        return WERR_GENERAL_FAILURE;
                }
        }
@@ -1721,8 +1830,8 @@ static WERROR regf_save_hbin(struct regf_data *regf)
        return WERR_OK;
 }
 
-WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, const char *location, 
-                                                        int minor_version, struct hive_key **key)
+WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, const char *location,
+                           int minor_version, struct hive_key **key)
 {
        struct regf_data *regf;
        struct regf_hdr *regf_hdr;
@@ -1754,7 +1863,8 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, const char *location,
        regf_hdr->version.major = 1;
        regf_hdr->version.minor = minor_version;
        regf_hdr->last_block = 0x1000; /* Block size */
-       regf_hdr->description = talloc_strdup(regf_hdr, "registry created by Samba 4");
+       regf_hdr->description = talloc_strdup(regf_hdr,
+                                             "registry created by Samba 4");
        W_ERROR_HAVE_NO_MEMORY(regf_hdr->description);
        regf_hdr->chksum = 0;
 
@@ -1785,14 +1895,16 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, const char *location,
        nk.clsname_offset = -1; /* FIXME: fill in */
        nk.clsname_length = 0;
        nk.key_name = "";
-       
+
        nk.sk_offset = -1; /* FIXME: fill in */
-       
+
        /* Store the new nk key */
-       regf->header->data_offset = hbin_store_tdr(regf, 
-                                                                       (tdr_push_fn_t)tdr_push_nk_block, &nk);
-       
-       *key = (struct hive_key *)regf_get_key(parent_ctx, regf, regf->header->data_offset);
+       regf->header->data_offset = hbin_store_tdr(regf,
+                                                  (tdr_push_fn_t)tdr_push_nk_block,
+                                                  &nk);
+
+       *key = (struct hive_key *)regf_get_key(parent_ctx, regf,
+                                              regf->header->data_offset);
 
        /* We can drop our own reference now that *key will have created one */
        talloc_free(regf);
@@ -1805,8 +1917,8 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx, const char *location,
        return WERR_OK;
 }
 
-WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx, 
-                                                 const char *location, struct hive_key **key)
+WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
+                         const char *location, struct hive_key **key)
 {
        struct regf_data *regf;
        struct regf_hdr *regf_hdr;
@@ -1850,7 +1962,7 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
 
        if (strcmp(regf_hdr->REGF_ID, "regf") != 0) {
                DEBUG(0, ("Unrecognized NT registry header id: %s, %s\n",
-                                 regf_hdr->REGF_ID, location));
+                       regf_hdr->REGF_ID, location));
                talloc_free(regf);
                return WERR_GENERAL_FAILURE;
        }
@@ -1858,8 +1970,8 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
        /* Validate the header ... */
        if (regf_hdr_checksum(pull.data.data) != regf_hdr->chksum) {
                DEBUG(0, ("Registry file checksum error: %s: %d,%d\n",
-                                 location, regf_hdr->chksum, 
-                                 regf_hdr_checksum(pull.data.data)));
+                       location, regf_hdr->chksum,
+                       regf_hdr_checksum(pull.data.data)));
                talloc_free(regf);
                return WERR_GENERAL_FAILURE;
        }
@@ -1873,8 +1985,10 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
 
        regf->hbins[0] = NULL;
 
-       while (pull.offset < pull.data.length && pull.offset <= regf->header->last_block) {
-               struct hbin_block *hbin = talloc(regf->hbins, struct hbin_block);
+       while (pull.offset < pull.data.length &&
+              pull.offset <= regf->header->last_block) {
+               struct hbin_block *hbin = talloc(regf->hbins,
+                                                struct hbin_block);
 
                W_ERROR_HAVE_NO_MEMORY(hbin);
 
@@ -1885,21 +1999,23 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
                }
 
                if (strcmp(hbin->HBIN_ID, "hbin") != 0) {
-                       DEBUG(0, ("[%d] Expected 'hbin', got '%s'\n", i, hbin->HBIN_ID));
+                       DEBUG(0, ("[%d] Expected 'hbin', got '%s'\n",
+                               i, hbin->HBIN_ID));
                        talloc_free(regf);
                        return WERR_FOOBAR;
                }
 
                regf->hbins[i] = hbin;
                i++;
-               regf->hbins = talloc_realloc(regf, regf->hbins, struct hbin_block *, i+2);
+               regf->hbins = talloc_realloc(regf, regf->hbins,
+                                            struct hbin_block *, i+2);
                regf->hbins[i] = NULL;
-       } 
+       }
 
        DEBUG(1, ("%d HBIN blocks read\n", i));
 
-       *key = (struct hive_key *)regf_get_key(parent_ctx, regf, 
-                                                                                               regf->header->data_offset);
+       *key = (struct hive_key *)regf_get_key(parent_ctx, regf,
+                                              regf->header->data_offset);
 
        /* We can drop our own reference now that *key will have created one */
        talloc_free(regf);
index 6dec84ad8906d71f86347903e83126188ec5c7ef..c1159dde2e26c094a0946469759b8e9075e25fda 100644 (file)
@@ -1,25 +1,25 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Registry interface
    Copyright (C) Gerald Carter                        2002.
    Copyright (C) Jelmer Vernooij                                         2003-2007.
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #ifndef _REGISTRY_H /* _REGISTRY_H */
-#define _REGISTRY_H 
+#define _REGISTRY_H
 
 struct registry_context;
 
@@ -29,15 +29,15 @@ struct registry_context;
 #include "libcli/util/ntstatus.h"
 
 /* Handles for the predefined keys */
-#define HKEY_CLASSES_ROOT               0x80000000
-#define HKEY_CURRENT_USER               0x80000001
-#define HKEY_LOCAL_MACHINE              0x80000002
-#define HKEY_USERS                              0x80000003
-#define HKEY_PERFORMANCE_DATA   0x80000004
-#define HKEY_CURRENT_CONFIG             0x80000005
-#define HKEY_DYN_DATA                   0x80000006
-#define HKEY_PERFORMANCE_TEXT   0x80000050
-#define HKEY_PERFORMANCE_NLSTEXT 0x80000060
+#define HKEY_CLASSES_ROOT              0x80000000
+#define HKEY_CURRENT_USER              0x80000001
+#define HKEY_LOCAL_MACHINE             0x80000002
+#define HKEY_USERS                     0x80000003
+#define HKEY_PERFORMANCE_DATA          0x80000004
+#define HKEY_CURRENT_CONFIG            0x80000005
+#define HKEY_DYN_DATA                  0x80000006
+#define HKEY_PERFORMANCE_TEXT          0x80000050
+#define HKEY_PERFORMANCE_NLSTEXT       0x80000060
 
 #define HKEY_FIRST             HKEY_CLASSES_ROOT
 #define HKEY_LAST              HKEY_PERFORMANCE_NLSTEXT
@@ -61,18 +61,18 @@ extern const struct reg_predefined_key reg_predefined_keys[];
 struct reg_key_operations;
 
 /* structure to store the registry handles */
-struct registry_key 
+struct registry_key
 {
        struct registry_context *context;
 };
 
 #include "lib/registry/patchfile.h"
 
-struct registry_value 
+struct registry_value
 {
-  const char *name;
-  unsigned int data_type;
-  DATA_BLOB data;
+       const char *name;
+       unsigned int data_type;
+       DATA_BLOB data;
 };
 
 /* FIXME */
@@ -86,77 +86,77 @@ struct registry_operations {
        const char *name;
 
        WERROR (*get_key_info) (TALLOC_CTX *mem_ctx,
-                                                       const struct registry_key *key,
-                                                       const char **classname,
-                                                       uint32_t *numsubkeys,
-                                                       uint32_t *numvalues,
-                                                       NTTIME *last_change_time);
+                               const struct registry_key *key,
+                               const char **classname,
+                               uint32_t *numsubkeys,
+                               uint32_t *numvalues,
+                               NTTIME *last_change_time);
 
        WERROR (*flush_key) (struct registry_key *key);
 
-       WERROR (*get_predefined_key) (const struct registry_context *ctx, 
-                                                         uint32_t key_id,
-                                                         struct registry_key **key);
+       WERROR (*get_predefined_key) (const struct registry_context *ctx,
+                                     uint32_t key_id,
+                                     struct registry_key **key);
 
        WERROR (*open_key) (TALLOC_CTX *mem_ctx,
-                                               struct registry_key *parent,
-                                               const char *path,
-                                               struct registry_key **key);
+                           struct registry_key *parent,
+                           const char *path,
+                           struct registry_key **key);
 
-       WERROR (*create_key) (TALLOC_CTX *mem_ctx, 
-                                                 struct registry_key *parent,
-                                                 const char *name,
-                                                 const char *key_class,
-                                                 struct security_descriptor *security,
-                                                 struct registry_key **key);
+       WERROR (*create_key) (TALLOC_CTX *mem_ctx,
+                             struct registry_key *parent,
+                             const char *name,
+                             const char *key_class,
+                             struct security_descriptor *security,
+                             struct registry_key **key);
 
        WERROR (*delete_key) (struct registry_key *key, const char *name);
 
        WERROR (*delete_value) (struct registry_key *key, const char *name);
 
        WERROR (*enum_key) (TALLOC_CTX *mem_ctx,
-                                               const struct registry_key *key, uint32_t idx,
-                                               const char **name,
-                                               const char **keyclass,
-                                               NTTIME *last_changed_time);
+                           const struct registry_key *key, uint32_t idx,
+                           const char **name,
+                           const char **keyclass,
+                           NTTIME *last_changed_time);
 
        WERROR (*enum_value) (TALLOC_CTX *mem_ctx,
-                                                 const struct registry_key *key, uint32_t idx,
-                                                 const char **name,
-                                                 uint32_t *type,
-                                                 DATA_BLOB *data);
+                             const struct registry_key *key, uint32_t idx,
+                             const char **name,
+                             uint32_t *type,
+                             DATA_BLOB *data);
 
        WERROR (*get_security) (TALLOC_CTX *mem_ctx,
-                                                       const struct registry_key *key, 
-                                                       struct security_descriptor **security);
+                               const struct registry_key *key,
+                               struct security_descriptor **security);
 
        WERROR (*set_security) (struct registry_key *key,
-                                                       const struct security_descriptor *security);
+                               const struct security_descriptor *security);
 
        WERROR (*load_key) (struct registry_key *key,
-                                               const char *key_name,
-                                               const char *path);
+                           const char *key_name,
+                           const char *path);
 
        WERROR (*unload_key) (struct registry_key *key, const char *name);
 
        WERROR (*notify_value_change) (struct registry_key *key,
-                                                                       reg_value_notification_function fn);
+                                      reg_value_notification_function fn);
 
        WERROR (*get_value) (TALLOC_CTX *mem_ctx,
-                                                const struct registry_key *key,
-                                                const char *name,
-                                                uint32_t *type,
-                                                DATA_BLOB *data);
+                            const struct registry_key *key,
+                            const char *name,
+                            uint32_t *type,
+                            DATA_BLOB *data);
 
        WERROR (*set_value) (struct registry_key *key,
-                                                const char *name,
-                                                uint32_t type,
-                                                const DATA_BLOB data);
-}; 
+                            const char *name,
+                            uint32_t type,
+                            const DATA_BLOB data);
+};
 
 /**
  * Handle to a full registry
- * contains zero or more hives 
+ * contains zero or more hives
  */
 struct registry_context {
        const struct registry_operations *ops;
@@ -168,113 +168,118 @@ struct event_context;
 /**
  * Open the locally defined registry.
  */
-WERROR reg_open_local (TALLOC_CTX *mem_ctx, 
-                               struct registry_context **ctx, 
-                               struct auth_session_info *session_info, 
-                               struct cli_credentials *credentials);
+WERROR reg_open_local(TALLOC_CTX *mem_ctx,
+                     struct registry_context **ctx,
+                     struct auth_session_info *session_info,
+                     struct cli_credentials *credentials);
 
-WERROR reg_open_samba (TALLOC_CTX *mem_ctx,
-                                                               struct registry_context **ctx,
-                                                               struct auth_session_info *session_info,
-                                                               struct cli_credentials *credentials);
+WERROR reg_open_samba(TALLOC_CTX *mem_ctx,
+                     struct registry_context **ctx,
+                     struct auth_session_info *session_info,
+                     struct cli_credentials *credentials);
 
 /**
  * Open the registry on a remote machine.
  */
-WERROR reg_open_remote(struct registry_context **ctx, 
-                                                               struct auth_session_info *session_info, 
-                                                               struct cli_credentials *credentials, 
-                                                               const char *location, struct event_context *ev);
+WERROR reg_open_remote(struct registry_context **ctx,
+                      struct auth_session_info *session_info,
+                      struct cli_credentials *credentials,
+                      const char *location, struct event_context *ev);
 
 WERROR reg_open_wine(struct registry_context **ctx, const char *path);
 
 const char *reg_get_predef_name(uint32_t hkey);
-WERROR reg_get_predefined_key_by_name(struct registry_context *ctx, 
-                                                                                          const char *name, 
-                                                                                          struct registry_key **key);
-WERROR reg_get_predefined_key(const struct registry_context *ctx, 
-                                                                          uint32_t hkey, 
-                                                                          struct registry_key **key);
-
-WERROR reg_open_key(TALLOC_CTX *mem_ctx, struct registry_key *parent, 
-                                                        const char *name, struct registry_key **result);
-
-WERROR reg_key_get_value_by_index(TALLOC_CTX *mem_ctx, 
-                                  const struct registry_key *key, uint32_t idx, 
-                                  const char **name,
-                                  uint32_t *type,
-                                  DATA_BLOB *data);
+WERROR reg_get_predefined_key_by_name(struct registry_context *ctx,
+                                     const char *name,
+                                     struct registry_key **key);
+WERROR reg_get_predefined_key(const struct registry_context *ctx,
+                             uint32_t hkey,
+                             struct registry_key **key);
+
+WERROR reg_open_key(TALLOC_CTX *mem_ctx, struct registry_key *parent,
+                   const char *name, struct registry_key **result);
+
+WERROR reg_key_get_value_by_index(TALLOC_CTX *mem_ctx,
+                                 const struct registry_key *key, uint32_t idx,
+                                 const char **name,
+                                 uint32_t *type,
+                                 DATA_BLOB *data);
 WERROR reg_key_get_info(TALLOC_CTX *mem_ctx,
-                                                                const struct registry_key *key, 
-                                                                       const char **class_name,
-                                                                       uint32_t *num_subkeys,
-                                                                       uint32_t *num_values,
-                                                                       NTTIME *last_change_time);
-WERROR reg_key_get_subkey_by_index(TALLOC_CTX *mem_ctx, 
-                                                                                       const struct registry_key *key, 
-                                                                                       int idx, 
-                                                                                       const char **name,
-                                                                                       const char **classname,
-                                                                                       NTTIME *last_mod_time);
-WERROR reg_key_get_subkey_by_name(TALLOC_CTX *mem_ctx, 
-                                                                 const struct registry_key *key, 
-                                                                 const char *name, 
-                                                                 struct registry_key **subkey);
-WERROR reg_key_get_value_by_name(TALLOC_CTX *mem_ctx, 
-                                                                                 const struct registry_key *key, 
-                                                                                 const char *name, 
-                                                                                 uint32_t *type,
-                                                                                 DATA_BLOB *data);
+                       const struct registry_key *key,
+                       const char **class_name,
+                       uint32_t *num_subkeys,
+                       uint32_t *num_values,
+                       NTTIME *last_change_time);
+WERROR reg_key_get_subkey_by_index(TALLOC_CTX *mem_ctx,
+                                  const struct registry_key *key,
+                                  int idx,
+                                  const char **name,
+                                  const char **classname,
+                                  NTTIME *last_mod_time);
+WERROR reg_key_get_subkey_by_name(TALLOC_CTX *mem_ctx,
+                                 const struct registry_key *key,
+                                 const char *name,
+                                 struct registry_key **subkey);
+WERROR reg_key_get_value_by_name(TALLOC_CTX *mem_ctx,
+                                const struct registry_key *key,
+                                const char *name,
+                                uint32_t *type,
+                                DATA_BLOB *data);
 WERROR reg_key_del(struct registry_key *parent, const char *name);
-WERROR reg_key_add_name(TALLOC_CTX *mem_ctx, 
-                                                                struct registry_key *parent, const char *name, 
-                                                                const char *classname, 
-                                                                struct security_descriptor *desc, 
-                                                                struct registry_key **newkey);
-WERROR reg_val_set(struct registry_key *key, const char *value, 
-                                                       uint32_t type, DATA_BLOB data);
-WERROR reg_get_sec_desc(TALLOC_CTX *ctx, const struct registry_key *key, struct security_descriptor **secdesc);
+WERROR reg_key_add_name(TALLOC_CTX *mem_ctx,
+                       struct registry_key *parent, const char *name,
+                       const char *classname,
+                       struct security_descriptor *desc,
+                       struct registry_key **newkey);
+WERROR reg_val_set(struct registry_key *key, const char *value,
+                  uint32_t type, DATA_BLOB data);
+WERROR reg_get_sec_desc(TALLOC_CTX *ctx, const struct registry_key *key,
+                       struct security_descriptor **secdesc);
 WERROR reg_del_value(struct registry_key *key, const char *valname);
 WERROR reg_key_flush(struct registry_key *key);
-WERROR reg_create_key (TALLOC_CTX *mem_ctx, 
-                                               struct registry_key *parent,
-
-                                                 const char *name,
-                                                 const char *key_class,
-                                                 struct security_descriptor *security,
-                                                 struct registry_key **key);
+WERROR reg_create_key(TALLOC_CTX *mem_ctx,
+                     struct registry_key *parent,
+                     const char *name,
+                     const char *key_class,
+                     struct security_descriptor *security,
+                     struct registry_key **key);
 
 
 
 
 /* Utility functions */
 const char *str_regtype(int type);
-char *reg_val_data_string(TALLOC_CTX *mem_ctx, uint32_t type, 
-                                                                  const DATA_BLOB data);
+char *reg_val_data_string(TALLOC_CTX *mem_ctx, uint32_t type,
+                         const DATA_BLOB data);
 char *reg_val_description(TALLOC_CTX *mem_ctx, const char *name,
-                                                                  uint32_t type, const DATA_BLOB data);
-bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, const char *data_str, uint32_t *type, DATA_BLOB *data);
-WERROR reg_open_key_abs(TALLOC_CTX *mem_ctx, struct registry_context *handle, const char *name, struct registry_key **result);
+                         uint32_t type, const DATA_BLOB data);
+bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str,
+                      const char *data_str, uint32_t *type, DATA_BLOB *data);
+WERROR reg_open_key_abs(TALLOC_CTX *mem_ctx, struct registry_context *handle,
+                       const char *name, struct registry_key **result);
 WERROR reg_key_del_abs(struct registry_context *ctx, const char *path);
-WERROR reg_key_add_abs(TALLOC_CTX *mem_ctx, struct registry_context *ctx, const char *path, uint32_t access_mask, struct security_descriptor *sec_desc, struct registry_key **result);
-WERROR reg_load_key(struct registry_context *ctx, struct registry_key *key, 
-                                       const char *name, const char *filename);
-
-WERROR reg_mount_hive(struct registry_context *rctx, 
-                                         struct hive_key *hive_key,
-                                         uint32_t key_id,
-                                         const char **elements);
+WERROR reg_key_add_abs(TALLOC_CTX *mem_ctx, struct registry_context *ctx,
+                      const char *path, uint32_t access_mask,
+                      struct security_descriptor *sec_desc,
+                      struct registry_key **result);
+WERROR reg_load_key(struct registry_context *ctx, struct registry_key *key,
+                   const char *name, const char *filename);
+
+WERROR reg_mount_hive(struct registry_context *rctx,
+                     struct hive_key *hive_key,
+                     uint32_t key_id,
+                     const char **elements);
 
 struct registry_key *reg_import_hive_key(struct registry_context *ctx,
-                                                                            struct hive_key *hive, 
-                                                                            uint32_t predef_key,
-                                                                                const char **elements);
-WERROR reg_get_security(TALLOC_CTX *mem_ctx, 
-                                                                const struct registry_key *key, 
-                                                                struct security_descriptor **security);
-
-WERROR reg_set_security(struct registry_key *key, 
-                                                                struct security_descriptor *security);
+                                        struct hive_key *hive,
+                                        uint32_t predef_key,
+                                        const char **elements);
+WERROR reg_get_security(TALLOC_CTX *mem_ctx,
+                       const struct registry_key *key,
+                       struct security_descriptor **security);
+
+WERROR reg_set_security(struct registry_key *key,
+                       struct security_descriptor *security);
 
 
 #endif /* _REGISTRY_H */
index e4157fe42457f7274b9a96bb42bf7822e3c9f96a..c694223909c02c900f33afc5e732d707ae090c80 100644 (file)
@@ -7,15 +7,15 @@
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
 #include "includes.h"
 #include "registry.h"
 #include "librpc/gen_ndr/ndr_winreg_c.h"
@@ -76,7 +76,8 @@ openhive(HKCC)
 
 static struct {
        uint32_t hkey;
-       WERROR (*open) (struct dcerpc_pipe *p, TALLOC_CTX *, struct policy_handle *h);
+       WERROR (*open) (struct dcerpc_pipe *p, TALLOC_CTX *,
+                       struct policy_handle *h);
 } known_hives[] = {
        { HKEY_LOCAL_MACHINE, open_HKLM },
        { HKEY_CURRENT_USER, open_HKCU },
@@ -90,20 +91,20 @@ static struct {
 
 static WERROR rpc_query_key(const struct registry_key *k);
 
-static WERROR rpc_get_predefined_key(const struct registry_context *ctx, 
-                                                                        uint32_t hkey_type, 
-                                                                        struct registry_key **k)
+static WERROR rpc_get_predefined_key(const struct registry_context *ctx,
+                                    uint32_t hkey_type,
+                                    struct registry_key **k)
 {
        int n;
-       struct rpc_registry_context *rctx = talloc_get_type(ctx, 
-                                                                                               struct rpc_registry_context);
+       struct rpc_registry_context *rctx = talloc_get_type(ctx,
+                                                           struct rpc_registry_context);
        struct rpc_key *mykeydata;
 
        for(n = 0; known_hives[n].hkey; n++) {
-               if(known_hives[n].hkey == hkey_type) 
+               if(known_hives[n].hkey == hkey_type)
                        break;
        }
-       
+
        if (known_hives[n].open == NULL)  {
                DEBUG(1, ("No such hive %d\n", hkey_type));
                return WERR_NO_MORE_ITEMS;
@@ -119,7 +120,7 @@ static WERROR rpc_get_predefined_key(const struct registry_context *ctx,
 #if 0
 static WERROR rpc_key_put_rpc_data(TALLOC_CTX *mem_ctx, struct registry_key *k)
 {
-    struct winreg_OpenKey r;
+       struct winreg_OpenKey r;
        struct rpc_key_data *mykeydata;
 
        k->backend_data = mykeydata = talloc(mem_ctx, struct rpc_key_data);
@@ -129,46 +130,47 @@ static WERROR rpc_key_put_rpc_data(TALLOC_CTX *mem_ctx, struct registry_key *k)
        /* Then, open the handle using the hive */
 
        memset(&r, 0, sizeof(struct winreg_OpenKey));
-    r.in.handle = &(((struct rpc_key_data *)k->hive->root->backend_data)->pol);
-    init_winreg_String(&r.in.keyname, k->path);
-    r.in.unknown = 0x00000000;
-    r.in.access_mask = 0x02000000;
-    r.out.handle = &mykeydata->pol;
+       r.in.handle = &(((struct rpc_key_data *)k->hive->root->backend_data)->pol);
+       init_winreg_String(&r.in.keyname, k->path);
+       r.in.unknown = 0x00000000;
+       r.in.access_mask = 0x02000000;
+       r.out.handle = &mykeydata->pol;
 
-    dcerpc_winreg_OpenKey((struct dcerpc_pipe *)k->hive->backend_data, mem_ctx, &r);
+       dcerpc_winreg_OpenKey((struct dcerpc_pipe *)k->hive->backend_data,
+                             mem_ctx, &r);
 
        return r.out.result;
 }
 #endif
 
-static WERROR rpc_open_key(TALLOC_CTX *mem_ctx, struct registry_key *h, 
-                                                  const char *name, struct registry_key **key)
+static WERROR rpc_open_key(TALLOC_CTX *mem_ctx, struct registry_key *h,
+                          const char *name, struct registry_key **key)
 {
        struct rpc_key *mykeydata = talloc_get_type(h, struct rpc_key),
-                                  *newkeydata;
-    struct winreg_OpenKey r;
+                                                   *newkeydata;
+       struct winreg_OpenKey r;
 
        mykeydata = talloc(mem_ctx, struct rpc_key);
 
        /* Then, open the handle using the hive */
        memset(&r, 0, sizeof(struct winreg_OpenKey));
-    r.in.parent_handle = &mykeydata->pol;
-    init_winreg_String(&r.in.keyname, name);
-    r.in.unknown = 0x00000000;
-    r.in.access_mask = 0x02000000;
-    r.out.handle = &newkeydata->pol;
+       r.in.parent_handle = &mykeydata->pol;
+       init_winreg_String(&r.in.keyname, name);
+       r.in.unknown = 0x00000000;
+       r.in.access_mask = 0x02000000;
+       r.out.handle = &newkeydata->pol;
 
-    dcerpc_winreg_OpenKey(mykeydata->pipe, mem_ctx, &r);
+       dcerpc_winreg_OpenKey(mykeydata->pipe, mem_ctx, &r);
 
        return r.out.result;
 }
 
-static WERROR rpc_get_value_by_index(TALLOC_CTX *mem_ctx, 
-                                                                        const struct registry_key *parent, 
-                                                                        uint32_t n, 
-                                                                        const char **value_name,
-                                                                        uint32_t *type,
-                                                                        DATA_BLOB *data)
+static WERROR rpc_get_value_by_index(TALLOC_CTX *mem_ctx,
+                                    const struct registry_key *parent,
+                                    uint32_t n,
+                                    const char **value_name,
+                                    uint32_t *type,
+                                    DATA_BLOB *data)
 {
        struct rpc_key *mykeydata = talloc_get_type(parent, struct rpc_key);
        WERROR error;
@@ -177,14 +179,14 @@ static WERROR rpc_get_value_by_index(TALLOC_CTX *mem_ctx,
        NTSTATUS status;
        struct winreg_StringBuf name;
        uint8_t u8;
-       
+
        if (mykeydata->num_values == -1) {
                error = rpc_query_key(parent);
                if(!W_ERROR_IS_OK(error)) return error;
        }
 
        len1 = mykeydata->max_valdatalen;
-       
+
        name.length = 0;
        name.size   = mykeydata->max_valnamelen * 2;
        name.name   = "";
@@ -197,29 +199,29 @@ static WERROR rpc_get_value_by_index(TALLOC_CTX *mem_ctx,
        r.in.length = &zero;
        r.in.size = &len1;
        r.out.name = &name;
-       
+
        status = dcerpc_winreg_EnumValue(mykeydata->pipe, mem_ctx, &r);
        if(NT_STATUS_IS_ERR(status)) {
                DEBUG(0, ("Error in EnumValue: %s\n", nt_errstr(status)));
                return WERR_GENERAL_FAILURE;
        }
-       
-       if(NT_STATUS_IS_OK(status) && 
+
+       if(NT_STATUS_IS_OK(status) &&
           W_ERROR_IS_OK(r.out.result) && r.out.length) {
                *value_name = talloc_strdup(mem_ctx, r.out.name->name);
                *data = data_blob_talloc(mem_ctx, r.out.value, *r.out.length);
                return WERR_OK;
        }
-       
+
        return r.out.result;
 }
 
-static WERROR rpc_get_subkey_by_index(TALLOC_CTX *mem_ctx, 
-                                                                         const struct registry_key *parent, 
-                                                                         uint32_t n, 
-                                                                         const char **name,
-                                                                         const char **keyclass,
-                                                                         NTTIME *last_changed_time)
+static WERROR rpc_get_subkey_by_index(TALLOC_CTX *mem_ctx,
+                                     const struct registry_key *parent,
+                                     uint32_t n,
+                                     const char **name,
+                                     const char **keyclass,
+                                     NTTIME *last_changed_time)
 {
        struct winreg_EnumKey r;
        struct rpc_key *mykeydata = talloc_get_type(parent, struct rpc_key);
@@ -242,7 +244,7 @@ static WERROR rpc_get_subkey_by_index(TALLOC_CTX *mem_ctx,
        r.out.name = &namebuf;
 
        status = dcerpc_winreg_EnumKey(mykeydata->pipe, mem_ctx, &r);
-       if(NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(r.out.result)) {
+       if (NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(r.out.result)) {
                *name = talloc_strdup(mem_ctx, r.out.name->name);
                *keyclass = talloc_strdup(mem_ctx, r.out.keyclass->name);
                *last_changed_time = *r.out.last_changed_time;
@@ -251,11 +253,11 @@ static WERROR rpc_get_subkey_by_index(TALLOC_CTX *mem_ctx,
        return r.out.result;
 }
 
-static WERROR rpc_add_key(TALLOC_CTX *mem_ctx, 
-                                                 struct registry_key *parent, const char *name, 
-                                                 const char *key_class,
-                                                 struct security_descriptor *sec, 
-                                                 struct registry_key **key)
+static WERROR rpc_add_key(TALLOC_CTX *mem_ctx,
+                         struct registry_key *parent, const char *name,
+                         const char *key_class,
+                         struct security_descriptor *sec,
+                         struct registry_key **key)
 {
        NTSTATUS status;
        struct winreg_CreateKey r;
@@ -273,11 +275,11 @@ static WERROR rpc_add_key(TALLOC_CTX *mem_ctx,
 
        status = dcerpc_winreg_CreateKey(parentkd->pipe, mem_ctx, &r);
 
-    if (!NT_STATUS_IS_OK(status)) {
+       if (!NT_STATUS_IS_OK(status)) {
                talloc_free(rpck);
-        DEBUG(1, ("CreateKey failed - %s\n", nt_errstr(status)));
-        return ntstatus_to_werror(status);
-    }
+               DEBUG(1, ("CreateKey failed - %s\n", nt_errstr(status)));
+               return ntstatus_to_werror(status);
+       }
 
        if (W_ERROR_IS_OK(r.out.result)) {
                rpck->pipe = talloc_reference(rpck, parentkd->pipe);
@@ -289,29 +291,29 @@ static WERROR rpc_add_key(TALLOC_CTX *mem_ctx,
 
 static WERROR rpc_query_key(const struct registry_key *k)
 {
-    NTSTATUS status;
-    struct winreg_QueryInfoKey r;
-    struct rpc_key *mykeydata = talloc_get_type(k, struct rpc_key);
+       NTSTATUS status;
+       struct winreg_QueryInfoKey r;
+       struct rpc_key *mykeydata = talloc_get_type(k, struct rpc_key);
        TALLOC_CTX *mem_ctx = talloc_init("query_key");
 
        r.in.classname = talloc(mem_ctx, struct winreg_String);
-    init_winreg_String(r.in.classname, NULL);
-    r.in.handle = &mykeydata->pol;
-       
-    status = dcerpc_winreg_QueryInfoKey(mykeydata->pipe, mem_ctx, &r);
+       init_winreg_String(r.in.classname, NULL);
+       r.in.handle = &mykeydata->pol;
+
+       status = dcerpc_winreg_QueryInfoKey(mykeydata->pipe, mem_ctx, &r);
        talloc_free(mem_ctx);
 
-    if (!NT_STATUS_IS_OK(status)) {
-        DEBUG(1, ("QueryInfoKey failed - %s\n", nt_errstr(status)));
-        return ntstatus_to_werror(status);
-    }
-                                                                                                       
-    if (W_ERROR_IS_OK(r.out.result)) {
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(1, ("QueryInfoKey failed - %s\n", nt_errstr(status)));
+               return ntstatus_to_werror(status);
+       }
+
+       if (W_ERROR_IS_OK(r.out.result)) {
                mykeydata->num_subkeys = *r.out.num_subkeys;
                mykeydata->num_values = *r.out.num_values;
                mykeydata->max_valnamelen = *r.out.max_valnamelen;
                mykeydata->max_valdatalen = *r.out.max_valbufsize;
-       } 
+       }
 
        return r.out.result;
 }
@@ -322,11 +324,11 @@ static WERROR rpc_del_key(struct registry_key *parent, const char *name)
        struct rpc_key *mykeydata = talloc_get_type(parent, struct rpc_key);
        struct winreg_DeleteKey r;
        TALLOC_CTX *mem_ctx = talloc_init("del_key");
-       
-    r.in.handle = &mykeydata->pol;
-    init_winreg_String(&r.in.key, name);
-    status = dcerpc_winreg_DeleteKey(mykeydata->pipe, mem_ctx, &r);
+
+       r.in.handle = &mykeydata->pol;
+       init_winreg_String(&r.in.key, name);
+
+       status = dcerpc_winreg_DeleteKey(mykeydata->pipe, mem_ctx, &r);
 
        talloc_free(mem_ctx);
 
@@ -334,19 +336,19 @@ static WERROR rpc_del_key(struct registry_key *parent, const char *name)
 }
 
 static WERROR rpc_get_info(TALLOC_CTX *mem_ctx, const struct registry_key *key,
-                                                  const char **classname, 
+                                                  const char **classname,
                                                   uint32_t *numsubkeys,
                                                   uint32_t *numvalue,
                                                   NTTIME *last_changed_time)
 {
        struct rpc_key *mykeydata = talloc_get_type(key, struct rpc_key);
        WERROR error;
-               
-       if(mykeydata->num_values == -1) {
+
+       if (mykeydata->num_values == -1) {
                error = rpc_query_key(key);
                if(!W_ERROR_IS_OK(error)) return error;
        }
-                       
+
        /* FIXME: *classname = talloc_strdup(mem_ctx, mykeydata->classname); */
        /* FIXME: *last_changed_time = mykeydata->last_changed_time */
 
@@ -370,10 +372,10 @@ static struct registry_operations reg_backend_rpc = {
        .get_predefined_key = rpc_get_predefined_key,
 };
 
-_PUBLIC_ WERROR reg_open_remote(struct registry_context **ctx, 
-                                                               struct auth_session_info *session_info, 
-                                                               struct cli_credentials *credentials, 
-                                                               const char *location, struct event_context *ev)
+_PUBLIC_ WERROR reg_open_remote(struct registry_context **ctx,
+                               struct auth_session_info *session_info,
+                               struct cli_credentials *credentials,
+                               const char *location, struct event_context *ev)
 {
        NTSTATUS status;
        struct dcerpc_pipe *p;
@@ -388,14 +390,15 @@ _PUBLIC_ WERROR reg_open_remote(struct registry_context **ctx,
                location = talloc_strdup(ctx, "ncalrpc:");
        }
 
-       status = dcerpc_pipe_connect(*ctx /* TALLOC_CTX */, 
-                                    &p, location, 
+       status = dcerpc_pipe_connect(*ctx /* TALLOC_CTX */,
+                                    &p, location,
                                         &ndr_table_winreg,
                                     credentials, ev);
        rctx->pipe = p;
 
        if(NT_STATUS_IS_ERR(status)) {
-               DEBUG(1, ("Unable to open '%s': %s\n", location, nt_errstr(status)));
+               DEBUG(1, ("Unable to open '%s': %s\n", location,
+                       nt_errstr(status)));
                talloc_free(*ctx);
                *ctx = NULL;
                return ntstatus_to_werror(status);
index 18bbcb8299593809ca227c362dd7ac40b4f15195..2397432f0bc1e043f0640a688bc91f633cff786f 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Copyright (C) Jelmer Vernooij                       2004-2007.
 
  * @brief Samba-specific registry functions
  */
 
-static WERROR mount_samba_hive(struct registry_context *ctx, 
+static WERROR mount_samba_hive(struct registry_context *ctx,
                               struct auth_session_info *auth_info,
                               struct cli_credentials *creds,
-                              const char *name, 
+                              const char *name,
                               uint32_t hive_id)
 {
        WERROR error;
        struct hive_key *hive;
        const char *location;
 
-       location = talloc_asprintf(ctx, "%s/%s.ldb", lp_private_dir(global_loadparm), name);
-
+       location = talloc_asprintf(ctx, "%s/%s.ldb",
+                                  lp_private_dir(global_loadparm),
+                                  name);
 
        error = reg_open_hive(ctx, location, auth_info, creds, &hive);
 
        if (W_ERROR_EQUAL(error, WERR_NOT_FOUND))
-               error = reg_open_ldb_file(ctx, location, auth_info, creds, &hive);
+               error = reg_open_ldb_file(ctx, location, auth_info,
+                                         creds, &hive);
 
        if (!W_ERROR_IS_OK(error))
                return error;
@@ -50,10 +52,10 @@ static WERROR mount_samba_hive(struct registry_context *ctx,
 }
 
 
-_PUBLIC_ WERROR reg_open_samba (TALLOC_CTX *mem_ctx, 
-                               struct registry_context **ctx, 
-                               struct auth_session_info *session_info, 
-                               struct cli_credentials *credentials)
+_PUBLIC_ WERROR reg_open_samba(TALLOC_CTX *mem_ctx,
+                              struct registry_context **ctx,
+                              struct auth_session_info *session_info,
+                              struct cli_credentials *credentials)
 {
        WERROR result;
 
@@ -62,19 +64,19 @@ _PUBLIC_ WERROR reg_open_samba (TALLOC_CTX *mem_ctx,
                return result;
        }
 
-       mount_samba_hive(*ctx, session_info, credentials, 
-                                        "hklm", HKEY_LOCAL_MACHINE);
+       mount_samba_hive(*ctx, session_info, credentials,
+                        "hklm", HKEY_LOCAL_MACHINE);
 
-       mount_samba_hive(*ctx, session_info, credentials, 
-                                        "hkcr", HKEY_CLASSES_ROOT);
+       mount_samba_hive(*ctx, session_info, credentials,
+                        "hkcr", HKEY_CLASSES_ROOT);
 
-       /* FIXME: Should be mounted from NTUSER.DAT in the home directory of the 
+       /* FIXME: Should be mounted from NTUSER.DAT in the home directory of the
         * current user */
-       mount_samba_hive(*ctx, session_info, credentials, 
-                                        "hkcu", HKEY_CURRENT_USER);
+       mount_samba_hive(*ctx, session_info, credentials,
+                        "hkcu", HKEY_CURRENT_USER);
 
-       mount_samba_hive(*ctx, session_info, credentials, 
-                                        "hku", HKEY_USERS);
+       mount_samba_hive(*ctx, session_info, credentials,
+                        "hku", HKEY_USERS);
 
        /* FIXME: Different hive backend for HKEY_CLASSES_ROOT: merged view of HKEY_LOCAL_MACHINE\Software\Classes
         * and HKEY_CURRENT_USER\Software\Classes */
@@ -86,6 +88,6 @@ _PUBLIC_ WERROR reg_open_samba (TALLOC_CTX *mem_ctx,
        /* FIXME: HKEY_LOCAL_MACHINE\Hardware is autogenerated */
 
        /* FIXME: HKEY_LOCAL_MACHINE\Security\SAM is an alias for HKEY_LOCAL_MACHINE\SAM */
-       
+
        return WERR_OK;
 }
index 78b578d2e502ab5c51c3d463eb993bf8225c9523..ca3e3dd619dd44d83f512aa23a9e291dce79eb63 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Transparent registry backend handling
    Copyright (C) Jelmer Vernooij                       2003-2007.
@@ -43,60 +43,59 @@ _PUBLIC_ const char *str_regtype(int type)
 {
        int i;
        for (i = 0; reg_value_types[i].name; i++) {
-               if (reg_value_types[i].id == type) 
+               if (reg_value_types[i].id == type)
                        return reg_value_types[i].name;
        }
 
        return "Unknown";
 }
 
-_PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx, uint32_t type, 
+_PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx, uint32_t type,
                                   const DATA_BLOB data)
-{ 
-  char *ret = NULL;
-
-  if (data.length == 0) 
-         return talloc_strdup(mem_ctx, "");
-
-  switch (type) {
-  case REG_EXPAND_SZ:
-  case REG_SZ:
-      convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, data.data, data.length, 
-                                                       (void **)&ret);
-         return ret;
-
-  case REG_BINARY:
-         ret = data_blob_hex_string(mem_ctx, &data);
-         return ret;
-
-  case REG_DWORD:
-         if (*(int *)data.data == 0)
-                 return talloc_strdup(mem_ctx, "0");
-
-         return talloc_asprintf(mem_ctx, "0x%x", *(int *)data.data);
+{
+       char *ret = NULL;
 
-  case REG_MULTI_SZ:
-       /* FIXME */
-    break;
+       if (data.length == 0)
+               return talloc_strdup(mem_ctx, "");
 
-  default:
-    break;
-  } 
+       switch (type) {
+               case REG_EXPAND_SZ:
+               case REG_SZ:
+                       convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX,
+                                             data.data, data.length,
+                                             (void **)&ret);
+                       return ret;
+               case REG_BINARY:
+                       ret = data_blob_hex_string(mem_ctx, &data);
+                       return ret;
+               case REG_DWORD:
+                       if (*(int *)data.data == 0)
+                               return talloc_strdup(mem_ctx, "0");
+                       return talloc_asprintf(mem_ctx, "0x%x",
+                                              *(int *)data.data);
+               case REG_MULTI_SZ:
+                       /* FIXME */
+                       break;
+               default:
+                       break;
+       }
 
-  return ret;
+       return ret;
 }
 
 /** Generate a string that describes a registry value */
-_PUBLIC_ char *reg_val_description(TALLOC_CTX *mem_ctx, const char *name, 
-                                                                  uint32_t data_type,
-                                                                  const DATA_BLOB data)
+_PUBLIC_ char *reg_val_description(TALLOC_CTX *mem_ctx, const char *name,
+                                  uint32_t data_type,
+                                  const DATA_BLOB data)
 {
-       return talloc_asprintf(mem_ctx, "%s = %s : %s", name?name:"<No Name>", 
-                                                  str_regtype(data_type), 
-                                       reg_val_data_string(mem_ctx, data_type, data));
+       return talloc_asprintf(mem_ctx, "%s = %s : %s", name?name:"<No Name>",
+                              str_regtype(data_type),
+                              reg_val_data_string(mem_ctx, data_type, data));
 }
 
-_PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, const char *data_str, uint32_t *type, DATA_BLOB *data)
+_PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str,
+                               const char *data_str, uint32_t *type,
+                               DATA_BLOB *data)
 {
        int i;
        *type = -1;
@@ -109,16 +108,18 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, const
                }
        }
 
-       if (*type == -1) 
+       if (*type == -1)
                return false;
 
        /* Convert data appropriately */
 
-       switch (*type) 
+       switch (*type)
        {
                case REG_SZ:
                case REG_EXPAND_SZ:
-               data->length = convert_string_talloc(mem_ctx, CH_UNIX, CH_UTF16, data_str, strlen(data_str), (void **)&data->data);
+               data->length = convert_string_talloc(mem_ctx, CH_UNIX, CH_UTF16,
+                                                    data_str, strlen(data_str),
+                                                    (void **)&data->data);
                        break;
 
                case REG_DWORD: {
@@ -130,12 +131,12 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, const
                case REG_NONE:
                        ZERO_STRUCTP(data);
                        break;
-       
-               case REG_BINARY: 
+
+               case REG_BINARY:
                        *data = strhex_to_data_blob(data_str);
                        talloc_steal(mem_ctx, data->data);
                        break;
-                       
+
                default:
                        /* FIXME */
                        return false;
@@ -144,16 +145,17 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx, const char *type_str, const
 }
 
 /** Open a key by name (including the predefined key name!) */
-WERROR reg_open_key_abs(TALLOC_CTX *mem_ctx, struct registry_context *handle, const char *name, struct registry_key **result)
+WERROR reg_open_key_abs(TALLOC_CTX *mem_ctx, struct registry_context *handle,
+                       const char *name, struct registry_key **result)
 {
        struct registry_key *predef;
        WERROR error;
        int predeflength;
        char *predefname;
 
-       if (strchr(name, '\\') != NULL) 
+       if (strchr(name, '\\') != NULL)
                predeflength = strchr(name, '\\')-name;
-       else 
+       else
                predeflength = strlen(name);
 
        predefname = talloc_strndup(mem_ctx, name, predeflength);
@@ -165,31 +167,32 @@ WERROR reg_open_key_abs(TALLOC_CTX *mem_ctx, struct registry_context *handle, co
        }
 
        if (strchr(name, '\\')) {
-               return reg_open_key(mem_ctx, predef, strchr(name, '\\')+1, result);
+               return reg_open_key(mem_ctx, predef, strchr(name, '\\')+1,
+                                   result);
        } else {
                *result = predef;
                return WERR_OK;
        }
 }
 
-static WERROR get_abs_parent(TALLOC_CTX *mem_ctx, struct registry_context *ctx, 
-                                                        const char *path, struct registry_key **parent, 
-                                                        const char **name)
+static WERROR get_abs_parent(TALLOC_CTX *mem_ctx, struct registry_context *ctx,
+                            const char *path, struct registry_key **parent,
+                            const char **name)
 {
        char *parent_name;
        WERROR error;
-       
+
        if (strchr(path, '\\') == NULL) {
                return WERR_FOOBAR;
        }
-       
+
        parent_name = talloc_strndup(mem_ctx, path, strrchr(path, '\\')-path);
 
        error = reg_open_key_abs(mem_ctx, ctx, parent_name, parent);
        if (!W_ERROR_IS_OK(error)) {
                return error;
        }
-       
+
        *name = talloc_strdup(mem_ctx, strrchr(path, '\\')+1);
 
        return WERR_OK;
@@ -201,11 +204,11 @@ WERROR reg_key_del_abs(struct registry_context *ctx, const char *path)
        const char *n;
        TALLOC_CTX *mem_ctx = talloc_init("reg_key_del_abs");
        WERROR error;
-       
+
        if (!strchr(path, '\\')) {
                return WERR_FOOBAR;
        }
-       
+
        error = get_abs_parent(mem_ctx, ctx, path, &parent, &n);
        if (W_ERROR_IS_OK(error)) {
                error = reg_key_del(parent, n);
@@ -216,22 +219,22 @@ WERROR reg_key_del_abs(struct registry_context *ctx, const char *path)
        return error;
 }
 
-WERROR reg_key_add_abs(TALLOC_CTX *mem_ctx, struct registry_context *ctx, 
-                                          const char *path, uint32_t access_mask, 
-                                          struct security_descriptor *sec_desc, 
-                                          struct registry_key **result)
+WERROR reg_key_add_abs(TALLOC_CTX *mem_ctx, struct registry_context *ctx,
+                      const char *path, uint32_t access_mask,
+                      struct security_descriptor *sec_desc,
+                      struct registry_key **result)
 {
        struct registry_key *parent;
        const char *n;
        WERROR error;
-       
+
        if (!strchr(path, '\\')) {
                return WERR_ALREADY_EXISTS;
        }
-       
+
        error = get_abs_parent(mem_ctx, ctx, path, &parent, &n);
        if (!W_ERROR_IS_OK(error)) {
-               DEBUG(2, ("Opening parent of %s failed with %s\n", path, 
+               DEBUG(2, ("Opening parent of %s failed with %s\n", path,
                                  win_errstr(error)));
                return error;
        }
index 2cb0b9955ebeee54a124fae14c2ba7bd477a18d6..77d2ce66e90d40ef4c4d931ae2997b8d4e9679cb 100644 (file)
@@ -1,18 +1,18 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    Registry interface
    Copyright (C) Jelmer Vernooij                                         2007.
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -29,7 +29,7 @@ static WERROR wine_open_reg (struct registry_hive *h, struct registry_key **key)
 static REG_OPS reg_backend_wine = {
        .name = "wine",
        .open_hive = wine_open_reg,
-       
+
 };
 
 NTSTATUS registry_wine_init(void)