The branch, master has been updated via a611769 rebuildexetendeddn: PEP8: Use spaces rather than tabs. via 6dbe3e3 rpcclient: PEP8: Use spaces rather than tabs. via a67683e smbstatus: PEP8: Use spaces rather than tabs. via e4e9c5d mischema: Remove unused import. via ac28c82 enablerecyclebin: Remove unused imports, fix formatting. from c9e3f6a s3-printing: skip migration of non-existent printers
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit a61176900fc16b6ad3dab330bf6465f35e891ea6 Author: Jelmer Vernooij <jel...@samba.org> Date: Thu Jun 30 10:33:05 2011 +0200 rebuildexetendeddn: PEP8: Use spaces rather than tabs. Autobuild-User: Jelmer Vernooij <jel...@samba.org> Autobuild-Date: Thu Jun 30 12:07:32 CEST 2011 on sn-devel-104 commit 6dbe3e36009707b88d1517aab2a47fbaefca4050 Author: Jelmer Vernooij <jel...@samba.org> Date: Thu Jun 30 10:32:35 2011 +0200 rpcclient: PEP8: Use spaces rather than tabs. commit a67683eb6d2ee340bd81a8c756e000954552ed38 Author: Jelmer Vernooij <jel...@samba.org> Date: Thu Jun 30 10:31:59 2011 +0200 smbstatus: PEP8: Use spaces rather than tabs. commit e4e9c5d140dd73f3a09fa9b04c0699f1d253eb38 Author: Jelmer Vernooij <jel...@samba.org> Date: Thu Jun 30 10:30:43 2011 +0200 mischema: Remove unused import. commit ac28c8216f3230bf647bc95f582a0d45e81fe33c Author: Jelmer Vernooij <jel...@samba.org> Date: Thu Jun 30 10:29:23 2011 +0200 enablerecyclebin: Remove unused imports, fix formatting. ----------------------------------------------------------------------- Summary of changes: source4/scripting/bin/enablerecyclebin | 8 +- source4/scripting/bin/minschema | 1 - source4/scripting/bin/rebuildextendeddn | 127 +++++++++++++++---------------- source4/scripting/bin/rpcclient | 90 +++++++++++----------- source4/scripting/bin/smbstatus | 76 +++++++++--------- 5 files changed, 147 insertions(+), 155 deletions(-) Changeset truncated at 500 lines: diff --git a/source4/scripting/bin/enablerecyclebin b/source4/scripting/bin/enablerecyclebin index 61ad32c..ab36ead 100755 --- a/source4/scripting/bin/enablerecyclebin +++ b/source4/scripting/bin/enablerecyclebin @@ -2,9 +2,7 @@ # # enabled the Recycle Bin optional feature # -import base64 import optparse -import os import sys # Find right directory when running from source tree @@ -12,7 +10,7 @@ sys.path.insert(0, "bin/python") import samba from samba import getopt as options, Ldb -from ldb import SCOPE_SUBTREE, SCOPE_BASE, LdbError +from ldb import SCOPE_BASE import sys import ldb from samba.auth import system_session @@ -48,8 +46,8 @@ configbase=rootDse["configurationNamingContext"] msg = ldb.Message() msg.dn = ldb.Dn(sam_ldb, "") msg["enableOptionalFeature"] = ldb.MessageElement( - "CN=Partitions," + str(configbase) + ":766ddcd8-acd0-445e-f3b9-a7f9b6744f2a", - ldb.FLAG_MOD_ADD, "enableOptionalFeature") + "CN=Partitions," + str(configbase) + ":766ddcd8-acd0-445e-f3b9-a7f9b6744f2a", + ldb.FLAG_MOD_ADD, "enableOptionalFeature") res = sam_ldb.modify(msg) print "Recycle Bin feature enabled" diff --git a/source4/scripting/bin/minschema b/source4/scripting/bin/minschema index 6fca074..1744f6c 100755 --- a/source4/scripting/bin/minschema +++ b/source4/scripting/bin/minschema @@ -5,7 +5,6 @@ import base64 import optparse -import os import sys # Find right directory when running from source tree diff --git a/source4/scripting/bin/rebuildextendeddn b/source4/scripting/bin/rebuildextendeddn index 1154b7c..5ab90c9 100755 --- a/source4/scripting/bin/rebuildextendeddn +++ b/source4/scripting/bin/rebuildextendeddn @@ -8,17 +8,16 @@ # Copyright (C) Jelmer Vernooij <jel...@samba.org> 2007-2008 # Copyright (C) Andrew Bartlett <abart...@samba.org> 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/>. # @@ -47,17 +46,17 @@ parser.add_option_group(options.VersionOptions(parser)) credopts = options.CredentialsOptions(parser) parser.add_option_group(credopts) parser.add_option("--targetdir", type="string", metavar="DIR", - help="Set target directory") + help="Set target directory") opts = parser.parse_args()[0] def message(text): - """print a message if quiet is not set.""" - if not opts.quiet: - print text + """print a message if quiet is not set.""" + if not opts.quiet: + print text if len(sys.argv) == 1: - opts.interactive = True + opts.interactive = True lp = sambaopts.get_loadparm() smbconf = lp.configfile @@ -70,70 +69,66 @@ session = system_session() def get_paths(targetdir=None,smbconf=None): - if targetdir is not None: - if (not os.path.exists(os.path.join(targetdir, "etc"))): - os.makedirs(os.path.join(targetdir, "etc")) - smbconf = os.path.join(targetdir, "etc", "smb.conf") - if smbconf is None: - smbconf = param.default_path() + if targetdir is not None: + if (not os.path.exists(os.path.join(targetdir, "etc"))): + os.makedirs(os.path.join(targetdir, "etc")) + smbconf = os.path.join(targetdir, "etc", "smb.conf") + if smbconf is None: + smbconf = param.default_path() - if not os.path.exists(smbconf): - print >>sys.stderr, "Unable to find smb.conf .. "+smbconf - parser.print_usage() - sys.exit(1) + if not os.path.exists(smbconf): + print >>sys.stderr, "Unable to find smb.conf .. "+smbconf + parser.print_usage() + sys.exit(1) - lp = param.LoadParm() - lp.load(smbconf) - paths = provision_paths_from_lp(lp,"foo") - return paths + lp = param.LoadParm() + lp.load(smbconf) + paths = provision_paths_from_lp(lp,"foo") + return paths def rebuild_en_dn(credentials,session_info,paths): - lp = param.LoadParm() - lp.load(paths.smbconf) - names = ProvisionNames() - names.domain = lp.get("workgroup") - names.realm = lp.get("realm") - names.rootdn = "DC=" + names.realm.replace(".",",DC=") - - attrs = ["dn" ] - dn = "" - sam_ldb = Ldb(paths.samdb, session_info=session_info, credentials=credentials,lp=lp) - attrs2 = ["schemaNamingContext"] - res2 = sam_ldb.search(expression="(objectClass=*)",base="", scope=SCOPE_BASE, attrs=attrs2) - attrs.extend(get_linked_attributes(ldb.Dn(sam_ldb,str(res2[0]["schemaNamingContext"])),sam_ldb).keys()) - attrs.extend(get_dnsyntax_attributes(ldb.Dn(sam_ldb,str(res2[0]["schemaNamingContext"])),sam_ldb)), - sam_ldb.transaction_start() - res = sam_ldb.search(expression="(cn=*)", scope=SCOPE_SUBTREE, attrs=attrs,controls=["search_options:1:2"] -) - mod = "" - for i in range (0,len(res)): - #print >>sys.stderr,res[i].dn - dn = res[i].dn - for att in res[i]: - if ( (att != "dn" and att != "cn") and not (res[i][att] is None) ): - m = ldb.Message() - m.dn = ldb.Dn(sam_ldb, str(dn)) - saveatt = [] - for j in range (0,len( res[i][att])): - mod = mod +att +": "+str(res[i][att][j])+"\n" - saveatt.append(str(res[i][att][j])) - m[att] = ldb.MessageElement(saveatt, ldb.FLAG_MOD_REPLACE, att) - sam_ldb.modify(m) - res3 = sam_ldb.search(expression="(&(dn=%s)(%s=*))"%(dn,att),scope=SCOPE_SUBTREE, attrs=[att],controls=["search_options:1:2"]) - if( len(res3) == 0 or (len(res3[0][att])!= len(saveatt))): - print >>sys.stderr, str(dn) + " has no attr " +att+ " or a wrong value" - for satt in saveatt: - print >>sys.stderr,str(att)+" = "+satt - sam_ldb.transaction_cancel() - sam_ldb.transaction_commit() - - - - -paths = get_paths(targetdir=opts.targetdir,smbconf=smbconf) - + lp = param.LoadParm() + lp.load(paths.smbconf) + names = ProvisionNames() + names.domain = lp.get("workgroup") + names.realm = lp.get("realm") + names.rootdn = "DC=" + names.realm.replace(".",",DC=") + + attrs = ["dn" ] + dn = "" + sam_ldb = Ldb(paths.samdb, session_info=session_info, credentials=credentials,lp=lp) + attrs2 = ["schemaNamingContext"] + res2 = sam_ldb.search(expression="(objectClass=*)",base="", scope=SCOPE_BASE, attrs=attrs2) + attrs.extend(get_linked_attributes(ldb.Dn(sam_ldb,str(res2[0]["schemaNamingContext"])),sam_ldb).keys()) + attrs.extend(get_dnsyntax_attributes(ldb.Dn(sam_ldb,str(res2[0]["schemaNamingContext"])),sam_ldb)) + sam_ldb.transaction_start() + res = sam_ldb.search(expression="(cn=*)", scope=SCOPE_SUBTREE, attrs=attrs,controls=["search_options:1:2"]) + mod = "" + for i in range (0,len(res)): + #print >>sys.stderr,res[i].dn + dn = res[i].dn + for att in res[i]: + if ( (att != "dn" and att != "cn") and not (res[i][att] is None) ): + m = ldb.Message() + m.dn = ldb.Dn(sam_ldb, str(dn)) + saveatt = [] + for j in range (0,len( res[i][att])): + mod = mod +att +": "+str(res[i][att][j])+"\n" + saveatt.append(str(res[i][att][j])) + m[att] = ldb.MessageElement(saveatt, ldb.FLAG_MOD_REPLACE, att) + sam_ldb.modify(m) + res3 = sam_ldb.search(expression="(&(dn=%s)(%s=*))"%(dn,att),scope=SCOPE_SUBTREE, attrs=[att],controls=["search_options:1:2"]) + if( len(res3) == 0 or (len(res3[0][att])!= len(saveatt))): + print >>sys.stderr, str(dn) + " has no attr " +att+ " or a wrong value" + for satt in saveatt: + print >>sys.stderr,str(att)+" = "+satt + sam_ldb.transaction_cancel() + sam_ldb.transaction_commit() + + +paths = get_paths(targetdir=opts.targetdir, smbconf=smbconf) rebuild_en_dn(creds,session,paths) diff --git a/source4/scripting/bin/rpcclient b/source4/scripting/bin/rpcclient index 68b33fe..871dc74 100755 --- a/source4/scripting/bin/rpcclient +++ b/source4/scripting/bin/rpcclient @@ -23,7 +23,7 @@ def swig2dict(obj): if attr == 'this' or attr == 'thisown': continue - + result[attr] = getattr(obj, attr) return result @@ -51,7 +51,7 @@ class rpcclient(Cmd): Cmd.onecmd(self, line) except dcerpc.NTSTATUS, arg: print 'The command returned an error: %s' % arg[1] - + # Command handlers def do_help(self, line): @@ -67,7 +67,7 @@ class rpcclient(Cmd): print 'Command exited with code %d' % os.WEXITSTATUS(status) else: print 'Command exited with signal %d' % os.WTERMSIG(status) - + def do_EOF(self, line): """Exits rpcclient.""" print @@ -77,7 +77,7 @@ class rpcclient(Cmd): def do_SamrEnumDomains(self, line): """Enumerate domain names.""" - + usage = 'usage: SamrEnumDomains' if line != '': @@ -116,16 +116,16 @@ class rpcclient(Cmd): print connect_handle.LookupDomain(args[0]) def do_SamrQueryDomInfo(self, line): - """Return information about a domain designated by its SID.""" + """Return information about a domain designated by its SID.""" - usage = 'SamrQueryDomInfo DOMAIN_SID [info_level]' + usage = 'SamrQueryDomInfo DOMAIN_SID [info_level]' - parser = OptionParser(usage) - options, args = parser.parse_args(string.split(line)) + parser = OptionParser(usage) + options, args = parser.parse_args(string.split(line)) - if (len(args) == 0) or (len(args) > 2): - print 'usage:', usage - return + if (len(args) == 0) or (len(args) > 2): + print 'usage:', usage + return pipe = dcerpc.pipe_connect( 'ncacn_np:%s' % self.server, @@ -133,26 +133,26 @@ class rpcclient(Cmd): self.cred) connect_handle = samr.Connect(pipe) - domain_handle = connect_handle.OpenDomain(args[0]) + domain_handle = connect_handle.OpenDomain(args[0]) - if (len(args) == 2): - result = domain_handle.QueryDomainInfo(int(args[1])) - else: - result = domain_handle.QueryDomainInfo() + if (len(args) == 2): + result = domain_handle.QueryDomainInfo(int(args[1])) + else: + result = domain_handle.QueryDomainInfo() pprint(swig2dict(result)) def do_SamrQueryDomInfo2(self, line): - """Return information about a domain designated by its SID. + """Return information about a domain designated by its SID. (Windows 2000 and >)""" - usage = 'SamrQueryDomInfo2 DOMAIN_SID [info_level] (Windows 2000 and >)' - parser = OptionParser(usage) - options, args = parser.parse_args(string.split(line)) + usage = 'SamrQueryDomInfo2 DOMAIN_SID [info_level] (Windows 2000 and >)' + parser = OptionParser(usage) + options, args = parser.parse_args(string.split(line)) - if len(args) == 0 or len(args) > 2: - print 'usage:', usage - return + if len(args) == 0 or len(args) > 2: + print 'usage:', usage + return pipe = dcerpc.pipe_connect( 'ncacn_np:%s' % self.server, @@ -160,19 +160,19 @@ class rpcclient(Cmd): self.cred) connect_handle = samr.Connect(pipe) - domain_handle = connect_handle.OpenDomain(args[0]) + domain_handle = connect_handle.OpenDomain(args[0]) - if (len(args) == 2): - result = domain_handle.QueryDomainInfo2(int(args[1])) - else: - result = domain_handle.QueryDomainInfo2() + if (len(args) == 2): + result = domain_handle.QueryDomainInfo2(int(args[1])) + else: + result = domain_handle.QueryDomainInfo2() pprint(swig2dict(result)) def do_SamrEnumDomainGroups(self, line): - """Return the list of groups of a domain designated by its SID.""" + """Return the list of groups of a domain designated by its SID.""" - usage = 'SamrEnumDomainGroups DOMAIN_SID' + usage = 'SamrEnumDomainGroups DOMAIN_SID' parser = OptionParser(usage) options, args = parser.parse_args(string.split(line)) @@ -186,10 +186,10 @@ class rpcclient(Cmd): dcerpc.DCERPC_SAMR_UUID, int(dcerpc.DCERPC_SAMR_VERSION), self.cred) - connect_handle = samr.Connect(pipe) - domain_handle = connect_handle.OpenDomain(args[0]) + connect_handle = samr.Connect(pipe) + domain_handle = connect_handle.OpenDomain(args[0]) - result = domain_handle.EnumDomainGroups() + result = domain_handle.EnumDomainGroups() pprint(result) @@ -197,7 +197,7 @@ class rpcclient(Cmd): """Return the list of aliases (local groups) of a domain designated by its SID.""" - usage = 'SamrEnumDomainAliases DOMAIN_SID' + usage = 'SamrEnumDomainAliases DOMAIN_SID' parser = OptionParser(usage) options, args = parser.parse_args(string.split(line)) @@ -214,21 +214,21 @@ class rpcclient(Cmd): connect_handle = samr.Connect(pipe) domain_handle = connect_handle.OpenDomain(args[0]) - result = domain_handle.EnumDomainAliases() + result = domain_handle.EnumDomainAliases() pprint(result) def do_SamrEnumDomainUsers(self, line): - """Return the list of users of a domain designated by its SID.""" + """Return the list of users of a domain designated by its SID.""" - usage = 'SamrEnumDomainUsers DOMAIN_SID [user_account_flags]' + usage = 'SamrEnumDomainUsers DOMAIN_SID [user_account_flags]' parser = OptionParser(usage) options, args = parser.parse_args(string.split(line)) - if (len(args) == 0) or (len(args) > 2): - print 'usage:', usage - return + if (len(args) == 0) or (len(args) > 2): + print 'usage:', usage + return pipe = dcerpc.pipe_connect( 'ncacn_np:%s' % self.server, @@ -238,10 +238,10 @@ class rpcclient(Cmd): connect_handle = samr.Connect(pipe) domain_handle = connect_handle.OpenDomain(args[0]) - if (len(args) == 2): - result = domain_handle.EnumDomainUsers(int(args[1])) - else: - result = domain_handle.EnumDomainUsers() + if (len(args) == 2): + result = domain_handle.EnumDomainUsers(int(args[1])) + else: + result = domain_handle.EnumDomainUsers() pprint(result) @@ -288,7 +288,7 @@ if __name__ == '__main__': username = options.username if username != '': - cred = (domain, username, password) + cred = (domain, username, password) # Run command loop diff --git a/source4/scripting/bin/smbstatus b/source4/scripting/bin/smbstatus index 16559e7..055753b 100755 --- a/source4/scripting/bin/smbstatus +++ b/source4/scripting/bin/smbstatus @@ -18,45 +18,45 @@ import samba.getopt as options from samba import irpc, messaging def show_sessions(conn): - """show open sessions""" + """show open sessions""" - sessions = conn.smbsrv_information(irpc.SMBSRV_INFO_SESSIONS).next() - print "User Client Connected at" - print "-" * 79 - for session in sessions: - fulluser = "%s/%s" % (session.account_name, session.domain_name) - print "%-30s %16s %s" % (fulluser, session.client_ip, sys.httptime(session.connect_time)) - print "" + sessions = conn.smbsrv_information(irpc.SMBSRV_INFO_SESSIONS).next() + print "User Client Connected at" + print "-" * 79 + for session in sessions: + fulluser = "%s/%s" % (session.account_name, session.domain_name) + print "%-30s %16s %s" % (fulluser, session.client_ip, sys.httptime(session.connect_time)) + print "" def show_tcons(open_connection): - """show open tree connects""" - conn = open_connection("smb_server") - tcons = conn.smbsrv_information(irpc.SMBSRV_INFO_TCONS).next() - print "Share Client Connected at" - print "-" * 79 - for tcon in tcons: - print "%-30s %16s %s" % (tcon.share_name, tcon.client_ip, sys.httptime(tcon.connect_time)) + """show open tree connects""" + conn = open_connection("smb_server") + tcons = conn.smbsrv_information(irpc.SMBSRV_INFO_TCONS).next() + print "Share Client Connected at" + print "-" * 79 + for tcon in tcons: + print "%-30s %16s %s" % (tcon.share_name, tcon.client_ip, sys.httptime(tcon.connect_time)) def show_nbt(open_connection): - """show nbtd information""" - conn = open_connection("nbt_server") - stats = conn.nbtd_information(irpc.NBTD_INFO_STATISTICS).next() - print "NBT server statistics:" - fields = [("total_received", "Total received"), - ("total_sent", "Total sent"), - ("query_count", "Query count"), - ("register_count", "Register count"), - ("release_count", "Release count")] - for (field, description) in fields: - print "\t%s:\t%s" % (description, getattr(stats, field)) - print + """show nbtd information""" + conn = open_connection("nbt_server") + stats = conn.nbtd_information(irpc.NBTD_INFO_STATISTICS).next() + print "NBT server statistics:" + fields = [("total_received", "Total received"), + ("total_sent", "Total sent"), + ("query_count", "Query count"), + ("register_count", "Register count"), + ("release_count", "Release count")] + for (field, description) in fields: + print "\t%s:\t%s" % (description, getattr(stats, field)) + print parser = optparse.OptionParser("%s [options]" % sys.argv[0]) sambaopts = options.SambaOptions(parser) parser.add_option_group(sambaopts) parser.add_option("--messaging-path", type="string", metavar="PATH", - help="messaging path") + help="messaging path") parser.add_option("--nbt", help="show NetBIOS status", action="store_true") -- Samba Shared Repository