From 666dba33531c7e7d391318c915fb393ec5b1da36 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 27 Jun 2012 23:24:39 +1000 Subject: s3-param: Rename loadparm_s3_context -> loadparm_s3_helpers This helps clarify the role of this structure and wrapper function. The purpose here is to provide helper functions to the lib/param loadparm_context that point back at the s3 lp_ functions. This allows a struct loadparm_context to be passed to any point in the code, and always refer to the correct loadparm system. If this has not been set, the variables loaded in the lib/param code will be returned. As requested by Michael Adam. Andrew Bartlett Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Wed Jun 27 17:11:16 CEST 2012 on sn-devel-104 --- lib/param/loadparm.c | 4 ++-- lib/param/param.h | 2 +- script/mks3param.pl | 2 +- source3/auth/auth_generic.c | 2 +- source3/auth/auth_samba4.c | 6 +++--- source3/include/proto.h | 2 +- source3/lib/dbwrap/dbwrap_ctdb.c | 2 +- source3/lib/dbwrap/dbwrap_open.c | 2 +- source3/lib/messages_local.c | 4 ++-- source3/lib/server_mutex.c | 2 +- source3/lib/serverid.c | 2 +- source3/libads/authdata.c | 2 +- source3/libsmb/auth_generic.c | 2 +- source3/modules/vfs_dfs_samba4.c | 2 +- source3/modules/vfs_posix_eadb.c | 2 +- source3/param/loadparm_ctx.c | 4 ++-- source3/param/pyparam.c | 4 ++-- source3/passdb/pdb_samba4.c | 2 +- source3/rpc_server/netlogon/srv_netlog_nt.c | 10 +++++----- source3/rpc_server/srv_pipe.c | 2 +- source3/smbd/notify_internal.c | 2 +- source3/smbd/server.c | 2 +- source3/utils/ntlm_auth.c | 2 +- 23 files changed, 33 insertions(+), 33 deletions(-) diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c index 41c8cc62ec..1341581139 100644 --- a/lib/param/loadparm.c +++ b/lib/param/loadparm.c @@ -1362,7 +1362,7 @@ struct loadparm_context { bool refuse_free; bool global; /* Is this the global context, which may set * global variables such as debug level etc? */ - const struct loadparm_s3_context *s3_fns; + const struct loadparm_s3_helpers *s3_fns; }; @@ -3469,7 +3469,7 @@ struct loadparm_context *loadparm_init_global(bool load_default) * Initialise the global parameter structure. */ struct loadparm_context *loadparm_init_s3(TALLOC_CTX *mem_ctx, - const struct loadparm_s3_context *s3_fns) + const struct loadparm_s3_helpers *s3_fns) { struct loadparm_context *loadparm_context = talloc_zero(mem_ctx, struct loadparm_context); if (!loadparm_context) { diff --git a/lib/param/param.h b/lib/param/param.h index e20a10cd99..18d4b29ea0 100644 --- a/lib/param/param.h +++ b/lib/param/param.h @@ -20,7 +20,7 @@ #ifndef _PARAM_H /* _PARAM_H */ #define _PARAM_H -struct loadparm_s3_context; +struct loadparm_s3_helpers; struct parmlist_entry; diff --git a/script/mks3param.pl b/script/mks3param.pl index 376f7ae85f..5c5eea3ce1 100644 --- a/script/mks3param.pl +++ b/script/mks3param.pl @@ -83,7 +83,7 @@ sub print_header($$) $file->("#ifndef $header_name\n"); $file->("#define $header_name\n\n"); $file->("/* This file was automatically generated by mks3param.pl. DO NOT EDIT */\n\n"); - $file->("struct loadparm_s3_context\n"); + $file->("struct loadparm_s3_helpers\n"); $file->("{\n"); $file->("\tconst char * (*get_parametric)(struct loadparm_service *, const char *type, const char *option);\n"); $file->("\tstruct parm_struct * (*get_parm_struct)(const char *param_name);\n"); diff --git a/source3/auth/auth_generic.c b/source3/auth/auth_generic.c index 9b9e96e89b..e941ab9a0e 100644 --- a/source3/auth/auth_generic.c +++ b/source3/auth/auth_generic.c @@ -239,7 +239,7 @@ NTSTATUS auth_generic_prepare(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } - lp_ctx = loadparm_init_s3(tmp_ctx, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(tmp_ctx, loadparm_s3_helpers()); if (lp_ctx == NULL) { DEBUG(10, ("loadparm_init_s3 failed\n")); TALLOC_FREE(tmp_ctx); diff --git a/source3/auth/auth_samba4.c b/source3/auth/auth_samba4.c index 1bf4227b9e..ff73ffb079 100644 --- a/source3/auth/auth_samba4.c +++ b/source3/auth/auth_samba4.c @@ -44,7 +44,7 @@ static NTSTATUS check_samba4_security(const struct auth_context *auth_context, struct auth4_context *auth4_context; struct loadparm_context *lp_ctx; - lp_ctx = loadparm_init_s3(frame, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(frame, loadparm_s3_helpers()); if (lp_ctx == NULL) { DEBUG(10, ("loadparm_init_s3 failed\n")); talloc_free(frame); @@ -109,7 +109,7 @@ static NTSTATUS prepare_gensec(TALLOC_CTX *mem_ctx, struct cli_credentials *server_credentials; struct server_id *server_id; - lp_ctx = loadparm_init_s3(frame, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(frame, loadparm_s3_helpers()); if (lp_ctx == NULL) { DEBUG(1, ("loadparm_init_s3 failed\n")); TALLOC_FREE(frame); @@ -192,7 +192,7 @@ static NTSTATUS make_auth4_context_s4(TALLOC_CTX *mem_ctx, struct imessaging_context *msg_ctx; struct server_id *server_id; - lp_ctx = loadparm_init_s3(frame, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(frame, loadparm_s3_helpers()); if (lp_ctx == NULL) { DEBUG(1, ("loadparm_init_s3 failed\n")); TALLOC_FREE(frame); diff --git a/source3/include/proto.h b/source3/include/proto.h index 69661bb8c5..1fced14d1d 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1504,7 +1504,7 @@ void _lp_set_server_role(int server_role); /* The following definitions come from param/loadparm_ctx.c */ -const struct loadparm_s3_context *loadparm_s3_context(void); +const struct loadparm_s3_helpers *loadparm_s3_helpers(void); /* The following definitions come from param/loadparm_server_role.c */ diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c index 7bb206bea5..1062cb0bbd 100644 --- a/source3/lib/dbwrap/dbwrap_ctdb.c +++ b/source3/lib/dbwrap/dbwrap_ctdb.c @@ -1583,7 +1583,7 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx, return NULL; } - lp_ctx = loadparm_init_s3(db_path, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(db_path, loadparm_s3_helpers()); db_ctdb->wtdb = tdb_wrap_open(db_ctdb, db_path, hash_size, tdb_flags, O_RDWR, 0, lp_ctx); diff --git a/source3/lib/dbwrap/dbwrap_open.c b/source3/lib/dbwrap/dbwrap_open.c index e5adab7eaa..515b4bff1d 100644 --- a/source3/lib/dbwrap/dbwrap_open.c +++ b/source3/lib/dbwrap/dbwrap_open.c @@ -118,7 +118,7 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx, #endif if (result == NULL) { - struct loadparm_context *lp_ctx = loadparm_init_s3(mem_ctx, loadparm_s3_context()); + struct loadparm_context *lp_ctx = loadparm_init_s3(mem_ctx, loadparm_s3_helpers()); result = dbwrap_local_open(mem_ctx, lp_ctx, name, hash_size, tdb_flags, open_flags, mode, lock_order); diff --git a/source3/lib/messages_local.c b/source3/lib/messages_local.c index 74b6a13764..6b63d72925 100644 --- a/source3/lib/messages_local.c +++ b/source3/lib/messages_local.c @@ -104,7 +104,7 @@ NTSTATUS messaging_tdb_init(struct messaging_context *msg_ctx, return NT_STATUS_NO_MEMORY; } - lp_ctx = loadparm_init_s3(result, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(result, loadparm_s3_helpers()); if (lp_ctx == NULL) { DEBUG(0, ("loadparm_init_s3 failed\n")); return NT_STATUS_INTERNAL_ERROR; @@ -158,7 +158,7 @@ bool messaging_tdb_parent_init(TALLOC_CTX *mem_ctx) struct tdb_wrap *db; struct loadparm_context *lp_ctx; - lp_ctx = loadparm_init_s3(mem_ctx, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(mem_ctx, loadparm_s3_helpers()); if (lp_ctx == NULL) { DEBUG(0, ("loadparm_init_s3 failed\n")); return false; diff --git a/source3/lib/server_mutex.c b/source3/lib/server_mutex.c index 9430141d1c..619fbd077f 100644 --- a/source3/lib/server_mutex.c +++ b/source3/lib/server_mutex.c @@ -54,7 +54,7 @@ struct named_mutex *grab_named_mutex(TALLOC_CTX *mem_ctx, const char *name, return NULL; } - lp_ctx = loadparm_init_s3(result, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(result, loadparm_s3_helpers()); if (lp_ctx == NULL) { DEBUG(0, ("loadparm_init_s3 failed\n")); talloc_free(result); diff --git a/source3/lib/serverid.c b/source3/lib/serverid.c index 4e31756620..3068d77a84 100644 --- a/source3/lib/serverid.c +++ b/source3/lib/serverid.c @@ -44,7 +44,7 @@ bool serverid_parent_init(TALLOC_CTX *mem_ctx) struct tdb_wrap *db; struct loadparm_context *lp_ctx; - lp_ctx = loadparm_init_s3(mem_ctx, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(mem_ctx, loadparm_s3_helpers()); if (lp_ctx == NULL) { DEBUG(0, ("loadparm_init_s3 failed\n")); return false; diff --git a/source3/libads/authdata.c b/source3/libads/authdata.c index f4ec5b9075..60897bf5fb 100644 --- a/source3/libads/authdata.c +++ b/source3/libads/authdata.c @@ -238,7 +238,7 @@ NTSTATUS kerberos_return_pac(TALLOC_CTX *mem_ctx, } auth_context->generate_session_info_pac = kerberos_fetch_pac; - lp_ctx = loadparm_init_s3(tmp_ctx, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(tmp_ctx, loadparm_s3_helpers()); if (lp_ctx == NULL) { status = NT_STATUS_INVALID_SERVER_STATE; DEBUG(10, ("loadparm_init_s3 failed\n")); diff --git a/source3/libsmb/auth_generic.c b/source3/libsmb/auth_generic.c index f1510d2e90..ba0a0ce977 100644 --- a/source3/libsmb/auth_generic.c +++ b/source3/libsmb/auth_generic.c @@ -62,7 +62,7 @@ NTSTATUS auth_generic_client_prepare(TALLOC_CTX *mem_ctx, struct auth_generic_st return NT_STATUS_NO_MEMORY; } - lp_ctx = loadparm_init_s3(ans, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(ans, loadparm_s3_helpers()); if (lp_ctx == NULL) { DEBUG(10, ("loadparm_init_s3 failed\n")); TALLOC_FREE(ans); diff --git a/source3/modules/vfs_dfs_samba4.c b/source3/modules/vfs_dfs_samba4.c index ad6f0411a1..200c744889 100644 --- a/source3/modules/vfs_dfs_samba4.c +++ b/source3/modules/vfs_dfs_samba4.c @@ -66,7 +66,7 @@ static int dfs_samba4_connect(struct vfs_handle_struct *handle, return -1; } - data->lp_ctx = loadparm_init_s3(data, loadparm_s3_context()); + data->lp_ctx = loadparm_init_s3(data, loadparm_s3_helpers()); if (data->lp_ctx == NULL) { DEBUG(0, ("loadparm_init_s3 failed\n")); SMB_VFS_NEXT_DISCONNECT(handle); diff --git a/source3/modules/vfs_posix_eadb.c b/source3/modules/vfs_posix_eadb.c index edc295bff0..e1b90ffbc6 100644 --- a/source3/modules/vfs_posix_eadb.c +++ b/source3/modules/vfs_posix_eadb.c @@ -248,7 +248,7 @@ static bool posix_eadb_init(int snum, struct tdb_wrap **p_db) return false; } - lp_ctx = loadparm_init_s3(NULL, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(NULL, loadparm_s3_helpers()); become_root(); db = tdb_wrap_open(NULL, eadb, 50000, diff --git a/source3/param/loadparm_ctx.c b/source3/param/loadparm_ctx.c index 437ce43506..9c78f15879 100644 --- a/source3/param/loadparm_ctx.c +++ b/source3/param/loadparm_ctx.c @@ -60,7 +60,7 @@ static bool lp_load_for_s4_ctx(const char *filename) * All of the s4 loadparm functions should be here eventually, once * they are implemented in the s3 loadparm, have the same format (enum * values in particular) and defaults. */ -static const struct loadparm_s3_context s3_fns = +static const struct loadparm_s3_helpers s3_fns = { .get_parametric = lp_parm_const_string_service, .get_parm_struct = lp_get_parameter, @@ -117,7 +117,7 @@ static const struct loadparm_s3_context s3_fns = .passwordserver = lp_passwordserver }; -const struct loadparm_s3_context *loadparm_s3_context(void) +const struct loadparm_s3_helpers *loadparm_s3_helpers(void) { return &s3_fns; } diff --git a/source3/param/pyparam.c b/source3/param/pyparam.c index ff234ac918..ddd17ca4b5 100644 --- a/source3/param/pyparam.c +++ b/source3/param/pyparam.c @@ -30,7 +30,7 @@ void initparam(void); static PyObject *py_get_context(PyObject *self) { PyObject *py_loadparm; - const struct loadparm_s3_context *s3_context; + const struct loadparm_s3_helpers *s3_context; const struct loadparm_context *s4_context; TALLOC_CTX *mem_ctx; @@ -40,7 +40,7 @@ static PyObject *py_get_context(PyObject *self) return NULL; } - s3_context = loadparm_s3_context(); + s3_context = loadparm_s3_helpers(); s4_context = loadparm_init_s3(mem_ctx, s3_context); if (s4_context == NULL) { diff --git a/source3/passdb/pdb_samba4.c b/source3/passdb/pdb_samba4.c index 3c44b72a05..40827df4ef 100644 --- a/source3/passdb/pdb_samba4.c +++ b/source3/passdb/pdb_samba4.c @@ -2283,7 +2283,7 @@ static NTSTATUS pdb_init_samba4(struct pdb_methods **pdb_method, goto nomem; } - state->lp_ctx = loadparm_init_s3(state, loadparm_s3_context()); + state->lp_ctx = loadparm_init_s3(state, loadparm_s3_helpers()); if (state->lp_ctx == NULL) { DEBUG(0, ("loadparm_init_s3 failed\n")); goto nomem; diff --git a/source3/rpc_server/netlogon/srv_netlog_nt.c b/source3/rpc_server/netlogon/srv_netlog_nt.c index f640a2e81f..1ab1034ae6 100644 --- a/source3/rpc_server/netlogon/srv_netlog_nt.c +++ b/source3/rpc_server/netlogon/srv_netlog_nt.c @@ -1001,7 +1001,7 @@ NTSTATUS _netr_ServerAuthenticate3(struct pipes_struct *p, goto out; } - lp_ctx = loadparm_init_s3(p->mem_ctx, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(p->mem_ctx, loadparm_s3_helpers()); if (lp_ctx == NULL) { DEBUG(10, ("loadparm_init_s3 failed\n")); status = NT_STATUS_INTERNAL_ERROR; @@ -1106,7 +1106,7 @@ static NTSTATUS netr_creds_server_step_check(struct pipes_struct *p, } } - lp_ctx = loadparm_init_s3(mem_ctx, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(mem_ctx, loadparm_s3_helpers()); if (lp_ctx == NULL) { DEBUG(0, ("loadparm_init_s3 failed\n")); return NT_STATUS_INTERNAL_ERROR; @@ -1782,7 +1782,7 @@ NTSTATUS _netr_LogonSamLogonEx(struct pipes_struct *p, return NT_STATUS_INVALID_PARAMETER; } - lp_ctx = loadparm_init_s3(p->mem_ctx, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(p->mem_ctx, loadparm_s3_helpers()); if (lp_ctx == NULL) { DEBUG(0, ("loadparm_init_s3 failed\n")); return NT_STATUS_INTERNAL_ERROR; @@ -2335,7 +2335,7 @@ NTSTATUS _netr_GetForestTrustInformation(struct pipes_struct *p, /* TODO: check server name */ - lp_ctx = loadparm_init_s3(p->mem_ctx, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(p->mem_ctx, loadparm_s3_helpers()); if (lp_ctx == NULL) { DEBUG(0, ("loadparm_init_s3 failed\n")); return NT_STATUS_INTERNAL_ERROR; @@ -2441,7 +2441,7 @@ NTSTATUS _netr_ServerGetTrustInfo(struct pipes_struct *p, DATA_BLOB session_key; struct loadparm_context *lp_ctx; - lp_ctx = loadparm_init_s3(p->mem_ctx, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(p->mem_ctx, loadparm_s3_helpers()); if (lp_ctx == NULL) { DEBUG(0, ("loadparm_init_s3 failed\n")); return NT_STATUS_INTERNAL_ERROR; diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index a870ec14fe..18356382ed 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -447,7 +447,7 @@ static bool pipe_schannel_auth_bind(struct pipes_struct *p, return false; } - lp_ctx = loadparm_init_s3(p, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(p, loadparm_s3_helpers()); if (!lp_ctx) { DEBUG(0,("pipe_schannel_auth_bind: loadparm_init_s3() failed!\n")); return false; diff --git a/source3/smbd/notify_internal.c b/source3/smbd/notify_internal.c index 4fb1b351f3..49d1b06fbf 100644 --- a/source3/smbd/notify_internal.c +++ b/source3/smbd/notify_internal.c @@ -133,7 +133,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, notify->msg = msg; notify->list = NULL; - lp_ctx = loadparm_init_s3(notify, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(notify, loadparm_s3_helpers()); notify->db_notify = db_open_tdb( notify, lp_ctx, lock_path("notify.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 661c2fa7a7..b4b5ae3d91 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -1365,7 +1365,7 @@ extern void build_options(bool screen); } if (lp_server_role() == ROLE_DOMAIN_BDC || lp_server_role() == ROLE_DOMAIN_PDC) { - struct loadparm_context *lp_ctx = loadparm_init_s3(NULL, loadparm_s3_context()); + struct loadparm_context *lp_ctx = loadparm_init_s3(NULL, loadparm_s3_helpers()); if (!open_schannel_session_store(NULL, lp_ctx)) { DEBUG(0,("ERROR: Samba cannot open schannel store for secured NETLOGON operations.\n")); exit(1); diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c index 0f8e54460b..5bf2a7be02 100644 --- a/source3/utils/ntlm_auth.c +++ b/source3/utils/ntlm_auth.c @@ -2900,7 +2900,7 @@ enum { opt_workstation = ""; } - lp_ctx = loadparm_init_s3(NULL, loadparm_s3_context()); + lp_ctx = loadparm_init_s3(NULL, loadparm_s3_helpers()); if (lp_ctx == NULL) { x_fprintf(x_stderr, "loadparm_init_s3() failed!\n"); exit(1); -- cgit