2007-10-10 12:27:24 +02:00
/*
2007-08-26 15:16:40 +00:00
Unix SMB / CIFS implementation .
Popt routines specifically for registry
Copyright ( C ) Jelmer Vernooij 2007
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 3 of the License , or
( at your option ) any later version .
2007-10-10 12:27:24 +02:00
2007-08-26 15:16:40 +00:00
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 .
2007-10-10 12:27:24 +02:00
2007-08-26 15:16:40 +00:00
You should have received a copy of the GNU General Public License
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
# include "includes.h"
# include "auth/credentials/credentials.h"
# include "lib/registry/registry.h"
2007-09-07 13:31:15 +00:00
# include "lib/registry/tools/common.h"
2007-08-26 15:16:40 +00:00
2007-10-10 12:27:24 +02:00
struct registry_context * reg_common_open_remote ( const char * remote ,
2007-12-07 03:01:41 +01:00
struct loadparm_context * lp_ctx ,
2007-10-10 12:27:24 +02:00
struct cli_credentials * creds )
2007-08-26 15:16:40 +00:00
{
2008-01-07 14:11:25 -06:00
struct registry_context * h = NULL ;
2007-08-26 15:16:40 +00:00
WERROR error ;
2007-10-10 12:27:24 +02:00
2007-12-07 03:01:41 +01:00
error = reg_open_remote ( & h , NULL , creds , lp_ctx , remote , NULL ) ;
2007-08-26 15:16:40 +00:00
if ( ! W_ERROR_IS_OK ( error ) ) {
2007-10-10 12:27:24 +02:00
fprintf ( stderr , " Unable to open remote registry at %s:%s \n " ,
remote , win_errstr ( error ) ) ;
2007-08-26 15:16:40 +00:00
return NULL ;
}
return h ;
}
2007-10-10 12:27:24 +02:00
struct registry_key * reg_common_open_file ( const char * path ,
2007-12-14 00:27:31 +01:00
struct loadparm_context * lp_ctx ,
2007-10-10 12:27:24 +02:00
struct cli_credentials * creds )
2007-08-26 15:16:40 +00:00
{
struct hive_key * hive_root ;
2008-01-07 14:11:25 -06:00
struct registry_context * h = NULL ;
2007-08-26 15:16:40 +00:00
WERROR error ;
2007-12-14 00:27:31 +01:00
error = reg_open_hive ( NULL , path , NULL , creds , lp_ctx , & hive_root ) ;
2007-08-26 15:16:40 +00:00
if ( ! W_ERROR_IS_OK ( error ) ) {
2007-10-10 12:27:24 +02:00
fprintf ( stderr , " Unable to open '%s': %s \n " ,
path , win_errstr ( error ) ) ;
2007-08-26 15:16:40 +00:00
return NULL ;
}
error = reg_open_local ( NULL , & h , NULL , creds ) ;
if ( ! W_ERROR_IS_OK ( error ) ) {
2007-10-10 12:27:24 +02:00
fprintf ( stderr , " Unable to initialize local registry: %s \n " ,
win_errstr ( error ) ) ;
2007-08-26 15:16:40 +00:00
return NULL ;
}
return reg_import_hive_key ( h , hive_root , - 1 , NULL ) ;
}
2007-12-02 22:32:11 +01:00
struct registry_context * reg_common_open_local ( struct cli_credentials * creds , struct loadparm_context * lp_ctx )
2007-08-26 15:16:40 +00:00
{
WERROR error ;
2008-01-07 14:11:25 -06:00
struct registry_context * h = NULL ;
2007-10-10 12:27:24 +02:00
2007-12-02 22:32:11 +01:00
error = reg_open_samba ( NULL , & h , lp_ctx , NULL , creds ) ;
2007-08-26 15:16:40 +00:00
if ( ! W_ERROR_IS_OK ( error ) ) {
2007-10-10 12:27:24 +02:00
fprintf ( stderr , " Unable to open local registry:%s \n " ,
win_errstr ( error ) ) ;
2007-08-26 15:16:40 +00:00
return NULL ;
}
return h ;
}