1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-03 13:47:25 +03:00

r26227: Make loadparm_context part of a server task, move loadparm_contexts further up the call stack.

This commit is contained in:
Jelmer Vernooij 2007-12-02 17:09:52 +01:00 committed by Stefan Metzmacher
parent 6cbce47a3e
commit 0721a07aad
27 changed files with 157 additions and 134 deletions

View File

@ -22,8 +22,8 @@
#include "includes.h" #include "includes.h"
#include "librpc/gen_ndr/ndr_netlogon.h" #include "librpc/gen_ndr/ndr_netlogon.h"
#include "system/time.h" #include "system/time.h"
#include "util/util_ldb.h"
#include "lib/ldb/include/ldb.h" #include "lib/ldb/include/ldb.h"
#include "util/util_ldb.h"
#include "auth/auth.h" #include "auth/auth.h"
#include "auth/auth_sam.h" #include "auth/auth_sam.h"
#include "dsdb/samdb/samdb.h" #include "dsdb/samdb/samdb.h"
@ -283,7 +283,7 @@ static NTSTATUS authsam_check_password_internals(struct auth_method_context *ctx
return NT_STATUS_NO_MEMORY; return NT_STATUS_NO_MEMORY;
} }
sam_ctx = samdb_connect(tmp_ctx, system_session(mem_ctx)); sam_ctx = samdb_connect(tmp_ctx, global_loadparm, system_session(mem_ctx));
if (sam_ctx == NULL) { if (sam_ctx == NULL) {
talloc_free(tmp_ctx); talloc_free(tmp_ctx);
return NT_STATUS_INVALID_SYSTEM_SERVICE; return NT_STATUS_INVALID_SYSTEM_SERVICE;

View File

@ -439,7 +439,7 @@ NTSTATUS sam_get_server_info_principal(TALLOC_CTX *mem_ctx, const char *principa
return NT_STATUS_NO_MEMORY; return NT_STATUS_NO_MEMORY;
} }
sam_ctx = samdb_connect(tmp_ctx, system_session(tmp_ctx)); sam_ctx = samdb_connect(tmp_ctx, global_loadparm, system_session(tmp_ctx));
if (sam_ctx == NULL) { if (sam_ctx == NULL) {
talloc_free(tmp_ctx); talloc_free(tmp_ctx);
return NT_STATUS_INVALID_SYSTEM_SERVICE; return NT_STATUS_INVALID_SYSTEM_SERVICE;

View File

@ -159,7 +159,7 @@ static void cldapd_task_init(struct task_server *task)
return; return;
} }
switch (lp_server_role(global_loadparm)) { switch (lp_server_role(task->lp_ctx)) {
case ROLE_STANDALONE: case ROLE_STANDALONE:
task_server_terminate(task, "cldap_server: no CLDAP server required in standalone configuration"); task_server_terminate(task, "cldap_server: no CLDAP server required in standalone configuration");
return; return;
@ -180,7 +180,7 @@ static void cldapd_task_init(struct task_server *task)
} }
cldapd->task = task; cldapd->task = task;
cldapd->samctx = samdb_connect(cldapd, anonymous_session(cldapd)); cldapd->samctx = samdb_connect(cldapd, task->lp_ctx, anonymous_session(cldapd));
if (cldapd->samctx == NULL) { if (cldapd->samctx == NULL) {
task_server_terminate(task, "cldapd failed to open samdb"); task_server_terminate(task, "cldapd failed to open samdb");
return; return;

View File

@ -27,6 +27,7 @@
#include "libcli/ldap/ldap.h" #include "libcli/ldap/ldap.h"
#include "util/util_ldb.h" #include "util/util_ldb.h"
#include "libcli/security/security.h" #include "libcli/security/security.h"
#include "param/param.h"
/* /*
these are used for the fallback local uid/gid to sid mapping these are used for the fallback local uid/gid to sid mapping
@ -54,7 +55,7 @@ _PUBLIC_ struct sidmap_context *sidmap_open(TALLOC_CTX *mem_ctx)
if (sidmap == NULL) { if (sidmap == NULL) {
return NULL; return NULL;
} }
sidmap->samctx = samdb_connect(sidmap, system_session(sidmap)); sidmap->samctx = samdb_connect(sidmap, global_loadparm, system_session(sidmap));
if (sidmap->samctx == NULL) { if (sidmap->samctx == NULL) {
talloc_free(sidmap); talloc_free(sidmap);
return NULL; return NULL;

View File

@ -50,7 +50,7 @@ static WERROR dreplsrv_connect_samdb(struct dreplsrv_service *service)
const struct GUID *ntds_guid; const struct GUID *ntds_guid;
struct drsuapi_DsBindInfo28 *bind_info28; struct drsuapi_DsBindInfo28 *bind_info28;
service->samdb = samdb_connect(service, service->system_session_info); service->samdb = samdb_connect(service, global_loadparm, service->system_session_info);
if (!service->samdb) { if (!service->samdb) {
return WERR_DS_SERVICE_UNAVAILABLE; return WERR_DS_SERVICE_UNAVAILABLE;
} }

View File

@ -33,6 +33,7 @@
#include "auth/auth.h" #include "auth/auth.h"
#include "util/util_ldb.h" #include "util/util_ldb.h"
#include "dsdb/samdb/samdb.h" #include "dsdb/samdb/samdb.h"
#include "param/param.h"
static WERROR DsCrackNameOneFilter(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx, static WERROR DsCrackNameOneFilter(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ctx,
struct smb_krb5_context *smb_krb5_context, struct smb_krb5_context *smb_krb5_context,
@ -1210,7 +1211,7 @@ NTSTATUS crack_name_to_nt4_name(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK; return NT_STATUS_OK;
} }
ldb = samdb_connect(mem_ctx, system_session(mem_ctx)); ldb = samdb_connect(mem_ctx, global_loadparm, system_session(mem_ctx));
if (ldb == NULL) { if (ldb == NULL) {
return NT_STATUS_INTERNAL_DB_CORRUPTION; return NT_STATUS_INTERNAL_DB_CORRUPTION;
} }

View File

@ -71,11 +71,12 @@ char *samdb_relative_path(struct ldb_context *ldb,
return an opaque context pointer on success, or NULL on failure return an opaque context pointer on success, or NULL on failure
*/ */
struct ldb_context *samdb_connect(TALLOC_CTX *mem_ctx, struct ldb_context *samdb_connect(TALLOC_CTX *mem_ctx,
struct loadparm_context *lp_ctx,
struct auth_session_info *session_info) struct auth_session_info *session_info)
{ {
struct ldb_context *ldb; struct ldb_context *ldb;
ldb = ldb_wrap_connect(mem_ctx, global_loadparm, ldb = ldb_wrap_connect(mem_ctx, lp_ctx,
lp_sam_url(global_loadparm), session_info, lp_sam_url(lp_ctx), session_info,
NULL, 0, NULL); NULL, 0, NULL);
if (!ldb) { if (!ldb) {
return NULL; return NULL;

View File

@ -26,6 +26,7 @@ struct auth_session_info;
struct dsdb_control_current_partition; struct dsdb_control_current_partition;
struct dsdb_extended_replicated_object; struct dsdb_extended_replicated_object;
struct dsdb_extended_replicated_objects; struct dsdb_extended_replicated_objects;
struct loadparm_context;
#include "librpc/gen_ndr/security.h" #include "librpc/gen_ndr/security.h"
#include "lib/ldb/include/ldb.h" #include "lib/ldb/include/ldb.h"

View File

@ -25,6 +25,7 @@
#include "auth/auth.h" #include "auth/auth.h"
#include "libcli/security/security.h" #include "libcli/security/security.h"
#include "util/util_ldb.h" #include "util/util_ldb.h"
#include "param/param.h"
/* /*
add privilege bits for one sid to a security_token add privilege bits for one sid to a security_token
@ -96,7 +97,7 @@ _PUBLIC_ NTSTATUS samdb_privilege_setup(struct security_token *token)
} }
mem_ctx = talloc_new(token); mem_ctx = talloc_new(token);
samctx = samdb_connect(mem_ctx, system_session(mem_ctx)); samctx = samdb_connect(mem_ctx, global_loadparm, system_session(mem_ctx));
if (samctx == NULL) { if (samctx == NULL) {
talloc_free(mem_ctx); talloc_free(mem_ctx);
return NT_STATUS_INTERNAL_DB_CORRUPTION; return NT_STATUS_INTERNAL_DB_CORRUPTION;

View File

@ -1133,7 +1133,7 @@ NTSTATUS kdc_hdb_ldb_create(TALLOC_CTX *mem_ctx,
CRED_DONT_USE_KERBEROS); CRED_DONT_USE_KERBEROS);
/* Setup the link to LDB */ /* Setup the link to LDB */
(*db)->hdb_db = samdb_connect(*db, session_info); (*db)->hdb_db = samdb_connect(*db, global_loadparm, session_info);
if ((*db)->hdb_db == NULL) { if ((*db)->hdb_db == NULL) {
DEBUG(1, ("hdb_ldb_create: Cannot open samdb for KDC backend!")); DEBUG(1, ("hdb_ldb_create: Cannot open samdb for KDC backend!"));
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;

View File

@ -180,7 +180,7 @@ static bool kpasswdd_change_password(struct kdc_server *kdc,
struct samr_DomInfo1 *dominfo; struct samr_DomInfo1 *dominfo;
struct ldb_context *samdb; struct ldb_context *samdb;
samdb = samdb_connect(mem_ctx, system_session(mem_ctx)); samdb = samdb_connect(mem_ctx, global_loadparm, system_session(mem_ctx));
if (!samdb) { if (!samdb) {
return kpasswdd_make_error_reply(kdc, mem_ctx, return kpasswdd_make_error_reply(kdc, mem_ctx,
KRB5_KPASSWD_HARDERROR, KRB5_KPASSWD_HARDERROR,
@ -310,7 +310,7 @@ static bool kpasswd_process_request(struct kdc_server *kdc,
krb5_free_principal(context, principal); krb5_free_principal(context, principal);
samdb = samdb_connect(mem_ctx, session_info); samdb = samdb_connect(mem_ctx, global_loadparm, session_info);
if (!samdb) { if (!samdb) {
return kpasswdd_make_error_reply(kdc, mem_ctx, return kpasswdd_make_error_reply(kdc, mem_ctx,
KRB5_KPASSWD_HARDERROR, KRB5_KPASSWD_HARDERROR,

View File

@ -441,6 +441,7 @@ static const struct stream_server_ops ldap_stream_ops = {
add a socket address to the list of events, one event per port add a socket address to the list of events, one event per port
*/ */
static NTSTATUS add_socket(struct event_context *event_context, static NTSTATUS add_socket(struct event_context *event_context,
struct loadparm_context *lp_ctx,
const struct model_ops *model_ops, const struct model_ops *model_ops,
const char *address, struct ldapsrv_service *ldap_service) const char *address, struct ldapsrv_service *ldap_service)
{ {
@ -471,7 +472,7 @@ static NTSTATUS add_socket(struct event_context *event_context,
} }
/* Load LDAP database */ /* Load LDAP database */
ldb = samdb_connect(ldap_service, system_session(ldap_service)); ldb = samdb_connect(ldap_service, lp_ctx, system_session(ldap_service));
if (!ldb) { if (!ldb) {
return NT_STATUS_INTERNAL_DB_CORRUPTION; return NT_STATUS_INTERNAL_DB_CORRUPTION;
} }
@ -538,7 +539,7 @@ static void ldapsrv_task_init(struct task_server *task)
ldap_service->tls_params = tls_initialise(ldap_service); ldap_service->tls_params = tls_initialise(ldap_service);
if (ldap_service->tls_params == NULL) goto failed; if (ldap_service->tls_params == NULL) goto failed;
if (lp_interfaces(global_loadparm) && lp_bind_interfaces_only(global_loadparm)) { if (lp_interfaces(task->lp_ctx) && lp_bind_interfaces_only(task->lp_ctx)) {
int num_interfaces = iface_count(); int num_interfaces = iface_count();
int i; int i;
@ -548,16 +549,16 @@ static void ldapsrv_task_init(struct task_server *task)
*/ */
for(i = 0; i < num_interfaces; i++) { for(i = 0; i < num_interfaces; i++) {
const char *address = iface_n_ip(i); const char *address = iface_n_ip(i);
status = add_socket(task->event_ctx, model_ops, address, ldap_service); status = add_socket(task->event_ctx, task->lp_ctx, model_ops, address, ldap_service);
if (!NT_STATUS_IS_OK(status)) goto failed; if (!NT_STATUS_IS_OK(status)) goto failed;
} }
} else { } else {
status = add_socket(task->event_ctx, model_ops, status = add_socket(task->event_ctx, task->lp_ctx, model_ops,
lp_socket_address(global_loadparm), ldap_service); lp_socket_address(task->lp_ctx), ldap_service);
if (!NT_STATUS_IS_OK(status)) goto failed; if (!NT_STATUS_IS_OK(status)) goto failed;
} }
ldapi_path = private_path(ldap_service, global_loadparm, "ldapi"); ldapi_path = private_path(ldap_service, task->lp_ctx, "ldapi");
if (!ldapi_path) { if (!ldapi_path) {
goto failed; goto failed;
} }

View File

@ -53,7 +53,7 @@ static void nbtd_netlogon_getdc(struct dgram_mailslot_handler *dgmslot,
return; return;
} }
samctx = samdb_connect(packet, anonymous_session(packet)); samctx = samdb_connect(packet, global_loadparm, anonymous_session(packet));
if (samctx == NULL) { if (samctx == NULL) {
DEBUG(2,("Unable to open sam in getdc reply\n")); DEBUG(2,("Unable to open sam in getdc reply\n"));
return; return;
@ -123,7 +123,7 @@ static void nbtd_netlogon_getdc2(struct dgram_mailslot_handler *dgmslot,
return; return;
} }
samctx = samdb_connect(packet, anonymous_session(packet)); samctx = samdb_connect(packet, global_loadparm, anonymous_session(packet));
if (samctx == NULL) { if (samctx == NULL) {
DEBUG(2,("Unable to open sam in getdc reply\n")); DEBUG(2,("Unable to open sam in getdc reply\n"));
return; return;

View File

@ -62,7 +62,7 @@ static void nbtd_task_init(struct task_server *task)
return; return;
} }
nbtsrv->sam_ctx = samdb_connect(nbtsrv, anonymous_session(nbtsrv)); nbtsrv->sam_ctx = samdb_connect(nbtsrv, task->lp_ctx, anonymous_session(nbtsrv));
if (nbtsrv->sam_ctx == NULL) { if (nbtsrv->sam_ctx == NULL) {
task_server_terminate(task, "nbtd failed to open samdb"); task_server_terminate(task, "nbtd failed to open samdb");
return; return;

View File

@ -2127,7 +2127,7 @@ static void dump_a_service(struct loadparm_service * pService, FILE * f)
} }
} }
bool lp_dump_a_parameter(struct loadparm_context *lp_ctx, int snum, char *parm_name, FILE * f, bool lp_dump_a_parameter(struct loadparm_context *lp_ctx, int snum, const char *parm_name, FILE * f,
bool isGlobal) bool isGlobal)
{ {
struct loadparm_service * pService = lp_ctx->ServicePtrs[snum]; struct loadparm_service * pService = lp_ctx->ServicePtrs[snum];

View File

@ -118,7 +118,7 @@ _PUBLIC_ uint32_t dcesrv_common_get_server_type(TALLOC_CTX *mem_ctx, struct dces
break; break;
} }
/* open main ldb */ /* open main ldb */
samctx = samdb_connect(tmp_ctx, anonymous_session(tmp_ctx)); samctx = samdb_connect(tmp_ctx, global_loadparm, anonymous_session(tmp_ctx));
if (samctx == NULL) { if (samctx == NULL) {
DEBUG(2,("Unable to open samdb in determining server announce flags\n")); DEBUG(2,("Unable to open samdb in determining server announce flags\n"));
} else { } else {

View File

@ -27,6 +27,7 @@
#include "rpc_server/drsuapi/dcesrv_drsuapi.h" #include "rpc_server/drsuapi/dcesrv_drsuapi.h"
#include "dsdb/samdb/samdb.h" #include "dsdb/samdb/samdb.h"
#include "lib/ldb/include/ldb_errors.h" #include "lib/ldb/include/ldb_errors.h"
#include "param/param.h"
/* /*
drsuapi_DsBind drsuapi_DsBind
@ -57,7 +58,7 @@ static WERROR dcesrv_drsuapi_DsBind(struct dcesrv_call_state *dce_call, TALLOC_C
/* /*
* connect to the samdb * connect to the samdb
*/ */
b_state->sam_ctx = samdb_connect(b_state, dce_call->conn->auth_state.session_info); b_state->sam_ctx = samdb_connect(b_state, global_loadparm, dce_call->conn->auth_state.session_info);
if (!b_state->sam_ctx) { if (!b_state->sam_ctx) {
return WERR_FOOBAR; return WERR_FOOBAR;
} }

View File

@ -50,7 +50,7 @@ NTSTATUS dcesrv_lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_
} }
/* make sure the sam database is accessible */ /* make sure the sam database is accessible */
state->sam_ldb = samdb_connect(state, dce_call->conn->auth_state.session_info); state->sam_ldb = samdb_connect(state, global_loadparm, dce_call->conn->auth_state.session_info);
if (state->sam_ldb == NULL) { if (state->sam_ldb == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE; return NT_STATUS_INVALID_SYSTEM_SERVICE;
} }

View File

@ -92,7 +92,7 @@ static NTSTATUS dcesrv_netr_ServerAuthenticate3(struct dcesrv_call_state *dce_ca
return NT_STATUS_ACCESS_DENIED; return NT_STATUS_ACCESS_DENIED;
} }
sam_ctx = samdb_connect(mem_ctx, system_session(mem_ctx)); sam_ctx = samdb_connect(mem_ctx, global_loadparm, system_session(mem_ctx));
if (sam_ctx == NULL) { if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE; return NT_STATUS_INVALID_SYSTEM_SERVICE;
} }
@ -301,7 +301,7 @@ static NTSTATUS dcesrv_netr_ServerPasswordSet(struct dcesrv_call_state *dce_call
&creds); &creds);
NT_STATUS_NOT_OK_RETURN(nt_status); NT_STATUS_NOT_OK_RETURN(nt_status);
sam_ctx = samdb_connect(mem_ctx, system_session(mem_ctx)); sam_ctx = samdb_connect(mem_ctx, global_loadparm, system_session(mem_ctx));
if (sam_ctx == NULL) { if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE; return NT_STATUS_INVALID_SYSTEM_SERVICE;
} }
@ -339,7 +339,7 @@ static NTSTATUS dcesrv_netr_ServerPasswordSet2(struct dcesrv_call_state *dce_cal
&creds); &creds);
NT_STATUS_NOT_OK_RETURN(nt_status); NT_STATUS_NOT_OK_RETURN(nt_status);
sam_ctx = samdb_connect(mem_ctx, system_session(mem_ctx)); sam_ctx = samdb_connect(mem_ctx, global_loadparm, system_session(mem_ctx));
if (sam_ctx == NULL) { if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE; return NT_STATUS_INVALID_SYSTEM_SERVICE;
} }
@ -885,7 +885,7 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct dcesrv_call_state *dce_cal
NULL); NULL);
NT_STATUS_NOT_OK_RETURN(status); NT_STATUS_NOT_OK_RETURN(status);
sam_ctx = samdb_connect(mem_ctx, dce_call->conn->auth_state.session_info); sam_ctx = samdb_connect(mem_ctx, global_loadparm, dce_call->conn->auth_state.session_info);
if (sam_ctx == NULL) { if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE; return NT_STATUS_INVALID_SYSTEM_SERVICE;
} }
@ -989,7 +989,7 @@ static WERROR dcesrv_netr_DsRGetDCNameEx2(struct dcesrv_call_state *dce_call, TA
ZERO_STRUCT(r->out); ZERO_STRUCT(r->out);
sam_ctx = samdb_connect(mem_ctx, dce_call->conn->auth_state.session_info); sam_ctx = samdb_connect(mem_ctx, global_loadparm, dce_call->conn->auth_state.session_info);
if (sam_ctx == NULL) { if (sam_ctx == NULL) {
return WERR_DS_SERVICE_UNAVAILABLE; return WERR_DS_SERVICE_UNAVAILABLE;
} }
@ -1147,7 +1147,7 @@ static WERROR dcesrv_netr_DsrEnumerateDomainTrusts(struct dcesrv_call_state *dce
ZERO_STRUCT(r->out); ZERO_STRUCT(r->out);
sam_ctx = samdb_connect(mem_ctx, dce_call->conn->auth_state.session_info); sam_ctx = samdb_connect(mem_ctx, global_loadparm, dce_call->conn->auth_state.session_info);
if (sam_ctx == NULL) { if (sam_ctx == NULL) {
return WERR_GENERAL_FAILURE; return WERR_GENERAL_FAILURE;
} }

View File

@ -141,7 +141,7 @@ static NTSTATUS dcesrv_samr_Connect(struct dcesrv_call_state *dce_call, TALLOC_C
} }
/* make sure the sam database is accessible */ /* make sure the sam database is accessible */
c_state->sam_ctx = samdb_connect(c_state, dce_call->conn->auth_state.session_info); c_state->sam_ctx = samdb_connect(c_state, global_loadparm, dce_call->conn->auth_state.session_info);
if (c_state->sam_ctx == NULL) { if (c_state->sam_ctx == NULL) {
talloc_free(c_state); talloc_free(c_state);
return NT_STATUS_INVALID_SYSTEM_SERVICE; return NT_STATUS_INVALID_SYSTEM_SERVICE;
@ -4086,7 +4086,7 @@ static NTSTATUS dcesrv_samr_GetDomPwInfo(struct dcesrv_call_state *dce_call, TAL
ZERO_STRUCT(r->out.info); ZERO_STRUCT(r->out.info);
sam_ctx = samdb_connect(mem_ctx, dce_call->conn->auth_state.session_info); sam_ctx = samdb_connect(mem_ctx, global_loadparm, dce_call->conn->auth_state.session_info);
if (sam_ctx == NULL) { if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE; return NT_STATUS_INVALID_SYSTEM_SERVICE;
} }

View File

@ -33,6 +33,7 @@
#include "rpc_server/samr/proto.h" #include "rpc_server/samr/proto.h"
#include "libcli/auth/libcli_auth.h" #include "libcli/auth/libcli_auth.h"
#include "util/util_ldb.h" #include "util/util_ldb.h"
#include "param/param.h"
/* /*
samr_ChangePasswordUser samr_ChangePasswordUser
@ -64,7 +65,7 @@ NTSTATUS dcesrv_samr_ChangePasswordUser(struct dcesrv_call_state *dce_call, TALL
} }
/* To change a password we need to open as system */ /* To change a password we need to open as system */
sam_ctx = samdb_connect(mem_ctx, system_session(mem_ctx)); sam_ctx = samdb_connect(mem_ctx, global_loadparm, system_session(mem_ctx));
if (sam_ctx == NULL) { if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE; return NT_STATUS_INVALID_SYSTEM_SERVICE;
} }
@ -203,7 +204,7 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call,
} }
/* To change a password we need to open as system */ /* To change a password we need to open as system */
sam_ctx = samdb_connect(mem_ctx, system_session(mem_ctx)); sam_ctx = samdb_connect(mem_ctx, global_loadparm, system_session(mem_ctx));
if (sam_ctx == NULL) { if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE; return NT_STATUS_INVALID_SYSTEM_SERVICE;
} }
@ -341,7 +342,7 @@ NTSTATUS dcesrv_samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call,
} }
/* To change a password we need to open as system */ /* To change a password we need to open as system */
sam_ctx = samdb_connect(mem_ctx, system_session(mem_ctx)); sam_ctx = samdb_connect(mem_ctx, global_loadparm, system_session(mem_ctx));
if (sam_ctx == NULL) { if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE; return NT_STATUS_INVALID_SYSTEM_SERVICE;
} }

View File

@ -203,7 +203,7 @@ static void smbsrv_preopen_ldb(struct task_server *task)
/* yes, this looks strange. It is a hack to preload the /* yes, this looks strange. It is a hack to preload the
schema. I'd like to share most of the ldb context with the schema. I'd like to share most of the ldb context with the
child too. That will come later */ child too. That will come later */
talloc_free(samdb_connect(task, NULL)); talloc_free(samdb_connect(task, global_loadparm, NULL));
} }
/* /*

View File

@ -64,9 +64,10 @@ static void task_server_callback(struct event_context *event_ctx,
task->event_ctx = event_ctx; task->event_ctx = event_ctx;
task->model_ops = state->model_ops; task->model_ops = state->model_ops;
task->server_id = server_id; task->server_id = server_id;
task->lp_ctx = global_loadparm;
task->msg_ctx = messaging_init(task, task->msg_ctx = messaging_init(task,
lp_messaging_path(task, global_loadparm), lp_messaging_path(task, task->lp_ctx),
task->server_id, task->event_ctx); task->server_id, task->event_ctx);
if (!task->msg_ctx) { if (!task->msg_ctx) {
task_server_terminate(task, "messaging_init() failed"); task_server_terminate(task, "messaging_init() failed");

View File

@ -28,6 +28,7 @@ struct task_server {
struct event_context *event_ctx; struct event_context *event_ctx;
const struct model_ops *model_ops; const struct model_ops *model_ops;
struct messaging_context *msg_ctx; struct messaging_context *msg_ctx;
struct loadparm_context *lp_ctx;
struct server_id server_id; struct server_id server_id;
void *private; void *private;
}; };

View File

@ -72,10 +72,107 @@ static int do_global_checks(struct loadparm_context *lp_ctx)
return ret; return ret;
} }
static int do_share_checks(struct loadparm_context *lp_ctx, const char *cname, const char *caddr, bool silent_mode,
bool show_defaults, const char *section_name, const char *parameter_name)
{
int ret = 0;
int s;
for (s=0;s<lp_numservices(lp_ctx);s++) {
struct loadparm_service *service = lp_servicebynum(lp_ctx, s);
if (service != NULL)
if (strlen(lp_servicename(lp_servicebynum(lp_ctx, s))) > 12) {
fprintf(stderr, "WARNING: You have some share names that are longer than 12 characters.\n" );
fprintf(stderr, "These may not be accessible to some older clients.\n" );
fprintf(stderr, "(Eg. Windows9x, WindowsMe, and not listed in smbclient in Samba 3.0.)\n" );
break;
}
}
for (s=0;s<lp_numservices(lp_ctx);s++) {
struct loadparm_service *service = lp_servicebynum(lp_ctx, s);
if (service != NULL) {
const char **deny_list = lp_hostsdeny(service);
const char **allow_list = lp_hostsallow(service);
int i;
if(deny_list) {
for (i=0; deny_list[i]; i++) {
char *hasstar = strchr_m(deny_list[i], '*');
char *hasquery = strchr_m(deny_list[i], '?');
if(hasstar || hasquery) {
fprintf(stderr,"Invalid character %c in hosts deny list (%s) for service %s.\n",
hasstar ? *hasstar : *hasquery, deny_list[i], lp_servicename(service) );
}
}
}
if(allow_list) {
for (i=0; allow_list[i]; i++) {
char *hasstar = strchr_m(allow_list[i], '*');
char *hasquery = strchr_m(allow_list[i], '?');
if(hasstar || hasquery) {
fprintf(stderr,"Invalid character %c in hosts allow list (%s) for service %s.\n",
hasstar ? *hasstar : *hasquery, allow_list[i], lp_servicename(service) );
}
}
}
}
}
if (!cname) {
if (!silent_mode) {
fprintf(stderr,"Press enter to see a dump of your service definitions\n");
fflush(stdout);
getc(stdin);
}
if (section_name || parameter_name) {
struct loadparm_service *service = NULL;
if (!section_name) {
section_name = GLOBAL_NAME;
service = NULL;
} else if ((!strwicmp(section_name, GLOBAL_NAME)) == 0 &&
(service=lp_service(lp_ctx, section_name)) == NULL) {
fprintf(stderr,"Unknown section %s\n",
section_name);
return(1);
}
if (!parameter_name) {
lp_dump_one(stdout, show_defaults, service);
} else {
ret = !lp_dump_a_parameter(lp_ctx, s, parameter_name, stdout, (service == NULL));
}
} else {
lp_dump(lp_ctx, stdout, show_defaults, lp_numservices(lp_ctx));
}
return(ret);
}
if(cname && caddr){
/* this is totally ugly, a real `quick' hack */
for (s=0;s<lp_numservices(lp_ctx);s++) {
struct loadparm_service *service = lp_servicebynum(lp_ctx, s);
if (service != NULL) {
if (allow_access(NULL, lp_hostsdeny(NULL), lp_hostsallow(NULL), cname, caddr)
&& allow_access(NULL, lp_hostsdeny(service), lp_hostsallow(service), cname, caddr)) {
fprintf(stderr,"Allow connection from %s (%s) to %s\n",
cname,caddr,lp_servicename(service));
} else {
fprintf(stderr,"Deny connection from %s (%s) to %s\n",
cname,caddr,lp_servicename(service));
}
}
}
}
return ret;
}
int main(int argc, const char *argv[]) int main(int argc, const char *argv[])
{ {
int s; static bool silent_mode = false;
static int silent_mode = 0;
int ret = 0; int ret = 0;
poptContext pc; poptContext pc;
/* /*
@ -86,12 +183,12 @@ static int do_global_checks(struct loadparm_context *lp_ctx)
static char *parameter_name = NULL; static char *parameter_name = NULL;
static const char *cname; static const char *cname;
static const char *caddr; static const char *caddr;
static int show_defaults; static bool show_defaults = false;
struct poptOption long_options[] = { struct poptOption long_options[] = {
POPT_AUTOHELP POPT_AUTOHELP
{"suppress-prompt", 0, POPT_ARG_NONE, &silent_mode, 1, "Suppress prompt for enter"}, {"suppress-prompt", 0, POPT_ARG_NONE, &silent_mode, true, "Suppress prompt for enter"},
{"verbose", 'v', POPT_ARG_NONE, &show_defaults, 1, "Show default options too"}, {"verbose", 'v', POPT_ARG_NONE, &show_defaults, true, "Show default options too"},
/* /*
We need support for smb.conf macros before this will work again We need support for smb.conf macros before this will work again
{"server", 'L',POPT_ARG_STRING, &new_local_machine, 0, "Set %%L macro to servername\n"}, {"server", 'L',POPT_ARG_STRING, &new_local_machine, 0, "Set %%L macro to servername\n"},
@ -150,92 +247,8 @@ static int do_global_checks(struct loadparm_context *lp_ctx)
ret = do_global_checks(global_loadparm); ret = do_global_checks(global_loadparm);
for (s=0;s<lp_numservices(global_loadparm);s++) { ret |= do_share_checks(global_loadparm, cname, caddr, silent_mode, show_defaults, section_name, parameter_name);
struct loadparm_service *service = lp_servicebynum(global_loadparm, s);
if (service != NULL)
if (strlen(lp_servicename(lp_servicebynum(global_loadparm, s))) > 12) {
fprintf(stderr, "WARNING: You have some share names that are longer than 12 characters.\n" );
fprintf(stderr, "These may not be accessible to some older clients.\n" );
fprintf(stderr, "(Eg. Windows9x, WindowsMe, and not listed in smbclient in Samba 3.0.)\n" );
break;
}
}
for (s=0;s<lp_numservices(global_loadparm);s++) {
struct loadparm_service *service = lp_servicebynum(global_loadparm, s);
if (service != NULL) {
const char **deny_list = lp_hostsdeny(service);
const char **allow_list = lp_hostsallow(service);
int i;
if(deny_list) {
for (i=0; deny_list[i]; i++) {
char *hasstar = strchr_m(deny_list[i], '*');
char *hasquery = strchr_m(deny_list[i], '?');
if(hasstar || hasquery) {
fprintf(stderr,"Invalid character %c in hosts deny list (%s) for service %s.\n",
hasstar ? *hasstar : *hasquery, deny_list[i], lp_servicename(service) );
}
}
}
if(allow_list) {
for (i=0; allow_list[i]; i++) {
char *hasstar = strchr_m(allow_list[i], '*');
char *hasquery = strchr_m(allow_list[i], '?');
if(hasstar || hasquery) {
fprintf(stderr,"Invalid character %c in hosts allow list (%s) for service %s.\n",
hasstar ? *hasstar : *hasquery, allow_list[i], lp_servicename(service) );
}
}
}
}
}
if (!cname) {
if (!silent_mode) {
fprintf(stderr,"Press enter to see a dump of your service definitions\n");
fflush(stdout);
getc(stdin);
}
if (section_name || parameter_name) {
struct loadparm_service *service = NULL;
if (!section_name) {
section_name = GLOBAL_NAME;
service = NULL;
} else if ((!strwicmp(section_name, GLOBAL_NAME)) == 0 &&
(service=lp_service(global_loadparm, section_name)) == NULL) {
fprintf(stderr,"Unknown section %s\n",
section_name);
return(1);
}
if (!parameter_name) {
lp_dump_one(stdout, show_defaults, service);
} else {
ret = !lp_dump_a_parameter(global_loadparm, s, parameter_name, stdout, (service == NULL));
}
} else {
lp_dump(global_loadparm, stdout, show_defaults, lp_numservices(global_loadparm));
}
return(ret);
}
if(cname && caddr){
/* this is totally ugly, a real `quick' hack */
for (s=0;s<lp_numservices(global_loadparm);s++) {
struct loadparm_service *service = lp_servicebynum(global_loadparm, s);
if (service != NULL) {
if (allow_access(NULL, lp_hostsdeny(NULL), lp_hostsallow(NULL), cname, caddr)
&& allow_access(NULL, lp_hostsdeny(service), lp_hostsallow(service), cname, caddr)) {
fprintf(stderr,"Allow connection from %s (%s) to %s\n",
cname,caddr,lp_servicename(service));
} else {
fprintf(stderr,"Deny connection from %s (%s) to %s\n",
cname,caddr,lp_servicename(service));
}
}
}
}
return(ret); return(ret);
} }

View File

@ -241,7 +241,7 @@ static const struct stream_server_ops web_stream_ops = {
static void websrv_task_init(struct task_server *task) static void websrv_task_init(struct task_server *task)
{ {
NTSTATUS status; NTSTATUS status;
uint16_t port = lp_web_port(global_loadparm); uint16_t port = lp_web_port(task->lp_ctx);
const struct model_ops *model_ops; const struct model_ops *model_ops;
task_server_set_title(task, "task[websrv]"); task_server_set_title(task, "task[websrv]");
@ -250,7 +250,7 @@ static void websrv_task_init(struct task_server *task)
model_ops = process_model_byname("single"); model_ops = process_model_byname("single");
if (!model_ops) goto failed; if (!model_ops) goto failed;
if (lp_interfaces(global_loadparm) && lp_bind_interfaces_only(global_loadparm)) { if (lp_interfaces(task->lp_ctx) && lp_bind_interfaces_only(task->lp_ctx)) {
int num_interfaces = iface_count(); int num_interfaces = iface_count();
int i; int i;
for(i = 0; i < num_interfaces; i++) { for(i = 0; i < num_interfaces; i++) {
@ -264,7 +264,7 @@ static void websrv_task_init(struct task_server *task)
} else { } else {
status = stream_setup_socket(task->event_ctx, model_ops, status = stream_setup_socket(task->event_ctx, model_ops,
&web_stream_ops, &web_stream_ops,
"ipv4", lp_socket_address(global_loadparm), "ipv4", lp_socket_address(task->lp_ctx),
&port, task); &port, task);
if (!NT_STATUS_IS_OK(status)) goto failed; if (!NT_STATUS_IS_OK(status)) goto failed;
} }

View File

@ -458,7 +458,7 @@ static void wreplsrv_task_init(struct task_server *task)
/* /*
* setup up all partners, and open the winsdb * setup up all partners, and open the winsdb
*/ */
status = wreplsrv_open_winsdb(service, global_loadparm); status = wreplsrv_open_winsdb(service, task->lp_ctx);
if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status)) {
task_server_terminate(task, "wreplsrv_task_init: wreplsrv_open_winsdb() failed"); task_server_terminate(task, "wreplsrv_task_init: wreplsrv_open_winsdb() failed");
return; return;