NTSTATUS auth_context_create_methods(TALLOC_CTX *mem_ctx, const char **methods,
struct event_context *ev,
struct messaging_context *msg,
+ struct loadparm_context *lp_ctx,
struct auth_context **auth_ctx)
{
int i;
ctx->methods = NULL;
ctx->event_ctx = ev;
ctx->msg_ctx = msg;
+ ctx->lp_ctx = lp_ctx;
for (i=0; methods[i] ; i++) {
struct auth_method_context *method;
auth_methods = lp_parm_string_list(lp_ctx, NULL, "auth methods", "domain controller", NULL);
break;
}
- return auth_context_create_methods(mem_ctx, auth_methods, ev, msg, auth_ctx);
+ return auth_context_create_methods(mem_ctx, auth_methods, ev, msg, lp_ctx, auth_ctx);
}
/* the messaging context which can be used by backends */
struct messaging_context *msg_ctx;
+
+ /* loadparm context */
+ struct loadparm_context *lp_ctx;
};
/* this structure is used by backends to determine the size of some critical types */
NTSTATUS status;
if (acct_flags & ACB_PWNOTREQ) {
- if (lp_null_passwords(global_loadparm)) {
+ if (lp_null_passwords(auth_context->lp_ctx)) {
DEBUG(3,("Account for user '%s' has no password and null passwords are allowed.\n",
user_info->mapped.account_name));
return NT_STATUS_OK;
*lm_sess_key = data_blob(NULL, 0);
*user_sess_key = data_blob(NULL, 0);
status = hash_password_check(mem_ctx,
+ auth_context->lp_ctx,
user_info->password.hash.lanman,
user_info->password.hash.nt,
user_info->mapped.account_name,
break;
case AUTH_PASSWORD_RESPONSE:
- status = ntlm_password_check(mem_ctx, user_info->logon_parameters,
+ status = ntlm_password_check(mem_ctx,
+ auth_context->lp_ctx,
+ user_info->logon_parameters,
&auth_context->challenge.data,
&user_info->password.response.lanman,
&user_info->password.response.nt,
return NT_STATUS_NO_MEMORY;
}
- sam_ctx = samdb_connect(tmp_ctx, global_loadparm, system_session(mem_ctx));
+ sam_ctx = samdb_connect(tmp_ctx, ctx->auth_ctx->lp_ctx, system_session(mem_ctx));
if (sam_ctx == NULL) {
talloc_free(tmp_ctx);
return NT_STATUS_INVALID_SYSTEM_SERVICE;
return NT_STATUS_NOT_IMPLEMENTED;
}
- is_local_name = lp_is_myname(global_loadparm,
+ is_local_name = lp_is_myname(ctx->auth_ctx->lp_ctx,
user_info->mapped.domain_name);
- is_my_domain = lp_is_mydomain(global_loadparm,
+ is_my_domain = lp_is_mydomain(ctx->auth_ctx->lp_ctx,
user_info->mapped.domain_name);
/* check whether or not we service this domain/workgroup name */
- switch (lp_server_role(global_loadparm)) {
+ switch (lp_server_role(ctx->auth_ctx->lp_ctx)) {
case ROLE_STANDALONE:
return NT_STATUS_OK;
const char *domain;
/* check whether or not we service this domain/workgroup name */
- switch (lp_server_role(global_loadparm)) {
+ switch (lp_server_role(ctx->auth_ctx->lp_ctx)) {
case ROLE_STANDALONE:
case ROLE_DOMAIN_MEMBER:
- domain = lp_netbios_name(global_loadparm);
+ domain = lp_netbios_name(ctx->auth_ctx->lp_ctx);
break;
case ROLE_DOMAIN_CONTROLLER:
- domain = lp_workgroup(global_loadparm);
+ domain = lp_workgroup(ctx->auth_ctx->lp_ctx);
break;
default:
* password file.
*/
- if (lp_is_myname(global_loadparm, user_info->domain.str)) {
+ if (lp_is_myname(auth_context->lp_ctx, user_info->domain.str)) {
DEBUG(3,("check_smbserver_security: Requested domain was for this machine.\n"));
return NT_STATUS_LOGON_FAILURE;
}
_PUBLIC_ NTSTATUS authenticate_username_pw(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct messaging_context *msg,
+ struct loadparm_context *lp_ctx,
const char *nt4_domain,
const char *nt4_username,
const char *password,
nt_status = auth_context_create(tmp_ctx,
ev, msg,
- global_loadparm,
+ lp_ctx,
&auth_context);
if (!NT_STATUS_IS_OK(nt_status)) {
talloc_free(tmp_ctx);
return NT_STATUS_NO_MEMORY;
}
- nt_status = check_unix_password(check_ctx, global_loadparm, user_info, &pwd);
+ nt_status = check_unix_password(check_ctx, ctx->auth_ctx->lp_ctx, user_info, &pwd);
if (!NT_STATUS_IS_OK(nt_status)) {
talloc_free(check_ctx);
return nt_status;
}
chall_blob = data_blob_talloc(mem_ctx, challenge, 8);
- if (lp_client_ntlmv2_auth(global_loadparm)) {
- DATA_BLOB names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_netbios_name(global_loadparm), lp_workgroup(global_loadparm));
+ if (lp_client_ntlmv2_auth(auth_context->lp_ctx)) {
+ DATA_BLOB names_blob = NTLMv2_generate_names_blob(mem_ctx, lp_netbios_name(auth_context->lp_ctx), lp_workgroup(auth_context->lp_ctx));
DATA_BLOB lmv2_response, ntlmv2_response, lmv2_session_key, ntlmv2_session_key;
if (!SMBNTLMv2encrypt_hash(user_info_temp,
SMBOWFencrypt(user_info_in->password.hash.nt->hash, challenge, blob.data);
user_info_temp->password.response.nt = blob;
- if (lp_client_lanman_auth(global_loadparm) && user_info_in->password.hash.lanman) {
+ if (lp_client_lanman_auth(auth_context->lp_ctx) && user_info_in->password.hash.lanman) {
DATA_BLOB lm_blob = data_blob_talloc(mem_ctx, NULL, 24);
SMBOWFencrypt(user_info_in->password.hash.lanman->hash, challenge, blob.data);
user_info_temp->password.response.lanman = lm_blob;
/**
connect to the schannel ldb
*/
-struct ldb_context *schannel_db_connect(TALLOC_CTX *mem_ctx)
+struct ldb_context *schannel_db_connect(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
{
char *path;
struct ldb_context *ldb;
"computerName: CASE_INSENSITIVE\n" \
"flatname: CASE_INSENSITIVE\n";
- path = smbd_tmp_path(mem_ctx, global_loadparm, "schannel.ldb");
+ path = smbd_tmp_path(mem_ctx, lp_ctx, "schannel.ldb");
if (!path) {
return NULL;
}
existed = file_exist(path);
- ldb = ldb_wrap_connect(mem_ctx, global_loadparm, path,
+ ldb = ldb_wrap_connect(mem_ctx, lp_ctx, path,
system_session(mem_ctx),
NULL, LDB_FLG_NOSYNC, NULL);
talloc_free(path);
NTSTATUS nt_status;
int ret;
- ldb = schannel_db_connect(mem_ctx);
+ ldb = schannel_db_connect(mem_ctx, global_loadparm);
if (!ldb) {
return NT_STATUS_ACCESS_DENIED;
}
NTSTATUS nt_status;
struct ldb_context *ldb;
- ldb = schannel_db_connect(mem_ctx);
+ ldb = schannel_db_connect(mem_ctx, global_loadparm);
if (!ldb) {
return NT_STATUS_ACCESS_DENIED;
}
*/
NTSTATUS hash_password_check(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
const struct samr_Password *client_lanman,
const struct samr_Password *client_nt,
const char *username,
}
} else if (client_lanman && stored_lanman) {
- if (!lp_lanman_auth(global_loadparm)) {
+ if (!lp_lanman_auth(lp_ctx)) {
DEBUG(3,("ntlm_password_check: Interactive logon: only LANMAN password supplied for user %s, and LM passwords are disabled!\n",
username));
return NT_STATUS_WRONG_PASSWORD;
*/
NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
uint32_t logon_parameters,
const DATA_BLOB *challenge,
const DATA_BLOB *lm_response,
lm_ok = false;
}
return hash_password_check(mem_ctx,
+ lp_ctx,
lm_ok ? &client_lm : NULL,
nt_response->length ? &client_nt : NULL,
username,
DEBUG(3,("ntlm_password_check: NTLMv2 password check failed\n"));
}
} else if (nt_response->length == 24 && stored_nt) {
- if (lp_ntlm_auth(global_loadparm)) {
+ if (lp_ntlm_auth(lp_ctx)) {
/* We have the NT MD4 hash challenge available - see if we can
use it (ie. does it exist in the smbpasswd file).
*/
/* The LM session key for this response is not very secure,
so use it only if we otherwise allow LM authentication */
- if (lp_lanman_auth(global_loadparm) && stored_lanman) {
+ if (lp_lanman_auth(lp_ctx) && stored_lanman) {
*lm_sess_key = data_blob_talloc(mem_ctx, stored_lanman->hash, 8);
}
return NT_STATUS_OK;
return NT_STATUS_WRONG_PASSWORD;
}
- if (!lp_lanman_auth(global_loadparm)) {
+ if (!lp_lanman_auth(lp_ctx)) {
DEBUG(3,("ntlm_password_check: Lanman passwords NOT PERMITTED for user %s\n",
username));
} else if (!stored_lanman) {
It not very secure, so use it only if we otherwise
allow LM authentication */
- if (lp_lanman_auth(global_loadparm) && stored_lanman) {
+ if (lp_lanman_auth(lp_ctx) && stored_lanman) {
uint8_t first_8_lm_hash[16];
memcpy(first_8_lm_hash, stored_lanman->hash, 8);
memset(first_8_lm_hash + 8, '\0', 8);
- I think this is related to Win9X pass-though authentication
*/
DEBUG(4,("ntlm_password_check: Checking NT MD4 password in LM field\n"));
- if (lp_ntlm_auth(global_loadparm)) {
+ if (lp_ntlm_auth(lp_ctx)) {
if (smb_pwd_check_ntlmv1(mem_ctx,
lm_response,
stored_nt->hash, challenge,
It not very secure, so use it only if we otherwise
allow LM authentication */
- if (lp_lanman_auth(global_loadparm) && stored_lanman) {
+ if (lp_lanman_auth(lp_ctx) && stored_lanman) {
uint8_t first_8_lm_hash[16];
memcpy(first_8_lm_hash, stored_lanman->hash, 8);
memset(first_8_lm_hash + 8, '\0', 8);
/*
open a sidmap context - use talloc_free to close
*/
-_PUBLIC_ struct sidmap_context *sidmap_open(TALLOC_CTX *mem_ctx)
+_PUBLIC_ struct sidmap_context *sidmap_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
{
struct sidmap_context *sidmap;
sidmap = talloc(mem_ctx, struct sidmap_context);
if (sidmap == NULL) {
return NULL;
}
- sidmap->samctx = samdb_connect(sidmap, global_loadparm, system_session(sidmap));
+ sidmap->samctx = samdb_connect(sidmap, lp_ctx, system_session(sidmap));
if (sidmap->samctx == NULL) {
talloc_free(sidmap);
return NULL;
return WERR_OK;
}
-static WERROR dreplsrv_connect_samdb(struct dreplsrv_service *service)
+static WERROR dreplsrv_connect_samdb(struct dreplsrv_service *service, struct loadparm_context *lp_ctx)
{
const struct GUID *ntds_guid;
struct drsuapi_DsBindInfo28 *bind_info28;
- service->samdb = samdb_connect(service, global_loadparm, service->system_session_info);
+ service->samdb = samdb_connect(service, lp_ctx, service->system_session_info);
if (!service->samdb) {
return WERR_DS_SERVICE_UNAVAILABLE;
}
struct dreplsrv_service *service;
uint32_t periodic_startup_interval;
- switch (lp_server_role(global_loadparm)) {
+ switch (lp_server_role(task->lp_ctx)) {
case ROLE_STANDALONE:
task_server_terminate(task, "dreplsrv: no DSDB replication required in standalone configuration");
return;
return;
}
- status = dreplsrv_connect_samdb(service);
+ status = dreplsrv_connect_samdb(service, task->lp_ctx);
if (!W_ERROR_IS_OK(status)) {
task_server_terminate(task, talloc_asprintf(task,
"dreplsrv: Failed to connect to local samdb: %s\n",
return;
}
- periodic_startup_interval = lp_parm_int(global_loadparm, NULL, "dreplsrv", "periodic_startup_interval", 15); /* in seconds */
- service->periodic.interval = lp_parm_int(global_loadparm, NULL, "dreplsrv", "periodic_interval", 300); /* in seconds */
+ periodic_startup_interval = lp_parm_int(task->lp_ctx, NULL, "dreplsrv", "periodic_startup_interval", 15); /* in seconds */
+ service->periodic.interval = lp_parm_int(task->lp_ctx, NULL, "dreplsrv", "periodic_interval", 300); /* in seconds */
status = dreplsrv_periodic_schedule(service, periodic_startup_interval);
if (!W_ERROR_IS_OK(status)) {
#include "dsdb/samdb/samdb.h"
#include "auth/gensec/gensec.h"
#include "auth/gensec/socket.h"
+#include "param/param.h"
static NTSTATUS ldapsrv_BindSimple(struct ldapsrv_call *call)
{
status = crack_auto_name_to_nt4_name(call, req->dn, &nt4_domain, &nt4_account);
if (NT_STATUS_IS_OK(status)) {
- status = authenticate_username_pw(call,
+ status = authenticate_username_pw(global_loadparm, call,
call->conn->connection->event.ctx,
call->conn->connection->msg_ctx,
nt4_domain, nt4_account,
/* Ensure we don't get packets until the database is ready below */
packet_recv_disable(conn->packet);
- server_credentials
- = cli_credentials_init(conn);
+ server_credentials = cli_credentials_init(conn);
if (!server_credentials) {
stream_terminate_connection(c, "Failed to init server credentials\n");
return;
NTSTATUS status;
const struct model_ops *model_ops;
- switch (lp_server_role(global_loadparm)) {
+ switch (lp_server_role(task->lp_ctx)) {
case ROLE_STANDALONE:
task_server_terminate(task, "ldap_server: no LDAP server required in standalone configuration");
return;
#include "lib/dbwrap/dbwrap.h"
#include "param/param.h"
-/*
+/**
open a temporary database
*/
-struct db_context *db_tmp_open(TALLOC_CTX *mem_ctx, const char *name, int tdb_flags)
+struct db_context *db_tmp_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *name, int tdb_flags)
{
- if (lp_parm_bool(global_loadparm, NULL, "ctdb", "enable", false) &&
- lp_parm_bool(global_loadparm, NULL, "ctdb", name, true)) {
+ if (lp_parm_bool(lp_ctx, NULL, "ctdb", "enable", false) &&
+ lp_parm_bool(lp_ctx, NULL, "ctdb", name, true)) {
return db_tmp_open_ctdb(mem_ctx, name, tdb_flags);
}
- return db_tmp_open_tdb(mem_ctx, name, tdb_flags);
+ return db_tmp_open_tdb(mem_ctx, lp_ctx, name, tdb_flags);
}
void *private_data;
};
-struct db_context *db_tmp_open(TALLOC_CTX *mem_ctx, const char *name, int tdb_flags);
+struct loadparm_context;
+struct db_context *db_tmp_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *name, int tdb_flags);
/* backends */
-struct db_context *db_tmp_open_tdb(TALLOC_CTX *mem_ctx, const char *name, int tdb_flags);
+struct db_context *db_tmp_open_tdb(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *name, int tdb_flags);
struct db_context *db_tmp_open_ctdb(TALLOC_CTX *mem_ctx, const char *name, int tdb_flags);
/*
open a temporary database
*/
-struct db_context *db_tmp_open_tdb(TALLOC_CTX *mem_ctx, const char *name, int tdb_flags)
+struct db_context *db_tmp_open_tdb(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
+ const char *name, int tdb_flags)
{
struct db_context *result;
struct db_tdb_ctx *db_tdb;
/* the name passed in should not be a full path, it should be
just be the db name */
- path = smbd_tmp_path(result, global_loadparm, name);
+ path = smbd_tmp_path(result, lp_ctx, name);
db_tdb->wtdb = tdb_wrap_open(db_tdb, path, 0, tdb_flags,
O_CREAT|O_RDWR, 0666);
* false on failure
**/
-bool gencache_init(void)
+bool gencache_init(struct loadparm_context *lp_ctx)
{
char* cache_fname = NULL;
TALLOC_CTX *mem_ctx = talloc_autofree_context();
/* skip file open if it's already opened */
if (cache) return true;
- cache_fname = lock_path(mem_ctx, global_loadparm, "gencache.tdb");
+ cache_fname = lock_path(mem_ctx, lp_ctx, "gencache.tdb");
if (cache_fname != NULL) {
DEBUG(5, ("Opening cache file at %s\n", cache_fname));
} else {
if (ldb_set_opaque(ldb, "credentials", cmdline_credentials)) {
goto failed;
}
+ if (ldb_set_opaque(ldb, "loadparm", global_loadparm)) {
+ goto failed;
+ }
+
ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
#endif
#include "cluster/cluster.h"
#include "ntvfs/common/brlock.h"
#include "ntvfs/ntvfs.h"
+#include "param/param.h"
/*
in this module a "DATA_BLOB *file_key" is a blob that uniquely identifies
return NULL;
}
- brl->db = db_tmp_open(brl, "brlock.tdb", TDB_DEFAULT);
+ brl->db = db_tmp_open(brl, global_loadparm, "brlock.tdb", TDB_DEFAULT);
if (brl->db == NULL) {
talloc_free(brl);
return NULL;
#include "util/util_ldb.h"
#include "libcli/security/security.h"
#include "lib/events/events.h"
-
+#include "param/param.h"
/*
setup config options for a posix share
event_context_find(pvfs),
pvfs->ntvfs->ctx->config);
- pvfs->sidmap = sidmap_open(pvfs);
+ pvfs->sidmap = sidmap_open(pvfs, global_loadparm);
if (pvfs->sidmap == NULL) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
#include "auth/auth.h"
#include "ntvfs/ntvfs.h"
#include "dsdb/samdb/samdb.h"
+#include "param/param.h"
struct unixuid_private {
struct sidmap_context *sidmap;
return NT_STATUS_NO_MEMORY;
}
- private->sidmap = sidmap_open(private);
+ private->sidmap = sidmap_open(private, global_loadparm);
if (private->sidmap == NULL) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
partitions_basedn = samdb_partitions_dn(state->sam_ldb, mem_ctx);
- state->sidmap = sidmap_open(state);
+ state->sidmap = sidmap_open(state, global_loadparm);
if (state->sidmap == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
struct ldb_context *ldb;
int ret;
- ldb = schannel_db_connect(mem_ctx);
+ ldb = schannel_db_connect(mem_ctx, global_loadparm);
if (!ldb) {
return NT_STATUS_ACCESS_DENIED;
}
#include "lib/events/events.h"
#include "dsdb/samdb/samdb.h"
#include "system/passwd.h"
+#include "param/param.h"
static NTSTATUS dcesrv_unixinfo_SidToUid(struct dcesrv_call_state *dce_call,
TALLOC_CTX *mem_ctx,
struct sidmap_context *sidmap;
uid_t uid;
- sidmap = sidmap_open(mem_ctx);
+ sidmap = sidmap_open(mem_ctx, global_loadparm);
if (sidmap == NULL) {
DEBUG(10, ("sidmap_open failed\n"));
return NT_STATUS_NO_MEMORY;
struct sidmap_context *sidmap;
uid_t uid;
- sidmap = sidmap_open(mem_ctx);
+ sidmap = sidmap_open(mem_ctx, global_loadparm);
if (sidmap == NULL) {
DEBUG(10, ("sidmap_open failed\n"));
return NT_STATUS_NO_MEMORY;
struct sidmap_context *sidmap;
gid_t gid;
- sidmap = sidmap_open(mem_ctx);
+ sidmap = sidmap_open(mem_ctx, global_loadparm);
if (sidmap == NULL) {
DEBUG(10, ("sidmap_open failed\n"));
return NT_STATUS_NO_MEMORY;
struct sidmap_context *sidmap;
gid_t gid;
- sidmap = sidmap_open(mem_ctx);
+ sidmap = sidmap_open(mem_ctx, global_loadparm);
if (sidmap == NULL) {
DEBUG(10, ("sidmap_open failed\n"));
return NT_STATUS_NO_MEMORY;
}
if (auth_types) {
- nt_status = auth_context_create_methods(tmp_ctx, auth_types, ev, msg, &auth_context);
+ nt_status = auth_context_create_methods(tmp_ctx, auth_types, ev, msg, global_loadparm, &auth_context);
} else {
nt_status = auth_context_create(tmp_ctx, ev, msg, global_loadparm, &auth_context);
}
/* authenticate a user with an encrypted username/password */
-static NTSTATUS local_pw_check_specified(const char *username,
+static NTSTATUS local_pw_check_specified(struct loadparm_context *lp_ctx,
+ const char *username,
const char *domain,
const char *workstation,
const DATA_BLOB *challenge,
nt_status = ntlm_password_check(mem_ctx,
+ lp_ctx,
MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT |
MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT,
challenge,
flags |= NTLM_AUTH_FLAG_USER_SESSION_KEY;
if (!NT_STATUS_IS_OK(
- local_pw_check_specified(username,
+ local_pw_check_specified(global_loadparm,
+ username,
domain,
lp_netbios_name(global_loadparm),
&challenge,