[SCM] Samba Shared Repository - branch master updated
Andrew Tridgell
tridge at samba.org
Wed Nov 10 20:40:01 MST 2010
The branch, master has been updated
via ee50bdd s4-loadparm: fix the FLAG_DEFAULT settings on specially handled parameters
via 21fe96e s4-provision: include command line provision options in the generated smb.conf
via 60cb372 s4-devel: useful script for testing join with empty smb.conf
via e908c26 s4-test: use IPC$ instead of ADMIN$ for srvsvc NetShareGetInfo test
via 81c9b98 s4-join: use the command line loadparm in provision during a join
via 1d7d09a s4-loadparm: fixed dumping of non-default parms with testparm
via ed8ea4e s4-server: move the creation of the IPC$ share into ntvfs
from 0afb299 Fix bug #7791 - gvfsd-smb (Gnome vfs) fails to copy files from a SMB share using SMB signing.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit ee50bdd42f01bfcebb2e75a923a01fa1d18e5694
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Nov 11 13:56:44 2010 +1100
s4-loadparm: fix the FLAG_DEFAULT settings on specially handled parameters
parameters with special handlers also need to clear the FLAG_DEFAULT
flag when set
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
Autobuild-User: Andrew Tridgell <tridge at samba.org>
Autobuild-Date: Thu Nov 11 03:39:23 UTC 2010 on sn-devel-104
commit 21fe96e8f9e1f3f3d047ed893633228c2aef881c
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Nov 11 13:09:29 2010 +1100
s4-provision: include command line provision options in the generated smb.conf
this saves the smb.conf using lp.dump_globals() to ensure that any
command line options (for example directory overrides) are saved in
the generated smb.conf
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
commit 60cb372bd6c874af1050ff3d723bacee8c9cbf8e
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Nov 11 11:18:48 2010 +1100
s4-devel: useful script for testing join with empty smb.conf
this sets up all the needed --options for a join with a prefix other
than the one compiled in
commit e908c263916c1e18468054d8a0416e5a1425c25d
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Nov 11 11:16:23 2010 +1100
s4-test: use IPC$ instead of ADMIN$ for srvsvc NetShareGetInfo test
IPC$ is guaranteed to exist on servers that do RPC, whereas ADMIN$
isn't
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
commit 81c9b98ecd6b0b4ec412ea7a0963002dc17f4f66
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Nov 11 10:45:13 2010 +1100
s4-join: use the command line loadparm in provision during a join
this allows a join with an empty smb.conf to override locations of
files correctly with --option
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
commit 1d7d09a8f72a9f7f888538b7f7c63969407e9c2d
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Nov 11 10:39:19 2010 +1100
s4-loadparm: fixed dumping of non-default parms with testparm
when using testparm without -v we should only dump non-default
parameters. This patch fixes up the handling of the FLAG_DEFAULT flag
in loadparm to correctly mark parameters as default or not, including
parametric options
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
commit ed8ea4ed18f08bfc93190513f2a2e8e058655daf
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Nov 11 10:35:38 2010 +1100
s4-server: move the creation of the IPC$ share into ntvfs
the IPC$ share is only used by the ntvfs backends, and doesn't need to
be created on every load of smb.conf. This fixes a problem with
testparm showing the ipc$ share when it isn't defined in smb.conf.
This also removes the admin$ share, which really shouldn't be on by
default. The admin$ share is used for remote software installation,
and normally exposes the c:\windows directory on a windows
server. That makes no sense on Samba. If for some reason a admin$
share is needed, then the admin can create one as usual. Exposing /tmp
via admin$ by default seems like a bad idea.
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
-----------------------------------------------------------------------
Summary of changes:
source4/ntvfs/ntvfs_base.c | 26 ++++++++
source4/param/loadparm.c | 93 ++++++++++++---------------
source4/scripting/devel/config_base | 43 ++++++++++++
source4/scripting/python/samba/join.py | 2 +-
source4/scripting/python/samba/provision.py | 43 ++++++++----
source4/torture/rpc/srvsvc.c | 6 +-
6 files changed, 143 insertions(+), 70 deletions(-)
create mode 100755 source4/scripting/devel/config_base
Changeset truncated at 500 lines:
diff --git a/source4/ntvfs/ntvfs_base.c b/source4/ntvfs/ntvfs_base.c
index d8d73e9..1b1a533 100644
--- a/source4/ntvfs/ntvfs_base.c
+++ b/source4/ntvfs/ntvfs_base.c
@@ -200,6 +200,30 @@ NTSTATUS ntvfs_init_connection(TALLOC_CTX *mem_ctx, struct share_config *scfg, e
return NT_STATUS_OK;
}
+/*
+ adds the IPC$ share, needed for RPC calls
+ */
+static NTSTATUS ntvfs_add_ipc_share(struct loadparm_context *lp_ctx)
+{
+ struct loadparm_service *ipc;
+
+ if (lpcfg_service(lp_ctx, "IPC$")) {
+ /* it has already been defined in smb.conf or elsewhere */
+ return NT_STATUS_OK;
+ }
+
+ ipc = lpcfg_add_service(lp_ctx, NULL, "IPC$");
+ NT_STATUS_HAVE_NO_MEMORY(ipc);
+
+ lpcfg_do_service_parameter(lp_ctx, ipc, "comment", "IPC Service");
+ lpcfg_do_service_parameter(lp_ctx, ipc, "path", "/dev/null");
+ lpcfg_do_service_parameter(lp_ctx, ipc, "ntvfs handler", "default");
+ lpcfg_do_service_parameter(lp_ctx, ipc, "browseable", "No");
+ lpcfg_do_service_parameter(lp_ctx, ipc, "fstype", "IPC");
+
+ return NT_STATUS_OK;
+}
+
NTSTATUS ntvfs_init(struct loadparm_context *lp_ctx)
{
static bool initialized = false;
@@ -217,6 +241,8 @@ NTSTATUS ntvfs_init(struct loadparm_context *lp_ctx)
run_init_functions(shared_init);
talloc_free(shared_init);
+
+ ntvfs_add_ipc_share(lp_ctx);
return NT_STATUS_OK;
}
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index 69dead7..09d4f39 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -1053,6 +1053,10 @@ struct loadparm_service *lpcfg_add_service(struct loadparm_context *lp_ctx,
int num_to_alloc = lp_ctx->iNumServices + 1;
struct parmlist_entry *data, *pdata;
+ if (pservice == NULL) {
+ pservice = lp_ctx->sDefault;
+ }
+
tservice = *pservice;
/* it might already exist */
@@ -1143,39 +1147,6 @@ bool lpcfg_add_home(struct loadparm_context *lp_ctx,
}
/**
- * Add the IPC service.
- */
-
-static bool lpcfg_add_hidden(struct loadparm_context *lp_ctx, const char *name,
- const char *fstype)
-{
- struct loadparm_service *service = lpcfg_add_service(lp_ctx, lp_ctx->sDefault, name);
-
- if (service == NULL)
- return false;
-
- string_set(service, &service->szPath, tmpdir());
-
- service->comment = talloc_asprintf(service, "%s Service (%s)",
- fstype, lp_ctx->globals->szServerString);
- string_set(service, &service->fstype, fstype);
- service->iMaxConnections = -1;
- service->bAvailable = true;
- service->bRead_only = true;
- service->bPrint_ok = false;
- service->bBrowseable = false;
-
- if (strcasecmp(fstype, "IPC") == 0) {
- lpcfg_do_service_parameter(lp_ctx, service, "ntvfs handler",
- "default");
- }
-
- DEBUG(3, ("adding hidden service %s\n", name));
-
- return true;
-}
-
-/**
* Add a new printer service, with defaults coming from service iFrom.
*/
@@ -1359,7 +1330,7 @@ static void copy_service(struct loadparm_service *pserviceDest,
pdata = pdata->next;
}
if (not_added) {
- paramo = talloc(pserviceDest, struct parmlist_entry);
+ paramo = talloc_zero(pserviceDest, struct parmlist_entry);
if (paramo == NULL)
smb_panic("OOM");
paramo->key = talloc_reference(paramo, data->key);
@@ -1632,7 +1603,7 @@ static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
}
}
- paramo = talloc(mem_ctx, struct parmlist_entry);
+ paramo = talloc_zero(mem_ctx, struct parmlist_entry);
if (!paramo)
smb_panic("OOM");
paramo->key = talloc_strdup(paramo, name);
@@ -1651,14 +1622,18 @@ static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
const char *pszParmName, const char *pszParmValue,
- struct loadparm_context *lp_ctx)
+ struct loadparm_context *lp_ctx, bool on_globals)
{
int i;
/* if it is a special case then go ahead */
if (parm_table[parmnum].special) {
- parm_table[parmnum].special(lp_ctx, pszParmValue,
- (char **)parm_ptr);
- return true;
+ bool ret;
+ ret = parm_table[parmnum].special(lp_ctx, pszParmValue,
+ (char **)parm_ptr);
+ if (!ret) {
+ return false;
+ }
+ goto mark_non_default;
}
/* now switch on the type of variable it is */
@@ -1730,7 +1705,8 @@ static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
break;
}
- if (lp_ctx->flags[parmnum] & FLAG_DEFAULT) {
+mark_non_default:
+ if (on_globals && (lp_ctx->flags[parmnum] & FLAG_DEFAULT)) {
lp_ctx->flags[parmnum] &= ~FLAG_DEFAULT;
/* we have to also unset FLAG_DEFAULT on aliases */
for (i=parmnum-1;i>=0 && parm_table[i].offset == parm_table[parmnum].offset;i--) {
@@ -1766,8 +1742,8 @@ bool lpcfg_do_global_parameter(struct loadparm_context *lp_ctx,
parm_ptr = lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[parmnum]);
- return set_variable(lp_ctx, parmnum, parm_ptr,
- pszParmName, pszParmValue, lp_ctx);
+ return set_variable(lp_ctx->globals, parmnum, parm_ptr,
+ pszParmName, pszParmValue, lp_ctx, true);
}
bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
@@ -1811,7 +1787,7 @@ bool lpcfg_do_service_parameter(struct loadparm_context *lp_ctx,
service->copymap[i] = false;
return set_variable(service, parmnum, parm_ptr, pszParmName,
- pszParmValue, lp_ctx);
+ pszParmValue, lp_ctx, false);
}
/**
@@ -2114,6 +2090,9 @@ static void dump_globals(struct loadparm_context *lp_ctx, FILE *f,
if (lp_ctx->globals->param_opt != NULL) {
for (data = lp_ctx->globals->param_opt; data;
data = data->next) {
+ if (!show_defaults && (data->priority & FLAG_DEFAULT)) {
+ continue;
+ }
fprintf(f, "\t%s = %s\n", data->key, data->value);
}
}
@@ -2124,7 +2103,8 @@ static void dump_globals(struct loadparm_context *lp_ctx, FILE *f,
* Display the contents of a single services record.
*/
-static void dump_a_service(struct loadparm_service * pService, struct loadparm_service *sDefault, FILE * f)
+static void dump_a_service(struct loadparm_service * pService, struct loadparm_service *sDefault, FILE * f,
+ unsigned int *flags)
{
int i;
struct parmlist_entry *data;
@@ -2139,8 +2119,14 @@ static void dump_a_service(struct loadparm_service * pService, struct loadparm_s
(i == 0 || (parm_table[i].offset != parm_table[i - 1].offset)))
{
if (pService == sDefault) {
- if (defaults_saved && is_default(sDefault, i))
+ if (flags && (flags[i] & FLAG_DEFAULT)) {
continue;
+ }
+ if (defaults_saved) {
+ if (is_default(sDefault, i)) {
+ continue;
+ }
+ }
} else {
if (equal_parameter(parm_table[i].type,
((char *)pService) +
@@ -2290,6 +2276,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
int i;
char *myname;
struct loadparm_context *lp_ctx;
+ struct parmlist_entry *parm;
lp_ctx = talloc_zero(mem_ctx, struct loadparm_context);
if (lp_ctx == NULL)
@@ -2477,6 +2464,12 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
}
}
+ for (parm=lp_ctx->globals->param_opt; parm; parm=parm->next) {
+ if (!(parm->priority & FLAG_CMDLINE)) {
+ parm->priority |= FLAG_DEFAULT;
+ }
+ }
+
return lp_ctx;
}
@@ -2501,9 +2494,6 @@ static bool lpcfg_update(struct loadparm_context *lp_ctx)
{
lpcfg_add_auto_services(lp_ctx, lpcfg_auto_services(lp_ctx));
- lpcfg_add_hidden(lp_ctx, "IPC$", "IPC");
- lpcfg_add_hidden(lp_ctx, "ADMIN$", "DISK");
-
if (!lp_ctx->globals->szWINSservers && lp_ctx->globals->bWINSsupport) {
lpcfg_do_global_parameter(lp_ctx, "wins server", "127.0.0.1");
}
@@ -2613,12 +2603,11 @@ void lpcfg_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
{
int iService;
- if (show_defaults)
- defaults_saved = false;
+ defaults_saved = !show_defaults;
dump_globals(lp_ctx, f, show_defaults);
- dump_a_service(lp_ctx->sDefault, lp_ctx->sDefault, f);
+ dump_a_service(lp_ctx->sDefault, lp_ctx->sDefault, f, lp_ctx->flags);
for (iService = 0; iService < maxtoprint; iService++)
lpcfg_dump_one(f, show_defaults, lp_ctx->services[iService], lp_ctx->sDefault);
@@ -2632,7 +2621,7 @@ void lpcfg_dump_one(FILE *f, bool show_defaults, struct loadparm_service *servic
if (service != NULL) {
if (service->szService[0] == '\0')
return;
- dump_a_service(service, sDefault, f);
+ dump_a_service(service, sDefault, f, NULL);
}
}
diff --git a/source4/scripting/devel/config_base b/source4/scripting/devel/config_base
new file mode 100755
index 0000000..2536065
--- /dev/null
+++ b/source4/scripting/devel/config_base
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+
+# this is useful for running samba tools with a different prefix
+
+# for example:
+# samba-tool $(scripting/devel/config_base /tmp/testprefix) join .....
+
+import sys, os
+
+vars = {
+ "dns update command" : "${PREFIX}/bin/samba_dnsupdate",
+ "spn update command" : "${PREFIX}/bin/samba_spnupdate",
+ "ncalrpc dir" : "${PREFIX}/var/ncalrpc",
+ "private dir" : "${PREFIX}/private",
+ "lock dir" : "${PREFIX}/var/locks",
+ "pid directory" : "${PREFIX}/var/run",
+ "winbindd socket directory" : "${PREFIX}/var/run/winbindd",
+ "winbindd privileged socket directory" : "${PREFIX}/var/lib/winbindd_privileged",
+ "ntp signd socket directory" : "${PREFIX}/var/run/ntp_signd"
+}
+
+if len(sys.argv) != 2:
+ print("Usage: config_base BASEDIRECTORY")
+ sys.exit(1)
+
+prefix = sys.argv[1]
+
+config_dir = prefix + "/etc"
+config_file = config_dir + "/smb.conf"
+
+if not os.path.isdir(config_dir):
+ os.makedirs(config_dir, mode=0755)
+if not os.path.isfile(config_file):
+ open(config_file, mode='w').close()
+
+options = " --configfile=${PREFIX}/etc/smb.conf"
+
+for v in vars:
+ options += " --option=%s=%s" % (v.replace(" ",""), vars[v])
+
+options = options.replace("${PREFIX}", prefix)
+
+print options
diff --git a/source4/scripting/python/samba/join.py b/source4/scripting/python/samba/join.py
index 571b822..bdd63db 100644
--- a/source4/scripting/python/samba/join.py
+++ b/source4/scripting/python/samba/join.py
@@ -412,7 +412,7 @@ class dc_join:
serverdn=ctx.server_dn, domain=ctx.domain_name,
hostname=ctx.myname, domainsid=ctx.domsid,
machinepass=ctx.acct_pass, serverrole="domain controller",
- sitename=ctx.site)
+ sitename=ctx.site, lp=ctx.lp)
print "Provision OK for domain DN %s" % presult.domaindn
ctx.local_samdb = presult.samdb
ctx.lp = presult.lp
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 85d883f..42c0345 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -83,13 +83,13 @@ def find_setup_dir():
if in_source_tree():
# In source tree
dirname = os.path.dirname(__file__)
- return os.path.join(dirname, "../../../setup")
+ return os.path.normpath(os.path.join(dirname, "../../../setup"))
else:
import sys
for prefix in [sys.prefix,
os.path.join(os.path.dirname(__file__), "../../../..")]:
for suffix in ["share/setup", "share/samba/setup", "setup"]:
- ret = os.path.join(prefix, suffix)
+ ret = os.path.normpath(os.path.join(prefix, suffix))
if os.path.isdir(ret):
return ret
raise Exception("Unable to find setup directory.")
@@ -548,7 +548,7 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None,
def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
- targetdir, sid_generator="internal", eadb=False):
+ targetdir, sid_generator="internal", eadb=False, lp=None):
"""Create a new smb.conf file based on a couple of basic settings.
"""
assert smbconf is not None
@@ -585,15 +585,16 @@ def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
assert realm is not None
realm = realm.upper()
- default_lp = samba.param.LoadParm()
+ if lp is None:
+ lp = samba.param.LoadParm()
#Load non-existant file
if os.path.exists(smbconf):
- default_lp.load(smbconf)
+ lp.load(smbconf)
if eadb:
if targetdir is not None:
privdir = os.path.join(targetdir, "private")
else:
- privdir = default_lp.get("private dir")
+ privdir = lp.get("private dir")
posixeadb_line = "posix:eadb = " + os.path.abspath(os.path.join(privdir, "eadb.tdb"))
else:
posixeadb_line = ""
@@ -602,7 +603,7 @@ def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
privatedir_line = "private dir = " + os.path.abspath(os.path.join(targetdir, "private"))
lockdir_line = "lock dir = " + os.path.abspath(targetdir)
- default_lp.set("lock dir", os.path.abspath(targetdir))
+ lp.set("lock dir", os.path.abspath(targetdir))
else:
privatedir_line = ""
lockdir_line = ""
@@ -613,13 +614,13 @@ def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
sid_generator_line = "sid generator = " + sid_generator
used_setup_dir = setup_path("")
- default_setup_dir = default_lp.get("setup directory")
+ default_setup_dir = lp.get("setup directory")
setupdir_line = ""
if used_setup_dir != default_setup_dir:
setupdir_line = "setup directory = %s" % used_setup_dir
- default_lp.set("setup directory", used_setup_dir)
+ lp.set("setup directory", used_setup_dir)
- sysvol = os.path.join(default_lp.get("lock dir"), "sysvol")
+ sysvol = os.path.join(lp.get("lock dir"), "sysvol")
netlogon = os.path.join(sysvol, realm.lower(), "scripts")
setup_file(setup_path("provision.smb.conf.%s" % smbconfsuffix),
@@ -637,6 +638,17 @@ def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
"POSIXEADB_LINE": posixeadb_line
})
+ # reload the smb.conf
+ lp.load(smbconf)
+
+ # and dump it without any values that are the default
+ # this ensures that any smb.conf parameters that were set
+ # on the provision/join command line are set in the resulting smb.conf
+ f = open(smbconf, mode='w')
+ lp.dump(f, False)
+ f.close()
+
+
def setup_name_mappings(samdb, idmap, sid, domaindn, root_uid, nobody_uid,
users_gid, wheel_gid):
@@ -1374,7 +1386,8 @@ def provision(setup_dir, logger, session_info,
sitename=None,
ol_mmr_urls=None, ol_olc=None,
setup_ds_path=None, slapd_path=None, nosync=False,
- ldap_dryrun_mode=False, useeadb=False, am_rodc=False):
+ ldap_dryrun_mode=False, useeadb=False, am_rodc=False,
+ lp=None):
"""Provision samba4
:note: caution, this wipes all existing data!
@@ -1446,12 +1459,14 @@ def provision(setup_dir, logger, session_info,
data = data.lstrip()
if data is None or data == "":
make_smbconf(smbconf, setup_path, hostname, domain, realm,
- serverrole, targetdir, sid_generator, useeadb)
+ serverrole, targetdir, sid_generator, useeadb,
+ lp=lp)
else:
make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
- targetdir, sid_generator, useeadb)
+ targetdir, sid_generator, useeadb, lp=lp)
- lp = samba.param.LoadParm()
+ if lp is None:
+ lp = samba.param.LoadParm()
lp.load(smbconf)
names = guess_names(lp=lp, hostname=hostname, domain=domain,
dnsdomain=realm, serverrole=serverrole,
diff --git a/source4/torture/rpc/srvsvc.c b/source4/torture/rpc/srvsvc.c
index 4137052..16f2673 100644
--- a/source4/torture/rpc/srvsvc.c
+++ b/source4/torture/rpc/srvsvc.c
@@ -306,7 +306,7 @@ static bool test_NetConnEnum(struct torture_context *tctx,
ZERO_STRUCT(info_ctr);
r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p));
- r.in.path = talloc_asprintf(tctx,"%s","ADMIN$");
+ r.in.path = talloc_asprintf(tctx,"%s","IPC$");
r.in.info_ctr = &info_ctr;
r.in.max_buffer = (uint32_t)-1;
r.in.resume_handle = NULL;
@@ -534,13 +534,13 @@ static bool test_NetShareGetInfo(struct torture_context *tctx,
static bool test_NetShareGetInfoAdminFull(struct torture_context *tctx,
struct dcerpc_pipe *p)
{
- return test_NetShareGetInfo(tctx, p, "ADMIN$", true);
+ return test_NetShareGetInfo(tctx, p, "IPC$", true);
}
static bool test_NetShareGetInfoAdminAnon(struct torture_context *tctx,
struct dcerpc_pipe *p)
{
- return test_NetShareGetInfo(tctx, p, "ADMIN$", false);
+ return test_NetShareGetInfo(tctx, p, "IPC$", false);
}
static bool test_NetShareAddSetDel(struct torture_context *tctx,
--
Samba Shared Repository
More information about the samba-cvs
mailing list