1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-26 01:49:31 +03:00

Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-trivial

(This used to be commit 52a8d06f00)
This commit is contained in:
Jelmer Vernooij
2008-02-21 16:11:13 +01:00
19 changed files with 1215 additions and 23 deletions

1
.gitignore vendored
View File

@ -129,6 +129,7 @@ source/utils/net/net_proto.h
source/web_server/proto.h
source/winbind/wb_helper.h
source/winbind/wb_proto.h
source/winbind/idmap_proto.h
source/wrepl_server/wrepl_server_proto.h
tags
source/auth/credentials/credentials_krb5_proto.h

View File

@ -99,7 +99,6 @@ OBJ_FILES = modules/skel.o
SUBSYSTEM = LIBLDB
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC SQLITE3 LIBTALLOC
INIT_FUNCTION = &ldb_sqlite3_module_ops
OBJ_FILES = \
ldb_sqlite3/ldb_sqlite3.o
# End MODULE ldb_sqlite3

View File

@ -1903,7 +1903,7 @@ failed:
return -1;
}
_PUBLIC_ const struct ldb_backend_ops ldb_sqlite3_backend_ops = {
const struct ldb_backend_ops ldb_sqlite3_backend_ops = {
.name = "sqlite3",
.connect_fn = lsqlite3_connect
};

View File

@ -960,7 +960,7 @@ import "misc.idl", "lsa.idl", "security.idl";
typedef struct {
uint32 idx;
lsa_AsciiString account_name;
lsa_AsciiStringLarge account_name;
} samr_DispEntryAscii;
typedef struct {

View File

@ -1127,7 +1127,16 @@ import "security.idl", "svcctl.idl";
/* srvsvc_NetDisk */
/**************************/
typedef struct {
[flag(STR_LEN4)] string disk;
/*
* In theory this should be:
* [charset(UTF16),string] uint16 annotation[3]
* But midl treats this as:
* [charset(UTF16),string] uint16 annotation[]
* and pidl doesn't support this yet
*/
[value(0)] uint32 __disk_offset;
[value(strlen(disk)+1)] uint32 __disk_length;
[charset(UTF16)] uint16 disk[__disk_length];
} srvsvc_NetDiskInfo0;
typedef struct {

View File

@ -91,6 +91,7 @@ struct loadparm_global
char *szPasswdChat;
char *szShareBackend;
char *szSAM_URL;
char *szIDMAP_URL;
char *szSECRETS_URL;
char *szSPOOLSS_URL;
char *szWINS_CONFIG_URL;
@ -119,6 +120,7 @@ struct loadparm_global
char *szTemplateShell;
char *szTemplateHomedir;
int bWinbindSealedPipes;
int bIdmapTrustedOnly;
char *swat_directory;
int tls_enabled;
char *tls_keyfile;
@ -384,6 +386,7 @@ static struct parm_struct parm_table[] = {
{"obey pam restrictions", P_BOOL, P_GLOBAL, GLOBAL_VAR(bObeyPamRestrictions), NULL, NULL},
{"password server", P_LIST, P_GLOBAL, GLOBAL_VAR(szPasswordServers), NULL, NULL},
{"sam database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSAM_URL), NULL, NULL},
{"idmap database", P_STRING, P_GLOBAL, GLOBAL_VAR(szIDMAP_URL), NULL, NULL},
{"secrets database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSECRETS_URL), NULL, NULL},
{"spoolss database", P_STRING, P_GLOBAL, GLOBAL_VAR(szSPOOLSS_URL), NULL, NULL},
{"wins config database", P_STRING, P_GLOBAL, GLOBAL_VAR(szWINS_CONFIG_URL), NULL, NULL},
@ -513,6 +516,7 @@ static struct parm_struct parm_table[] = {
{"winbind sealed pipes", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWinbindSealedPipes), NULL, NULL },
{"template shell", P_STRING, P_GLOBAL, GLOBAL_VAR(szTemplateShell), NULL, NULL },
{"template homedir", P_STRING, P_GLOBAL, GLOBAL_VAR(szTemplateHomedir), NULL, NULL },
{"idmap trusted only", P_BOOL, P_GLOBAL, GLOBAL_VAR(bIdmapTrustedOnly), NULL, NULL},
{NULL, P_BOOL, P_NONE, 0, NULL, NULL}
};
@ -642,6 +646,7 @@ _PUBLIC_ FN_GLOBAL_STRING(lp_tls_crlfile, tls_crlfile)
_PUBLIC_ FN_GLOBAL_STRING(lp_tls_dhpfile, tls_dhpfile)
_PUBLIC_ FN_GLOBAL_STRING(lp_share_backend, szShareBackend)
_PUBLIC_ FN_GLOBAL_STRING(lp_sam_url, szSAM_URL)
_PUBLIC_ FN_GLOBAL_STRING(lp_idmap_url, szIDMAP_URL)
_PUBLIC_ FN_GLOBAL_STRING(lp_secrets_url, szSECRETS_URL)
_PUBLIC_ FN_GLOBAL_STRING(lp_spoolss_url, szSPOOLSS_URL)
_PUBLIC_ FN_GLOBAL_STRING(lp_wins_config_url, szWINS_CONFIG_URL)
@ -651,6 +656,7 @@ _PUBLIC_ FN_GLOBAL_CONST_STRING(lp_winbindd_socket_directory, szWinbinddSocketDi
_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_template_shell, szTemplateShell)
_PUBLIC_ FN_GLOBAL_CONST_STRING(lp_template_homedir, szTemplateHomedir)
_PUBLIC_ FN_GLOBAL_BOOL(lp_winbind_sealed_pipes, bWinbindSealedPipes)
_PUBLIC_ FN_GLOBAL_BOOL(lp_idmap_trusted_only, bIdmapTrustedOnly)
_PUBLIC_ FN_GLOBAL_STRING(lp_private_dir, szPrivateDir)
_PUBLIC_ FN_GLOBAL_STRING(lp_serverstring, szServerString)
_PUBLIC_ FN_GLOBAL_STRING(lp_lockdir, szLockDir)
@ -2305,6 +2311,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
lp_do_global_parameter(lp_ctx, "auth methods:standalone", "anonymous sam_ignoredomain");
lp_do_global_parameter(lp_ctx, "private dir", dyn_PRIVATE_DIR);
lp_do_global_parameter(lp_ctx, "sam database", "sam.ldb");
lp_do_global_parameter(lp_ctx, "idmap database", "idmap.ldb");
lp_do_global_parameter(lp_ctx, "secrets database", "secrets.ldb");
lp_do_global_parameter(lp_ctx, "spoolss database", "spoolss.ldb");
lp_do_global_parameter(lp_ctx, "wins config database", "wins_config.ldb");
@ -2380,6 +2387,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
lp_do_global_parameter(lp_ctx, "winbindd socket directory", dyn_WINBINDD_SOCKET_DIR);
lp_do_global_parameter(lp_ctx, "template shell", "/bin/false");
lp_do_global_parameter(lp_ctx, "template homedir", "/home/%WORKGROUP%/%ACCOUNTNAME%");
lp_do_global_parameter(lp_ctx, "idmap trusted only", "False");
lp_do_global_parameter(lp_ctx, "client signing", "Yes");
lp_do_global_parameter(lp_ctx, "server signing", "auto");

View File

@ -389,6 +389,7 @@ function provision_default_paths(subobj)
paths.smbconf = lp.filename()
paths.shareconf = lp.get("private dir") + "/" + "share.ldb";
paths.samdb = lp.get("sam database");
paths.idmapdb = lp.get("idmap database");
paths.secrets = lp.get("secrets database");
paths.templates = lp.get("private dir") + "/" + "templates.ldb";
paths.keytab = "secrets.keytab";
@ -679,6 +680,9 @@ function provision(subobj, message, blank, paths, session_info, credentials, lda
message("Setting up templates into " + paths.templates + "\n");
setup_ldb("provision_templates.ldif", info, paths.templates);
message("Setting up " + paths.idmapdb +"\n");
setup_ldb("idmap_init.ldif", info, paths.idmapdb);
message("Setting up sam.ldb partitions\n");
/* Also wipes the database */
setup_ldb("provision_partitions.ldif", info, paths.samdb);

View File

@ -59,6 +59,7 @@ class ProvisionPaths:
self.hkpd = None
self.hkpt = None
self.samdb = None
self.idmapdb = None
self.secrets = None
self.keytab = None
self.dns_keytab = None
@ -202,6 +203,7 @@ def provision_paths_from_lp(lp, dnsdomain):
paths.shareconf = os.path.join(private_dir, "share.ldb")
paths.samdb = os.path.join(private_dir, lp.get("sam database") or "samdb.ldb")
paths.idmapdb = os.path.join(private_dir, lp.get("idmap database") or "idmap.ldb")
paths.secrets = os.path.join(private_dir, lp.get("secrets database") or "secrets.ldb")
paths.templates = os.path.join(private_dir, "templates.ldb")
paths.dns = os.path.join(private_dir, dnsdomain + ".zone")
@ -471,6 +473,24 @@ def setup_registry(path, setup_path, session_info, credentials, lp):
assert os.path.exists(provision_reg)
reg.diff_apply(provision_reg)
def setup_idmapdb(path, setup_path, session_info, credentials, lp):
"""Setup the idmap database.
:param path: path to the idmap database
:param setup_path: Function that returns a path to a setup file
:param session_info: Session information
:param credentials: Credentials
:param lp: Loadparm context
"""
if os.path.exists(path):
os.unlink(path)
idmap_ldb = Ldb(path, session_info=session_info, credentials=credentials,
lp=lp)
idmap_ldb.erase()
idmap_ldb.load_ldif_file_add(setup_path("idmap_init.ldif"))
return idmap_ldb
def setup_samdb_rootdse(samdb, setup_path, schemadn, domaindn, hostname,
dnsdomain, realm, rootdn, configdn, netbiosname,
@ -844,6 +864,10 @@ def provision(lp, setup_dir, message, paths, session_info,
setup_templatesdb(paths.templates, setup_path, session_info=session_info,
credentials=credentials, lp=lp)
message("Setting up idmap db")
setup_idmapdb(paths.idmapdb, setup_path, session_info=session_info,
credentials=credentials, lp=lp)
samdb = setup_samdb(paths.samdb, setup_path, session_info=session_info,
credentials=credentials, lp=lp, schemadn=schemadn,
configdn=configdn, domaindn=domaindn,

View File

@ -204,7 +204,7 @@ sub getlog_env($);
sub setup_pcap($)
{
my ($state, $name) = @_;
my ($name) = @_;
return unless ($opt_socket_wrapper_pcap);
return unless defined($ENV{SOCKET_WRAPPER_PCAP_DIR});

View File

@ -0,0 +1,5 @@
dn: CN=CONFIG
cn: CONFIG
lowerBound: 10000
upperBound: 20000

View File

@ -37,6 +37,7 @@ OBJ_FILES = \
wb_sam_logon.o
PRIVATE_DEPENDENCIES = \
WB_HELPER \
IDMAP \
NDR_WINBIND \
process_model \
RPC_NDR_LSA \
@ -56,3 +57,13 @@ OBJ_FILES = \
PUBLIC_DEPENDENCIES = RPC_NDR_LSA dcerpc_samr
# End SUBSYSTEM WB_HELPER
################################################
################################################
# Start SUBYSTEM IDMAP
[SUBSYSTEM::IDMAP]
PRIVATE_PROTO_HEADER = idmap_proto.h
OBJ_FILES = \
idmap.o
PUBLIC_DEPENDENCIES = SAMDB_COMMON
# End SUBSYSTEM IDMAP
################################################

1072
source4/winbind/idmap.c Normal file

File diff suppressed because it is too large Load Diff

33
source4/winbind/idmap.h Normal file
View File

@ -0,0 +1,33 @@
/*
Unix SMB/CIFS implementation.
Map SIDs to uids/gids and back
Copyright (C) Kai Blin 2008
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.
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _IDMAP_H_
#define _IDMAP_H_
struct idmap_context {
struct loadparm_context *lp_ctx;
struct ldb_context *ldb_ctx;
};
#include "winbind/idmap_proto.h"
#endif

View File

@ -25,6 +25,7 @@
#include "smbd/service_task.h"
#include "winbind/wb_helper.h"
#include "libcli/security/proto.h"
#include "winbind/idmap.h"
struct gid2sid_state {
struct composite_context *ctx;
@ -50,10 +51,14 @@ struct composite_context *wb_gid2sid_send(TALLOC_CTX *mem_ctx,
result->private_data = state;
state->service = service;
/* FIXME: This is a stub so far.
* We cheat by just using the gid as RID with the domain SID.*/
state->sid = dom_sid_add_rid(result, service->primary_sid, gid);
if (composite_nomem(state->sid, state->ctx)) return result;
state->ctx->status = idmap_gid_to_sid(service->idmap_ctx, mem_ctx, gid,
&state->sid);
if (NT_STATUS_EQUAL(state->ctx->status, NT_STATUS_RETRY)) {
state->ctx->status = idmap_gid_to_sid(service->idmap_ctx,
mem_ctx, gid,
&state->sid);
}
if (!composite_is_ok(state->ctx)) return result;
composite_done(state->ctx);
return result;

View File

@ -149,6 +149,12 @@ static void winbind_task_init(struct task_server *task)
return;
}
service->idmap_ctx = idmap_init(service, task->lp_ctx);
if (service->idmap_ctx == NULL) {
task_server_terminate(task, "Failed to load idmap database");
return;
}
/* setup the unprivileged samba3 socket */
listen_socket = talloc(service, struct wbsrv_listen_socket);
if (!listen_socket) goto nomem;

View File

@ -21,6 +21,7 @@
#include "nsswitch/winbind_nss_config.h"
#include "nsswitch/winbind_struct_protocol.h"
#include "winbind/idmap.h"
#include "libnet/libnet.h"
#define WINBINDD_SAMBA3_SOCKET "pipe"
@ -33,6 +34,7 @@ struct wbsrv_service {
const struct dom_sid *primary_sid;
struct wbsrv_domain *domains;
struct idmap_context *idmap_ctx;
};
struct wbsrv_samconn {

View File

@ -25,6 +25,7 @@
#include "smbd/service_task.h"
#include "winbind/wb_helper.h"
#include "libcli/security/proto.h"
#include "winbind/idmap.h"
struct sid2gid_state {
struct composite_context *ctx;
@ -50,9 +51,13 @@ struct composite_context *wb_sid2gid_send(TALLOC_CTX *mem_ctx,
result->private_data = state;
state->service = service;
/*FIXME: This is a stub so far. */
state->ctx->status = dom_sid_split_rid(result, sid, NULL, &state->gid);
if(!composite_is_ok(state->ctx)) return result;
state->ctx->status = idmap_sid_to_gid(service->idmap_ctx, state, sid,
&state->gid);
if (NT_STATUS_EQUAL(state->ctx->status, NT_STATUS_RETRY)) {
state->ctx->status = idmap_sid_to_gid(service->idmap_ctx, state,
sid, &state->gid);
}
if (!composite_is_ok(state->ctx)) return result;
composite_done(state->ctx);
return result;

View File

@ -3,7 +3,7 @@
Map a SID to a uid
Copyright (C) Kai Blin 2007
Copyright (C) Kai Blin 2007-2008
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
@ -25,6 +25,7 @@
#include "smbd/service_task.h"
#include "winbind/wb_helper.h"
#include "libcli/security/proto.h"
#include "winbind/idmap.h"
struct sid2uid_state {
struct composite_context *ctx;
@ -50,11 +51,13 @@ struct composite_context *wb_sid2uid_send(TALLOC_CTX *mem_ctx,
result->private_data = state;
state->service = service;
/*FIXME: This is a stub so far. */
state->ctx->status = dom_sid_split_rid(result, sid, NULL, &state->uid);
if(!composite_is_ok(state->ctx)) return result;
DEBUG(5, ("Rid is %d\n", state->uid));
state->ctx->status = idmap_sid_to_uid(service->idmap_ctx, state, sid,
&state->uid);
if (NT_STATUS_EQUAL(state->ctx->status, NT_STATUS_RETRY)) {
state->ctx->status = idmap_sid_to_uid(service->idmap_ctx, state,
sid, &state->uid);
}
if (!composite_is_ok(state->ctx)) return result;
composite_done(state->ctx);
return result;

View File

@ -3,7 +3,7 @@
Command backend for wbinfo -U
Copyright (C) Kai Blin 2007
Copyright (C) Kai Blin 2007-2008
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
@ -25,6 +25,7 @@
#include "smbd/service_task.h"
#include "winbind/wb_helper.h"
#include "libcli/security/proto.h"
#include "winbind/idmap.h"
struct uid2sid_state {
struct composite_context *ctx;
@ -50,10 +51,14 @@ struct composite_context *wb_uid2sid_send(TALLOC_CTX *mem_ctx,
result->private_data = state;
state->service = service;
/* FIXME: This is a stub so far.
* We cheat by just using the uid as RID with the domain SID.*/
state->sid = dom_sid_add_rid(result, service->primary_sid, uid);
if (composite_nomem(state->sid, state->ctx)) return result;
state->ctx->status = idmap_uid_to_sid(service->idmap_ctx, mem_ctx, uid,
&state->sid);
if (NT_STATUS_EQUAL(state->ctx->status, NT_STATUS_RETRY)) {
state->ctx->status = idmap_uid_to_sid(service->idmap_ctx,
mem_ctx, uid,
&state->sid);
}
if (!composite_is_ok(state->ctx)) return result;
composite_done(state->ctx);
return result;