2006-07-11 22:01:26 +04: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 23:25:36 +04:00
* Software Foundation ; either version 3 of the License , or ( at your option )
2006-07-11 22:01:26 +04: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 09:23:25 +04:00
* this program ; if not , see < http : //www.gnu.org/licenses/>.
2006-07-11 22:01:26 +04:00
*/
# include "includes.h"
2007-09-29 03:05:52 +04:00
# undef DBGC_CLASS
# define DBGC_CLASS DBGC_REGISTRY
2007-06-14 15:29:35 +04:00
extern REGISTRY_OPS smbconf_reg_ops ;
2006-11-22 00:18:53 +03:00
const char * reg_type_lookup ( enum winreg_Type type )
2006-07-11 22:01:26 +04: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 23:03:54 +04:00
case REG_DWORD_BIG_ENDIAN :
result = " REG_DWORD_BIG_ENDIAN " ;
2006-07-11 22:01:26 +04: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 23:01:09 +03:00
WERROR reg_pull_multi_sz ( TALLOC_CTX * mem_ctx , const void * buf , size_t len ,
uint32 * num_values , char * * * values )
2006-07-11 22:01:26 +04: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 23:01:09 +03:00
return WERR_NOMEM ;
2006-07-11 22:01:26 +04: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 22:37:09 +04:00
dstlen = convert_string_allocate ( * values , CH_UTF16LE , CH_UNIX ,
2006-07-11 22:01:26 +04:00
p , thislen * 2 , ( void * ) & val ,
True ) ;
if ( dstlen = = ( size_t ) - 1 ) {
TALLOC_FREE ( * values ) ;
2006-12-01 23:01:09 +03:00
return WERR_NOMEM ;
2006-07-11 22:01:26 +04:00
}
ADD_TO_ARRAY ( * values , char * , val , values , num_values ) ;
if ( * values = = NULL ) {
2006-12-01 23:01:09 +03:00
return WERR_NOMEM ;
2006-07-11 22:01:26 +04:00
}
p + = thislen ;
len - = thislen ;
}
2006-12-01 23:01:09 +03:00
return WERR_OK ;
2006-07-11 22:01:26 +04:00
}
2007-06-15 19:51:45 +04:00
void normalize_dbkey ( char * key )
{
size_t len = strlen ( key ) ;
string_sub ( key , " \\ " , " / " , len + 1 ) ;
strupper_m ( key ) ;
}
2007-06-28 14:32:52 +04:00
/*
* check whether a given value name is forbidden in registry ( smbconf )
*/
2007-10-19 04:40:25 +04:00
bool registry_smbconf_valname_forbidden ( const char * valname )
2007-06-28 14:32:52 +04:00
{
/* hard code the list of forbidden names here for now */
const char * forbidden_valnames [ ] = {
" include " ,
" lock directory " ,
" lock dir " ,
2008-01-16 19:31:44 +03:00
" config backend " ,
2007-06-28 14:32:52 +04:00
NULL
} ;
const char * * forbidden = NULL ;
for ( forbidden = forbidden_valnames ; * forbidden ! = NULL ; forbidden + + ) {
if ( strwicmp ( valname , * forbidden ) = = 0 ) {
return True ;
}
}
return False ;
}