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); if (W_ERROR_EQUAL(error, WERR_BADFILE)) { DEBUG(0, ("Error opening key '%s'\n", path)); return error; } /* Set value */ 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 cmd_set(struct regshell_context *ctx, int argc, char **argv) { struct registry_value val; WERROR error; if (argc < 4) { fprintf(stderr, "Usage: set value-name type value\n"); return WERR_INVALID_PARAM; } if (!reg_string_to_val(ctx, argv[2], argv[3], &val.data_type, &val.data)) { fprintf(stderr, "Unable to interpret data\n"); return WERR_INVALID_PARAM; } error = reg_val_set(ctx->current, argv[1], val.data_type, val.data); if (!W_ERROR_IS_OK(error)) { fprintf(stderr, "Error setting value: %s\n", win_errstr(error)); return error; } return WERR_OK; }
/* winreg_SetValue */ static WERROR dcesrv_winreg_SetValue(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct winreg_SetValue *r) { struct dcesrv_handle *h; struct registry_key *key; DATA_BLOB data; WERROR result; DCESRV_PULL_HANDLE_FAULT(h, r->in.handle, HTYPE_REGKEY); key = h->data; switch (security_session_user_level(dce_call->conn->auth_state.session_info)) { case SECURITY_SYSTEM: case SECURITY_ADMINISTRATOR: data.data = r->in.data; data.length = r->in.size; result = reg_val_set(key, r->in.name.name, r->in.type, data); return result; default: return WERR_ACCESS_DENIED; } }