2004-04-04 20:24:08 +04:00
/*
Unix SMB / CIFS implementation .
endpoint server for the winreg pipe
Copyright ( C ) Jelmer Vernooij 2004
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
# include "includes.h"
2004-05-04 10:11:47 +04:00
# include "rpc_server/common/common.h"
2004-04-04 20:24:08 +04:00
2004-10-29 02:38:27 +04:00
enum handle_types { HTYPE_REGVAL , HTYPE_REGKEY } ;
static void winreg_destroy_hive ( struct dcesrv_connection * c , struct dcesrv_handle * h )
2004-04-06 00:44:33 +04:00
{
2004-10-29 02:38:27 +04:00
/* FIXME: Free ((struct registry_key *)h->data)->root->hive->reg_ctx */
2004-04-06 00:44:33 +04:00
}
2004-10-29 02:38:27 +04:00
static WERROR winreg_openhive ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx , const char * hivename , struct policy_handle * * outh )
2004-04-06 00:44:33 +04:00
{
2004-10-29 02:38:27 +04:00
struct registry_context * ctx ;
struct dcesrv_handle * h ;
2004-04-09 02:39:47 +04:00
WERROR error ;
2004-10-29 02:38:27 +04:00
const char * conf = lp_parm_string ( - 1 , " registry " , hivename ) ;
char * backend , * location ;
if ( ! conf ) {
return WERR_NOT_SUPPORTED ;
}
2004-09-27 20:37:41 +04:00
2004-10-29 02:38:27 +04:00
backend = talloc_strdup ( mem_ctx , conf ) ;
location = strchr ( backend , ' : ' ) ;
2004-09-27 20:37:41 +04:00
2004-10-29 02:38:27 +04:00
if ( location ) {
* location = ' \0 ' ;
location + + ;
}
2004-04-06 00:44:33 +04:00
2004-10-29 02:38:27 +04:00
error = reg_open ( & ctx , backend , location , NULL ) ;
if ( ! W_ERROR_IS_OK ( error ) ) return error ;
h = dcesrv_handle_new ( dce_call - > conn , HTYPE_REGKEY ) ;
h - > data = ctx - > hives [ 0 ] - > root ;
SMB_ASSERT ( h - > data ) ;
h - > destroy = winreg_destroy_hive ;
* outh = & h - > wire_handle ;
return WERR_OK ;
}
2004-04-06 00:44:33 +04:00
2004-05-04 10:07:52 +04:00
# define func_winreg_OpenHive(k,n) static WERROR winreg_Open ## k (struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct winreg_Open ## k *r) \
2004-04-09 02:39:47 +04:00
{ \
2004-10-29 02:38:27 +04:00
return winreg_openhive ( dce_call , mem_ctx , n , & r - > out . handle ) ; \
2004-04-09 02:39:47 +04:00
}
2004-09-27 20:37:41 +04:00
func_winreg_OpenHive ( HKCR , " HKEY_CLASSES_ROOT " )
func_winreg_OpenHive ( HKCU , " HKEY_CURRENT_USER " )
func_winreg_OpenHive ( HKLM , " HKEY_LOCAL_MACHINE " )
func_winreg_OpenHive ( HKPD , " HKEY_PERFORMANCE_DATA " )
func_winreg_OpenHive ( HKU , " HKEY_USERS " )
func_winreg_OpenHive ( HKCC , " HKEY_CC " )
func_winreg_OpenHive ( HKDD , " HKEY_DD " )
func_winreg_OpenHive ( HKPT , " HKEY_PT " )
func_winreg_OpenHive ( HKPN , " HKEY_PN " )
2004-04-04 20:24:08 +04:00
/*
2004-04-09 02:39:47 +04:00
winreg_CloseKey
2004-04-04 20:24:08 +04:00
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_CloseKey ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-09 02:39:47 +04:00
struct winreg_CloseKey * r )
2004-04-04 20:24:08 +04:00
{
2004-10-29 02:38:27 +04:00
struct dcesrv_handle * h ;
2004-05-04 10:07:52 +04:00
2004-10-29 02:38:27 +04:00
h = dcesrv_handle_fetch ( dce_call - > conn , r - > in . handle , HTYPE_REGKEY ) ;
2004-05-04 10:07:52 +04:00
DCESRV_CHECK_HANDLE ( h ) ;
2004-04-06 00:44:33 +04:00
2004-04-09 02:39:47 +04:00
dcesrv_handle_destroy ( dce_call - > conn , h ) ;
2004-04-06 00:44:33 +04:00
2004-05-04 10:07:52 +04:00
return WERR_OK ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_CreateKey
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_CreateKey ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_CreateKey * r )
{
2004-10-29 02:38:27 +04:00
struct dcesrv_handle * h , * newh ;
2004-04-09 02:39:47 +04:00
WERROR error ;
2004-05-04 10:07:52 +04:00
2004-10-29 02:38:27 +04:00
h = dcesrv_handle_fetch ( dce_call - > conn , r - > in . handle , HTYPE_REGKEY ) ;
2004-05-04 10:07:52 +04:00
DCESRV_CHECK_HANDLE ( h ) ;
2004-10-29 02:38:27 +04:00
newh = dcesrv_handle_new ( dce_call - > conn , HTYPE_REGKEY ) ;
error = reg_key_add_name ( newh , ( struct registry_key * ) h - > data , r - > in . key . name ,
r - > in . access_mask ,
r - > in . sec_desc ? r - > in . sec_desc - > sd : NULL ,
( struct registry_key * * ) & newh - > data ) ;
2004-04-09 02:39:47 +04:00
if ( W_ERROR_IS_OK ( error ) ) {
2004-10-29 02:38:27 +04:00
r - > out . handle = & newh - > wire_handle ;
} else {
dcesrv_handle_destroy ( dce_call - > conn , newh ) ;
2004-04-09 02:39:47 +04:00
}
2004-05-04 10:07:52 +04:00
return error ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_DeleteKey
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_DeleteKey ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_DeleteKey * r )
{
2004-10-29 02:38:27 +04:00
struct dcesrv_handle * h ;
struct registry_key * key ;
2004-05-04 10:07:52 +04:00
WERROR result ;
2004-10-29 02:38:27 +04:00
h = dcesrv_handle_fetch ( dce_call - > conn , r - > in . handle , HTYPE_REGKEY ) ;
2004-05-04 10:07:52 +04:00
DCESRV_CHECK_HANDLE ( h ) ;
2004-04-09 02:39:47 +04:00
2004-10-29 02:38:27 +04:00
result = reg_open_key ( mem_ctx , ( struct registry_key * ) h - > data , r - > in . key . name , & key ) ;
2004-05-04 10:07:52 +04:00
if ( W_ERROR_IS_OK ( result ) ) {
return reg_key_del ( key ) ;
2004-04-09 02:39:47 +04:00
}
2004-05-04 10:07:52 +04:00
return result ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_DeleteValue
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_DeleteValue ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_DeleteValue * r )
{
2004-10-29 02:38:27 +04:00
struct dcesrv_handle * h ;
struct registry_value * value ;
h = dcesrv_handle_fetch ( dce_call - > conn , r - > in . handle , HTYPE_REGVAL ) ;
DCESRV_CHECK_HANDLE ( h ) ;
value = h - > data ;
/* FIXME */
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_EnumKey
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_EnumKey ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_EnumKey * r )
{
2004-10-29 02:38:27 +04:00
struct dcesrv_handle * h ;
2004-09-22 16:33:39 +04:00
struct registry_key * key ;
2004-05-04 10:07:52 +04:00
2004-10-29 02:38:27 +04:00
h = dcesrv_handle_fetch ( dce_call - > conn , r - > in . handle , HTYPE_REGKEY ) ;
2004-05-04 10:07:52 +04:00
DCESRV_CHECK_HANDLE ( h ) ;
2004-04-09 02:39:47 +04:00
key = h - > data ;
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_EnumValue
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_EnumValue ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_EnumValue * r )
{
2004-10-29 02:38:27 +04:00
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_FlushKey
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_FlushKey ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_FlushKey * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_GetKeySecurity
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_GetKeySecurity ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_GetKeySecurity * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_LoadKey
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_LoadKey ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_LoadKey * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_NotifyChangeKeyValue
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_NotifyChangeKeyValue ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_NotifyChangeKeyValue * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_OpenKey
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_OpenKey ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_OpenKey * r )
{
2004-10-29 02:38:27 +04:00
struct dcesrv_handle * h , * newh ;
2004-05-04 10:07:52 +04:00
WERROR result ;
2004-10-29 02:38:27 +04:00
h = dcesrv_handle_fetch ( dce_call - > conn , r - > in . handle , HTYPE_REGKEY ) ;
2004-05-04 10:07:52 +04:00
DCESRV_CHECK_HANDLE ( h ) ;
2004-04-09 02:39:47 +04:00
2004-10-29 02:38:27 +04:00
newh = dcesrv_handle_new ( dce_call - > conn , HTYPE_REGKEY ) ;
2004-04-09 02:39:47 +04:00
2004-10-29 02:38:27 +04:00
result = reg_open_key ( newh , ( struct registry_key * ) h - > data ,
r - > in . keyname . name , ( struct registry_key * * ) & newh - > data ) ;
2004-04-09 02:39:47 +04:00
2004-05-04 10:07:52 +04:00
if ( W_ERROR_IS_OK ( result ) ) {
2004-10-29 02:38:27 +04:00
r - > out . handle = & newh - > wire_handle ;
} else {
dcesrv_handle_destroy ( dce_call - > conn , newh ) ;
2004-04-09 02:39:47 +04:00
}
2004-04-06 00:44:33 +04:00
2004-05-04 10:07:52 +04:00
return result ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_QueryInfoKey
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_QueryInfoKey ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_QueryInfoKey * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_QueryValue
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_QueryValue ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_QueryValue * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_ReplaceKey
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_ReplaceKey ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_ReplaceKey * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_RestoreKey
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_RestoreKey ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_RestoreKey * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_SaveKey
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_SaveKey ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_SaveKey * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_SetKeySecurity
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_SetKeySecurity ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_SetKeySecurity * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_SetValue
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_SetValue ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_SetValue * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_UnLoadKey
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_UnLoadKey ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_UnLoadKey * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_InitiateSystemShutdown
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_InitiateSystemShutdown ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_InitiateSystemShutdown * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_AbortSystemShutdown
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_AbortSystemShutdown ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_AbortSystemShutdown * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_GetVersion
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_GetVersion ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_GetVersion * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_QueryMultipleValues
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_QueryMultipleValues ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_QueryMultipleValues * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_InitiateSystemShutdownEx
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_InitiateSystemShutdownEx ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_InitiateSystemShutdownEx * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_SaveKeyEx
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_SaveKeyEx ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_SaveKeyEx * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/*
winreg_QueryMultipleValues2
*/
2004-05-04 10:07:52 +04:00
static WERROR winreg_QueryMultipleValues2 ( struct dcesrv_call_state * dce_call , TALLOC_CTX * mem_ctx ,
2004-04-04 20:24:08 +04:00
struct winreg_QueryMultipleValues2 * r )
{
2004-05-04 10:07:52 +04:00
return WERR_NOT_SUPPORTED ;
2004-04-04 20:24:08 +04:00
}
/* include the generated boilerplate */
# include "librpc/gen_ndr/ndr_winreg_s.c"