summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-06-24 22:34:40 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:58:01 -0500
commitb8e787bcac79b01d3f44d497517138b0c013be00 (patch)
treef83b5bb7b6e03072bce7dc35015428896a7b5c0d /source3
parent292d11bee56c5493f0c1a9e9e2078bd582704874 (diff)
downloadsamba-b8e787bcac79b01d3f44d497517138b0c013be00.tar.gz
samba-b8e787bcac79b01d3f44d497517138b0c013be00.tar.bz2
samba-b8e787bcac79b01d3f44d497517138b0c013be00.zip
r7890: * add Reg[SG]etKeySec() server stubs
* merge a compile warning fix from trunk to SAMBA_3_0 (This used to be commit 71eb018a05c5012fbd42ba6817aabc0797d38ba1)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/rpc_reg.h4
-rw-r--r--source3/registry/reg_db.c46
-rw-r--r--source3/rpc_parse/parse_reg.c8
-rw-r--r--source3/rpc_server/srv_reg.c55
-rw-r--r--source3/rpc_server/srv_reg_nt.c107
5 files changed, 172 insertions, 48 deletions
diff --git a/source3/include/rpc_reg.h b/source3/include/rpc_reg.h
index 6ef90cd30d..7ef2696228 100644
--- a/source3/include/rpc_reg.h
+++ b/source3/include/rpc_reg.h
@@ -146,7 +146,7 @@ typedef struct {
/***********************************************/
typedef struct {
- POLICY_HND pol;
+ POLICY_HND handle;
uint32 sec_info;
uint32 ptr;
BUFHDR hdr_sec;
@@ -161,7 +161,7 @@ typedef struct {
/***********************************************/
typedef struct {
- POLICY_HND pol;
+ POLICY_HND handle;
uint32 sec_info;
uint32 ptr;
BUFHDR hdr_sec;
diff --git a/source3/registry/reg_db.c b/source3/registry/reg_db.c
index 1ae1d6be54..af0a30b76c 100644
--- a/source3/registry/reg_db.c
+++ b/source3/registry/reg_db.c
@@ -56,6 +56,22 @@ static const char *builtin_registry_paths[] = {
"HKCR",
NULL };
+#if 0 /* not used yet */
+struct builtin_regkey_value {
+ const char *path;
+ const char *valuename;
+ uint32 type;
+ union {
+ const char *string;
+ uint32 dw_value;
+ } data;
+};
+
+static struct builtin_regkey_value builtin_values[] = {
+ { "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "SystemRoot", REG_SZ, { "c:\\Windows" } },
+};
+#endif
+
#define REGVER_V1 1 /* first db version with write support */
/***********************************************************************
@@ -356,38 +372,10 @@ static int regdb_fetch_reg_keys( char* key, REGSUBKEY_CTR *ctr )
static int regdb_fetch_reg_values( char* key, REGVAL_CTR *val )
{
- UNISTR2 data;
- int num_vals;
- char *hname;
- fstring mydomainname;
+ int num_vals = 0;
DEBUG(10,("regdb_fetch_reg_values: Looking for value of key [%s] \n", key));
- num_vals = 0;
-
- if ( strequal(key, "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion" ) ) {
- DEBUG(10,("regdb_fetch_reg_values: Supplying SystemRoot \n"));
- init_unistr2( &data, "c:\\Windows", UNI_STR_TERMINATE);
- regval_ctr_addvalue( val, "SystemRoot",REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );
- num_vals = 1;
- } else if ( strequal(key, "HKLM\\System\\CurrentControlSet\\Control\\ProductOptions" ) ) {
- DEBUG(10,("regdb_fetch_reg_values: Supplying ProductType \n"));
- init_unistr2( &data, "WinNT", UNI_STR_TERMINATE);
- regval_ctr_addvalue( val, "ProductType",REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );
- num_vals = 1;
- } else if ( strequal(key, "HKLM\\System\\CurrentControlSet\\Services\\Tcpip\\Parameters" ) ) {
- DEBUG(10,("regdb_fetch_reg_values: Supplying Hostname & Domain Name\n"));
- hname = SMB_STRDUP(myhostname());
- get_mydnsdomname(mydomainname);
- init_unistr2( &data, hname, UNI_STR_TERMINATE);
- regval_ctr_addvalue( val, "Hostname",REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );
- init_unistr2( &data, mydomainname, UNI_STR_TERMINATE);
- regval_ctr_addvalue( val, "Domain",REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );
- num_vals = 2;
- }
-
-
-
return num_vals;
}
diff --git a/source3/rpc_parse/parse_reg.c b/source3/rpc_parse/parse_reg.c
index d71ecc33de..190f39eb79 100644
--- a/source3/rpc_parse/parse_reg.c
+++ b/source3/rpc_parse/parse_reg.c
@@ -745,7 +745,7 @@ makes a structure.
void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC *q_u, POLICY_HND *pol,
uint32 sec_info, SEC_DESC_BUF *sec_desc_buf)
{
- memcpy(&q_u->pol, pol, sizeof(q_u->pol));
+ memcpy(&q_u->handle, pol, sizeof(q_u->handle));
q_u->sec_info = sec_info;
@@ -769,7 +769,7 @@ BOOL reg_io_q_set_key_sec(const char *desc, REG_Q_SET_KEY_SEC *q_u, prs_struct
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
+ if(!smb_io_pol_hnd("", &q_u->handle, ps, depth))
return False;
if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
@@ -813,7 +813,7 @@ void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_u, POLICY_HND *pol,
uint32 sec_info, uint32 sec_buf_size,
SEC_DESC_BUF *psdb)
{
- memcpy(&q_u->pol, pol, sizeof(q_u->pol));
+ memcpy(&q_u->handle, pol, sizeof(q_u->handle));
q_u->sec_info = sec_info;
@@ -838,7 +838,7 @@ BOOL reg_io_q_get_key_sec(const char *desc, REG_Q_GET_KEY_SEC *q_u, prs_struct
if(!prs_align(ps))
return False;
- if(!smb_io_pol_hnd("", &q_u->pol, ps, depth))
+ if(!smb_io_pol_hnd("", &q_u->handle, ps, depth))
return False;
if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info))
diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c
index fec6702758..efff8e6722 100644
--- a/source3/rpc_server/srv_reg.c
+++ b/source3/rpc_server/srv_reg.c
@@ -512,6 +512,57 @@ static BOOL api_reg_delete_value(pipes_struct *p)
return True;
}
+
+/*******************************************************************
+ ******************************************************************/
+
+static BOOL api_reg_get_key_sec(pipes_struct *p)
+{
+ REG_Q_GET_KEY_SEC q_u;
+ REG_R_GET_KEY_SEC r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ if(!reg_io_q_get_key_sec("", &q_u, data, 0))
+ return False;
+
+ r_u.status = _reg_get_key_sec(p, &q_u, &r_u);
+
+ if(!reg_io_r_get_key_sec("", &r_u, rdata, 0))
+ return False;
+
+ return True;
+}
+
+
+/*******************************************************************
+ ******************************************************************/
+
+static BOOL api_reg_set_key_sec(pipes_struct *p)
+{
+ REG_Q_SET_KEY_SEC q_u;
+ REG_R_SET_KEY_SEC r_u;
+ prs_struct *data = &p->in_data.data;
+ prs_struct *rdata = &p->out_data.rdata;
+
+ ZERO_STRUCT(q_u);
+ ZERO_STRUCT(r_u);
+
+ if(!reg_io_q_set_key_sec("", &q_u, data, 0))
+ return False;
+
+ r_u.status = _reg_set_key_sec(p, &q_u, &r_u);
+
+ if(!reg_io_r_set_key_sec("", &r_u, rdata, 0))
+ return False;
+
+ return True;
+}
+
+
/*******************************************************************
array of \PIPE\reg operations
********************************************************************/
@@ -536,7 +587,9 @@ static struct api_struct api_reg_cmds[] =
{ "REG_CREATE_KEY" , REG_CREATE_KEY , api_reg_create_key },
{ "REG_SET_VALUE" , REG_SET_VALUE , api_reg_set_value },
{ "REG_DELETE_KEY" , REG_DELETE_KEY , api_reg_delete_key },
- { "REG_DELETE_VALUE" , REG_DELETE_VALUE , api_reg_delete_value }
+ { "REG_DELETE_VALUE" , REG_DELETE_VALUE , api_reg_delete_value },
+ { "REG_GET_KEY_SEC" , REG_GET_KEY_SEC , api_reg_get_key_sec },
+ { "REG_SET_KEY_SEC" , REG_SET_KEY_SEC , api_reg_set_key_sec }
};
void reg_get_pipe_fns( struct api_struct **fns, int *n_fns )
diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c
index 455ff3da40..3b25f11359 100644
--- a/source3/rpc_server/srv_reg_nt.c
+++ b/source3/rpc_server/srv_reg_nt.c
@@ -185,12 +185,12 @@ static WERROR open_registry_key(pipes_struct *p, POLICY_HND *hnd, REGISTRY_KEY *
result = WERR_BADFILE;
goto done;
}
-
+
if ( !create_policy_hnd( p, hnd, free_regkey_info, regkey ) ) {
- result = WERR_BADFILE;
+ result = WERR_BADFILE;
goto done;
}
-
+
/* save the access mask */
regkey->access_granted = access_granted;
@@ -317,7 +317,7 @@ WERROR _reg_close(pipes_struct *p, REG_Q_CLOSE *q_u, REG_R_CLOSE *r_u)
{
/* close the policy handle */
- if ( !close_registry_key(p, &q_u->pol) )
+ if (!close_registry_key(p, &q_u->pol))
return WERR_BADFID;
return WERR_OK;
@@ -405,14 +405,14 @@ WERROR _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY
if ( !parent )
return WERR_BADFID;
-
+
rpcstr_pull( name, q_u->name.string->buffer, sizeof(name), q_u->name.string->uni_str_len*2, 0 );
/* check granted access first; what is the correct mask here? */
if ( !(parent->access_granted & (SEC_RIGHTS_ENUM_SUBKEYS|SEC_RIGHTS_CREATE_SUBKEY)) )
return WERR_ACCESS_DENIED;
-
+
/* open the key first to get the appropriate REGISTRY_HOOK
and then check the premissions */
@@ -503,19 +503,61 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL
value_ascii = REG_PT_WINNT;
break;
}
- value_length = push_ucs2(value, value, value_ascii,
- sizeof(value),
- STR_TERMINATE|STR_NOALIGN);
- regval_ctr_addvalue(&regvals, REGSTR_PRODUCTTYPE, REG_SZ,
- value, value_length);
+ value_length = push_ucs2(value, value, value_ascii, sizeof(value),
+ STR_TERMINATE|STR_NOALIGN);
+ regval_ctr_addvalue(&regvals, REGSTR_PRODUCTTYPE, REG_SZ, value, value_length);
val = dup_registry_value( regval_ctr_specific_value( &regvals, 0 ) );
status = WERR_OK;
goto out;
}
+
+ /* "HKLM\\System\\CurrentControlSet\\Services\\Tcpip\\Parameters" */
+
+ if ( strequal( name, "Hostname") ) {
+ char *hname;
+
+ hname = myhostname();
+ value_length = push_ucs2( value, value, hname, sizeof(value), STR_TERMINATE|STR_NOALIGN);
+ regval_ctr_addvalue( &regvals, "Hostname",REG_SZ, value, value_length );
+
+ val = dup_registry_value( regval_ctr_specific_value( &regvals, 0 ) );
+
+ status = WERR_OK;
+
+ goto out;
+ }
+ if ( strequal( name, "Domain") ) {
+ fstring mydomainname;
+
+ get_mydnsdomname( mydomainname );
+ value_length = push_ucs2( value, value, mydomainname, sizeof(value), STR_TERMINATE|STR_NOALIGN);
+ regval_ctr_addvalue( &regvals, "Domain", REG_SZ, value, value_length );
+
+ val = dup_registry_value( regval_ctr_specific_value( &regvals, 0 ) );
+
+ status = WERR_OK;
+
+ goto out;
+ }
+
+ /* "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion" */
+
+ if ( strequal( name, "SystemRoot") ) {
+ value_length = push_ucs2( value, value, "c:\\windows", sizeof(value), STR_TERMINATE|STR_NOALIGN);
+ regval_ctr_addvalue( &regvals, "SystemRoot", REG_SZ, value, value_length );
+
+ val = dup_registry_value( regval_ctr_specific_value( &regvals, 0 ) );
+
+ status = WERR_OK;
+
+ goto out;
+ }
+
+
/* else fall back to actually looking up the value */
for ( i=0; fetch_reg_values_specific(regkey, &val, i); i++ )
@@ -1377,6 +1419,8 @@ WERROR _reg_delete_key(pipes_struct *p, REG_Q_DELETE_KEY *q_u, REG_R_DELETE_KEY
write_result = store_reg_keys( newparent, &subkeys );
regsubkey_ctr_destroy( &subkeys );
+
+ result = write_result ? WERR_OK : WERR_REG_IO_FAILURE;
done:
/* close any intermediate key handles */
@@ -1384,7 +1428,7 @@ done:
if ( newparent != parent )
close_registry_key( p, &newparent_handle );
- return write_result ? WERR_OK : WERR_REG_IO_FAILURE;
+ return result;
}
@@ -1424,3 +1468,42 @@ WERROR _reg_delete_value(pipes_struct *p, REG_Q_DELETE_VALUE *q_u, REG_R_DELETE
return WERR_OK;
}
+/*******************************************************************
+ ********************************************************************/
+
+WERROR _reg_get_key_sec(pipes_struct *p, REG_Q_GET_KEY_SEC *q_u, REG_R_GET_KEY_SEC *r_u)
+{
+ REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->handle);
+
+ if ( !key )
+ return WERR_BADFID;
+
+ /* access checks first */
+
+ if ( !(key->access_granted & STD_RIGHT_READ_CONTROL_ACCESS) )
+ return WERR_ACCESS_DENIED;
+
+
+
+ return WERR_ACCESS_DENIED;
+}
+
+/*******************************************************************
+ ********************************************************************/
+
+WERROR _reg_set_key_sec(pipes_struct *p, REG_Q_SET_KEY_SEC *q_u, REG_R_SET_KEY_SEC *r_u)
+{
+ REGISTRY_KEY *key = find_regkey_index_by_hnd(p, &q_u->handle);
+
+ if ( !key )
+ return WERR_BADFID;
+
+ /* access checks first */
+
+ if ( !(key->access_granted & STD_RIGHT_WRITE_DAC_ACCESS) )
+ return WERR_ACCESS_DENIED;
+
+ return WERR_ACCESS_DENIED;
+}
+
+