The Samba-Bugzilla – Attachment 3535 Details for
Bug 5739
Cosmetic corrections
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
DSDB cosmetic patch
dsdbCosmetic.patch (text/plain), 51.76 KB, created by
Matthias Dieter Wallnöfer
on 2008-09-07 15:55:43 UTC
(
hide
)
Description:
DSDB cosmetic patch
Filename:
MIME Type:
Creator:
Matthias Dieter Wallnöfer
Created:
2008-09-07 15:55:43 UTC
Size:
51.76 KB
patch
obsolete
>diff --git a/source/auth/gensec/cyrus_sasl.c b/source/auth/gensec/cyrus_sasl.c >index 06a7b8a..6f82de8 100644 >--- a/source/auth/gensec/cyrus_sasl.c >+++ b/source/auth/gensec/cyrus_sasl.c >@@ -110,7 +110,7 @@ static int gensec_sasl_get_password(sasl_conn_t *conn, void *context, int id, > static int gensec_sasl_dispose(struct gensec_sasl_state *gensec_sasl_state) > { > sasl_dispose(&gensec_sasl_state->conn); >- return 0; >+ return SASL_OK; > } > > static NTSTATUS gensec_sasl_client_start(struct gensec_security *gensec_security) >diff --git a/source/auth/kerberos/kerberos.c b/source/auth/kerberos/kerberos.c >index 2579ab2..d54664f 100644 >--- a/source/auth/kerberos/kerberos.c >+++ b/source/auth/kerberos/kerberos.c >@@ -33,7 +33,7 @@ > This version is built to use a keyblock, rather than needing the > original password. > */ >- int kerberos_kinit_keyblock_cc(krb5_context ctx, krb5_ccache cc, >+ krb5_error_code kerberos_kinit_keyblock_cc(krb5_context ctx, krb5_ccache cc, > krb5_principal principal, krb5_keyblock *keyblock, > time_t *expire_time, time_t *kdc_time) > { >@@ -77,7 +77,7 @@ > simulate a kinit, putting the tgt in the given credentials cache. > Orignally by remus@snapserver.com > */ >- int kerberos_kinit_password_cc(krb5_context ctx, krb5_ccache cc, >+ krb5_error_code kerberos_kinit_password_cc(krb5_context ctx, krb5_ccache cc, > krb5_principal principal, const char *password, > time_t *expire_time, time_t *kdc_time) > { >diff --git a/source/auth/kerberos/kerberos_util.c b/source/auth/kerberos/kerberos_util.c >index 9002715..0567565 100644 >--- a/source/auth/kerberos/kerberos_util.c >+++ b/source/auth/kerberos/kerberos_util.c >@@ -32,7 +32,7 @@ struct principal_container { > krb5_principal principal; > }; > >-static int free_principal(struct principal_container *pc) >+static krb5_error_code free_principal(struct principal_container *pc) > { > /* current heimdal - 0.6.3, which we need anyway, fixes segfaults here */ > krb5_free_principal(pc->smb_krb5_context->krb5_context, pc->principal); >@@ -241,19 +241,17 @@ static krb5_error_code salt_principal_from_credentials(TALLOC_CTX *parent_ctx, > return 0; > } > >-static int free_keytab(struct keytab_container *ktc) >+static krb5_error_code free_keytab(struct keytab_container *ktc) > { >- krb5_kt_close(ktc->smb_krb5_context->krb5_context, ktc->keytab); >- >- return 0; >+ return krb5_kt_close(ktc->smb_krb5_context->krb5_context, ktc->keytab); > } > >-int smb_krb5_open_keytab(TALLOC_CTX *mem_ctx, >+krb5_error_code smb_krb5_open_keytab(TALLOC_CTX *mem_ctx, > struct smb_krb5_context *smb_krb5_context, > const char *keytab_name, struct keytab_container **ktc) > { > krb5_keytab keytab; >- int ret; >+ krb5_error_code ret; > ret = krb5_kt_resolve(smb_krb5_context->krb5_context, keytab_name, &keytab); > if (ret) { > DEBUG(1,("failed to open krb5 keytab: %s\n", >@@ -339,7 +337,7 @@ static krb5_error_code keytab_add_keys(TALLOC_CTX *parent_ctx, > return 0; > } > >-static int create_keytab(TALLOC_CTX *parent_ctx, >+static krb5_error_code create_keytab(TALLOC_CTX *parent_ctx, > struct cli_credentials *machine_account, > struct smb_krb5_context *smb_krb5_context, > const char **enctype_strings, >@@ -603,7 +601,7 @@ static krb5_error_code remove_old_entries(TALLOC_CTX *parent_ctx, > return ret; > } > >-int smb_krb5_update_keytab(TALLOC_CTX *parent_ctx, >+krb5_error_code smb_krb5_update_keytab(TALLOC_CTX *parent_ctx, > struct cli_credentials *machine_account, > struct smb_krb5_context *smb_krb5_context, > const char **enctype_strings, >@@ -635,7 +633,7 @@ int smb_krb5_update_keytab(TALLOC_CTX *parent_ctx, > return ret; > } > >-int smb_krb5_create_memory_keytab(TALLOC_CTX *parent_ctx, >+krb5_error_code smb_krb5_create_memory_keytab(TALLOC_CTX *parent_ctx, > struct cli_credentials *machine_account, > struct smb_krb5_context *smb_krb5_context, > const char **enctype_strings, >diff --git a/source/auth/kerberos/krb5_init_context.c b/source/auth/kerberos/krb5_init_context.c >index 82e42a4..90b542c 100644 >--- a/source/auth/kerberos/krb5_init_context.c >+++ b/source/auth/kerberos/krb5_init_context.c >@@ -49,13 +49,13 @@ struct smb_krb5_socket { > krb5_krbhst_info *hi; > }; > >-static int smb_krb5_context_destroy_1(struct smb_krb5_context *ctx) >+static krb5_error_code smb_krb5_context_destroy_1(struct smb_krb5_context *ctx) > { > krb5_free_context(ctx->krb5_context); > return 0; > } > >-static int smb_krb5_context_destroy_2(struct smb_krb5_context *ctx) >+static krb5_error_code smb_krb5_context_destroy_2(struct smb_krb5_context *ctx) > { > /* Otherwise krb5_free_context will try and close what we have already free()ed */ > krb5_set_warn_dest(ctx->krb5_context, NULL); >diff --git a/source/dsdb/samdb/ldb_modules/kludge_acl.c b/source/dsdb/samdb/ldb_modules/kludge_acl.c >index 2c01594..3305487 100644 >--- a/source/dsdb/samdb/ldb_modules/kludge_acl.c >+++ b/source/dsdb/samdb/ldb_modules/kludge_acl.c >@@ -142,7 +142,7 @@ static int kludge_acl_allowedAttributes(struct ldb_context *ldb, struct ldb_mess > ldb_msg_add_string(msg, attrName, attr_list[i]); > } > talloc_free(mem_ctx); >- return 0; >+ return LDB_SUCCESS; > > } > /* read all objectClasses */ >@@ -201,7 +201,7 @@ static int kludge_acl_childClasses(struct ldb_context *ldb, struct ldb_message * > } > } > >- return 0; >+ return LDB_SUCCESS; > > } > >diff --git a/source/dsdb/samdb/ldb_modules/proxy.c b/source/dsdb/samdb/ldb_modules/proxy.c >index 0d06542..277305e 100644 >--- a/source/dsdb/samdb/ldb_modules/proxy.c >+++ b/source/dsdb/samdb/ldb_modules/proxy.c >@@ -66,7 +66,7 @@ static int load_proxy_info(struct ldb_module *module) > > /* see if we have already loaded it */ > if (proxy->upstream != NULL) { >- return 0; >+ return LDB_SUCCESS; > } > > dn = ldb_dn_new(proxy, module->ldb, "@PROXYINFO"); >@@ -145,7 +145,7 @@ static int load_proxy_info(struct ldb_module *module) > > talloc_free(res); > >- return 0; >+ return LDB_SUCCESS; > > failed: > talloc_free(res); >@@ -153,7 +153,7 @@ failed: > talloc_free(proxy->newdn); > talloc_free(proxy->upstream); > proxy->upstream = NULL; >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > >@@ -259,7 +259,7 @@ static int proxy_search_bytree(struct ldb_module *module, struct ldb_request *re > } > > if (load_proxy_info(module) != 0) { >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > /* see if the dn is within olddn */ >@@ -269,7 +269,7 @@ static int proxy_search_bytree(struct ldb_module *module, struct ldb_request *re > > newreq = talloc(module, struct ldb_request); > if (newreq == NULL) { >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > newreq->op.search.tree = proxy_convert_tree(module, req->op.search.tree); >@@ -298,7 +298,7 @@ static int proxy_search_bytree(struct ldb_module *module, struct ldb_request *re > if (ret != LDB_SUCCESS) { > ldb_set_errstring(module->ldb, ldb_errstring(proxy->upstream)); > talloc_free(newreq); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > for (i = 0; i < newreq->op.search.res->count; i++) { >diff --git a/source/dsdb/samdb/ldb_modules/repl_meta_data.c b/source/dsdb/samdb/ldb_modules/repl_meta_data.c >index dd5faf8..34e235a 100644 >--- a/source/dsdb/samdb/ldb_modules/repl_meta_data.c >+++ b/source/dsdb/samdb/ldb_modules/repl_meta_data.c >@@ -124,16 +124,16 @@ static int add_time_element(struct ldb_message *msg, const char *attr, time_t t) > char *s; > > if (ldb_msg_find_element(msg, attr) != NULL) { >- return 0; >+ return LDB_SUCCESS; > } > > s = ldb_timestring(msg, t); > if (s == NULL) { >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > if (ldb_msg_add_string(msg, attr, s) != 0) { >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > el = ldb_msg_find_element(msg, attr); >@@ -141,7 +141,7 @@ static int add_time_element(struct ldb_message *msg, const char *attr, time_t t) > is ignored */ > el->flags = LDB_FLAG_MOD_REPLACE; > >- return 0; >+ return LDB_SUCCESS; > } > > /* >@@ -152,11 +152,11 @@ static int add_uint64_element(struct ldb_message *msg, const char *attr, uint64_ > struct ldb_message_element *el; > > if (ldb_msg_find_element(msg, attr) != NULL) { >- return 0; >+ return LDB_SUCCESS; > } > > if (ldb_msg_add_fmt(msg, attr, "%llu", (unsigned long long)v) != 0) { >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > el = ldb_msg_find_element(msg, attr); >@@ -164,7 +164,7 @@ static int add_uint64_element(struct ldb_message *msg, const char *attr, uint64_ > is ignored */ > el->flags = LDB_FLAG_MOD_REPLACE; > >- return 0; >+ return LDB_SUCCESS; > } > > static int replmd_replPropertyMetaData1_attid_sort(const struct replPropertyMetaData1 *m1, >diff --git a/source/dsdb/samdb/ldb_modules/schema_fsmo.c b/source/dsdb/samdb/ldb_modules/schema_fsmo.c >index 968b19c..7c6a6dd 100644 >--- a/source/dsdb/samdb/ldb_modules/schema_fsmo.c >+++ b/source/dsdb/samdb/ldb_modules/schema_fsmo.c >@@ -307,7 +307,7 @@ static int generate_dITContentRules(struct ldb_context *ldb, struct ldb_message > } > } > } >- return 0; >+ return LDB_SUCCESS; > } > > >diff --git a/source/kdc/hdb-ldb.c b/source/kdc/hdb-ldb.c >index ef3a0bc..30fd284 100644 >--- a/source/kdc/hdb-ldb.c >+++ b/source/kdc/hdb-ldb.c >@@ -186,7 +186,7 @@ static HDBFlags uf2HDBFlags(krb5_context context, int userAccountControl, enum h > return flags; > } > >-static int hdb_ldb_destrutor(struct hdb_ldb_private *private) >+static int hdb_ldb_destructor(struct hdb_ldb_private *private) > { > hdb_entry_ex *entry_ex = private->entry_ex; > free_hdb_entry(&entry_ex->entry); >@@ -542,7 +542,7 @@ static krb5_error_code LDB_message2entry(krb5_context context, HDB *db, > private->iconv_convenience = lp_iconv_convenience(lp_ctx); > private->netbios_name = lp_netbios_name(lp_ctx); > >- talloc_set_destructor(private, hdb_ldb_destrutor); >+ talloc_set_destructor(private, hdb_ldb_destructor); > > entry_ex->ctx = private; > entry_ex->free_entry = hdb_ldb_free_entry; >@@ -728,7 +728,7 @@ static krb5_error_code LDB_trust_message2entry(krb5_context context, HDB *db, > private->iconv_convenience = lp_iconv_convenience(lp_ctx); > private->netbios_name = lp_netbios_name(lp_ctx); > >- talloc_set_destructor(private, hdb_ldb_destrutor); >+ talloc_set_destructor(private, hdb_ldb_destructor); > > entry_ex->ctx = private; > entry_ex->free_entry = hdb_ldb_free_entry; >diff --git a/source/lib/charset/iconv.c b/source/lib/charset/iconv.c >index d4f930b..7a07a86 100644 >--- a/source/lib/charset/iconv.c >+++ b/source/lib/charset/iconv.c >@@ -469,9 +469,6 @@ static size_t iconv_copy(void *cd, const char **inbuf, size_t *inbytesleft, > return 0; > } > >-/* >- this takes a UTF8 sequence and produces a UTF16 sequence >- */ > static size_t utf8_pull(void *cd, const char **inbuf, size_t *inbytesleft, > char **outbuf, size_t *outbytesleft) > { >@@ -589,10 +586,6 @@ error: > return -1; > } > >- >-/* >- this takes a UTF16 sequence and produces a UTF8 sequence >- */ > static size_t utf8_push(void *cd, const char **inbuf, size_t *inbytesleft, > char **outbuf, size_t *outbytesleft) > { >@@ -600,6 +593,14 @@ static size_t utf8_push(void *cd, const char **inbuf, size_t *inbytesleft, > uint8_t *c = (uint8_t *)*outbuf; > const uint8_t *uc = (const uint8_t *)*inbuf; > >+ /* Special case: Windows (e.g. "regedit") also expects an empty buffer >+ with length 1 as a valid empty UTF8 string */ >+ if (in_left == 1 && uc[0] == 0 && out_left >= 1) { >+ c[0] = uc[0]; >+ in_left -= 1; >+ out_left -= 1; >+ } >+ > while (in_left >= 2 && out_left >= 1) { > unsigned int codepoint; > >diff --git a/source/lib/ldb-samba/ldif_handlers.c b/source/lib/ldb-samba/ldif_handlers.c >index a16582d..46ea095 100644 >--- a/source/lib/ldb-samba/ldif_handlers.c >+++ b/source/lib/ldb-samba/ldif_handlers.c >@@ -134,7 +134,7 @@ static int ldb_canonicalise_objectSid(struct ldb_context *ldb, void *mem_ctx, > /* Perhaps not a string after all */ > return ldb_handler_copy(ldb, mem_ctx, in, out); > } >- return 0; >+ return LDB_SUCCESS; > } > return ldb_handler_copy(ldb, mem_ctx, in, out); > } >diff --git a/source/lib/ldb/common/attrib_handlers.c b/source/lib/ldb/common/attrib_handlers.c >index fb57e2d..6f1b081 100644 >--- a/source/lib/ldb/common/attrib_handlers.c >+++ b/source/lib/ldb/common/attrib_handlers.c >@@ -38,9 +38,9 @@ int ldb_handler_copy(struct ldb_context *ldb, void *mem_ctx, > *out = ldb_val_dup(mem_ctx, in); > if (in->length > 0 && out->data == NULL) { > ldb_oom(ldb); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } >- return 0; >+ return LDB_SUCCESS; > } > > /* >@@ -57,13 +57,13 @@ int ldb_handler_fold(struct ldb_context *ldb, void *mem_ctx, > int l; > > if (!in || !out || !(in->data)) { >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > out->data = (uint8_t *)ldb_casefold(ldb, mem_ctx, (const char *)(in->data), in->length); > if (out->data == NULL) { > ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_handler_fold: unable to casefold string [%s]", in->data); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > s = (char *)(out->data); >@@ -96,7 +96,7 @@ int ldb_handler_fold(struct ldb_context *ldb, void *mem_ctx, > } > > out->length = strlen((char *)out->data); >- return 0; >+ return LDB_SUCCESS; > } > > >@@ -111,14 +111,14 @@ int ldb_canonicalise_Integer(struct ldb_context *ldb, void *mem_ctx, > char *end; > long long i = strtoll((char *)in->data, &end, 0); > if (*end != 0) { >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > out->data = (uint8_t *)talloc_asprintf(mem_ctx, "%lld", i); > if (out->data == NULL) { >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > out->length = strlen((char *)out->data); >- return 0; >+ return LDB_SUCCESS; > } > > /* >@@ -251,7 +251,7 @@ int ldb_canonicalise_dn(struct ldb_context *ldb, void *mem_ctx, > } > out->length = strlen((char *)out->data); > >- ret = 0; >+ ret = LDB_SUCCESS; > > done: > talloc_free(dn); >@@ -305,10 +305,10 @@ int ldb_canonicalise_utctime(struct ldb_context *ldb, void *mem_ctx, > time_t t = ldb_string_to_time((char *)in->data); > out->data = (uint8_t *)ldb_timestring(mem_ctx, t); > if (out->data == NULL) { >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > out->length = strlen((char *)out->data); >- return 0; >+ return LDB_SUCCESS; > } > > /* >diff --git a/source/lib/ldb/common/ldb_attributes.c b/source/lib/ldb/common/ldb_attributes.c >index 747f241..0fbb5e2 100644 >--- a/source/lib/ldb/common/ldb_attributes.c >+++ b/source/lib/ldb/common/ldb_attributes.c >@@ -61,7 +61,7 @@ int ldb_schema_attribute_add_with_syntax(struct ldb_context *ldb, > struct ldb_schema_attribute, n); > if (a == NULL) { > ldb_oom(ldb); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > ldb->schema.attributes = a; > >@@ -70,7 +70,7 @@ int ldb_schema_attribute_add_with_syntax(struct ldb_context *ldb, > if (cmp == 0) { > /* silently ignore attempts to overwrite fixed attributes */ > if (a[i].flags & LDB_ATTR_FLAG_FIXED) { >- return 0; >+ return LDB_SUCCESS; > } > if (a[i].flags & LDB_ATTR_FLAG_ALLOCATED) { > talloc_free(discard_const_p(char, a[i].name)); >@@ -93,11 +93,11 @@ int ldb_schema_attribute_add_with_syntax(struct ldb_context *ldb, > a[i].name = talloc_strdup(a, a[i].name); > if (a[i].name == NULL) { > ldb_oom(ldb); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > } > >- return 0; >+ return LDB_SUCCESS; > } > > static const struct ldb_schema_syntax ldb_syntax_default = { >diff --git a/source/lib/ldb/common/ldb_debug.c b/source/lib/ldb/common/ldb_debug.c >index 0f78e37..8e1c491 100644 >--- a/source/lib/ldb/common/ldb_debug.c >+++ b/source/lib/ldb/common/ldb_debug.c >@@ -43,7 +43,7 @@ int ldb_set_debug(struct ldb_context *ldb, > { > ldb->debug_ops.debug = debug; > ldb->debug_ops.context = context; >- return 0; >+ return LDB_SUCCESS; > } > > /* >diff --git a/source/lib/ldb/common/ldb_ldif.c b/source/lib/ldb/common/ldb_ldif.c >index fb93e17..6cbd30f 100644 >--- a/source/lib/ldb/common/ldb_ldif.c >+++ b/source/lib/ldb/common/ldb_ldif.c >@@ -191,19 +191,19 @@ int ldb_should_b64_encode(const struct ldb_val *val) > uint8_t *p = val->data; > > if (val->length == 0) { >- return 0; >+ return LDB_SUCCESS; > } > > if (p[0] == ' ' || p[0] == ':') { >- return 1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > for (i=0; i<val->length; i++) { > if (!isprint(p[i]) || p[i] == '\n') { >- return 1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > } >- return 0; >+ return LDB_SUCCESS; > } > > /* this macro is used to handle the return checking on fprintf_fn() */ >@@ -444,12 +444,12 @@ static int next_attr(void *mem_ctx, char **s, const char **attr, struct ldb_val > value->length = 0; > *attr = "-"; > *s += 2; >- return 0; >+ return LDB_SUCCESS; > } > > p = strchr(*s, ':'); > if (!p) { >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > *p++ = 0; >@@ -487,7 +487,7 @@ static int next_attr(void *mem_ctx, char **s, const char **attr, struct ldb_val > int len = ldb_base64_decode((char *)value->data); > if (len == -1) { > /* it wasn't valid base64 data */ >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > value->length = len; > } >@@ -496,11 +496,11 @@ static int next_attr(void *mem_ctx, char **s, const char **attr, struct ldb_val > int len = ldb_read_data_file(mem_ctx, value); > if (len == -1) { > /* an error occured hile trying to retrieve the file */ >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > } > >- return 0; >+ return LDB_SUCCESS; > } > > >diff --git a/source/lib/ldb/common/ldb_modules.c b/source/lib/ldb/common/ldb_modules.c >index 4d69dc6..96c97ab 100644 >--- a/source/lib/ldb/common/ldb_modules.c >+++ b/source/lib/ldb/common/ldb_modules.c >@@ -279,16 +279,16 @@ int ldb_register_module(const struct ldb_module_ops *ops) > struct ops_list_entry *entry = talloc(talloc_autofree_context(), struct ops_list_entry); > > if (ldb_find_module_ops(ops->name) != NULL) >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > > if (entry == NULL) >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > > entry->ops = ops; > entry->next = registered_modules; > registered_modules = entry; > >- return 0; >+ return LDB_SUCCESS; > } > > void *ldb_dso_load_symbol(struct ldb_context *ldb, const char *name, >diff --git a/source/lib/ldb/ldb_ildap/ldb_ildap.c b/source/lib/ldb/ldb_ildap/ldb_ildap.c >index 5ad671e..3a5da89 100644 >--- a/source/lib/ldb/ldb_ildap/ldb_ildap.c >+++ b/source/lib/ldb/ldb_ildap/ldb_ildap.c >@@ -753,7 +753,7 @@ static int ildb_connect(struct ldb_context *ldb, const char *url, > module = talloc(ldb, struct ldb_module); > if (!module) { > ldb_oom(ldb); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > talloc_set_name_const(module, "ldb_ildap backend"); > module->ldb = ldb; >@@ -819,11 +819,11 @@ static int ildb_connect(struct ldb_context *ldb, const char *url, > } > > *_module = module; >- return 0; >+ return LDB_SUCCESS; > > failed: > talloc_free(module); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > _PUBLIC_ const struct ldb_backend_ops ldb_ldap_backend_ops = { >diff --git a/source/lib/ldb/ldb_ldap/ldb_ldap.c b/source/lib/ldb/ldb_ldap/ldb_ldap.c >index a4534c5..5026f9c 100644 >--- a/source/lib/ldb/ldb_ldap/ldb_ldap.c >+++ b/source/lib/ldb/ldb_ldap/ldb_ldap.c >@@ -180,14 +180,14 @@ static int lldb_add_msg_attr(struct ldb_context *ldb, > count = ldap_count_values_len(bval); > > if (count <= 0) { >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > el = talloc_realloc(msg, msg->elements, struct ldb_message_element, > msg->num_elements + 1); > if (!el) { > errno = ENOMEM; >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > msg->elements = el; >@@ -197,7 +197,7 @@ static int lldb_add_msg_attr(struct ldb_context *ldb, > el->name = talloc_strdup(msg->elements, attr); > if (!el->name) { > errno = ENOMEM; >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > el->flags = 0; > >@@ -205,7 +205,7 @@ static int lldb_add_msg_attr(struct ldb_context *ldb, > el->values = talloc_array(msg->elements, struct ldb_val, count); > if (!el->values) { > errno = ENOMEM; >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > for (i=0;i<count;i++) { >@@ -214,7 +214,7 @@ static int lldb_add_msg_attr(struct ldb_context *ldb, > el->values[i].data = talloc_size(el->values, bval[i]->bv_len+1); > if (!el->values[i].data) { > errno = ENOMEM; >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > memcpy(el->values[i].data, bval[i]->bv_val, bval[i]->bv_len); > el->values[i].data[bval[i]->bv_len] = 0; >@@ -224,7 +224,7 @@ static int lldb_add_msg_attr(struct ldb_context *ldb, > > msg->num_elements++; > >- return 0; >+ return LDB_SUCCESS; > } > > /* >@@ -785,7 +785,7 @@ static int lldb_connect(struct ldb_context *ldb, > if (module == NULL) { > ldb_oom(ldb); > talloc_free(lldb); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > talloc_set_name_const(module, "ldb_ldap backend"); > module->ldb = ldb; >@@ -819,11 +819,11 @@ static int lldb_connect(struct ldb_context *ldb, > } > > *_module = module; >- return 0; >+ return LDB_SUCCESS; > > failed: > talloc_free(module); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > const struct ldb_backend_ops ldb_ldap_backend_ops = { >diff --git a/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c >index a0e63c8..7e4fe1d 100644 >--- a/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c >+++ b/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c >@@ -670,10 +670,10 @@ static int lsqlite3_safe_rollback(sqlite3 *sqlite) > printf("lsqlite3_safe_rollback: Error: %s\n", errmsg); > free(errmsg); > } >- return -1; >+ return SQLITE_ERROR; > } > >- return 0; >+ return SQLITE_OK; > } > > /* return an eid as result */ >@@ -1440,13 +1440,13 @@ static int lsql_start_trans(struct ldb_module * module) > printf("lsqlite3_start_trans: error: %s\n", errmsg); > free(errmsg); > } >- return -1; >+ return SQLITE_ERROR; > } > }; > > lsqlite3->trans_count++; > >- return 0; >+ return SQLITE_OK; > } > > static int lsql_end_trans(struct ldb_module *module) >@@ -1457,7 +1457,7 @@ static int lsql_end_trans(struct ldb_module *module) > > if (lsqlite3->trans_count > 0) { > lsqlite3->trans_count--; >- } else return -1; >+ } else return SQLITE_ERROR; > > if (lsqlite3->trans_count == 0) { > ret = sqlite3_exec(lsqlite3->sqlite, "COMMIT;", NULL, NULL, &errmsg); >@@ -1466,11 +1466,11 @@ static int lsql_end_trans(struct ldb_module *module) > printf("lsqlite3_end_trans: error: %s\n", errmsg); > free(errmsg); > } >- return -1; >+ return SQLITE_ERROR; > } > } > >- return 0; >+ return SQLITE_OK; > } > > static int lsql_del_trans(struct ldb_module *module) >@@ -1479,13 +1479,13 @@ static int lsql_del_trans(struct ldb_module *module) > > if (lsqlite3->trans_count > 0) { > lsqlite3->trans_count--; >- } else return -1; >+ } else return SQLITE_ERROR; > > if (lsqlite3->trans_count == 0) { > return lsqlite3_safe_rollback(lsqlite3->sqlite); > } > >- return -1; >+ return SQLITE_ERROR; > } > > static int destructor(struct lsqlite3_private *lsqlite3) >@@ -1493,7 +1493,7 @@ static int destructor(struct lsqlite3_private *lsqlite3) > if (lsqlite3->sqlite) { > sqlite3_close(lsqlite3->sqlite); > } >- return 0; >+ return SQLITE_OK; > } > > static int lsql_request(struct ldb_module *module, struct ldb_request *req) >@@ -1540,7 +1540,7 @@ static int initialize(struct lsqlite3_private *lsqlite3, > /* create a local ctx */ > local_ctx = talloc_named(lsqlite3, 0, "lsqlite3_rename local context"); > if (local_ctx == NULL) { >- return -1; >+ return SQLITE_ERROR; > } > > schema = lsqlite3_tprintf(local_ctx, >@@ -1792,7 +1792,7 @@ static int initialize(struct lsqlite3_private *lsqlite3, > failed: > if (rollback) lsqlite3_safe_rollback(lsqlite3->sqlite); > sqlite3_close(lsqlite3->sqlite); >- return -1; >+ return SQLITE_ERROR; > } > > /* >@@ -1860,14 +1860,14 @@ static int lsqlite3_connect(struct ldb_context *ldb, > } > } > >- return 0; >+ return LDB_SUCCESS; > > failed: > if (lsqlite3->sqlite != NULL) { > (void) sqlite3_close(lsqlite3->sqlite); > } > talloc_free(lsqlite3); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > const struct ldb_backend_ops ldb_sqlite3_backend_ops = { >diff --git a/source/lib/ldb/ldb_tdb/ldb_cache.c b/source/lib/ldb/ldb_tdb/ldb_cache.c >index 2576e2c..e502f1e 100644 >--- a/source/lib/ldb/ldb_tdb/ldb_cache.c >+++ b/source/lib/ldb/ldb_tdb/ldb_cache.c >@@ -92,11 +92,11 @@ static int ltdb_attributes_flags(struct ldb_message_element *el, unsigned *v) > } > } > if (ltdb_valid_attr_flags[j].name == NULL) { >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > } > *v = value; >- return 0; >+ return LDB_SUCCESS; > } > > /* >@@ -118,7 +118,7 @@ static int ltdb_attributes_load(struct ldb_module *module) > goto failed; > } > if (r == LDB_ERR_NO_SUCH_OBJECT) { >- return 0; >+ return LDB_SUCCESS; > } > /* mapping these flags onto ldap 'syntaxes' isn't strictly correct, > but its close enough for now */ >@@ -162,9 +162,9 @@ static int ltdb_attributes_load(struct ldb_module *module) > } > } > >- return 0; >+ return LDB_SUCCESS; > failed: >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > >@@ -258,7 +258,7 @@ int ltdb_cache_load(struct ldb_module *module) > /* a very fast check to avoid extra database reads */ > if (ltdb->cache != NULL && > tdb_get_seqnum(ltdb->tdb) == ltdb->tdb_seqnum) { >- return 0; >+ return LDB_SUCCESS; > } > > if (ltdb->cache == NULL) { >@@ -344,7 +344,7 @@ int ltdb_cache_load(struct ldb_module *module) > goto failed; > } > >- if (ltdb_attributes_load(module) == -1) { >+ if (ltdb_attributes_load(module) != LDB_SUCCESS) { > goto failed; > } > >@@ -353,14 +353,14 @@ done: > talloc_free(baseinfo); > talloc_free(baseinfo_dn); > talloc_free(indexlist_dn); >- return 0; >+ return LDB_SUCCESS; > > failed: > talloc_free(options); > talloc_free(baseinfo); > talloc_free(baseinfo_dn); > talloc_free(indexlist_dn); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > >@@ -449,10 +449,10 @@ int ltdb_check_at_attributes_values(const struct ldb_val *value) > > for (i = 0; ltdb_valid_attr_flags[i].name != NULL; i++) { > if ((strcmp(ltdb_valid_attr_flags[i].name, (char *)value->data) == 0)) { >- return 0; >+ return LDB_SUCCESS; > } > } > >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > >diff --git a/source/lib/ldb/ldb_tdb/ldb_index.c b/source/lib/ldb/ldb_tdb/ldb_index.c >index 269305a..5977340 100644 >--- a/source/lib/ldb/ldb_tdb/ldb_index.c >+++ b/source/lib/ldb/ldb_tdb/ldb_index.c >@@ -721,7 +721,7 @@ static int ltdb_index_filter(const struct dn_list *dn_list, > /* filter the attributes that the user wants */ > ret = ltdb_filter_attrs(ares->message, ac->attrs); > >- if (ret == -1) { >+ if (ret) { > handle->status = LDB_ERR_OPERATIONS_ERROR; > handle->state = LDB_ASYNC_DONE; > talloc_free(ares); >diff --git a/source/lib/ldb/ldb_tdb/ldb_pack.c b/source/lib/ldb/ldb_tdb/ldb_pack.c >index afb07dc..d96e759 100644 >--- a/source/lib/ldb/ldb_tdb/ldb_pack.c >+++ b/source/lib/ldb/ldb_tdb/ldb_pack.c >@@ -89,7 +89,7 @@ int ltdb_pack_data(struct ldb_module *module, > dn = ldb_dn_get_linearized(message->dn); > if (dn == NULL) { > errno = ENOMEM; >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > /* work out how big it needs to be */ >@@ -114,7 +114,7 @@ int ltdb_pack_data(struct ldb_module *module, > data->dptr = talloc_array(ldb, uint8_t, size); > if (!data->dptr) { > errno = ENOMEM; >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > data->dsize = size; > >@@ -147,7 +147,7 @@ int ltdb_pack_data(struct ldb_module *module, > } > } > >- return 0; >+ return LDB_SUCCESS; > } > > /* >@@ -207,7 +207,7 @@ int ltdb_unpack_data(struct ldb_module *module, > > if (message->num_elements == 0) { > message->elements = NULL; >- return 0; >+ return LDB_SUCCESS; > } > > if (message->num_elements > remaining / 6) { >@@ -281,9 +281,9 @@ int ltdb_unpack_data(struct ldb_module *module, > "Error: %d bytes unread in ltdb_unpack_data\n", remaining); > } > >- return 0; >+ return LDB_SUCCESS; > > failed: > talloc_free(message->elements); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } >diff --git a/source/lib/ldb/ldb_tdb/ldb_search.c b/source/lib/ldb/ldb_tdb/ldb_search.c >index da899c3..ce7a90e 100644 >--- a/source/lib/ldb/ldb_tdb/ldb_search.c >+++ b/source/lib/ldb/ldb_tdb/ldb_search.c >@@ -262,7 +262,7 @@ int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_mes > > ret = ltdb_unpack_data(module, &tdb_data, msg); > free(tdb_data.dptr); >- if (ret == -1) { >+ if (ret != LDB_SUCCESS) { > return LDB_ERR_OPERATIONS_ERROR; > } > >@@ -285,7 +285,7 @@ static int ltdb_lock_read(struct ldb_module *module) > if (ltdb->in_transaction == 0) { > return tdb_lockall_read(ltdb->tdb); > } >- return 0; >+ return LDB_SUCCESS; > } > > /* >@@ -297,7 +297,7 @@ static int ltdb_unlock_read(struct ldb_module *module) > if (ltdb->in_transaction == 0) { > return tdb_unlockall_read(ltdb->tdb); > } >- return 0; >+ return LDB_SUCCESS; > } > > /* >@@ -317,14 +317,14 @@ int ltdb_add_attr_results(struct ldb_module *module, > /* pull the attributes that the user wants */ > msg2 = ltdb_pull_attrs(module, mem_ctx, msg, attrs); > if (!msg2) { >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > /* add to the results list */ > res2 = talloc_realloc(mem_ctx, *res, struct ldb_message *, (*count)+2); > if (!res2) { > talloc_free(msg2); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > (*res) = res2; >@@ -333,7 +333,7 @@ int ltdb_add_attr_results(struct ldb_module *module, > (*res)[(*count)+1] = NULL; > (*count)++; > >- return 0; >+ return LDB_SUCCESS; > } > > >@@ -356,7 +356,7 @@ int ltdb_filter_attrs(struct ldb_message *msg, const char * const *attrs) > > if (ldb_attr_cmp(attrs[i], "distinguishedName") == 0) { > if (msg_add_distinguished_name(msg) != 0) { >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > } > } >@@ -366,9 +366,9 @@ int ltdb_filter_attrs(struct ldb_message *msg, const char * const *attrs) > > if (keep_all) { > if (msg_add_distinguished_name(msg) != 0) { >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } >- return 0; >+ return LDB_SUCCESS; > } > > for (i = 0; i < msg->num_elements; i++) { >@@ -387,7 +387,7 @@ int ltdb_filter_attrs(struct ldb_message *msg, const char * const *attrs) > } > } > >- return 0; >+ return LDB_SUCCESS; > } > > /* >@@ -402,14 +402,14 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi > > if (key.dsize < 4 || > strncmp((char *)key.dptr, "DN=", 3) != 0) { >- return 0; >+ return LDB_SUCCESS; > } > > ares = talloc_zero(ac, struct ldb_reply); > if (!ares) { > handle->status = LDB_ERR_OPERATIONS_ERROR; > handle->state = LDB_ASYNC_DONE; >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > ares->message = ldb_msg_new(ares); >@@ -417,14 +417,14 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi > handle->status = LDB_ERR_OPERATIONS_ERROR; > handle->state = LDB_ASYNC_DONE; > talloc_free(ares); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > /* unpack the record */ > ret = ltdb_unpack_data(ac->module, &data, ares->message); >- if (ret == -1) { >+ if (ret) { > talloc_free(ares); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > if (!ares->message->dn) { >@@ -433,7 +433,7 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi > handle->status = LDB_ERR_OPERATIONS_ERROR; > handle->state = LDB_ASYNC_DONE; > talloc_free(ares); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > } > >@@ -441,17 +441,17 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi > if (!ldb_match_msg(ac->module->ldb, ares->message, ac->tree, > ac->base, ac->scope)) { > talloc_free(ares); >- return 0; >+ return LDB_SUCCESS; > } > > /* filter the attributes that the user wants */ > ret = ltdb_filter_attrs(ares->message, ac->attrs); > >- if (ret == -1) { >+ if (ret != LDB_SUCCESS) { > handle->status = LDB_ERR_OPERATIONS_ERROR; > handle->state = LDB_ASYNC_DONE; > talloc_free(ares); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > ares->type = LDB_REPLY_ENTRY; >@@ -460,10 +460,10 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi > > if (handle->status != LDB_SUCCESS) { > /* don't try to free ares here, the callback is in charge of that */ >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > >- return 0; >+ return LDB_SUCCESS; > } > > >diff --git a/source/lib/ldb/ldb_tdb/ldb_tdb.c b/source/lib/ldb/ldb_tdb/ldb_tdb.c >index 01d570c..b711efd 100644 >--- a/source/lib/ldb/ldb_tdb/ldb_tdb.c >+++ b/source/lib/ldb/ldb_tdb/ldb_tdb.c >@@ -174,7 +174,7 @@ int ltdb_check_special_dn(struct ldb_module *module, > > if (! ldb_dn_is_special(msg->dn) || > ! ldb_dn_check_special(msg->dn, LTDB_ATTRIBUTES)) { >- return 0; >+ return LDB_SUCCESS; > } > > /* we have @ATTRIBUTES, let's check attributes are fine */ >@@ -188,7 +188,7 @@ int ltdb_check_special_dn(struct ldb_module *module, > } > } > >- return 0; >+ return LDB_SUCCESS; > } > > >@@ -231,7 +231,7 @@ int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flg > } > > ret = ltdb_pack_data(module, msg, &tdb_data); >- if (ret == -1) { >+ if (ret != LDB_SUCCESS) { > talloc_free(tdb_key.dptr); > return LDB_ERR_OTHER; > } >@@ -626,7 +626,7 @@ int ltdb_modify_internal(struct ldb_module *module, > } > > ret = ltdb_unpack_data(module, &tdb_data, msg2); >- if (ret == -1) { >+ if (ret != LDB_SUCCESS) { > ret = LDB_ERR_OTHER; > goto failed; > } >@@ -1069,7 +1069,7 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url, > if (strncmp(url, "tdb://", 6) != 0) { > ldb_debug(ldb, LDB_DEBUG_ERROR, > "Invalid tdb URL '%s'", url); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > path = url+6; > } else { >@@ -1097,7 +1097,7 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url, > ltdb = talloc_zero(ldb, struct ltdb_private); > if (!ltdb) { > ldb_oom(ldb); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > /* note that we use quite a large default hash size */ >@@ -1108,7 +1108,7 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url, > ldb_debug(ldb, LDB_DEBUG_ERROR, > "Unable to open tdb '%s'\n", path); > talloc_free(ltdb); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > ltdb->sequence_number = 0; >@@ -1117,7 +1117,7 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url, > if (!module) { > ldb_oom(ldb); > talloc_free(ltdb); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > talloc_set_name_const(*module, "ldb_tdb backend"); > (*module)->ldb = ldb; >@@ -1128,10 +1128,10 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url, > if (ltdb_cache_load(*module) != 0) { > talloc_free(*module); > talloc_free(ltdb); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > >- return 0; >+ return LDB_SUCCESS; > } > > const struct ldb_backend_ops ldb_tdb_backend_ops = { >diff --git a/source/lib/ldb/ldb_tdb/ldb_tdb_wrap.c b/source/lib/ldb/ldb_tdb/ldb_tdb_wrap.c >index 654574c..59a1590 100644 >--- a/source/lib/ldb/ldb_tdb/ldb_tdb_wrap.c >+++ b/source/lib/ldb/ldb_tdb/ldb_tdb_wrap.c >@@ -53,7 +53,7 @@ static int ltdb_wrap_destructor(struct ltdb_wrap *w) > if (w == tdb_list) { > tdb_list = w->next; > } >- return 0; >+ return LDB_SUCCESS; > } > > static void ltdb_log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); >diff --git a/source/lib/ldb/modules/operational.c b/source/lib/ldb/modules/operational.c >index a59e81b..716f34d 100644 >--- a/source/lib/ldb/modules/operational.c >+++ b/source/lib/ldb/modules/operational.c >@@ -158,13 +158,13 @@ static int operational_search_post_process(struct ldb_module *module, > } > } > >- return 0; >+ return LDB_SUCCESS; > > failed: > ldb_debug_set(module->ldb, LDB_DEBUG_WARNING, > "operational_search_post_process failed for attribute '%s'\n", > attrs[a]); >- return -1; >+ return LDB_ERR_OPERATIONS_ERROR; > } > > >diff --git a/source/lib/ldb/modules/paged_results.c b/source/lib/ldb/modules/paged_results.c >index b62b1f9..c7296a1 100644 >--- a/source/lib/ldb/modules/paged_results.c >+++ b/source/lib/ldb/modules/paged_results.c >@@ -86,7 +86,7 @@ int store_destructor(struct results_store *store) > store->priv->store = NULL; > } > >- return 0; >+ return LDB_SUCCESS; > } > > static struct results_store *new_store(struct private_data *priv) >diff --git a/source/lib/ldb/modules/skel.c b/source/lib/ldb/modules/skel.c >index 0cd29ac..15df463 100644 >--- a/source/lib/ldb/modules/skel.c >+++ b/source/lib/ldb/modules/skel.c >@@ -90,7 +90,7 @@ static int skel_destructor(struct ldb_module *ctx) > struct private_data *data = talloc_get_type(ctx->private_data, struct private_data); > /* put your clean-up functions here */ > if (data->some_private_data) talloc_free(data->some_private_data); >- return 0; >+ return LDB_SUCCESS; > } > > static int skel_request(struct ldb_module *module, struct ldb_request *req) >diff --git a/source/lib/ldb_wrap.c b/source/lib/ldb_wrap.c >index 6c683a1..8082f4f 100644 >--- a/source/lib/ldb_wrap.c >+++ b/source/lib/ldb_wrap.c >@@ -84,7 +84,7 @@ static int ldb_wrap_destructor(struct ldb_context *ldb) > smb_panic("probable memory leak in ldb"); > #endif > } >- return 0; >+ return LDB_SUCCESS; > } > > /* >diff --git a/source/lib/registry/ldb.c b/source/lib/registry/ldb.c >index a8a9ed5..2eb4e9e 100644 >--- a/source/lib/registry/ldb.c >+++ b/source/lib/registry/ldb.c >@@ -64,6 +64,15 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx, > (void **)&data->data); > break; > >+ case REG_BINARY: >+ if (val) >+ *data = strhex_to_data_blob((char *)val->data); >+ else { >+ data->data = NULL; >+ data->length = 0; >+ } >+ break; >+ > case REG_DWORD: { > uint32_t tmp = strtoul((char *)val->data, NULL, 0); > *data = data_blob_talloc(mem_ctx, &tmp, 4); >@@ -97,6 +106,11 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx, > ldb_msg_add_value(msg, "data", &val, NULL); > break; > >+ case REG_BINARY: >+ ldb_msg_add_string(msg, "data", >+ data_blob_hex_string(mem_ctx, &data)); >+ break; >+ > case REG_DWORD: > ldb_msg_add_string(msg, "data", > talloc_asprintf(mem_ctx, "0x%x", >@@ -269,22 +283,58 @@ static WERROR ldb_get_subkey_by_id(TALLOC_CTX *mem_ctx, > return WERR_OK; > } > >+static WERROR ldb_get_default_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; >+ const char* attrs[] = { "data", "type", NULL }; >+ struct ldb_result *res; >+ int ret; >+ >+ ret = ldb_search(c, kd->dn, LDB_SCOPE_BASE, "", attrs, &res); >+ >+ if (ret != LDB_SUCCESS) { >+ DEBUG(0, ("Error getting default value for '%s': %s\n", >+ ldb_dn_get_linearized(kd->dn), ldb_errstring(c))); >+ return WERR_FOOBAR; >+ } >+ >+ if (res->count == 0 || res->msgs[0]->num_elements == 0) >+ return WERR_BADFILE; >+ >+ reg_ldb_unpack_value(mem_ctx, lp_iconv_convenience(global_loadparm), >+ res->msgs[0], name, data_type, data); >+ >+ talloc_free(res); >+ >+ return WERR_OK; >+} >+ > static WERROR ldb_get_value_by_id(TALLOC_CTX *mem_ctx, 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); > >- /* Do the search if necessary */ >- if (kd->values == NULL) { >- W_ERROR_NOT_OK_RETURN(cache_values(kd)); >- } >+ if (idx == 0) { >+ /* default value */ >+ return ldb_get_default_value(mem_ctx, k, name, data_type, data); >+ } else { >+ /* normal value */ > >- if (idx >= kd->value_count) >- return WERR_NO_MORE_ITEMS; >+ /* Do the search if necessary */ >+ if (kd->values == NULL) { >+ W_ERROR_NOT_OK_RETURN(cache_values(kd)); >+ } > >- reg_ldb_unpack_value(mem_ctx, lp_iconv_convenience(global_loadparm), kd->values[idx], >- name, data_type, data); >+ if (idx >= kd->value_count) >+ return WERR_NO_MORE_ITEMS; >+ >+ reg_ldb_unpack_value(mem_ctx, lp_iconv_convenience(global_loadparm), >+ kd->values[idx], name, data_type, data); >+ } > > return WERR_OK; > } >@@ -297,22 +347,31 @@ static WERROR ldb_get_value(TALLOC_CTX *mem_ctx, struct hive_key *k, > struct ldb_context *c = kd->ldb; > struct ldb_result *res; > int ret; >- char *query = talloc_asprintf(mem_ctx, "(value=%s)", name); >+ char *query; > >- ret = ldb_search(c, kd->dn, LDB_SCOPE_ONELEVEL, query, NULL, &res); >- >- talloc_free(query); >+ if (strlen(name) == 0) { >+ /* default value */ >+ return ldb_get_default_value(mem_ctx, k, NULL, data_type, data); >+ } else { >+ /* normal value */ >+ query = talloc_asprintf(mem_ctx, "(value=%s)", name); >+ ret = ldb_search(c, kd->dn, LDB_SCOPE_ONELEVEL, query, NULL, &res); >+ 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))); >+ return WERR_FOOBAR; >+ } > >- if (ret != LDB_SUCCESS) { >- DEBUG(0, ("Error getting values for '%s': %s\n", >- ldb_dn_get_linearized(kd->dn), ldb_errstring(c))); >- return WERR_FOOBAR; >- } >+ if (res->count == 0) >+ return WERR_BADFILE; > >- if (res->count == 0) >- return WERR_BADFILE; >+ reg_ldb_unpack_value(mem_ctx, lp_iconv_convenience(global_loadparm), >+ res->msgs[0], NULL, data_type, data); > >- reg_ldb_unpack_value(mem_ctx, lp_iconv_convenience(global_loadparm), res->msgs[0], NULL, data_type, data); >+ talloc_free(res); >+ } > > return WERR_OK; > } >@@ -349,8 +408,6 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h, > > *key = (struct hive_key *)newkd; > >- talloc_free(res); >- > return WERR_OK; > } > >@@ -447,30 +504,52 @@ static WERROR ldb_del_value (struct hive_key *key, const char *child) > { > int ret; > struct ldb_key_data *kd = talloc_get_type(key, struct ldb_key_data); >+ TALLOC_CTX *mem_ctx; >+ struct ldb_message *msg; > struct ldb_dn *childdn; > >- childdn = ldb_dn_copy(kd->ldb, kd->dn); >- if (!ldb_dn_add_child_fmt(childdn, "value=%s", >+ if (strlen(child) == 0) { >+ /* default value */ >+ mem_ctx = talloc_init("ldb_del_value"); >+ >+ msg = talloc_zero(mem_ctx, struct ldb_message); >+ msg->dn = ldb_dn_copy(msg, kd->dn); >+ ldb_msg_add_empty(msg, "data", LDB_FLAG_MOD_DELETE, NULL); >+ ldb_msg_add_empty(msg, "type", LDB_FLAG_MOD_DELETE, NULL); >+ >+ ret = ldb_modify(kd->ldb, msg); >+ if (ret != LDB_SUCCESS) { >+ DEBUG(1, ("ldb_del_value: %s\n", ldb_errstring(kd->ldb))); >+ talloc_free(mem_ctx); >+ return WERR_FOOBAR; >+ } >+ >+ talloc_free(mem_ctx); >+ } else { >+ /* normal value */ >+ childdn = ldb_dn_copy(kd->ldb, kd->dn); >+ if (!ldb_dn_add_child_fmt(childdn, "value=%s", > reg_ldb_escape(childdn, child))) >- { >- talloc_free(childdn); >- return WERR_FOOBAR; >- } >+ { >+ talloc_free(childdn); >+ return WERR_FOOBAR; >+ } > >- ret = ldb_delete(kd->ldb, childdn); >+ ret = ldb_delete(kd->ldb, childdn); > >- talloc_free(childdn); >+ talloc_free(childdn); > >- if (ret == LDB_ERR_NO_SUCH_OBJECT) { >- return WERR_BADFILE; >- } else if (ret != LDB_SUCCESS) { >- DEBUG(1, ("ldb_del_value: %s\n", ldb_errstring(kd->ldb))); >- return WERR_FOOBAR; >- } >+ if (ret == LDB_ERR_NO_SUCH_OBJECT) { >+ return WERR_BADFILE; >+ } else if (ret != LDB_SUCCESS) { >+ DEBUG(1, ("ldb_del_value: %s\n", ldb_errstring(kd->ldb))); >+ return WERR_FOOBAR; >+ } > >- /* reset cache */ >- talloc_free(kd->values); >- kd->values = NULL; >+ /* reset cache */ >+ talloc_free(kd->values); >+ kd->values = NULL; >+ } > > return WERR_OK; > } >@@ -601,13 +680,17 @@ static WERROR ldb_set_value(struct hive_key *parent, > TALLOC_CTX *mem_ctx = talloc_init("ldb_set_value"); > > msg = reg_ldb_pack_value(kd->ldb, mem_ctx, name, type, data); >- > msg->dn = ldb_dn_copy(msg, kd->dn); >- if (!ldb_dn_add_child_fmt(msg->dn, "value=%s", >+ >+ if (strlen(name) > 0) { >+ /* For a default value, we add/overwrite the attributes to/of the hive. >+ For a normal value, we create new childs. */ >+ if (!ldb_dn_add_child_fmt(msg->dn, "value=%s", > reg_ldb_escape(mem_ctx, name))) >- { >- talloc_free(mem_ctx); >- return WERR_FOOBAR; >+ { >+ talloc_free(mem_ctx); >+ return WERR_FOOBAR; >+ } > } > > ret = ldb_add(kd->ldb, msg); >@@ -620,7 +703,7 @@ static WERROR ldb_set_value(struct hive_key *parent, > } > > if (ret != LDB_SUCCESS) { >- DEBUG(1, ("ldb_msg_add: %s\n", ldb_errstring(kd->ldb))); >+ DEBUG(1, ("ldb_set_value: %s\n", ldb_errstring(kd->ldb))); > talloc_free(mem_ctx); > return WERR_FOOBAR; > } >diff --git a/source/lib/registry/tools/common.c b/source/lib/registry/tools/common.c >index 3ea780d..f770f6a 100644 >--- a/source/lib/registry/tools/common.c >+++ b/source/lib/registry/tools/common.c >@@ -24,13 +24,14 @@ > #include "lib/registry/tools/common.h" > > struct registry_context *reg_common_open_remote(const char *remote, >+ struct event_context *ev_ctx, > struct loadparm_context *lp_ctx, > struct cli_credentials *creds) > { > struct registry_context *h = NULL; > WERROR error; > >- error = reg_open_remote(&h, NULL, creds, lp_ctx, remote, NULL); >+ error = reg_open_remote(&h, NULL, creds, lp_ctx, remote, ev_ctx); > > if (!W_ERROR_IS_OK(error)) { > fprintf(stderr, "Unable to open remote registry at %s:%s \n", >diff --git a/source/lib/registry/tools/regpatch.c b/source/lib/registry/tools/regpatch.c >index 1170fba..add59a5 100644 >--- a/source/lib/registry/tools/regpatch.c >+++ b/source/lib/registry/tools/regpatch.c >@@ -34,7 +34,7 @@ int main(int argc, char **argv) > struct registry_context *h; > const char *file = NULL; > const char *remote = NULL; >- struct event_context *ev; >+ struct event_context *ev_ctx; > struct poptOption long_options[] = { > POPT_AUTOHELP > {"remote", 'R', POPT_ARG_STRING, &remote, 0, "connect to specified remote server", NULL}, >@@ -49,12 +49,12 @@ int main(int argc, char **argv) > while((opt = poptGetNextOpt(pc)) != -1) { > } > >- ev = s4_event_context_init(NULL); >+ ev_ctx = s4_event_context_init(NULL); > > if (remote) { >- h = reg_common_open_remote (remote, cmdline_lp_ctx, cmdline_credentials); >+ h = reg_common_open_remote (remote, ev_ctx, cmdline_lp_ctx, cmdline_credentials); > } else { >- h = reg_common_open_local (cmdline_credentials, ev, cmdline_lp_ctx); >+ h = reg_common_open_local (cmdline_credentials, ev_ctx, cmdline_lp_ctx); > } > > if (h == NULL) >diff --git a/source/lib/registry/tools/regshell.c b/source/lib/registry/tools/regshell.c >index 4e859df..98f7f02 100644 >--- a/source/lib/registry/tools/regshell.c >+++ b/source/lib/registry/tools/regshell.c >@@ -162,9 +162,7 @@ static WERROR cmd_ck(struct regshell_context *ctx, int argc, char **argv) > struct registry_key *new = NULL; > WERROR error; > >- if(argc < 2) { >- new = ctx->current; >- } else { >+ if(argc == 2) { > error = reg_open_key(ctx->registry, ctx->current, argv[1], > &new); > if(!W_ERROR_IS_OK(error)) { >@@ -172,11 +170,11 @@ static WERROR cmd_ck(struct regshell_context *ctx, int argc, char **argv) > win_errstr(error))); > return error; > } >- } > >- ctx->path = talloc_asprintf(ctx, "%s\\%s", ctx->path, argv[1]); >- printf("Current path is: %s\n", ctx->path); >- ctx->current = new; >+ ctx->path = talloc_asprintf(ctx, "%s\\%s", ctx->path, argv[1]); >+ ctx->current = new; >+ } >+ printf("New path is: %s\n", ctx->path); > > return WERR_OK; > } >@@ -188,7 +186,7 @@ static WERROR cmd_print(struct regshell_context *ctx, int argc, char **argv) > WERROR error; > > if (argc != 2) { >- fprintf(stderr, "Usage: print <valuename>"); >+ fprintf(stderr, "Usage: print <valuename>\n"); > return WERR_INVALID_PARAM; > } > >@@ -520,8 +518,8 @@ int main(int argc, char **argv) > ev_ctx = s4_event_context_init(ctx); > > if (remote != NULL) { >- ctx->registry = reg_common_open_remote(remote, cmdline_lp_ctx, >- cmdline_credentials); >+ ctx->registry = reg_common_open_remote(remote, ev_ctx, >+ cmdline_lp_ctx, cmdline_credentials); > } else if (file != NULL) { > ctx->current = reg_common_open_file(file, ev_ctx, cmdline_lp_ctx, cmdline_credentials); > if (ctx->current == NULL) >diff --git a/source/lib/registry/tools/regtree.c b/source/lib/registry/tools/regtree.c >index daca695..19e4a01 100644 >--- a/source/lib/registry/tools/regtree.c >+++ b/source/lib/registry/tools/regtree.c >@@ -132,7 +132,7 @@ int main(int argc, char **argv) > ev_ctx = s4_event_context_init(NULL); > > if (remote != NULL) { >- h = reg_common_open_remote(remote, cmdline_lp_ctx, cmdline_credentials); >+ h = reg_common_open_remote(remote, ev_ctx, cmdline_lp_ctx, cmdline_credentials); > } else if (file != NULL) { > start_key = reg_common_open_file(file, ev_ctx, cmdline_lp_ctx, cmdline_credentials); > } else { >diff --git a/source/rpc_server/winreg/rpc_winreg.c b/source/rpc_server/winreg/rpc_winreg.c >index 22c60c3..62f2676 100644 >--- a/source/rpc_server/winreg/rpc_winreg.c >+++ b/source/rpc_server/winreg/rpc_winreg.c >@@ -222,16 +222,14 @@ static WERROR dcesrv_winreg_EnumKey(struct dcesrv_call_state *dce_call, > r->in.enum_index, > &name, NULL, &last_mod); > >- if (W_ERROR_IS_OK(r->out.result)) { >- if (2*strlen_m_term(name) > r->in.name->size) { >- return WERR_MORE_DATA; >- } >- r->out.name->length = 2*strlen_m_term(name); >- r->out.name->name = name; >- r->out.keyclass = talloc_zero(mem_ctx, struct winreg_StringBuf); >- if (r->in.last_changed_time) { >- r->out.last_changed_time = &last_mod; >- } >+ if (2*strlen_m_term(name) > r->in.name->size) { >+ return WERR_MORE_DATA; >+ } >+ r->out.name->length = 2*strlen_m_term(name); >+ r->out.name->name = name; >+ r->out.keyclass = talloc_zero(mem_ctx, struct winreg_StringBuf); >+ if (r->in.last_changed_time) { >+ r->out.last_changed_time = &last_mod; > } > > return r->out.result; >@@ -259,8 +257,13 @@ static WERROR dcesrv_winreg_EnumValue(struct dcesrv_call_state *dce_call, > result = reg_key_get_value_by_index(mem_ctx, key, r->in.enum_index, > &data_name, > &data_type, &data); >+ > if (!W_ERROR_IS_OK(result)) { >- return result; >+ /* if the lookup wasn't successful, send client query back */ >+ data_name = r->in.name->name; >+ data_type = *r->in.type; >+ data.data = r->in.value; >+ data.length = *r->in.length; > } > > /* the client can optionally pass a NULL for type, meaning they don't >@@ -282,8 +285,14 @@ static WERROR dcesrv_winreg_EnumValue(struct dcesrv_call_state *dce_call, > return WERR_MORE_DATA; > } > >- r->out.name->name = data_name; >- r->out.name->length = 2*strlen_m_term(data_name); >+ /* "data_name" is NULL when we query the default attribute */ >+ if (data_name) { >+ r->out.name->name = data_name; >+ r->out.name->length = 2*strlen_m_term(data_name); >+ } else { >+ r->out.name->name = r->in.name->name; >+ r->out.name->length = r->in.name->length; >+ } > r->out.name->size = r->in.name->size; > > if (r->in.value) { >@@ -296,7 +305,7 @@ static WERROR dcesrv_winreg_EnumValue(struct dcesrv_call_state *dce_call, > r->out.length = r->out.size; > } > >- return WERR_OK; >+ return result; > } > > >@@ -408,7 +417,7 @@ static WERROR dcesrv_winreg_QueryInfoKey(struct dcesrv_call_state *dce_call, > { > struct dcesrv_handle *h; > struct registry_key *k; >- WERROR ret; >+ WERROR result; > const char *classname = NULL; > > DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY); >@@ -420,7 +429,7 @@ static WERROR dcesrv_winreg_QueryInfoKey(struct dcesrv_call_state *dce_call, > case SECURITY_USER: > k = h->data; > >- ret = reg_key_get_info(mem_ctx, k, &classname, r->out.num_subkeys, >+ result = reg_key_get_info(mem_ctx, k, &classname, r->out.num_subkeys, > r->out.num_values, r->out.last_changed_time, > r->out.max_subkeylen, r->out.max_valnamelen, > r->out.max_valbufsize); >@@ -428,7 +437,7 @@ static WERROR dcesrv_winreg_QueryInfoKey(struct dcesrv_call_state *dce_call, > if (r->out.classname != NULL) > r->out.classname->name = classname; > >- return ret; >+ return result; > default: > return WERR_ACCESS_DENIED; > } >@@ -444,9 +453,9 @@ static WERROR dcesrv_winreg_QueryValue(struct dcesrv_call_state *dce_call, > { > struct dcesrv_handle *h; > struct registry_key *key; >+ WERROR result; > uint32_t value_type; > DATA_BLOB value_data; >- WERROR result; > > DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY); > >@@ -460,10 +469,14 @@ static WERROR dcesrv_winreg_QueryValue(struct dcesrv_call_state *dce_call, > result = reg_key_get_value_by_name(mem_ctx, key, r->in.value_name.name, > &value_type, &value_data); > >+ > if (!W_ERROR_IS_OK(result)) { >- return result; >+ /* if the lookup wasn't successful, send client query back */ >+ value_type = *r->in.type; >+ value_data.data = r->in.data; >+ value_data.length = *r->in.length; > } >- >+ > /* Just asking for the size of the buffer */ > r->out.type = talloc(mem_ctx, uint32_t); > if (!r->out.type) { >@@ -475,15 +488,15 @@ static WERROR dcesrv_winreg_QueryValue(struct dcesrv_call_state *dce_call, > return WERR_NOMEM; > } > *r->out.length = value_data.length; >- if (r->in.data == NULL) { >- r->out.size = talloc(mem_ctx, uint32_t); >- *r->out.size = value_data.length; >- } else { >- r->out.size = r->in.size; >- r->out.data = value_data.data; >+ r->out.size = talloc(mem_ctx, uint32_t); >+ if (!r->out.size) { >+ return WERR_NOMEM; > } >- >- return WERR_OK; >+ *r->out.size = value_data.length; >+ >+ r->out.data = value_data.data; >+ >+ return result; > default: > return WERR_ACCESS_DENIED; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 5739
:
3534
|
3535
|
3536
|
3537
|
3538
|
3539
|
3540
|
3541
|
3628