From b4ce9dc3609aafd6df17bd3b57c0da63fdaba4b1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 13 Feb 2008 01:21:06 +0100 Subject: Fix invalid symbol. (This used to be commit bd0ef811c4e6419ba05076fbc151827cea5d1ca1) --- source4/scripting/python/samba/samdb.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source4/scripting/python/samba/samdb.py b/source4/scripting/python/samba/samdb.py index c11fabf553..3c6bb23c02 100644 --- a/source4/scripting/python/samba/samdb.py +++ b/source4/scripting/python/samba/samdb.py @@ -100,12 +100,14 @@ userAccountControl: %u self.transaction_start() # find the DNs for the domain and the domain users group - res = self.search("", SCOPE_BASE, "defaultNamingContext=*", - ["defaultNamingContext"]) + res = self.search("", scope=ldb.SCOPE_BASE, + expression="(defaultNamingContext=*)", + attrs=["defaultNamingContext"]) assert(len(res) == 1 and res[0].defaultNamingContext is not None) domain_dn = res[0]["defaultNamingContext"][0] assert(domain_dn is not None) - dom_users = self.searchone(basedn=domain_dn, attribute="dn", expression="name=Domain Users") + dom_users = self.searchone(basedn=domain_dn, attribute="dn", + expression="name=Domain Users") assert(dom_users is not None) user_dn = "CN=%s,CN=Users,%s" % (username, domain_dn) -- cgit From 9f01303d15e7691bd706010bc272074c96d3ecb9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 13 Feb 2008 01:22:09 +0100 Subject: Add python version of newuser.py. (This used to be commit f70aef8e51e1a2f186fe71edaa4c81a39b837573) --- source4/setup/newuser.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 source4/setup/newuser.py diff --git a/source4/setup/newuser.py b/source4/setup/newuser.py new file mode 100755 index 0000000000..03ae4e5ffb --- /dev/null +++ b/source4/setup/newuser.py @@ -0,0 +1,61 @@ +#!/usr/bin/python +# +# add a new user to a Samba4 server +# Copyright Andrew Tridgell 2005 +# Copyright Jelmer Vernooij 2008 +# Released under the GNU GPL v2 or later +# + +import samba.getopt as options +import optparse +import pwd +import sys + +from auth import system_session +from samba.samdb import SamDB + +parser = optparse.OptionParser("newuser [options] []") +sambaopts = options.SambaOptions(parser) +parser.add_option_group(sambaopts) +parser.add_option_group(options.VersionOptions(parser)) +credopts = options.CredentialsOptions(parser) +parser.add_option_group(credopts) +parser.add_option("--quiet", help="Be quiet", action="store_true") +parser.add_option("--unixname", help="Unix Username", type=str) + +opts, args = parser.parse_args() + +# +# print a message if quiet is not set +# +def message(text): + if not opts.quiet: + print text + +if len(args) == 0: + parser.print_usage() + sys.exit(1) + +username = args[0] +if len(args) > 1: + password = args[1] +else: + random_init(local) + options.password = randpass(12) + print "chose random password %s\n" % password + +if opts.unixname is None: + opts.unixname = username + +try: + pwd.getpwnam(opts.unixname) +except KeyError: + print "ERROR: Unix user '%s' does not exist" % opts.unixname + sys.exit(1) + +creds = credopts.get_credentials() + +lp = sambaopts.get_loadparm() +samdb = SamDB(url=lp.get("sam database"), session_info=system_session(), + credentials=creds, lp=lp) +samdb.newuser(username, opts.unixname, password) -- cgit From 08e3f99f14f178e87f3543261be59a7f97f60b4f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 13 Feb 2008 02:18:45 +0100 Subject: Initial work on a test for samba.tests.samdb (This used to be commit 8b33860954ca03be1ea45fd8d40963dbbd5b162f) --- source4/samba4-skip | 1 + source4/scripting/python/samba/provision.py | 3 +- source4/scripting/python/samba/tests/samdb.py | 55 +++++++++++++++++++++++++++ source4/selftest/samba4_tests.sh | 1 + 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 source4/scripting/python/samba/tests/samdb.py diff --git a/source4/samba4-skip b/source4/samba4-skip index b53f444c9c..ea69e297ce 100644 --- a/source4/samba4-skip +++ b/source4/samba4-skip @@ -50,4 +50,5 @@ RPC-FRSAPI # Not provided by Samba 4 WINBIND # FIXME: This should not be skipped NSS-TEST # Fails samba4.samba3sam.python # Conversion from EJS not yet finished +samba4.samdb.python # Not finished yet RAW-OFFLINE # Samba 4 doesn't have much offline support yet diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index 4f52d36167..97021fceb2 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -332,7 +332,6 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info, schemadn_ldb = "schema.ldb" if ldap_backend is not None: schema_ldb = ldap_backend - schemadn_ldb = ldap_backend if ldap_backend_type == "fedora-ds": @@ -536,6 +535,8 @@ def setup_samdb(path, setup_path, session_info, credentials, lp, :note: This will wipe the main SAM database file! """ + assert serverrole in ("domain controller", "member server") + # Also wipes the database setup_samdb_partitions(path, setup_path, schemadn=schemadn, configdn=configdn, domaindn=domaindn, message=message, lp=lp, diff --git a/source4/scripting/python/samba/tests/samdb.py b/source4/scripting/python/samba/tests/samdb.py new file mode 100644 index 0000000000..40e56bebb5 --- /dev/null +++ b/source4/scripting/python/samba/tests/samdb.py @@ -0,0 +1,55 @@ +#!/usr/bin/python + +# Unix SMB/CIFS implementation. Tests for SamDB +# Copyright (C) Jelmer Vernooij 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 . +# +from auth import system_session +from credentials import Credentials +import os +from samba.provision import setup_samdb +from samba.samdb import SamDB +from samba.tests import get_loadparm, TestCaseInTempDir +import security +from unittest import TestCase +import uuid + +class SamDBTestCase(TestCaseInTempDir): + def setUp(self): + super(SamDBTestCase, self).setUp() + invocationid = uuid.random() + domaindn = "DC=COM,DC=EXAMPLE" + self.domaindn = domaindn + configdn = "CN=Configuration," + domaindn + schemadn = "CN=Schema," + configdn + domainguid = uuid.random() + policyguid = uuid.random() + setup_path = lambda x: os.path.join("setup", x) + creds = Credentials() + domainsid = security.random_sid() + hostguid = uuid.random() + path = os.path.join(self.tempdir, "samdb.ldb") + self.samdb = setup_samdb(path, setup_path, system_session(), creds, + get_loadparm(), schemadn, configdn, + self.domaindn, "example.com", "EXAMPLE.COM", + "FOO", lambda x: None, "foo", domaindn, + False, domainsid, "# no aci", domainguid, + policyguid, "EXAMPLE", True, "secret", + "secret", "secret", hostguid, invocationid, + "secret", "domain controller") + + def test_add_foreign(self): + self.samdb.add_foreign(self.domaindn, "S-1-5-7", "Somedescription") + diff --git a/source4/selftest/samba4_tests.sh b/source4/selftest/samba4_tests.sh index c90373e446..2595d51177 100755 --- a/source4/selftest/samba4_tests.sh +++ b/source4/selftest/samba4_tests.sh @@ -320,6 +320,7 @@ then plantest "provision.python" none $SUBUNITRUN samba.tests.provision plantest "samba3.python" none $SUBUNITRUN samba.tests.samba3 plantest "samr.python" dc $SUBUNITRUN samba.tests.dcerpc.sam + plantest "samdb.python" dc $SUBUNITRUN samba.tests.samdb plantest "events.python" none PYTHONPATH="$PYTHONPATH:lib/events" $SUBUNITRUN tests plantest "samba3sam.python" none PYTHONPATH="$PYTHONPATH:dsdb/samdb/ldb_modules/tests" $SUBUNITRUN samba3sam plantest "rpcecho.python" dc $SUBUNITRUN samba.tests.dcerpc.rpcecho -- cgit From d4006e799ac1305092c2d292c9237f58938268a2 Mon Sep 17 00:00:00 2001 From: Julien Kerihuel Date: Wed, 13 Feb 2008 02:24:11 +0100 Subject: Support ETT_FIELD keyword. (This used to be commit ec8bd3991f76cf8746cf77c277c3491725711f9d) --- source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm | 19 +++++++++++++++++++ source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm b/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm index b53c56e741..a240bbf9cd 100644 --- a/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm +++ b/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm @@ -52,6 +52,10 @@ use old_hf_name. This can be used in conjunction with HF_FIELD in order to make more than one element use the same filter name. +=item I ett + +Register a custom ett field + =item I prefix Remove the specified prefix from all function names (if present). @@ -313,6 +317,20 @@ sub handle_import }; } +sub handle_ett_field +{ + my $pos = shift @_; + my $data = shift @_; + my $ett = shift @_; + + unless(defined($ett)) { + error($pos, "incomplete ETT_FIELD command"); + return; + }; + + push (@{$data->{ett}}, $ett); +} + my %field_handlers = ( TYPE => \&handle_type, NOEMIT => \&handle_noemit, @@ -320,6 +338,7 @@ my %field_handlers = ( PARAM_VALUE => \&handle_param_value, HF_FIELD => \&handle_hf_field, HF_RENAME => \&handle_hf_rename, + ETT_FIELD => \&handle_ett_field, TFS => \&handle_tfs, STRIP_PREFIX => \&handle_strip_prefix, PROTOCOL => \&handle_protocol, diff --git a/source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm index ffe104c941..8846b740ab 100644 --- a/source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm +++ b/source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm @@ -940,6 +940,10 @@ sub Parse($$$$$) $self->{res}->{headers} .= "#include \"$h_basename\"\n"; $self->pidl_code(""); + if (defined($self->{conformance}->{ett})) { + register_ett($self,$_) foreach(@{$self->{conformance}->{ett}}) + } + # Wireshark protocol registration foreach (@$ndr) { -- cgit