summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/librpc/config.mk114
-rwxr-xr-xsource4/librpc/scripts/build_idl.sh2
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/Python.pm27
-rwxr-xr-xsource4/scripting/bin/samr.py114
-rw-r--r--source4/scripting/libjs/samr.js170
-rw-r--r--source4/scripting/libjs/winreg.js291
-rw-r--r--source4/scripting/python/pytalloc.c11
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/sam.py22
-rwxr-xr-xsource4/selftest/samba4_tests.sh3
-rwxr-xr-xsource4/selftest/selftest.pl16
-rwxr-xr-xsource4/setup/provision-backend9
11 files changed, 179 insertions, 600 deletions
diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk
index cbb0d19564..c7cbf27667 100644
--- a/source4/librpc/config.mk
+++ b/source4/librpc/config.mk
@@ -607,120 +607,6 @@ PUBLIC_HEADERS += $(addprefix $(librpcsrcdir)/, rpc/dcerpc.h \
gen_ndr/epmapper.h gen_ndr/ndr_epmapper.h gen_ndr/ndr_epmapper_c.h)
-[MODULE::RPC_EJS_ECHO]
-INIT_FUNCTION = ejs_init_rpcecho
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_ECHO EJSRPC
-
-RPC_EJS_ECHO_OBJ_FILES = $(gen_ndrsrcdir)/ndr_echo_ejs.o
-
-[MODULE::RPC_EJS_MISC]
-INIT_FUNCTION = ejs_init_misc
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_MISC EJSRPC
-
-RPC_EJS_MISC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_misc_ejs.o
-
-[MODULE::RPC_EJS_SAMR]
-INIT_FUNCTION = ejs_init_samr
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_SAMR EJSRPC RPC_EJS_LSA RPC_EJS_SECURITY RPC_EJS_MISC
-
-RPC_EJS_SAMR_OBJ_FILES = $(gen_ndrsrcdir)/ndr_samr_ejs.o
-
-[MODULE::RPC_EJS_SECURITY]
-INIT_FUNCTION = ejs_init_security
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_SECURITY EJSRPC
-
-RPC_EJS_SECURITY_OBJ_FILES = $(gen_ndrsrcdir)/ndr_security_ejs.o
-
-[MODULE::RPC_EJS_LSA]
-INIT_FUNCTION = ejs_init_lsarpc
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_LSA EJSRPC RPC_EJS_SECURITY RPC_EJS_MISC
-
-RPC_EJS_LSA_OBJ_FILES = $(gen_ndrsrcdir)/ndr_lsa_ejs.o
-
-[MODULE::RPC_EJS_DFS]
-INIT_FUNCTION = ejs_init_netdfs
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_DFS EJSRPC
-
-RPC_EJS_DFS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dfs_ejs.o
-
-[MODULE::RPC_EJS_DRSUAPI]
-INIT_FUNCTION = ejs_init_drsuapi
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_DRSUAPI EJSRPC RPC_EJS_MISC RPC_EJS_SAMR
-
-RPC_EJS_DRSUAPI_OBJ_FILES = $(gen_ndrsrcdir)/ndr_drsuapi_ejs.o
-
-[MODULE::RPC_EJS_SPOOLSS]
-INIT_FUNCTION = ejs_init_spoolss
-SUBSYSTEM = smbcalls
-ENABLE = NO
-PRIVATE_DEPENDENCIES = dcerpc NDR_SPOOLSS EJSRPC
-
-RPC_EJS_SPOOLSS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_spoolss_ejs.o
-
-[MODULE::RPC_EJS_WKSSVC]
-INIT_FUNCTION = ejs_init_wkssvc
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_WKSSVC EJSRPC RPC_EJS_SRVSVC RPC_EJS_MISC
-
-RPC_EJS_WKSSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_wkssvc_ejs.o
-
-[MODULE::RPC_EJS_SRVSVC]
-INIT_FUNCTION = ejs_init_srvsvc
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_SRVSVC EJSRPC RPC_EJS_MISC RPC_EJS_SVCCTL RPC_EJS_SECURITY
-
-RPC_EJS_SRVSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_srvsvc_ejs.o
-
-[MODULE::RPC_EJS_EVENTLOG]
-INIT_FUNCTION = ejs_init_eventlog
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_EVENTLOG EJSRPC RPC_EJS_MISC
-
-RPC_EJS_EVENTLOG_OBJ_FILES = $(gen_ndrsrcdir)/ndr_eventlog_ejs.o
-
-[MODULE::RPC_EJS_WINREG]
-INIT_FUNCTION = ejs_init_winreg
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_WINREG EJSRPC RPC_EJS_INITSHUTDOWN \
- RPC_EJS_MISC RPC_EJS_SECURITY
-
-RPC_EJS_WINREG_OBJ_FILES = $(gen_ndrsrcdir)/ndr_winreg_ejs.o
-
-[MODULE::RPC_EJS_INITSHUTDOWN]
-INIT_FUNCTION = ejs_init_initshutdown
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_INITSHUTDOWN EJSRPC
-
-RPC_EJS_INITSHUTDOWN_OBJ_FILES = $(gen_ndrsrcdir)/ndr_initshutdown_ejs.o
-
-[MODULE::RPC_EJS_NETLOGON]
-INIT_FUNCTION = ejs_init_netlogon
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_NETLOGON EJSRPC RPC_EJS_SAMR RPC_EJS_SECURITY RPC_EJS_MISC
-
-RPC_EJS_NETLOGON_OBJ_FILES = $(gen_ndrsrcdir)/ndr_netlogon_ejs.o
-
-[MODULE::RPC_EJS_SVCCTL]
-INIT_FUNCTION = ejs_init_svcctl
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_SVCCTL EJSRPC RPC_EJS_MISC
-
-RPC_EJS_SVCCTL_OBJ_FILES = $(gen_ndrsrcdir)/ndr_svcctl_ejs.o
-
-[MODULE::RPC_EJS_IRPC]
-INIT_FUNCTION = ejs_init_irpc
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_IRPC EJSRPC
-
-RPC_EJS_IRPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_irpc_ejs.o
-
[PYTHON::swig_dcerpc]
LIBRARY_REALNAME = samba/dcerpc/_dcerpc.$(SHLIBEXT)
PUBLIC_DEPENDENCIES = LIBCLI_SMB NDR_MISC LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG dcerpc_samr RPC_NDR_LSA DYNCONFIG
diff --git a/source4/librpc/scripts/build_idl.sh b/source4/librpc/scripts/build_idl.sh
index 5796f40c61..3f13b64a2e 100755
--- a/source4/librpc/scripts/build_idl.sh
+++ b/source4/librpc/scripts/build_idl.sh
@@ -8,7 +8,7 @@ PIDL_EXTRA_ARGS="$*"
[ -d $OUTDIR ] || mkdir -p $OUTDIR || exit 1
-PIDL="$PIDL --outputdir $OUTDIR --header --ndr-parser --server --client --swig --ejs --python $PIDL_EXTRA_ARGS"
+PIDL="$PIDL --outputdir $OUTDIR --header --ndr-parser --server --client --swig --python $PIDL_EXTRA_ARGS"
if [ x$FULLBUILD = xFULL ]; then
echo Rebuilding all idl files in $IDLDIR
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 884ee1d822..440b1bff97 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -203,7 +203,7 @@ sub PythonStruct($$$$$$)
$self->pidl("return 0;");
$self->deindent;
$self->pidl("}");
- $self->pidl("");
+ $self->pidl("");
}
$getsetters = "py_$name\_getsetters";
@@ -253,6 +253,20 @@ sub PythonStruct($$$$$$)
return "&$typeobject";
}
+sub get_metadata_var($)
+{
+ my ($e) = @_;
+ sub get_var($) { my $x = shift; $x =~ s/\*//g; return $x; }
+
+ if (has_property($e, "length_is")) {
+ return get_var($e->{PROPERTIES}->{length_is});
+ } elsif (has_property($e, "size_is")) {
+ return get_var($e->{PROPERTIES}->{size_is});
+ }
+
+ return undef;
+}
+
sub PythonFunctionBody($$$)
{
my ($self, $fn, $iface, $prettyname) = @_;
@@ -274,17 +288,10 @@ sub PythonFunctionBody($$$)
my $metadata_args = { in => {}, out => {} };
- sub get_var($) { my $x = shift; $x =~ s/\*//g; return $x; }
-
# Determine arguments that are metadata for other arguments (size_is/length_is)
foreach my $e (@{$fn->{ELEMENTS}}) {
foreach my $dir (@{$e->{DIRECTION}}) {
- my $main = undef;
- if (has_property($e, "length_is")) {
- $main = get_var($e->{PROPERTIES}->{length_is});
- } elsif (has_property($e, "size_is")) {
- $main = get_var($e->{PROPERTIES}->{size_is});
- }
+ my $main = get_metadata_var($e);
if ($main) {
$metadata_args->{$dir}->{$main} = $e->{NAME};
}
@@ -651,7 +658,7 @@ sub Interface($$$)
$self->pidl("");
my $signature =
-"\"$interface->{NAME}(binding, lp_ctx=None, credentials=None) -> Connection to DCE/RPC interface.\\n\"
+"\"$interface->{NAME}(binding, lp_ctx=None, credentials=None) -> connection\\n\"
\"\\n\"
\"binding should be a DCE/RPC binding string (for example: ncacn_ip_tcp:127.0.0.1)\\n\"
\"lp_ctx should be a path to a smb.conf file or a param.LoadParm object\\n\"
diff --git a/source4/scripting/bin/samr.py b/source4/scripting/bin/samr.py
new file mode 100755
index 0000000000..e91b5bc312
--- /dev/null
+++ b/source4/scripting/bin/samr.py
@@ -0,0 +1,114 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Unix SMB/CIFS implementation.
+# Copyright © Jelmer Vernooij <jelmer@samba.org> 2008
+#
+# Based on samr.js © Andrew Tridgell <tridge@samba.org>
+#
+# 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 sys
+
+sys.path.insert(0, "bin/python")
+
+from samba.dcerpc import samr, security, lsa
+
+def FillUserInfo(samr, dom_handle, users, level):
+ """fill a user array with user information from samrQueryUserInfo"""
+ for i in range(len(users)):
+ user_handle = samr.OpenUser(handle, security.SEC_FLAG_MAXIMUM_ALLOWED, users[i].idx)
+ info = samr.QueryUserInfo(user_handle, level)
+ info.name = users[i].name
+ info.idx = users[i].idx
+ users[i] = info
+ samr.Close(user_handle)
+
+def toArray((handle, array, num_entries)):
+ ret = []
+ for x in range(num_entries):
+ ret.append((array.entries[x].idx, array.entries[x].name))
+ return ret
+
+
+def test_Connect(samr):
+ """test the samr_Connect interface"""
+ print "Testing samr_Connect"
+ return samr.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED)
+
+def test_LookupDomain(samr, handle, domain):
+ """test the samr_LookupDomain interface"""
+ print "Testing samr_LookupDomain"
+ return samr.LookupDomain(handle, domain)
+
+def test_OpenDomain(samr, handle, sid):
+ """test the samr_OpenDomain interface"""
+ print "Testing samr_OpenDomain"
+ return samr.OpenDomain(handle, security.SEC_FLAG_MAXIMUM_ALLOWED, sid)
+
+def test_EnumDomainUsers(samr, dom_handle):
+ """test the samr_EnumDomainUsers interface"""
+ print "Testing samr_EnumDomainUsers"
+ users = toArray(samr.EnumDomainUsers(dom_handle, 0, 0, -1))
+ print "Found %d users" % len(users)
+ for idx, user in users:
+ print "\t%s\t(%d)" % (user, idx)
+
+def test_EnumDomainGroups(samr, dom_handle):
+ """test the samr_EnumDomainGroups interface"""
+ print "Testing samr_EnumDomainGroups"
+ groups = toArray(samr.EnumDomainGroups(dom_handle, 0, 0))
+ print "Found %d groups" % len(groups)
+ for idx, group in groups:
+ print "\t%s\t(%d)" % (group, idx)
+
+def test_domain_ops(samr, dom_handle):
+ """test domain specific ops"""
+ test_EnumDomainUsers(samr, dom_handle)
+ test_EnumDomainGroups(samr, dom_handle)
+
+def test_EnumDomains(samr, handle):
+ """test the samr_EnumDomains interface"""
+ print "Testing samr_EnumDomains"
+
+ domains = toArray(samr.EnumDomains(handle, 0, -1))
+ print "Found %d domains" % len(domains)
+ for idx, domain in domains:
+ print "\t%s (%d)" % (domain, idx)
+ for idx, domain in domains:
+ print "Testing domain %s" % domain
+ sid = samr.LookupDomain(handle, domain)
+ dom_handle = test_OpenDomain(samr, handle, sid)
+ test_domain_ops(samr, dom_handle)
+ samr.Close(dom_handle)
+
+if len(sys.argv) != 2:
+ print "Usage: samr.js <BINDING>"
+ sys.exit(1)
+
+binding = sys.argv[1]
+
+print "Connecting to " + binding
+try:
+ samr = samr.samr(binding)
+except Exception, e:
+ print "Failed to connect to %s: %s" % (binding, e.message)
+ sys.exit(1)
+
+handle = test_Connect(samr)
+test_EnumDomains(samr, handle)
+samr.Close(handle)
+
+print "All OK"
diff --git a/source4/scripting/libjs/samr.js b/source4/scripting/libjs/samr.js
deleted file mode 100644
index 6e8c70af3c..0000000000
--- a/source4/scripting/libjs/samr.js
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- samr rpc utility functions
- Copyright Andrew Tridgell 2005
- released under the GNU GPL version 3 or later
-*/
-
-if (global["HAVE_SAMR_JS"] != undefined) {
- return;
-}
-HAVE_SAMR_JS=1
-
-/*
- return a list of names and indexes from a samArray
-*/
-function samArray(output)
-{
- var list = new Array(output.num_entries);
- if (output.sam == NULL) {
- return list;
- }
- var i, entries = output.sam.entries;
- for (i=0;i<output.num_entries;i++) {
- list[i] = new Object();
- list[i].name = entries[i].name;
- list[i].idx = entries[i].idx;
- }
- return list;
-}
-
-/*
- connect to the sam database
-*/
-function samrConnect(conn)
-{
- security_init(conn);
- var io = irpcObj();
- io.input.system_name = NULL;
- io.input.access_mask = conn.SEC_FLAG_MAXIMUM_ALLOWED;
- var status = conn.samr_Connect2(io);
- check_status_ok(status);
- return io.output.connect_handle;
-}
-
-/*
- close a handle
-*/
-function samrClose(conn, handle)
-{
- var io = irpcObj();
- io.input.handle = handle;
- var status = conn.samr_Close(io);
- check_status_ok(status);
-}
-
-/*
- get the sid for a domain
-*/
-function samrLookupDomain(conn, handle, domain)
-{
- var io = irpcObj();
- io.input.connect_handle = handle;
- io.input.domain_name = domain;
- var status = conn.samr_LookupDomain(io);
- check_status_ok(status);
- return io.output.sid;
-}
-
-/*
- open a domain by sid
-*/
-function samrOpenDomain(conn, handle, sid)
-{
- var io = irpcObj();
- io.input.connect_handle = handle;
- io.input.access_mask = conn.SEC_FLAG_MAXIMUM_ALLOWED;
- io.input.sid = sid;
- var status = conn.samr_OpenDomain(io);
- check_status_ok(status);
- return io.output.domain_handle;
-}
-
-/*
- open a user by rid
-*/
-function samrOpenUser(conn, handle, rid)
-{
- var io = irpcObj();
- io.input.domain_handle = handle;
- io.input.access_mask = conn.SEC_FLAG_MAXIMUM_ALLOWED;
- io.input.rid = rid;
- var status = conn.samr_OpenUser(io);
- check_status_ok(status);
- return io.output.user_handle;
-}
-
-/*
- return a list of all users
-*/
-function samrEnumDomainUsers(conn, dom_handle)
-{
- var io = irpcObj();
- io.input.domain_handle = dom_handle;
- io.input.resume_handle = 0;
- io.input.acct_flags = 0;
- io.input.max_size = -1;
- var status = conn.samr_EnumDomainUsers(io);
- check_status_ok(status);
- return samArray(io.output);
-}
-
-/*
- return a list of all groups
-*/
-function samrEnumDomainGroups(conn, dom_handle)
-{
- var io = irpcObj();
- io.input.domain_handle = dom_handle;
- io.input.resume_handle = 0;
- io.input.acct_flags = 0;
- io.input.max_size = -1;
- var status = conn.samr_EnumDomainGroups(io);
- check_status_ok(status);
- return samArray(io.output);
-}
-
-/*
- return a list of domains
-*/
-function samrEnumDomains(conn, handle)
-{
- var io = irpcObj();
- io.input.connect_handle = handle;
- io.input.resume_handle = 0;
- io.input.buf_size = -1;
- var status = conn.samr_EnumDomains(io);
- check_status_ok(status);
- return samArray(io.output);
-}
-
-/*
- return information about a user
-*/
-function samrQueryUserInfo(conn, user_handle, level)
-{
- var r, io = irpcObj();
- io.input.user_handle = user_handle;
- io.input.level = level;
- var status = conn.samr_QueryUserInfo(io);
- check_status_ok(status);
- return io.output.info.info3;
-}
-
-
-/*
- fill a user array with user information from samrQueryUserInfo
-*/
-function samrFillUserInfo(conn, dom_handle, users, level)
-{
- var i;
- for (i=0;i<users.length;i++) {
- var r, user_handle, info;
- user_handle = samrOpenUser(conn, dom_handle, users[i].idx);
- info = samrQueryUserInfo(conn, user_handle, level);
- info.name = users[i].name;
- info.idx = users[i].idx;
- users[i] = info;
- samrClose(conn, user_handle);
- }
-}
-
diff --git a/source4/scripting/libjs/winreg.js b/source4/scripting/libjs/winreg.js
deleted file mode 100644
index 9db415694d..0000000000
--- a/source4/scripting/libjs/winreg.js
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- winreg rpc utility functions
- Copyright Andrew Tridgell 2005
- released under the GNU GPL version 3 or later
-*/
-
-libinclude("base.js");
-
-/*
- close a handle
-*/
-function __winreg_close(handle)
-{
- var io = irpcObj();
- io.input.handle = handle;
- this.winreg_CloseKey(io);
-}
-
-
-/*
- open a hive
-*/
-function __winreg_open_hive(hive)
-{
- var io = irpcObj();
- io.input.system_name = NULL;
- io.input.access_mask = this.SEC_FLAG_MAXIMUM_ALLOWED;
- var status;
- if (hive == "HKLM") {
- status = this.winreg_OpenHKLM(io);
- } else if (hive == "HKCR") {
- status = this.winreg_OpenHKCR(io);
- } else if (hive == "HKPD") {
- status = this.winreg_OpenHKPD(io);
- } else if (hive == "HKU") {
- status = this.winreg_OpenHKU(io);
- } else {
- this._last_error = "Unknown hive " + hive;
- return undefined;
- }
- if (!status.is_ok) {
- return undefined;
- }
- return io.output.handle;
-}
-
-/*
- open a handle to a path
-*/
-function __winreg_open_path(path)
-{
- var s = string_init();
- var i, components = s.split('\\', path);
-
- /* cope with a leading slash */
- if (components[0] == '') {
- for (i=0;i<(components.length-1);i++) {
- components[i] = components[i+1];
- }
- delete(components[i]);
- }
-
- if (components.length == 0) {
- return undefined;
- }
-
- var handle = this.open_hive(components[0]);
- if (handle == undefined) {
- return undefined;
- }
-
- if (components.length == 1) {
- return handle;
- }
-
- var hpath = components[1];
-
- for (i=2;i<components.length;i++) {
- hpath = hpath + "\\" + components[i];
- }
-
- io = irpcObj();
- io.input.parent_handle = handle;
- io.input.keyname = hpath;
- io.input.unknown = 0;
- io.input.access_mask = this.SEC_FLAG_MAXIMUM_ALLOWED;
- var status = this.winreg_OpenKey(io);
-
- this.close(handle);
-
- if (!status.is_ok) {
- return undefined;
- }
- if (io.output.result != "WERR_OK") {
- return undefined;
- }
-
- return io.output.handle;
-}
-
-/*
- return a list of keys for a winreg server given a path
- usage:
- list = reg.enum_path(path);
-*/
-function __winreg_enum_path(path)
-{
- var list = new Array(0);
-
- if (path == null || path == "\\" || path == "") {
- return new Array("HKLM", "HKU");
- }
-
- var handle = this.open_path(path);
- if (handle == undefined) {
- return undefined;
- }
-
- var io = irpcObj();
- io.input.handle = handle;
- io.input.name = new Object();
- io.input.name.length = 0;
- io.input.name.size = 32;
- io.input.name.name = NULL;
- io.input.keyclass = new Object();
- io.input.keyclass.length = 0;
- io.input.keyclass.size = 1024;
- io.input.keyclass.name = NULL;
- io.input.last_changed_time = 0;
-
- var idx = 0;
- for (idx=0;idx >= 0;idx++) {
- io.input.enum_index = idx;
- var status = this.winreg_EnumKey(io);
- if (!status.is_ok) {
- this.close(handle);
- return list;
- }
- var out = io.output;
- if (out.result == "WERR_MORE_DATA") {
- io.input.name.size = io.input.name.size * 2;
- idx--;
- if (io.input.name.size > 32000) {
- this.close(handle);
- return list;
- }
- continue;
- }
- if (out.result != "WERR_OK") {
- this.close(handle);
- return list;
- }
- list[list.length] = out.name.name;
- }
-
- this.close(handle);
- return list;
-}
-
-
-/*
- return a list of values for a winreg server given a path
- usage:
- list = reg.enum_values(path);
-
- each returned list element is an object containing a name, a
- type and a value
-*/
-function __winreg_enum_values(path)
-{
- var data = datablob_init();
- var list = new Array(0);
-
- var handle = this.open_path(path);
- if (handle == undefined) {
- return undefined;
- }
-
- var io = irpcObj();
- io.input.handle = handle;
- io.input.name = new Object();
- io.input.name.length = 0;
- io.input.name.size = 128;
- io.input.name.name = "";
- io.input.type = 0;
- io.input.value = new Array(0);
- io.input.size = 1024;
- io.input.length = 0;
-
- var idx;
- for (idx=0;idx >= 0;idx++) {
- io.input.enum_index = idx;
- var status = this.winreg_EnumValue(io);
- if (!status.is_ok) {
- this.close(handle);
- return list;
- }
- var out = io.output;
- if (out.result == "WERR_MORE_DATA") {
- io.input.size = io.input.size * 2;
- io.input.name.size = io.input.name.size * 2;
- idx--;
- /* limit blobs to 1M */
- if (io.input.size > 1000000) {
- this.close(handle);
- return list;
- }
- continue;
- }
- if (out.result != "WERR_OK") {
- this.close(handle);
- return list;
- }
- var el = new Object();
- el.name = out.name.name;
- el.type = out.type;
- el.rawvalue = out.value;
- el.value = data.regToVar(el.rawvalue, el.type);
- el.size = out.size;
- list[list.length] = el;
- }
-
- this.close(handle);
- return list;
-}
-
-
-/*
- create a new key
- ok = reg.create_key(path, key);
-*/
-function __winreg_create_key(path, key)
-{
- var handle = this.open_path(path);
- if (handle == undefined) {
- return undefined;
- }
-
- var io = irpcObj();
- io.input.handle = handle;
- io.input.name = key;
- io.input.keyclass = NULL;
- io.input.options = 0;
- io.input.access_mask = this.SEC_FLAG_MAXIMUM_ALLOWED;
- io.input.secdesc = NULL;
- io.input.action_taken = 0;
-
- var status = this.winreg_CreateKey(io);
- this.close(handle);
- if (!status.is_ok) {
- return false;
- }
- if (io.output.result != "WERR_OK") {
- return false;
- }
- this.close(io.output.new_handle);
- return true;
-}
-
-
-/*
- return a string for a winreg type
-*/
-function __winreg_typestring(type)
-{
- return this.typenames[type];
-}
-
-/*
- initialise the winreg lib, returning an object
-*/
-function winregObj()
-{
- var reg = winreg_init();
- security_init(reg);
-
- reg.typenames = new Array("REG_NONE", "REG_SZ", "REG_EXPAND_SZ", "REG_BINARY",
- "REG_DWORD", "REG_DWORD_BIG_ENDIAN", "REG_LINK", "REG_MULTI_SZ",
- "REG_RESOURCE_LIST", "REG_FULL_RESOURCE_DESCRIPTOR",
- "REG_RESOURCE_REQUIREMENTS_LIST", "REG_QWORD");
-
- reg.close = __winreg_close;
- reg.open_hive = __winreg_open_hive;
- reg.open_path = __winreg_open_path;
- reg.enum_path = __winreg_enum_path;
- reg.enum_values = __winreg_enum_values;
- reg.create_key = __winreg_create_key;
- reg.typestring = __winreg_typestring;
-
- return reg;
-}
diff --git a/source4/scripting/python/pytalloc.c b/source4/scripting/python/pytalloc.c
index aa0ae9bf90..ca476e9604 100644
--- a/source4/scripting/python/pytalloc.c
+++ b/source4/scripting/python/pytalloc.c
@@ -24,6 +24,7 @@ void py_talloc_dealloc(PyObject* self)
{
py_talloc_Object *obj = (py_talloc_Object *)self;
talloc_free(obj->talloc_ctx);
+ obj->talloc_ctx = NULL;
PyObject_Del(self);
}
@@ -31,7 +32,13 @@ PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx,
void *ptr)
{
py_talloc_Object *ret = PyObject_New(py_talloc_Object, py_type);
- ret->talloc_ctx = talloc_reference(NULL, mem_ctx);
+ ret->talloc_ctx = talloc_new(NULL);
+ if (ret->talloc_ctx == NULL) {
+ return NULL;
+ }
+ if (talloc_reference(ret->talloc_ctx, mem_ctx) == NULL) {
+ return NULL;
+ }
ret->ptr = ptr;
return (PyObject *)ret;
}
@@ -41,5 +48,5 @@ PyObject *py_talloc_default_repr(PyObject *py_obj)
py_talloc_Object *obj = (py_talloc_Object *)py_obj;
PyTypeObject *type = (PyTypeObject*)PyObject_Type((PyObject *)obj);
- return PyString_FromFormat("<%s>", type->tp_name);
+ return PyString_FromFormat("<%s talloc object at 0x%x>", type->tp_name, (intptr_t)py_obj);
}
diff --git a/source4/scripting/python/samba/tests/dcerpc/sam.py b/source4/scripting/python/samba/tests/dcerpc/sam.py
index a6816153c0..50e00a3f9e 100644
--- a/source4/scripting/python/samba/tests/dcerpc/sam.py
+++ b/source4/scripting/python/samba/tests/dcerpc/sam.py
@@ -1,7 +1,8 @@
#!/usr/bin/python
+# -*- coding: utf-8 -*-
# Unix SMB/CIFS implementation.
-# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
+# Copyright © Jelmer Vernooij <jelmer@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
@@ -17,12 +18,29 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-from samba.dcerpc import samr
+from samba.dcerpc import samr, security
from samba.tests import RpcInterfaceTestCase
+# FIXME: Pidl should be doing this for us
+def toArray((handle, array, num_entries)):
+ ret = []
+ for x in range(num_entries):
+ ret.append((array.entries[x].idx, array.entries[x].name))
+ return ret
+
+
class SamrTests(RpcInterfaceTestCase):
def setUp(self):
self.conn = samr.samr("ncalrpc:", self.get_loadparm())
def test_connect5(self):
(level, info, handle) = self.conn.Connect5(None, 0, 1, samr.ConnectInfo1())
+
+ def test_connect2(self):
+ handle = self.conn.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED)
+
+ def test_EnumDomains(self):
+ handle = self.conn.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED)
+ domains = toArray(self.conn.EnumDomains(handle, 0, -1))
+ self.conn.Close(handle)
+
diff --git a/source4/selftest/samba4_tests.sh b/source4/selftest/samba4_tests.sh
index 2f65561ceb..36cf2adccb 100755
--- a/source4/selftest/samba4_tests.sh
+++ b/source4/selftest/samba4_tests.sh
@@ -64,8 +64,7 @@ SCRIPTDIR=$samba4srcdir/../testprogs/ejs
smb4torture="$samba4bindir/smbtorture $TORTURE_OPTIONS"
plantest "js.base" dc "$SCRIPTDIR/base.js" $CONFIGURATION
-plantest "js.samr" dc "$SCRIPTDIR/samr.js" $CONFIGURATION ncalrpc: -U\$USERNAME%\$PASSWORD
-plantest "js.echo" dc "$SCRIPTDIR/echo.js" $CONFIGURATION ncalrpc: -U\$USERNAME%\$PASSWORD
+plantest "samr.python" dc "$samba4bindir/../scripting/bin/samr.py" ncalrpc:
#plantest "ejsnet.js" dc "$SCRIPTDIR/ejsnet.js" $CONFIGURATION -U\$USERNAME%\$PASSWORD \$DOMAIN ejstestuser
plantest "js.ldb" none "$SCRIPTDIR/ldb.js" `pwd` $CONFIGURATION -d 10
plantest "js.winreg" dc $samba4srcdir/scripting/bin/winreg $CONFIGURATION ncalrpc: 'HKLM' -U\$USERNAME%\$PASSWORD
diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl
index 385d31bbfd..5854a94b8d 100755
--- a/source4/selftest/selftest.pl
+++ b/source4/selftest/selftest.pl
@@ -407,13 +407,19 @@ my $tls_enabled = not $opt_quick;
$ENV{TLS_ENABLED} = ($tls_enabled?"yes":"no");
$ENV{LDB_MODULES_PATH} = "$old_pwd/bin/modules/ldb";
$ENV{LD_SAMBA_MODULE_PATH} = "$old_pwd/bin/modules";
-if (defined($ENV{PKG_CONFIG_PATH})) {
- $ENV{PKG_CONFIG_PATH} = "$old_pwd/bin/pkgconfig:$ENV{PKG_CONFIG_PATH}";
-} else {
- $ENV{PKG_CONFIG_PATH} = "$old_pwd/bin/pkgconfig";
+sub prefix_pathvar($$)
+{
+ my ($name, $newpath) = @_;
+ if (defined($ENV{$name})) {
+ $ENV{$name} = "$newpath:$ENV{$name}";
+ } else {
+ $ENV{$name} = $newpath;
+ }
}
+prefix_pathvar("PKG_CONFIG_PATH", "$old_pwd/bin/pkgconfig");
# Required for smbscript:
-$ENV{PATH} = "$old_pwd/bin:$old_pwd:$ENV{PATH}";
+prefix_pathvar("PATH", "$old_pwd/bin");
+prefix_pathvar("PYTHONPATH", "$old_pwd/bin/python");
if ($opt_socket_wrapper_keep_pcap) {
# Socket wrapper keep pcap implies socket wrapper pcap
diff --git a/source4/setup/provision-backend b/source4/setup/provision-backend
index 4f222c467a..54dc5839bf 100755
--- a/source4/setup/provision-backend
+++ b/source4/setup/provision-backend
@@ -22,14 +22,17 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+import os, sys
+
+sys.path.insert(0, "bin/python")
+
import getopt
import optparse
-import os, sys
import samba
-import param
+from samba import param
-from auth import system_session
+from samba.auth import system_session
import samba.getopt as options
from samba.provision import (provision_backend)