mirror of
https://github.com/samba-team/samba.git
synced 2025-03-12 20:58:37 +03:00
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into 4-0-abartlet
(This used to be commit 58e00594d8c191f499225aa2755a06bac2937300)
This commit is contained in:
commit
5eda5e5197
@ -30,11 +30,9 @@ INIT_FUNCTION = s4_events_standard_init
|
||||
|
||||
##############################
|
||||
# Start SUBSYSTEM LIBEVENTS
|
||||
[LIBRARY::LIBEVENTS]
|
||||
[SUBSYSTEM::LIBEVENTS]
|
||||
OBJ_FILES = events.o events_timed.o events_signal.o
|
||||
PUBLIC_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL
|
||||
SO_VERSION = 0
|
||||
VERSION = 0.0.1
|
||||
# End SUBSYSTEM LIBEVENTS
|
||||
##############################
|
||||
|
||||
|
@ -2,6 +2,3 @@
|
||||
OUTPUT_TYPE = STATIC_LIBRARY
|
||||
OBJ_FILES = talloc.o
|
||||
CFLAGS = -Ilib/talloc
|
||||
|
||||
|
||||
MANPAGES += $(tallocdir)/talloc.3
|
||||
|
@ -32,6 +32,6 @@ PUBLIC_DEPENDENCIES = CREDENTIALS dcerpc dcerpc_samr RPC_NDR_LSA RPC_NDR_SRVSVC
|
||||
# userinfo.h userman.h)
|
||||
|
||||
|
||||
[PYTHON::swig_net]
|
||||
PRIVATE_DEPENDENCIES = LIBSAMBA-NET
|
||||
SWIG_FILE = net.i
|
||||
[PYTHON::python_net]
|
||||
PRIVATE_DEPENDENCIES = LIBSAMBA-NET LIBPYTHON
|
||||
OBJ_FILES = py_net.o
|
||||
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
%module(package="samba.net") net
|
||||
|
||||
%{
|
||||
#include "includes.h"
|
||||
#include "libnet/libnet.h"
|
||||
#include "lib/events/events.h"
|
||||
#include "param/param.h"
|
||||
typedef struct libnet_context libnet;
|
||||
%}
|
||||
|
||||
%import "../libcli/util/errors.i"
|
||||
%import "../lib/events/events.i"
|
||||
%import "../lib/talloc/talloc.i"
|
||||
%import "../param/param.i"
|
||||
|
||||
%talloctype(libnet_context);
|
||||
|
||||
typedef struct libnet_context {
|
||||
struct cli_credentials *cred;
|
||||
%extend {
|
||||
libnet(struct event_context *ev, struct loadparm_context *lp_ctx) {
|
||||
return libnet_context_init(ev, lp_ctx);
|
||||
}
|
||||
NTSTATUS samsync_ldb(TALLOC_CTX *mem_ctx, struct libnet_samsync_ldb *r);
|
||||
NTSTATUS DomainList(TALLOC_CTX *mem_ctx, struct libnet_DomainList *io);
|
||||
NTSTATUS DomainClose(TALLOC_CTX *mem_ctx, struct libnet_DomainClose *io);
|
||||
NTSTATUS DomainOpen(TALLOC_CTX *mem_ctx, struct libnet_DomainOpen *io);
|
||||
NTSTATUS LookupName(TALLOC_CTX *mem_ctx, struct libnet_LookupName *io);
|
||||
NTSTATUS LookupDCs(TALLOC_CTX *mem_ctx, struct libnet_LookupDCs *io);
|
||||
NTSTATUS LookupHost(TALLOC_CTX *mem_ctx, struct libnet_Lookup *io);
|
||||
NTSTATUS Lookup(TALLOC_CTX *mem_ctx, struct libnet_Lookup *io);
|
||||
NTSTATUS ListShares(TALLOC_CTX *mem_ctx, struct libnet_ListShares *r);
|
||||
NTSTATUS AddShare(TALLOC_CTX *mem_ctx, struct libnet_AddShare *r);
|
||||
NTSTATUS DelShare(TALLOC_CTX *mem_ctx, struct libnet_DelShare *r);
|
||||
NTSTATUS GroupList(TALLOC_CTX *mem_ctx, struct libnet_GroupList *io);
|
||||
NTSTATUS GroupInfo(TALLOC_CTX *mem_ctx, struct libnet_GroupInfo *io);
|
||||
NTSTATUS UserList(TALLOC_CTX *mem_ctx, struct libnet_UserList *r);
|
||||
NTSTATUS UserInfo(TALLOC_CTX *mem_ctx, struct libnet_UserInfo *r);
|
||||
NTSTATUS ModifyUser(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r);
|
||||
NTSTATUS DeleteUser(TALLOC_CTX *mem_ctx, struct libnet_DeleteUser *r);
|
||||
NTSTATUS CreateUser(TALLOC_CTX *mem_ctx, struct libnet_CreateUser *r);
|
||||
NTSTATUS SamDump_keytab(TALLOC_CTX *mem_ctx, struct libnet_SamDump_keytab *r);
|
||||
NTSTATUS SamDump(TALLOC_CTX *mem_ctx, struct libnet_SamDump *r);
|
||||
NTSTATUS SamSync_netlogon(TALLOC_CTX *mem_ctx, struct libnet_SamSync *r);
|
||||
NTSTATUS UnbecomeDC(TALLOC_CTX *mem_ctx, struct libnet_UnbecomeDC *r);
|
||||
NTSTATUS BecomeDC(TALLOC_CTX *mem_ctx, struct libnet_BecomeDC *r);
|
||||
NTSTATUS JoinSite(struct ldb_context *remote_ldb, struct libnet_JoinDomain *libnet_r);
|
||||
NTSTATUS JoinDomain(TALLOC_CTX *mem_ctx, struct libnet_JoinDomain *r);
|
||||
NTSTATUS Join(TALLOC_CTX *mem_ctx, struct libnet_Join *r);
|
||||
NTSTATUS RpcConnect(TALLOC_CTX *mem_ctx, struct libnet_RpcConnect *r);
|
||||
NTSTATUS RemoteTOD(TALLOC_CTX *mem_ctx, union libnet_RemoteTOD *r);
|
||||
NTSTATUS ChangePassword(TALLOC_CTX *mem_ctx, union libnet_ChangePassword *r);
|
||||
NTSTATUS SetPassword(TALLOC_CTX *mem_ctx, union libnet_SetPassword *r);
|
||||
}
|
||||
} libnet;
|
@ -1,103 +0,0 @@
|
||||
# This file was automatically generated by SWIG (http://www.swig.org).
|
||||
# Version 1.3.33
|
||||
#
|
||||
# Don't modify this file, modify the SWIG interface instead.
|
||||
|
||||
import _net
|
||||
import new
|
||||
new_instancemethod = new.instancemethod
|
||||
try:
|
||||
_swig_property = property
|
||||
except NameError:
|
||||
pass # Python < 2.2 doesn't have 'property'.
|
||||
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
|
||||
if (name == "thisown"): return self.this.own(value)
|
||||
if (name == "this"):
|
||||
if type(value).__name__ == 'PySwigObject':
|
||||
self.__dict__[name] = value
|
||||
return
|
||||
method = class_type.__swig_setmethods__.get(name,None)
|
||||
if method: return method(self,value)
|
||||
if (not static) or hasattr(self,name):
|
||||
self.__dict__[name] = value
|
||||
else:
|
||||
raise AttributeError("You cannot add attributes to %s" % self)
|
||||
|
||||
def _swig_setattr(self,class_type,name,value):
|
||||
return _swig_setattr_nondynamic(self,class_type,name,value,0)
|
||||
|
||||
def _swig_getattr(self,class_type,name):
|
||||
if (name == "thisown"): return self.this.own()
|
||||
method = class_type.__swig_getmethods__.get(name,None)
|
||||
if method: return method(self)
|
||||
raise AttributeError,name
|
||||
|
||||
def _swig_repr(self):
|
||||
try: strthis = "proxy of " + self.this.__repr__()
|
||||
except: strthis = ""
|
||||
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
|
||||
|
||||
import types
|
||||
try:
|
||||
_object = types.ObjectType
|
||||
_newclass = 1
|
||||
except AttributeError:
|
||||
class _object : pass
|
||||
_newclass = 0
|
||||
del types
|
||||
|
||||
|
||||
def _swig_setattr_nondynamic_method(set):
|
||||
def set_attr(self,name,value):
|
||||
if (name == "thisown"): return self.this.own(value)
|
||||
if hasattr(self,name) or (name == "this"):
|
||||
set(self,name,value)
|
||||
else:
|
||||
raise AttributeError("You cannot add attributes to %s" % self)
|
||||
return set_attr
|
||||
|
||||
|
||||
import events
|
||||
import param
|
||||
class libnet(object):
|
||||
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
|
||||
__repr__ = _swig_repr
|
||||
cred = _swig_property(_net.libnet_cred_get, _net.libnet_cred_set)
|
||||
def __init__(self, *args, **kwargs):
|
||||
_net.libnet_swiginit(self,_net.new_libnet(*args, **kwargs))
|
||||
__swig_destroy__ = _net.delete_libnet
|
||||
libnet.samsync_ldb = new_instancemethod(_net.libnet_samsync_ldb,None,libnet)
|
||||
libnet.DomainList = new_instancemethod(_net.libnet_DomainList,None,libnet)
|
||||
libnet.DomainClose = new_instancemethod(_net.libnet_DomainClose,None,libnet)
|
||||
libnet.DomainOpen = new_instancemethod(_net.libnet_DomainOpen,None,libnet)
|
||||
libnet.LookupName = new_instancemethod(_net.libnet_LookupName,None,libnet)
|
||||
libnet.LookupDCs = new_instancemethod(_net.libnet_LookupDCs,None,libnet)
|
||||
libnet.LookupHost = new_instancemethod(_net.libnet_LookupHost,None,libnet)
|
||||
libnet.Lookup = new_instancemethod(_net.libnet_Lookup,None,libnet)
|
||||
libnet.ListShares = new_instancemethod(_net.libnet_ListShares,None,libnet)
|
||||
libnet.AddShare = new_instancemethod(_net.libnet_AddShare,None,libnet)
|
||||
libnet.DelShare = new_instancemethod(_net.libnet_DelShare,None,libnet)
|
||||
libnet.GroupList = new_instancemethod(_net.libnet_GroupList,None,libnet)
|
||||
libnet.GroupInfo = new_instancemethod(_net.libnet_GroupInfo,None,libnet)
|
||||
libnet.UserList = new_instancemethod(_net.libnet_UserList,None,libnet)
|
||||
libnet.UserInfo = new_instancemethod(_net.libnet_UserInfo,None,libnet)
|
||||
libnet.ModifyUser = new_instancemethod(_net.libnet_ModifyUser,None,libnet)
|
||||
libnet.DeleteUser = new_instancemethod(_net.libnet_DeleteUser,None,libnet)
|
||||
libnet.CreateUser = new_instancemethod(_net.libnet_CreateUser,None,libnet)
|
||||
libnet.SamDump_keytab = new_instancemethod(_net.libnet_SamDump_keytab,None,libnet)
|
||||
libnet.SamDump = new_instancemethod(_net.libnet_SamDump,None,libnet)
|
||||
libnet.SamSync_netlogon = new_instancemethod(_net.libnet_SamSync_netlogon,None,libnet)
|
||||
libnet.UnbecomeDC = new_instancemethod(_net.libnet_UnbecomeDC,None,libnet)
|
||||
libnet.BecomeDC = new_instancemethod(_net.libnet_BecomeDC,None,libnet)
|
||||
libnet.JoinSite = new_instancemethod(_net.libnet_JoinSite,None,libnet)
|
||||
libnet.JoinDomain = new_instancemethod(_net.libnet_JoinDomain,None,libnet)
|
||||
libnet.Join = new_instancemethod(_net.libnet_Join,None,libnet)
|
||||
libnet.RpcConnect = new_instancemethod(_net.libnet_RpcConnect,None,libnet)
|
||||
libnet.RemoteTOD = new_instancemethod(_net.libnet_RemoteTOD,None,libnet)
|
||||
libnet.ChangePassword = new_instancemethod(_net.libnet_ChangePassword,None,libnet)
|
||||
libnet.SetPassword = new_instancemethod(_net.libnet_SetPassword,None,libnet)
|
||||
libnet_swigregister = _net.libnet_swigregister
|
||||
libnet_swigregister(libnet)
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
77
source4/libnet/py_net.c
Normal file
77
source4/libnet/py_net.c
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
Samba utility functions
|
||||
Copyright (C) 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
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "includes.h"
|
||||
#include <Python.h>
|
||||
#include "libnet.h"
|
||||
#include "param/param.h"
|
||||
#include "libcli/security/security.h"
|
||||
|
||||
struct libnet_context *py_net_ctx(PyObject *obj)
|
||||
{
|
||||
/* FIXME: Use obj */
|
||||
return libnet_context_init(NULL, global_loadparm);
|
||||
}
|
||||
|
||||
static PyObject *py_net_join(PyObject *cls, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
struct libnet_Join r;
|
||||
NTSTATUS status;
|
||||
PyObject *result;
|
||||
TALLOC_CTX *mem_ctx;
|
||||
struct libnet_context *libnet_ctx;
|
||||
const char *kwnames[] = { "domain_name", "netbios_name", "join_type", "level", NULL };
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ssii:Join", discard_const_p(char *, kwnames),
|
||||
&r.in.domain_name, &r.in.netbios_name,
|
||||
&r.in.join_type, &r.in.level))
|
||||
return NULL;
|
||||
|
||||
mem_ctx = talloc_new(NULL);
|
||||
|
||||
libnet_ctx = py_net_ctx(cls);
|
||||
|
||||
status = libnet_Join(libnet_ctx, mem_ctx, &r);
|
||||
if (NT_STATUS_IS_ERR(status)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, r.out.error_string);
|
||||
talloc_free(mem_ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = Py_BuildValue("sss", r.out.join_password,
|
||||
dom_sid_string(mem_ctx, r.out.domain_sid),
|
||||
r.out.domain_name);
|
||||
|
||||
talloc_free(mem_ctx);
|
||||
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static struct PyMethodDef net_methods[] = {
|
||||
{"Join", (PyCFunction)py_net_join, METH_VARARGS|METH_KEYWORDS},
|
||||
{NULL }
|
||||
};
|
||||
|
||||
void initnet(void)
|
||||
{
|
||||
Py_InitModule("net", net_methods);
|
||||
}
|
@ -286,8 +286,6 @@ PUBLIC_DEPENDENCIES = LIBNDR NDR_NBT
|
||||
OBJ_FILES = gen_ndr/ndr_winbind.o
|
||||
PUBLIC_DEPENDENCIES = LIBNDR NDR_NETLOGON
|
||||
|
||||
PUBLIC_HEADERS += librpc/gen_ndr/winbind.h
|
||||
|
||||
librpc/idl-deps:
|
||||
./librpc/idl-deps.pl librpc/idl/*.idl >$@
|
||||
|
||||
|
@ -12,6 +12,10 @@ PRIVATE_PROTO_HEADER = proto.h
|
||||
|
||||
PUBLIC_HEADERS += param/param.h
|
||||
|
||||
[SUBSYSTEM::PROVISION]
|
||||
OBJ_FILES = provision.o
|
||||
PRIVATE_DEPENDENCIES = LIBPYTHON
|
||||
|
||||
#################################
|
||||
# Start SUBSYSTEM share
|
||||
[SUBSYSTEM::share]
|
||||
|
@ -20,12 +20,11 @@
|
||||
#include "includes.h"
|
||||
#include "auth/auth.h"
|
||||
#include "lib/ldb_wrap.h"
|
||||
#include "torture/torture.h"
|
||||
#include "libcli/raw/libcliraw.h"
|
||||
#include "torture/util.h"
|
||||
#include "librpc/ndr/libndr.h"
|
||||
|
||||
#include "param/param.h"
|
||||
#include "param/provision.h"
|
||||
#include <Python.h>
|
||||
#include "scripting/python/modules.h"
|
||||
|
45
source4/param/provision.h
Normal file
45
source4/param/provision.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
Samba utility functions
|
||||
Copyright (C) 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
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#ifndef _PROVISION_H_
|
||||
#define _PROVISION_H_
|
||||
|
||||
struct provision_settings {
|
||||
const char *dns_name;
|
||||
const char *site_name;
|
||||
const char *root_dn_str;
|
||||
const char *domain_dn_str;
|
||||
const char *config_dn_str;
|
||||
const char *schema_dn_str;
|
||||
const char *server_dn_str;
|
||||
const struct GUID *invocation_id;
|
||||
const char *netbios_name;
|
||||
const char *host_ip;
|
||||
const char *realm;
|
||||
const char *domain;
|
||||
const struct GUID *ntds_guid;
|
||||
const char *ntds_dn_str;
|
||||
const char *machine_password;
|
||||
const char *targetdir;
|
||||
};
|
||||
|
||||
NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
|
||||
struct provision_settings *settings);
|
||||
|
||||
#endif /* _PROVISION_H_ */
|
@ -5,7 +5,7 @@ pidl-testcov: pidl/Makefile
|
||||
cd pidl && cover -test
|
||||
|
||||
installpidl:: pidl/Makefile
|
||||
$(MAKE) -C pidl install_vendor PREFIX=$(prefix)
|
||||
$(MAKE) -C pidl install_vendor VENDORPREFIX=$(prefix)
|
||||
|
||||
ifeq ($(HAVE_PERL_EXTUTILS_MAKEMAKER),1)
|
||||
install:: installpidl
|
||||
|
@ -272,7 +272,28 @@ sub PythonFunctionBody($$$)
|
||||
|
||||
my $signature = "S.$prettyname(";
|
||||
|
||||
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});
|
||||
}
|
||||
if ($main) {
|
||||
$metadata_args->{$dir}->{$main} = $e->{NAME};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $e (@{$fn->{ELEMENTS}}) {
|
||||
next if (($metadata_args->{in}->{$e->{NAME}} and grep(/in/, @{$e->{DIRECTION}})) or
|
||||
($metadata_args->{out}->{$e->{NAME}}) and grep(/out/, @{$e->{DIRECTION}}));
|
||||
$self->pidl("PyObject *py_$e->{NAME};");
|
||||
if (grep(/out/,@{$e->{DIRECTION}})) {
|
||||
$result_size++;
|
||||
@ -301,14 +322,27 @@ sub PythonFunctionBody($$$)
|
||||
$self->pidl("return NULL;");
|
||||
$self->deindent;
|
||||
$self->pidl("}");
|
||||
$self->pidl("");
|
||||
|
||||
if ($fn->{RETURN_TYPE}) {
|
||||
$result_size++ unless ($fn->{RETURN_TYPE} eq "WERROR" or $fn->{RETURN_TYPE} eq "NTSTATUS");
|
||||
}
|
||||
|
||||
my $fail = "talloc_free(mem_ctx); return NULL;";
|
||||
foreach my $e (@{$fn->{ELEMENTS}}) {
|
||||
if (grep(/in/,@{$e->{DIRECTION}})) {
|
||||
$self->ConvertObjectFromPython($env, "mem_ctx", $e, "py_$e->{NAME}", "r->in.$e->{NAME}", "talloc_free(mem_ctx); return NULL;");
|
||||
next unless (grep(/in/,@{$e->{DIRECTION}}));
|
||||
if ($metadata_args->{in}->{$e->{NAME}}) {
|
||||
my $py_var = "py_".$metadata_args->{in}->{$e->{NAME}};
|
||||
$self->pidl("PY_CHECK_TYPE(PyList, $py_var, $fail);");
|
||||
my $val = "PyList_Size($py_var)";
|
||||
if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
|
||||
$self->pidl("r->in.$e->{NAME} = talloc_ptrtype(mem_ctx, r->in.$e->{NAME});");
|
||||
$self->pidl("*r->in.$e->{NAME} = $val;");
|
||||
} else {
|
||||
$self->pidl("r->in.$e->{NAME} = $val;");
|
||||
}
|
||||
} else {
|
||||
$self->ConvertObjectFromPython($env, "mem_ctx", $e, "py_$e->{NAME}", "r->in.$e->{NAME}", $fail);
|
||||
}
|
||||
}
|
||||
$self->pidl("status = dcerpc_$fn->{NAME}(iface->pipe, mem_ctx, r);");
|
||||
@ -325,6 +359,7 @@ sub PythonFunctionBody($$$)
|
||||
}
|
||||
|
||||
foreach my $e (@{$fn->{ELEMENTS}}) {
|
||||
next if ($metadata_args->{out}->{$e->{NAME}});
|
||||
my $py_name = "py_$e->{NAME}";
|
||||
if (grep(/out/,@{$e->{DIRECTION}})) {
|
||||
$self->ConvertObjectToPython("r", $env, $e, "r->out.$e->{NAME}", $py_name);
|
||||
@ -334,7 +369,7 @@ sub PythonFunctionBody($$$)
|
||||
$signature .= "$e->{NAME}, ";
|
||||
} else {
|
||||
$self->pidl("result = $py_name;");
|
||||
$signature .= "result";
|
||||
$signature .= $e->{NAME};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -347,11 +382,10 @@ sub PythonFunctionBody($$$)
|
||||
my $conv = $self->ConvertObjectToPythonData("r", $fn->{RETURN_TYPE}, "r->out.result");
|
||||
if ($result_size > 1) {
|
||||
$self->pidl("PyTuple_SetItem(result, $i, $conv);");
|
||||
$signature .= "result";
|
||||
} else {
|
||||
$self->pidl("result = $conv;");
|
||||
$signature .= "result";
|
||||
}
|
||||
$signature .= "result";
|
||||
}
|
||||
|
||||
if (substr($signature, -2) eq ", ") {
|
||||
|
@ -42,6 +42,7 @@ extern void initepmapper(void);
|
||||
extern void initinitshutdown(void);
|
||||
static void initdcerpc_misc(void) {}
|
||||
extern void initmgmt(void);
|
||||
extern void initnet(void);
|
||||
extern void initatsvc(void);
|
||||
extern void initsamr(void);
|
||||
static void initdcerpc_security(void) {}
|
||||
|
@ -264,9 +264,11 @@ def provision_paths_from_lp(lp, dnsdomain):
|
||||
|
||||
return paths
|
||||
|
||||
|
||||
def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None, serverrole=None,
|
||||
rootdn=None, domaindn=None, configdn=None, schemadn=None, serverdn=None,
|
||||
sitename=None):
|
||||
"""Guess configuration settings to use."""
|
||||
|
||||
if hostname is None:
|
||||
hostname = socket.gethostname().split(".")[0].lower()
|
||||
@ -400,6 +402,7 @@ def load_or_make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrol
|
||||
|
||||
return lp
|
||||
|
||||
|
||||
def setup_name_mappings(samdb, idmap, sid, domaindn, root_uid, nobody_uid,
|
||||
users_gid, wheel_gid):
|
||||
"""setup reasonable name mappings for sam names to unix names.
|
||||
@ -425,6 +428,7 @@ def setup_name_mappings(samdb, idmap, sid, domaindn, root_uid, nobody_uid,
|
||||
idmap.setup_name_mapping(sid + "-500", idmap.TYPE_UID, root_uid)
|
||||
idmap.setup_name_mapping(sid + "-513", idmap.TYPE_GID, users_gid)
|
||||
|
||||
|
||||
def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
|
||||
credentials, names,
|
||||
serverrole, ldap_backend=None,
|
||||
@ -637,6 +641,7 @@ def setup_registry(path, setup_path, session_info, credentials, lp):
|
||||
assert os.path.exists(provision_reg)
|
||||
reg.diff_apply(provision_reg)
|
||||
|
||||
|
||||
def setup_idmapdb(path, setup_path, session_info, credentials, lp):
|
||||
"""Setup the idmap database.
|
||||
|
||||
@ -656,6 +661,7 @@ def setup_idmapdb(path, setup_path, session_info, credentials, lp):
|
||||
idmap_ldb.load_ldif_file_add(setup_path("idmap_init.ldif"))
|
||||
return idmap_ldb
|
||||
|
||||
|
||||
def setup_samdb_rootdse(samdb, setup_path, names):
|
||||
"""Setup the SamDB rootdse.
|
||||
|
||||
@ -1060,6 +1066,7 @@ def provision(setup_dir, message, session_info,
|
||||
result.samdb = samdb
|
||||
return result
|
||||
|
||||
|
||||
def provision_become_dc(setup_dir=None,
|
||||
smbconf=None, targetdir=None, realm=None,
|
||||
rootdn=None, domaindn=None, schemadn=None, configdn=None,
|
||||
@ -1081,7 +1088,11 @@ def provision_become_dc(setup_dir=None,
|
||||
domain=domain, hostname=hostname, hostip="127.0.0.1", domainsid=domainsid, machinepass=machinepass, serverrole="domain controller", sitename=sitename);
|
||||
|
||||
|
||||
def setup_db_config(setup_path, file, dbdir):
|
||||
def setup_db_config(setup_path, dbdir):
|
||||
"""Setup a Berkeley database.
|
||||
|
||||
:param setup_path: Setup path function.
|
||||
:param dbdir: Database directory."""
|
||||
if not os.path.isdir(os.path.join(dbdir, "bdb-logs")):
|
||||
os.makedirs(os.path.join(dbdir, "bdb-logs"), 0700);
|
||||
if not os.path.isdir(os.path.join(dbdir, "tmp")):
|
||||
@ -1211,12 +1222,11 @@ refint_attributes""" + refint_attributes + "\n";
|
||||
setup_file(setup_path("modules.conf"), paths.modulesconf,
|
||||
{"REALM": names.realm})
|
||||
|
||||
setup_db_config(setup_path, file, os.path.join(paths.ldapdir, "db", "user"))
|
||||
setup_db_config(setup_path, file, os.path.join(paths.ldapdir, "db", "config"))
|
||||
setup_db_config(setup_path, file, os.path.join(paths.ldapdir, "db", "schema"))
|
||||
setup_db_config(setup_path, file, os.path.join(paths.ldapdir, "user"))
|
||||
setup_db_config(setup_path, file, os.path.join(paths.ldapdir, "config"))
|
||||
setup_db_config(setup_path, file, os.path.join(paths.ldapdir, "schema"))
|
||||
mapping = "schema-map-openldap-2.3"
|
||||
backend_schema = "backend-schema.schema"
|
||||
|
||||
|
||||
ldapi_uri = "ldapi://" + urllib.quote(os.path.join(paths.private_dir, "ldap", "ldapi"), safe="")
|
||||
if ldap_backend_port is not None:
|
||||
|
@ -30,7 +30,7 @@ class RpcEchoTests(unittest.TestCase):
|
||||
self.assertEquals(2, self.conn.AddOne(1))
|
||||
|
||||
def test_echodata(self):
|
||||
self.assertEquals([1,2,3], self.conn.EchoData(3, [1, 2, 3]))
|
||||
self.assertEquals([1,2,3], self.conn.EchoData([1, 2, 3]))
|
||||
|
||||
def test_call(self):
|
||||
self.assertEquals(u"foobar", self.conn.TestCall(u"foobar"))
|
||||
|
@ -26,5 +26,11 @@ class UnixinfoTests(unittest.TestCase):
|
||||
self.conn = unixinfo.unixinfo("ncalrpc:", get_loadparm())
|
||||
|
||||
def test_getpwuid(self):
|
||||
(count, infos) = self.conn.GetPWUid(1, [0])
|
||||
self.assertEquals(1, len(infos))
|
||||
infos = self.conn.GetPWUid(range(512))
|
||||
self.assertEquals(512, len(infos))
|
||||
|
||||
def test_gidtosid(self):
|
||||
self.conn.GidToSid(1000)
|
||||
|
||||
def test_uidtosid(self):
|
||||
self.conn.UidToSid(1000)
|
||||
|
@ -40,7 +40,12 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
|
||||
int fnum1 = -1;
|
||||
bool ret = true;
|
||||
ssize_t written;
|
||||
time_t t;
|
||||
struct timeval start;
|
||||
struct timeval end;
|
||||
int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
|
||||
int normal_delay = 2000000;
|
||||
double sec = ((double)used_delay) / ((double)normal_delay);
|
||||
int msec = 1000 * sec;
|
||||
|
||||
if (!torture_setup_dir(cli, BASEDIR)) {
|
||||
return false;
|
||||
@ -68,7 +73,7 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
|
||||
|
||||
/* 3 second delay to ensure we get past any 2 second time
|
||||
granularity (older systems may have that) */
|
||||
sleep(3);
|
||||
msleep(3 * msec);
|
||||
|
||||
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
|
||||
|
||||
@ -78,9 +83,9 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
|
||||
return false;
|
||||
}
|
||||
|
||||
t = time(NULL);
|
||||
|
||||
while (time(NULL) < t+120) {
|
||||
start = timeval_current();
|
||||
end = timeval_add(&start, (120*sec), 0);
|
||||
while (!timeval_expired(&end)) {
|
||||
status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
@ -91,20 +96,22 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
|
||||
torture_comment(tctx, "write time %s\n",
|
||||
nt_time_string(tctx, finfo2.basic_info.out.write_time));
|
||||
if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
|
||||
int diff = time(NULL) - t;
|
||||
if (diff < 2) {
|
||||
torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
|
||||
diff);
|
||||
double diff = timeval_elapsed(&start);
|
||||
if (diff < (2 * sec * 0.75)) { /* 0.75 to cope with vmware timing */
|
||||
torture_comment(tctx, "Server updated write_time after %.2f seconds"
|
||||
"(1 sec == %.2f)(wrong!)\n",
|
||||
diff, sec);
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
|
||||
torture_comment(tctx, "Server updated write_time after %d seconds (correct)\n",
|
||||
diff);
|
||||
torture_comment(tctx, "Server updated write_time after %.2f seconds"
|
||||
"(1 sec == %.2f)(correct)\n",
|
||||
diff, sec);
|
||||
break;
|
||||
}
|
||||
sleep(1);
|
||||
fflush(stdout);
|
||||
msleep(1 * msec);
|
||||
}
|
||||
|
||||
if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
|
||||
@ -135,7 +142,12 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
|
||||
int fnum2 = -1;
|
||||
bool ret = true;
|
||||
ssize_t written;
|
||||
time_t t;
|
||||
struct timeval start;
|
||||
struct timeval end;
|
||||
int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
|
||||
int normal_delay = 2000000;
|
||||
double sec = ((double)used_delay) / ((double)normal_delay);
|
||||
int msec = 1000 * sec;
|
||||
union smb_flush flsh;
|
||||
|
||||
if (!torture_setup_dir(cli, BASEDIR)) {
|
||||
@ -164,7 +176,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
|
||||
|
||||
/* 3 second delay to ensure we get past any 2 second time
|
||||
granularity (older systems may have that) */
|
||||
sleep(3);
|
||||
msleep(3 * msec);
|
||||
|
||||
{
|
||||
/* Try using setfileinfo instead of write to update write time. */
|
||||
@ -251,12 +263,11 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
|
||||
return false;
|
||||
}
|
||||
|
||||
t = time(NULL);
|
||||
|
||||
/* Once the time was set using setfileinfo then it stays set - writes
|
||||
don't have any effect. But make sure. */
|
||||
|
||||
while (time(NULL) < t+15) {
|
||||
start = timeval_current();
|
||||
end = timeval_add(&start, (15*sec), 0);
|
||||
while (!timeval_expired(&end)) {
|
||||
status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
@ -267,13 +278,15 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
|
||||
torture_comment(tctx, "write time %s\n",
|
||||
nt_time_string(tctx, finfo2.basic_info.out.write_time));
|
||||
if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
|
||||
torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
|
||||
(int)(time(NULL) - t));
|
||||
double diff = timeval_elapsed(&start);
|
||||
torture_comment(tctx, "Server updated write_time after %.2f seconds"
|
||||
"(1sec == %.2f) (wrong!)\n",
|
||||
diff, sec);
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
sleep(1);
|
||||
fflush(stdout);
|
||||
msleep(1 * msec);
|
||||
}
|
||||
|
||||
if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
|
||||
@ -339,12 +352,11 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
|
||||
ret = false;
|
||||
}
|
||||
|
||||
t = time(NULL);
|
||||
|
||||
/* Once the time was set using setfileinfo then it stays set - writes
|
||||
don't have any effect. But make sure. */
|
||||
|
||||
while (time(NULL) < t+15) {
|
||||
start = timeval_current();
|
||||
end = timeval_add(&start, (15*sec), 0);
|
||||
while (!timeval_expired(&end)) {
|
||||
status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
@ -355,13 +367,15 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
|
||||
torture_comment(tctx, "write time %s\n",
|
||||
nt_time_string(tctx, finfo2.basic_info.out.write_time));
|
||||
if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
|
||||
torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
|
||||
(int)(time(NULL) - t));
|
||||
double diff = timeval_elapsed(&start);
|
||||
torture_comment(tctx, "Server updated write_time after %.2f seconds "
|
||||
"(1sec == %.2f) (wrong!)\n",
|
||||
diff, sec);
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
sleep(1);
|
||||
fflush(stdout);
|
||||
msleep(1 * msec);
|
||||
}
|
||||
|
||||
if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
|
||||
@ -393,7 +407,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
|
||||
torture_comment(tctx, "Second open initial write time %s\n",
|
||||
nt_time_string(tctx, finfo1.basic_info.out.write_time));
|
||||
|
||||
sleep(10);
|
||||
msleep(10 * msec);
|
||||
torture_comment(tctx, "Doing a 10 byte write to extend the file to see if this changes the last write time.\n");
|
||||
|
||||
written = smbcli_write(cli->tree, fnum1, 0, "0123456789", 31, 10);
|
||||
@ -420,11 +434,10 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
|
||||
ret = false;
|
||||
}
|
||||
|
||||
t = time(NULL);
|
||||
|
||||
/* Now the write time should be updated again */
|
||||
|
||||
while (time(NULL) < t+15) {
|
||||
start = timeval_current();
|
||||
end = timeval_add(&start, (15*sec), 0);
|
||||
while (!timeval_expired(&end)) {
|
||||
status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
@ -435,20 +448,22 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
|
||||
torture_comment(tctx, "write time %s\n",
|
||||
nt_time_string(tctx, finfo2.basic_info.out.write_time));
|
||||
if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
|
||||
int diff = time(NULL) - t;
|
||||
if (diff < 2) {
|
||||
torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
|
||||
diff);
|
||||
double diff = timeval_elapsed(&start);
|
||||
if (diff < (2 * sec * 0.75)) { /* 0.75 to cope with vmware timing */
|
||||
torture_comment(tctx, "Server updated write_time after %.2f seconds"
|
||||
"(1sec == %.2f) (wrong!)\n",
|
||||
diff, sec);
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
|
||||
torture_comment(tctx, "Server updated write_time after %d seconds (correct)\n",
|
||||
diff);
|
||||
torture_comment(tctx, "Server updated write_time after %.2f seconds"
|
||||
"(1sec == %.2f) (correct)\n",
|
||||
diff, sec);
|
||||
break;
|
||||
}
|
||||
sleep(1);
|
||||
fflush(stdout);
|
||||
msleep(1*msec);
|
||||
}
|
||||
|
||||
if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
|
||||
@ -490,6 +505,10 @@ static bool test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
|
||||
int fnum2;
|
||||
bool ret = true;
|
||||
ssize_t written;
|
||||
int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
|
||||
int normal_delay = 2000000;
|
||||
double sec = ((double)used_delay) / ((double)normal_delay);
|
||||
int msec = 1000 * sec;
|
||||
|
||||
if (!torture_setup_dir(cli, BASEDIR)) {
|
||||
return false;
|
||||
@ -513,7 +532,7 @@ static bool test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
|
||||
goto done;
|
||||
}
|
||||
|
||||
msleep(1000);
|
||||
msleep(1 * msec);
|
||||
|
||||
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
|
||||
|
||||
@ -613,12 +632,23 @@ static bool test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
|
||||
}
|
||||
|
||||
#define COMPARE_WRITE_TIME_CMP(given, correct, cmp) do { \
|
||||
uint64_t r = 10*1000*1000; \
|
||||
NTTIME g = (given).basic_info.out.write_time; \
|
||||
NTTIME gr = (g / r) * r; \
|
||||
NTTIME c = (correct).basic_info.out.write_time; \
|
||||
if (g cmp c) { \
|
||||
torture_result(tctx, TORTURE_FAIL, __location__": wrong write_time (%s)%s %s (%s)%s", \
|
||||
#given, nt_time_string(tctx, g), \
|
||||
#cmp, #correct, nt_time_string(tctx, c)); \
|
||||
NTTIME cr = (c / r) * r; \
|
||||
bool strict = torture_setting_bool(tctx, "strict mode", false); \
|
||||
bool err = false; \
|
||||
if (strict && (g cmp c)) { \
|
||||
err = true; \
|
||||
} else if (gr cmp cr) { \
|
||||
/* handle filesystem without high resolution timestamps */ \
|
||||
err = true; \
|
||||
} \
|
||||
if (err) { \
|
||||
torture_result(tctx, TORTURE_FAIL, __location__": wrong write_time (%s)%s(%llu) %s (%s)%s(%llu)", \
|
||||
#given, nt_time_string(tctx, g), (unsigned long long)g, \
|
||||
#cmp, #correct, nt_time_string(tctx, c), (unsigned long long)c); \
|
||||
ret = false; \
|
||||
goto done; \
|
||||
} \
|
||||
@ -724,7 +754,12 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
|
||||
int fnum1 = -1;
|
||||
bool ret = true;
|
||||
ssize_t written;
|
||||
time_t t;
|
||||
struct timeval start;
|
||||
struct timeval end;
|
||||
int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
|
||||
int normal_delay = 2000000;
|
||||
double sec = ((double)used_delay) / ((double)normal_delay);
|
||||
int msec = 1000 * sec;
|
||||
|
||||
if (!torture_setup_dir(cli, BASEDIR)) {
|
||||
return false;
|
||||
@ -760,8 +795,9 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
|
||||
* calcuated from the first write
|
||||
* (but expect upto 5 seconds extra time for a busy server)
|
||||
*/
|
||||
t = time(NULL);
|
||||
while (time(NULL) < t+7) {
|
||||
start = timeval_current();
|
||||
end = timeval_add(&start, 7 * sec, 0);
|
||||
while (!timeval_expired(&end)) {
|
||||
/* do a write */
|
||||
torture_comment(tctx, "Do a write on the file handle\n");
|
||||
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
|
||||
@ -774,26 +810,29 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
|
||||
GET_INFO_FILE(finfo1);
|
||||
|
||||
if (finfo1.basic_info.out.write_time > finfo0.basic_info.out.write_time) {
|
||||
int diff = time(NULL) - t;
|
||||
if (diff < 2) {
|
||||
torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
|
||||
diff);
|
||||
double diff = timeval_elapsed(&start);
|
||||
if (diff < (2 * sec * 0.75)) { /* 0.75 to cope with vmware timing */
|
||||
torture_comment(tctx, "Server updated write_time after %.2f seconds "
|
||||
"(1sec == %.2f) (wrong!)\n",
|
||||
diff, sec);
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
|
||||
torture_comment(tctx, "Server updated write_time after %d seconds (correct)\n",
|
||||
diff);
|
||||
torture_comment(tctx, "Server updated write_time after %.2f seconds "
|
||||
"(1sec == %.2f) (correct)\n",
|
||||
diff, sec);
|
||||
break;
|
||||
}
|
||||
msleep(500);
|
||||
msleep(0.5 * msec);
|
||||
}
|
||||
|
||||
GET_INFO_BOTH(finfo1,pinfo1);
|
||||
|
||||
/* sure any further write doesn't update the write time */
|
||||
t = time(NULL);
|
||||
while (time(NULL) < t+15) {
|
||||
start = timeval_current();
|
||||
end = timeval_add(&start, 15 * sec, 0);
|
||||
while (!timeval_expired(&end)) {
|
||||
/* do a write */
|
||||
torture_comment(tctx, "Do a write on the file handle\n");
|
||||
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
|
||||
@ -806,12 +845,14 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
|
||||
GET_INFO_BOTH(finfo2,pinfo2);
|
||||
|
||||
if (finfo2.basic_info.out.write_time > finfo1.basic_info.out.write_time) {
|
||||
torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
|
||||
(int)(time(NULL) - t));
|
||||
double diff = timeval_elapsed(&start);
|
||||
torture_comment(tctx, "Server updated write_time after %.2f seconds "
|
||||
"(1sec == %.2f) (wrong!)\n",
|
||||
diff, sec);
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
msleep(2000);
|
||||
msleep(2 * msec);
|
||||
}
|
||||
|
||||
GET_INFO_BOTH(finfo2,pinfo2);
|
||||
@ -821,7 +862,7 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
|
||||
}
|
||||
|
||||
/* sleep */
|
||||
msleep(5000);
|
||||
msleep(5 * msec);
|
||||
|
||||
GET_INFO_BOTH(finfo3,pinfo3);
|
||||
COMPARE_WRITE_TIME_EQUAL(finfo3, finfo2);
|
||||
@ -860,7 +901,12 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
|
||||
int fnum1 = -1;
|
||||
bool ret = true;
|
||||
ssize_t written;
|
||||
time_t t;
|
||||
struct timeval start;
|
||||
struct timeval end;
|
||||
int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
|
||||
int normal_delay = 2000000;
|
||||
double sec = ((double)used_delay) / ((double)normal_delay);
|
||||
int msec = 1000 * sec;
|
||||
|
||||
if (!torture_setup_dir(cli, BASEDIR)) {
|
||||
return false;
|
||||
@ -892,7 +938,7 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
|
||||
GET_INFO_BOTH(finfo0,pinfo0);
|
||||
|
||||
/* sleep a bit */
|
||||
msleep(5000);
|
||||
msleep(5 * msec);
|
||||
|
||||
/* do a write */
|
||||
torture_comment(tctx, "Do a write on the file handle\n");
|
||||
@ -911,32 +957,36 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
|
||||
* calcuated from the first write
|
||||
* (but expect upto 3 seconds extra time for a busy server)
|
||||
*/
|
||||
t = time(NULL);
|
||||
while (time(NULL) < t+5) {
|
||||
start = timeval_current();
|
||||
end = timeval_add(&start, 5 * sec, 0);
|
||||
while (!timeval_expired(&end)) {
|
||||
/* get the times after the first write */
|
||||
GET_INFO_FILE(finfo1);
|
||||
|
||||
if (finfo1.basic_info.out.write_time > finfo0.basic_info.out.write_time) {
|
||||
int diff = time(NULL) - t;
|
||||
if (diff < 2) {
|
||||
torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
|
||||
diff);
|
||||
double diff = timeval_elapsed(&start);
|
||||
if (diff < (2 * sec * 0.75)) { /* 0.75 to cope with vmware timing */
|
||||
torture_comment(tctx, "Server updated write_time after %.2f seconds "
|
||||
"(1sec == %.2f) (wrong!)\n",
|
||||
diff, sec);
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
|
||||
torture_comment(tctx, "Server updated write_time after %d seconds (correct)\n",
|
||||
diff);
|
||||
torture_comment(tctx, "Server updated write_time after %.2f seconds "
|
||||
"(1sec == %.2f) (correct)\n",
|
||||
diff, sec);
|
||||
break;
|
||||
}
|
||||
msleep(500);
|
||||
msleep(0.5 * msec);
|
||||
}
|
||||
|
||||
GET_INFO_BOTH(finfo1,pinfo1);
|
||||
|
||||
/* sure any further write doesn't update the write time */
|
||||
t = time(NULL);
|
||||
while (time(NULL) < t+15) {
|
||||
start = timeval_current();
|
||||
end = timeval_add(&start, 15 * sec, 0);
|
||||
while (!timeval_expired(&end)) {
|
||||
/* do a write */
|
||||
torture_comment(tctx, "Do a write on the file handle\n");
|
||||
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
|
||||
@ -949,12 +999,14 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
|
||||
GET_INFO_BOTH(finfo2,pinfo2);
|
||||
|
||||
if (finfo2.basic_info.out.write_time > finfo1.basic_info.out.write_time) {
|
||||
torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
|
||||
(int)(time(NULL) - t));
|
||||
double diff = timeval_elapsed(&start);
|
||||
torture_comment(tctx, "Server updated write_time after %.2f seconds "
|
||||
"(1sec == %.2f) (wrong!)\n",
|
||||
diff, sec);
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
msleep(2000);
|
||||
msleep(2 * msec);
|
||||
}
|
||||
|
||||
GET_INFO_BOTH(finfo2,pinfo2);
|
||||
@ -964,7 +1016,7 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
|
||||
}
|
||||
|
||||
/* sleep */
|
||||
msleep(5000);
|
||||
msleep(5 * msec);
|
||||
|
||||
GET_INFO_BOTH(finfo3,pinfo3);
|
||||
COMPARE_WRITE_TIME_EQUAL(finfo3, finfo2);
|
||||
@ -1003,7 +1055,12 @@ static bool test_delayed_write_update5(struct torture_context *tctx,
|
||||
int fnum1 = -1;
|
||||
bool ret = true;
|
||||
ssize_t written;
|
||||
time_t t;
|
||||
struct timeval start;
|
||||
struct timeval end;
|
||||
int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
|
||||
int normal_delay = 2000000;
|
||||
double sec = ((double)used_delay) / ((double)normal_delay);
|
||||
int msec = 1000 * sec;
|
||||
|
||||
if (!torture_setup_dir(cli, BASEDIR)) {
|
||||
return false;
|
||||
@ -1059,19 +1116,22 @@ static bool test_delayed_write_update5(struct torture_context *tctx,
|
||||
COMPARE_WRITE_TIME_LESS(finfo2, finfo1);
|
||||
|
||||
/* make sure the 2 second delay from the first write are canceled */
|
||||
t = time(NULL);
|
||||
while (time(NULL) < t+15) {
|
||||
start = timeval_current();
|
||||
end = timeval_add(&start, 15 * sec, 0);
|
||||
while (!timeval_expired(&end)) {
|
||||
|
||||
/* get the times after the first write */
|
||||
GET_INFO_BOTH(finfo3,pinfo3);
|
||||
|
||||
if (finfo3.basic_info.out.write_time > finfo2.basic_info.out.write_time) {
|
||||
torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
|
||||
(int)(time(NULL) - t));
|
||||
double diff = timeval_elapsed(&start);
|
||||
torture_comment(tctx, "Server updated write_time after %.2f seconds "
|
||||
"(1sec == %.2f) (wrong!)\n",
|
||||
diff, sec);
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
msleep(2000);
|
||||
msleep(2 * msec);
|
||||
}
|
||||
|
||||
GET_INFO_BOTH(finfo3,pinfo3);
|
||||
@ -1081,8 +1141,9 @@ static bool test_delayed_write_update5(struct torture_context *tctx,
|
||||
}
|
||||
|
||||
/* sure any further write doesn't update the write time */
|
||||
t = time(NULL);
|
||||
while (time(NULL) < t+15) {
|
||||
start = timeval_current();
|
||||
end = timeval_add(&start, 15 * sec, 0);
|
||||
while (!timeval_expired(&end)) {
|
||||
/* do a write */
|
||||
torture_comment(tctx, "Do a write on the file handle\n");
|
||||
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
|
||||
@ -1095,12 +1156,14 @@ static bool test_delayed_write_update5(struct torture_context *tctx,
|
||||
GET_INFO_BOTH(finfo4,pinfo4);
|
||||
|
||||
if (finfo4.basic_info.out.write_time > finfo3.basic_info.out.write_time) {
|
||||
torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
|
||||
(int)(time(NULL) - t));
|
||||
double diff = timeval_elapsed(&start);
|
||||
torture_comment(tctx, "Server updated write_time after %.2f seconds "
|
||||
"(1sec == %.2f) (wrong!)\n",
|
||||
diff, sec);
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
msleep(2000);
|
||||
msleep(2 * msec);
|
||||
}
|
||||
|
||||
GET_INFO_BOTH(finfo4,pinfo4);
|
||||
@ -1110,7 +1173,7 @@ static bool test_delayed_write_update5(struct torture_context *tctx,
|
||||
}
|
||||
|
||||
/* sleep */
|
||||
msleep(5000);
|
||||
msleep(5 * msec);
|
||||
|
||||
GET_INFO_BOTH(finfo5,pinfo5);
|
||||
COMPARE_WRITE_TIME_EQUAL(finfo5, finfo4);
|
||||
@ -1149,7 +1212,12 @@ static bool test_delayed_write_update6(struct torture_context *tctx,
|
||||
int fnum2 = -1;
|
||||
bool ret = true;
|
||||
ssize_t written;
|
||||
time_t t;
|
||||
struct timeval start;
|
||||
struct timeval end;
|
||||
int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
|
||||
int normal_delay = 2000000;
|
||||
double sec = ((double)used_delay) / ((double)normal_delay);
|
||||
int msec = 1000 * sec;
|
||||
bool first = true;
|
||||
|
||||
if (!torture_setup_dir(cli, BASEDIR)) {
|
||||
@ -1217,19 +1285,22 @@ again:
|
||||
COMPARE_WRITE_TIME_LESS(finfo2, finfo1);
|
||||
|
||||
/* make sure the 2 second delay from the first write are canceled */
|
||||
t = time(NULL);
|
||||
while (time(NULL) < t+15) {
|
||||
start = timeval_current();
|
||||
end = timeval_add(&start, 15 * sec, 0);
|
||||
while (!timeval_expired(&end)) {
|
||||
|
||||
/* get the times after the first write */
|
||||
GET_INFO_BOTH(finfo3,pinfo3);
|
||||
|
||||
if (finfo3.basic_info.out.write_time > finfo2.basic_info.out.write_time) {
|
||||
torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
|
||||
(int)(time(NULL) - t));
|
||||
double diff = timeval_elapsed(&start);
|
||||
torture_comment(tctx, "Server updated write_time after %.2f seconds "
|
||||
"(1sec == %.2f) (wrong!)\n",
|
||||
diff, sec);
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
msleep(2000);
|
||||
msleep(2 * msec);
|
||||
}
|
||||
|
||||
GET_INFO_BOTH(finfo3,pinfo3);
|
||||
@ -1239,8 +1310,9 @@ again:
|
||||
}
|
||||
|
||||
/* sure any further write doesn't update the write time */
|
||||
t = time(NULL);
|
||||
while (time(NULL) < t+15) {
|
||||
start = timeval_current();
|
||||
end = timeval_add(&start, 15 * sec, 0);
|
||||
while (!timeval_expired(&end)) {
|
||||
/* do a write */
|
||||
torture_comment(tctx, "Do a write on the file handle\n");
|
||||
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
|
||||
@ -1253,12 +1325,14 @@ again:
|
||||
GET_INFO_BOTH(finfo4,pinfo4);
|
||||
|
||||
if (finfo4.basic_info.out.write_time > finfo3.basic_info.out.write_time) {
|
||||
torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
|
||||
(int)(time(NULL) - t));
|
||||
double diff = timeval_elapsed(&start);
|
||||
torture_comment(tctx, "Server updated write_time after %.2f seconds "
|
||||
"(1sec == %.2f) (wrong!)\n",
|
||||
diff, sec);
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
msleep(2000);
|
||||
msleep(2 * msec);
|
||||
}
|
||||
|
||||
GET_INFO_BOTH(finfo4,pinfo4);
|
||||
@ -1268,7 +1342,7 @@ again:
|
||||
}
|
||||
|
||||
/* sleep */
|
||||
msleep(5000);
|
||||
msleep(5 * msec);
|
||||
|
||||
GET_INFO_BOTH(finfo5,pinfo5);
|
||||
COMPARE_WRITE_TIME_EQUAL(finfo5, finfo4);
|
||||
|
@ -16,8 +16,8 @@ PUBLIC_DEPENDENCIES = \
|
||||
PUBLIC_HEADERS += torture/torture.h torture/ui.h
|
||||
|
||||
[SUBSYSTEM::TORTURE_UTIL]
|
||||
OBJ_FILES = util_smb.o util_provision.o
|
||||
PRIVATE_DEPENDENCIES = LIBCLI_RAW LIBPYTHON smbcalls
|
||||
OBJ_FILES = util_smb.o
|
||||
PRIVATE_DEPENDENCIES = LIBCLI_RAW LIBPYTHON smbcalls PROVISION
|
||||
PUBLIC_DEPENDENCIES = POPT_CREDENTIALS
|
||||
|
||||
#################################
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "auth/auth.h"
|
||||
#include "param/param.h"
|
||||
#include "torture/util.h"
|
||||
#include "param/provision.h"
|
||||
|
||||
struct test_become_dc_state {
|
||||
struct libnet_context *ctx;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "lib/events/events.h"
|
||||
#include "libcli/raw/libcliraw.h"
|
||||
#include "torture/util.h"
|
||||
#include "param/provision.h"
|
||||
|
||||
static bool test_tempdir(struct torture_context *tctx)
|
||||
{
|
||||
|
@ -20,29 +20,6 @@
|
||||
#ifndef _TORTURE_PROVISION_H_
|
||||
#define _TORTURE_PROVISION_H_
|
||||
|
||||
struct provision_settings {
|
||||
const char *dns_name;
|
||||
const char *site_name;
|
||||
const char *root_dn_str;
|
||||
const char *domain_dn_str;
|
||||
const char *config_dn_str;
|
||||
const char *schema_dn_str;
|
||||
const char *server_dn_str;
|
||||
const struct GUID *invocation_id;
|
||||
const char *netbios_name;
|
||||
const char *host_ip;
|
||||
const char *realm;
|
||||
const char *domain;
|
||||
const struct GUID *ntds_guid;
|
||||
const char *ntds_dn_str;
|
||||
const char *machine_password;
|
||||
const char *targetdir;
|
||||
};
|
||||
|
||||
NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
|
||||
struct provision_settings *settings);
|
||||
|
||||
|
||||
/**
|
||||
setup a directory ready for a test
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user