#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
-/******************************************************************
- free() function for struct registry_key
- *****************************************************************/
-
-static void free_regkey(void *ptr)
-{
- struct registry_key *key = (struct registry_key *)ptr;
- TALLOC_FREE(key);
-}
-
/******************************************************************
Find a registry key handle and return a struct registry_key *
*****************************************************************/
static struct registry_key *find_regkey_by_hnd(pipes_struct *p,
- POLICY_HND *hnd)
+ struct policy_handle *hnd)
{
struct registry_key *regkey = NULL;
HK[LM|U]\<key>\<key>\...
*******************************************************************/
-static WERROR open_registry_key( pipes_struct *p, POLICY_HND *hnd,
+static WERROR open_registry_key( pipes_struct *p, struct policy_handle *hnd,
struct registry_key *parent,
const char *subkeyname,
uint32 access_desired )
struct registry_key *key;
if (parent == NULL) {
- result = reg_openhive(NULL, subkeyname, access_desired,
- p->pipe_user.nt_user_token, &key);
+ result = reg_openhive(p->mem_ctx, subkeyname, access_desired,
+ p->server_info->ptok, &key);
}
else {
- result = reg_openkey(NULL, parent, subkeyname, access_desired,
- &key);
+ result = reg_openkey(p->mem_ctx, parent, subkeyname,
+ access_desired, &key);
}
if ( !W_ERROR_IS_OK(result) ) {
return result;
}
- if ( !create_policy_hnd( p, hnd, free_regkey, key ) ) {
+ if ( !create_policy_hnd( p, hnd, key ) ) {
return WERR_BADFILE;
}
Note that P should be valid & hnd should already have space
*******************************************************************/
-static bool close_registry_key(pipes_struct *p, POLICY_HND *hnd)
+static bool close_registry_key(pipes_struct *p, struct policy_handle *hnd)
{
struct registry_key *regkey = find_regkey_by_hnd(p, hnd);
if ( !regkey )
return WERR_BADFID;
- *r->out.value_length = *r->out.type = REG_NONE;
+ if ((r->out.data_length == NULL) || (r->out.type == NULL)) {
+ return WERR_INVALID_PARAM;
+ }
+
+ *r->out.data_length = *r->out.type = REG_NONE;
DEBUG(7,("_reg_info: policy key name = [%s]\n", regkey->key->name));
DEBUG(7,("_reg_info: policy key type = [%08x]\n", regkey->key->type));
/* Handle QueryValue calls on HKEY_PERFORMANCE_DATA */
if(regkey->key->type == REG_KEY_HKPD)
{
- if(strequal(r->in.value_name.name, "Global")) {
+ if (strequal(r->in.value_name->name, "Global")) {
if (!prs_init(&prs_hkpd, *r->in.data_size, p->mem_ctx, MARSHALL))
return WERR_NOMEM;
status = reg_perfcount_get_hkpd(
outbuf = (uint8_t *)prs_hkpd.data_p;
free_prs = True;
}
- else if(strequal(r->in.value_name.name, "Counter 009")) {
+ else if (strequal(r->in.value_name->name, "Counter 009")) {
outbuf_size = reg_perfcount_get_counter_names(
reg_perfcount_get_base_index(),
(char **)(void *)&outbuf);
free_buf = True;
}
- else if(strequal(r->in.value_name.name, "Explain 009")) {
+ else if (strequal(r->in.value_name->name, "Explain 009")) {
outbuf_size = reg_perfcount_get_counter_help(
reg_perfcount_get_base_index(),
(char **)(void *)&outbuf);
free_buf = True;
}
- else if(isdigit(r->in.value_name.name[0])) {
+ else if (isdigit(r->in.value_name->name[0])) {
/* we probably have a request for a specific object
* here */
if (!prs_init(&prs_hkpd, *r->in.data_size, p->mem_ctx, MARSHALL))
return WERR_NOMEM;
status = reg_perfcount_get_hkpd(
&prs_hkpd, *r->in.data_size, &outbuf_size,
- r->in.value_name.name);
+ r->in.value_name->name);
outbuf = (uint8_t *)prs_hkpd.data_p;
free_prs = True;
}
else {
DEBUG(3,("Unsupported key name [%s] for HKPD.\n",
- r->in.value_name.name));
+ r->in.value_name->name));
return WERR_BADFILE;
}
else {
struct registry_value *val;
- status = reg_queryvalue(p->mem_ctx, regkey, r->in.value_name.name,
+ status = reg_queryvalue(p->mem_ctx, regkey, r->in.value_name->name,
&val);
if (!W_ERROR_IS_OK(status)) {
if (r->out.data_size) {
*r->out.data_size = 0;
}
- if (r->out.value_length) {
- *r->out.value_length = 0;
+ if (r->out.data_length) {
+ *r->out.data_length = 0;
}
return status;
}
*r->out.type = val->type;
}
- *r->out.value_length = outbuf_size;
+ *r->out.data_length = outbuf_size;
if ( *r->in.data_size == 0 || !r->out.data ) {
status = WERR_OK;
- } else if ( *r->out.value_length > *r->in.data_size ) {
+ } else if ( *r->out.data_length > *r->in.data_size ) {
status = WERR_MORE_DATA;
} else {
- memcpy( r->out.data, outbuf, *r->out.value_length );
+ memcpy( r->out.data, outbuf, *r->out.data_length );
status = WERR_OK;
}
- *r->out.data_size = *r->out.value_length;
+ *r->out.data_size = *r->out.data_length;
if (free_prs) prs_mem_free(&prs_hkpd);
if (free_buf) SAFE_FREE(outbuf);
s.in.message = r->in.message;
s.in.timeout = r->in.timeout;
s.in.force_apps = r->in.force_apps;
- s.in.reboot = r->in.reboot;
+ s.in.do_reboot = r->in.do_reboot;
s.in.reason = 0;
/* thunk down to _winreg_InitiateSystemShutdownEx()
char *chkmsg = NULL;
fstring str_timeout;
fstring str_reason;
- fstring reboot;
+ fstring do_reboot;
fstring f;
int ret;
bool can_shutdown;
/* pull the message string and perform necessary sanity checks on it */
- if ( r->in.message && r->in.message->name && r->in.message->name->name ) {
- if ( (msg = talloc_strdup(p->mem_ctx, r->in.message->name->name )) == NULL ) {
+ if ( r->in.message && r->in.message->string ) {
+ if ( (msg = talloc_strdup(p->mem_ctx, r->in.message->string )) == NULL ) {
return WERR_NOMEM;
}
chkmsg = TALLOC_ARRAY(p->mem_ctx, char, strlen(msg)+1);
}
fstr_sprintf(str_timeout, "%d", r->in.timeout);
- fstr_sprintf(reboot, r->in.reboot ? SHUTDOWN_R_STRING : "");
+ fstr_sprintf(do_reboot, r->in.do_reboot ? SHUTDOWN_R_STRING : "");
fstr_sprintf(f, r->in.force_apps ? SHUTDOWN_F_STRING : "");
fstr_sprintf(str_reason, "%d", r->in.reason );
return WERR_NOMEM;
}
shutdown_script = talloc_all_string_sub(p->mem_ctx,
- shutdown_script, "%r", reboot);
+ shutdown_script, "%r", do_reboot);
if (!shutdown_script) {
return WERR_NOMEM;
}
return WERR_NOMEM;
}
- can_shutdown = user_has_privileges( p->pipe_user.nt_user_token, &se_remote_shutdown );
+ can_shutdown = user_has_privileges( p->server_info->ptok,
+ &se_remote_shutdown );
/* IF someone has privs, run the shutdown script as root. OTHERWISE run it as not root
Take the error return from the script and provide it as the Windows return code. */
if (!*abort_shutdown_script)
return WERR_ACCESS_DENIED;
- can_shutdown = user_has_privileges( p->pipe_user.nt_user_token, &se_remote_shutdown );
+ can_shutdown = user_has_privileges( p->server_info->ptok,
+ &se_remote_shutdown );
/********** BEGIN SeRemoteShutdownPrivilege BLOCK **********/
/* user must posses SeRestorePrivilege for this this proceed */
- if ( !user_has_privileges( p->pipe_user.nt_user_token, &se_restore ) )
+ if ( !user_has_privileges( p->server_info->ptok, &se_restore ) )
return WERR_ACCESS_DENIED;
DEBUG(2,("_winreg_RestoreKey: Restoring [%s] from %s in share %s\n",
if ( !parent )
return WERR_BADFID;
+ DEBUG(10, ("_winreg_CreateKey called with parent key '%s' and "
+ "subkey name '%s'\n", parent->key->name, r->in.name.name));
+
result = reg_createkey(NULL, parent, r->in.name.name, r->in.access_mask,
&new_key, r->out.action_taken);
if (!W_ERROR_IS_OK(result)) {
return result;
}
- if (!create_policy_hnd(p, r->out.new_handle, free_regkey, new_key)) {
+ if (!create_policy_hnd(p, r->out.new_handle, new_key)) {
TALLOC_FREE(new_key);
return WERR_BADFILE;
}