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 ,
2008-12-29 20:24:57 +01:00
struct tevent_context * ev_ctx ,
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
2012-07-13 00:16:09 +02:00
error = reg_open_remote ( NULL , & h , NULL , creds , lp_ctx , remote , ev_ctx ) ;
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 ,
2008-12-29 20:24:57 +01:00
struct tevent_context * ev_ctx ,
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 ;
2009-01-02 22:41:04 +11:00
error = reg_open_hive ( ev_ctx , path , NULL , creds , ev_ctx , 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 ;
}
2008-04-16 01:32:54 +02:00
error = reg_open_local ( NULL , & h ) ;
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 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 ) ;
}
2008-04-17 12:23:44 +02:00
struct registry_context * reg_common_open_local ( struct cli_credentials * creds ,
2008-12-29 20:24:57 +01:00
struct tevent_context * ev_ctx ,
2008-04-17 12:23:44 +02:00
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
2008-04-17 12:23:44 +02:00
error = reg_open_samba ( NULL , & h , ev_ctx , 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 ;
}