1
0
mirror of https://github.com/samba-team/samba.git synced 2025-11-23 20:23:50 +03:00

r26235: Avoid global_loadparm.

This commit is contained in:
Jelmer Vernooij
2007-12-02 21:32:08 +01:00
committed by Stefan Metzmacher
parent 84892d030d
commit e903978220
9 changed files with 34 additions and 29 deletions

View File

@@ -163,6 +163,7 @@ _PUBLIC_ struct auth_session_info *system_session(TALLOC_CTX *mem_ctx)
}
static NTSTATUS _auth_system_session_info(TALLOC_CTX *parent_ctx,
struct loadparm_context *lp_ctx,
bool anonymous_credentials,
struct auth_session_info **_session_info)
{
@@ -171,7 +172,7 @@ static NTSTATUS _auth_system_session_info(TALLOC_CTX *parent_ctx,
struct auth_session_info *session_info = NULL;
TALLOC_CTX *mem_ctx = talloc_new(parent_ctx);
nt_status = auth_system_server_info(mem_ctx, lp_netbios_name(global_loadparm),
nt_status = auth_system_server_info(mem_ctx, lp_netbios_name(lp_ctx),
&server_info);
if (!NT_STATUS_IS_OK(nt_status)) {
talloc_free(mem_ctx);
@@ -189,7 +190,7 @@ static NTSTATUS _auth_system_session_info(TALLOC_CTX *parent_ctx,
return NT_STATUS_NO_MEMORY;
}
cli_credentials_set_conf(session_info->credentials, global_loadparm);
cli_credentials_set_conf(session_info->credentials, lp_ctx);
if (anonymous_credentials) {
cli_credentials_set_anonymous(session_info->credentials);
@@ -208,7 +209,7 @@ _PUBLIC_ struct auth_session_info *system_session_anon(TALLOC_CTX *mem_ctx)
{
NTSTATUS nt_status;
struct auth_session_info *session_info = NULL;
nt_status = _auth_system_session_info(mem_ctx, false, &session_info);
nt_status = _auth_system_session_info(mem_ctx, global_loadparm, false, &session_info);
if (!NT_STATUS_IS_OK(nt_status)) {
return NULL;
}
@@ -221,6 +222,7 @@ _PUBLIC_ NTSTATUS auth_system_session_info(TALLOC_CTX *parent_ctx,
struct auth_session_info **_session_info)
{
return _auth_system_session_info(parent_ctx,
global_loadparm,
lp_parm_bool(global_loadparm, NULL, "system", "anonymous", false),
_session_info);
}

View File

@@ -84,7 +84,8 @@ static void cldapd_request_handler(struct cldap_socket *cldap,
/*
start listening on the given address
*/
static NTSTATUS cldapd_add_socket(struct cldapd_server *cldapd, const char *address)
static NTSTATUS cldapd_add_socket(struct cldapd_server *cldapd, struct loadparm_context *lp_ctx,
const char *address)
{
struct cldap_socket *cldapsock;
struct socket_address *socket_address;
@@ -95,7 +96,7 @@ static NTSTATUS cldapd_add_socket(struct cldapd_server *cldapd, const char *addr
NT_STATUS_HAVE_NO_MEMORY(cldapsock);
socket_address = socket_address_from_strings(cldapsock, cldapsock->sock->backend_name,
address, lp_cldap_port(global_loadparm));
address, lp_cldap_port(lp_ctx));
if (!socket_address) {
talloc_free(cldapsock);
return NT_STATUS_NO_MEMORY;
@@ -104,7 +105,7 @@ static NTSTATUS cldapd_add_socket(struct cldapd_server *cldapd, const char *addr
status = socket_listen(cldapsock->sock, socket_address, 0, 0);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Failed to bind to %s:%d - %s\n",
address, lp_cldap_port(global_loadparm), nt_errstr(status)));
address, lp_cldap_port(lp_ctx), nt_errstr(status)));
talloc_free(cldapsock);
return status;
}
@@ -120,7 +121,7 @@ static NTSTATUS cldapd_add_socket(struct cldapd_server *cldapd, const char *addr
/*
setup our listening sockets on the configured network interfaces
*/
static NTSTATUS cldapd_startup_interfaces(struct cldapd_server *cldapd)
static NTSTATUS cldapd_startup_interfaces(struct cldapd_server *cldapd, struct loadparm_context *lp_ctx)
{
int num_interfaces = iface_count();
TALLOC_CTX *tmp_ctx = talloc_new(cldapd);
@@ -128,15 +129,15 @@ static NTSTATUS cldapd_startup_interfaces(struct cldapd_server *cldapd)
/* if we are allowing incoming packets from any address, then
we need to bind to the wildcard address */
if (!lp_bind_interfaces_only(global_loadparm)) {
status = cldapd_add_socket(cldapd, "0.0.0.0");
if (!lp_bind_interfaces_only(lp_ctx)) {
status = cldapd_add_socket(cldapd, lp_ctx, "0.0.0.0");
NT_STATUS_NOT_OK_RETURN(status);
} else {
int i;
for (i=0; i<num_interfaces; i++) {
const char *address = talloc_strdup(tmp_ctx, iface_n_ip(i));
status = cldapd_add_socket(cldapd, address);
status = cldapd_add_socket(cldapd, lp_ctx, address);
NT_STATUS_NOT_OK_RETURN(status);
}
}
@@ -187,7 +188,7 @@ static void cldapd_task_init(struct task_server *task)
}
/* start listening on the configured network interfaces */
status = cldapd_startup_interfaces(cldapd);
status = cldapd_startup_interfaces(cldapd, task->lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
task_server_terminate(task, "cldapd failed to setup interfaces");
return;

View File

@@ -727,7 +727,7 @@ int samdb_copy_template(struct ldb_context *ldb,
return LDB_ERR_OPERATIONS_ERROR;
}
templates_ldb = ldb_wrap_connect(ldb, global_loadparm,
templates_ldb = ldb_wrap_connect(ldb, (struct loadparm_context *)ldb_get_opaque(ldb, "loadparm"),
templates_ldb_path, NULL,
NULL, 0, NULL);
talloc_free(templates_ldb_path);

View File

@@ -65,7 +65,7 @@ static NTSTATUS torture_smb2_close(struct smb2_tree *tree, struct smb2_handle ha
/*
test writing
*/
static NTSTATUS torture_smb2_write(struct smb2_tree *tree, struct smb2_handle handle)
static NTSTATUS torture_smb2_write(struct torture_context *tctx, struct smb2_tree *tree, struct smb2_handle handle)
{
struct smb2_write w;
struct smb2_read r;
@@ -74,9 +74,9 @@ static NTSTATUS torture_smb2_write(struct smb2_tree *tree, struct smb2_handle ha
DATA_BLOB data;
int i;
if (lp_parm_bool(global_loadparm, NULL, "torture", "dangerous", false)) {
if (torture_setting_bool(tctx, "dangerous", false)) {
data = data_blob_talloc(tree, NULL, 160000);
} else if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) {
} else if (torture_setting_bool(tctx, "samba4", false)) {
data = data_blob_talloc(tree, NULL, UINT16_MAX);
} else {
data = data_blob_talloc(tree, NULL, 120000);
@@ -202,7 +202,7 @@ bool torture_smb2_connect(struct torture_context *torture)
h1 = torture_smb2_create(tree, "test9.dat");
h2 = torture_smb2_create(tree, "test9.dat");
status = torture_smb2_write(tree, h1);
status = torture_smb2_write(torture, tree, h1);
if (!NT_STATUS_IS_OK(status)) {
printf("Write failed - %s\n", nt_errstr(status));
return false;

View File

@@ -388,7 +388,7 @@ static void http_simple_request(struct websrv_context *web)
const char *path;
struct stat st;
path = http_local_path(web, url, lp_swat_directory(global_loadparm));
path = http_local_path(web, url, lp_swat_directory(web->task->lp_ctx));
if (path == NULL) goto invalid;
/* looks ok */
@@ -470,7 +470,7 @@ static void http_setup_arrays(struct esp_state *esp)
talloc_asprintf(esp, "%u", socket_address->port));
}
SETVAR(ESP_SERVER_OBJ, "DOCUMENT_ROOT", lp_swat_directory(global_loadparm));
SETVAR(ESP_SERVER_OBJ, "DOCUMENT_ROOT", lp_swat_directory(esp->web->task->lp_ctx));
SETVAR(ESP_SERVER_OBJ, "SERVER_PROTOCOL", tls_enabled(web->conn->socket)?"https":"http");
SETVAR(ESP_SERVER_OBJ, "SERVER_SOFTWARE", "SAMBA");
SETVAR(ESP_SERVER_OBJ, "GATEWAY_INTERFACE", "CGI/1.1");
@@ -515,7 +515,7 @@ static void esp_request(struct esp_state *esp, const char *url)
int res;
char *emsg = NULL, *buf;
if (http_readFile(web, &buf, &size, url, lp_swat_directory(global_loadparm)) != 0) {
if (http_readFile(web, &buf, &size, url, lp_swat_directory(esp->web->task->lp_ctx)) != 0) {
http_error_unix(web, url);
return;
}
@@ -547,7 +547,7 @@ static bool http_preauth(struct esp_state *esp)
{
const char *path = http_local_path(esp->web,
HTTP_PREAUTH_URI,
lp_swat_directory(global_loadparm));
lp_swat_directory(esp->web->task->lp_ctx));
int i;
if (path == NULL) {
http_error(esp->web, 500, "Internal server error");
@@ -734,7 +734,7 @@ static void http_setup_session(struct esp_state *esp)
s->data = NULL;
s->te = NULL;
s->edata = edata;
s->lifetime = lp_parm_int(global_loadparm, NULL, "web", "sessiontimeout", 900);
s->lifetime = lp_parm_int(esp->web->task->lp_ctx, NULL, "web", "sessiontimeout", 900);
DLIST_ADD(edata->sessions, s);
talloc_set_destructor(s, session_destructor);
if (!generated_key) {

View File

@@ -23,10 +23,10 @@
#include "libcli/composite/composite.h"
#include "winbind/wb_server.h"
#include "winbind/wb_async_helpers.h"
#include "param/param.h"
#include "winbind/wb_helper.h"
#include "smbd/service_task.h"
#include "libnet/libnet_proto.h"
#include "param/param.h"
#include "libcli/security/proto.h"
struct cmd_getpwnam_state {
@@ -86,7 +86,7 @@ static void cmd_getpwnam_recv_domain(struct composite_context *ctx)
user_info = talloc(state, struct libnet_UserInfo);
if (composite_nomem(user_info, state->ctx)) return;
ok= wb_samba3_split_username(state, state->name, &user_dom, &user_name);
ok= wb_samba3_split_username(state, global_loadparm, state->name, &user_dom, &user_name);
if(!ok){
composite_error(state->ctx, NT_STATUS_OBJECT_NAME_INVALID);
return;

View File

@@ -24,6 +24,7 @@
#include "winbind/wb_server.h"
#include "smbd/service_task.h"
#include "winbind/wb_helper.h"
#include "param/param.h"
struct name2domain_state {
struct composite_context *ctx;
@@ -54,7 +55,7 @@ struct composite_context *wb_name2domain_send(TALLOC_CTX *mem_ctx,
result->private_data = state;
state->service = service;
ok = wb_samba3_split_username(state, name, &user_dom, &user_name);
ok = wb_samba3_split_username(state, global_loadparm, name, &user_dom, &user_name);
if(!ok) {
composite_error(state->ctx, NT_STATUS_OBJECT_NAME_INVALID);
return result;

View File

@@ -23,13 +23,13 @@
#include "includes.h"
#include "winbind/wb_server.h"
#include "winbind/wb_async_helpers.h"
#include "param/param.h"
#include "winbind/wb_helper.h"
#include "libcli/composite/composite.h"
#include "version.h"
#include "librpc/gen_ndr/netlogon.h"
#include "libcli/security/security.h"
#include "auth/pam_errors.h"
#include "param/param.h"
/*
Send off the reply to an async Samba3 query, handling filling in the PAM, NTSTATUS and string errors.
@@ -545,7 +545,7 @@ NTSTATUS wbsrv_samba3_pam_auth(struct wbsrv_samba3_call *s3call)
s3call->wbconn->listen_socket->service;
char *user, *domain;
if (!wb_samba3_split_username(s3call,
if (!wb_samba3_split_username(s3call, global_loadparm,
s3call->request.data.auth.user,
&domain, &user)) {
return NT_STATUS_NO_SUCH_USER;

View File

@@ -27,13 +27,14 @@
* as one string.
* TODO: We probably will need to handle other formats later. */
bool wb_samba3_split_username(TALLOC_CTX *mem_ctx, const char *domuser,
bool wb_samba3_split_username(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
const char *domuser,
char **domain, char **user)
{
char *p = strchr(domuser, *lp_winbind_separator(global_loadparm));
char *p = strchr(domuser, *lp_winbind_separator(lp_ctx));
if (p == NULL) {
*domain = talloc_strdup(mem_ctx, lp_workgroup(global_loadparm));
*domain = talloc_strdup(mem_ctx, lp_workgroup(lp_ctx));
} else {
*domain = talloc_strndup(mem_ctx, domuser,
PTR_DIFF(p, domuser));