[SCM] Samba Shared Repository - branch master updated
Andrew Tridgell
tridge at samba.org
Fri Jun 10 02:32:01 MDT 2011
The branch, master has been updated
via 0c89d62 s4-samba-tool: added dbcheck commmand
via 683f986 waf-symbols: don't look for symbol lists in GENERATOR targets
via ae1414e waf: fixed 'make bin/XXX' for the remaining binaries
from 91f3515 s3-param Avoid strupper_m() where possible.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 0c89d624e6d5620c9e37649cc2976aba918b1e6a
Author: Andrew Tridgell <tridge at samba.org>
Date: Fri Jun 10 17:17:12 2011 +1000
s4-samba-tool: added dbcheck commmand
this will be used as a consistency checker and repair tool for
sam.ldb. This initial checkin just checks for empty attributes and
offers to fix them
Autobuild-User: Andrew Tridgell <tridge at samba.org>
Autobuild-Date: Fri Jun 10 10:31:56 CEST 2011 on sn-devel-104
commit 683f9868eb13cfaaf0da81bf002a85b81c928f51
Author: Andrew Tridgell <tridge at samba.org>
Date: Fri Jun 10 12:16:59 2011 +1000
waf-symbols: don't look for symbol lists in GENERATOR targets
generated header files are not object files
Pair-Programmed-With: Andrew Bartlett <abartlet at samba.org>
commit ae1414e79698c0c506aabd7458c4fbae8cc8fcf5
Author: Andrew Tridgell <tridge at samba.org>
Date: Fri Jun 10 11:32:27 2011 +1000
waf: fixed 'make bin/XXX' for the remaining binaries
this fixes 'make bin/smbd' to work correctly with the waf build. It
didn't work before as smbd is actually 'smbd/smbd' internally and we
tried to use the target name 'smbd'. The new approach reads the
symlink to get the right target.
This also speeds up the null build by quite a lot
-----------------------------------------------------------------------
Summary of changes:
Makefile | 2 +-
buildtools/scripts/Makefile.waf | 2 +-
buildtools/wafsamba/samba_wildcard.py | 35 +++++-
buildtools/wafsamba/symbols.py | 2 +-
source4/scripting/python/samba/netcmd/__init__.py | 2 +
source4/scripting/python/samba/netcmd/dbcheck.py | 123 +++++++++++++++++++++
6 files changed, 159 insertions(+), 7 deletions(-)
create mode 100644 source4/scripting/python/samba/netcmd/dbcheck.py
Changeset truncated at 500 lines:
diff --git a/Makefile b/Makefile
index cbbf045..3b40c73 100644
--- a/Makefile
+++ b/Makefile
@@ -68,7 +68,7 @@ ctags:
# this allows for things like "make bin/smbtorture"
bin/%:: FORCE
- $(WAF) --targets=`basename $@`
+ $(WAF) --targets=$@
FORCE:
pydoctor:
diff --git a/buildtools/scripts/Makefile.waf b/buildtools/scripts/Makefile.waf
index 716ab93..5fc939c 100644
--- a/buildtools/scripts/Makefile.waf
+++ b/buildtools/scripts/Makefile.waf
@@ -62,7 +62,7 @@ ctags:
$(WAF) ctags
bin/%:: FORCE
- $(WAF) --targets=`basename $@`
+ $(WAF) --targets=$@
FORCE:
configure: autogen-waf.sh BUILDTOOLS/scripts/configure.waf
diff --git a/buildtools/wafsamba/samba_wildcard.py b/buildtools/wafsamba/samba_wildcard.py
index 5bf1267..75ab5de 100644
--- a/buildtools/wafsamba/samba_wildcard.py
+++ b/buildtools/wafsamba/samba_wildcard.py
@@ -17,7 +17,7 @@ def run_task(t, k):
def run_named_build_task(cmd):
'''run a named build task, matching the cmd name using fnmatch
wildcards against inputs and outputs of all build tasks'''
- bld = fake_build_environment()
+ bld = fake_build_environment(info=False)
found = False
cwd_node = bld.root.find_dir(os.getcwd())
top_node = bld.root.find_dir(bld.srcnode.abspath())
@@ -50,6 +50,28 @@ def run_named_build_task(cmd):
raise Utils.WafError("Unable to find build target matching %s" % cmd)
+def rewrite_compile_targets():
+ '''cope with the bin/ form of compile target'''
+ if not Options.options.compile_targets:
+ return
+
+ bld = fake_build_environment(info=False)
+ targets = LOCAL_CACHE(bld, 'TARGET_TYPE')
+ tlist = []
+
+ for t in Options.options.compile_targets.split(','):
+ if not os.path.islink(t):
+ tlist.append(t)
+ continue
+ link = os.readlink(t)
+ list = link.split('/')
+ for name in [list[-1], '/'.join(list[-2:])]:
+ if name in targets:
+ tlist.append(name)
+ continue
+ Options.options.compile_targets = ",".join(tlist)
+
+
def wildcard_main(missing_cmd_fn):
'''this replaces main from Scripting, allowing us to override the
@@ -60,6 +82,9 @@ def wildcard_main(missing_cmd_fn):
'''
Scripting.commands = Options.arg_line[:]
+ # rewrite the compile targets to cope with the bin/xx form
+ rewrite_compile_targets()
+
while Scripting.commands:
x = Scripting.commands.pop(0)
@@ -99,7 +124,7 @@ def wildcard_main(missing_cmd_fn):
-def fake_build_environment():
+def fake_build_environment(info=True, flush=False):
"""create all the tasks for the project, but do not run the build
return the build context in use"""
bld = getattr(Utils.g_module, 'build_context', Utils.Context)()
@@ -119,10 +144,12 @@ def fake_build_environment():
bld.load_dirs(proj[SRCDIR], proj[BLDDIR])
bld.load_envs()
- Logs.info("Waf: Entering directory `%s'" % bld.bldnode.abspath())
+ if info:
+ Logs.info("Waf: Entering directory `%s'" % bld.bldnode.abspath())
bld.add_subdirs([os.path.split(Utils.g_module.root_path)[0]])
bld.pre_build()
- bld.flush()
+ if flush:
+ bld.flush()
return bld
diff --git a/buildtools/wafsamba/symbols.py b/buildtools/wafsamba/symbols.py
index ed19517..dfab71c 100644
--- a/buildtools/wafsamba/symbols.py
+++ b/buildtools/wafsamba/symbols.py
@@ -447,7 +447,7 @@ def check_dependencies(bld, t):
deps = set(t.samba_deps)
for d in t.samba_deps:
- if targets[d] in [ 'EMPTY', 'DISABLED', 'SYSLIB' ]:
+ if targets[d] in [ 'EMPTY', 'DISABLED', 'SYSLIB', 'GENERATOR' ]:
continue
bld.ASSERT(d in bld.env.public_symbols, "Failed to find symbol list for dependency '%s'" % d)
diff = remaining.intersection(bld.env.public_symbols[d])
diff --git a/source4/scripting/python/samba/netcmd/__init__.py b/source4/scripting/python/samba/netcmd/__init__.py
index d934cf8..1373cb2 100644
--- a/source4/scripting/python/samba/netcmd/__init__.py
+++ b/source4/scripting/python/samba/netcmd/__init__.py
@@ -212,3 +212,5 @@ from samba.netcmd.ldapcmp import cmd_ldapcmp
commands["ldapcmp"] = cmd_ldapcmp()
from samba.netcmd.testparm import cmd_testparm
commands["testparm"] = cmd_testparm()
+from samba.netcmd.dbcheck import cmd_dbcheck
+commands["dbcheck"] = cmd_dbcheck()
diff --git a/source4/scripting/python/samba/netcmd/dbcheck.py b/source4/scripting/python/samba/netcmd/dbcheck.py
new file mode 100644
index 0000000..7bbd4d2
--- /dev/null
+++ b/source4/scripting/python/samba/netcmd/dbcheck.py
@@ -0,0 +1,123 @@
+#!/usr/bin/env python
+#
+# Samba4 AD database checker
+#
+# Copyright (C) Andrew Tridgell 2011
+#
+# 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/>.
+#
+
+import samba, ldb
+import samba.getopt as options
+from samba.auth import system_session
+from samba.samdb import SamDB
+from samba.dcerpc import security
+from samba.netcmd import (
+ Command,
+ CommandError,
+ Option
+ )
+
+def confirm(self, msg):
+ '''confirm an action with the user'''
+ if self.yes:
+ print("%s [YES]" % msg)
+ return True
+ v = raw_input(msg + ' [y/N] ')
+ return v.upper() in ['Y', 'YES']
+
+
+def empty_attribute(self, dn, attrname):
+ '''fix empty attributes'''
+ print("ERROR: Empty attribute %s in %s" % (attrname, dn))
+ if not self.fix:
+ return
+ if not confirm(self, 'Remove empty attribute %s from %s?' % (attrname, dn)):
+ print("Not fixing empty attribute %s" % attrname)
+ return
+
+ m = ldb.Message()
+ m.dn = dn
+ m[attrname] = ldb.MessageElement('', ldb.FLAG_MOD_DELETE, attrname)
+ try:
+ self.samdb.modify(m, ["relax:0"])
+ except Exception, msg:
+ print("Failed to remove empty attribute %s : %s" % (attrname, msg))
+ return
+ print("Removed empty attribute %s" % attrname)
+
+
+
+def check_object(self, dn):
+ '''check one object'''
+ if self.verbose:
+ print("Checking object %s" % dn)
+ res = self.samdb.search(base=dn, scope=ldb.SCOPE_BASE)
+ if len(res) != 1:
+ print("Object %s disappeared during check" % dn)
+ return
+ obj = res[0]
+ for attrname in obj:
+ if attrname == 'dn':
+ continue
+ for val in obj[attrname]:
+ if val == '':
+ empty_attribute(self, dn, attrname)
+ continue
+
+
+class cmd_dbcheck(Command):
+ """check local AD database for errors"""
+ synopsis = "dbcheck <DN> [options]"
+
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "versionopts": options.VersionOptions,
+ "credopts": options.CredentialsOptionsDouble,
+ }
+
+ takes_args = ["DN?"]
+
+ takes_options = [
+ Option("--scope", dest="scope", default="SUB",
+ help="Pass search scope that builds DN list. Options: SUB, ONE, BASE"),
+ Option("--fix", dest="fix", default=False, action='store_true',
+ help='Fix any errors found'),
+ Option("--yes", dest="yes", default=False, action='store_true',
+ help="don't confirm changes, just do them all"),
+ Option("-v", "--verbose", dest="verbose", action="store_true", default=False,
+ help="Print more details of checking"),
+ ]
+
+ def run(self, DN=None, verbose=False, fix=False, yes=False,
+ scope="SUB", credopts=None, sambaopts=None, versionopts=None):
+ self.lp = sambaopts.get_loadparm()
+ self.creds = credopts.get_credentials(self.lp, fallback_machine=True)
+
+ self.samdb = SamDB(session_info=system_session(), url=None,
+ credentials=self.creds, lp=self.lp)
+ self.verbose = verbose
+ self.fix = fix
+ self.yes = yes
+
+ scope_map = { "SUB": ldb.SCOPE_SUBTREE, "BASE":ldb.SCOPE_BASE, "ONE":ldb.SCOPE_ONELEVEL }
+ scope = scope.upper()
+ if not scope in scope_map:
+ raise CommandError("Unknown scope %s" % scope)
+ self.search_scope = scope_map[scope]
+
+ res = self.samdb.search(base=DN, scope=self.search_scope, attrs=['dn'])
+ for object in res:
+ check_object(self, object.dn)
+ print('Checked %u objects' % len(res))
--
Samba Shared Repository
More information about the samba-cvs
mailing list