Merge branch 'master' of ssh://git.samba.org/data/git/samba
[kai/samba.git] / source4 / libnet / libnet_samdump.c
index 795345461642114003bc2a81188d3ba4876f0025..b35fef2c16c002b584fbd071cc36bbad09eca119 100644 (file)
@@ -7,7 +7,7 @@
    
    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
+   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,
    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.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 
 #include "includes.h"
 #include "libnet/libnet.h"
-#include "lib/util/dlinklist.h"
+#include "../lib/util/dlinklist.h"
 #include "samba3/samba3.h"
 #include "libcli/security/security.h"
 
@@ -76,13 +75,13 @@ static NTSTATUS vampire_samdump_handle_secret(TALLOC_CTX *mem_ctx,
 {
        struct netr_DELTA_SECRET *secret = delta->delta_union.secret;
        const char *name = delta->delta_id_union.name;
-       struct samdump_secret *new = talloc(samdump_state, struct samdump_secret);
+       struct samdump_secret *n = talloc(samdump_state, struct samdump_secret);
 
-       new->name = talloc_strdup(new, name);
-       new->secret = data_blob_talloc(new, secret->current_cipher.cipher_data, secret->current_cipher.maxlen);
-       new->mtime = secret->current_cipher_set_time;
+       n->name = talloc_strdup(n, name);
+       n->secret = data_blob_talloc(n, secret->current_cipher.cipher_data, secret->current_cipher.maxlen);
+       n->mtime = secret->current_cipher_set_time;
 
-       DLIST_ADD(samdump_state->secrets, new);
+       DLIST_ADD(samdump_state->secrets, n);
 
        return NT_STATUS_OK;
 }
@@ -94,24 +93,24 @@ static NTSTATUS vampire_samdump_handle_trusted_domain(TALLOC_CTX *mem_ctx,
        struct netr_DELTA_TRUSTED_DOMAIN *trusted_domain = delta->delta_union.trusted_domain;
        struct dom_sid *dom_sid = delta->delta_id_union.sid;
 
-       struct samdump_trusted_domain *new = talloc(samdump_state, struct samdump_trusted_domain);
+       struct samdump_trusted_domain *n = talloc(samdump_state, struct samdump_trusted_domain);
 
-       new->name = talloc_strdup(new, trusted_domain->domain_name.string);
-       new->sid = talloc_steal(new, dom_sid);
+       n->name = talloc_strdup(n, trusted_domain->domain_name.string);
+       n->sid = talloc_steal(n, dom_sid);
 
-       DLIST_ADD(samdump_state->trusted_domains, new);
+       DLIST_ADD(samdump_state->trusted_domains, n);
 
        return NT_STATUS_OK;
 }
 
-static NTSTATUS libnet_samdump_fn(TALLOC_CTX *mem_ctx,                 
-                                 void *private,                        
+static NTSTATUS libnet_samdump_fn(TALLOC_CTX *mem_ctx,
+                                 void *private_data,
                                  enum netr_SamDatabaseID database,
                                  struct netr_DELTA_ENUM *delta,
                                  char **error_string)
 {
        NTSTATUS nt_status = NT_STATUS_OK;
-       struct samdump_state *samdump_state = private;
+       struct samdump_state *samdump_state = (struct samdump_state *)private_data;
 
        *error_string = NULL;
        switch (delta->delta_type) {
@@ -145,7 +144,8 @@ static NTSTATUS libnet_samdump_fn(TALLOC_CTX *mem_ctx,
        return nt_status;
 }
 
-NTSTATUS libnet_SamDump(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, struct libnet_SamDump *r)
+NTSTATUS libnet_SamDump(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, 
+                       struct libnet_SamDump *r)
 {
        NTSTATUS nt_status;
        struct libnet_SamSync r2;
@@ -163,7 +163,7 @@ NTSTATUS libnet_SamDump(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, struct
 
        r2.out.error_string            = NULL;
        r2.in.binding_string           = r->in.binding_string;
-       r2.in.rid_crypt                = lp_parm_bool(-1, "vampire", "rid decrypt", True);
+       r2.in.rid_crypt                = lp_parm_bool(ctx->lp_ctx, NULL, "vampire", "rid decrypt", true);
        r2.in.init_fn                  = NULL;
        r2.in.delta_fn                 = libnet_samdump_fn;
        r2.in.fn_ctx                   = samdump_state;
@@ -185,7 +185,7 @@ NTSTATUS libnet_SamDump(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, struct
                        if (strcasecmp_m(s->name, secret_name) != 0) {
                                continue;
                        }
-                       if (convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, 
+                       if (convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF16, CH_UNIX, 
                                                  s->secret.data, s->secret.length, 
                                                  (void **)&secret_string) == -1) {
                                r->out.error_string = talloc_asprintf(mem_ctx,