2006-07-11 18:01:26 +00:00
/*
* Unix SMB / CIFS implementation .
* Registry helper routines
* Copyright ( C ) Volker Lendecke 2006
*
* 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
2007-07-09 19:25:36 +00:00
* Software Foundation ; either version 3 of the License , or ( at your option )
2006-07-11 18:01:26 +00:00
* 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
2007-07-10 05:23:25 +00:00
* this program ; if not , see < http : //www.gnu.org/licenses/>.
2006-07-11 18:01:26 +00:00
*/
# include "includes.h"
2007-09-28 23:05:52 +00:00
# undef DBGC_CLASS
# define DBGC_CLASS DBGC_REGISTRY
2007-06-14 11:29:35 +00:00
extern REGISTRY_OPS smbconf_reg_ops ;
2006-11-21 21:18:53 +00:00
const char * reg_type_lookup ( enum winreg_Type type )
2006-07-11 18:01:26 +00:00
{
const char * result ;
switch ( type ) {
case REG_NONE :
result = " REG_NONE " ;
break ;
case REG_SZ :
result = " REG_SZ " ;
break ;
case REG_EXPAND_SZ :
result = " REG_EXPAND_SZ " ;
break ;
case REG_BINARY :
result = " REG_BINARY " ;
break ;
case REG_DWORD :
result = " REG_DWORD " ;
break ;
2006-09-27 19:03:54 +00:00
case REG_DWORD_BIG_ENDIAN :
result = " REG_DWORD_BIG_ENDIAN " ;
2006-07-11 18:01:26 +00:00
break ;
case REG_LINK :
result = " REG_LINK " ;
break ;
case REG_MULTI_SZ :
result = " REG_MULTI_SZ " ;
break ;
case REG_RESOURCE_LIST :
result = " REG_RESOURCE_LIST " ;
break ;
case REG_FULL_RESOURCE_DESCRIPTOR :
result = " REG_FULL_RESOURCE_DESCRIPTOR " ;
break ;
case REG_RESOURCE_REQUIREMENTS_LIST :
result = " REG_RESOURCE_REQUIREMENTS_LIST " ;
break ;
case REG_QWORD :
result = " REG_QWORD " ;
break ;
default :
result = " REG TYPE IS UNKNOWN " ;
break ;
}
return result ;
}
2006-12-01 20:01:09 +00:00
WERROR reg_pull_multi_sz ( TALLOC_CTX * mem_ctx , const void * buf , size_t len ,
uint32 * num_values , char * * * values )
2006-07-11 18:01:26 +00:00
{
const smb_ucs2_t * p = ( const smb_ucs2_t * ) buf ;
* num_values = 0 ;
/*
* Make sure that a talloc context for the strings retrieved exists
*/
if ( ! ( * values = TALLOC_ARRAY ( mem_ctx , char * , 1 ) ) ) {
2006-12-01 20:01:09 +00:00
return WERR_NOMEM ;
2006-07-11 18:01:26 +00:00
}
len / = 2 ; /* buf is a set of UCS2 strings */
while ( len > 0 ) {
char * val ;
size_t dstlen , thislen ;
thislen = strnlen_w ( p , len ) + 1 ;
2006-09-21 18:37:09 +00:00
dstlen = convert_string_allocate ( * values , CH_UTF16LE , CH_UNIX ,
2006-07-11 18:01:26 +00:00
p , thislen * 2 , ( void * ) & val ,
2008-02-14 15:35:07 +01:00
true ) ;
2006-07-11 18:01:26 +00:00
if ( dstlen = = ( size_t ) - 1 ) {
TALLOC_FREE ( * values ) ;
2006-12-01 20:01:09 +00:00
return WERR_NOMEM ;
2006-07-11 18:01:26 +00:00
}
ADD_TO_ARRAY ( * values , char * , val , values , num_values ) ;
if ( * values = = NULL ) {
2006-12-01 20:01:09 +00:00
return WERR_NOMEM ;
2006-07-11 18:01:26 +00:00
}
p + = thislen ;
len - = thislen ;
}
2006-12-01 20:01:09 +00:00
return WERR_OK ;
2006-07-11 18:01:26 +00:00
}
2007-06-15 15:51:45 +00:00
void normalize_dbkey ( char * key )
{
size_t len = strlen ( key ) ;
string_sub ( key , " \\ " , " / " , len + 1 ) ;
strupper_m ( key ) ;
}
2007-06-28 10:32:52 +00:00
/*
* check whether a given value name is forbidden in registry ( smbconf )
*/
2007-10-18 17:40:25 -07:00
bool registry_smbconf_valname_forbidden ( const char * valname )
2007-06-28 10:32:52 +00:00
{
/* hard code the list of forbidden names here for now */
const char * forbidden_valnames [ ] = {
" include " ,
" lock directory " ,
" lock dir " ,
2008-01-16 17:31:44 +01:00
" config backend " ,
2007-06-28 10:32:52 +00:00
NULL
} ;
const char * * forbidden = NULL ;
for ( forbidden = forbidden_valnames ; * forbidden ! = NULL ; forbidden + + ) {
if ( strwicmp ( valname , * forbidden ) = = 0 ) {
2008-02-14 15:35:07 +01:00
return true ;
2007-06-28 10:32:52 +00:00
}
}
2008-02-14 15:35:07 +01:00
return false ;
2007-06-28 10:32:52 +00:00
}