mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
s3:services_db: change svcctl_lookup_description() to use reg_api functions
This commit is contained in:
parent
9fee033656
commit
53dcbc2dd2
@ -671,46 +671,44 @@ done:
|
|||||||
const char *svcctl_lookup_description(TALLOC_CTX *ctx, const char *name, struct security_token *token )
|
const char *svcctl_lookup_description(TALLOC_CTX *ctx, const char *name, struct security_token *token )
|
||||||
{
|
{
|
||||||
const char *description = NULL;
|
const char *description = NULL;
|
||||||
struct registry_key_handle *key = NULL;
|
struct registry_key *key = NULL;
|
||||||
struct regval_ctr *values = NULL;
|
struct registry_value *value = NULL;
|
||||||
struct regval_blob *val = NULL;
|
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
WERROR wresult;
|
WERROR wresult;
|
||||||
DATA_BLOB blob;
|
|
||||||
TALLOC_CTX *mem_ctx = talloc_stackframe();
|
TALLOC_CTX *mem_ctx = talloc_stackframe();
|
||||||
|
|
||||||
path = talloc_asprintf(mem_ctx, "%s\\%s", KEY_SERVICES, name);
|
path = talloc_asprintf(mem_ctx, "%s\\%s", KEY_SERVICES, name);
|
||||||
if (path == NULL) {
|
if (path == NULL) {
|
||||||
return NULL;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
wresult = regkey_open_internal(mem_ctx, &key, path, token,
|
wresult = reg_open_path(mem_ctx, path, REG_KEY_READ, token, &key);
|
||||||
REG_KEY_READ );
|
|
||||||
if (!W_ERROR_IS_OK(wresult)) {
|
if (!W_ERROR_IS_OK(wresult)) {
|
||||||
DEBUG(0, ("svcctl_lookup_description: key lookup failed! "
|
DEBUG(0, ("svcctl_lookup_description: key lookup failed! "
|
||||||
"[%s] (%s)\n", path, win_errstr(wresult)));
|
"[%s] (%s)\n", path, win_errstr(wresult)));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
wresult = regval_ctr_init(key, &values);
|
wresult = reg_queryvalue(mem_ctx, key, "Description", &value);
|
||||||
if (!W_ERROR_IS_OK(wresult)) {
|
if (!W_ERROR_IS_OK(wresult)) {
|
||||||
DEBUG(0, ("svcctl_lookup_description: talloc() failed!\n"));
|
DEBUG(0, ("svcctl_lookup_dispname: error getting value "
|
||||||
goto done;
|
"'Description': %s\n", win_errstr(wresult)));
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch_reg_values( key, values );
|
if (value->type != REG_SZ) {
|
||||||
|
goto fail;
|
||||||
if ( !(val = regval_ctr_getvalue( values, "Description" )) ) {
|
|
||||||
description = talloc_strdup(ctx, "Unix Service");
|
|
||||||
goto done;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blob = data_blob_const(regval_data_p(val), regval_size(val));
|
pull_reg_sz(ctx, &value->data, &description);
|
||||||
pull_reg_sz(ctx, &blob, &description);
|
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
description = talloc_strdup(ctx, "Unix Service");
|
||||||
|
|
||||||
done:
|
done:
|
||||||
talloc_free(mem_ctx);
|
talloc_free(mem_ctx);
|
||||||
|
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user