Merge branch 'master' of ssh://git.samba.org/data/git/samba into regsrv
authorJelmer Vernooij <jelmer@samba.org>
Tue, 21 Oct 2008 12:51:13 +0000 (14:51 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Tue, 21 Oct 2008 12:51:13 +0000 (14:51 +0200)
Conflicts:
source4/lib/registry/ldb.c
source4/rpc_server/winreg/rpc_winreg.c

1  2 
source4/lib/registry/ldb.c
source4/rpc_server/winreg/rpc_winreg.c

@@@ -365,32 -297,27 +365,33 @@@ static WERROR ldb_get_value(TALLOC_CTX 
        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, mem_ctx, &res, kd->dn, LDB_SCOPE_ONELEVEL, NULL, "%s", 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);
++              ret = ldb_search(c, kd->dn, &res, LDB_SCOPE_ONELEVEL, query, NULL, "%s", query);
 +              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;
 +              }
  
 -      talloc_free(query);
 +              if (res->count == 0)
 +                      return WERR_BADFILE;
  
 -      if (ret != LDB_SUCCESS) {
 -              DEBUG(0, ("Error getting values for '%s': %s\n",
 -                      ldb_dn_get_linearized(kd->dn), ldb_errstring(c)));
 -              talloc_free(res);
 -              return WERR_FOOBAR;
 -      }
 +              reg_ldb_unpack_value(mem_ctx, lp_iconv_convenience(global_loadparm),
 +                       res->msgs[0], NULL, data_type, data);
  
 -      if (res->count == 0) {
                talloc_free(res);
 -              return WERR_BADFILE;
        }
  
 -      reg_ldb_unpack_value(mem_ctx, lp_iconv_convenience(global_loadparm), res->msgs[0], NULL, data_type, data);
 -
+       talloc_free(res);
        return WERR_OK;
  }
  
@@@ -489,35 -455,35 +489,34 @@@ static WERROR dcesrv_winreg_QueryValue(
        case SECURITY_SYSTEM:
        case SECURITY_ADMINISTRATOR:
        case SECURITY_USER:
-               result = reg_key_get_value_by_name(mem_ctx, key,
-                        r->in.value_name.name, &value_type, &value_data);
 -              key = h->data;
 -              
 -              result = reg_key_get_value_by_name(mem_ctx, key, r->in.value_name->name,
 -                                                 &value_type, &value_data);
++              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) {
                        return WERR_NOMEM;
                }
                *r->out.type = value_type;
-               r->out.length = talloc(mem_ctx, uint32_t);
-               if (!r->out.length) {
+               r->out.data_length = talloc(mem_ctx, uint32_t);
+               if (!r->out.data_length) {
                        return WERR_NOMEM;
                }
 -              *r->out.data_length = value_data.length;
 -              if (r->in.data == NULL) {
 -                      r->out.data_size = talloc(mem_ctx, uint32_t);
 -                      *r->out.data_size = value_data.length;
 -              } else {
 -                      r->out.data_size = r->in.data_size;
 -                      r->out.data = value_data.data;
 +              *r->out.length = value_data.length;
-               r->out.size = talloc(mem_ctx, uint32_t);
-               if (!r->out.size) {
++              r->out.data_size = talloc(mem_ctx, uint32_t);
++              if (!r->out.data_size) {
 +                      return WERR_NOMEM;
                }
-               *r->out.size = value_data.length;
 -              
 -              return WERR_OK;
++              *r->out.data_size = value_data.length;
 +              r->out.data = value_data.data;
 +
 +              return result;
        default:
                return WERR_ACCESS_DENIED;
        }