summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2008-02-21 09:55:13 +1100
committerAndrew Bartlett <abartlet@samba.org>2008-02-21 09:55:13 +1100
commit774fa12ac1695600710ce9fac18024edd38161ee (patch)
tree5440d8c0f00d28656e0d8f65f3b771eb11a01842 /source4
parent49b3a4829325967df9d1e616ad32e5379ce6cf5d (diff)
parent910a1cafdf253255510d3aff7cc2385da43331dd (diff)
downloadsamba-774fa12ac1695600710ce9fac18024edd38161ee.tar.gz
samba-774fa12ac1695600710ce9fac18024edd38161ee.tar.bz2
samba-774fa12ac1695600710ce9fac18024edd38161ee.zip
Merge branch 'v4-0-test' of git://git.samba.org/samba into 4-0-local
(This used to be commit 5cd3310b78a85243eb436d05db3228c3495f9162)
Diffstat (limited to 'source4')
-rw-r--r--source4/Makefile185
-rw-r--r--source4/auth/auth_anonymous.c2
-rw-r--r--source4/auth/auth_developer.c2
-rw-r--r--source4/auth/auth_sam.c2
-rw-r--r--source4/auth/auth_unix.c2
-rw-r--r--source4/auth/auth_winbind.c2
-rw-r--r--source4/auth/config.mk8
-rw-r--r--source4/auth/gensec/config.mk2
-rw-r--r--source4/auth/gensec/cyrus_sasl.c5
-rw-r--r--source4/auth/gensec/gensec_gssapi.c2
-rw-r--r--source4/auth/gensec/gensec_krb5.c2
-rw-r--r--source4/auth/gensec/schannel.c2
-rw-r--r--source4/auth/gensec/spnego.c2
-rw-r--r--source4/auth/ntlmssp/config.mk2
-rw-r--r--source4/auth/ntlmssp/ntlmssp.c2
-rwxr-xr-xsource4/autogen.sh14
-rw-r--r--source4/build/m4/check_ld.m417
-rw-r--r--source4/build/m4/check_make.m48
-rw-r--r--source4/build/m4/check_path.m42
-rw-r--r--source4/build/m4/public.m458
-rwxr-xr-xsource4/build/smb_build/cflags.pm2
-rw-r--r--source4/build/smb_build/config_mk.pm4
-rwxr-xr-xsource4/build/smb_build/dot.pl2
-rw-r--r--source4/build/smb_build/header.pm11
-rw-r--r--source4/build/smb_build/input.pm88
-rw-r--r--source4/build/smb_build/main.pl35
-rw-r--r--source4/build/smb_build/makefile.pm356
-rw-r--r--source4/build/smb_build/output.pm55
-rw-r--r--source4/build/smb_build/summary.pm8
-rw-r--r--source4/cluster/config.mk2
-rw-r--r--source4/configure.ac31
-rw-r--r--source4/dsdb/config.mk2
-rw-r--r--source4/dsdb/samdb/ldb_modules/anr.c8
-rw-r--r--source4/dsdb/samdb/ldb_modules/config.mk57
-rw-r--r--source4/dsdb/samdb/ldb_modules/dsdb_cache.c7
-rw-r--r--source4/dsdb/samdb/ldb_modules/extended_dn.c7
-rw-r--r--source4/dsdb/samdb/ldb_modules/instancetype.c8
-rw-r--r--source4/dsdb/samdb/ldb_modules/kludge_acl.c7
-rw-r--r--source4/dsdb/samdb/ldb_modules/linked_attributes.c7
-rw-r--r--source4/dsdb/samdb/ldb_modules/local_password.c8
-rw-r--r--source4/dsdb/samdb/ldb_modules/naming_fsmo.c7
-rw-r--r--source4/dsdb/samdb/ldb_modules/normalise.c8
-rw-r--r--source4/dsdb/samdb/ldb_modules/objectclass.c8
-rw-r--r--source4/dsdb/samdb/ldb_modules/objectguid.c8
-rw-r--r--source4/dsdb/samdb/ldb_modules/partition.c9
-rw-r--r--source4/dsdb/samdb/ldb_modules/password_hash.c8
-rw-r--r--source4/dsdb/samdb/ldb_modules/pdc_fsmo.c7
-rw-r--r--source4/dsdb/samdb/ldb_modules/proxy.c7
-rw-r--r--source4/dsdb/samdb/ldb_modules/ranged_results.c7
-rw-r--r--source4/dsdb/samdb/ldb_modules/repl_meta_data.c7
-rw-r--r--source4/dsdb/samdb/ldb_modules/rootdse.c8
-rw-r--r--source4/dsdb/samdb/ldb_modules/samba3sam.c17
-rw-r--r--source4/dsdb/samdb/ldb_modules/samldb.c8
-rw-r--r--source4/dsdb/samdb/ldb_modules/schema.c7
-rw-r--r--source4/dsdb/samdb/ldb_modules/schema_fsmo.c7
-rw-r--r--source4/dsdb/samdb/ldb_modules/show_deleted.c7
-rw-r--r--source4/dsdb/samdb/ldb_modules/simple_ldap_map.c38
-rw-r--r--source4/dsdb/samdb/ldb_modules/subtree_delete.c7
-rw-r--r--source4/dsdb/samdb/ldb_modules/subtree_rename.c7
-rw-r--r--source4/dsdb/samdb/ldb_modules/update_keytab.c7
-rw-r--r--source4/dsdb/schema/schema.h2
-rw-r--r--source4/dsdb/schema/schema_init.c14
-rw-r--r--source4/dsdb/schema/schema_syntax.c17
-rw-r--r--source4/dynconfig.mk20
-rw-r--r--source4/headermap.txt1
-rw-r--r--source4/heimdal_build/config.mk61
-rw-r--r--source4/kdc/config.mk3
-rw-r--r--source4/lib/basic.mk42
-rw-r--r--source4/lib/events/events_select.c2
-rw-r--r--source4/lib/events/events_standard.c2
-rw-r--r--source4/lib/gencache/gencache.h94
-rw-r--r--source4/lib/ldb/Makefile.in151
-rw-r--r--source4/lib/ldb/common/ldb.c65
-rw-r--r--source4/lib/ldb/common/ldb_modules.c75
-rw-r--r--source4/lib/ldb/config.mk24
-rw-r--r--source4/lib/ldb/configure.ac4
-rw-r--r--source4/lib/ldb/include/ldb_private.h37
-rw-r--r--source4/lib/ldb/ldb.mk89
-rw-r--r--source4/lib/ldb/ldb_ildap/config.mk1
-rw-r--r--source4/lib/ldb/ldb_ildap/ldb_ildap.c21
-rw-r--r--source4/lib/ldb/ldb_ldap/ldb_ldap.c20
-rw-r--r--source4/lib/ldb/ldb_map/ldb_map.c38
-rw-r--r--source4/lib/ldb/ldb_map/ldb_map.h17
-rw-r--r--source4/lib/ldb/ldb_map/ldb_map_private.h7
-rw-r--r--source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c8
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c8
-rw-r--r--source4/lib/ldb/modules/asq.c8
-rw-r--r--source4/lib/ldb/modules/operational.c7
-rw-r--r--source4/lib/ldb/modules/paged_results.c8
-rw-r--r--source4/lib/ldb/modules/paged_searches.c8
-rw-r--r--source4/lib/ldb/modules/rdn_name.c8
-rw-r--r--source4/lib/ldb/modules/skel.c7
-rw-r--r--source4/lib/ldb/modules/sort.c7
-rw-r--r--source4/lib/ldb/nssldb/ldb-nss.c5
-rw-r--r--source4/lib/ldb/rules.mk30
-rwxr-xr-xsource4/lib/ldb/setup.py15
-rwxr-xr-xsource4/lib/ldb/tests/python/api.py3
-rwxr-xr-xsource4/lib/ldb/tests/python/ldap.py1465
-rw-r--r--source4/lib/ldb/tests/sample_module.c9
-rw-r--r--source4/lib/ldb/tools/ad2oLschema.c2
-rw-r--r--source4/lib/ldb/tools/cmdline.c2
-rw-r--r--source4/lib/ldb/tools/ldbadd.c2
-rw-r--r--source4/lib/ldb/tools/ldbdel.c2
-rw-r--r--source4/lib/ldb/tools/ldbedit.c2
-rw-r--r--source4/lib/ldb/tools/ldbmodify.c2
-rw-r--r--source4/lib/ldb/tools/ldbrename.c2
-rw-r--r--source4/lib/ldb/tools/ldbsearch.c2
-rw-r--r--source4/lib/ldb/tools/ldbtest.c2
-rw-r--r--source4/lib/ldb/tools/oLschema2ldif.c2
-rw-r--r--source4/lib/registry/ldb.c2
-rw-r--r--source4/lib/registry/tools/regshell.c3
-rw-r--r--source4/lib/replace/dlfcn.c2
-rw-r--r--source4/lib/replace/getifaddrs.m433
-rw-r--r--source4/lib/replace/getpass.m412
-rw-r--r--source4/lib/replace/libreplace.m472
-rw-r--r--source4/lib/replace/libreplace_ld.m43
-rw-r--r--source4/lib/replace/system/config.m416
-rw-r--r--source4/lib/replace/system/network.h7
-rw-r--r--source4/lib/samba3/config.mk14
-rw-r--r--source4/lib/samba3/group.c141
-rw-r--r--source4/lib/samba3/idmap.c98
-rw-r--r--source4/lib/samba3/policy.c50
-rw-r--r--source4/lib/samba3/registry.c147
-rw-r--r--source4/lib/samba3/samba3.c132
-rw-r--r--source4/lib/samba3/samba3.h1
-rw-r--r--source4/lib/samba3/secrets.c263
-rw-r--r--source4/lib/samba3/share_info.c89
-rw-r--r--source4/lib/samba3/smbpasswd.c139
-rw-r--r--source4/lib/samba3/tdbsam.c263
-rw-r--r--source4/lib/samba3/winsdb.c160
-rw-r--r--source4/lib/socket/config.mk4
-rw-r--r--source4/lib/socket/socket_ip.c4
-rw-r--r--source4/lib/socket/socket_unix.c2
-rw-r--r--source4/lib/socket_wrapper/config.m47
-rw-r--r--source4/lib/socket_wrapper/socket_wrapper.c79
-rw-r--r--source4/lib/talloc/Makefile.in68
-rw-r--r--source4/lib/talloc/config.mk4
-rw-r--r--source4/lib/talloc/configure.ac2
-rw-r--r--source4/lib/talloc/rules.mk18
-rw-r--r--source4/lib/talloc/talloc.c197
-rw-r--r--source4/lib/talloc/talloc.h1
-rw-r--r--source4/lib/talloc/talloc.mk37
-rw-r--r--source4/lib/talloc/testsuite.c37
-rw-r--r--source4/lib/talloc/web/index.html15
-rw-r--r--source4/lib/tdb/Makefile.in126
-rw-r--r--source4/lib/tdb/config.mk4
-rw-r--r--source4/lib/tdb/configure.ac5
-rw-r--r--source4/lib/tdb/python/tests/simple.py5
-rw-r--r--source4/lib/tdb/rules.mk21
-rwxr-xr-xsource4/lib/tdb/setup.py11
-rw-r--r--source4/lib/tdb/tdb.mk86
-rw-r--r--source4/lib/tls/config.m44
-rw-r--r--source4/lib/util/attr.h2
-rw-r--r--source4/lib/util/fault.c2
-rw-r--r--source4/lib/util/time.c8
-rw-r--r--source4/lib/util/time.h5
-rw-r--r--source4/lib/util/util.h3
-rw-r--r--source4/lib/util/util_ldb.c17
-rw-r--r--source4/libcli/composite/composite.c31
-rw-r--r--source4/libcli/config.mk10
-rw-r--r--source4/libcli/raw/clisession.c20
-rw-r--r--source4/libcli/raw/clitransport.c4
-rw-r--r--source4/libcli/raw/clitree.c6
-rw-r--r--source4/libcli/raw/interfaces.h68
-rw-r--r--source4/libcli/raw/libcliraw.h4
-rw-r--r--source4/libcli/raw/rawfile.c4
-rw-r--r--source4/libcli/raw/rawioctl.c2
-rw-r--r--source4/libcli/raw/rawnegotiate.c14
-rw-r--r--source4/libcli/raw/rawreadwrite.c9
-rw-r--r--source4/libcli/raw/rawrequest.c94
-rw-r--r--source4/libcli/raw/rawsearch.c2
-rw-r--r--source4/libcli/raw/rawsetfileinfo.c11
-rw-r--r--source4/libcli/raw/request.h19
-rw-r--r--source4/libcli/raw/smb_signing.c6
-rw-r--r--source4/libcli/smb2/cancel.c6
-rw-r--r--source4/libcli/smb2/connect.c10
-rw-r--r--source4/libcli/smb2/create.c52
-rw-r--r--source4/libcli/smb2/getinfo.c45
-rw-r--r--source4/libcli/smb2/logoff.c2
-rw-r--r--source4/libcli/smb2/negprot.c54
-rw-r--r--source4/libcli/smb2/notify.c2
-rw-r--r--source4/libcli/smb2/request.c101
-rw-r--r--source4/libcli/smb2/session.c24
-rw-r--r--source4/libcli/smb2/setinfo.c6
-rw-r--r--source4/libcli/smb2/smb2.h73
-rw-r--r--source4/libcli/smb2/smb2_calls.h61
-rw-r--r--source4/libcli/smb2/tcon.c18
-rw-r--r--source4/libcli/smb2/transport.c4
-rw-r--r--source4/libnet/config.mk2
-rw-r--r--source4/librpc/config.mk2
-rw-r--r--source4/librpc/idl/dcerpc.idl3
-rw-r--r--source4/librpc/idl/drsblobs.idl3
-rw-r--r--source4/librpc/idl/drsuapi.idl9
-rw-r--r--source4/librpc/idl/epmapper.idl12
-rw-r--r--source4/librpc/idl/idl_types.h17
-rw-r--r--source4/librpc/idl/initshutdown.idl25
-rw-r--r--source4/librpc/idl/krb5pac.idl3
-rw-r--r--source4/librpc/idl/lsa.idl10
-rw-r--r--source4/librpc/idl/nbt.idl2
-rw-r--r--source4/librpc/idl/spoolss.idl15
-rw-r--r--source4/librpc/idl/winreg.idl14
-rw-r--r--source4/librpc/ndr/libndr.h2
-rw-r--r--source4/librpc/ndr/ndr_sec_helper.c3
-rw-r--r--source4/librpc/ndr/ndr_string.c45
-rw-r--r--source4/librpc/rpc/dcerpc_smb2.c6
-rw-r--r--source4/main.mk402
-rw-r--r--source4/nbt_server/config.mk2
-rw-r--r--source4/nbt_server/wins/wins_ldb.c9
-rw-r--r--source4/nsswitch/config.mk3
-rw-r--r--source4/ntvfs/cifs/vfs_cifs.c20
-rw-r--r--source4/ntvfs/config.mk8
-rw-r--r--source4/ntvfs/ipc/vfs_ipc.c4
-rw-r--r--source4/ntvfs/ntvfs.h8
-rw-r--r--source4/ntvfs/ntvfs_generic.c12
-rw-r--r--source4/ntvfs/posix/config.mk2
-rw-r--r--source4/ntvfs/posix/pvfs_setfileinfo.c44
-rw-r--r--source4/param/config.mk5
-rw-r--r--source4/param/loadparm.c326
-rw-r--r--source4/pidl/config.mk36
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm2
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm8
-rw-r--r--source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm40
-rw-r--r--source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm4
-rwxr-xr-xsource4/pidl/tests/ndr_compat.pl2
-rwxr-xr-xsource4/pidl/tests/wireshark-conf.pl9
-rw-r--r--source4/rpc_server/config.mk4
-rw-r--r--source4/rules.mk199
-rw-r--r--source4/samba4-knownfail75
-rw-r--r--source4/samba4-quick64
-rw-r--r--source4/samba4-skip105
-rwxr-xr-xsource4/script/cflags.pl35
-rwxr-xr-xsource4/scripting/bin/minschema.py579
-rwxr-xr-xsource4/scripting/bin/subunitrun5
-rw-r--r--source4/scripting/ejs/config.mk29
-rw-r--r--source4/scripting/ejs/smbcalls_samba3.c501
-rw-r--r--source4/scripting/ejs/smbscript.c2
-rw-r--r--source4/scripting/libjs/provision.js4
-rw-r--r--source4/scripting/python/config.m48
-rw-r--r--source4/scripting/python/config.mk2
-rw-r--r--source4/scripting/python/samba/provision.py54
-rw-r--r--source4/scripting/python/samba/samdb.py8
-rw-r--r--source4/scripting/python/samba/tests/__init__.py6
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/registry.py4
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/rpcecho.py5
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/sam.py3
-rw-r--r--source4/scripting/python/samba/tests/provision.py5
-rw-r--r--source4/scripting/python/samba/tests/samdb.py55
-rw-r--r--source4/scripting/python/samba/tests/upgrade.py19
-rw-r--r--source4/scripting/python/samba/upgrade.py6
-rw-r--r--source4/scripting/python/subunit/__init__.py6
-rw-r--r--source4/selftest/README21
-rw-r--r--source4/selftest/config.mk45
-rw-r--r--source4/selftest/output/plain.pm11
-rwxr-xr-xsource4/selftest/samba4_tests.sh139
-rwxr-xr-xsource4/selftest/selftest.pl48
-rw-r--r--source4/selftest/target/Kvm.pm167
-rw-r--r--source4/selftest/target/Samba4.pm24
-rwxr-xr-xsource4/setup/newuser.py61
-rwxr-xr-xsource4/setup/tests/blackbox_provision.sh39
-rw-r--r--source4/smb_server/blob.c45
-rw-r--r--source4/smb_server/config.mk4
-rw-r--r--source4/smb_server/smb/config.mk1
-rw-r--r--source4/smb_server/smb/negprot.c3
-rw-r--r--source4/smb_server/smb/nttrans.c6
-rw-r--r--source4/smb_server/smb/receive.c6
-rw-r--r--source4/smb_server/smb/reply.c94
-rw-r--r--source4/smb_server/smb/request.c64
-rw-r--r--source4/smb_server/smb/search.c12
-rw-r--r--source4/smb_server/smb/trans2.c24
-rw-r--r--source4/smb_server/smb2/config.mk1
-rw-r--r--source4/smb_server/smb2/fileinfo.c49
-rw-r--r--source4/smb_server/smb2/fileio.c27
-rw-r--r--source4/smb_server/smb2/find.c5
-rw-r--r--source4/smb_server/smb2/negprot.c104
-rw-r--r--source4/smb_server/smb2/receive.c38
-rw-r--r--source4/smb_server/smb2/sesssetup.c27
-rw-r--r--source4/smb_server/smb2/tcon.c57
-rw-r--r--source4/smb_server/smb_server.h6
-rw-r--r--source4/smbd/server.c2
-rw-r--r--source4/torture/config.mk39
-rw-r--r--source4/torture/gentest.c173
-rw-r--r--source4/torture/libnet/libnet_BecomeDC.c333
-rw-r--r--source4/torture/local/torture.c35
-rw-r--r--source4/torture/locktest.c181
-rw-r--r--source4/torture/masktest.c157
-rw-r--r--source4/torture/rpc/eventlog.c10
-rw-r--r--source4/torture/rpc/initshutdown.c13
-rw-r--r--source4/torture/rpc/samba3rpc.c73
-rw-r--r--source4/torture/rpc/samsync.c13
-rw-r--r--source4/torture/rpc/spoolss.c22
-rw-r--r--source4/torture/rpc/winreg.c15
-rw-r--r--source4/torture/smb2/connect.c10
-rw-r--r--source4/torture/smb2/getinfo.c10
-rw-r--r--source4/torture/smb2/lock.c8
-rw-r--r--source4/torture/smb2/scan.c15
-rw-r--r--source4/torture/smb2/util.c43
-rw-r--r--source4/torture/smbtorture.c2
-rw-r--r--source4/torture/util.c73
-rw-r--r--source4/torture/util.h120
-rw-r--r--source4/torture/util_provision.c355
-rw-r--r--source4/torture/util_smb.c39
-rw-r--r--source4/utils/net/net.c2
-rwxr-xr-xsource4/utils/tests/test_nmblookup.sh36
303 files changed, 6182 insertions, 6448 deletions
diff --git a/source4/Makefile b/source4/Makefile
new file mode 100644
index 0000000000..1fddfefce3
--- /dev/null
+++ b/source4/Makefile
@@ -0,0 +1,185 @@
+#!gmake
+# The Samba 4 Makefile.
+# This file is *NOT* autogenerated.
+
+include mkconfig.mk
+
+VPATH = $(builddir):$(srcdir):heimdal_build:heimdal/lib/asn1:heimdal/lib/krb5:heimdal/lib/gssapi:heimdal/lib/hdb:heimdal/lib/roken:heimdal/lib/des
+
+BASEDIR = $(prefix)
+TORTUREDIR = $(libdir)/torture
+SWATDIR = $(datadir)/swat
+JSDIR = $(datadir)/js
+SETUPDIR = $(datadir)/setup
+NCALRPCDIR = $(localstatedir)/ncalrpc
+
+BNLD = $(LD)
+BNLD_FLAGS = $(LDFLAGS) $(SYS_LDFLAGS)
+
+HOSTCC_FLAGS = -D_SAMBA_HOSTCC_ $(CFLAGS)
+HOSTLD_FLAGS = $(LDFLAGS) $(SYS_LDFLAGS)
+
+default: all
+
+include rules.mk
+include data.mk
+
+DEFAULT_HEADERS = $(srcdir)/lib/util/dlinklist.h \
+ $(srcdir)/version.h
+
+binaries::
+libraries:: $(STATIC_LIBS) $(SHARED_LIBS)
+modules:: $(PLUGINS)
+headers:: $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
+manpages:: $(MANPAGES)
+all:: showflags $(ALL_PREDEP) bin/asn1_compile bin/compile_et binaries modules pythonmods
+everything:: all libraries headers
+
+LD_LIBPATH_OVERRIDE = $(LIB_PATH_VAR)=$(builddir)/bin/shared
+
+# 'make testsuite' creates all binaries which are
+# needed by samba3's 'make test' and the build-farm
+# scripts use that it as fallback in case
+# 'make everything' fails
+testsuite:: bin/smbclient bin/cifsdd bin/smbtorture bin/nmblookup
+
+showlayout::
+ @echo 'Samba will be installed into:'
+ @echo ' basedir: $(BASEDIR)'
+ @echo ' bindir: $(bindir)'
+ @echo ' sbindir: $(sbindir)'
+ @echo ' libdir: $(libdir)'
+ @echo ' modulesdir: $(modulesdir)'
+ @echo ' includedir: $(includedir)'
+ @echo ' vardir: $(localstatedir)'
+ @echo ' privatedir: $(privatedir)'
+ @echo ' piddir: $(piddir)'
+ @echo ' lockdir: $(lockdir)'
+ @echo ' logfilebase: $(logfilebase)'
+ @echo ' setupdir: $(SETUPDIR)'
+ @echo ' jsdir: $(JSDIR)'
+ @echo ' swatdir: $(SWATDIR)'
+ @echo ' mandir: $(mandir)'
+ @echo ' torturedir: $(TORTUREDIR)'
+ @echo ' datadir: $(datadir)'
+ @echo ' winbindd_socket_dir: $(winbindd_socket_dir)'
+
+showflags::
+ @echo ' srcdir = $(srcdir)'
+ @echo ' builddir = $(builddir)'
+
+# The permissions to give the executables
+INSTALLPERMS = 0755
+
+install:: showlayout everything installbin installdat installswat installmisc \
+ installlib installheader installpc installplugins
+
+# DESTDIR is used here to prevent packagers wasting their time
+# duplicating the Makefile. Remove it and you will have the privilege
+# of packaging each samba release for multiple versions of multiple
+# distributions and operating systems, or at least supplying patches
+# to all the packaging files required for this, prior to committing
+# the removal of DESTDIR. Do not remove it even though you think it
+# is not used.
+
+installdirs::
+ @$(SHELL) $(srcdir)/script/installdirs.sh \
+ $(DESTDIR)$(BASEDIR) \
+ $(DESTDIR)$(bindir) \
+ $(DESTDIR)$(sbindir) \
+ $(DESTDIR)$(TORTUREDIR) \
+ $(DESTDIR)$(libdir) \
+ $(DESTDIR)$(modulesdir) \
+ $(DESTDIR)$(mandir) \
+ $(DESTDIR)$(localstatedir) \
+ $(DESTDIR)$(privatedir) \
+ $(DESTDIR)$(datadir) \
+ $(DESTDIR)$(piddir) \
+ $(DESTDIR)$(lockdir) \
+ $(DESTDIR)$(logfilebase) \
+ $(DESTDIR)$(privatedir)/tls \
+ $(DESTDIR)$(includedir) \
+ $(DESTDIR)$(PKGCONFIGDIR) \
+ $(DESTDIR)$(sysconfdir) \
+
+installbin:: $(SBIN_PROGS) $(BIN_PROGS) $(TORTURE_PROGS) installdirs
+ @$(SHELL) $(srcdir)/script/installbin.sh \
+ $(INSTALLPERMS) \
+ $(DESTDIR)$(BASEDIR) \
+ $(DESTDIR)$(sbindir) \
+ $(DESTDIR)$(libdir) \
+ $(DESTDIR)$(localstatedir) \
+ $(SBIN_PROGS)
+ @$(SHELL) $(srcdir)/script/installbin.sh \
+ $(INSTALLPERMS) \
+ $(DESTDIR)$(BASEDIR) \
+ $(DESTDIR)$(bindir) \
+ $(DESTDIR)$(libdir) \
+ $(DESTDIR)$(localstatedir) \
+ $(BIN_PROGS)
+ @$(SHELL) $(srcdir)/script/installtorture.sh \
+ $(INSTALLPERMS) \
+ $(DESTDIR)$(TORTUREDIR) \
+ $(TORTURE_PROGS)
+
+installplugins::
+
+installlib:: $(SHARED_LIBS) $(STATIC_LIBS) installdirs
+ @$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(libdir) "$(SHLIBEXT)" $(SHARED_LIBS)
+ #@$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(libdir) "$(STLIBEXT)" $(STATIC_LIBS)
+
+installheader:: headers installdirs
+ @srcdir=$(srcdir) builddir=$(builddir) $(PERL) $(srcdir)/script/installheader.pl $(DESTDIR)$(includedir) $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
+
+installdat:: installdirs
+ @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(datadir) $(srcdir)
+
+installswat:: installdirs
+ @$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir)
+
+installman:: manpages installdirs
+ @$(SHELL) $(srcdir)/script/installman.sh $(DESTDIR)$(mandir) $(MANPAGES)
+
+installmisc:: installdirs
+ @$(SHELL) $(srcdir)/script/installmisc.sh $(srcdir) $(DESTDIR)$(JSDIR) $(DESTDIR)$(SETUPDIR) $(DESTDIR)$(bindir)
+
+installpc:: installdirs
+ @$(SHELL) $(srcdir)/script/installpc.sh $(builddir) $(DESTDIR)$(PKGCONFIGDIR) $(PC_FILES)
+
+uninstall:: uninstallbin uninstallman uninstallmisc uninstalllib uninstallheader \
+ uninstallplugins
+
+uninstallmisc::
+ #FIXME
+
+uninstallbin::
+ @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(sbindir) $(DESTDIR)$(libdir) $(DESTDIR)$(localstatedir) $(DESTDIR)$(SBIN_PROGS)
+ @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(localstatedir) $(DESTDIR)$(BIN_PROGS)
+ @$(SHELL) $(srcdir)/script/uninstalltorture.sh $(DESTDIR)$(TORTUREDIR) $(TORTURE_PROGS)
+
+uninstalllib::
+ @$(SHELL) $(srcdir)/script/uninstalllib.sh $(DESTDIR)$(libdir) $(SHARED_LIBS)
+ #@$(SHELL) $(srcdir)/script/uninstalllib.sh $(DESTDIR)$(libdir) $(STATIC_LIBS)
+
+uninstallheader::
+ @$(SHELL) $(srcdir)/script/uninstallheader.sh $(DESTDIR)$(includedir) $(PUBLIC_HEADERS)
+
+uninstallman::
+ @$(SHELL) $(srcdir)/script/uninstallman.sh $(DESTDIR)$(mandir) $(MANPAGES)
+
+uninstallplugins::
+
+config.status:
+ @echo "config.status does not exist. Please run ./configure."
+ @/bin/false
+
+data.mk: config.status $(MK_FILES)
+ ./config.status
+
+testcov-html::
+
+include pidl/config.mk
+include selftest/config.mk
+
+showflags::
+ @echo ' pwd = '`/bin/pwd`
diff --git a/source4/auth/auth_anonymous.c b/source4/auth/auth_anonymous.c
index bcab918347..38c13d4b65 100644
--- a/source4/auth/auth_anonymous.c
+++ b/source4/auth/auth_anonymous.c
@@ -63,7 +63,7 @@ static const struct auth_operations anonymous_auth_ops = {
.check_password = anonymous_check_password
};
-NTSTATUS auth_anonymous_init(void)
+_PUBLIC_ NTSTATUS auth_anonymous_init(void)
{
NTSTATUS ret;
diff --git a/source4/auth/auth_developer.c b/source4/auth/auth_developer.c
index 57eb752ac8..0da947b68d 100644
--- a/source4/auth/auth_developer.c
+++ b/source4/auth/auth_developer.c
@@ -186,7 +186,7 @@ static const struct auth_operations fixed_challenge_auth_ops = {
.check_password = fixed_challenge_check_password
};
-NTSTATUS auth_developer_init(void)
+_PUBLIC_ NTSTATUS auth_developer_init(void)
{
NTSTATUS ret;
diff --git a/source4/auth/auth_sam.c b/source4/auth/auth_sam.c
index 0885d8265a..9189640150 100644
--- a/source4/auth/auth_sam.c
+++ b/source4/auth/auth_sam.c
@@ -425,7 +425,7 @@ static const struct auth_operations sam_ops = {
.check_password = authsam_check_password
};
-NTSTATUS auth_sam_init(void)
+_PUBLIC_ NTSTATUS auth_sam_init(void)
{
NTSTATUS ret;
diff --git a/source4/auth/auth_unix.c b/source4/auth/auth_unix.c
index 62fb42935a..20e198701d 100644
--- a/source4/auth/auth_unix.c
+++ b/source4/auth/auth_unix.c
@@ -829,7 +829,7 @@ static const struct auth_operations unix_ops = {
.check_password = authunix_check_password
};
-NTSTATUS auth_unix_init(void)
+_PUBLIC_ NTSTATUS auth_unix_init(void)
{
NTSTATUS ret;
diff --git a/source4/auth/auth_winbind.c b/source4/auth/auth_winbind.c
index 89ae3195df..2f8074d3cb 100644
--- a/source4/auth/auth_winbind.c
+++ b/source4/auth/auth_winbind.c
@@ -260,7 +260,7 @@ static const struct auth_operations winbind_ops = {
.check_password = winbind_check_password
};
-NTSTATUS auth_winbind_init(void)
+_PUBLIC_ NTSTATUS auth_winbind_init(void)
{
NTSTATUS ret;
diff --git a/source4/auth/config.mk b/source4/auth/config.mk
index 37581b95f3..5b320bcf36 100644
--- a/source4/auth/config.mk
+++ b/source4/auth/config.mk
@@ -1,8 +1,8 @@
# auth server subsystem
-include gensec/config.mk
-include kerberos/config.mk
-include ntlmssp/config.mk
-include credentials/config.mk
+mkinclude gensec/config.mk
+mkinclude kerberos/config.mk
+mkinclude ntlmssp/config.mk
+mkinclude credentials/config.mk
[SUBSYSTEM::auth_session]
OBJ_FILES = session.o
diff --git a/source4/auth/gensec/config.mk b/source4/auth/gensec/config.mk
index a53dff8bfe..9aab2c704e 100644
--- a/source4/auth/gensec/config.mk
+++ b/source4/auth/gensec/config.mk
@@ -62,7 +62,7 @@ INIT_FUNCTION = gensec_schannel_init
OBJ_FILES = schannel.o \
schannel_sign.o
PRIVATE_DEPENDENCIES = SCHANNELDB NDR_SCHANNEL CREDENTIALS LIBNDR
-OUTPUT_TYPE = INTEGRATED
+OUTPUT_TYPE = MERGED_OBJ
# End MODULE gensec_schannel
################################################
diff --git a/source4/auth/gensec/cyrus_sasl.c b/source4/auth/gensec/cyrus_sasl.c
index 64a0b2f0c7..cb7bcb71d8 100644
--- a/source4/auth/gensec/cyrus_sasl.c
+++ b/source4/auth/gensec/cyrus_sasl.c
@@ -362,8 +362,11 @@ int gensec_sasl_log(void *context,
NTSTATUS gensec_sasl_init(void)
{
NTSTATUS ret;
- int sasl_ret, i;
+ int sasl_ret;
+#if 0
+ int i;
const char **sasl_mechs;
+#endif
static const sasl_callback_t callbacks[] = {
{
diff --git a/source4/auth/gensec/gensec_gssapi.c b/source4/auth/gensec/gensec_gssapi.c
index 87fa47646b..8361b115d7 100644
--- a/source4/auth/gensec/gensec_gssapi.c
+++ b/source4/auth/gensec/gensec_gssapi.c
@@ -1463,7 +1463,7 @@ static const struct gensec_security_ops gensec_gssapi_sasl_krb5_security_ops = {
.priority = GENSEC_GSSAPI
};
-NTSTATUS gensec_gssapi_init(void)
+_PUBLIC_ NTSTATUS gensec_gssapi_init(void)
{
NTSTATUS ret;
diff --git a/source4/auth/gensec/gensec_krb5.c b/source4/auth/gensec/gensec_krb5.c
index 5cd0de1ceb..d9addcaa3c 100644
--- a/source4/auth/gensec/gensec_krb5.c
+++ b/source4/auth/gensec/gensec_krb5.c
@@ -775,7 +775,7 @@ static const struct gensec_security_ops gensec_krb5_security_ops = {
.priority = GENSEC_KRB5
};
-NTSTATUS gensec_krb5_init(void)
+_PUBLIC_ NTSTATUS gensec_krb5_init(void)
{
NTSTATUS ret;
diff --git a/source4/auth/gensec/schannel.c b/source4/auth/gensec/schannel.c
index 42db959380..96e3478982 100644
--- a/source4/auth/gensec/schannel.c
+++ b/source4/auth/gensec/schannel.c
@@ -274,7 +274,7 @@ static const struct gensec_security_ops gensec_schannel_security_ops = {
.priority = GENSEC_SCHANNEL
};
-NTSTATUS gensec_schannel_init(void)
+_PUBLIC_ NTSTATUS gensec_schannel_init(void)
{
NTSTATUS ret;
ret = gensec_register(&gensec_schannel_security_ops);
diff --git a/source4/auth/gensec/spnego.c b/source4/auth/gensec/spnego.c
index 782aa44c75..f593d17d4b 100644
--- a/source4/auth/gensec/spnego.c
+++ b/source4/auth/gensec/spnego.c
@@ -1042,7 +1042,7 @@ static const struct gensec_security_ops gensec_spnego_security_ops = {
.priority = GENSEC_SPNEGO
};
-NTSTATUS gensec_spnego_init(void)
+_PUBLIC_ NTSTATUS gensec_spnego_init(void)
{
NTSTATUS ret;
ret = gensec_register(&gensec_spnego_security_ops);
diff --git a/source4/auth/ntlmssp/config.mk b/source4/auth/ntlmssp/config.mk
index 544850264a..9033384b1f 100644
--- a/source4/auth/ntlmssp/config.mk
+++ b/source4/auth/ntlmssp/config.mk
@@ -13,6 +13,6 @@ OBJ_FILES = ntlmssp.o \
ntlmssp_client.o \
ntlmssp_server.o
PRIVATE_DEPENDENCIES = MSRPC_PARSE CREDENTIALS
-OUTPUT_TYPE = INTEGRATED
+OUTPUT_TYPE = MERGED_OBJ
# End MODULE gensec_ntlmssp
################################################
diff --git a/source4/auth/ntlmssp/ntlmssp.c b/source4/auth/ntlmssp/ntlmssp.c
index 4f5822567a..8901488004 100644
--- a/source4/auth/ntlmssp/ntlmssp.c
+++ b/source4/auth/ntlmssp/ntlmssp.c
@@ -425,7 +425,7 @@ static const struct gensec_security_ops gensec_ntlmssp_security_ops = {
};
-NTSTATUS gensec_ntlmssp_init(void)
+_PUBLIC_ NTSTATUS gensec_ntlmssp_init(void)
{
NTSTATUS ret;
diff --git a/source4/autogen.sh b/source4/autogen.sh
index 9c73c96572..b721a45a99 100755
--- a/source4/autogen.sh
+++ b/source4/autogen.sh
@@ -1,9 +1,9 @@
#!/bin/sh
-# Run this script to build samba from SVN.
+# Run this script to build samba from git.
-## insert all possible names (only works with
-## autoconf 2.x
+## insert all possible names (only works with
+## autoconf 2.x)
TESTAUTOHEADER="autoheader autoheader-2.53 autoheader2.50 autoheader259 autoheader253"
TESTAUTOCONF="autoconf autoconf-2.53 autoconf2.50 autoconf259 autoconf253"
@@ -12,7 +12,7 @@ AUTOCONFFOUND="0"
##
-## Look for autoheader
+## Look for autoheader
##
for i in $TESTAUTOHEADER; do
if which $i > /dev/null 2>&1; then
@@ -24,7 +24,7 @@ for i in $TESTAUTOHEADER; do
fi
done
-##
+##
## Look for autoconf
##
@@ -39,11 +39,11 @@ for i in $TESTAUTOCONF; do
done
-##
+##
## do we have it?
##
if test "$AUTOCONFFOUND" = "0" -o "$AUTOHEADERFOUND" = "0"; then
- echo "$0: need autoconf 2.53 or later to build samba from SVN" >&2
+ echo "$0: need autoconf 2.53 or later to build samba from git" >&2
exit 1
fi
diff --git a/source4/build/m4/check_ld.m4 b/source4/build/m4/check_ld.m4
index 3b69057a69..0d0742e5d2 100644
--- a/source4/build/m4/check_ld.m4
+++ b/source4/build/m4/check_ld.m4
@@ -13,6 +13,7 @@ LD=""
AC_SUBST(BLDSHARED)
AC_SUBST(LD)
+AC_SUBST(SYS_LDFLAGS)
AC_SUBST(LDFLAGS)
# Assume non-shared by default and override below
@@ -32,13 +33,13 @@ AC_MSG_CHECKING([whether to try to build shared libraries on $host_os])
case "$host_os" in
*linux*)
BLDSHARED="true"
- LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
+ SYS_LDFLAGS="-Wl,--export-dynamic"
;;
*solaris*)
BLDSHARED="true"
if test "${GCC}" = "yes"; then
if test "${ac_cv_prog_gnu_ld}" = "yes"; then
- LDFLAGS="$LDFLAGS -Wl,-E"
+ SYS_LDFLAGS="-Wl,-E"
fi
fi
;;
@@ -47,26 +48,26 @@ case "$host_os" in
;;
*netbsd* | *freebsd* | *dragonfly* )
BLDSHARED="true"
- LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
+ SYS_LDFLAGS="-Wl,--export-dynamic"
;;
*openbsd*)
BLDSHARED="true"
- LDFLAGS="$LDFLAGS -Wl,-Bdynamic"
+ SYS_LDFLAGS="-Wl,-Bdynamic"
;;
*irix*)
BLDSHARED="true"
;;
*aix*)
BLDSHARED="true"
- LDFLAGS="$LDFLAGS -Wl,-brtl,-bexpall,-bbigtoc"
+ SYS_LDFLAGS="-Wl,-brtl,-bexpall,-bbigtoc"
;;
*hpux*)
# Use special PIC flags for the native HP-UX compiler.
BLDSHARED="true" # I hope this is correct
if test "$host_cpu" = "ia64"; then
- LDFLAGS="$LDFLAGS -Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32"
+ SYS_LDFLAGS="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32"
else
- LDFLAGS="$LDFLAGS -Wl,-E,+b/usr/local/lib:/usr/lib"
+ SYS_LDFLAGS="-Wl,-E,+b/usr/local/lib:/usr/lib"
fi
;;
*osf*)
@@ -86,6 +87,8 @@ AC_MSG_CHECKING([LD])
AC_MSG_RESULT([$LD])
AC_MSG_CHECKING([LDFLAGS])
AC_MSG_RESULT([$LDFLAGS])
+AC_MSG_CHECKING([SYS_LDFLAGS])
+AC_MSG_RESULT([$SYS_LDFLAGS])
AC_SUBST(HOSTLD)
diff --git a/source4/build/m4/check_make.m4 b/source4/build/m4/check_make.m4
index 4780f43e1c..d7799649a7 100644
--- a/source4/build/m4/check_make.m4
+++ b/source4/build/m4/check_make.m4
@@ -46,3 +46,11 @@ AC_ARG_ENABLE(automatic-dependencies,
[ automatic_dependencies=no ])
AC_MSG_RESULT($automatic_dependencies)
AC_SUBST(automatic_dependencies)
+
+FIRST_PREREQ="\$*.c"
+AC_SUBST(FIRST_PREREQ)
+
+if test x$GNU_MAKE = xyes; then
+ FIRST_PREREQ="\$<"
+fi
+
diff --git a/source4/build/m4/check_path.m4 b/source4/build/m4/check_path.m4
index 1dacd956ea..08a858ebb2 100644
--- a/source4/build/m4/check_path.m4
+++ b/source4/build/m4/check_path.m4
@@ -132,7 +132,7 @@ AC_SUBST(modulesdir)
selftest_prefix="./st"
AC_SUBST(selftest_prefix)
AC_ARG_WITH(selftest-prefix,
-[ --with-selftest-prefix=DIR The prefix where make test will be runned ($selftest_prefix)],
+[ --with-selftest-prefix=DIR The prefix where make test will be run ($selftest_prefix)],
[ case "$withval" in
yes|no)
AC_MSG_WARN([--with-selftest-prefix called without argument - will use default])
diff --git a/source4/build/m4/public.m4 b/source4/build/m4/public.m4
index 4192128bbd..eb673446c7 100644
--- a/source4/build/m4/public.m4
+++ b/source4/build/m4/public.m4
@@ -8,7 +8,7 @@ dnl SMB_SUBSYSTEM(name,obj_files,required_subsystems)
dnl
dnl SMB_EXT_LIB_FROM_PKGCONFIG(name,pkg-config name,[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
dnl
-dnl SMB_EXT_LIB(name,libs,cflags,cppflags,ldflags,pcname)
+dnl SMB_EXT_LIB(name,libs,cflags,cppflags,ldflags)
dnl
dnl SMB_ENABLE(name,default_build)
dnl
@@ -21,33 +21,45 @@ dnl #######################################################
dnl SMB_SUBSYSTEM(name,obj_files,required_subsystems,cflags)
AC_DEFUN([SMB_SUBSYSTEM],
[
+MAKE_SETTINGS="$MAKE_SETTINGS
+$1_OBJ_FILES = $2
+$1_CFLAGS = $4
+$1_ENABLE = YES
+"
+
SMB_INFO_SUBSYSTEMS="$SMB_INFO_SUBSYSTEMS
###################################
# Start Subsystem $1
@<:@SUBSYSTEM::$1@:>@
-OBJ_FILES = $2
+OBJ_FILES = \$($1_OBJ_FILES)
PRIVATE_DEPENDENCIES = $3
-CFLAGS = $4
+CFLAGS = \$($1_CFLAGS)
ENABLE = YES
# End Subsystem $1
###################################
"
])
-dnl SMB_LIBRARY(name,obj_files,required_subsystems,version,so_version,cflags,ldflags,pcname)
+dnl SMB_LIBRARY(name,obj_files,required_subsystems,version,so_version,cflags,ldflags)
AC_DEFUN([SMB_LIBRARY],
[
+MAKE_SETTINGS="$MAKE_SETTINGS
+$1_OBJ_FILES = $2
+$1_CFLAGS = $6
+$1_LDFLAGS = $7
+$1_ENABLE = YES
+"
+
SMB_INFO_LIBRARIES="$SMB_INFO_LIBRARIES
###################################
# Start Library $1
@<:@LIBRARY::$1@:>@
-OBJ_FILES = $2
+OBJ_FILES = \$($1_OBJ_FILES)
PRIVATE_DEPENDENCIES = $3
VERSION = $4
SO_VERSION = $5
-CFLAGS = $6
-LDFLAGS = $7
-PC_NAME = $8
+CFLAGS = \$($1_CFLAGS)
+LDFLAGS = \$($1_LDFLAGS)
ENABLE = YES
# End Library $1
###################################
@@ -91,8 +103,7 @@ AC_DEFUN([SMB_EXT_LIB_FROM_PKGCONFIG],
[`$PKG_CONFIG --libs-only-l '$2'`],
[`$PKG_CONFIG --cflags-only-other '$2'`],
[`$PKG_CONFIG --cflags-only-I '$2'`],
- [`$PKG_CONFIG --libs-only-other '$2'` `$PKG_CONFIG --libs-only-L '$2'`],
- [ $2 ])
+ [`$PKG_CONFIG --libs-only-other '$2'` `$PKG_CONFIG --libs-only-L '$2'`])
ac_cv_$1_found=yes
else
@@ -120,33 +131,28 @@ dnl SMB_INCLUDE_MK(file)
AC_DEFUN([SMB_INCLUDE_MK],
[
SMB_INFO_EXT_LIBS="$SMB_INFO_EXT_LIBS
-include $1
+mkinclude $1
"
])
-dnl SMB_EXT_LIB(name,libs,cflags,cppflags,ldflags,pcname)
+dnl SMB_EXT_LIB(name,libs,cflags,cppflags,ldflags)
AC_DEFUN([SMB_EXT_LIB],
[
-
-SMB_INFO_EXT_LIBS="$SMB_INFO_EXT_LIBS
-###################################
-# Start Ext Lib $1
-@<:@EXT_LIB::$1@:>@
-LIBS = $2
-CFLAGS = $3
-CPPFLAGS = $4
-LDFLAGS = $5
-PC_NAME = $6
-# End Ext Lib $1
-###################################
+MAKE_SETTINGS="$MAKE_SETTINGS
+$1_LIBS = $2
+$1_CFLAGS = $3
+$1_CPPFLAGS = $4
+$1_LDFLAGS = $5
"
+
])
dnl SMB_ENABLE(name,default_build)
AC_DEFUN([SMB_ENABLE],
[
- [SMB_ENABLE_][$1]="$2";
-
+ MAKE_SETTINGS="$MAKE_SETTINGS
+$1_ENABLE = $2
+"
SMB_INFO_ENABLES="$SMB_INFO_ENABLES
\$enabled{$1} = \"$2\";"
])
diff --git a/source4/build/smb_build/cflags.pm b/source4/build/smb_build/cflags.pm
index ad6cd42c65..a4ab90a8cd 100755
--- a/source4/build/smb_build/cflags.pm
+++ b/source4/build/smb_build/cflags.pm
@@ -23,6 +23,8 @@ sub create_cflags($$$$) {
open(CFLAGS_TXT,">$file") || die ("Can't open `$file'\n");
+ print CFLAGS_TXT "include mkconfig.mk\n";
+
my $src_ne_build = ($srcdir ne $builddir) ? 1 : 0;
foreach my $key (values %{$CTX}) {
diff --git a/source4/build/smb_build/config_mk.pm b/source4/build/smb_build/config_mk.pm
index aa075490bc..4d8db8a04e 100644
--- a/source4/build/smb_build/config_mk.pm
+++ b/source4/build/smb_build/config_mk.pm
@@ -18,7 +18,6 @@ my $section_types = {
"CFLAGS" => "list",
"CPPFLAGS" => "list",
"LDFLAGS" => "list",
- "PC_NAME" => "string",
},
"PYTHON" => {
SWIG_FILE => "string",
@@ -90,7 +89,6 @@ my $section_types = {
"SO_VERSION" => "string",
"LIBRARY_REALNAME" => "string",
- "PC_NAME" => "string",
"PC_FILE" => "string",
"INIT_FUNCTION_TYPE" => "string",
@@ -241,7 +239,7 @@ sub run_config_mk($$$$)
}
# include
- if ($line =~ /^include (.*)$/) {
+ if ($line =~ /^mkinclude (.*)$/) {
my $subfile= $1;
my $subdir = dirname($filename);
$subdir =~ s/^\.$//g;
diff --git a/source4/build/smb_build/dot.pl b/source4/build/smb_build/dot.pl
index 82f89c081a..e50ee50f95 100755
--- a/source4/build/smb_build/dot.pl
+++ b/source4/build/smb_build/dot.pl
@@ -44,7 +44,7 @@ my $name = "samba4";
my $only;
if (defined($subsys)) {
my $DEPEND = smb_build::input::check($INPUT, \%config::enabled,
- "STATIC_LIBRARY", "SHARED_LIBRARY", "SHARED_LIBRARY");
+ "MERGED_OBJ", "SHARED_LIBRARY", "SHARED_LIBRARY");
die("No such subsystem $subsys") unless (defined($DEPEND->{$subsys}));
diff --git a/source4/build/smb_build/header.pm b/source4/build/smb_build/header.pm
index b52464922b..c2bdbaf4c8 100644
--- a/source4/build/smb_build/header.pm
+++ b/source4/build/smb_build/header.pm
@@ -44,8 +44,14 @@ sub _prepare_build_h($)
$DEFINE->{VAL} .= "\t$_, \\\n";
unless (/{/) {
my $fn = $key->{INIT_FUNCTION_TYPE};
- $fn =~ s/\(\*\)/$_/;
- $output .= "$fn;\n";
+ my $n = $_;
+ if ($fn =~ /\(\*\)/) {
+ $fn =~ s/\(\*\)/$n/;
+ $output .= "$fn;\n";
+ } else {
+ $n =~ s/\&//;
+ $output .= "$fn $n;\n";
+ }
}
}
@@ -82,4 +88,5 @@ sub create_smb_build_h($$)
print __FILE__.": creating $file\n";
}
+
1;
diff --git a/source4/build/smb_build/input.pm b/source4/build/smb_build/input.pm
index 6d5c4f4a1e..da90e9db48 100644
--- a/source4/build/smb_build/input.pm
+++ b/source4/build/smb_build/input.pm
@@ -5,13 +5,10 @@
# Copyright (C) Jelmer Vernooij 2004
# Released under the GNU GPL
-use smb_build::config;
use strict;
package smb_build::input;
use File::Basename;
-my $srcdir = $config::config{srcdir};
-
sub strtrim($)
{
$_ = shift;
@@ -60,14 +57,9 @@ sub check_subsystem($$$)
my ($INPUT, $subsys, $default_ot) = @_;
return if ($subsys->{ENABLE} ne "YES");
- unless(defined($subsys->{OUTPUT_TYPE})) {
- $subsys->{OUTPUT_TYPE} = $default_ot;
- }
-
+ unless (defined($subsys->{OUTPUT_TYPE})) { $subsys->{OUTPUT_TYPE} = $default_ot; }
unless (defined($subsys->{INIT_FUNCTION_TYPE})) { $subsys->{INIT_FUNCTION_TYPE} = "NTSTATUS (*) (void)"; }
unless (defined($subsys->{INIT_FUNCTION_SENTINEL})) { $subsys->{INIT_FUNCTION_SENTINEL} = "NULL"; }
-
- add_libreplace($subsys);
}
sub check_module($$$)
@@ -76,18 +68,16 @@ sub check_module($$$)
die("Module $mod->{NAME} does not have a SUBSYSTEM set") if not defined($mod->{SUBSYSTEM});
- my $use_default = 0;
-
if (not exists($INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTIONS})) {
$INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTIONS} = [];
}
if (!(defined($INPUT->{$mod->{SUBSYSTEM}}))) {
- $mod->{ENABLE} = "NO";
- return;
+ die("Unknown subsystem $mod->{SUBSYSTEM} for module $mod->{NAME}");
}
if ($INPUT->{$mod->{SUBSYSTEM}} eq "NO") {
+ warn("Disabling module $mod->{NAME} because subsystem $mod->{SUBSYSTEM} is disabled");
$mod->{ENABLE} = "NO";
return;
}
@@ -102,7 +92,7 @@ sub check_module($$$)
if (not defined($mod->{OUTPUT_TYPE})) {
if ($INPUT->{$mod->{SUBSYSTEM}}->{TYPE} eq "EXT_LIB") {
- $mod->{OUTPUT_TYPE} = ["SHARED_LIBRARY"];
+ $mod->{OUTPUT_TYPE} = undef;
} else {
$mod->{OUTPUT_TYPE} = $default_ot;
}
@@ -113,11 +103,12 @@ sub check_module($$$)
$sane_subsystem =~ s/^lib//;
$mod->{INSTALLDIR} = "MODULESDIR/$sane_subsystem";
push (@{$mod->{PUBLIC_DEPENDENCIES}}, $mod->{SUBSYSTEM});
+ add_libreplace($mod);
}
- if (grep(/INTEGRATED/, @{$mod->{OUTPUT_TYPE}})) {
+ if (grep(/MERGED_OBJ/, @{$mod->{OUTPUT_TYPE}})) {
push (@{$INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTIONS}}, $mod->{INIT_FUNCTION}) if defined($mod->{INIT_FUNCTION});
+ unshift (@{$INPUT->{$mod->{SUBSYSTEM}}{PRIVATE_DEPENDENCIES}}, $mod->{NAME});
}
- add_libreplace($mod);
}
sub check_library($$$)
@@ -126,9 +117,7 @@ sub check_library($$$)
return if ($lib->{ENABLE} ne "YES");
- unless (defined($lib->{OUTPUT_TYPE})) {
- $lib->{OUTPUT_TYPE} = $default_ot;
- }
+ unless (defined($lib->{OUTPUT_TYPE})) { $lib->{OUTPUT_TYPE} = $default_ot; }
if (defined($lib->{VERSION}) and not defined($lib->{SO_VERSION})) {
print "$lib->{NAME}: Please specify SO_VERSION when specifying VERSION\n";
@@ -141,12 +130,8 @@ sub check_library($$$)
}
unless (defined($lib->{INIT_FUNCTION_TYPE})) { $lib->{INIT_FUNCTION_TYPE} = "NTSTATUS (*) (void)"; }
-
unless (defined($lib->{INIT_FUNCTION_SENTINEL})) { $lib->{INIT_FUNCTION_SENTINEL} = "NULL"; }
-
- unless(defined($lib->{INSTALLDIR})) {
- $lib->{INSTALLDIR} = "LIBDIR";
- }
+ unless (defined($lib->{INSTALLDIR})) { $lib->{INSTALLDIR} = "LIBDIR"; }
add_libreplace($lib);
}
@@ -169,8 +154,8 @@ sub check_python($$$)
$python->{OBJ_FILES} = ["$dirname$basename\_wrap.o"];
$python->{LIBRARY_REALNAME} = "_$basename.\$(SHLIBEXT)";
$python->{PYTHON_FILES} = ["$dirname$basename.py"];
- push (@{$python->{CFLAGS}}, $config::config{CFLAG_NO_UNUSED_MACROS});
- push (@{$python->{CFLAGS}}, $config::config{CFLAG_NO_CAST_QUAL});
+ push (@{$python->{CFLAGS}}, "\$(CFLAG_NO_UNUSED_MACROS)");
+ push (@{$python->{CFLAGS}}, "\$(CFLAG_NO_CAST_QUAL)");
$python->{INIT_FUNCTION} = "{ (char *)\"_$basename\", init_$basename }";
} else {
my $basename = $python->{NAME};
@@ -178,7 +163,7 @@ sub check_python($$$)
$python->{LIBRARY_REALNAME} = "$basename.\$(SHLIBEXT)";
$python->{INIT_FUNCTION} = "{ (char *)\"$basename\", init$basename }";
}
- push (@{$python->{CFLAGS}}, @{$INPUT->{EXT_LIB_PYTHON}->{CFLAGS}});
+ push (@{$python->{CFLAGS}}, "\$(EXT_LIB_PYTHON_CFLAGS)");
$python->{SUBSYSTEM} = "LIBPYTHON";
@@ -197,25 +182,20 @@ sub check_binary($$)
add_libreplace($bin);
}
-sub import_integrated($$)
+sub add_implicit($$)
{
- my ($lib, $depend) = @_;
-
- foreach my $mod (values %$depend) {
- next if(not defined($mod->{OUTPUT_TYPE}));
- next if(not grep(/INTEGRATED/, @{$mod->{OUTPUT_TYPE}}));
- next if(not defined($mod->{SUBSYSTEM}));
- next if($mod->{SUBSYSTEM} ne $lib->{NAME});
- next if($mod->{ENABLE} ne "YES");
-
- push (@{$lib->{FULL_OBJ_LIST}}, "\$($mod->{TYPE}_$mod->{NAME}_FULL_OBJ_LIST)");
- push (@{$lib->{LINK_FLAGS}}, "\$($mod->{TYPE}_$mod->{NAME}_LINK_FLAGS)");
- push (@{$lib->{CFLAGS}}, @{$mod->{CFLAGS}}) if defined($mod->{CFLAGS});
- push (@{$lib->{PUBLIC_DEPENDENCIES}}, @{$mod->{PUBLIC_DEPENDENCIES}}) if defined($mod->{PUBLIC_DEPENDENCIES});
- push (@{$lib->{PRIVATE_DEPENDENCIES}}, @{$mod->{PRIVATE_DEPENDENCIES}}) if defined($mod->{PRIVATE_DEPENDENCIES});
-
- $mod->{ENABLE} = "NO";
- }
+ my ($INPUT, $n) = @_;
+
+ $INPUT->{$n} = {
+ TYPE => "MAKE_RULE",
+ NAME => $n,
+ TARGET => "",
+ OUTPUT_TYPE => undef,
+ LIBS => ["\$(".uc($n)."_LIBS)"],
+ LDFLAGS => ["\$(".uc($n)."_LDFLAGS)"],
+ CFLAGS => ["\$(".uc($n)."_CFLAGS)"],
+ CPPFLAGS => ["\$(".uc($n)."_CPPFLAGS)"]
+ };
}
sub calc_unique_deps($$$$$$$$)
@@ -224,16 +204,19 @@ sub calc_unique_deps($$$$$$$$)
my ($name, $INPUT, $deps, $udeps, $withlibs, $forward, $pubonly, $busy) = @_;
foreach my $n (@$deps) {
- die("Dependency unknown: $n (for $name)") unless (defined($INPUT->{$n}));
- die("Recursive dependency: $n, list: " . join(',', @$busy)) if (grep (/^$n$/, @$busy));
- next if (grep /^$n$/, @$udeps);
+ add_implicit($INPUT, $n) unless (defined($INPUT->{$n}));
my $dep = $INPUT->{$n};
+ if (grep (/^$n$/, @$busy)) {
+ next if (@{$dep->{OUTPUT_TYPE}}[0] eq "MERGED_OBJ");
+ die("Recursive dependency: $n, list: " . join(',', @$busy));
+ }
+ next if (grep /^$n$/, @$udeps);
push (@{$udeps}, $dep->{NAME}) if $forward;
if (defined ($dep->{OUTPUT_TYPE}) &&
($withlibs or
- (@{$dep->{OUTPUT_TYPE}}[0] eq "INTEGRATED") or
+ (@{$dep->{OUTPUT_TYPE}}[0] eq "MERGED_OBJ") or
(@{$dep->{OUTPUT_TYPE}}[0] eq "STATIC_LIBRARY"))) {
push (@$busy, $dep->{NAME});
calc_unique_deps($dep->{NAME}, $INPUT, $dep->{PUBLIC_DEPENDENCIES}, $udeps, $withlibs, $forward, $pubonly, $busy);
@@ -280,11 +263,9 @@ sub check($$$$$)
}
}
- foreach my $k (keys %$INPUT) {
- my $part = $INPUT->{$k};
-
+ foreach my $part (values %$INPUT) {
$part->{LINK_FLAGS} = [];
- $part->{FULL_OBJ_LIST} = ["\$($part->{TYPE}_$part->{NAME}_OBJ_LIST)"];
+ $part->{FULL_OBJ_LIST} = ["\$($part->{NAME}_OBJ_LIST)"];
if ($part->{TYPE} eq "SUBSYSTEM") {
check_subsystem($INPUT, $part, $subsys_ot);
@@ -306,7 +287,6 @@ sub check($$$$$)
if (defined($part->{INIT_FUNCTIONS})) {
push (@{$part->{LINK_FLAGS}}, "\$(DYNEXP)");
}
- import_integrated($part, $INPUT);
}
foreach my $part (values %$INPUT) {
diff --git a/source4/build/smb_build/main.pl b/source4/build/smb_build/main.pl
index fb769103d0..3ed0327d6d 100644
--- a/source4/build/smb_build/main.pl
+++ b/source4/build/smb_build/main.pl
@@ -19,8 +19,7 @@ use strict;
my $INPUT = {};
my $mkfile = smb_build::config_mk::run_config_mk($INPUT, $config::config{srcdir}, $config::config{builddir}, "main.mk");
-my $subsys_output_type;
-$subsys_output_type = ["STATIC_LIBRARY"];
+my $subsys_output_type = ["MERGED_OBJ"];
my $library_output_type;
if ($config::config{USESHARED} eq "true") {
@@ -35,7 +34,7 @@ my $module_output_type;
if ($config::config{USESHARED} eq "true") {
$module_output_type = ["SHARED_LIBRARY"];
} else {
- $module_output_type = ["INTEGRATED"];
+ $module_output_type = ["MERGED_OBJ"];
}
my $DEPEND = smb_build::input::check($INPUT, \%config::enabled,
@@ -43,36 +42,31 @@ my $DEPEND = smb_build::input::check($INPUT, \%config::enabled,
$library_output_type,
$module_output_type);
my $OUTPUT = output::create_output($DEPEND, \%config::config);
-$config::config{SUBSYSTEM_OUTPUT_TYPE} = $subsys_output_type;
-$config::config{LIBRARY_OUTPUT_TYPE} = $library_output_type;
-$config::config{MODULE_OUTPUT_TYPE} = $module_output_type;
my $mkenv = new smb_build::makefile(\%config::config, $mkfile);
+my $shared_libs_used = 0;
foreach my $key (values %$OUTPUT) {
- next unless defined $key->{OUTPUT_TYPE};
-
- $mkenv->Integrated($key) if grep(/INTEGRATED/, @{$key->{OUTPUT_TYPE}});
+ $mkenv->_prepare_list($key, "OBJ_LIST");
+ push(@{$mkenv->{all_objs}}, "\$($key->{NAME}_OBJ_LIST)");
}
-my $shared_libs_used = 0;
-
foreach my $key (values %$OUTPUT) {
next unless defined $key->{OUTPUT_TYPE};
+ $mkenv->MergedObj($key) if grep(/MERGED_OBJ/, @{$key->{OUTPUT_TYPE}});
$mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$key->{OUTPUT_TYPE}});
if (defined($key->{PC_FILE})) {
push(@{$mkenv->{pc_files}}, "$key->{BASEDIR}/$key->{PC_FILE}");
}
- $mkenv->SharedLibrary($key) if ($key->{TYPE} eq "LIBRARY") and
+ $mkenv->SharedLibraryPrimitives($key) if ($key->{TYPE} eq "LIBRARY") and
grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
if ($key->{TYPE} eq "LIBRARY" and
${$key->{OUTPUT_TYPE}}[0] eq "SHARED_LIBRARY") {
$shared_libs_used = 1;
}
- $mkenv->SharedModule($key) if ($key->{TYPE} eq "MODULE" or
+ $mkenv->SharedModulePrimitives($key) if ($key->{TYPE} eq "MODULE" or
$key->{TYPE} eq "PYTHON") and
grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
- $mkenv->Binary($key) if grep(/BINARY/, @{$key->{OUTPUT_TYPE}});
$mkenv->PythonFiles($key) if defined($key->{PYTHON_FILES});
$mkenv->Manpage($key) if defined($key->{MANPAGE});
$mkenv->Header($key) if defined($key->{PUBLIC_HEADERS});
@@ -80,7 +74,18 @@ foreach my $key (values %$OUTPUT) {
defined($key->{PUBLIC_PROTO_HEADER});
}
-$mkenv->write("Makefile");
+foreach my $key (values %$OUTPUT) {
+ next unless defined $key->{OUTPUT_TYPE};
+
+ $mkenv->SharedLibrary($key) if ($key->{TYPE} eq "LIBRARY") and
+ grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
+ $mkenv->SharedModule($key) if ($key->{TYPE} eq "MODULE" or
+ $key->{TYPE} eq "PYTHON") and
+ grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
+ $mkenv->Binary($key) if grep(/BINARY/, @{$key->{OUTPUT_TYPE}});
+}
+
+$mkenv->write("data.mk");
header::create_smb_build_h($OUTPUT, "include/build.h");
cflags::create_cflags($OUTPUT, $config::config{srcdir},
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm
index 452e4254a3..17474db00e 100644
--- a/source4/build/smb_build/makefile.pm
+++ b/source4/build/smb_build/makefile.pm
@@ -24,35 +24,23 @@ sub new($$$)
$self->{manpages} = [];
$self->{sbin_progs} = [];
$self->{bin_progs} = [];
- $self->{torture_progs} = [];
$self->{static_libs} = [];
$self->{python_dsos} = [];
$self->{python_pys} = [];
$self->{shared_libs} = [];
- $self->{installable_shared_libs} = [];
$self->{headers} = [];
- $self->{shared_modules} = [];
$self->{plugins} = [];
- $self->{install_plugins} = "";
- $self->{uninstall_plugins} = "";
$self->{pc_files} = [];
$self->{proto_headers} = [];
$self->{output} = "";
$self->{mkfile} = $mkfile;
- $self->output("#!gmake\n");
$self->output("################################################\n");
$self->output("# Autogenerated by build/smb_build/makefile.pm #\n");
$self->output("################################################\n");
$self->output("\n");
- $self->output("default: all\n\n");
-
- $self->_prepare_path_vars();
- $self->_prepare_suffix_rules();
- $self->_prepare_compiler_linker();
-
if (!$self->{automatic_deps}) {
$self->output("ALL_PREDEP = proto\n");
$self->output(".NOTPARALLEL:\n");
@@ -68,173 +56,6 @@ sub output($$)
$self->{output} .= $text;
}
-sub _prepare_path_vars($)
-{
- my ($self) = @_;
-
- $self->output(<< "__EOD__"
-prefix = $self->{config}->{prefix}
-exec_prefix = $self->{config}->{exec_prefix}
-selftest_prefix = $self->{config}->{selftest_prefix}
-
-builddir = $self->{config}->{builddir}
-srcdir = $self->{config}->{srcdir}
-datarootdir = $self->{config}->{datarootdir}
-
-VPATH = \$(builddir):\$(srcdir):heimdal_build:heimdal/lib/asn1:heimdal/lib/krb5:heimdal/lib/gssapi:heimdal/lib/hdb:heimdal/lib/roken:heimdal/lib/des
-
-BASEDIR = $self->{config}->{prefix}
-BINDIR = $self->{config}->{bindir}
-SBINDIR = $self->{config}->{sbindir}
-LIBDIR = $self->{config}->{libdir}
-TORTUREDIR = $self->{config}->{libdir}/torture
-MODULESDIR = $self->{config}->{modulesdir}
-INCLUDEDIR = $self->{config}->{includedir}
-CONFIGDIR = $self->{config}->{sysconfdir}
-DATADIR = $self->{config}->{datadir}
-SWATDIR = \$(DATADIR)/swat
-JSDIR = \$(DATADIR)/js
-SETUPDIR = \$(DATADIR)/setup
-VARDIR = $self->{config}->{localstatedir}
-LOGFILEBASE = $self->{config}->{logfilebase}
-NCALRPCDIR = $self->{config}->{localstatedir}/ncalrpc
-LOCKDIR = $self->{config}->{lockdir}
-PIDDIR = $self->{config}->{piddir}
-MANDIR = $self->{config}->{mandir}
-PRIVATEDIR = $self->{config}->{privatedir}
-WINBINDD_SOCKET_DIR = $self->{config}->{winbindd_socket_dir}
-
-__EOD__
-);
-}
-
-sub _prepare_suffix_rules($)
-{
- my ($self) = @_;
- my $first_prereq = '$*.c';
-
- if ($self->{config}->{GNU_MAKE} eq 'yes') {
- $first_prereq = '$<';
- }
-
- $self->output(<< "__EOD__"
-FIRST_PREREQ = $first_prereq
-
-# Dependencies command
-DEPENDS = \$(CC) -M -MG -MP -MT \$(<:.c=.o) -MT \$@ \\
- \$(CFLAGS) `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
- \$(CPPFLAGS) \$(FIRST_PREREQ) -o \$@
-# Dependencies for host objects
-HDEPENDS = \$(CC) -M -MG -MP -MT \$(<:.c=.ho) -MT \$@ \\
- \$(HOSTCC_FLAGS) `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
- \$(CPPFLAGS) \$(FIRST_PREREQ) -o \$@
-# Dependencies for precompiled headers
-PCHDEPENDS = \$(CC) -M -MG -MT include/includes.h.gch -MT \$@ \\
- \$(CFLAGS) \$(CPPFLAGS) \$(FIRST_PREREQ) -o \$@
-
-# \$< is broken in older BSD versions:
-# when \$@ is foo/bar.o, \$< could be torture/foo/bar.c
-# if it also exists. So better use \$* which is foo/bar
-# and append .c manually to get foo/bar.c
-#
-# If we have GNU Make, it is safe to use \$<, which also lets
-# building with \$srcdir != \$builddir work.
-
-# Run a static analysis checker
-CHECK = \$(CC_CHECKER) \$(CFLAGS) `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
- \$(PICFLAG) \$(CPPLAGS) -c \$(FIRST_PREREQ) -o \$@
-
-# Run the configured compiler
-COMPILE = \$(CC) \$(CFLAGS) \$(PICFLAG) \\
- `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
- \$(CPPFLAGS) \\
- -c \$(FIRST_PREREQ) -o \$@
-
-# Run the compiler for the build host
-HCOMPILE = \$(HOSTCC) \$(HOSTCC_FLAGS) `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
- \$(CPPFLAGS) -c \$(FIRST_PREREQ) -o \$@
-
-# Precompile headers
-PCHCOMPILE = @\$(CC) -Ilib/replace \\
- \$(CFLAGS) `\$(PERL) \$(srcdir)/script/cflags.pl \$@` \\
- \$(PICFLAG) \$(CPPFLAGS) -c \$(FIRST_PREREQ) -o \$@
-
-__EOD__
-);
-}
-
-sub _prepare_compiler_linker($)
-{
- my ($self) = @_;
-
- my $builddir_headers = "";
- my $libdir;
- my $extra_link_flags = "";
-
- if ($self->{config}->{USESHARED} eq "true") {
- $libdir = "\$(builddir)/bin/shared";
- $extra_link_flags = "-Wl,-rpath-link,\$(builddir)/bin/shared";
- } else {
- $libdir = "\$(builddir)/bin/static";
- }
-
- if (!(abs_path($self->{config}->{srcdir}) eq abs_path($self->{config}->{builddir}))) {
- $builddir_headers= "-I\$(builddir)/include -I\$(builddir) -I\$(builddir)/lib ";
- }
-
- $self->output(<< "__EOD__"
-SHELL=$self->{config}->{SHELL}
-
-PERL=$self->{config}->{PERL}
-PYTHON=$self->{config}->{PYTHON}
-SWIG=$self->{config}->{SWIG}
-
-CPP=$self->{config}->{CPP}
-CPPFLAGS=$builddir_headers-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -I\$(srcdir)/lib/replace -I\$(srcdir)/lib/talloc -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H $self->{config}->{CPPFLAGS}
-
-CC=$self->{config}->{CC}
-CFLAGS=$self->{config}->{CFLAGS}
-CFLAG_NO_UNUSED_MACROS=$self->{config}->{CFLAG_NO_UNUSED_MACROS}
-PICFLAG=$self->{config}->{PICFLAG}
-
-INSTALL_LINK_FLAGS=$extra_link_flags
-
-BNLD=$self->{config}->{LD}
-BNLD_FLAGS=$self->{config}->{LDFLAGS} -L$libdir
-
-STLD=$self->{config}->{STLD}
-STLD_FLAGS=$self->{config}->{STLD_FLAGS}
-
-SHLD=$self->{config}->{SHLD}
-SHLD_FLAGS=$self->{config}->{SHLD_FLAGS} -L\$(builddir)/bin/shared
-
-MDLD=$self->{config}->{MDLD}
-MDLD_FLAGS=$self->{config}->{MDLD_FLAGS} -L\$(builddir)/bin/shared
-
-SHLIBEXT=$self->{config}->{SHLIBEXT}
-
-HOSTCC=$self->{config}->{HOSTCC}
-HOSTCC_FLAGS=-D_SAMBA_HOSTCC_ \$(CFLAGS)
-
-HOSTLD=$self->{config}->{HOSTLD}
-HOSTLD_FLAGS=$self->{config}->{LDFLAGS}
-
-XSLTPROC=$self->{config}->{XSLTPROC}
-
-LIB_PATH_VAR=$self->{config}->{LIB_PATH_VAR}
-
-LEX=$self->{config}->{LEX}
-YACC=$self->{config}->{YACC}
-YAPP=$self->{config}->{YAPP}
-
-GCOV=$self->{config}->{GCOV}
-
-DEFAULT_TEST_OPTIONS=$self->{config}->{DEFAULT_TEST_OPTIONS}
-
-__EOD__
-);
-}
-
sub _prepare_mk_files($)
{
my $self = shift;
@@ -278,35 +99,24 @@ sub array2oneperline($)
return $output;
}
-sub _prepare_list_ex($$$$$)
+sub _prepare_list($$$)
{
- my ($self,$ctx,$var,$pre,$post) = @_;
+ my ($self,$ctx,$var) = @_;
my @tmparr = ();
- push(@tmparr, $pre) if defined($pre);
push(@tmparr, @{$ctx->{$var}}) if defined($ctx->{$var});
- push(@tmparr, $post) if defined($post);
my $tmplist = array2oneperline(\@tmparr);
return if ($tmplist eq "");
- $self->output("$ctx->{TYPE}\_$ctx->{NAME}_$var =$tmplist\n");
+ $self->output("$ctx->{NAME}_$var =$tmplist\n");
}
-sub _prepare_list($$$)
-{
- my ($self,$ctx,$var) = @_;
-
- $self->_prepare_list_ex($ctx, $var, undef, undef);
-}
-
-sub Integrated($$)
+sub SharedModulePrimitives($$)
{
my ($self,$ctx) = @_;
-
- $self->_prepare_list($ctx, "OBJ_LIST");
- $self->_prepare_list($ctx, "FULL_OBJ_LIST");
- $self->_prepare_list($ctx, "LINK_FLAGS");
+
+ #FIXME
}
sub SharedModule($$)
@@ -322,31 +132,36 @@ sub SharedModule($$)
push (@{$self->{python_dsos}},
"$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}");
} else {
- push (@{$self->{shared_modules}}, "$ctx->{TARGET_SHARED_LIBRARY}");
push (@{$self->{plugins}}, "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}");
- $self->{install_plugins} .= "\t\@echo Installing $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} as \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n";
- $self->{install_plugins} .= "\t\@mkdir -p \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/\n";
- $self->{install_plugins} .= "\t\@cp $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n";
- $self->{uninstall_plugins} .= "\t\@echo Uninstalling \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n";
- $self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n";
+ $self->output("installplugins:: $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
+ $self->output("\t\@echo Installing $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} as \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n");
+ $self->output("\t\@mkdir -p \$(DESTDIR)\$(modulesdir)/$sane_subsystem/\n");
+ $self->output("\t\@cp $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n");
if (defined($ctx->{ALIASES})) {
foreach (@{$ctx->{ALIASES}}) {
- $self->{install_plugins} .= "\t\@rm -f \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$_.\$(SHLIBEXT)\n";
- $self->{install_plugins} .= "\t\@ln -fs $ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$_.\$(SHLIBEXT)\n";
- $self->{uninstall_plugins} .= "\t\@-rm \$(DESTDIR)\$(MODULESDIR)/$sane_subsystem/$_.\$(SHLIBEXT)\n";
+ $self->output("\t\@rm -f \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$_.\$(SHLIBEXT)\n");
+ $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$_.\$(SHLIBEXT)\n");
+ }
+ }
+
+ $self->output("uninstallplugins::\n");
+ $self->output("\t\@echo Uninstalling \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n");
+ $self->output("\t\@-rm \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$ctx->{LIBRARY_REALNAME}\n");
+
+ if (defined($ctx->{ALIASES})) {
+ foreach (@{$ctx->{ALIASES}}) {
+ $self->output("\t\@-rm \$(DESTDIR)\$(modulesdir)/$sane_subsystem/$_.\$(SHLIBEXT)\n");
}
}
}
- $self->output("$ctx->{TYPE}_$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
- $self->_prepare_list($ctx, "OBJ_LIST");
+ $self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
$self->_prepare_list($ctx, "FULL_OBJ_LIST");
$self->_prepare_list($ctx, "DEPEND_LIST");
$self->_prepare_list($ctx, "LINK_FLAGS");
- push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
-
- if (defined($ctx->{INIT_FUNCTION}) and $ctx->{TYPE} ne "PYTHON") {
+ if (defined($ctx->{INIT_FUNCTION}) and $ctx->{TYPE} ne "PYTHON" and
+ $ctx->{INIT_FUNCTION_TYPE} =~ /\(\*\)/) {
my $init_fn = $ctx->{INIT_FUNCTION_TYPE};
$init_fn =~ s/\(\*\)/init_module/;
my $proto_fn = $ctx->{INIT_FUNCTION_TYPE};
@@ -370,12 +185,12 @@ __EOD__
$self->output(<< "__EOD__"
#
-$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST) $init_obj
+$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST) $init_obj
\@echo Linking \$\@
\@mkdir -p $ctx->{SHAREDDIR}
- \@\$(MDLD) \$(MDLD_FLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
- \$($ctx->{TYPE}_$ctx->{NAME}\_FULL_OBJ_LIST) $init_obj \\
- \$($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS)
+ \@\$(MDLD) \$(LDFLAGS) \$(MDLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
+ \$($ctx->{NAME}\_FULL_OBJ_LIST) $init_obj \\
+ \$($ctx->{NAME}_LINK_FLAGS)
__EOD__
);
@@ -388,79 +203,91 @@ __EOD__
$self->output("\n");
}
-sub SharedLibrary($$)
+sub SharedLibraryPrimitives($$)
{
my ($self,$ctx) = @_;
- my $has_static_lib = 0;
-
- push (@{$self->{shared_libs}}, "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}") if (defined($ctx->{SO_VERSION}));
- push (@{$self->{installable_shared_libs}}, "$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}") if (defined($ctx->{SO_VERSION}));
-
- $has_static_lib = 1 if grep(/STATIC_LIBRARY/, @{$ctx->{OUTPUT_TYPE}});
+ $self->output("$ctx->{NAME}_SOVERSION = $ctx->{SO_VERSION}\n") if (defined($ctx->{SO_VERSION}));
+ $self->output("$ctx->{NAME}_VERSION = $ctx->{VERSION}\n") if (defined($ctx->{VERSION}));
- if (not $has_static_lib) {
- $self->output("$ctx->{TYPE}_$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
- $self->_prepare_list($ctx, "OBJ_LIST");
+ if (not grep(/STATIC_LIBRARY/, @{$ctx->{OUTPUT_TYPE}})) {
+ $self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
$self->_prepare_list($ctx, "FULL_OBJ_LIST");
}
+}
+
+sub SharedLibrary($$)
+{
+ my ($self,$ctx) = @_;
+
+ push (@{$self->{shared_libs}}, $ctx->{RESULT_SHARED_LIBRARY}) if (defined($ctx->{SO_VERSION}));
+
$self->_prepare_list($ctx, "DEPEND_LIST");
$self->_prepare_list($ctx, "LINK_FLAGS");
-# $self->_prepare_list_ex($ctx, "LINK_FLAGS", "-Wl,--whole-archive", "-Wl,--no-whole-archive");
-
- push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
my $soarg = "";
my $lns = "";
if ($self->{config}->{SONAMEFLAG} ne "#" and defined($ctx->{LIBRARY_SONAME})) {
$soarg = "$self->{config}->{SONAMEFLAG}$ctx->{LIBRARY_SONAME}";
if ($ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) {
- $lns .= "\n\t\@rm -f $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}";
- $lns .= "\n\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}";
+ $lns .= "\n\t\@test \$($ctx->{NAME}_VERSION) = \$($ctx->{NAME}_SOVERSION) || ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}";
}
}
if (defined($ctx->{LIBRARY_SONAME})) {
- $lns .= "\n\t\@rm -f $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}";
$lns .= "\n\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}";
}
$self->output(<< "__EOD__"
#
-
-$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
+$ctx->{RESULT_SHARED_LIBRARY}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST)
\@echo Linking \$\@
\@mkdir -p $ctx->{SHAREDDIR}
- \@\$(SHLD) \$(SHLD_FLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
- \$($ctx->{TYPE}_$ctx->{NAME}\_FULL_OBJ_LIST) \\
- \$($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS) \\
+ \@\$(SHLD) \$(LDFLAGS) \$(SHLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
+ \$($ctx->{NAME}\_FULL_OBJ_LIST) \\
+ \$($ctx->{NAME}_LINK_FLAGS) \\
$soarg$lns
__EOD__
);
$self->output("\n");
}
+sub MergedObj($$)
+{
+ my ($self, $ctx) = @_;
+
+ return unless defined($ctx->{OUTPUT});
+
+ $self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
+ $self->output(<< "__EOD__"
+#
+$ctx->{RESULT_MERGED_OBJ}: \$($ctx->{NAME}_OBJ_LIST)
+ \@echo Partially linking \$@
+ \@mkdir -p bin/mergedobj
+ \$(PARTLINK) -o \$@ \$($ctx->{NAME}_OBJ_LIST)
+
+__EOD__
+);
+}
+
sub StaticLibrary($$)
{
my ($self,$ctx) = @_;
return unless (defined($ctx->{OBJ_FILES}));
- push (@{$self->{static_libs}}, $ctx->{TARGET_STATIC_LIBRARY}) if ($ctx->{TYPE} eq "LIBRARY");
+ push (@{$self->{static_libs}}, $ctx->{RESULT_STATIC_LIBRARY}) if ($ctx->{TYPE} eq "LIBRARY");
- $self->output("$ctx->{TYPE}_$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
- $self->_prepare_list($ctx, "OBJ_LIST");
+ $self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
$self->_prepare_list($ctx, "FULL_OBJ_LIST");
- push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
-
$self->output(<< "__EOD__"
#
-$ctx->{TARGET_STATIC_LIBRARY}: \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
+$ctx->{RESULT_STATIC_LIBRARY}: \$($ctx->{NAME}_FULL_OBJ_LIST)
\@echo Linking \$@
\@rm -f \$@
\@mkdir -p $ctx->{STATICDIR}
- \@\$(STLD) \$(STLD_FLAGS) \$@ \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
+ \@\$(STLD) \$(STLD_FLAGS) \$@ \$($ctx->{NAME}_FULL_OBJ_LIST)
__EOD__
);
@@ -479,51 +306,37 @@ sub Binary($$)
{
my ($self,$ctx) = @_;
- my $installdir;
my $extradir = "";
- if (defined($ctx->{INSTALLDIR}) && $ctx->{INSTALLDIR} =~ /^TORTUREDIR/) {
- $extradir = "/torture" . substr($ctx->{INSTALLDIR}, length("TORTUREDIR"));
- }
- my $localdir = "bin$extradir";
-
- $installdir = "bin$extradir";
-
- push(@{$self->{all_objs}}, "\$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)");
-
unless (defined($ctx->{INSTALLDIR})) {
} elsif ($ctx->{INSTALLDIR} eq "SBINDIR") {
- push (@{$self->{sbin_progs}}, "$installdir/$ctx->{BINARY}");
+ push (@{$self->{sbin_progs}}, $ctx->{RESULT_BINARY});
} elsif ($ctx->{INSTALLDIR} eq "BINDIR") {
- push (@{$self->{bin_progs}}, "$installdir/$ctx->{BINARY}");
- } elsif ($ctx->{INSTALLDIR} =~ /^TORTUREDIR/) {
- push (@{$self->{torture_progs}}, "$installdir/$ctx->{BINARY}");
+ push (@{$self->{bin_progs}}, $ctx->{RESULT_BINARY});
}
+ $self->output("binaries:: $ctx->{TARGET_BINARY}\n");
- push (@{$self->{binaries}}, "$localdir/$ctx->{BINARY}");
-
- $self->_prepare_list($ctx, "OBJ_LIST");
$self->_prepare_list($ctx, "FULL_OBJ_LIST");
$self->_prepare_list($ctx, "DEPEND_LIST");
$self->_prepare_list($ctx, "LINK_FLAGS");
$self->output(<< "__EOD__"
-$installdir/$ctx->{BINARY}: \$($ctx->{TYPE}_$ctx->{NAME}_DEPEND_LIST) \$($ctx->{TYPE}_$ctx->{NAME}_FULL_OBJ_LIST)
+$ctx->{RESULT_BINARY}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST)
\@echo Linking \$\@
__EOD__
);
if (defined($ctx->{USE_HOSTCC}) && $ctx->{USE_HOSTCC} eq "YES") {
$self->output(<< "__EOD__"
- \@\$(HOSTLD) \$(HOSTLD_FLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
- \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS)
+ \@\$(HOSTLD) \$(HOSTLD_FLAGS) -L\${builddir}/bin/static -o \$\@ \$(INSTALL_LINK_FLAGS) \\
+ \$\($ctx->{NAME}_LINK_FLAGS)
__EOD__
);
} else {
$self->output(<< "__EOD__"
- \@\$(BNLD) \$(BNLD_FLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
- \$\($ctx->{TYPE}_$ctx->{NAME}_LINK_FLAGS)
+ \@\$(BNLD) \$(BNLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
+ \$\($ctx->{NAME}_LINK_FLAGS)
__EOD__
);
@@ -586,35 +399,28 @@ sub ProtoHeader($$)
$pub = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PUBLIC_PROTO_HEADER});
}
- $self->output("$pub: $ctx->{MK_FILE} \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST:.o=.c) \$(srcdir)/script/mkproto.pl\n");
+ $self->output("$pub: $ctx->{MK_FILE} \$($ctx->{NAME}_OBJ_LIST:.o=.c) \$(srcdir)/script/mkproto.pl\n");
$self->output("\t\@echo \"$comment\"\n");
- $self->output("\t\@\$(PERL) \$(srcdir)/script/mkproto.pl --srcdir=\$(srcdir) --builddir=\$(builddir) --private=$priv --public=$pub \$($ctx->{TYPE}_$ctx->{NAME}_OBJ_LIST)\n\n");
+ $self->output("\t\@\$(PERL) \$(srcdir)/script/mkproto.pl --srcdir=\$(srcdir) --builddir=\$(builddir) --private=$priv --public=$pub \$($ctx->{NAME}_OBJ_LIST)\n\n");
}
sub write($$)
{
- my ($self,$file) = @_;
+ my ($self, $file) = @_;
- $self->output("MANPAGES = ".array2oneperline($self->{manpages})."\n");
+ $self->output("MANPAGES = " . array2oneperline($self->{manpages})."\n");
$self->output("BIN_PROGS = " . array2oneperline($self->{bin_progs}) . "\n");
$self->output("SBIN_PROGS = " . array2oneperline($self->{sbin_progs}) . "\n");
- $self->output("TORTURE_PROGS = " . array2oneperline($self->{torture_progs}) . "\n");
- $self->output("BINARIES = " . array2oneperline($self->{binaries}) . "\n");
$self->output("STATIC_LIBS = " . array2oneperline($self->{static_libs}) . "\n");
$self->output("SHARED_LIBS = " . array2oneperline($self->{shared_libs}) . "\n");
$self->output("PYTHON_DSOS = " . array2oneperline($self->{python_dsos}) . "\n");
$self->output("PYTHON_PYS = " . array2oneperline($self->{python_pys}) . "\n");
- $self->output("INSTALLABLE_SHARED_LIBS = " . array2oneperline($self->{installable_shared_libs}) . "\n");
$self->output("PUBLIC_HEADERS = " . array2oneperline($self->{headers}) . "\n");
$self->output("PC_FILES = " . array2oneperline($self->{pc_files}) . "\n");
$self->output("ALL_OBJS = " . array2oneperline($self->{all_objs}) . "\n");
$self->output("PROTO_HEADERS = " . array2oneperline($self->{proto_headers}) . "\n");
- $self->output("SHARED_MODULES = " . array2oneperline($self->{shared_modules}) . "\n");
$self->output("PLUGINS = " . array2oneperline($self->{plugins}) . "\n");
- $self->output("\ninstallplugins: \$(PLUGINS)\n".$self->{install_plugins}."\n");
- $self->output("\nuninstallplugins:\n".$self->{uninstall_plugins}."\n");
-
$self->_prepare_mk_files();
$self->output($self->{mkfile});
diff --git a/source4/build/smb_build/output.pm b/source4/build/smb_build/output.pm
index fbf14f7e91..ff9afe8e8c 100644
--- a/source4/build/smb_build/output.pm
+++ b/source4/build/smb_build/output.pm
@@ -81,12 +81,30 @@ sub generate_shared_library($)
$lib->{LIBRARY_DEBUGNAME} = $lib->{LIBRARY_REALNAME};
if (defined($lib->{VERSION}) and $config::config{SONAMEFLAG} ne "#") {
- $lib->{LIBRARY_SONAME} = "$lib->{LIBRARY_REALNAME}.$lib->{SO_VERSION}";
- $lib->{LIBRARY_REALNAME} = "$lib->{LIBRARY_REALNAME}.$lib->{VERSION}";
+ $lib->{LIBRARY_SONAME} = "$lib->{LIBRARY_REALNAME}.\$($lib->{NAME}_SOVERSION)";
+ $lib->{LIBRARY_REALNAME} = "$lib->{LIBRARY_REALNAME}.\$($lib->{NAME}_VERSION)";
}
- $lib->{TARGET_SHARED_LIBRARY} = "$lib->{SHAREDDIR}/$lib->{LIBRARY_REALNAME}";
- $lib->{OUTPUT_SHARED_LIBRARY} = $lib->{TARGET_SHARED_LIBRARY};
+ $lib->{RESULT_SHARED_LIBRARY} = "$lib->{SHAREDDIR}/$lib->{LIBRARY_REALNAME}";
+ $lib->{OUTPUT_SHARED_LIBRARY} = "-l$link_name";
+ $lib->{TARGET_SHARED_LIBRARY} = $lib->{RESULT_SHARED_LIBRARY};
+}
+
+sub generate_merged_obj($)
+{
+ my $lib = shift;
+
+ my $link_name = $lib->{NAME};
+ $link_name =~ s/^LIB//;
+
+ if (defined($lib->{OBJ_FILES})) {
+ $lib->{MERGED_OBJNAME} = lc($link_name).".o";
+ $lib->{RESULT_MERGED_OBJ} = $lib->{OUTPUT_MERGED_OBJ} = "bin/mergedobj/$lib->{MERGED_OBJNAME}";
+ $lib->{TARGET_MERGED_OBJ} = $lib->{RESULT_MERGED_OBJ};
+ } else {
+ $lib->{TARGET_MERGED_OBJ} = "";
+ $lib->{RESULT_MERGED_OBJ} = "";
+ }
}
sub generate_static_library($)
@@ -102,12 +120,15 @@ sub generate_static_library($)
$lib->{LIBRARY_NAME} = "lib".lc($link_name).".a";
if (defined($lib->{OBJ_FILES})) {
- $lib->{TARGET_STATIC_LIBRARY} = "bin/static/$lib->{LIBRARY_NAME}";
+ $lib->{RESULT_STATIC_LIBRARY} = "bin/static/$lib->{LIBRARY_NAME}";
+ $lib->{TARGET_STATIC_LIBRARY} = $lib->{RESULT_STATIC_LIBRARY};
$lib->{STATICDIR} = 'bin/static';
+ $lib->{OUTPUT_STATIC_LIBRARY} = "-l".lc($link_name);
} else {
+ $lib->{RESULT_STATIC_LIBRARY} = "";
$lib->{TARGET_STATIC_LIBRARY} = "";
+ $lib->{OUTPUT_STATIC_LIBRARY} = "";
}
- $lib->{OUTPUT_STATIC_LIBRARY} = $lib->{TARGET_STATIC_LIBRARY};
}
sub generate_binary($)
@@ -115,10 +136,11 @@ sub generate_binary($)
my $bin = shift;
$bin->{DEPEND_LIST} = [];
- push(@{$bin->{LINK_FLAGS}}, "\$($bin->{TYPE}_$bin->{NAME}\_OBJ_LIST)");
+ push(@{$bin->{LINK_FLAGS}}, "\$($bin->{NAME}\_FULL_OBJ_LIST)");
- $bin->{DEBUGDIR} = "bin/";
- $bin->{TARGET_BINARY} = $bin->{OUTPUT_BINARY} = "$bin->{DEBUGDIR}/$bin->{NAME}";
+ $bin->{DEBUGDIR} = "bin";
+ $bin->{RESULT_BINARY} = $bin->{OUTPUT_BINARY} = "$bin->{DEBUGDIR}/$bin->{NAME}";
+ $bin->{TARGET_BINARY} = $bin->{RESULT_BINARY};
$bin->{BINARY} = $bin->{NAME};
}
@@ -152,6 +174,7 @@ sub create_output($$)
generate_binary($part) if grep(/BINARY/, @{$part->{OUTPUT_TYPE}});
generate_shared_library($part) if grep(/SHARED_LIBRARY/, @{$part->{OUTPUT_TYPE}});
generate_static_library($part) if grep(/STATIC_LIBRARY/, @{$part->{OUTPUT_TYPE}});
+ generate_merged_obj($part) if grep(/MERGED_OBJ/, @{$part->{OUTPUT_TYPE}});
$part->{OUTPUT} = $part->{"OUTPUT_" . @{$part->{OUTPUT_TYPE}}[0]};
$part->{TARGET} = $part->{"TARGET_" . @{$part->{OUTPUT_TYPE}}[0]};
}
@@ -162,7 +185,7 @@ sub create_output($$)
merge_array(\$part->{FINAL_CFLAGS}, $part->{CPPFLAGS});
merge_array(\$part->{FINAL_CFLAGS}, $part->{CFLAGS});
- foreach (@{$part->{UNIQUE_DEPENDENCIES_COMPILE}}) {
+ foreach (@{$part->{UNIQUE_DEPENDENCIES_ALL}}) {
my $elem = $depend->{$_};
next if $elem == $part;
@@ -175,15 +198,19 @@ sub create_output($$)
my $elem = $depend->{$_};
next if $elem == $part;
- push(@{$part->{LINK_FLAGS}}, $elem->{OUTPUT}) if defined($elem->{OUTPUT});
push(@{$part->{LINK_FLAGS}}, @{$elem->{LIBS}}) if defined($elem->{LIBS});
- push(@{$part->{LINK_FLAGS}},@{$elem->{LDFLAGS}}) if defined($elem->{LDFLAGS});
- push(@{$part->{DEPEND_LIST}}, $elem->{TARGET}) if defined($elem->{TARGET});
+ push(@{$part->{LINK_FLAGS}}, @{$elem->{LDFLAGS}}) if defined($elem->{LDFLAGS});
+ if (defined($elem->{OUTPUT_TYPE}) and @{$elem->{OUTPUT_TYPE}}[0] eq "MERGED_OBJ") {
+ push (@{$part->{FULL_OBJ_LIST}}, $elem->{TARGET});
+ } else {
+ push(@{$part->{LINK_FLAGS}}, "\$($elem->{NAME}_OUTPUT)") if defined($elem->{OUTPUT});
+ push(@{$part->{DEPEND_LIST}}, $elem->{TARGET}) if defined($elem->{TARGET});
+ }
}
}
foreach $part (values %{$depend}) {
- if (($part->{STANDARD_VISIBILITY} ne "default") and
+ if (defined($part->{STANDARD_VISIBILITY}) and ($part->{STANDARD_VISIBILITY} ne "default") and
($config->{visibility_attribute} eq "yes")) {
push(@{$part->{FINAL_CFLAGS}}, "-fvisibility=$part->{STANDARD_VISIBILITY}");
}
diff --git a/source4/build/smb_build/summary.pm b/source4/build/smb_build/summary.pm
index 52817f3597..a6557fb1fe 100644
--- a/source4/build/smb_build/summary.pm
+++ b/source4/build/smb_build/summary.pm
@@ -5,6 +5,7 @@
# Released under the GNU GPL
package summary;
+use smb_build::config;
use strict;
sub enabled($)
@@ -21,9 +22,7 @@ sub showitem($$$)
my @need = ();
foreach (@$items) {
- if (!enabled($output->{$_}->{ENABLE})) {
- push (@need, $_);
- }
+ push (@need, $_) if (enabled($config::enable{$_}));
}
print "Support for $desc: ";
@@ -54,6 +53,9 @@ sub show($$)
showitem($output, "using libblkid", ["BLKID"]);
showitem($output, "using iconv", ["ICONV"]);
showitem($output, "using pam", ["PAM"]);
+ if (enabled($config->{developer})) {
+ showitem($output, "using VDE", ["VDEPLUG"]);
+ }
showitem($output, "python bindings", ["LIBPYTHON"]);
showisexternal($output, "popt", "LIBPOPT");
showisexternal($output, "talloc", "LIBTALLOC");
diff --git a/source4/cluster/config.mk b/source4/cluster/config.mk
index c5c2ea970a..8b225202fb 100644
--- a/source4/cluster/config.mk
+++ b/source4/cluster/config.mk
@@ -1,4 +1,4 @@
-include ctdb/config.mk
+mkinclude ctdb/config.mk
####################
[SUBSYSTEM::CLUSTER]
diff --git a/source4/configure.ac b/source4/configure.ac
index ed74bc1251..b609b4f52c 100644
--- a/source4/configure.ac
+++ b/source4/configure.ac
@@ -35,12 +35,11 @@ AC_CONFIG_FILES(auth/gensec/gensec.pc)
AC_CONFIG_FILES(param/samba-config.pc)
AC_CONFIG_FILES(librpc/dcerpc_samr.pc)
-SMB_EXT_LIB_FROM_PKGCONFIG(LIBTALLOC, talloc >= 1.1.0,
+SMB_EXT_LIB_FROM_PKGCONFIG(LIBTALLOC, talloc >= 1.2.0,
[],
[
m4_include(lib/talloc/libtalloc.m4)
SMB_INCLUDE_MK(lib/talloc/config.mk)
- AC_CONFIG_FILES(lib/talloc/talloc.pc)
]
)
@@ -49,7 +48,6 @@ SMB_EXT_LIB_FROM_PKGCONFIG(LIBTDB, tdb >= 1.1.0,
[
m4_include(lib/tdb/libtdb.m4)
SMB_INCLUDE_MK(lib/tdb/config.mk)
- AC_CONFIG_FILES(lib/tdb/tdb.pc)
]
)
@@ -140,6 +138,25 @@ for d in build/smb_build bin include ; do
test -d ${builddir}/$d || AS_MKDIR_P(${builddir}/$d)
done
+AC_SUBST(INTERN_LDFLAGS)
+AC_SUBST(INSTALL_LINK_FLAGS)
+if test $USESHARED = "true";
+then
+ INTERN_LDFLAGS="-L\${builddir}/bin/shared -L\${builddir}/bin/static"
+ INSTALL_LINK_FLAGS="-Wl,-rpath-link,\${builddir}/bin/shared";
+else
+ INTERN_LDFLAGS="-L\${builddir}/bin/static -L\${builddir}/bin/shared"
+fi
+
+builddir_headers=""
+
+if test "x$ac_abs_srcdir" != "x$ac_abs_builddir"
+then
+ builddir_headers="-I\$(builddir)/include -I\$(builddir) -I\$(builddir)/lib ";
+fi
+
+CPPFLAGS="$builddir_headers-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -I\$(srcdir)/lib/replace -I\$(srcdir)/lib/talloc -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H $CPPFLAGS"
+
echo "configure: creating build/smb_build/config.pm"
cat >build/smb_build/config.pm<<CEOF
# config.pm - Autogenerate by configure. DO NOT EDIT!
@@ -201,3 +218,11 @@ CMP_RET=$?
if test $CMP_RET != 0; then
cp include/config_tmp.h include/config.h
fi
+
+echo "configure: creating mkconfig.mk"
+cat >mkconfig.mk<<CEOF
+# mkconfig.mk - Autogenerated by configure, DO NOT EDIT!
+AC_FOREACH([AC_Var], m4_defn([_AC_SUBST_VARS]), [
+AC_Var = $AC_Var])
+$MAKE_SETTINGS
+CEOF
diff --git a/source4/dsdb/config.mk b/source4/dsdb/config.mk
index de00b401c8..17752fbbbd 100644
--- a/source4/dsdb/config.mk
+++ b/source4/dsdb/config.mk
@@ -1,6 +1,6 @@
# Directory Service subsystem
-include samdb/ldb_modules/config.mk
+mkinclude samdb/ldb_modules/config.mk
################################################
# Start SUBSYSTEM SAMDB
diff --git a/source4/dsdb/samdb/ldb_modules/anr.c b/source4/dsdb/samdb/ldb_modules/anr.c
index 908d9b088c..1252c9ee42 100644
--- a/source4/dsdb/samdb/ldb_modules/anr.c
+++ b/source4/dsdb/samdb/ldb_modules/anr.c
@@ -295,13 +295,7 @@ static int anr_search(struct ldb_module *module, struct ldb_request *req)
return ldb_next_request(module, req);
}
-static const struct ldb_module_ops anr_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_anr_module_ops = {
.name = "anr",
.search = anr_search
};
-
-int ldb_anr_init(void)
-{
- return ldb_register_module(&anr_ops);
-}
-
diff --git a/source4/dsdb/samdb/ldb_modules/config.mk b/source4/dsdb/samdb/ldb_modules/config.mk
index dc407fbd8a..de93b5638d 100644
--- a/source4/dsdb/samdb/ldb_modules/config.mk
+++ b/source4/dsdb/samdb/ldb_modules/config.mk
@@ -4,7 +4,7 @@
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC LIBNDR NDR_MISC
-INIT_FUNCTION = objectguid_module_init
+INIT_FUNCTION = objectguid_module_module_ops
OBJ_FILES = \
objectguid.o
# End MODULE ldb_objectguid
@@ -17,7 +17,7 @@ SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC LIBNDR NDR_MISC NDR_DRSUAPI \
NDR_DRSBLOBS LIBNDR
-INIT_FUNCTION = repl_meta_data_module_init
+INIT_FUNCTION = repl_meta_data_module_module_ops
OBJ_FILES = \
repl_meta_data.o
# End MODULE ldb_repl_meta_data
@@ -29,7 +29,7 @@ OBJ_FILES = \
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC
-INIT_FUNCTION = dsdb_cache_module_init
+INIT_FUNCTION = dsdb_cache_module_module_ops
OBJ_FILES = \
dsdb_cache.o
# End MODULE ldb_dsdb_cache
@@ -41,7 +41,7 @@ OBJ_FILES = \
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC
-INIT_FUNCTION = schema_fsmo_module_init
+INIT_FUNCTION = schema_fsmo_module_module_ops
OBJ_FILES = \
schema_fsmo.o
# End MODULE ldb_schema_fsmo
@@ -53,7 +53,7 @@ OBJ_FILES = \
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC
-INIT_FUNCTION = naming_fsmo_module_init
+INIT_FUNCTION = naming_fsmo_module_module_ops
OBJ_FILES = \
naming_fsmo.o
# End MODULE ldb_naming_fsmo
@@ -65,7 +65,7 @@ OBJ_FILES = \
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC
-INIT_FUNCTION = pdc_fsmo_module_init
+INIT_FUNCTION = pdc_fsmo_module_module_ops
OBJ_FILES = \
pdc_fsmo.o
# End MODULE ldb_pdc_fsmo
@@ -77,7 +77,7 @@ OBJ_FILES = \
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC LDAP_ENCODE NDR_MISC SAMDB
-INIT_FUNCTION = samldb_module_init
+INIT_FUNCTION = samldb_module_module_ops
OBJ_FILES = \
samldb.o
#
@@ -89,7 +89,7 @@ OBJ_FILES = \
[MODULE::ldb_samba3sam]
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
-INIT_FUNCTION = ldb_samba3sam_module_init
+INIT_FUNCTION = &ldb_samba3sam_module_module_ops
PRIVATE_DEPENDENCIES = LIBTALLOC ldb_map SMBPASSWD NSS_WRAPPER LIBSECURITY \
NDR_SECURITY
OBJ_FILES = \
@@ -103,7 +103,7 @@ OBJ_FILES = \
[MODULE::ldb_simple_ldap_map]
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
-INIT_FUNCTION = ldb_simple_ldap_map_module_init
+INIT_FUNCTION = &ldb_simple_ldap_map_module_module_ops
PRIVATE_DEPENDENCIES = LIBTALLOC ldb_map LIBNDR NDR_MISC
ENABLE = YES
ALIASES = entryuuid nsuniqueid
@@ -117,7 +117,7 @@ OBJ_FILES = \
# # Start MODULE ldb_proxy
# [MODULE::ldb_proxy]
# SUBSYSTEM = LIBLDB
-# INIT_FUNCTION = proxy_module_init
+# INIT_FUNCTION = proxy_module_module_ops
# OBJ_FILES = \
# proxy.o
#
@@ -131,7 +131,7 @@ OBJ_FILES = \
SUBSYSTEM = LIBLDB
PRIVATE_DEPENDENCIES = LIBTALLOC SAMDB
OUTPUT_TYPE = SHARED_LIBRARY
-INIT_FUNCTION = rootdse_module_init
+INIT_FUNCTION = rootdse_module_module_ops
OBJ_FILES = \
rootdse.o
#
@@ -143,7 +143,7 @@ OBJ_FILES = \
[MODULE::ldb_password_hash]
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
-INIT_FUNCTION = password_hash_module_init
+INIT_FUNCTION = password_hash_module_module_ops
OBJ_FILES = password_hash.o
PRIVATE_DEPENDENCIES = HEIMDAL_HDB_KEYS LIBTALLOC HEIMDAL_KRB5 LDAP_ENCODE \
LIBCLI_AUTH NDR_DRSBLOBS KERBEROS SAMDB
@@ -157,7 +157,7 @@ PRIVATE_DEPENDENCIES = HEIMDAL_HDB_KEYS LIBTALLOC HEIMDAL_KRB5 LDAP_ENCODE \
PRIVATE_DEPENDENCIES = LIBTALLOC LIBNDR SAMDB
OUTPUT_TYPE = SHARED_LIBRARY
SUBSYSTEM = LIBLDB
-INIT_FUNCTION = local_password_module_init
+INIT_FUNCTION = local_password_module_module_ops
OBJ_FILES = local_password.o
#
# End MODULE ldb_local_password
@@ -169,7 +169,7 @@ OBJ_FILES = local_password.o
PRIVATE_DEPENDENCIES = LIBTALLOC LIBSECURITY SAMDB
OUTPUT_TYPE = SHARED_LIBRARY
SUBSYSTEM = LIBLDB
-INIT_FUNCTION = ldb_kludge_acl_init
+INIT_FUNCTION = &ldb_kludge_acl_module_ops
OBJ_FILES = \
kludge_acl.o
#
@@ -182,7 +182,7 @@ OBJ_FILES = \
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC LIBNDR LIBSECURITY SAMDB
-INIT_FUNCTION = ldb_extended_dn_init
+INIT_FUNCTION = &ldb_extended_dn_module_ops
OBJ_FILES = \
extended_dn.o
#
@@ -195,7 +195,7 @@ OBJ_FILES = \
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC
-INIT_FUNCTION = ldb_show_deleted_init
+INIT_FUNCTION = &ldb_show_deleted_module_ops
OBJ_FILES = \
show_deleted.o
#
@@ -208,7 +208,7 @@ OBJ_FILES = \
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC SAMDB
-INIT_FUNCTION = ldb_partition_init
+INIT_FUNCTION = &ldb_partition_module_ops
OBJ_FILES = \
partition.o
#
@@ -221,7 +221,7 @@ OBJ_FILES = \
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC LIBLDB
-INIT_FUNCTION = ldb_schema_init
+INIT_FUNCTION = &ldb_schema_module_ops
OBJ_FILES = \
schema.o schema_syntax.o
#
@@ -235,7 +235,7 @@ SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC CREDENTIALS
#Also depends on credentials, but that would loop
-INIT_FUNCTION = ldb_update_kt_init
+INIT_FUNCTION = &ldb_update_kt_module_ops
OBJ_FILES = \
update_keytab.o
#
@@ -245,7 +245,7 @@ OBJ_FILES = \
################################################
# Start MODULE ldb_objectclass
[MODULE::ldb_objectclass]
-INIT_FUNCTION = ldb_objectclass_init
+INIT_FUNCTION = &ldb_objectclass_module_ops
OUTPUT_TYPE = SHARED_LIBRARY
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC LIBSECURITY NDR_SECURITY SAMDB
@@ -258,8 +258,7 @@ OBJ_FILES = \
################################################
# Start MODULE ldb_subtree_rename
[MODULE::ldb_subtree_rename]
-INIT_FUNCTION = ldb_subtree_rename_init
-OUTPUT_TYPE = SHARED_LIBRARY
+INIT_FUNCTION = &ldb_subtree_rename_module_ops
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC
SUBSYSTEM = LIBLDB
@@ -271,8 +270,7 @@ OBJ_FILES = \
################################################
# Start MODULE ldb_subtree_rename
[MODULE::ldb_subtree_delete]
-INIT_FUNCTION = ldb_subtree_delete_init
-OUTPUT_TYPE = SHARED_LIBRARY
+INIT_FUNCTION = &ldb_subtree_delete_module_ops
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC
SUBSYSTEM = LIBLDB
@@ -284,7 +282,7 @@ OBJ_FILES = \
################################################
# Start MODULE ldb_linked_attributes
[MODULE::ldb_linked_attributes]
-INIT_FUNCTION = ldb_linked_attributes_init
+INIT_FUNCTION = &ldb_linked_attributes_module_ops
CFLAGS = -Ilib/ldb/include
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC SAMDB
@@ -297,9 +295,8 @@ OBJ_FILES = \
################################################
# Start MODULE ldb_ranged_results
[MODULE::ldb_ranged_results]
-INIT_FUNCTION = ldb_ranged_results_init
+INIT_FUNCTION = &ldb_ranged_results_module_ops
CFLAGS = -Ilib/ldb/include
-OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC
SUBSYSTEM = LIBLDB
OBJ_FILES = \
@@ -310,7 +307,7 @@ OBJ_FILES = \
################################################
# Start MODULE ldb_anr
[MODULE::ldb_anr]
-INIT_FUNCTION = ldb_anr_init
+INIT_FUNCTION = &ldb_anr_module_ops
CFLAGS = -Ilib/ldb/include
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL SAMDB
@@ -323,7 +320,7 @@ OBJ_FILES = \
################################################
# Start MODULE ldb_normalise
[MODULE::ldb_normalise]
-INIT_FUNCTION = ldb_normalise_init
+INIT_FUNCTION = &ldb_normalise_module_ops
CFLAGS = -Ilib/ldb/include
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL SAMDB
@@ -336,7 +333,7 @@ OBJ_FILES = \
################################################
# Start MODULE ldb_instancetype
[MODULE::ldb_instancetype]
-INIT_FUNCTION = ldb_instancetype_init
+INIT_FUNCTION = &ldb_instancetype_module_ops
CFLAGS = -Ilib/ldb/include
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC
diff --git a/source4/dsdb/samdb/ldb_modules/dsdb_cache.c b/source4/dsdb/samdb/ldb_modules/dsdb_cache.c
index 4ca8bbf463..e60605dce1 100644
--- a/source4/dsdb/samdb/ldb_modules/dsdb_cache.c
+++ b/source4/dsdb/samdb/ldb_modules/dsdb_cache.c
@@ -36,12 +36,7 @@ static int dsdb_cache_init(struct ldb_module *module)
return ldb_next_init(module);
}
-static const struct ldb_module_ops dsdb_cache_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_dsdb_cache_module_ops = {
.name = "dsdb_cache",
.init_context = dsdb_cache_init
};
-
-int dsdb_cache_module_init(void)
-{
- return ldb_register_module(&dsdb_cache_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn.c b/source4/dsdb/samdb/ldb_modules/extended_dn.c
index 802f86570b..84bf5e4843 100644
--- a/source4/dsdb/samdb/ldb_modules/extended_dn.c
+++ b/source4/dsdb/samdb/ldb_modules/extended_dn.c
@@ -362,13 +362,8 @@ static int extended_init(struct ldb_module *module)
return ldb_next_init(module);
}
-static const struct ldb_module_ops extended_dn_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_extended_dn_module_ops = {
.name = "extended_dn",
.search = extended_search,
.init_context = extended_init
};
-
-int ldb_extended_dn_init(void)
-{
- return ldb_register_module(&extended_dn_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/instancetype.c b/source4/dsdb/samdb/ldb_modules/instancetype.c
index 65df294e90..fd5aa5e18a 100644
--- a/source4/dsdb/samdb/ldb_modules/instancetype.c
+++ b/source4/dsdb/samdb/ldb_modules/instancetype.c
@@ -118,13 +118,7 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req)
return ret;
}
-static const struct ldb_module_ops instancetype_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_instancetype_module_ops = {
.name = "instancetype",
.add = instancetype_add,
};
-
-
-int ldb_instancetype_init(void)
-{
- return ldb_register_module(&instancetype_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/kludge_acl.c b/source4/dsdb/samdb/ldb_modules/kludge_acl.c
index ea33548b91..e3e1f7ac88 100644
--- a/source4/dsdb/samdb/ldb_modules/kludge_acl.c
+++ b/source4/dsdb/samdb/ldb_modules/kludge_acl.c
@@ -471,7 +471,7 @@ done:
return ldb_next_init(module);
}
-static const struct ldb_module_ops kludge_acl_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_kludge_acl_module_ops = {
.name = "kludge_acl",
.search = kludge_acl_search,
.add = kludge_acl_change,
@@ -481,8 +481,3 @@ static const struct ldb_module_ops kludge_acl_ops = {
.extended = kludge_acl_change,
.init_context = kludge_acl_init
};
-
-int ldb_kludge_acl_init(void)
-{
- return ldb_register_module(&kludge_acl_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/linked_attributes.c b/source4/dsdb/samdb/ldb_modules/linked_attributes.c
index b3fdffe566..8685c722aa 100644
--- a/source4/dsdb/samdb/ldb_modules/linked_attributes.c
+++ b/source4/dsdb/samdb/ldb_modules/linked_attributes.c
@@ -915,7 +915,7 @@ static int linked_attributes_wait(struct ldb_handle *handle, enum ldb_wait_type
}
}
-static const struct ldb_module_ops linked_attributes_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_linked_attributes_module_ops = {
.name = "linked_attributes",
.add = linked_attributes_add,
.modify = linked_attributes_modify,
@@ -923,8 +923,3 @@ static const struct ldb_module_ops linked_attributes_ops = {
.rename = linked_attributes_rename,
.wait = linked_attributes_wait,
};
-
-int ldb_linked_attributes_init(void)
-{
- return ldb_register_module(&linked_attributes_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/local_password.c b/source4/dsdb/samdb/ldb_modules/local_password.c
index 350434df51..dfa98ef0af 100644
--- a/source4/dsdb/samdb/ldb_modules/local_password.c
+++ b/source4/dsdb/samdb/ldb_modules/local_password.c
@@ -843,16 +843,10 @@ static int local_password_wait(struct ldb_handle *handle, enum ldb_wait_type typ
}
}
-static const struct ldb_module_ops local_password_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_local_password_module_ops = {
.name = "local_password",
.add = local_password_add,
.modify = local_password_modify,
.search = local_password_search,
.wait = local_password_wait
};
-
-
-int local_password_module_init(void)
-{
- return ldb_register_module(&local_password_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c
index d6b6a24287..084540f68d 100644
--- a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c
+++ b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c
@@ -117,12 +117,7 @@ static int naming_fsmo_init(struct ldb_module *module)
return ldb_next_init(module);
}
-static const struct ldb_module_ops naming_fsmo_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_naming_fsmo_module_ops = {
.name = "naming_fsmo",
.init_context = naming_fsmo_init
};
-
-int naming_fsmo_module_init(void)
-{
- return ldb_register_module(&naming_fsmo_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/normalise.c b/source4/dsdb/samdb/ldb_modules/normalise.c
index efc9bb29e8..695393d4e8 100644
--- a/source4/dsdb/samdb/ldb_modules/normalise.c
+++ b/source4/dsdb/samdb/ldb_modules/normalise.c
@@ -105,6 +105,7 @@ static int normalise_search_callback(struct ldb_context *ldb, void *context, str
if (!attribute) {
continue;
}
+ /* Look to see if this attributeSyntax is a DN */
if ((strcmp(attribute->attributeSyntax_oid, "2.5.5.1") != 0) &&
(strcmp(attribute->attributeSyntax_oid, "2.5.5.7") != 0)) {
continue;
@@ -155,12 +156,7 @@ static int normalise_search(struct ldb_module *module, struct ldb_request *req)
}
-static const struct ldb_module_ops normalise_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_normalise_module_ops = {
.name = "normalise",
.search = normalise_search,
};
-
-int ldb_normalise_init(void)
-{
- return ldb_register_module(&normalise_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/objectclass.c b/source4/dsdb/samdb/ldb_modules/objectclass.c
index 737475ca78..e63ad4de56 100644
--- a/source4/dsdb/samdb/ldb_modules/objectclass.c
+++ b/source4/dsdb/samdb/ldb_modules/objectclass.c
@@ -1153,16 +1153,10 @@ static int objectclass_wait(struct ldb_handle *handle, enum ldb_wait_type type)
}
}
-static const struct ldb_module_ops objectclass_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_objectclass_module_ops = {
.name = "objectclass",
.add = objectclass_add,
.modify = objectclass_modify,
.rename = objectclass_rename,
.wait = objectclass_wait
};
-
-int ldb_objectclass_init(void)
-{
- return ldb_register_module(&objectclass_ops);
-}
-
diff --git a/source4/dsdb/samdb/ldb_modules/objectguid.c b/source4/dsdb/samdb/ldb_modules/objectguid.c
index bf57f5c21b..f62839389d 100644
--- a/source4/dsdb/samdb/ldb_modules/objectguid.c
+++ b/source4/dsdb/samdb/ldb_modules/objectguid.c
@@ -247,14 +247,8 @@ static int objectguid_modify(struct ldb_module *module, struct ldb_request *req)
return ret;
}
-static const struct ldb_module_ops objectguid_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_objectguid_module_ops = {
.name = "objectguid",
.add = objectguid_add,
.modify = objectguid_modify,
};
-
-
-int objectguid_module_init(void)
-{
- return ldb_register_module(&objectguid_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/partition.c b/source4/dsdb/samdb/ldb_modules/partition.c
index 61b64441a7..78b5a09f78 100644
--- a/source4/dsdb/samdb/ldb_modules/partition.c
+++ b/source4/dsdb/samdb/ldb_modules/partition.c
@@ -87,7 +87,7 @@ static struct ldb_module *make_module_for_next_request(TALLOC_CTX *mem_ctx,
struct ldb_module *module)
{
struct ldb_module *current;
- static const struct ldb_module_ops ops; /* zero */
+_PUBLIC_ static const struct ldb_module_ops ops; /* zero */
current = talloc_zero(mem_ctx, struct ldb_module);
if (current == NULL) {
return module;
@@ -1030,7 +1030,7 @@ static int partition_wait(struct ldb_handle *handle, enum ldb_wait_type type)
}
}
-static const struct ldb_module_ops partition_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_partition_module_ops = {
.name = "partition",
.init_context = partition_init,
.search = partition_search,
@@ -1045,8 +1045,3 @@ static const struct ldb_module_ops partition_ops = {
.del_transaction = partition_del_trans,
.wait = partition_wait
};
-
-int ldb_partition_init(void)
-{
- return ldb_register_module(&partition_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c
index 57c053d961..aa64700f2f 100644
--- a/source4/dsdb/samdb/ldb_modules/password_hash.c
+++ b/source4/dsdb/samdb/ldb_modules/password_hash.c
@@ -2044,15 +2044,9 @@ static int password_hash_wait(struct ldb_handle *handle, enum ldb_wait_type type
}
}
-static const struct ldb_module_ops password_hash_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_password_hash_module_ops = {
.name = "password_hash",
.add = password_hash_add,
.modify = password_hash_modify,
.wait = password_hash_wait
};
-
-
-int password_hash_module_init(void)
-{
- return ldb_register_module(&password_hash_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c
index 0f3293ed1d..09d56d77c9 100644
--- a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c
+++ b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c
@@ -115,12 +115,7 @@ static int pdc_fsmo_init(struct ldb_module *module)
return ldb_next_init(module);
}
-static const struct ldb_module_ops pdc_fsmo_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_pdc_fsmo_module_ops = {
.name = "pdc_fsmo",
.init_context = pdc_fsmo_init
};
-
-int pdc_fsmo_module_init(void)
-{
- return ldb_register_module(&pdc_fsmo_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/proxy.c b/source4/dsdb/samdb/ldb_modules/proxy.c
index 37ee7f9fce..0d065425ca 100644
--- a/source4/dsdb/samdb/ldb_modules/proxy.c
+++ b/source4/dsdb/samdb/ldb_modules/proxy.c
@@ -331,12 +331,7 @@ static int proxy_request(struct ldb_module *module, struct ldb_request *req)
}
}
-static const struct ldb_module_ops proxy_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_proxy_module_ops = {
.name = "proxy",
.request = proxy_request
};
-
-int proxy_module_init(void)
-{
- return ldb_register_module(&proxy_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/ranged_results.c b/source4/dsdb/samdb/ldb_modules/ranged_results.c
index c527afc6db..c6ebea1044 100644
--- a/source4/dsdb/samdb/ldb_modules/ranged_results.c
+++ b/source4/dsdb/samdb/ldb_modules/ranged_results.c
@@ -201,12 +201,7 @@ static int rr_search(struct ldb_module *module, struct ldb_request *req)
return ldb_next_request(module, req);
}
-static const struct ldb_module_ops rr_ops = {
+const struct ldb_module_ops ldb_ranged_results_module_ops = {
.name = "ranged_results",
.search = rr_search,
};
-
-int ldb_ranged_results_init(void)
-{
- return ldb_register_module(&rr_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
index 441dbc9598..dd5faf837a 100644
--- a/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
+++ b/source4/dsdb/samdb/ldb_modules/repl_meta_data.c
@@ -1579,15 +1579,10 @@ static int replmd_wait(struct ldb_handle *handle, enum ldb_wait_type type)
}
}
-static const struct ldb_module_ops replmd_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_repl_meta_data_module_ops = {
.name = "repl_meta_data",
.add = replmd_add,
.modify = replmd_modify,
.extended = replmd_extended,
.wait = replmd_wait
};
-
-int repl_meta_data_module_init(void)
-{
- return ldb_register_module(&replmd_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c
index 02f43d7076..3235b24ef9 100644
--- a/source4/dsdb/samdb/ldb_modules/rootdse.c
+++ b/source4/dsdb/samdb/ldb_modules/rootdse.c
@@ -386,15 +386,9 @@ static int rootdse_init(struct ldb_module *module)
return ldb_next_init(module);
}
-static const struct ldb_module_ops rootdse_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_rootdse_module_ops = {
.name = "rootdse",
.init_context = rootdse_init,
.search = rootdse_search,
.request = rootdse_request
};
-
-int rootdse_module_init(void)
-{
- return ldb_register_module(&rootdse_ops);
-}
-
diff --git a/source4/dsdb/samdb/ldb_modules/samba3sam.c b/source4/dsdb/samdb/ldb_modules/samba3sam.c
index 3a666b5380..88b04b1bb6 100644
--- a/source4/dsdb/samdb/ldb_modules/samba3sam.c
+++ b/source4/dsdb/samdb/ldb_modules/samba3sam.c
@@ -925,21 +925,8 @@ static int samba3sam_init(struct ldb_module *module)
return ldb_next_init(module);
}
-static struct ldb_module_ops samba3sam_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_samba3sam_module_ops = {
+ LDB_MAP_OPS
.name = "samba3sam",
.init_context = samba3sam_init,
};
-
-/* the init function */
-int ldb_samba3sam_module_init(void)
-{
- struct ldb_module_ops ops = ldb_map_get_ops();
- samba3sam_ops.add = ops.add;
- samba3sam_ops.modify = ops.modify;
- samba3sam_ops.del = ops.del;
- samba3sam_ops.rename = ops.rename;
- samba3sam_ops.search = ops.search;
- samba3sam_ops.wait = ops.wait;
-
- return ldb_register_module(&samba3sam_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index baf419c750..178149a886 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -750,14 +750,8 @@ static int samldb_init(struct ldb_module *module)
return ldb_next_init(module);
}
-static const struct ldb_module_ops samldb_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_samldb_module_ops = {
.name = "samldb",
.init_context = samldb_init,
.add = samldb_add,
};
-
-
-int samldb_module_init(void)
-{
- return ldb_register_module(&samldb_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/schema.c b/source4/dsdb/samdb/ldb_modules/schema.c
index 525193ac8c..ff9530ca92 100644
--- a/source4/dsdb/samdb/ldb_modules/schema.c
+++ b/source4/dsdb/samdb/ldb_modules/schema.c
@@ -1221,7 +1221,7 @@ static int schema_init(struct ldb_module *module)
return LDB_SUCCESS;
}
-static const struct ldb_module_ops schema_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_schema_module_ops = {
.name = "schema",
.init_context = schema_init,
.add = schema_add,
@@ -1230,8 +1230,3 @@ static const struct ldb_module_ops schema_ops = {
.rename = schema_rename,
.wait = schema_wait
};
-
-int ldb_schema_init(void)
-{
- return ldb_register_module(&schema_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c
index f9dd131fd4..729fd15202 100644
--- a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c
+++ b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c
@@ -255,12 +255,7 @@ static int schema_fsmo_init(struct ldb_module *module)
return ldb_next_init(module);
}
-static const struct ldb_module_ops schema_fsmo_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_schema_fsmo_module_ops = {
.name = "schema_fsmo",
.init_context = schema_fsmo_init
};
-
-int schema_fsmo_module_init(void)
-{
- return ldb_register_module(&schema_fsmo_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/show_deleted.c b/source4/dsdb/samdb/ldb_modules/show_deleted.c
index 19fa63fb6e..361cf226dc 100644
--- a/source4/dsdb/samdb/ldb_modules/show_deleted.c
+++ b/source4/dsdb/samdb/ldb_modules/show_deleted.c
@@ -194,13 +194,8 @@ static int show_deleted_init(struct ldb_module *module)
return ldb_next_init(module);
}
-static const struct ldb_module_ops show_deleted_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_show_deleted_module_ops = {
.name = "show_deleted",
.search = show_deleted_search,
.init_context = show_deleted_init
};
-
-int ldb_show_deleted_init(void)
-{
- return ldb_register_module(&show_deleted_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c
index acf2fd622c..3f4c19d285 100644
--- a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c
+++ b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c
@@ -793,42 +793,16 @@ static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_reque
return LDB_SUCCESS;
}
-static struct ldb_module_ops entryuuid_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_entryuuid_module_ops = {
.name = "entryuuid",
.init_context = entryuuid_init,
- .sequence_number = entryuuid_sequence_number
+ .sequence_number = entryuuid_sequence_number,
+ LDB_MAP_OPS
};
-static struct ldb_module_ops nsuniqueid_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_nsuniqueid_module_ops = {
.name = "nsuniqueid",
.init_context = nsuniqueid_init,
- .sequence_number = entryuuid_sequence_number
+ .sequence_number = entryuuid_sequence_number,
+ LDB_MAP_OPS
};
-
-/* the init function */
-int ldb_simple_ldap_map_module_init(void)
-{
- int ret;
- struct ldb_module_ops ops = ldb_map_get_ops();
- entryuuid_ops.add = ops.add;
- entryuuid_ops.modify = ops.modify;
- entryuuid_ops.del = ops.del;
- entryuuid_ops.rename = ops.rename;
- entryuuid_ops.search = ops.search;
- entryuuid_ops.wait = ops.wait;
- ret = ldb_register_module(&entryuuid_ops);
-
- if (ret) {
- return ret;
- }
-
- nsuniqueid_ops.add = ops.add;
- nsuniqueid_ops.modify = ops.modify;
- nsuniqueid_ops.del = ops.del;
- nsuniqueid_ops.rename = ops.rename;
- nsuniqueid_ops.search = ops.search;
- nsuniqueid_ops.wait = ops.wait;
- ret = ldb_register_module(&nsuniqueid_ops);
-
- return ret;
-}
diff --git a/source4/dsdb/samdb/ldb_modules/subtree_delete.c b/source4/dsdb/samdb/ldb_modules/subtree_delete.c
index e84bf60b32..56ae7b239a 100644
--- a/source4/dsdb/samdb/ldb_modules/subtree_delete.c
+++ b/source4/dsdb/samdb/ldb_modules/subtree_delete.c
@@ -247,13 +247,8 @@ static int subtree_delete_wait(struct ldb_handle *handle, enum ldb_wait_type typ
}
}
-static const struct ldb_module_ops subtree_delete_ops = {
+const struct ldb_module_ops ldb_subtree_delete_module_ops = {
.name = "subtree_delete",
.del = subtree_delete,
.wait = subtree_delete_wait,
};
-
-int ldb_subtree_delete_init(void)
-{
- return ldb_register_module(&subtree_delete_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/subtree_rename.c b/source4/dsdb/samdb/ldb_modules/subtree_rename.c
index 0964c3fdcd..bf8124e253 100644
--- a/source4/dsdb/samdb/ldb_modules/subtree_rename.c
+++ b/source4/dsdb/samdb/ldb_modules/subtree_rename.c
@@ -264,13 +264,8 @@ static int subtree_rename_wait(struct ldb_handle *handle, enum ldb_wait_type typ
}
}
-static const struct ldb_module_ops subtree_rename_ops = {
+const struct ldb_module_ops ldb_subtree_rename_module_ops = {
.name = "subtree_rename",
.rename = subtree_rename,
.wait = subtree_rename_wait,
};
-
-int ldb_subtree_rename_init(void)
-{
- return ldb_register_module(&subtree_rename_ops);
-}
diff --git a/source4/dsdb/samdb/ldb_modules/update_keytab.c b/source4/dsdb/samdb/ldb_modules/update_keytab.c
index a18efd757a..54362dcfd4 100644
--- a/source4/dsdb/samdb/ldb_modules/update_keytab.c
+++ b/source4/dsdb/samdb/ldb_modules/update_keytab.c
@@ -199,7 +199,7 @@ static int update_kt_init(struct ldb_module *module)
return ldb_next_init(module);
}
-static const struct ldb_module_ops update_kt_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_update_keytab_module_ops = {
.name = "update_keytab",
.init_context = update_kt_init,
.add = update_kt_add,
@@ -209,8 +209,3 @@ static const struct ldb_module_ops update_kt_ops = {
.end_transaction = update_kt_end_trans,
.del_transaction = update_kt_del_trans,
};
-
-int ldb_update_kt_init(void)
-{
- return ldb_register_module(&update_kt_ops);
-}
diff --git a/source4/dsdb/schema/schema.h b/source4/dsdb/schema/schema.h
index 1379ddee9f..bb34235465 100644
--- a/source4/dsdb/schema/schema.h
+++ b/source4/dsdb/schema/schema.h
@@ -149,6 +149,8 @@ struct dsdb_schema {
struct dsdb_attribute *attributes;
struct dsdb_class *classes;
+
+ struct smb_iconv_convenience *iconv_convenience;
};
#include "dsdb/schema/proto.h"
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c
index 6a7463951e..30d0adeda7 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -88,8 +88,7 @@ WERROR dsdb_load_oid_mappings_ldb(struct dsdb_schema *schema,
TALLOC_CTX *mem_ctx = talloc_new(schema);
W_ERROR_HAVE_NO_MEMORY(mem_ctx);
- ndr_err = ndr_pull_struct_blob(prefixMap, mem_ctx, lp_iconv_convenience(global_loadparm), &pfm,
- (ndr_pull_flags_fn_t)ndr_pull_prefixMapBlob);
+ ndr_err = ndr_pull_struct_blob(prefixMap, mem_ctx, schema->iconv_convenience, &pfm, (ndr_pull_flags_fn_t)ndr_pull_prefixMapBlob);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err);
talloc_free(mem_ctx);
@@ -181,8 +180,7 @@ WERROR dsdb_get_oid_mappings_ldb(const struct dsdb_schema *schema,
pfm.reserved = 0;
pfm.ctr.dsdb = *ctr;
- ndr_err = ndr_push_struct_blob(prefixMap, mem_ctx, lp_iconv_convenience(global_loadparm), &pfm,
- (ndr_push_flags_fn_t)ndr_push_prefixMapBlob);
+ ndr_err = ndr_push_struct_blob(prefixMap, mem_ctx, schema->iconv_convenience, &pfm, (ndr_push_flags_fn_t)ndr_push_prefixMapBlob);
talloc_free(ctr);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err);
@@ -628,7 +626,7 @@ static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb
} \
if (_a && _a->value_ctr.num_values >= 1) { \
ssize_t _ret; \
- _ret = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, \
+ _ret = convert_string_talloc(mem_ctx, s->iconv_convenience, CH_UTF16, CH_UNIX, \
_a->value_ctr.values[0].blob->data, \
_a->value_ctr.values[0].blob->length, \
(void **)discard_const(&(p)->elem)); \
@@ -665,7 +663,7 @@ static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb
struct drsuapi_DsReplicaObjectIdentifier3 _id3; \
enum ndr_err_code _ndr_err; \
_ndr_err = ndr_pull_struct_blob_all(_a->value_ctr.values[0].blob, \
- mem_ctx, lp_iconv_convenience(global_loadparm), &_id3,\
+ mem_ctx, s->iconv_convenience, &_id3,\
(ndr_pull_flags_fn_t)ndr_pull_drsuapi_DsReplicaObjectIdentifier3);\
if (!NDR_ERR_CODE_IS_SUCCESS(_ndr_err)) { \
NTSTATUS _nt_status = ndr_map_error2ntstatus(_ndr_err); \
@@ -727,7 +725,7 @@ static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb
&& _a->value_ctr.values[0].blob->length == 16) { \
enum ndr_err_code _ndr_err; \
_ndr_err = ndr_pull_struct_blob_all(_a->value_ctr.values[0].blob, \
- mem_ctx, lp_iconv_convenience(global_loadparm), &(p)->elem, \
+ mem_ctx, s->iconv_convenience, &(p)->elem, \
(ndr_pull_flags_fn_t)ndr_pull_GUID); \
if (!NDR_ERR_CODE_IS_SUCCESS(_ndr_err)) { \
NTSTATUS _nt_status = ndr_map_error2ntstatus(_ndr_err); \
@@ -1157,6 +1155,8 @@ WERROR dsdb_attach_schema_from_ldif_file(struct ldb_context *ldb, const char *pf
goto nomem;
}
+ schema->iconv_convenience = lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm"));
+
/*
* load the prefixMap attribute from pf
*/
diff --git a/source4/dsdb/schema/schema_syntax.c b/source4/dsdb/schema/schema_syntax.c
index 2c133b6424..beacfc49c2 100644
--- a/source4/dsdb/schema/schema_syntax.c
+++ b/source4/dsdb/schema/schema_syntax.c
@@ -767,7 +767,8 @@ static WERROR dsdb_syntax_UNICODE_drsuapi_to_ldb(const struct dsdb_schema *schem
return WERR_FOOBAR;
}
- ret = convert_string_talloc(out->values, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX,
+ ret = convert_string_talloc(out->values, schema->iconv_convenience,
+ CH_UTF16, CH_UNIX,
in->value_ctr.values[i].blob->data,
in->value_ctr.values[i].blob->length,
(void **)&str);
@@ -809,7 +810,7 @@ static WERROR dsdb_syntax_UNICODE_ldb_to_drsuapi(const struct dsdb_schema *schem
out->value_ctr.values[i].blob = &blobs[i];
- ret = convert_string_talloc(blobs, lp_iconv_convenience(global_loadparm), CH_UNIX, CH_UTF16,
+ ret = convert_string_talloc(blobs, schema->iconv_convenience, CH_UNIX, CH_UTF16,
in->values[i].data,
in->values[i].length,
(void **)&blobs[i].data);
@@ -851,7 +852,7 @@ static WERROR dsdb_syntax_DN_drsuapi_to_ldb(const struct dsdb_schema *schema,
}
ndr_err = ndr_pull_struct_blob_all(in->value_ctr.values[i].blob,
- out->values, lp_iconv_convenience(global_loadparm), &id3,
+ out->values, schema->iconv_convenience, &id3,
(ndr_pull_flags_fn_t)ndr_pull_drsuapi_DsReplicaObjectIdentifier3);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
NTSTATUS status = ndr_map_error2ntstatus(ndr_err);
@@ -898,7 +899,7 @@ static WERROR dsdb_syntax_DN_ldb_to_drsuapi(const struct dsdb_schema *schema,
ZERO_STRUCT(id3);
id3.dn = (const char *)in->values[i].data;
- ndr_err = ndr_push_struct_blob(&blobs[i], blobs, lp_iconv_convenience(global_loadparm), &id3, (ndr_push_flags_fn_t)ndr_push_drsuapi_DsReplicaObjectIdentifier3);
+ ndr_err = ndr_push_struct_blob(&blobs[i], blobs, schema->iconv_convenience, &id3, (ndr_push_flags_fn_t)ndr_push_drsuapi_DsReplicaObjectIdentifier3);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
NTSTATUS status = ndr_map_error2ntstatus(ndr_err);
return ntstatus_to_werror(status);
@@ -939,7 +940,7 @@ static WERROR dsdb_syntax_DN_BINARY_drsuapi_to_ldb(const struct dsdb_schema *sch
}
ndr_err = ndr_pull_struct_blob_all(in->value_ctr.values[i].blob,
- out->values, lp_iconv_convenience(global_loadparm), &id3b,
+ out->values, schema->iconv_convenience, &id3b,
(ndr_pull_flags_fn_t)ndr_pull_drsuapi_DsReplicaObjectIdentifier3Binary);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
NTSTATUS status = ndr_map_error2ntstatus(ndr_err);
@@ -997,7 +998,7 @@ static WERROR dsdb_syntax_DN_BINARY_ldb_to_drsuapi(const struct dsdb_schema *sch
id3b.dn = (const char *)in->values[i].data;
id3b.binary = data_blob(NULL, 0);
- ndr_err = ndr_push_struct_blob(&blobs[i], blobs, lp_iconv_convenience(global_loadparm), &id3b,
+ ndr_err = ndr_push_struct_blob(&blobs[i], blobs, schema->iconv_convenience, &id3b,
(ndr_push_flags_fn_t)ndr_push_drsuapi_DsReplicaObjectIdentifier3Binary);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
NTSTATUS status = ndr_map_error2ntstatus(ndr_err);
@@ -1043,7 +1044,7 @@ static WERROR dsdb_syntax_PRESENTATION_ADDRESS_drsuapi_to_ldb(const struct dsdb_
return WERR_FOOBAR;
}
- ret = convert_string_talloc(out->values, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX,
+ ret = convert_string_talloc(out->values, schema->iconv_convenience, CH_UTF16, CH_UNIX,
in->value_ctr.values[i].blob->data+4,
in->value_ctr.values[i].blob->length-4,
(void **)&str);
@@ -1086,7 +1087,7 @@ static WERROR dsdb_syntax_PRESENTATION_ADDRESS_ldb_to_drsuapi(const struct dsdb_
out->value_ctr.values[i].blob = &blobs[i];
- ret = convert_string_talloc(blobs, lp_iconv_convenience(global_loadparm), CH_UNIX, CH_UTF16,
+ ret = convert_string_talloc(blobs, schema->iconv_convenience, CH_UNIX, CH_UTF16,
in->values[i].data,
in->values[i].length,
(void **)&data);
diff --git a/source4/dynconfig.mk b/source4/dynconfig.mk
index 9c872da3e8..e970d4cd4c 100644
--- a/source4/dynconfig.mk
+++ b/source4/dynconfig.mk
@@ -4,20 +4,20 @@ OBJ_FILES = dynconfig.o
# set these to where to find various files
# These can be overridden by command line switches (see smbd(8))
# or in smb.conf (see smb.conf(5))
-CONFIGFILE = $(CONFIGDIR)/smb.conf
-PKGCONFIGDIR = $(LIBDIR)/pkgconfig
-LMHOSTSFILE = $(CONFIGDIR)/lmhosts
+CONFIGFILE = $(sysconfdir)/smb.conf
+PKGCONFIGDIR = $(libdir)/pkgconfig
+LMHOSTSFILE = $(sysconfdir)/lmhosts
PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\" \
- -DBINDIR=\"$(BINDIR)\" -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" \
- -DLOCKDIR=\"$(LOCKDIR)\" -DPIDDIR=\"$(PIDDIR)\" -DDATADIR=\"$(DATADIR)\" \
- -DLOGFILEBASE=\"$(LOGFILEBASE)\" \
- -DCONFIGDIR=\"$(CONFIGDIR)\" -DNCALRPCDIR=\"$(NCALRPCDIR)\" \
+ -DBINDIR=\"$(bindir)\" -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" \
+ -DLOCKDIR=\"$(lockdir)\" -DPIDDIR=\"$(piddir)\" -DDATADIR=\"$(datadir)\" \
+ -DLOGFILEBASE=\"$(logfilebase)\" \
+ -DCONFIGDIR=\"$(sysconfdir)\" -DNCALRPCDIR=\"$(NCALRPCDIR)\" \
-DSWATDIR=\"$(SWATDIR)\" \
- -DPRIVATE_DIR=\"$(PRIVATEDIR)\" \
- -DMODULESDIR=\"$(MODULESDIR)\" -DJSDIR=\"$(JSDIR)\" \
+ -DPRIVATE_DIR=\"$(privatedir)\" \
+ -DMODULESDIR=\"$(modulesdir)\" -DJSDIR=\"$(JSDIR)\" \
-DTORTUREDIR=\"$(TORTUREDIR)\" \
- -DSETUPDIR=\"$(SETUPDIR)\" -DWINBINDD_SOCKET_DIR=\"$(WINBINDD_SOCKET_DIR)\"
+ -DSETUPDIR=\"$(SETUPDIR)\" -DWINBINDD_SOCKET_DIR=\"$(winbindd_socket_dir)\"
dynconfig.o: dynconfig.c Makefile
@echo Compiling $<
diff --git a/source4/headermap.txt b/source4/headermap.txt
index acbe81328e..70ca92c01c 100644
--- a/source4/headermap.txt
+++ b/source4/headermap.txt
@@ -120,3 +120,4 @@ lib/util/wrap_xattr.h: wrap_xattr.h
lib/events/events.h: events/events.h
lib/events/events_internal.h: events/events_internal.h
libcli/ldap/ldap_ndr.h: ldb/ldap_ndr.h
+lib/gencache/gencache.h: gencache.h
diff --git a/source4/heimdal_build/config.mk b/source4/heimdal_build/config.mk
index 604516ccf6..45bfd8e81f 100644
--- a/source4/heimdal_build/config.mk
+++ b/source4/heimdal_build/config.mk
@@ -15,8 +15,7 @@ OBJ_FILES = \
../heimdal/kdc/digest.o \
../heimdal/kdc/process.o \
../heimdal/kdc/windc.o \
- ../heimdal/kdc/kx509.o \
- ../heimdal/lib/asn1/asn1_KRB5SignedPath.o
+ ../heimdal/kdc/kx509.o
PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_KRB5 HEIMDAL_HDB HEIMDAL_HEIM_ASN1 HEIMDAL_DIGEST_ASN1 HEIMDAL_KX509_ASN1
PUBLIC_DEPENDENCIES = HEIMDAL_NTLM HEIMDAL_HCRYPTO
# End SUBSYSTEM HEIMDAL_KDC
@@ -31,10 +30,9 @@ PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_HCRYPTO HEIMDAL_KRB5
[SUBSYSTEM::HEIMDAL_HDB_KEYS]
CFLAGS = -Iheimdal_build -Iheimdal/lib/hdb
OBJ_FILES = \
- ../heimdal/lib/hdb/keys.o \
- ../heimdal/lib/hdb/asn1_Key.o \
- ../heimdal/lib/hdb/asn1_Salt.o
-PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_HCRYPTO HEIMDAL_KRB5
+ ../heimdal/lib/hdb/keys.o
+PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_HCRYPTO HEIMDAL_KRB5 \
+ HEIMDAL_HDB_ASN1
#######################
# Start SUBSYSTEM HEIMDAL_HDB
@@ -278,9 +276,7 @@ OBJ_FILES = \
../heimdal/lib/asn1/der_cmp.o \
../heimdal/lib/asn1/extra.o \
../heimdal/lib/asn1/timegm.o \
- ../heimdal/lib/asn1/asn1_err.o \
- ../heimdal/lib/asn1/asn1_krb5int32.o \
- ../heimdal/lib/asn1/asn1_krb5uint32.o
+ ../heimdal/lib/asn1/asn1_err.o
PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_COM_ERR
# End SUBSYSTEM HEIMDAL_KRB5
#######################
@@ -341,7 +337,7 @@ PRIVATE_DEPENDENCIES = \
HEIMDAL_CMS_ASN1 HEIMDAL_RFC2459_ASN1 \
HEIMDAL_OCSP_ASN1 HEIMDAL_PKCS8_ASN1 \
HEIMDAL_PKCS9_ASN1 HEIMDAL_PKCS12_ASN1 \
- HEIMDAL_PKINIT_ASN1
+ HEIMDAL_PKINIT_ASN1 HEIMDAL_PKCS10_ASN1
OBJ_FILES = \
../heimdal/lib/hx509/ca.o \
../heimdal/lib/hx509/cert.o \
@@ -412,7 +408,6 @@ OBJ_FILES = \
../heimdal/lib/roken/estrdup.o \
../heimdal/lib/roken/erealloc.o \
../heimdal/lib/roken/simple_exec.o \
- ../heimdal/lib/roken/simple_exec.o \
../heimdal/lib/roken/strcollect.o \
../heimdal/lib/roken/rtbl.o \
replace.o
@@ -511,32 +506,32 @@ PRIVATE_DEPENDENCIES = HEIMDAL_COM_ERR_COMPILE_LEX HEIMDAL_ROKEN_GETPROGNAME_H E
# End BINARY compile_et
#######################
-include perl_path_wrapper.sh asn1_deps.pl heimdal/lib/hdb/hdb.asn1 hdb_asn1 heimdal/lib/hdb |
-include perl_path_wrapper.sh asn1_deps.pl heimdal/lib/gssapi/spnego/spnego.asn1 spnego_asn1 heimdal/lib/gssapi --sequence=MechTypeList |
-include perl_path_wrapper.sh asn1_deps.pl heimdal/lib/gssapi/mech/gssapi.asn1 gssapi_asn1 heimdal/lib/gssapi|
-include perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/k5.asn1 krb5_asn1 heimdal/lib/asn1 --encode-rfc1510-bit-string --sequence=KRB5SignedPathPrincipals --sequence=AuthorizationData --sequence=METHOD-DATA|
-include perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/digest.asn1 digest_asn1 heimdal/lib/asn1|
-include perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/pkcs8.asn1 pkcs8_asn1 heimdal/lib/asn1|
-include perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/pkcs9.asn1 pkcs9_asn1 heimdal/lib/asn1|
-include perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/pkcs12.asn1 pkcs12_asn1 heimdal/lib/asn1|
-include perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/rfc2459.asn1 rfc2459_asn1 heimdal/lib/asn1 --preserve-binary=TBSCertificate --preserve-binary=TBSCRLCertList --preserve-binary=Name --sequence=GeneralNames --sequence=Extensions --sequence=CRLDistributionPoints|
-include perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/pkinit.asn1 pkinit_asn1 heimdal/lib/asn1|
-include perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/CMS.asn1 cms_asn1 heimdal/lib/asn1|
-include perl_path_wrapper.sh asn1_deps.pl heimdal/lib/hx509/ocsp.asn1 ocsp_asn1 heimdal/lib/hx509 --preserve-binary=OCSPTBSRequest --preserve-binary=OCSPResponseData|
-include perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/kx509.asn1 kx509_asn1 heimdal/lib/asn1|
-include perl_path_wrapper.sh asn1_deps.pl heimdal/lib/hx509/pkcs10.asn1 pkcs10_asn1 heimdal/lib/hx509 --preserve-binary=CertificationRequestInfo|
+mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/hdb/hdb.asn1 hdb_asn1 heimdal/lib/hdb |
+mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/gssapi/spnego/spnego.asn1 spnego_asn1 heimdal/lib/gssapi --sequence=MechTypeList |
+mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/gssapi/mech/gssapi.asn1 gssapi_asn1 heimdal/lib/gssapi|
+mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/k5.asn1 krb5_asn1 heimdal/lib/asn1 --encode-rfc1510-bit-string --sequence=KRB5SignedPathPrincipals --sequence=AuthorizationData --sequence=METHOD-DATA|
+mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/digest.asn1 digest_asn1 heimdal/lib/asn1|
+mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/pkcs8.asn1 pkcs8_asn1 heimdal/lib/asn1|
+mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/pkcs9.asn1 pkcs9_asn1 heimdal/lib/asn1|
+mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/pkcs12.asn1 pkcs12_asn1 heimdal/lib/asn1|
+mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/rfc2459.asn1 rfc2459_asn1 heimdal/lib/asn1 --preserve-binary=TBSCertificate --preserve-binary=TBSCRLCertList --preserve-binary=Name --sequence=GeneralNames --sequence=Extensions --sequence=CRLDistributionPoints|
+mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/pkinit.asn1 pkinit_asn1 heimdal/lib/asn1|
+mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/CMS.asn1 cms_asn1 heimdal/lib/asn1|
+mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/hx509/ocsp.asn1 ocsp_asn1 heimdal/lib/hx509 --preserve-binary=OCSPTBSRequest --preserve-binary=OCSPResponseData|
+mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/kx509.asn1 kx509_asn1 heimdal/lib/asn1|
+mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/hx509/pkcs10.asn1 pkcs10_asn1 heimdal/lib/hx509 --preserve-binary=CertificationRequestInfo|
#
# Ensure to update ../static_deps.mk when you add a new entry here!
#
-include perl_path_wrapper.sh et_deps.pl heimdal/lib/asn1/asn1_err.et heimdal/lib/asn1|
-include perl_path_wrapper.sh et_deps.pl heimdal/lib/hdb/hdb_err.et heimdal/lib/hdb|
-include perl_path_wrapper.sh et_deps.pl heimdal/lib/krb5/heim_err.et heimdal/lib/krb5|
-include perl_path_wrapper.sh et_deps.pl heimdal/lib/krb5/k524_err.et heimdal/lib/krb5|
-include perl_path_wrapper.sh et_deps.pl heimdal/lib/krb5/krb_err.et heimdal/lib/krb5|
-include perl_path_wrapper.sh et_deps.pl heimdal/lib/krb5/krb5_err.et heimdal/lib/krb5|
-include perl_path_wrapper.sh et_deps.pl heimdal/lib/gssapi/krb5/gkrb5_err.et heimdal/lib/gssapi|
-include perl_path_wrapper.sh et_deps.pl heimdal/lib/hx509/hx509_err.et heimdal/lib/hx509|
+mkinclude perl_path_wrapper.sh et_deps.pl heimdal/lib/asn1/asn1_err.et heimdal/lib/asn1|
+mkinclude perl_path_wrapper.sh et_deps.pl heimdal/lib/hdb/hdb_err.et heimdal/lib/hdb|
+mkinclude perl_path_wrapper.sh et_deps.pl heimdal/lib/krb5/heim_err.et heimdal/lib/krb5|
+mkinclude perl_path_wrapper.sh et_deps.pl heimdal/lib/krb5/k524_err.et heimdal/lib/krb5|
+mkinclude perl_path_wrapper.sh et_deps.pl heimdal/lib/krb5/krb_err.et heimdal/lib/krb5|
+mkinclude perl_path_wrapper.sh et_deps.pl heimdal/lib/krb5/krb5_err.et heimdal/lib/krb5|
+mkinclude perl_path_wrapper.sh et_deps.pl heimdal/lib/gssapi/krb5/gkrb5_err.et heimdal/lib/gssapi|
+mkinclude perl_path_wrapper.sh et_deps.pl heimdal/lib/hx509/hx509_err.et heimdal/lib/hx509|
clean::
@-rm -f bin/compile_et bin/asn1_compile
diff --git a/source4/kdc/config.mk b/source4/kdc/config.mk
index c787343515..479cb36296 100644
--- a/source4/kdc/config.mk
+++ b/source4/kdc/config.mk
@@ -22,7 +22,8 @@ OBJ_FILES = \
hdb-ldb.o \
pac-glue.o
PRIVATE_DEPENDENCIES = \
- LIBLDB auth_sam auth_sam_reply KERBEROS CREDENTIALS
+ LIBLDB auth_sam auth_sam_reply KERBEROS CREDENTIALS \
+ HEIMDAL_HDB_ASN1
# End SUBSYSTEM KDC
#######################
diff --git a/source4/lib/basic.mk b/source4/lib/basic.mk
index 8653779044..a118636c52 100644
--- a/source4/lib/basic.mk
+++ b/source4/lib/basic.mk
@@ -1,32 +1,28 @@
# LIB BASIC subsystem
-include samba3/config.mk
-include socket/config.mk
-include charset/config.mk
-include ldb-samba/config.mk
-include tls/config.mk
-include registry/config.mk
-include policy/config.mk
-include messaging/config.mk
-include events/config.mk
-include cmdline/config.mk
-include socket_wrapper/config.mk
-include nss_wrapper/config.mk
-include appweb/config.mk
-include stream/config.mk
-include util/config.mk
-include tdr/config.mk
-include dbwrap/config.mk
-include crypto/config.mk
+mkinclude samba3/config.mk
+mkinclude socket/config.mk
+mkinclude charset/config.mk
+mkinclude ldb-samba/config.mk
+mkinclude tls/config.mk
+mkinclude registry/config.mk
+mkinclude policy/config.mk
+mkinclude messaging/config.mk
+mkinclude events/config.mk
+mkinclude cmdline/config.mk
+mkinclude socket_wrapper/config.mk
+mkinclude nss_wrapper/config.mk
+mkinclude appweb/config.mk
+mkinclude stream/config.mk
+mkinclude util/config.mk
+mkinclude tdr/config.mk
+mkinclude dbwrap/config.mk
+mkinclude crypto/config.mk
-################################################
-# Start SUBSYSTEM LIBCOMPRESSION
[SUBSYSTEM::LIBCOMPRESSION]
OBJ_FILES = compression/mszip.o
-# End SUBSYSTEM LIBCOMPRESION
-################################################
[SUBSYSTEM::GENCACHE]
-PRIVATE_PROTO_HEADER = gencache/gencache.h
+PUBLIC_HEADERS = gencache/gencache.h
OBJ_FILES = gencache/gencache.o
PRIVATE_DEPENDENCIES = TDB_WRAP
diff --git a/source4/lib/events/events_select.c b/source4/lib/events/events_select.c
index 3f9eeb5617..f4b7e4e5eb 100644
--- a/source4/lib/events/events_select.c
+++ b/source4/lib/events/events_select.c
@@ -300,7 +300,7 @@ bool events_select_init(void)
}
#if _SAMBA_BUILD_
-NTSTATUS s4_events_select_init(void)
+_PUBLIC_ NTSTATUS s4_events_select_init(void)
{
if (!events_select_init()) {
return NT_STATUS_INTERNAL_ERROR;
diff --git a/source4/lib/events/events_standard.c b/source4/lib/events/events_standard.c
index 5e529d66ab..7b945b154d 100644
--- a/source4/lib/events/events_standard.c
+++ b/source4/lib/events/events_standard.c
@@ -602,7 +602,7 @@ bool events_standard_init(void)
}
#if _SAMBA_BUILD_
-NTSTATUS s4_events_standard_init(void)
+_PUBLIC_ NTSTATUS s4_events_standard_init(void)
{
if (!events_standard_init()) {
return NT_STATUS_INTERNAL_ERROR;
diff --git a/source4/lib/gencache/gencache.h b/source4/lib/gencache/gencache.h
new file mode 100644
index 0000000000..1481676fd9
--- /dev/null
+++ b/source4/lib/gencache/gencache.h
@@ -0,0 +1,94 @@
+#ifndef __LIB_GENCACHE_GENCACHE_H__
+#define __LIB_GENCACHE_GENCACHE_H__
+
+/**
+ * Cache initialisation function. Opens cache tdb file or creates
+ * it if does not exist.
+ *
+ * @return true on successful initialisation of the cache or
+ * false on failure
+ **/
+bool gencache_init(struct loadparm_context *lp_ctx);
+
+/**
+ * Cache shutdown function. Closes opened cache tdb file.
+ *
+ * @return true on successful closing the cache or
+ * false on failure during cache shutdown
+ **/
+bool gencache_shutdown(void);
+
+/**
+ * Set an entry in the cache file. If there's no such
+ * one, then add it.
+ *
+ * @param keystr string that represents a key of this entry
+ * @param value text representation value being cached
+ * @param timeout time when the value is expired
+ *
+ * @retval true when entry is successfuly stored
+ * @retval false on failure
+ **/
+bool gencache_set(const char *keystr, const char *value, time_t timeout);
+
+/**
+ * Set existing entry to the cache file.
+ *
+ * @param keystr string that represents a key of this entry
+ * @param valstr text representation value being cached
+ * @param timeout time when the value is expired
+ *
+ * @retval true when entry is successfuly set
+ * @retval false on failure
+ **/
+bool gencache_set_only(const char *keystr, const char *valstr, time_t timeout);
+
+/**
+ * Delete one entry from the cache file.
+ *
+ * @param keystr string that represents a key of this entry
+ *
+ * @retval true upon successful deletion
+ * @retval false in case of failure
+ **/
+bool gencache_del(const char *keystr);
+
+/**
+ * Get existing entry from the cache file.
+ *
+ * @param keystr string that represents a key of this entry
+ * @param valstr buffer that is allocated and filled with the entry value
+ * buffer's disposing must be done outside
+ * @param timeout pointer to a time_t that is filled with entry's
+ * timeout
+ *
+ * @retval true when entry is successfuly fetched
+ * @retval false for failure
+ **/
+bool gencache_get(const char *keystr, char **valstr, time_t *timeout);
+
+/**
+ * Iterate through all entries which key matches to specified pattern
+ *
+ * @param fn pointer to the function that will be supplied with each single
+ * matching cache entry (key, value and timeout) as an arguments
+ * @param data void pointer to an arbitrary data that is passed directly to the fn
+ * function on each call
+ * @param keystr_pattern pattern the existing entries' keys are matched to
+ *
+ **/
+void gencache_iterate(void (*fn)(const char* key, const char *value, time_t timeout, void* dptr),
+ void* data, const char* keystr_pattern);
+
+/********************************************************************
+ lock a key
+********************************************************************/
+int gencache_lock_entry( const char *key );
+
+/********************************************************************
+ unlock a key
+********************************************************************/
+void gencache_unlock_entry( const char *key );
+
+#endif /* __LIB_GENCACHE_GENCACHE_H__ */
+
diff --git a/source4/lib/ldb/Makefile.in b/source4/lib/ldb/Makefile.in
index 7bd719cdd9..d88f82b726 100644
--- a/source4/lib/ldb/Makefile.in
+++ b/source4/lib/ldb/Makefile.in
@@ -19,6 +19,11 @@ SWIG = swig
EXTRA_OBJ=@EXTRA_OBJ@
TESTS=test-tdb.sh @TESTS@
PACKAGE_VERSION = @PACKAGE_VERSION@
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+tdbdir = @tdbdir@
+ldbdir = $(srcdir)
+tallocdir = @tallocdir@
TALLOC_LIBS = @TALLOC_LIBS@
TALLOC_CFLAGS = @TALLOC_CFLAGS@
@@ -53,35 +58,6 @@ CFLAGS=-g -I$(srcdir)/include -Iinclude -I$(srcdir) -I$(srcdir)/.. \
MDLD = @MDLD@
MDLD_FLAGS = @MDLD_FLAGS@
-LDB_LIB = $(STATICLIB)
-
-LIB_FLAGS=$(LDFLAGS) -Llib $(LDB_LIB) $(LIBS) $(POPT_LIBS) $(TALLOC_LIBS) \
- $(TDB_LIBS) $(LDAP_LIBS) $(LIBDL)
-
-LDB_TDB_DIR=ldb_tdb
-LDB_TDB_OBJ=$(LDB_TDB_DIR)/ldb_tdb.o \
- $(LDB_TDB_DIR)/ldb_pack.o $(LDB_TDB_DIR)/ldb_search.o $(LDB_TDB_DIR)/ldb_index.o \
- $(LDB_TDB_DIR)/ldb_cache.o $(LDB_TDB_DIR)/ldb_tdb_wrap.o
-
-LDB_MAP_DIR=ldb_map
-LDB_MAP_OBJ=$(LDB_MAP_DIR)/ldb_map.o $(LDB_MAP_DIR)/ldb_map_inbound.o \
- $(LDB_MAP_DIR)/ldb_map_outbound.o
-
-COMDIR=common
-COMMON_OBJ=$(COMDIR)/ldb.o $(COMDIR)/ldb_ldif.o \
- $(COMDIR)/ldb_parse.o $(COMDIR)/ldb_msg.o $(COMDIR)/ldb_utf8.o \
- $(COMDIR)/ldb_debug.o $(COMDIR)/ldb_modules.o \
- $(COMDIR)/ldb_dn.o $(COMDIR)/ldb_match.o $(COMDIR)/ldb_attributes.o \
- $(COMDIR)/attrib_handlers.o $(COMDIR)/ldb_controls.o $(COMDIR)/qsort.o
-
-MODDIR=modules
-MODULES_OBJ=$(MODDIR)/operational.o $(MODDIR)/rdn_name.o \
- $(MODDIR)/paged_results.o $(MODDIR)/sort.o $(MODDIR)/asq.o
-
-NSSDIR=nssldb
-NSS_OBJ= $(NSSDIR)/ldb-nss.o $(NSSDIR)/ldb-pwd.o $(NSSDIR)/ldb-grp.o
-NSS_LIB = lib/libnss_ldb.$(SHLIBEXT).2
-
OBJS = $(MODULES_OBJ) $(COMMON_OBJ) $(LDB_TDB_OBJ) $(TDB_OBJ) $(TALLOC_OBJ) $(POPT_OBJ) $(LDB_MAP_OBJ) @LIBREPLACEOBJ@ $(EXTRA_OBJ)
headers = $(srcdir)/include/ldb.h $(srcdir)/include/ldb_errors.h $(srcdir)/include/ldb_handlers.h
@@ -94,6 +70,8 @@ DIRS = lib bin common ldb_tdb ldb_ldap ldb_sqlite3 modules tools examples
default: all
+include $(ldbdir)/rules.mk
+
nss: nssdir all $(NSS_LIB)
nssdir:
@@ -109,76 +87,22 @@ lib/$(SONAME): $(SOLIB)
lib/libldb.$(SHLIBEXT): $(SOLIB)
ln -fs libldb.$(SHLIBEXT).$(PACKAGE_VERSION) $@
+lib/libnss_ldb.$(SHLIBEXT).2: $(NSS_OBJ) $(SOLIB)
+ $(SHLD) $(SHLD_FLAGS) -o $@ $(NSS_OBJ) $(LDFLAGS) $(SOLIB) @SONAMEFLAG@libnss_ldb.$(SHLIBEXT).2
+
$(SOLIB): $(OBJS)
$(SHLD) $(SHLD_FLAGS) -o $@ $(OBJS) $(LDFLAGS) $(LIBS) $(TALLOC_LIBS) $(TDB_LIBS) $(LIBDL) $(LDAP_LIBS) @SONAMEFLAG@$(SONAME)
all: showflags dirs $(OBJS) $(STATICLIB) $(SOLIB) $(BINS) $(EXAMPLES) manpages \
@PYTHON_BUILD_TARGET@
-showflags:
- @echo 'ldb will be compiled with flags:'
- @echo ' CFLAGS = $(CFLAGS)'
- @echo ' LIBS = $(LIBS)'
-
-.c.o:
- @echo Compiling $*.c
- @mkdir -p `dirname $@`
- @$(CC) $(CFLAGS) $(PICFLAG) -c $< -o $@
-
-.c.po:
- @echo Compiling $*.c
- @mkdir -p `dirname $@`
- @$(CC) -fPIC $(CFLAGS) -c $< -o $@
-
dirs:
@mkdir -p $(DIRS)
-lib/libldb.a: $(OBJS)
- ar -rv $@ $(OBJS)
- @-ranlib $@
-
-lib/libnss_ldb.$(SHLIBEXT).2: $(NSS_OBJ) $(SOLIB)
- $(SHLD) $(SHLD_FLAGS) -o $@ $(NSS_OBJ) $(LDFLAGS) $(SOLIB) @SONAMEFLAG@libnss_ldb.$(SHLIBEXT).2
-
-sample_module.$(SHLIBEXT): tests/sample_module.o
- $(MDLD) $(MDLD_FLAGS) -o $@ tests/sample_module.o
-
-bin/ldbadd: tools/ldbadd.o tools/cmdline.o $(LIBS)
- $(CC) -o bin/ldbadd tools/ldbadd.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-
-bin/ldbsearch: tools/ldbsearch.o tools/cmdline.o $(LIBS)
- $(CC) -o bin/ldbsearch tools/ldbsearch.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-
-bin/ldbdel: tools/ldbdel.o tools/cmdline.o $(LIBS)
- $(CC) -o bin/ldbdel tools/ldbdel.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-
-bin/ldbmodify: tools/ldbmodify.o tools/cmdline.o $(LIBS)
- $(CC) -o bin/ldbmodify tools/ldbmodify.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-
-bin/ldbedit: tools/ldbedit.o tools/cmdline.o $(LIBS)
- $(CC) -o bin/ldbedit tools/ldbedit.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-
-bin/ldbrename: tools/ldbrename.o tools/cmdline.o $(LIBS)
- $(CC) -o bin/ldbrename tools/ldbrename.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-
-bin/ldbtest: tools/ldbtest.o tools/cmdline.o $(LIBS)
- $(CC) -o bin/ldbtest tools/ldbtest.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
-
-bin/oLschema2ldif: tools/oLschema2ldif.o tools/cmdline.o tools/convert.o $(LIBS)
- $(CC) -o bin/oLschema2ldif tools/oLschema2ldif.o tools/cmdline.o tools/convert.o $(LIB_FLAGS)
-
-examples/ldbreader: examples/ldbreader.o $(LIBS)
- $(CC) -o examples/ldbreader examples/ldbreader.o $(LIB_FLAGS)
-
-examples/ldifreader: examples/ldifreader.o $(LIBS)
- $(CC) -o examples/ldifreader examples/ldifreader.o $(LIB_FLAGS)
-
-.SUFFIXES: .1 .1.xml .3 .3.xml .xml .html .c .o
-
-manpages:
+manpages::
@$(srcdir)/docs/builddocs.sh "$(XSLTPROC)" "$(srcdir)"
-doxygen:
+doxygen::
test -z "$(DOXYGEN)" || (cd $(srcdir) && "$(DOXYGEN)")
clean::
@@ -191,7 +115,6 @@ clean::
rm -rf tests/schema/
distclean:: clean
- rm -f *~ */*~
rm -rf bin lib
rm -f config.log config.status config.cache include/config.h
rm -f ldb.pc
@@ -200,39 +123,39 @@ distclean:: clean
realdistclean:: distclean
rm -f configure.in include/config.h.in
-check:: test check-soloading
+check:: test @PYTHON_CHECK_TARGET@
-check-soloading: sample_module.$(SHLIBEXT)
+check-soloading: sample.$(SHLIBEXT)
LDB_MODULES_PATH=$(builddir) $(srcdir)/tests/test-soloading.sh
-test: all check-soloading
+test:: all check-soloading
for t in $(TESTS); do echo STARTING $${t}; $(srcdir)/tests/$${t} || exit 1; done
-valgrindtest: all
+valgrindtest:: all
for t in $(TESTS); do echo STARTING $${t}; VALGRIND="valgrind -q --db-attach=yes --num-callers=30" $(srcdir)/tests/$${t} || exit 1; done
-installcheck: install test
+installcheck:: install test
install:: all installdirs installheaders installlibs installbin installdocs \
@PYTHON_INSTALL_TARGET@
-installdirs:
+installdirs::
mkdir -p $(DESTDIR)$(includedir) $(DESTDIR)$(libdir) $(DESTDIR)$(bindir) $(DESTDIR)$(libdir)/pkgconfig
-installheaders: installdirs
+installheaders:: installdirs
cp $(headers) $(DESTDIR)$(includedir)
-installlibs: installdirs
+installlibs:: installdirs
cp $(STATICLIB) $(SOLIB) $(DESTDIR)$(libdir)
cp ldb.pc $(DESTDIR)$(libdir)/pkgconfig
-installbin: installdirs
+installbin:: installdirs
cp $(BINS) $(DESTDIR)$(bindir)
-installdocs: installdirs
+installdocs:: installdirs
$(srcdir)/docs/installdocs.sh $(DESTDIR)$(mandir)
-gcov:
+gcov::
$(GCOV) -po ldb_sqlite3 $(srcdir)/ldb_sqlite3/*.c 2| tee ldb_sqlite3.report.gcov
$(GCOV) -po ldb_ldap $(srcdir)/ldb_ldap/*.c 2| tee ldb_ldap.report.gcov
$(GCOV) -po ldb_tdb $(srcdir)/ldb_tdb/*.c 2| tee ldb_tdb.report.gcov
@@ -240,30 +163,4 @@ gcov:
$(GCOV) -po modules $(srcdir)/modules/*.c 2| tee modules.report.gcov
$(GCOV) -po tools $(srcdir)/tools/*.c 2| tee tools.report.gcov
-etags:
- etags `find $(srcdir) -name "*.[ch]"`
-
-ctags:
- ctags `find $(srcdir) -name "*.[ch]"`
-
-.SUFFIXES: _wrap.c .i
-
-.i_wrap.c:
- [ "$(SWIG)" == "no" ] || $(SWIG) -O -Wall -python -keyword $<
-
-# Python bindings
-build-python: lib/libldb.$(SHLIBEXT) ldb_wrap.c
- ./setup.py build
-
-install-python: build-python
- ./setup.py install --prefix=$(DESTDIR)$(prefix)
-
-install-swig:
- cp ldb.i `$(SWIG) -swiglib`
-
-check-python: build-python
- # FIXME: This isn't portable
- LD_LIBRARY_PATH=lib PYTHONPATH=.:build/lib.linux-i686-2.4/ trial tests/python/api.py
-
-clean-python:
- ./setup.py clean
+include $(ldbdir)/ldb.mk
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 5601a33191..3c9ef3ff69 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -56,20 +56,51 @@ struct ldb_context *ldb_init(void *mem_ctx)
return ldb;
}
-struct ldb_backend {
- const char *name;
- ldb_connect_fn connect_fn;
- struct ldb_backend *prev, *next;
+static struct backends_list_entry {
+ struct ldb_backend_ops *ops;
+ struct backends_list_entry *prev, *next;
} *ldb_backends = NULL;
+#ifndef STATIC_LIBLDB_BACKENDS
+
+#ifdef HAVE_LDB_LDAP
+#define LDAP_INIT &ldb_ldap_backend_ops, \
+ &ldb_ildap_backend_ops, \
+ &ldb_ldaps_backend_ops,
+#else
+#define LDAP_INIT
+#endif
+
+#ifdef HAVE_LDB_SQLITE3
+#define SQLITE3_INIT &ldb_sqlite3_backend_ops,
+#else
+#define SQLITE3_INIT
+#endif
+
+#define STATIC_LIBLDB_BACKENDS \
+ LDAP_INIT \
+ SQLITE3_INIT \
+ &ldb_tdb_backend_ops, \
+ NULL
+#endif
+
+const static struct ldb_backend_ops *builtin_backends[] = {
+ STATIC_LIBLDB_BACKENDS
+};
static ldb_connect_fn ldb_find_backend(const char *url)
{
- struct ldb_backend *backend;
+ struct backends_list_entry *backend;
+ int i;
+
+ for (i = 0; builtin_backends[i]; i++) {
+ if (strncmp(builtin_backends[i]->name, url, strlen(builtin_backends[i]->name)) == 0)
+ return builtin_backends[i]->connect_fn;
+ }
for (backend = ldb_backends; backend; backend = backend->next) {
- if (strncmp(backend->name, url, strlen(backend->name)) == 0) {
- return backend->connect_fn;
+ if (strncmp(backend->ops->name, url, strlen(backend->ops->name)) == 0) {
+ return backend->ops->connect_fn;
}
}
@@ -81,7 +112,8 @@ static ldb_connect_fn ldb_find_backend(const char *url)
*/
int ldb_register_backend(const char *url_prefix, ldb_connect_fn connectfn)
{
- struct ldb_backend *backend = talloc(talloc_autofree_context(), struct ldb_backend);
+ struct ldb_backend_ops *backend = talloc(talloc_autofree_context(), struct ldb_backend_ops);
+ struct backends_list_entry *entry = talloc(talloc_autofree_context(), struct backends_list_entry);
if (ldb_find_backend(url_prefix)) {
return LDB_SUCCESS;
@@ -91,7 +123,8 @@ int ldb_register_backend(const char *url_prefix, ldb_connect_fn connectfn)
backend->name = talloc_strdup(backend, url_prefix);
backend->connect_fn = connectfn;
- DLIST_ADD(ldb_backends, backend);
+ entry->ops = backend;
+ DLIST_ADD(ldb_backends, entry);
return LDB_SUCCESS;
}
@@ -135,6 +168,19 @@ int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *op
}
}
+ if (fn == NULL) {
+ struct ldb_backend_ops *ops;
+ char *symbol_name = talloc_asprintf(ldb, "ldb_%s_backend_ops", backend);
+ if (symbol_name == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ ops = ldb_dso_load_symbol(ldb, backend, symbol_name);
+ if (ops != NULL) {
+ fn = ops->connect_fn;
+ }
+ talloc_free(symbol_name);
+ }
+
talloc_free(backend);
if (fn == NULL) {
@@ -236,7 +282,6 @@ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, co
int ret;
const char *url2;
/* We seem to need to do this here, or else some utilities don't get ldb backends */
- ldb_global_init();
ldb->flags = flags;
diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c
index 18070bdb86..7da7b9ba34 100644
--- a/source4/lib/ldb/common/ldb_modules.c
+++ b/source4/lib/ldb/common/ldb_modules.c
@@ -126,9 +126,30 @@ static struct ops_list_entry {
struct ops_list_entry *next;
} *registered_modules = NULL;
+#ifndef STATIC_LIBLDB_MODULES
+
+#define STATIC_LIBLDB_MODULES \
+ ldb_operational_module_ops, \
+ ldb_rdn_name_module_ops, \
+ ldb_paged_results_module_ops, \
+ ldb_sort_module_ops, \
+ ldb_asq_module_ops, \
+ NULL
+#endif
+
+const static struct ldb_module_ops *builtin_modules[] = {
+ STATIC_LIBLDB_MODULES
+};
+
static const struct ldb_module_ops *ldb_find_module_ops(const char *name)
{
struct ops_list_entry *e;
+ int i;
+
+ for (i = 0; builtin_modules[i]; i++) {
+ if (strcmp(builtin_modules[i]->name, name) == 0)
+ return builtin_modules[i];
+ }
for (e = registered_modules; e; e = e->next) {
if (strcmp(e->ops->name, name) == 0)
@@ -138,51 +159,6 @@ static const struct ldb_module_ops *ldb_find_module_ops(const char *name)
return NULL;
}
-#ifndef STATIC_LIBLDB_MODULES
-
-#ifdef HAVE_LDB_LDAP
-#define LDAP_INIT ldb_ldap_init,
-#else
-#define LDAP_INIT
-#endif
-
-#ifdef HAVE_LDB_SQLITE3
-#define SQLITE3_INIT ldb_sqlite3_init,
-#else
-#define SQLITE3_INIT
-#endif
-
-#define STATIC_LIBLDB_MODULES \
- LDAP_INIT \
- SQLITE3_INIT \
- ldb_tdb_init, \
- ldb_operational_init, \
- ldb_rdn_name_init, \
- ldb_paged_results_init, \
- ldb_sort_init, \
- ldb_asq_init, \
- NULL
-#endif
-
-int ldb_global_init(void)
-{
- int (*static_init_fns[])(void) = { STATIC_LIBLDB_MODULES };
-
- static int initialized = 0;
- int ret = 0, i;
-
- if (initialized)
- return 0;
-
- initialized = 1;
-
- for (i = 0; static_init_fns[i]; i++) {
- if (static_init_fns[i]() == -1)
- ret = -1;
- }
-
- return ret;
-}
int ldb_register_module(const struct ldb_module_ops *ops)
{
@@ -257,8 +233,13 @@ int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, str
}
if (ops == NULL) {
- ops = ldb_dso_load_symbol(ldb, module_list[i],
- "ldb_module_ops");
+ char *symbol_name = talloc_asprintf(ldb, "ldb_%s_module_ops",
+ module_list[i]);
+ if (symbol_name == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ ops = ldb_dso_load_symbol(ldb, module_list[i], symbol_name);
+ talloc_free(symbol_name);
}
if (ops == NULL) {
diff --git a/source4/lib/ldb/config.mk b/source4/lib/ldb/config.mk
index 75ce89d6cf..6027acd0c7 100644
--- a/source4/lib/ldb/config.mk
+++ b/source4/lib/ldb/config.mk
@@ -3,7 +3,7 @@
[MODULE::ldb_asq]
PRIVATE_DEPENDENCIES = LIBTALLOC
CFLAGS = -Ilib/ldb/include
-INIT_FUNCTION = ldb_asq_init
+INIT_FUNCTION = &ldb_asq_module_ops
SUBSYSTEM = LIBLDB
OBJ_FILES = \
modules/asq.o
@@ -15,7 +15,7 @@ OBJ_FILES = \
[MODULE::ldb_server_sort]
PRIVATE_DEPENDENCIES = LIBTALLOC
CFLAGS = -Ilib/ldb/include
-INIT_FUNCTION = ldb_sort_init
+INIT_FUNCTION = &ldb_server_sort_module_ops
SUBSYSTEM = LIBLDB
OBJ_FILES = \
modules/sort.o
@@ -25,7 +25,7 @@ OBJ_FILES = \
################################################
# Start MODULE ldb_paged_results
[MODULE::ldb_paged_results]
-INIT_FUNCTION = ldb_paged_results_init
+INIT_FUNCTION = &ldb_paged_results_module_ops
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC
SUBSYSTEM = LIBLDB
@@ -37,7 +37,7 @@ OBJ_FILES = \
################################################
# Start MODULE ldb_paged_results
[MODULE::ldb_paged_searches]
-INIT_FUNCTION = ldb_paged_searches_init
+INIT_FUNCTION = &ldb_paged_searches_module_ops
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC
SUBSYSTEM = LIBLDB
@@ -52,7 +52,7 @@ OBJ_FILES = \
SUBSYSTEM = LIBLDB
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC
-INIT_FUNCTION = ldb_operational_init
+INIT_FUNCTION = &ldb_operational_module_ops
OBJ_FILES = \
modules/operational.o
# End MODULE ldb_operational
@@ -64,7 +64,7 @@ OBJ_FILES = \
SUBSYSTEM = LIBLDB
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC
-INIT_FUNCTION = ldb_rdn_name_init
+INIT_FUNCTION = &ldb_rdn_name_module_ops
OBJ_FILES = \
modules/rdn_name.o
# End MODULE ldb_rdn_name
@@ -88,7 +88,7 @@ OBJ_FILES = \
SUBSYSTEM = LIBLDB
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC
-INIT_FUNCTION = ldb_skel_init
+INIT_FUNCTION = &ldb_skel_module_ops
OBJ_FILES = modules/skel.o
# End MODULE ldb_skel
################################################
@@ -99,7 +99,7 @@ OBJ_FILES = modules/skel.o
SUBSYSTEM = LIBLDB
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC SQLITE3 LIBTALLOC
-INIT_FUNCTION = ldb_sqlite3_init
+INIT_FUNCTION = &ldb_sqlite3_module_ops
OBJ_FILES = \
ldb_sqlite3/ldb_sqlite3.o
# End MODULE ldb_sqlite3
@@ -110,7 +110,6 @@ OBJ_FILES = \
[MODULE::ldb_tdb]
SUBSYSTEM = LIBLDB
CFLAGS = -Ilib/ldb/include -Ilib/ldb/ldb_tdb
-INIT_FUNCTION = ldb_tdb_init
OBJ_FILES = \
ldb_tdb/ldb_tdb.o \
ldb_tdb/ldb_search.o \
@@ -128,10 +127,9 @@ PRIVATE_DEPENDENCIES = \
[LIBRARY::LIBLDB]
VERSION = 0.0.1
SO_VERSION = 0
-OUTPUT_TYPE = SHARED_LIBRARY
CFLAGS = -Ilib/ldb/include
PC_FILE = ldb.pc
-INIT_FUNCTION_TYPE = int (*) (void)
+INIT_FUNCTION_TYPE = extern const struct ldb_module_ops
OBJ_FILES = \
common/ldb.o \
common/ldb_ldif.o \
@@ -193,5 +191,5 @@ PRIVATE_DEPENDENCIES = \
################################################
-include tools/config.mk
-include ldb_ildap/config.mk
+mkinclude tools/config.mk
+mkinclude ldb_ildap/config.mk
diff --git a/source4/lib/ldb/configure.ac b/source4/lib/ldb/configure.ac
index 176cef0f3e..4d9444ad10 100644
--- a/source4/lib/ldb/configure.ac
+++ b/source4/lib/ldb/configure.ac
@@ -78,14 +78,18 @@ AC_LIBREPLACE_MDLD_FLAGS
AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
AC_PATH_PROGS([PYTHON_CONFIG], [python2.6-config python2.5-config python2.4-config python-config])
+AC_PATH_PROGS([PYTHON], [python2.6 python2.5 python2.4 python])
PYTHON_BUILD_TARGET="build-python"
PYTHON_INSTALL_TARGET="install-python"
+PYTHON_CHECK_TARGET="check-python"
AC_SUBST(PYTHON_BUILD_TARGET)
AC_SUBST(PYTHON_INSTALL_TARGET)
+AC_SUBST(PYTHON_CHECK_TARGET)
if test -z "$PYTHON_CONFIG"; then
PYTHON_BUILD_TARGET=""
+ PYTHON_CHECK_TARGET=""
PYTHON_INSTALL_TARGET=""
fi
diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h
index d9f2defdc9..d2dcc675a5 100644
--- a/source4/lib/ldb/include/ldb_private.h
+++ b/source4/lib/ldb/include/ldb_private.h
@@ -41,6 +41,8 @@ struct ldb_context;
struct ldb_module_ops;
+struct ldb_backend_ops;
+
/* basic module structure */
struct ldb_module {
struct ldb_module *prev, *next;
@@ -70,9 +72,16 @@ struct ldb_module_ops {
int (*sequence_number)(struct ldb_module *, struct ldb_request *);
};
+
typedef int (*ldb_connect_fn) (struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[],
struct ldb_module **module);
+
+struct ldb_backend_ops {
+ const char *name;
+ ldb_connect_fn connect_fn;
+};
+
const char *ldb_default_modules_dir(void);
/*
@@ -170,17 +179,23 @@ void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level,
/* The following definitions come from lib/ldb/common/ldb_ldif.c */
int ldb_should_b64_encode(const struct ldb_val *val);
-int ldb_objectclass_init(void);
-int ldb_operational_init(void);
-int ldb_paged_results_init(void);
-int ldb_rdn_name_init(void);
-int ldb_schema_init(void);
-int ldb_asq_init(void);
-int ldb_sort_init(void);
-int ldb_ldap_init(void);
-int ldb_ildap_init(void);
-int ldb_tdb_init(void);
-int ldb_sqlite3_init(void);
+extern const struct ldb_module_ops ldb_objectclass_module_ops;
+extern const struct ldb_module_ops ldb_operational_module_ops;
+extern const struct ldb_module_ops ldb_paged_results_module_ops;
+extern const struct ldb_module_ops ldb_rdn_name_module_ops;
+extern const struct ldb_module_ops ldb_schema_module_ops;
+extern const struct ldb_module_ops ldb_asq_module_ops;
+extern const struct ldb_module_ops ldb_sort_module_ops;
+extern const struct ldb_module_ops ldb_ldap_module_ops;
+extern const struct ldb_module_ops ldb_ildap_module_ops;
+extern const struct ldb_module_ops ldb_tdb_module_ops;
+extern const struct ldb_module_ops ldb_sqlite3_module_ops;
+
+extern const struct ldb_backend_ops ldb_tdb_backend_ops;
+extern const struct ldb_backend_ops ldb_sqlite3_backend_ops;
+extern const struct ldb_backend_ops ldb_ldap_backend_ops;
+extern const struct ldb_backend_ops ldb_ildap_backend_ops;
+extern const struct ldb_backend_ops ldb_ldaps_backend_ops;
int ldb_match_msg(struct ldb_context *ldb,
const struct ldb_message *msg,
diff --git a/source4/lib/ldb/ldb.mk b/source4/lib/ldb/ldb.mk
new file mode 100644
index 0000000000..cc920178bc
--- /dev/null
+++ b/source4/lib/ldb/ldb.mk
@@ -0,0 +1,89 @@
+LDB_LIB = $(STATICLIB)
+
+LIB_FLAGS=$(LDFLAGS) -Llib $(LDB_LIB) $(LIBS) $(POPT_LIBS) $(TALLOC_LIBS) \
+ $(TDB_LIBS) $(LDAP_LIBS) $(LIBDL)
+
+LDB_TDB_DIR=ldb_tdb
+LDB_TDB_OBJ=$(LDB_TDB_DIR)/ldb_tdb.o \
+ $(LDB_TDB_DIR)/ldb_pack.o $(LDB_TDB_DIR)/ldb_search.o $(LDB_TDB_DIR)/ldb_index.o \
+ $(LDB_TDB_DIR)/ldb_cache.o $(LDB_TDB_DIR)/ldb_tdb_wrap.o
+
+LDB_MAP_DIR=ldb_map
+LDB_MAP_OBJ=$(LDB_MAP_DIR)/ldb_map.o $(LDB_MAP_DIR)/ldb_map_inbound.o \
+ $(LDB_MAP_DIR)/ldb_map_outbound.o
+
+COMDIR=common
+COMMON_OBJ=$(COMDIR)/ldb.o $(COMDIR)/ldb_ldif.o \
+ $(COMDIR)/ldb_parse.o $(COMDIR)/ldb_msg.o $(COMDIR)/ldb_utf8.o \
+ $(COMDIR)/ldb_debug.o $(COMDIR)/ldb_modules.o \
+ $(COMDIR)/ldb_dn.o $(COMDIR)/ldb_match.o $(COMDIR)/ldb_attributes.o \
+ $(COMDIR)/attrib_handlers.o $(COMDIR)/ldb_controls.o $(COMDIR)/qsort.o
+
+MODDIR=modules
+MODULES_OBJ=$(MODDIR)/operational.o $(MODDIR)/rdn_name.o \
+ $(MODDIR)/paged_results.o $(MODDIR)/sort.o $(MODDIR)/asq.o
+
+NSSDIR=nssldb
+NSS_OBJ= $(NSSDIR)/ldb-nss.o $(NSSDIR)/ldb-pwd.o $(NSSDIR)/ldb-grp.o
+NSS_LIB = lib/libnss_ldb.$(SHLIBEXT).2
+
+lib/libldb.a: $(OBJS)
+ ar -rv $@ $(OBJS)
+ @-ranlib $@
+
+sample.$(SHLIBEXT): tests/sample_module.o
+ $(MDLD) $(MDLD_FLAGS) -o $@ tests/sample_module.o
+
+bin/ldbadd: tools/ldbadd.o tools/cmdline.o $(LIBS)
+ $(CC) -o bin/ldbadd tools/ldbadd.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
+
+bin/ldbsearch: tools/ldbsearch.o tools/cmdline.o $(LIBS)
+ $(CC) -o bin/ldbsearch tools/ldbsearch.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
+
+bin/ldbdel: tools/ldbdel.o tools/cmdline.o $(LIBS)
+ $(CC) -o bin/ldbdel tools/ldbdel.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
+
+bin/ldbmodify: tools/ldbmodify.o tools/cmdline.o $(LIBS)
+ $(CC) -o bin/ldbmodify tools/ldbmodify.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
+
+bin/ldbedit: tools/ldbedit.o tools/cmdline.o $(LIBS)
+ $(CC) -o bin/ldbedit tools/ldbedit.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
+
+bin/ldbrename: tools/ldbrename.o tools/cmdline.o $(LIBS)
+ $(CC) -o bin/ldbrename tools/ldbrename.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
+
+bin/ldbtest: tools/ldbtest.o tools/cmdline.o $(LIBS)
+ $(CC) -o bin/ldbtest tools/ldbtest.o tools/cmdline.o $(LIB_FLAGS) $(LD_EXPORT_DYNAMIC)
+
+bin/oLschema2ldif: tools/oLschema2ldif.o tools/cmdline.o tools/convert.o $(LIBS)
+ $(CC) -o bin/oLschema2ldif tools/oLschema2ldif.o tools/cmdline.o tools/convert.o $(LIB_FLAGS)
+
+examples/ldbreader: examples/ldbreader.o $(LIBS)
+ $(CC) -o examples/ldbreader examples/ldbreader.o $(LIB_FLAGS)
+
+examples/ldifreader: examples/ldifreader.o $(LIBS)
+ $(CC) -o examples/ldifreader examples/ldifreader.o $(LIB_FLAGS)
+
+# Python bindings
+build-python:: _ldb.$(SHLIBEXT)
+
+ldb_wrap.o: $(ldbdir)/ldb_wrap.c
+ $(CC) $(PICFLAG) -c $(ldbdir)/ldb_wrap.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags`
+
+_ldb.$(SHLIBEXT): $(LIBS) ldb_wrap.o
+ $(SHLD) $(SHLD_FLAGS) -o _ldb.$(SHLIBEXT) ldb_wrap.o $(LIB_FLAGS)
+
+install-python:: build-python
+ mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` \
+ $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"`
+ cp $(ldbdir)/ldb.py $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"`
+ cp _ldb.$(SHLIBEXT) $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"`
+
+install-swig::
+ cp ldb.i `$(SWIG) -swiglib`
+
+check-python:: build-python
+ LD_LIBRARY_PATH=lib PYTHONPATH=.:$(ldbdir) $(PYTHON) $(ldbdir)/tests/python/api.py
+
+clean::
+ rm -f _ldb.$(SHLIBEXT)
diff --git a/source4/lib/ldb/ldb_ildap/config.mk b/source4/lib/ldb/ldb_ildap/config.mk
index 01d9ec88ff..3062dc886f 100644
--- a/source4/lib/ldb/ldb_ildap/config.mk
+++ b/source4/lib/ldb/ldb_ildap/config.mk
@@ -5,7 +5,6 @@ SUBSYSTEM = LIBLDB
CFLAGS = -Ilib/ldb/include
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC LIBCLI_LDAP CREDENTIALS
-INIT_FUNCTION = ldb_ildap_init
ALIASES = ldapi ldaps ldap
OBJ_FILES = \
ldb_ildap.o
diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
index a834e912d4..995b584f51 100644
--- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c
+++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
@@ -811,9 +811,18 @@ failed:
return -1;
}
-int ldb_ildap_init(void)
-{
- return ldb_register_backend("ldap", ildb_connect) +
- ldb_register_backend("ldapi", ildb_connect) +
- ldb_register_backend("ldaps", ildb_connect);
-}
+_PUBLIC_ const struct ldb_backend_ops ldb_ldap_backend_ops = {
+ .name = "ldap",
+ .connect_fn = ildb_connect
+};
+
+_PUBLIC_ const struct ldb_backend_ops ldb_ildap_backend_ops = {
+ .name = "ildap",
+ .connect_fn = ildb_connect
+};
+
+_PUBLIC_ const struct ldb_backend_ops ldb_ldaps_backend_ops = {
+ .name = "ldaps",
+ .connect_fn = ildb_connect
+};
+
diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
index d897350c2f..3f6ff3fd5b 100644
--- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c
+++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
@@ -826,9 +826,17 @@ failed:
return -1;
}
-int ldb_ldap_init(void)
-{
- return ldb_register_backend("ldap", lldb_connect) +
- ldb_register_backend("ldapi", lldb_connect) +
- ldb_register_backend("ldaps", lldb_connect);
-}
+_PUBLIC_ struct ldb_backend_ops ldb_ldap_backend_ops = {
+ .name = "ldap",
+ .connect_fn = lldb_connect
+};
+
+_PUBLIC_ struct ldb_backend_ops ldb_ldapi_backend_ops = {
+ .name = "ldapi",
+ .connect_fn = lldb_connect
+};
+
+_PUBLIC_ struct ldb_backend_ops ldb_ldaps_backend_ops = {
+ .name = "ldaps",
+ .connect_fn = lldb_connect
+};
diff --git a/source4/lib/ldb/ldb_map/ldb_map.c b/source4/lib/ldb/ldb_map/ldb_map.c
index 9582f36130..9c189feb11 100644
--- a/source4/lib/ldb/ldb_map/ldb_map.c
+++ b/source4/lib/ldb/ldb_map/ldb_map.c
@@ -1186,7 +1186,7 @@ static int map_wait_all(struct ldb_handle *handle)
}
/* Wait for pending requests to finish. */
-static int map_wait(struct ldb_handle *handle, enum ldb_wait_type type)
+int map_wait(struct ldb_handle *handle, enum ldb_wait_type type)
{
if (type == LDB_WAIT_ALL) {
return map_wait_all(handle);
@@ -1199,16 +1199,6 @@ static int map_wait(struct ldb_handle *handle, enum ldb_wait_type type)
/* Module initialization
* ===================== */
-/* Provided module operations */
-static const struct ldb_module_ops map_ops = {
- .name = "ldb_map",
- .add = map_add,
- .modify = map_modify,
- .del = map_delete,
- .rename = map_rename,
- .search = map_search,
- .wait = map_wait,
-};
/* Builtin mappings for DNs and objectClasses */
static const struct ldb_map_attribute builtin_attribute_maps[] = {
@@ -1344,12 +1334,6 @@ static int map_init_maps(struct ldb_module *module, struct ldb_map_context *data
return LDB_SUCCESS;
}
-/* Copy the list of provided module operations. */
-_PUBLIC_ struct ldb_module_ops ldb_map_get_ops(void)
-{
- return map_ops;
-}
-
/* Initialize global private data. */
_PUBLIC_ int ldb_map_init(struct ldb_module *module, const struct ldb_map_attribute *attrs,
const struct ldb_map_objectclass *ocls,
@@ -1393,23 +1377,3 @@ _PUBLIC_ int ldb_map_init(struct ldb_module *module, const struct ldb_map_attrib
return LDB_SUCCESS;
}
-
-/* Usage note for initialization of this module:
- *
- * ldb_map is meant to be used from a different module that sets up
- * the mappings and gets registered in ldb.
- *
- * 'ldb_map_init' initializes the private data of this module and
- * stores the attribute and objectClass maps in there. It also looks
- * up the '@MAP' special DN so requests can be redirected to the
- * remote partition.
- *
- * This function should be called from the 'init_context' op of the
- * module using ldb_map.
- *
- * 'ldb_map_get_ops' returns a copy of ldb_maps module operations.
- *
- * It should be called from the initialize function of the using
- * module, which should then override the 'init_context' op with a
- * function making the appropriate calls to 'ldb_map_init'.
- */
diff --git a/source4/lib/ldb/ldb_map/ldb_map.h b/source4/lib/ldb/ldb_map/ldb_map.h
index ef4da4e654..e40bb9cd7e 100644
--- a/source4/lib/ldb/ldb_map/ldb_map.h
+++ b/source4/lib/ldb/ldb_map/ldb_map.h
@@ -155,8 +155,19 @@ int ldb_map_init(struct ldb_module *module, const struct ldb_map_attribute *attr
const char *add_objectclass,
const char *name);
-/* get copy of map_ops */
-struct ldb_module_ops
-ldb_map_get_ops(void);
+int map_add(struct ldb_module *module, struct ldb_request *req);
+int map_search(struct ldb_module *module, struct ldb_request *req);
+int map_rename(struct ldb_module *module, struct ldb_request *req);
+int map_delete(struct ldb_module *module, struct ldb_request *req);
+int map_modify(struct ldb_module *module, struct ldb_request *req);
+int map_wait(struct ldb_handle *handle, enum ldb_wait_type type);
+
+#define LDB_MAP_OPS \
+ .add = map_add, \
+ .modify = map_modify, \
+ .del = map_delete, \
+ .rename = map_rename, \
+ .search = map_search, \
+ .wait = map_wait,
#endif /* __LDB_MAP_H__ */
diff --git a/source4/lib/ldb/ldb_map/ldb_map_private.h b/source4/lib/ldb/ldb_map/ldb_map_private.h
index 2c35097069..58a9f2704e 100644
--- a/source4/lib/ldb/ldb_map/ldb_map_private.h
+++ b/source4/lib/ldb/ldb_map/ldb_map_private.h
@@ -98,20 +98,13 @@ int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx,
/* The following definitions come from lib/ldb/modules/ldb_map_inbound.c */
int map_add_do_remote(struct ldb_handle *handle);
int map_add_do_local(struct ldb_handle *handle);
-int map_add(struct ldb_module *module, struct ldb_request *req);
int map_modify_do_remote(struct ldb_handle *handle);
int map_modify_do_local(struct ldb_handle *handle);
-int map_modify(struct ldb_module *module, struct ldb_request *req);
int map_delete_do_remote(struct ldb_handle *handle);
int map_delete_do_local(struct ldb_handle *handle);
-int map_delete(struct ldb_module *module, struct ldb_request *req);
int map_rename_do_remote(struct ldb_handle *handle);
int map_rename_do_fixup(struct ldb_handle *handle);
int map_rename_do_local(struct ldb_handle *handle);
-int map_rename(struct ldb_module *module, struct ldb_request *req);
-
-/* The following definitions come from lib/ldb/modules/ldb_map_outbound.c */
-int map_search(struct ldb_module *module, struct ldb_request *req);
diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
index 1ec3b1aabd..214e7eec5f 100644
--- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
+++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
@@ -1903,7 +1903,7 @@ failed:
return -1;
}
-int ldb_sqlite3_init(void)
-{
- return ldb_register_backend("sqlite3", lsqlite3_connect);
-}
+_PUBLIC_ const struct ldb_backend_ops ldb_sqlite3_backend_ops = {
+ .name = "sqlite3",
+ .connect_fn = lsqlite3_connect
+};
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index 45a8109584..11d6c30710 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -1107,7 +1107,7 @@ static int ltdb_connect(struct ldb_context *ldb, const char *url,
return 0;
}
-int ldb_tdb_init(void)
-{
- return ldb_register_backend("tdb", ltdb_connect);
-}
+const struct ldb_backend_ops ldb_tdb_backend_ops = {
+ .name = "tdb",
+ .connect_fn = ltdb_connect
+};
diff --git a/source4/lib/ldb/modules/asq.c b/source4/lib/ldb/modules/asq.c
index b6a8594166..eb27263b16 100644
--- a/source4/lib/ldb/modules/asq.c
+++ b/source4/lib/ldb/modules/asq.c
@@ -473,15 +473,9 @@ static int asq_init(struct ldb_module *module)
return ldb_next_init(module);
}
-
-static const struct ldb_module_ops asq_ops = {
+const struct ldb_module_ops ldb_asq_module_ops = {
.name = "asq",
.search = asq_search,
.wait = asq_wait,
.init_context = asq_init
};
-
-int ldb_asq_init(void)
-{
- return ldb_register_module(&asq_ops);
-}
diff --git a/source4/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c
index 45f23aa0c1..7dc4ae08c3 100644
--- a/source4/lib/ldb/modules/operational.c
+++ b/source4/lib/ldb/modules/operational.c
@@ -304,13 +304,8 @@ static int operational_init(struct ldb_module *ctx)
return ldb_next_init(ctx);
}
-static const struct ldb_module_ops operational_ops = {
+const struct ldb_module_ops ldb_operational_module_ops = {
.name = "operational",
.search = operational_search,
.init_context = operational_init
};
-
-int ldb_operational_init(void)
-{
- return ldb_register_module(&operational_ops);
-}
diff --git a/source4/lib/ldb/modules/paged_results.c b/source4/lib/ldb/modules/paged_results.c
index ee1bbe0335..b62b1f92cb 100644
--- a/source4/lib/ldb/modules/paged_results.c
+++ b/source4/lib/ldb/modules/paged_results.c
@@ -549,15 +549,9 @@ static int paged_request_init(struct ldb_module *module)
return ldb_next_init(module);
}
-static const struct ldb_module_ops paged_ops = {
+const struct ldb_module_ops ldb_paged_results_module_ops = {
.name = "paged_results",
.search = paged_search,
.wait = paged_wait,
.init_context = paged_request_init
};
-
-int ldb_paged_results_init(void)
-{
- return ldb_register_module(&paged_ops);
-}
-
diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c
index fd580a3c4a..40e87f70d6 100644
--- a/source4/lib/ldb/modules/paged_searches.c
+++ b/source4/lib/ldb/modules/paged_searches.c
@@ -455,15 +455,9 @@ static int ps_init(struct ldb_module *module)
return ldb_next_init(module);
}
-static const struct ldb_module_ops ps_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_paged_searches_module_ops = {
.name = "paged_searches",
.search = ps_search,
.wait = ps_wait,
.init_context = ps_init
};
-
-int ldb_paged_searches_init(void)
-{
- return ldb_register_module(&ps_ops);
-}
-
diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c
index 1a0ddbb3c4..c4de8e8da8 100644
--- a/source4/lib/ldb/modules/rdn_name.c
+++ b/source4/lib/ldb/modules/rdn_name.c
@@ -326,15 +326,9 @@ static int rdn_name_wait(struct ldb_handle *handle, enum ldb_wait_type type)
return rdn_name_wait_once(handle);
}
-static const struct ldb_module_ops rdn_name_ops = {
+const struct ldb_module_ops ldb_rdn_name_module_ops = {
.name = "rdn_name",
.add = rdn_name_add,
.rename = rdn_name_rename,
.wait = rdn_name_wait
};
-
-
-int ldb_rdn_name_init(void)
-{
- return ldb_register_module(&rdn_name_ops);
-}
diff --git a/source4/lib/ldb/modules/skel.c b/source4/lib/ldb/modules/skel.c
index 5400c502f1..0cd29ac4b7 100644
--- a/source4/lib/ldb/modules/skel.c
+++ b/source4/lib/ldb/modules/skel.c
@@ -116,7 +116,7 @@ static int skel_init(struct ldb_module *module)
return ldb_next_init(module);
}
-static const struct ldb_module_ops skel_ops = {
+const struct ldb_module_ops ldb_skel_module_ops = {
.name = "skel",
.init_context = skel_init,
.search = skel_search,
@@ -129,8 +129,3 @@ static const struct ldb_module_ops skel_ops = {
.end_transaction = skel_end_trans,
.del_transaction = skel_del_trans,
};
-
-int ldb_skel_init(void)
-{
- return ldb_register_module(&skel_ops);
-}
diff --git a/source4/lib/ldb/modules/sort.c b/source4/lib/ldb/modules/sort.c
index 89b9a4fb19..746befa559 100644
--- a/source4/lib/ldb/modules/sort.c
+++ b/source4/lib/ldb/modules/sort.c
@@ -450,14 +450,9 @@ static int server_sort_init(struct ldb_module *module)
return ldb_next_init(module);
}
-static const struct ldb_module_ops server_sort_ops = {
+const struct ldb_module_ops ldb_server_sort_module_ops = {
.name = "server_sort",
.search = server_sort_search,
.wait = server_sort_wait,
.init_context = server_sort_init
};
-
-int ldb_sort_init(void)
-{
- return ldb_register_module(&server_sort_ops);
-}
diff --git a/source4/lib/ldb/nssldb/ldb-nss.c b/source4/lib/ldb/nssldb/ldb-nss.c
index 199212dbbf..e256f41a4d 100644
--- a/source4/lib/ldb/nssldb/ldb-nss.c
+++ b/source4/lib/ldb/nssldb/ldb-nss.c
@@ -45,11 +45,6 @@ NSS_STATUS _ldb_nss_init(void)
_ldb_nss_ctx->pid = mypid;
- ret = ldb_global_init();
- if (ret != 0) {
- goto failed;
- }
-
_ldb_nss_ctx->ldb = ldb_init(_ldb_nss_ctx);
if (_ldb_nss_ctx->ldb == NULL) {
goto failed;
diff --git a/source4/lib/ldb/rules.mk b/source4/lib/ldb/rules.mk
new file mode 100644
index 0000000000..534ba016ab
--- /dev/null
+++ b/source4/lib/ldb/rules.mk
@@ -0,0 +1,30 @@
+etags:
+ etags `find $(srcdir) -name "*.[ch]"`
+
+ctags:
+ ctags `find $(srcdir) -name "*.[ch]"`
+
+.SUFFIXES: _wrap.c .i
+
+.i_wrap.c:
+ [ "$(SWIG)" == "no" ] || $(SWIG) -O -Wall -python -keyword $<
+
+.SUFFIXES: .1 .1.xml .3 .3.xml .xml .html .c .o
+
+.c.o:
+ @echo Compiling $*.c
+ @mkdir -p `dirname $@`
+ @$(CC) $(CFLAGS) $(PICFLAG) -c $< -o $@
+
+.c.po:
+ @echo Compiling $*.c
+ @mkdir -p `dirname $@`
+ @$(CC) -fPIC $(CFLAGS) -c $< -o $@
+
+showflags::
+ @echo 'ldb will be compiled with flags:'
+ @echo ' CFLAGS = $(CFLAGS)'
+ @echo ' LIBS = $(LIBS)'
+
+distclean::
+ rm -f *~ */*~
diff --git a/source4/lib/ldb/setup.py b/source4/lib/ldb/setup.py
deleted file mode 100755
index b04f3b09f1..0000000000
--- a/source4/lib/ldb/setup.py
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/python
-from distutils.core import setup
-from distutils.extension import Extension
-
-setup(name="ldb",
- version="1.0",
- url="http://ldb.samba.org/",
- author="LDB Developers",
- author_email="ldb@samba.org",
- license="LGPLv3",
- keywords=["ldap","ldb","db","ldif"],
- py_modules=["ldb"],
- ext_modules=[Extension('_ldb', ['ldb_wrap.c'], include_dirs=['include'],
- library_dirs=["lib"], libraries=['ldb'])],
- )
diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py
index d5346c30b0..5f3f727b5d 100755
--- a/source4/lib/ldb/tests/python/api.py
+++ b/source4/lib/ldb/tests/python/api.py
@@ -418,3 +418,6 @@ class ModuleTests(unittest.TestCase):
def test_register_module(self):
ldb.register_module(ExampleModule())
+if __name__ == '__main__':
+ import unittest
+ unittest.TestProgram()
diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py
index a425ddc830..f75bb8124d 100755
--- a/source4/lib/ldb/tests/python/ldap.py
+++ b/source4/lib/ldb/tests/python/ldap.py
@@ -6,17 +6,17 @@ import getopt
import optparse
import sys
-# Add path to the library for in-tree use
-sys.path.append("scripting/python")
import samba.getopt as options
from auth import system_session
from ldb import (SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, LdbError,
LDB_ERR_NO_SUCH_OBJECT, LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS,
LDB_ERR_ENTRY_ALREADY_EXISTS, LDB_ERR_UNWILLING_TO_PERFORM,
- LDB_ERR_NOT_ALLOWED_ON_NON_LEAF)
+ LDB_ERR_NOT_ALLOWED_ON_NON_LEAF, LDB_ERR_OTHER)
from samba import Ldb
+from subunit import SubunitTestRunner
import param
+import unittest
parser = optparse.OptionParser("ldap [options] <host>")
sambaopts = options.SambaOptions(parser)
@@ -36,122 +36,122 @@ host = args[0]
lp = sambaopts.get_loadparm()
-def delete_force(ldb, dn):
- try:
- ldb.delete(dn)
- except LdbError, (num, _):
- if num != LDB_ERR_NO_SUCH_OBJECT:
- assert False
-
-def assertEquals(a1, a2):
- assert a1 == a2, "Expected %r == %r" % (a1, a2)
+class BasicTests(unittest.TestCase):
+ def delete_force(self, ldb, dn):
+ try:
+ ldb.delete(dn)
+ except LdbError, (num, _):
+ self.assertEquals(num, LDB_ERR_NO_SUCH_OBJECT)
+
+ def find_basedn(self, ldb):
+ res = ldb.search(base="", expression="", scope=SCOPE_BASE,
+ attrs=["defaultNamingContext"])
+ self.assertEquals(len(res), 1)
+ return res[0]["defaultNamingContext"][0]
+
+ def find_configurationdn(self, ldb):
+ res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["configurationNamingContext"])
+ self.assertEquals(len(res), 1)
+ return res[0]["configurationNamingContext"][0]
+
+ def find_schemadn(self, ldb):
+ res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["schemaNamingContext"])
+ self.assertEquals(len(res), 1)
+ return res[0]["schemaNamingContext"][0]
+
+ def setUp(self):
+ self.ldb = ldb
+ self.gc_ldb = gc_ldb
+ self.base_dn = self.find_basedn(ldb)
+ self.configuration_dn = self.find_configurationdn(ldb)
+ self.schema_dn = self.find_schemadn(ldb)
+
+ print "baseDN: %s\n" % self.base_dn
+
+ self.delete_force(self.ldb, "cn=ldaptestuser,cn=users," + self.base_dn)
+ self.delete_force(self.ldb, "cn=ldaptestgroup,cn=users," + self.base_dn)
+
+ def test_group_add_invalid_member(self):
+ """Testing group add with invalid member"""
+ try:
+ self.ldb.add({
+ "dn": "cn=ldaptestgroup,cn=uSers," + self.base_dn,
+ "objectclass": "group",
+ "member": "cn=ldaptestuser,cn=useRs," + self.base_dn})
+ self.fail()
+ except LdbError, (num, _):
+ self.assertEquals(num, LDB_ERR_NO_SUCH_OBJECT)
-def basic_tests(ldb, gc_ldb, base_dn, configuration_dn, schema_dn):
- print "Running basic tests"
+ def test_all(self):
+ """Basic tests"""
- delete_force(ldb, "cn=ldaptestuser,cn=users," + base_dn)
- delete_force(ldb, "cn=ldaptestgroup,cn=users," + base_dn)
+ self.delete_force(self.ldb, "cn=ldaptestuser,cn=users," + self.base_dn)
- print "Testing group add with invalid member"
- try:
- ldb.add({
- "dn": "cn=ldaptestgroup,cn=uSers," + base_dn,
- "objectclass": "group",
- "member": "cn=ldaptestuser,cn=useRs," + base_dn})
- except LdbError, (num, _):
- if num != LDB_ERR_NO_SUCH_OBJECT:
- assert False
- else:
- assert False
-
- print "Testing user add"
- try:
+ print "Testing user add"
ldb.add({
- "dn": "cn=ldaptestuser,cn=uSers," + base_dn,
+ "dn": "cn=ldaptestuser,cn=uSers," + self.base_dn,
"objectclass": ["user", "person"],
"cN": "LDAPtestUSER",
"givenname": "ldap",
"sn": "testy"})
- except LdbError:
- ldb.delete("cn=ldaptestuser,cn=users," + base_dn)
- ldb.add({
- "dn": "cn=ldaptestuser,cn=uSers," + base_dn,
- "objectclass": ["user", "person"],
- "cN": "LDAPtestUSER",
- "givenname": "ldap",
- "sn": "testy"})
-
- ldb.add({
- "dn": "cn=ldaptestgroup,cn=uSers," + base_dn,
- "objectclass": "group",
- "member": "cn=ldaptestuser,cn=useRs," + base_dn})
-
- try:
- ldb.add({
- "dn": "cn=ldaptestcomputer,cn=computers," + base_dn,
- "objectclass": "computer",
- "cN": "LDAPtestCOMPUTER"})
- except LdbError:
- ldb.delete("cn=ldaptestcomputer,cn=computers," + base_dn)
+
ldb.add({
- "dn": "cn=ldaptestcomputer,cn=computers," + base_dn,
- "objectClass": "computer",
- "cn": "LDAPtestCOMPUTER"})
-
- try:
- ldb.add({"dn": "cn=ldaptest2computer,cn=computers," + base_dn,
- "objectClass": "computer",
- "cn": "LDAPtest2COMPUTER",
- "userAccountControl": "4096",
- "displayname": "ldap testy"})
- except LdbError:
- ldb.delete("cn=ldaptest2computer,cn=computers," + base_dn)
+ "dn": "cn=ldaptestgroup,cn=uSers," + self.base_dn,
+ "objectclass": "group",
+ "member": "cn=ldaptestuser,cn=useRs," + self.base_dn})
+
+ self.delete_force(ldb, "cn=ldaptestcomputer,cn=computers," + self.base_dn)
ldb.add({
- "dn": "cn=ldaptest2computer,cn=computers," + base_dn,
+ "dn": "cn=ldaptestcomputer,cn=computers," + self.base_dn,
+ "objectclass": "computer",
+ "cN": "LDAPtestCOMPUTER"})
+
+ self.delete_force(self.ldb, "cn=ldaptest2computer,cn=computers," + self.base_dn)
+ ldb.add({"dn": "cn=ldaptest2computer,cn=computers," + self.base_dn,
"objectClass": "computer",
"cn": "LDAPtest2COMPUTER",
"userAccountControl": "4096",
"displayname": "ldap testy"})
- print "Testing attribute or value exists behaviour"
- try:
- ldb.modify_ldif("""
-dn: cn=ldaptest2computer,cn=computers,""" + base_dn + """
+ print "Testing attribute or value exists behaviour"
+ try:
+ ldb.modify_ldif("""
+dn: cn=ldaptest2computer,cn=computers,""" + self.base_dn + """
changetype: modify
replace: servicePrincipalName
servicePrincipalName: host/ldaptest2computer
servicePrincipalName: host/ldaptest2computer
servicePrincipalName: cifs/ldaptest2computer
""")
- except LdbError, (num, msg):
- assert num == LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS
+ except LdbError, (num, msg):
+ self.assertEquals(num, LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS)
- ldb.modify_ldif("""
-dn: cn=ldaptest2computer,cn=computers,""" + base_dn + """
+ ldb.modify_ldif("""
+dn: cn=ldaptest2computer,cn=computers,""" + self.base_dn + """
changetype: modify
replace: servicePrincipalName
servicePrincipalName: host/ldaptest2computer
servicePrincipalName: cifs/ldaptest2computer
""")
- try:
- ldb.modify_ldif("""
-dn: cn=ldaptest2computer,cn=computers,""" + base_dn + """
+ try:
+ ldb.modify_ldif("""
+dn: cn=ldaptest2computer,cn=computers,""" + self.base_dn + """
changetype: modify
add: servicePrincipalName
servicePrincipalName: host/ldaptest2computer
""")
- except LdbError, (num, msg):
- assert num == LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS
-
- print "Testing ranged results"
- ldb.modify_ldif("""
-dn: cn=ldaptest2computer,cn=computers,""" + base_dn + """
+ except LdbError, (num, msg):
+ self.assertEquals(num, LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS)
+
+ print "Testing ranged results"
+ ldb.modify_ldif("""
+dn: cn=ldaptest2computer,cn=computers,""" + self.base_dn + """
changetype: modify
replace: servicePrincipalName
""")
-
- ldb.modify_ldif("""
-dn: cn=ldaptest2computer,cn=computers,""" + base_dn + """
+
+ ldb.modify_ldif("""
+dn: cn=ldaptest2computer,cn=computers,""" + self.base_dn + """
changetype: modify
add: servicePrincipalName
servicePrincipalName: host/ldaptest2computer0
@@ -186,730 +186,685 @@ servicePrincipalName: host/ldaptest2computer28
servicePrincipalName: host/ldaptest2computer29
""")
- res = ldb.search(base_dn, expression="(cn=ldaptest2computer))", scope=SCOPE_SUBTREE,
- attrs=["servicePrincipalName;range=0-*"])
- assert len(res) == 1, "Could not find (cn=ldaptest2computer)"
- #print len(res[0]["servicePrincipalName;range=0-*"])
- assertEquals(len(res[0]["servicePrincipalName;range=0-*"]), 30)
-
- res = ldb.search(base_dn, expression="(cn=ldaptest2computer))", scope=SCOPE_SUBTREE, attrs=["servicePrincipalName;range=0-19"])
- assert len(res) == 1, "Could not find (cn=ldaptest2computer)"
-# print res[0]["servicePrincipalName;range=0-19"].length
- assertEquals(len(res[0]["servicePrincipalName;range=0-19"]), 20)
-
-
- res = ldb.search(base_dn, expression="(cn=ldaptest2computer))", scope=SCOPE_SUBTREE, attrs=["servicePrincipalName;range=0-30"])
- assert len(res) == 1, "Could not find (cn=ldaptest2computer)"
- assertEquals(len(res[0]["servicePrincipalName;range=0-*"]), 30)
-
- res = ldb.search(base_dn, expression="(cn=ldaptest2computer))", scope=SCOPE_SUBTREE, attrs=["servicePrincipalName;range=0-40"])
- assert len(res) == 1, "Could not find (cn=ldaptest2computer)"
- assertEquals(len(res[0]["servicePrincipalName;range=0-*"]), 30)
-
- res = ldb.search(base_dn, expression="(cn=ldaptest2computer))", scope=SCOPE_SUBTREE, attrs=["servicePrincipalName;range=30-40"])
- assert len(res) == 1, "Could not find (cn=ldaptest2computer)"
- assertEquals(len(res[0]["servicePrincipalName;range=30-*"]), 0)
-
-
- res = ldb.search(base_dn, expression="(cn=ldaptest2computer))", scope=SCOPE_SUBTREE, attrs=["servicePrincipalName;range=10-40"])
- assert len(res) == 1, "Could not find (cn=ldaptest2computer)"
- assertEquals(len(res[0]["servicePrincipalName;range=10-*"]), 20)
-# pos_11 = res[0]["servicePrincipalName;range=10-*"][18]
-
- res = ldb.search(base_dn, expression="(cn=ldaptest2computer))", scope=SCOPE_SUBTREE, attrs=["servicePrincipalName;range=11-40"])
- assert len(res) == 1, "Could not find (cn=ldaptest2computer)"
- assertEquals(len(res[0]["servicePrincipalName;range=11-*"]), 19)
-# print res[0]["servicePrincipalName;range=11-*"][18]
-# print pos_11
-# assertEquals((res[0]["servicePrincipalName;range=11-*"][18]), pos_11)
-
- res = ldb.search(base_dn, expression="(cn=ldaptest2computer))", scope=SCOPE_SUBTREE, attrs=["servicePrincipalName;range=11-15"])
- assert len(res) == 1, "Could not find (cn=ldaptest2computer)"
- assertEquals(len(res[0]["servicePrincipalName;range=11-15"]), 5)
-# assertEquals(res[0]["servicePrincipalName;range=11-15"][4], pos_11)
-
- res = ldb.search(base_dn, expression="(cn=ldaptest2computer))", scope=SCOPE_SUBTREE, attrs=["servicePrincipalName"])
- assert len(res) == 1, "Could not find (cn=ldaptest2computer)"
-# print res[0]["servicePrincipalName"][18]
-# print pos_11
- assertEquals(len(res[0]["servicePrincipalName"]), 30)
-# assertEquals(res[0]["servicePrincipalName"][18], pos_11)
-
- try:
+ res = ldb.search(self.base_dn, expression="(cn=ldaptest2computer))", scope=SCOPE_SUBTREE,
+ attrs=["servicePrincipalName;range=0-*"])
+ self.assertEquals(len(res), 1, "Could not find (cn=ldaptest2computer)")
+ #print len(res[0]["servicePrincipalName;range=0-*"])
+ self.assertEquals(len(res[0]["servicePrincipalName;range=0-*"]), 30)
+
+ res = ldb.search(self.base_dn, expression="(cn=ldaptest2computer))", scope=SCOPE_SUBTREE, attrs=["servicePrincipalName;range=0-19"])
+ self.assertEquals(len(res), 1, "Could not find (cn=ldaptest2computer)")
+ # print res[0]["servicePrincipalName;range=0-19"].length
+ self.assertEquals(len(res[0]["servicePrincipalName;range=0-19"]), 20)
+
+
+ res = ldb.search(self.base_dn, expression="(cn=ldaptest2computer))", scope=SCOPE_SUBTREE, attrs=["servicePrincipalName;range=0-30"])
+ self.assertEquals(len(res), 1, "Could not find (cn=ldaptest2computer)")
+ self.assertEquals(len(res[0]["servicePrincipalName;range=0-*"]), 30)
+
+ res = ldb.search(self.base_dn, expression="(cn=ldaptest2computer))", scope=SCOPE_SUBTREE, attrs=["servicePrincipalName;range=0-40"])
+ self.assertEquals(len(res), 1, "Could not find (cn=ldaptest2computer)")
+ self.assertEquals(len(res[0]["servicePrincipalName;range=0-*"]), 30)
+
+ res = ldb.search(self.base_dn, expression="(cn=ldaptest2computer))", scope=SCOPE_SUBTREE, attrs=["servicePrincipalName;range=30-40"])
+ self.assertEquals(len(res), 1, "Could not find (cn=ldaptest2computer)")
+ self.assertEquals(len(res[0]["servicePrincipalName;range=30-*"]), 0)
+
+
+ res = ldb.search(self.base_dn, expression="(cn=ldaptest2computer))", scope=SCOPE_SUBTREE, attrs=["servicePrincipalName;range=10-40"])
+ self.assertEquals(len(res), 1, "Could not find (cn=ldaptest2computer)")
+ self.assertEquals(len(res[0]["servicePrincipalName;range=10-*"]), 20)
+ # pos_11 = res[0]["servicePrincipalName;range=10-*"][18]
+
+ res = ldb.search(self.base_dn, expression="(cn=ldaptest2computer))", scope=SCOPE_SUBTREE, attrs=["servicePrincipalName;range=11-40"])
+ self.assertEquals(len(res), 1, "Could not find (cn=ldaptest2computer)")
+ self.assertEquals(len(res[0]["servicePrincipalName;range=11-*"]), 19)
+ # print res[0]["servicePrincipalName;range=11-*"][18]
+ # print pos_11
+ # self.assertEquals((res[0]["servicePrincipalName;range=11-*"][18]), pos_11)
+
+ res = ldb.search(self.base_dn, expression="(cn=ldaptest2computer))", scope=SCOPE_SUBTREE, attrs=["servicePrincipalName;range=11-15"])
+ self.assertEquals(len(res), 1, "Could not find (cn=ldaptest2computer)")
+ self.assertEquals(len(res[0]["servicePrincipalName;range=11-15"]), 5)
+ # self.assertEquals(res[0]["servicePrincipalName;range=11-15"][4], pos_11)
+
+ res = ldb.search(self.base_dn, expression="(cn=ldaptest2computer))", scope=SCOPE_SUBTREE, attrs=["servicePrincipalName"])
+ self.assertEquals(len(res), 1, "Could not find (cn=ldaptest2computer)")
+ # print res[0]["servicePrincipalName"][18]
+ # print pos_11
+ self.assertEquals(len(res[0]["servicePrincipalName"]), 30)
+ # self.assertEquals(res[0]["servicePrincipalName"][18], pos_11)
+
+ self.delete_force(self.ldb, "cn=ldaptestuser2,cn=users," + self.base_dn)
ldb.add({
- "dn": "cn=ldaptestuser2,cn=useRs," + base_dn,
- "objectClass": ["person", "user"],
- "cn": "LDAPtestUSER2",
- "givenname": "testy",
- "sn": "ldap user2"})
- except LdbError:
- ldb.delete("cn=ldaptestuser2,cn=users," + base_dn)
- ldb.add({
- "dn": "cn=ldaptestuser2,cn=useRs," + base_dn,
- "objectClass": ["person", "user"],
- "cn": "LDAPtestUSER2",
- "givenname": "testy",
- "sn": "ldap user2"})
-
- print "Testing Ambigious Name Resolution"
-# Testing ldb.search for (&(anr=ldap testy)(objectClass=user))
- res = ldb.search(expression="(&(anr=ldap testy)(objectClass=user))")
- assert len(res) == 3, "Could not find (&(anr=ldap testy)(objectClass=user))"
-
-# Testing ldb.search for (&(anr=testy ldap)(objectClass=user))
- res = ldb.search(expression="(&(anr=testy ldap)(objectClass=user))")
- assert len(res) == 2, "Found only %d for (&(anr=testy ldap)(objectClass=user))" % len(res)
-
-# Testing ldb.search for (&(anr=ldap)(objectClass=user))
- res = ldb.search(expression="(&(anr=ldap)(objectClass=user))")
- assert len(res) == 4, "Found only %d for (&(anr=ldap)(objectClass=user))" % len(res)
-
-# Testing ldb.search for (&(anr==ldap)(objectClass=user))
- res = ldb.search(expression="(&(anr==ldap)(objectClass=user))")
- assert len(res) == 1, "Could not find (&(anr==ldap)(objectClass=user)). Found only %d for (&(anr=ldap)(objectClass=user))" % len(res)
-
- assertEquals(str(res[0].dn), ("CN=ldaptestuser,CN=Users," + base_dn))
- assertEquals(res[0]["cn"][0], "ldaptestuser")
- assertEquals(res[0]["name"], "ldaptestuser")
-
-# Testing ldb.search for (&(anr=testy)(objectClass=user))
- res = ldb.search(expression="(&(anr=testy)(objectClass=user))")
- assert len(res) == 2, "Found only %d for (&(anr=testy)(objectClass=user))" % len(res)
-
-# Testing ldb.search for (&(anr=ldap testy)(objectClass=user))
- res = ldb.search(expression="(&(anr=testy ldap)(objectClass=user))")
- assert len(res) == 2, "Found only %d for (&(anr=ldap testy)(objectClass=user))" % len(res)
-
-# Testing ldb.search for (&(anr==ldap testy)(objectClass=user))
- res = ldb.search(expression="(&(anr==testy ldap)(objectClass=user))")
- assert len(res) == 1, "Found only %d for (&(anr==ldap testy)(objectClass=user))" % len(res)
-
- assertEquals(str(res[0].dn), ("CN=ldaptestuser,CN=Users," + base_dn))
- assertEquals(res[0]["cn"][0], "ldaptestuser")
- assertEquals(res[0]["name"][0], "ldaptestuser")
-
-# Testing ldb.search for (&(anr==testy ldap)(objectClass=user))
- res = ldb.search(expression="(&(anr==testy ldap)(objectClass=user))")
- assert len(res) == 1, "Could not find (&(anr==testy ldap)(objectClass=user))"
-
- assertEquals(str(res[0].dn), ("CN=ldaptestuser,CN=Users," + base_dn))
- assertEquals(res[0]["cn"][0], "ldaptestuser")
- assertEquals(res[0]["name"][0], "ldaptestuser")
-
- # Testing ldb.search for (&(anr=testy ldap user)(objectClass=user))
- res = ldb.search(expression="(&(anr=testy ldap user)(objectClass=user))")
- assert len(res) == 1, "Could not find (&(anr=testy ldap user)(objectClass=user))"
-
- assertEquals(str(res[0].dn), ("CN=ldaptestuser2,CN=Users," + base_dn))
- assertEquals(res[0]["cn"], "ldaptestuser2")
- assertEquals(res[0]["name"], "ldaptestuser2")
-
- # Testing ldb.search for (&(anr==testy ldap user2)(objectClass=user))
- res = ldb.search(expression="(&(anr==testy ldap user2)(objectClass=user))")
- assert len(res) == 1, "Could not find (&(anr==testy ldap user2)(objectClass=user))"
-
- assertEquals(str(res[0].dn), ("CN=ldaptestuser2,CN=Users," + base_dn))
- assertEquals(res[0]["cn"], "ldaptestuser2")
- assertEquals(res[0]["name"], "ldaptestuser2")
-
- # Testing ldb.search for (&(anr==ldap user2)(objectClass=user))
- res = ldb.search(expression="(&(anr==ldap user2)(objectClass=user))")
- assert len(res) == 1, "Could not find (&(anr==ldap user2)(objectClass=user))"
-
- assertEquals(str(res[0].dn), ("CN=ldaptestuser2,CN=Users," + base_dn))
- assertEquals(res[0]["cn"], "ldaptestuser2")
- assertEquals(res[0]["name"], "ldaptestuser2")
-
- # Testing ldb.search for (&(anr==not ldap user2)(objectClass=user))
- res = ldb.search(expression="(&(anr==not ldap user2)(objectClass=user))")
- assert len(res) == 0, "Must not find (&(anr==not ldap user2)(objectClass=user))"
-
- # Testing ldb.search for (&(anr=not ldap user2)(objectClass=user))
- res = ldb.search(expression="(&(anr=not ldap user2)(objectClass=user))")
- assert len(res) == 0, "Must not find (&(anr=not ldap user2)(objectClass=user))"
-
- print "Testing Group Modifies"
- ldb.modify_ldif("""
-dn: cn=ldaptestgroup,cn=users,""" + base_dn + """
+ "dn": "cn=ldaptestuser2,cn=useRs," + self.base_dn,
+ "objectClass": ["person", "user"],
+ "cn": "LDAPtestUSER2",
+ "givenname": "testy",
+ "sn": "ldap user2"})
+
+ print "Testing Ambigious Name Resolution"
+ # Testing ldb.search for (&(anr=ldap testy)(objectClass=user))
+ res = ldb.search(expression="(&(anr=ldap testy)(objectClass=user))")
+ self.assertEquals(len(res), 3, "Could not find (&(anr=ldap testy)(objectClass=user))")
+
+ # Testing ldb.search for (&(anr=testy ldap)(objectClass=user))
+ res = ldb.search(expression="(&(anr=testy ldap)(objectClass=user))")
+ self.assertEquals(len(res), 2, "Found only %d for (&(anr=testy ldap)(objectClass=user))" % len(res))
+
+ # Testing ldb.search for (&(anr=ldap)(objectClass=user))
+ res = ldb.search(expression="(&(anr=ldap)(objectClass=user))")
+ self.assertEquals(len(res), 4, "Found only %d for (&(anr=ldap)(objectClass=user))" % len(res))
+
+ # Testing ldb.search for (&(anr==ldap)(objectClass=user))
+ res = ldb.search(expression="(&(anr==ldap)(objectClass=user))")
+ self.assertEquals(len(res), 1, "Could not find (&(anr==ldap)(objectClass=user)). Found only %d for (&(anr=ldap)(objectClass=user))" % len(res))
+
+ self.assertEquals(str(res[0].dn), ("CN=ldaptestuser,CN=Users," + self.base_dn))
+ self.assertEquals(res[0]["cn"][0], "ldaptestuser")
+ self.assertEquals(res[0]["name"], "ldaptestuser")
+
+ # Testing ldb.search for (&(anr=testy)(objectClass=user))
+ res = ldb.search(expression="(&(anr=testy)(objectClass=user))")
+ self.assertEquals(len(res), 2, "Found only %d for (&(anr=testy)(objectClass=user))" % len(res))
+
+ # Testing ldb.search for (&(anr=ldap testy)(objectClass=user))
+ res = ldb.search(expression="(&(anr=testy ldap)(objectClass=user))")
+ self.assertEquals(len(res), 2, "Found only %d for (&(anr=ldap testy)(objectClass=user))" % len(res))
+
+ # Testing ldb.search for (&(anr==ldap testy)(objectClass=user))
+ res = ldb.search(expression="(&(anr==testy ldap)(objectClass=user))")
+ self.assertEquals(len(res), 1, "Found only %d for (&(anr==ldap testy)(objectClass=user))" % len(res))
+
+ self.assertEquals(str(res[0].dn), ("CN=ldaptestuser,CN=Users," + self.base_dn))
+ self.assertEquals(res[0]["cn"][0], "ldaptestuser")
+ self.assertEquals(res[0]["name"][0], "ldaptestuser")
+
+ # Testing ldb.search for (&(anr==testy ldap)(objectClass=user))
+ res = ldb.search(expression="(&(anr==testy ldap)(objectClass=user))")
+ self.assertEquals(len(res), 1, "Could not find (&(anr==testy ldap)(objectClass=user))")
+
+ self.assertEquals(str(res[0].dn), ("CN=ldaptestuser,CN=Users," + self.base_dn))
+ self.assertEquals(res[0]["cn"][0], "ldaptestuser")
+ self.assertEquals(res[0]["name"][0], "ldaptestuser")
+
+ # Testing ldb.search for (&(anr=testy ldap user)(objectClass=user))
+ res = ldb.search(expression="(&(anr=testy ldap user)(objectClass=user))")
+ self.assertEquals(len(res), 1, "Could not find (&(anr=testy ldap user)(objectClass=user))")
+
+ self.assertEquals(str(res[0].dn), ("CN=ldaptestuser2,CN=Users," + self.base_dn))
+ self.assertEquals(res[0]["cn"], "ldaptestuser2")
+ self.assertEquals(res[0]["name"], "ldaptestuser2")
+
+ # Testing ldb.search for (&(anr==testy ldap user2)(objectClass=user))
+ res = ldb.search(expression="(&(anr==testy ldap user2)(objectClass=user))")
+ self.assertEquals(len(res), 1, "Could not find (&(anr==testy ldap user2)(objectClass=user))")
+
+ self.assertEquals(str(res[0].dn), ("CN=ldaptestuser2,CN=Users," + self.base_dn))
+ self.assertEquals(res[0]["cn"], "ldaptestuser2")
+ self.assertEquals(res[0]["name"], "ldaptestuser2")
+
+ # Testing ldb.search for (&(anr==ldap user2)(objectClass=user))
+ res = ldb.search(expression="(&(anr==ldap user2)(objectClass=user))")
+ self.assertEquals(len(res), 1, "Could not find (&(anr==ldap user2)(objectClass=user))")
+
+ self.assertEquals(str(res[0].dn), ("CN=ldaptestuser2,CN=Users," + self.base_dn))
+ self.assertEquals(res[0]["cn"], "ldaptestuser2")
+ self.assertEquals(res[0]["name"], "ldaptestuser2")
+
+ # Testing ldb.search for (&(anr==not ldap user2)(objectClass=user))
+ res = ldb.search(expression="(&(anr==not ldap user2)(objectClass=user))")
+ self.assertEquals(len(res), 0, "Must not find (&(anr==not ldap user2)(objectClass=user))")
+
+ # Testing ldb.search for (&(anr=not ldap user2)(objectClass=user))
+ res = ldb.search(expression="(&(anr=not ldap user2)(objectClass=user))")
+ self.assertEquals(len(res), 0, "Must not find (&(anr=not ldap user2)(objectClass=user))")
+
+ print "Testing Group Modifies"
+ ldb.modify_ldif("""
+dn: cn=ldaptestgroup,cn=users,""" + self.base_dn + """
changetype: modify
add: member
-member: cn=ldaptestuser2,cn=users,""" + base_dn + """
-member: cn=ldaptestcomputer,cn=computers,""" + base_dn + """
+member: cn=ldaptestuser2,cn=users,""" + self.base_dn + """
+member: cn=ldaptestcomputer,cn=computers,""" + self.base_dn + """
""")
- delete_force(ldb, "cn=ldaptestuser3,cn=users," + base_dn)
+ self.delete_force(ldb, "cn=ldaptestuser3,cn=users," + self.base_dn)
- print "Testing adding non-existent user to a group"
- try:
- ldb.modify_ldif("""
-dn: cn=ldaptestgroup,cn=users,""" + base_dn + """
+ print "Testing adding non-existent user to a group"
+ try:
+ ldb.modify_ldif("""
+dn: cn=ldaptestgroup,cn=users,""" + self.base_dn + """
changetype: modify
add: member
-member: cn=ldaptestuser3,cn=users,""" + base_dn + """
+member: cn=ldaptestuser3,cn=users,""" + self.base_dn + """
""")
- except LdbError, (num, _):
- assert num == LDB_ERR_NO_SUCH_OBJECT
- else:
- assert False
-
- print "Testing Renames"
-
- ldb.rename("cn=ldaptestuser2,cn=users," + base_dn, "cn=ldaptestuser3,cn=users," + base_dn)
-
- ldb.rename("cn=ldaptestuser3,cn=users," + base_dn, "cn=ldaptestuser3,cn=users," + base_dn)
-
- ldb.rename("cn=ldaptestuser3,cn=users," + base_dn, "cn=ldaptestUSER3,cn=users," + base_dn)
-
- print "Testing ldb.search for (&(cn=ldaptestuser3)(objectClass=user))"
- res = ldb.search(expression="(&(cn=ldaptestuser3)(objectClass=user))")
- assert len(res) == 1, "Could not find (&(cn=ldaptestuser3)(objectClass=user))"
-
- assertEquals(str(res[0].dn), ("CN=ldaptestUSER3,CN=Users," + base_dn))
- assertEquals(res[0]["cn"], "ldaptestUSER3")
- assertEquals(res[0]["name"], "ldaptestUSER3")
-
-# This is a Samba special, and does not exist in real AD
-# print "Testing ldb.search for (dn=CN=ldaptestUSER3,CN=Users," + base_dn + ")"
-# res = ldb.search("(dn=CN=ldaptestUSER3,CN=Users," + base_dn + ")")
-# if (res.error != 0 || len(res) != 1) {
-# print "Could not find (dn=CN=ldaptestUSER3,CN=Users," + base_dn + ")"
-# assertEquals(len(res), 1)
-# }
-# assertEquals(res[0].dn, ("CN=ldaptestUSER3,CN=Users," + base_dn))
-# assertEquals(res[0].cn, "ldaptestUSER3")
-# assertEquals(res[0].name, "ldaptestUSER3")
-
- print "Testing ldb.search for (distinguishedName=CN=ldaptestUSER3,CN=Users," + base_dn + ")"
- res = ldb.search(expression="(distinguishedName=CN=ldaptestUSER3,CN=Users," + base_dn + ")")
- assert len(res) == 1, "Could not find (dn=CN=ldaptestUSER3,CN=Users," + base_dn + ")"
- assertEquals(str(res[0].dn), ("CN=ldaptestUSER3,CN=Users," + base_dn))
- assertEquals(res[0]["cn"], "ldaptestUSER3")
- assertEquals(res[0]["name"], "ldaptestUSER3")
-
- # ensure we cannot add it again
- try:
- ldb.add({"dn": "cn=ldaptestuser3,cn=userS," + base_dn,
- "objectClass": ["person", "user"],
- "cn": "LDAPtestUSER3"})
- except LdbError, (num, _):
- assert num == LDB_ERR_ENTRY_ALREADY_EXISTS
- else:
- assert False
-
- # rename back
- ldb.rename("cn=ldaptestuser3,cn=users," + base_dn, "cn=ldaptestuser2,cn=users," + base_dn)
-
- # ensure we cannnot rename it twice
- try:
- ldb.rename("cn=ldaptestuser3,cn=users," + base_dn, "cn=ldaptestuser2,cn=users," + base_dn)
- except LdbError, (num, _):
- assert num == LDB_ERR_NO_SUCH_OBJECT
- else:
- assert False
-
- # ensure can now use that name
- ldb.add({"dn": "cn=ldaptestuser3,cn=users," + base_dn,
- "objectClass": ["person", "user"],
- "cn": "LDAPtestUSER3"})
-
- # ensure we now cannnot rename
- try:
- ldb.rename("cn=ldaptestuser2,cn=users," + base_dn, "cn=ldaptestuser3,cn=users," + base_dn)
- except LdbError, (num, _):
- assert num == LDB_ERR_ENTRY_ALREADY_EXISTS
- else:
- assert False
- try:
- ldb.rename("cn=ldaptestuser3,cn=users," + base_dn, "cn=ldaptestuser3,cn=configuration," + base_dn)
- except LdbError, (num, _):
- assert num in (71, 64)
- else:
- assert False
-
- ldb.rename("cn=ldaptestuser3,cn=users," + base_dn, "cn=ldaptestuser5,cn=users," + base_dn)
-
- ldb.delete("cn=ldaptestuser5,cn=users," + base_dn)
-
- delete_force(ldb, "cn=ldaptestgroup2,cn=users," + base_dn)
-
- ldb.rename("cn=ldaptestgroup,cn=users," + base_dn, "cn=ldaptestgroup2,cn=users," + base_dn)
-
- print "Testing subtree Renames"
-
- ldb.add({"dn": "cn=ldaptestcontainer," + base_dn,
- "objectClass": "container"})
-
- try:
- ldb.add({"dn": "CN=ldaptestuser4,CN=ldaptestcontainer," + base_dn,
- "objectClass": ["person", "user"],
- "cn": "LDAPtestUSER4"})
- except LdbError:
- ldb.delete("cn=ldaptestuser4,cn=ldaptestcontainer," + base_dn)
- ldb.add({"dn": "CN=ldaptestuser4,CN=ldaptestcontainer," + base_dn,
+ self.fail()
+ except LdbError, (num, _):
+ self.assertEquals(num, LDB_ERR_NO_SUCH_OBJECT)
+
+ print "Testing Renames"
+
+ ldb.rename("cn=ldaptestuser2,cn=users," + self.base_dn, "cn=ldaptestuser3,cn=users," + self.base_dn)
+
+ ldb.rename("cn=ldaptestuser3,cn=users," + self.base_dn, "cn=ldaptestuser3,cn=users," + self.base_dn)
+
+ ldb.rename("cn=ldaptestuser3,cn=users," + self.base_dn, "cn=ldaptestUSER3,cn=users," + self.base_dn)
+
+ print "Testing ldb.search for (&(cn=ldaptestuser3)(objectClass=user))"
+ res = ldb.search(expression="(&(cn=ldaptestuser3)(objectClass=user))")
+ self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestuser3)(objectClass=user))")
+
+ self.assertEquals(str(res[0].dn), ("CN=ldaptestUSER3,CN=Users," + self.base_dn))
+ self.assertEquals(res[0]["cn"], "ldaptestUSER3")
+ self.assertEquals(res[0]["name"], "ldaptestUSER3")
+
+ # This is a Samba special, and does not exist in real AD
+ # print "Testing ldb.search for (dn=CN=ldaptestUSER3,CN=Users," + self.base_dn + ")"
+ # res = ldb.search("(dn=CN=ldaptestUSER3,CN=Users," + self.base_dn + ")")
+ # if (res.error != 0 || len(res) != 1) {
+ # print "Could not find (dn=CN=ldaptestUSER3,CN=Users," + self.base_dn + ")"
+ # self.assertEquals(len(res), 1)
+ # }
+ # self.assertEquals(res[0].dn, ("CN=ldaptestUSER3,CN=Users," + self.base_dn))
+ # self.assertEquals(res[0].cn, "ldaptestUSER3")
+ # self.assertEquals(res[0].name, "ldaptestUSER3")
+
+ print "Testing ldb.search for (distinguishedName=CN=ldaptestUSER3,CN=Users," + self.base_dn + ")"
+ res = ldb.search(expression="(distinguishedName=CN=ldaptestUSER3,CN=Users," + self.base_dn + ")")
+ self.assertEquals(len(res), 1, "Could not find (dn=CN=ldaptestUSER3,CN=Users," + self.base_dn + ")")
+ self.assertEquals(str(res[0].dn), ("CN=ldaptestUSER3,CN=Users," + self.base_dn))
+ self.assertEquals(res[0]["cn"], "ldaptestUSER3")
+ self.assertEquals(res[0]["name"], "ldaptestUSER3")
+
+ # ensure we cannot add it again
+ try:
+ ldb.add({"dn": "cn=ldaptestuser3,cn=userS," + self.base_dn,
"objectClass": ["person", "user"],
- "cn": "LDAPtestUSER4"})
+ "cn": "LDAPtestUSER3"})
+ self.fail()
+ except LdbError, (num, _):
+ self.assertEquals(num, LDB_ERR_ENTRY_ALREADY_EXISTS)
+
+ # rename back
+ ldb.rename("cn=ldaptestuser3,cn=users," + self.base_dn, "cn=ldaptestuser2,cn=users," + self.base_dn)
+
+ # ensure we cannnot rename it twice
+ try:
+ ldb.rename("cn=ldaptestuser3,cn=users," + self.base_dn,
+ "cn=ldaptestuser2,cn=users," + self.base_dn)
+ self.fail()
+ except LdbError, (num, _):
+ self.assertEquals(num, LDB_ERR_NO_SUCH_OBJECT)
+
+ # ensure can now use that name
+ ldb.add({"dn": "cn=ldaptestuser3,cn=users," + self.base_dn,
+ "objectClass": ["person", "user"],
+ "cn": "LDAPtestUSER3"})
+
+ # ensure we now cannnot rename
+ try:
+ ldb.rename("cn=ldaptestuser2,cn=users," + self.base_dn, "cn=ldaptestuser3,cn=users," + self.base_dn)
+ self.fail()
+ except LdbError, (num, _):
+ self.assertEquals(num, LDB_ERR_ENTRY_ALREADY_EXISTS)
+ try:
+ ldb.rename("cn=ldaptestuser3,cn=users," + self.base_dn, "cn=ldaptestuser3,cn=configuration," + self.base_dn)
+ self.fail()
+ except LdbError, (num, _):
+ self.assertTrue(num in (71, 64))
+
+ ldb.rename("cn=ldaptestuser3,cn=users," + self.base_dn, "cn=ldaptestuser5,cn=users," + self.base_dn)
- ldb.modify_ldif("""
-dn: cn=ldaptestgroup2,cn=users,""" + base_dn + """
+ ldb.delete("cn=ldaptestuser5,cn=users," + self.base_dn)
+
+ self.delete_force(ldb, "cn=ldaptestgroup2,cn=users," + self.base_dn)
+
+ ldb.rename("cn=ldaptestgroup,cn=users," + self.base_dn, "cn=ldaptestgroup2,cn=users," + self.base_dn)
+
+ print "Testing subtree Renames"
+
+ ldb.add({"dn": "cn=ldaptestcontainer," + self.base_dn,
+ "objectClass": "container"})
+
+ self.delete_force(self.ldb, "cn=ldaptestuser4,cn=ldaptestcontainer," + self.base_dn)
+ ldb.add({"dn": "CN=ldaptestuser4,CN=ldaptestcontainer," + self.base_dn,
+ "objectClass": ["person", "user"],
+ "cn": "LDAPtestUSER4"})
+
+ ldb.modify_ldif("""
+dn: cn=ldaptestgroup2,cn=users,""" + self.base_dn + """
changetype: modify
add: member
-member: cn=ldaptestuser4,cn=ldaptestcontainer,""" + base_dn + """
+member: cn=ldaptestuser4,cn=ldaptestcontainer,""" + self.base_dn + """
""")
-
- print "Testing ldb.rename of cn=ldaptestcontainer," + base_dn + " to cn=ldaptestcontainer2," + base_dn
- ldb.rename("CN=ldaptestcontainer," + base_dn, "CN=ldaptestcontainer2," + base_dn)
-
- print "Testing ldb.search for (&(cn=ldaptestuser4)(objectClass=user))"
- res = ldb.search(expression="(&(cn=ldaptestuser4)(objectClass=user))")
- assert len(res) == 1, "Could not find (&(cn=ldaptestuser4)(objectClass=user))"
-
- print "Testing subtree ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in (just renamed from) cn=ldaptestcontainer," + base_dn
- try:
- ldb.search("cn=ldaptestcontainer," + base_dn,
- expression="(&(cn=ldaptestuser4)(objectClass=user))",
- scope=SCOPE_SUBTREE)
- except LdbError, (num, _):
- assert num == LDB_ERR_NO_SUCH_OBJECT
- else:
- assert False
-
- print "Testing one-level ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in (just renamed from) cn=ldaptestcontainer," + base_dn
- try:
- res = ldb.search("cn=ldaptestcontainer," + base_dn, expression="(&(cn=ldaptestuser4)(objectClass=user))", scope=SCOPE_ONELEVEL)
- except LdbError, (num, _):
- assert num == LDB_ERR_NO_SUCH_OBJECT
- else:
- assert False
-
- print "Testing ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in renamed container"
- res = ldb.search("cn=ldaptestcontainer2," + base_dn, expression="(&(cn=ldaptestuser4)(objectClass=user))", scope=SCOPE_SUBTREE)
- assert len(res) == 1, "Could not find (&(cn=ldaptestuser4)(objectClass=user)) under cn=ldaptestcontainer2," + base_dn
-
- assertEquals(str(res[0].dn), ("CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn))
- assertEquals(res[0]["memberOf"][0].upper(), ("CN=ldaptestgroup2,CN=Users," + base_dn).upper())
-
- print "Testing ldb.search for (&(member=CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn + ")(objectclass=group)) to check subtree renames and linked attributes"
- res = ldb.search(base_dn, expression="(&(member=CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn + ")(objectclass=group))", scope=SCOPE_SUBTREE)
- assert len(res) == 1, "Could not find (&(member=CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn + ")(objectclass=group)), perhaps linked attributes are not conistant with subtree renames?"
-
- print "Testing ldb.rename (into itself) of cn=ldaptestcontainer2," + base_dn + " to cn=ldaptestcontainer,cn=ldaptestcontainer2," + base_dn
- try:
- ldb.rename("cn=ldaptestcontainer2," + base_dn, "cn=ldaptestcontainer,cn=ldaptestcontainer2," + base_dn)
- except LdbError, (num, _):
- assert num == LDB_ERR_UNWILLING_TO_PERFORM
- else:
- assert False
-
- print "Testing ldb.rename (into non-existent container) of cn=ldaptestcontainer2," + base_dn + " to cn=ldaptestcontainer,cn=ldaptestcontainer3," + base_dn
- try:
- ldb.rename("cn=ldaptestcontainer2," + base_dn, "cn=ldaptestcontainer,cn=ldaptestcontainer3," + base_dn)
- except LdbError, (num, _):
- assert num in (53, 80)
- else:
- assert False
-
- print "Testing delete (should fail, not a leaf node) of renamed cn=ldaptestcontainer2," + base_dn
- try:
- ldb.delete("cn=ldaptestcontainer2," + base_dn)
- except LdbError, (num, _):
- assert num == LDB_ERR_NOT_ALLOWED_ON_NON_LEAF
- else:
- assert False
-
- print "Testing base ldb.search for CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn
- res = ldb.search(expression="(objectclass=*)", base=("CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn), scope=SCOPE_BASE)
- assert len(res) == 1
- res = ldb.search(expression="(cn=ldaptestuser40)", base=("CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn), scope=SCOPE_BASE)
- assert len(res) == 0
-
- print "Testing one-level ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in cn=ldaptestcontainer2," + base_dn
- res = ldb.search(expression="(&(cn=ldaptestuser4)(objectClass=user))", base=("cn=ldaptestcontainer2," + base_dn), scope=SCOPE_ONELEVEL)
- assert len(res) == 0
-
- print "Testing one-level ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in cn=ldaptestcontainer2," + base_dn
- res = ldb.search(expression="(&(cn=ldaptestuser4)(objectClass=user))", base=("cn=ldaptestcontainer2," + base_dn), scope=SCOPE_SUBTREE)
- assert len(res) == 0
-
- print "Testing delete of subtree renamed "+("CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn)
- ldb.delete(("CN=ldaptestuser4,CN=ldaptestcontainer2," + base_dn))
- print "Testing delete of renamed cn=ldaptestcontainer2," + base_dn
- ldb.delete("cn=ldaptestcontainer2," + base_dn)
-
- try:
- ldb.add({"dn": "cn=ldaptestutf8user èùéìòà ,cn=users," + base_dn, "objectClass": "user"})
- except LdbError, (num, _):
- ldb.delete("cn=ldaptestutf8user èùéìòà ,cn=users," + base_dn)
- ldb.add({"dn": "cn=ldaptestutf8user èùéìòà ,cn=users," + base_dn, "objectClass": "user"})
-
- try:
- ldb.add({"dn": "cn=ldaptestutf8user2 èùéìòà ,cn=users," + base_dn, "objectClass": "user"})
- except LdbError, (num, _):
- ldb.delete("cn=ldaptestutf8user2 èùéìòà ,cn=users," + base_dn)
- ldb.add({"dn": "cn=ldaptestutf8user2 èùéìòà ,cn=users," + base_dn,
- "objectClass": "user"})
-
- print "Testing ldb.search for (&(cn=ldaptestuser)(objectClass=user))"
- res = ldb.search(expression="(&(cn=ldaptestuser)(objectClass=user))")
- assert len(res) == 1, "Could not find (&(cn=ldaptestuser)(objectClass=user))"
-
- assertEquals(str(res[0].dn), ("CN=ldaptestuser,CN=Users," + base_dn))
- assertEquals(res[0]["cn"], "ldaptestuser")
- assertEquals(res[0]["name"], "ldaptestuser")
- assertEquals(res[0]["objectClass"], ["top", "person", "organizationalPerson", "user"])
- assert("objectGUID" in res[0])
- assert("whenCreated" in res[0])
- assertEquals(res[0]["objectCategory"], ("CN=Person,CN=Schema,CN=Configuration," + base_dn))
- assertEquals(int(res[0]["sAMAccountType"][0]), 805306368)
-# assertEquals(res[0].userAccountControl, 546)
- assertEquals(res[0]["memberOf"][0], ("CN=ldaptestgroup2,CN=Users," + base_dn))
- assertEquals(len(res[0]["memberOf"]), 1)
-
- print "Testing ldb.search for (&(cn=ldaptestuser)(objectCategory=cn=person,cn=schema,cn=configuration," + base_dn + "))"
- res2 = ldb.search(expression="(&(cn=ldaptestuser)(objectCategory=cn=person,cn=schema,cn=configuration," + base_dn + "))")
- assert len(res2) == 1, "Could not find (&(cn=ldaptestuser)(objectCategory=cn=person,cn=schema,cn=configuration," + base_dn + "))"
-
- assertEquals(res[0].dn, res2[0].dn)
-
- print "Testing ldb.search for (&(cn=ldaptestuser)(objectCategory=PerSon))"
- res3 = ldb.search(expression="(&(cn=ldaptestuser)(objectCategory=PerSon))")
- assert len(res3) == 1, "Could not find (&(cn=ldaptestuser)(objectCategory=PerSon)): matched " + len(res3)
-
- assertEquals(res[0].dn, res3[0].dn)
-
- if gc_ldb is not None:
- print "Testing ldb.search for (&(cn=ldaptestuser)(objectCategory=PerSon)) in Global Catalog"
- res3gc = gc_ldb.search(expression="(&(cn=ldaptestuser)(objectCategory=PerSon))")
- assert len(res3gc) == 1
-
- assertEquals(res[0].dn, res3gc[0].dn)
-
- print "Testing ldb.search for (&(cn=ldaptestuser)(objectCategory=PerSon)) in with 'phantom root' control"
-
- res3control = gc_ldb.search(base_dn, expression="(&(cn=ldaptestuser)(objectCategory=PerSon))", scope=SCOPE_SUBTREE, attrs=["cn"], controls=["search_options:1:2"])
- assert len(res3control) == 1, "Could not find (&(cn=ldaptestuser)(objectCategory=PerSon)) in Global Catalog"
-
- assertEquals(res[0].dn, res3control[0].dn)
-
- ldb.delete(res[0].dn)
-
- print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectClass=user))"
- res = ldb.search(expression="(&(cn=ldaptestcomputer)(objectClass=user))")
- assert len(res) == 1, "Could not find (&(cn=ldaptestuser)(objectClass=user))"
-
- assertEquals(str(res[0].dn), ("CN=ldaptestcomputer,CN=Computers," + base_dn))
- assertEquals(res[0]["cn"], "ldaptestcomputer")
- assertEquals(res[0]["name"], "ldaptestcomputer")
- assertEquals(res[0]["objectClass"], ["top", "person", "organizationalPerson", "user", "computer"])
- assert("objectGUID" in res[0])
- assert("whenCreated" in res[0])
- assertEquals(res[0]["objectCategory"], ("CN=Computer,CN=Schema,CN=Configuration," + base_dn))
- assertEquals(int(res[0]["primaryGroupID"][0]), 513)
-# assertEquals(res[0].sAMAccountType, 805306368)
-# assertEquals(res[0].userAccountControl, 546)
- assertEquals(res[0]["memberOf"][0], "CN=ldaptestgroup2,CN=Users," + base_dn)
- assertEquals(len(res[0]["memberOf"]), 1)
-
- print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration," + base_dn + "))"
- res2 = ldb.search(expression="(&(cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration," + base_dn + "))")
- assert len(res2) == 1, "Could not find (&(cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration," + base_dn + "))"
-
- assertEquals(res[0].dn, res2[0].dn)
-
- if gc_ldb is not None:
- print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration," + base_dn + ")) in Global Catlog"
- res2gc = gc_ldb.search(expression="(&(cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration," + base_dn + "))")
- assert len(res2gc) == 1, "Could not find (&(cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration," + base_dn + ")) in Global Catlog"
-
- assertEquals(res[0].dn, res2gc[0].dn)
-
- print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectCategory=compuTER))"
- res3 = ldb.search(expression="(&(cn=ldaptestcomputer)(objectCategory=compuTER))")
- assert len(res3) == 1, "Could not find (&(cn=ldaptestcomputer)(objectCategory=compuTER))"
-
- assertEquals(res[0].dn, res3[0].dn)
-
- if gc_ldb is not None:
- print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectCategory=compuTER)) in Global Catalog"
- res3gc = gc_ldb.search(expression="(&(cn=ldaptestcomputer)(objectCategory=compuTER))")
- assert len(res3gc) == 1, "Could not find (&(cn=ldaptestcomputer)(objectCategory=compuTER)) in Global Catalog"
-
- assertEquals(res[0].dn, res3gc[0].dn)
-
- print "Testing ldb.search for (&(cn=ldaptestcomp*r)(objectCategory=compuTER))"
- res4 = ldb.search(expression="(&(cn=ldaptestcomp*r)(objectCategory=compuTER))")
- assert len(res4) == 1, "Could not find (&(cn=ldaptestcomp*r)(objectCategory=compuTER))"
-
- assertEquals(res[0].dn, res4[0].dn)
-
- print "Testing ldb.search for (&(cn=ldaptestcomput*)(objectCategory=compuTER))"
- res5 = ldb.search(expression="(&(cn=ldaptestcomput*)(objectCategory=compuTER))")
- assert len(res5) == 1, "Could not find (&(cn=ldaptestcomput*)(objectCategory=compuTER))"
-
- assertEquals(res[0].dn, res5[0].dn)
-
- print "Testing ldb.search for (&(cn=*daptestcomputer)(objectCategory=compuTER))"
- res6 = ldb.search(expression="(&(cn=*daptestcomputer)(objectCategory=compuTER))")
- assert len(res6) == 1, "Could not find (&(cn=*daptestcomputer)(objectCategory=compuTER))"
-
- assertEquals(res[0].dn, res6[0].dn)
-
- ldb.delete(res[0].dn)
-
- print "Testing ldb.search for (&(cn=ldaptest2computer)(objectClass=user))"
- res = ldb.search(expression="(&(cn=ldaptest2computer)(objectClass=user))")
- assert len(res) == 1, "Could not find (&(cn=ldaptest2computer)(objectClass=user))"
-
- assertEquals(res[0].dn, ("CN=ldaptest2computer,CN=Computers," + base_dn))
- assertEquals(res[0]["cn"], "ldaptest2computer")
- assertEquals(res[0]["name"], "ldaptest2computer")
- assertEquals(res[0]["objectClass"], ["top", "person", "organizationalPerson", "user", "computer"])
- assert("objectGUID" in res[0])
- assert("whenCreated" in res[0])
- assertEquals(res[0]["objectCategory"][0], "CN=Computer,CN=Schema,CN=Configuration," + base_dn)
- assertEquals(int(res[0]["sAMAccountType"][0]), 805306369)
-# assertEquals(res[0].userAccountControl, 4098)
-
- ldb.delete(res[0].dn)
-
- attrs = ["cn", "name", "objectClass", "objectGUID", "whenCreated", "nTSecurityDescriptor", "memberOf"]
- print "Testing ldb.search for (&(cn=ldaptestUSer2)(objectClass=user))"
- res = ldb.search(base_dn, expression="(&(cn=ldaptestUSer2)(objectClass=user))", scope=SCOPE_SUBTREE, attrs=attrs)
- assert len(res) == 1, "Could not find (&(cn=ldaptestUSer2)(objectClass=user))"
-
- assertEquals(res[0].dn, ("CN=ldaptestuser2,CN=Users," + base_dn))
- assertEquals(res[0]["cn"], "ldaptestuser2")
- assertEquals(res[0]["name"], "ldaptestuser2")
- assertEquals(res[0]["objectClass"], ["top", "person", "organizationalPerson", "user"])
- assert("objectGUID" in res[0])
- assert("whenCreated" in res[0])
- assert("nTSecurityDescriptor" in res[0])
- assertEquals(res[0]["memberOf"][0], ("CN=ldaptestgroup2,CN=Users," + base_dn))
-
- attrs = ["cn", "name", "objectClass", "objectGUID", "whenCreated", "nTSecurityDescriptor", "member"]
- print "Testing ldb.search for (&(cn=ldaptestgroup2)(objectClass=group))"
- res = ldb.search(base_dn, expression="(&(cn=ldaptestgroup2)(objectClass=group))", scope=SCOPE_SUBTREE, attrs=attrs)
- assert len(res) == 1, "Could not find (&(cn=ldaptestgroup2)(objectClass=group))"
-
- assertEquals(res[0].dn, ("CN=ldaptestgroup2,CN=Users," + base_dn))
- assertEquals(res[0]["cn"], "ldaptestgroup2")
- assertEquals(res[0]["name"], "ldaptestgroup2")
- assertEquals(res[0]["objectClass"], ["top", "group"])
- assert("objectGuid" not in res[0])
- assert("whenCreated" in res[0])
- assert("nTSecurityDescriptor" in res[0])
- assertEquals(res[0]["member"], ["CN=ldaptestuser2,CN=Users," + base_dn])
-
- ldb.modify_ldif("""
-dn: cn=ldaptestgroup2,cn=users,""" + base_dn + """
+
+ print "Testing ldb.rename of cn=ldaptestcontainer," + self.base_dn + " to cn=ldaptestcontainer2," + self.base_dn
+ ldb.rename("CN=ldaptestcontainer," + self.base_dn, "CN=ldaptestcontainer2," + self.base_dn)
+
+ print "Testing ldb.search for (&(cn=ldaptestuser4)(objectClass=user))"
+ res = ldb.search(expression="(&(cn=ldaptestuser4)(objectClass=user))")
+ self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestuser4)(objectClass=user))")
+
+ print "Testing subtree ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in (just renamed from) cn=ldaptestcontainer," + self.base_dn
+ try:
+ ldb.search("cn=ldaptestcontainer," + self.base_dn,
+ expression="(&(cn=ldaptestuser4)(objectClass=user))",
+ scope=SCOPE_SUBTREE)
+ self.fail()
+ except LdbError, (num, _):
+ self.assertEquals(num, LDB_ERR_NO_SUCH_OBJECT)
+
+ print "Testing one-level ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in (just renamed from) cn=ldaptestcontainer," + self.base_dn
+ try:
+ res = ldb.search("cn=ldaptestcontainer," + self.base_dn,
+ expression="(&(cn=ldaptestuser4)(objectClass=user))", scope=SCOPE_ONELEVEL)
+ self.fail()
+ except LdbError, (num, _):
+ self.assertEquals(num, LDB_ERR_NO_SUCH_OBJECT)
+
+ print "Testing ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in renamed container"
+ res = ldb.search("cn=ldaptestcontainer2," + self.base_dn, expression="(&(cn=ldaptestuser4)(objectClass=user))", scope=SCOPE_SUBTREE)
+ self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestuser4)(objectClass=user)) under cn=ldaptestcontainer2," + self.base_dn)
+
+ self.assertEquals(str(res[0].dn), ("CN=ldaptestuser4,CN=ldaptestcontainer2," + self.base_dn))
+ self.assertEquals(res[0]["memberOf"][0].upper(), ("CN=ldaptestgroup2,CN=Users," + self.base_dn).upper())
+
+ print "Testing ldb.search for (&(member=CN=ldaptestuser4,CN=ldaptestcontainer2," + self.base_dn + ")(objectclass=group)) to check subtree renames and linked attributes"
+ res = ldb.search(self.base_dn, expression="(&(member=CN=ldaptestuser4,CN=ldaptestcontainer2," + self.base_dn + ")(objectclass=group))", scope=SCOPE_SUBTREE)
+ self.assertEquals(len(res), 1, "Could not find (&(member=CN=ldaptestuser4,CN=ldaptestcontainer2," + self.base_dn + ")(objectclass=group)), perhaps linked attributes are not conistant with subtree renames?")
+
+ print "Testing ldb.rename (into itself) of cn=ldaptestcontainer2," + self.base_dn + " to cn=ldaptestcontainer,cn=ldaptestcontainer2," + self.base_dn
+ try:
+ ldb.rename("cn=ldaptestcontainer2," + self.base_dn, "cn=ldaptestcontainer,cn=ldaptestcontainer2," + self.base_dn)
+ self.fail()
+ except LdbError, (num, _):
+ self.assertEquals(num, LDB_ERR_UNWILLING_TO_PERFORM)
+
+ print "Testing ldb.rename (into non-existent container) of cn=ldaptestcontainer2," + self.base_dn + " to cn=ldaptestcontainer,cn=ldaptestcontainer3," + self.base_dn
+ try:
+ ldb.rename("cn=ldaptestcontainer2," + self.base_dn, "cn=ldaptestcontainer,cn=ldaptestcontainer3," + self.base_dn)
+ self.fail()
+ except LdbError, (num, _):
+ self.assertTrue(num in (LDB_ERR_UNWILLING_TO_PERFORM, LDB_ERR_OTHER))
+
+ print "Testing delete (should fail, not a leaf node) of renamed cn=ldaptestcontainer2," + self.base_dn
+ try:
+ ldb.delete("cn=ldaptestcontainer2," + self.base_dn)
+ self.fail()
+ except LdbError, (num, _):
+ self.assertEquals(num, LDB_ERR_NOT_ALLOWED_ON_NON_LEAF)
+
+ print "Testing base ldb.search for CN=ldaptestuser4,CN=ldaptestcontainer2," + self.base_dn
+ res = ldb.search(expression="(objectclass=*)", base=("CN=ldaptestuser4,CN=ldaptestcontainer2," + self.base_dn), scope=SCOPE_BASE)
+ self.assertEquals(len(res), 1)
+ res = ldb.search(expression="(cn=ldaptestuser40)", base=("CN=ldaptestuser4,CN=ldaptestcontainer2," + self.base_dn), scope=SCOPE_BASE)
+ self.assertEquals(len(res), 0)
+
+ print "Testing one-level ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in cn=ldaptestcontainer2," + self.base_dn
+ res = ldb.search(expression="(&(cn=ldaptestuser4)(objectClass=user))", base=("cn=ldaptestcontainer2," + self.base_dn), scope=SCOPE_ONELEVEL)
+ # FIXME: self.assertEquals(len(res), 0)
+
+ print "Testing one-level ldb.search for (&(cn=ldaptestuser4)(objectClass=user)) in cn=ldaptestcontainer2," + self.base_dn
+ res = ldb.search(expression="(&(cn=ldaptestuser4)(objectClass=user))", base=("cn=ldaptestcontainer2," + self.base_dn), scope=SCOPE_SUBTREE)
+ # FIXME: self.assertEquals(len(res), 0)
+
+ print "Testing delete of subtree renamed "+("CN=ldaptestuser4,CN=ldaptestcontainer2," + self.base_dn)
+ ldb.delete(("CN=ldaptestuser4,CN=ldaptestcontainer2," + self.base_dn))
+ print "Testing delete of renamed cn=ldaptestcontainer2," + self.base_dn
+ ldb.delete("cn=ldaptestcontainer2," + self.base_dn)
+
+ self.delete_force(self.ldb, "cn=ldaptestutf8user èùéìòà ,cn=users," + self.base_dn)
+ ldb.add({"dn": "cn=ldaptestutf8user èùéìòà ,cn=users," + self.base_dn, "objectClass": "user"})
+
+ self.delete_force(self.ldb, "cn=ldaptestutf8user2 èùéìòà ,cn=users," + self.base_dn)
+ ldb.add({"dn": "cn=ldaptestutf8user2 èùéìòà ,cn=users," + self.base_dn, "objectClass": "user"})
+
+ print "Testing ldb.search for (&(cn=ldaptestuser)(objectClass=user))"
+ res = ldb.search(expression="(&(cn=ldaptestuser)(objectClass=user))")
+ self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestuser)(objectClass=user))")
+
+ self.assertEquals(str(res[0].dn), ("CN=ldaptestuser,CN=Users," + self.base_dn))
+ self.assertEquals(res[0]["cn"], "ldaptestuser")
+ self.assertEquals(res[0]["name"], "ldaptestuser")
+ self.assertEquals(res[0]["objectClass"], ["top", "person", "organizationalPerson", "user"])
+ self.assertTrue("objectGUID" in res[0])
+ self.assertTrue("whenCreated" in res[0])
+ self.assertEquals(res[0]["objectCategory"], ("CN=Person,CN=Schema,CN=Configuration," + self.base_dn))
+ self.assertEquals(int(res[0]["sAMAccountType"][0]), 805306368)
+ # self.assertEquals(res[0].userAccountControl, 546)
+ self.assertEquals(res[0]["memberOf"][0], ("CN=ldaptestgroup2,CN=Users," + self.base_dn))
+ self.assertEquals(len(res[0]["memberOf"]), 1)
+
+ print "Testing ldb.search for (&(cn=ldaptestuser)(objectCategory=cn=person,cn=schema,cn=configuration," + self.base_dn + "))"
+ res2 = ldb.search(expression="(&(cn=ldaptestuser)(objectCategory=cn=person,cn=schema,cn=configuration," + self.base_dn + "))")
+ self.assertEquals(len(res2), 1, "Could not find (&(cn=ldaptestuser)(objectCategory=cn=person,cn=schema,cn=configuration," + self.base_dn + "))")
+
+ self.assertEquals(res[0].dn, res2[0].dn)
+
+ print "Testing ldb.search for (&(cn=ldaptestuser)(objectCategory=PerSon))"
+ res3 = ldb.search(expression="(&(cn=ldaptestuser)(objectCategory=PerSon))")
+ self.assertEquals(len(res3), 1, "Could not find (&(cn=ldaptestuser)(objectCategory=PerSon)): matched %d" % len(res3))
+
+ self.assertEquals(res[0].dn, res3[0].dn)
+
+ if gc_ldb is not None:
+ print "Testing ldb.search for (&(cn=ldaptestuser)(objectCategory=PerSon)) in Global Catalog"
+ res3gc = gc_ldb.search(expression="(&(cn=ldaptestuser)(objectCategory=PerSon))")
+ self.assertEquals(len(res3gc), 1)
+
+ self.assertEquals(res[0].dn, res3gc[0].dn)
+
+ print "Testing ldb.search for (&(cn=ldaptestuser)(objectCategory=PerSon)) in with 'phantom root' control"
+
+ res3control = gc_ldb.search(self.base_dn, expression="(&(cn=ldaptestuser)(objectCategory=PerSon))", scope=SCOPE_SUBTREE, attrs=["cn"], controls=["search_options:1:2"])
+ self.assertEquals(len(res3control), 1, "Could not find (&(cn=ldaptestuser)(objectCategory=PerSon)) in Global Catalog")
+
+ self.assertEquals(res[0].dn, res3control[0].dn)
+
+ ldb.delete(res[0].dn)
+
+ print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectClass=user))"
+ res = ldb.search(expression="(&(cn=ldaptestcomputer)(objectClass=user))")
+ self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestuser)(objectClass=user))")
+
+ self.assertEquals(str(res[0].dn), ("CN=ldaptestcomputer,CN=Computers," + self.base_dn))
+ self.assertEquals(res[0]["cn"], "ldaptestcomputer")
+ self.assertEquals(res[0]["name"], "ldaptestcomputer")
+ self.assertEquals(res[0]["objectClass"], ["top", "person", "organizationalPerson", "user", "computer"])
+ self.assertTrue("objectGUID" in res[0])
+ self.assertTrue("whenCreated" in res[0])
+ self.assertEquals(res[0]["objectCategory"], ("CN=Computer,CN=Schema,CN=Configuration," + self.base_dn))
+ self.assertEquals(int(res[0]["primaryGroupID"][0]), 513)
+ # self.assertEquals(res[0].sAMAccountType, 805306368)
+ # self.assertEquals(res[0].userAccountControl, 546)
+ self.assertEquals(res[0]["memberOf"][0], "CN=ldaptestgroup2,CN=Users," + self.base_dn)
+ self.assertEquals(len(res[0]["memberOf"]), 1)
+
+ print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration," + self.base_dn + "))"
+ res2 = ldb.search(expression="(&(cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration," + self.base_dn + "))")
+ self.assertEquals(len(res2), 1, "Could not find (&(cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration," + self.base_dn + "))")
+
+ self.assertEquals(res[0].dn, res2[0].dn)
+
+ if gc_ldb is not None:
+ print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration," + self.base_dn + ")) in Global Catlog"
+ res2gc = gc_ldb.search(expression="(&(cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration," + self.base_dn + "))")
+ self.assertEquals(len(res2gc), 1, "Could not find (&(cn=ldaptestcomputer)(objectCategory=cn=computer,cn=schema,cn=configuration," + self.base_dn + ")) in Global Catlog")
+
+ self.assertEquals(res[0].dn, res2gc[0].dn)
+
+ print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectCategory=compuTER))"
+ res3 = ldb.search(expression="(&(cn=ldaptestcomputer)(objectCategory=compuTER))")
+ self.assertEquals(len(res3), 1, "Could not find (&(cn=ldaptestcomputer)(objectCategory=compuTER))")
+
+ self.assertEquals(res[0].dn, res3[0].dn)
+
+ if gc_ldb is not None:
+ print "Testing ldb.search for (&(cn=ldaptestcomputer)(objectCategory=compuTER)) in Global Catalog"
+ res3gc = gc_ldb.search(expression="(&(cn=ldaptestcomputer)(objectCategory=compuTER))")
+ self.assertEquals(len(res3gc), 1, "Could not find (&(cn=ldaptestcomputer)(objectCategory=compuTER)) in Global Catalog")
+
+ self.assertEquals(res[0].dn, res3gc[0].dn)
+
+ print "Testing ldb.search for (&(cn=ldaptestcomp*r)(objectCategory=compuTER))"
+ res4 = ldb.search(expression="(&(cn=ldaptestcomp*r)(objectCategory=compuTER))")
+ self.assertEquals(len(res4), 1, "Could not find (&(cn=ldaptestcomp*r)(objectCategory=compuTER))")
+
+ self.assertEquals(res[0].dn, res4[0].dn)
+
+ print "Testing ldb.search for (&(cn=ldaptestcomput*)(objectCategory=compuTER))"
+ res5 = ldb.search(expression="(&(cn=ldaptestcomput*)(objectCategory=compuTER))")
+ self.assertEquals(len(res5), 1, "Could not find (&(cn=ldaptestcomput*)(objectCategory=compuTER))")
+
+ self.assertEquals(res[0].dn, res5[0].dn)
+
+ print "Testing ldb.search for (&(cn=*daptestcomputer)(objectCategory=compuTER))"
+ res6 = ldb.search(expression="(&(cn=*daptestcomputer)(objectCategory=compuTER))")
+ self.assertEquals(len(res6), 1, "Could not find (&(cn=*daptestcomputer)(objectCategory=compuTER))")
+
+ self.assertEquals(res[0].dn, res6[0].dn)
+
+ ldb.delete(res[0].dn)
+
+ print "Testing ldb.search for (&(cn=ldaptest2computer)(objectClass=user))"
+ res = ldb.search(expression="(&(cn=ldaptest2computer)(objectClass=user))")
+ self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptest2computer)(objectClass=user))")
+
+ self.assertEquals(res[0].dn, ("CN=ldaptest2computer,CN=Computers," + self.base_dn))
+ self.assertEquals(res[0]["cn"], "ldaptest2computer")
+ self.assertEquals(res[0]["name"], "ldaptest2computer")
+ self.assertEquals(res[0]["objectClass"], ["top", "person", "organizationalPerson", "user", "computer"])
+ self.assertTrue("objectGUID" in res[0])
+ self.assertTrue("whenCreated" in res[0])
+ self.assertEquals(res[0]["objectCategory"][0], "CN=Computer,CN=Schema,CN=Configuration," + self.base_dn)
+ self.assertEquals(int(res[0]["sAMAccountType"][0]), 805306369)
+ # self.assertEquals(res[0].userAccountControl, 4098)
+
+ ldb.delete(res[0].dn)
+
+ attrs = ["cn", "name", "objectClass", "objectGUID", "whenCreated", "nTSecurityDescriptor", "memberOf"]
+ print "Testing ldb.search for (&(cn=ldaptestUSer2)(objectClass=user))"
+ res = ldb.search(self.base_dn, expression="(&(cn=ldaptestUSer2)(objectClass=user))", scope=SCOPE_SUBTREE, attrs=attrs)
+ self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestUSer2)(objectClass=user))")
+
+ self.assertEquals(res[0].dn, ("CN=ldaptestuser2,CN=Users," + self.base_dn))
+ self.assertEquals(res[0]["cn"], "ldaptestuser2")
+ self.assertEquals(res[0]["name"], "ldaptestuser2")
+ self.assertEquals(res[0]["objectClass"], ["top", "person", "organizationalPerson", "user"])
+ self.assertTrue("objectGUID" in res[0])
+ self.assertTrue("whenCreated" in res[0])
+ self.assertTrue("nTSecurityDescriptor" in res[0])
+ self.assertEquals(res[0]["memberOf"][0], ("CN=ldaptestgroup2,CN=Users," + self.base_dn))
+
+ attrs = ["cn", "name", "objectClass", "objectGUID", "whenCreated", "nTSecurityDescriptor", "member"]
+ print "Testing ldb.search for (&(cn=ldaptestgroup2)(objectClass=group))"
+ res = ldb.search(self.base_dn, expression="(&(cn=ldaptestgroup2)(objectClass=group))", scope=SCOPE_SUBTREE, attrs=attrs)
+ self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestgroup2)(objectClass=group))")
+
+ self.assertEquals(res[0].dn, ("CN=ldaptestgroup2,CN=Users," + self.base_dn))
+ self.assertEquals(res[0]["cn"], "ldaptestgroup2")
+ self.assertEquals(res[0]["name"], "ldaptestgroup2")
+ self.assertEquals(res[0]["objectClass"], ["top", "group"])
+ self.assertTrue("objectGuid" not in res[0])
+ self.assertTrue("whenCreated" in res[0])
+ self.assertTrue("nTSecurityDescriptor" in res[0])
+ self.assertEquals(res[0]["member"], ["CN=ldaptestuser2,CN=Users," + self.base_dn])
+
+ ldb.modify_ldif("""
+dn: cn=ldaptestgroup2,cn=users,""" + self.base_dn + """
changetype: modify
replace: member
-member: CN=ldaptestuser2,CN=Users,""" + base_dn + """
-member: CN=ldaptestutf8user èùéìòà,CN=Users,""" + base_dn + """
+member: CN=ldaptestuser2,CN=Users,""" + self.base_dn + """
+member: CN=ldaptestutf8user èùéìòà,CN=Users,""" + self.base_dn + """
""")
-
- print "Testing Linked attribute behaviours"
- ldb.modify_ldif("""
-dn: cn=ldaptestgroup2,cn=users,""" + base_dn + """
+
+ print "Testing Linked attribute behaviours"
+ ldb.modify_ldif("""
+dn: cn=ldaptestgroup2,cn=users,""" + self.base_dn + """
changetype: modify
delete: member
""")
- ldb.modify_ldif("""
-dn: cn=ldaptestgroup2,cn=users,""" + base_dn + """
+ ldb.modify_ldif("""
+dn: cn=ldaptestgroup2,cn=users,""" + self.base_dn + """
changetype: modify
add: member
-member: CN=ldaptestuser2,CN=Users,""" + base_dn + """
-member: CN=ldaptestutf8user èùéìòà,CN=Users,""" + base_dn + """
+member: CN=ldaptestuser2,CN=Users,""" + self.base_dn + """
+member: CN=ldaptestutf8user èùéìòà,CN=Users,""" + self.base_dn + """
""")
-
- ldb.modify_ldif("""
-dn: cn=ldaptestgroup2,cn=users,""" + base_dn + """
+
+ ldb.modify_ldif("""
+dn: cn=ldaptestgroup2,cn=users,""" + self.base_dn + """
changetype: modify
replace: member
""")
-
- ldb.modify_ldif("""
-dn: cn=ldaptestgroup2,cn=users,""" + base_dn + """
+
+ ldb.modify_ldif("""
+dn: cn=ldaptestgroup2,cn=users,""" + self.base_dn + """
changetype: modify
add: member
-member: CN=ldaptestuser2,CN=Users,""" + base_dn + """
-member: CN=ldaptestutf8user èùéìòà,CN=Users,""" + base_dn + """
+member: CN=ldaptestuser2,CN=Users,""" + self.base_dn + """
+member: CN=ldaptestutf8user èùéìòà,CN=Users,""" + self.base_dn + """
""")
-
- ldb.modify_ldif("""
-dn: cn=ldaptestgroup2,cn=users,""" + base_dn + """
+
+ ldb.modify_ldif("""
+dn: cn=ldaptestgroup2,cn=users,""" + self.base_dn + """
changetype: modify
delete: member
-member: CN=ldaptestutf8user èùéìòà,CN=Users,""" + base_dn + """
+member: CN=ldaptestutf8user èùéìòà,CN=Users,""" + self.base_dn + """
""")
-
- res = ldb.search(base_dn, expression="(&(cn=ldaptestgroup2)(objectClass=group))", scope=SCOPE_SUBTREE, attrs=attrs)
- assert len(res) == 1, "Could not find (&(cn=ldaptestgroup2)(objectClass=group))"
+
+ res = ldb.search(self.base_dn, expression="(&(cn=ldaptestgroup2)(objectClass=group))", scope=SCOPE_SUBTREE, attrs=attrs)
+ self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestgroup2)(objectClass=group))")
+
+ self.assertEquals(res[0].dn, ("CN=ldaptestgroup2,CN=Users," + self.base_dn))
+ self.assertEquals(res[0]["member"][0], ("CN=ldaptestuser2,CN=Users," + self.base_dn))
+ self.assertEquals(len(res[0]["member"]), 1)
- assertEquals(res[0].dn, ("CN=ldaptestgroup2,CN=Users," + base_dn))
- assertEquals(res[0]["member"][0], ("CN=ldaptestuser2,CN=Users," + base_dn))
- assertEquals(len(res[0]["member"]), 1)
+ ldb.delete(("CN=ldaptestuser2,CN=Users," + self.base_dn))
- ldb.delete(("CN=ldaptestuser2,CN=Users," + base_dn))
+ attrs = ["cn", "name", "objectClass", "objectGUID", "whenCreated", "nTSecurityDescriptor", "member"]
+ print "Testing ldb.search for (&(cn=ldaptestgroup2)(objectClass=group)) to check linked delete"
+ res = ldb.search(self.base_dn, expression="(&(cn=ldaptestgroup2)(objectClass=group))", scope=SCOPE_SUBTREE, attrs=attrs)
+ self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestgroup2)(objectClass=group)) to check linked delete")
- attrs = ["cn", "name", "objectClass", "objectGUID", "whenCreated", "nTSecurityDescriptor", "member"]
- print "Testing ldb.search for (&(cn=ldaptestgroup2)(objectClass=group)) to check linked delete"
- res = ldb.search(base_dn, expression="(&(cn=ldaptestgroup2)(objectClass=group))", scope=SCOPE_SUBTREE, attrs=attrs)
- assert len(res) == 1, "Could not find (&(cn=ldaptestgroup2)(objectClass=group)) to check linked delete"
+ self.assertEquals(res[0].dn, ("CN=ldaptestgroup2,CN=Users," + self.base_dn))
+ self.assertTrue("member" not in res[0])
- assertEquals(res[0].dn, ("CN=ldaptestgroup2,CN=Users," + base_dn))
- assert("member" not in res[0])
+ print "Testing ldb.search for (&(cn=ldaptestutf8user ÈÙÉÌÒÀ)(objectClass=user))"
+ res = ldb.search(expression="(&(cn=ldaptestutf8user ÈÙÉÌÒÀ)(objectClass=user))")
+ self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestutf8user ÈÙÉÌÒÀ)(objectClass=user))")
- print "Testing ldb.search for (&(cn=ldaptestutf8user ÈÙÉÌÒÀ)(objectClass=user))"
- res = ldb.search(expression="(&(cn=ldaptestutf8user ÈÙÉÌÒÀ)(objectClass=user))")
- assert len(res) == 1, "Could not find (&(cn=ldaptestutf8user ÈÙÉÌÒÀ)(objectClass=user))"
+ self.assertEquals(res[0].dn, ("CN=ldaptestutf8user èùéìòà,CN=Users," + self.base_dn))
+ self.assertEquals(res[0]["cn"], "ldaptestutf8user èùéìòà")
+ self.assertEquals(res[0]["name"], "ldaptestutf8user èùéìòà")
+ self.assertEquals(res[0]["objectClass"], ["top", "person", "organizationalPerson", "user"])
+ self.assertTrue("objectGUID" in res[0])
+ self.assertTrue("whenCreated" in res[0])
- assertEquals(res[0].dn, ("CN=ldaptestutf8user èùéìòà,CN=Users," + base_dn))
- assertEquals(res[0]["cn"], "ldaptestutf8user èùéìòà")
- assertEquals(res[0]["name"], "ldaptestutf8user èùéìòà")
- assertEquals(res[0]["objectClass"], ["top", "person", "organizationalPerson", "user"])
- assert("objectGUID" in res[0])
- assert("whenCreated" in res[0])
+ ldb.delete(res[0].dn)
- ldb.delete(res[0].dn)
+ print "Testing ldb.search for (&(cn=ldaptestutf8user2*)(objectClass=user))"
+ res = ldb.search(expression="(&(cn=ldaptestutf8user2*)(objectClass=user))")
+ self.assertEquals(len(res), 1, "Could not find (&(cn=ldaptestutf8user2*)(objectClass=user))")
- print "Testing ldb.search for (&(cn=ldaptestutf8user2*)(objectClass=user))"
- res = ldb.search(expression="(&(cn=ldaptestutf8user2*)(objectClass=user))")
- assert len(res) == 1, "Could not find (&(cn=ldaptestutf8user2*)(objectClass=user))"
+ ldb.delete(res[0].dn)
- ldb.delete(res[0].dn)
+ ldb.delete(("CN=ldaptestgroup2,CN=Users," + self.base_dn))
- ldb.delete(("CN=ldaptestgroup2,CN=Users," + base_dn))
+ print "Testing ldb.search for (&(cn=ldaptestutf8user2 ÈÙÉÌÒÀ)(objectClass=user))"
+ res = ldb.search(expression="(&(cn=ldaptestutf8user ÈÙÉÌÒÀ)(objectClass=user))")
- print "Testing ldb.search for (&(cn=ldaptestutf8user2 ÈÙÉÌÒÀ)(objectClass=user))"
- res = ldb.search(expression="(&(cn=ldaptestutf8user ÈÙÉÌÒÀ)(objectClass=user))")
+ #FIXME: self.assert len(res) == 1, "Could not find (expect space collapse, win2k3 fails) (&(cn=ldaptestutf8user2 ÈÙÉÌÒÀ)(objectClass=user))"
- #FIXME: assert len(res) == 1, "Could not find (expect space collapse, win2k3 fails) (&(cn=ldaptestutf8user2 ÈÙÉÌÒÀ)(objectClass=user))"
+ print "Testing that we can't get at the configuration DN from the main search base"
+ res = ldb.search(self.base_dn, expression="objectClass=crossRef", scope=SCOPE_SUBTREE, attrs=["cn"])
+ self.assertEquals(len(res), 0)
- print "Testing that we can't get at the configuration DN from the main search base"
- res = ldb.search(base_dn, expression="objectClass=crossRef", scope=SCOPE_SUBTREE, attrs=["cn"])
- assert len(res) == 0, "Got configuration DN " + res[0].dn + " which should not be able to be seen from main search base"
- assertEquals(len(res), 0)
+ print "Testing that we can get at the configuration DN from the main search base on the LDAP port with the 'phantom root' search_options control"
+ res = ldb.search(self.base_dn, expression="objectClass=crossRef", scope=SCOPE_SUBTREE, attrs=["cn"], controls=["search_options:1:2"])
+ self.assertTrue(len(res) > 0)
- print "Testing that we can get at the configuration DN from the main search base on the LDAP port with the 'phantom root' search_options control"
- res = ldb.search(base_dn, expression="objectClass=crossRef", scope=SCOPE_SUBTREE, attrs=["cn"], controls=["search_options:1:2"])
- assert(len(res) > 0)
+ if gc_ldb is not None:
+ print "Testing that we can get at the configuration DN from the main search base on the GC port with the search_options control == 0"
+
+ res = gc_ldb.search(self.base_dn, expression="objectClass=crossRef", scope=SCOPE_SUBTREE, attrs=["cn"], controls=["search_options:1:0"])
+ self.assertTrue(len(res) > 0)
- if gc_ldb is not None:
- print "Testing that we can get at the configuration DN from the main search base on the GC port with the search_options control == 0"
+ print "Testing that we do find configuration elements in the global catlog"
+ res = gc_ldb.search(self.base_dn, expression="objectClass=crossRef", scope=SCOPE_SUBTREE, attrs=["cn"])
+ self.assertTrue(len(res) > 0)
+
+ print "Testing that we do find configuration elements and user elements at the same time"
+ res = gc_ldb.search(self.base_dn, expression="(|(objectClass=crossRef)(objectClass=person))", scope=SCOPE_SUBTREE, attrs=["cn"])
+ self.assertTrue(len(res) > 0)
+
+ print "Testing that we do find configuration elements in the global catlog, with the configuration basedn"
+ res = gc_ldb.search(self.configuration_dn, expression="objectClass=crossRef", scope=SCOPE_SUBTREE, attrs=["cn"])
+ self.assertTrue(len(res) > 0)
+
+ print "Testing that we can get at the configuration DN on the main LDAP port"
+ res = ldb.search(self.configuration_dn, expression="objectClass=crossRef", scope=SCOPE_SUBTREE, attrs=["cn"])
+ self.assertTrue(len(res) > 0)
+
+ print "Testing objectCategory canonacolisation"
+ res = ldb.search(self.configuration_dn, expression="objectCategory=ntDsDSA", scope=SCOPE_SUBTREE, attrs=["cn"])
+ self.assertTrue(len(res) > 0, "Didn't find any records with objectCategory=ntDsDSA")
+ self.assertTrue(len(res) != 0)
- res = gc_ldb.search(base_dn, expression="objectClass=crossRef", scope=SCOPE_SUBTREE, attrs=["cn"], controls=["search_options:1:0"])
- assert(len(res) > 0)
-
- print "Testing that we do find configuration elements in the global catlog"
- res = gc_ldb.search(base_dn, expression="objectClass=crossRef", scope=SCOPE_SUBTREE, attrs=["cn"])
- assert (len(res) > 0)
-
- print "Testing that we do find configuration elements and user elements at the same time"
- res = gc_ldb.search(base_dn, expression="(|(objectClass=crossRef)(objectClass=person))", scope=SCOPE_SUBTREE, attrs=["cn"])
- assert (len(res) > 0)
-
- print "Testing that we do find configuration elements in the global catlog, with the configuration basedn"
- res = gc_ldb.search(configuration_dn, expression="objectClass=crossRef", scope=SCOPE_SUBTREE, attrs=["cn"])
- assert (len(res) > 0)
-
- print "Testing that we can get at the configuration DN on the main LDAP port"
- res = ldb.search(configuration_dn, expression="objectClass=crossRef", scope=SCOPE_SUBTREE, attrs=["cn"])
- assert (len(res) > 0)
-
- print "Testing objectCategory canonacolisation"
- res = ldb.search(configuration_dn, expression="objectCategory=ntDsDSA", scope=SCOPE_SUBTREE, attrs=["cn"])
- assert len(res) > 0, "Didn't find any records with objectCategory=ntDsDSA"
- assert(len(res) != 0)
-
- res = ldb.search(configuration_dn, expression="objectCategory=CN=ntDs-DSA," + schema_dn, scope=SCOPE_SUBTREE, attrs=["cn"])
- assert len(res) > 0, "Didn't find any records with objectCategory=CN=ntDs-DSA," + schema_dn
- assert(len(res) != 0)
-
- print "Testing objectClass attribute order on "+ base_dn
- res = ldb.search(expression="objectClass=domain", base=base_dn,
- scope=SCOPE_BASE, attrs=["objectClass"])
- assertEquals(len(res), 1)
-
- assertEquals(res[0]["objectClass"], ["top", "domain", "domainDNS"])
-
-# check enumeration
-
- print "Testing ldb.search for objectCategory=person"
- res = ldb.search(base_dn, expression="objectCategory=person", scope=SCOPE_SUBTREE, attrs=["cn"])
- assert(len(res) > 0)
-
- print "Testing ldb.search for objectCategory=person with domain scope control"
- res = ldb.search(base_dn, expression="objectCategory=person", scope=SCOPE_SUBTREE, attrs=["cn"], controls=["domain_scope:1"])
- assert(len(res) > 0)
-
- print "Testing ldb.search for objectCategory=user"
- res = ldb.search(base_dn, expression="objectCategory=user", scope=SCOPE_SUBTREE, attrs=["cn"])
- assert(len(res) > 0)
-
-
- print "Testing ldb.search for objectCategory=user with domain scope control"
- res = ldb.search(base_dn, expression="objectCategory=user", scope=SCOPE_SUBTREE, attrs=["cn"], controls=["domain_scope:1"])
- assert(len(res) > 0)
-
- print "Testing ldb.search for objectCategory=group"
- res = ldb.search(base_dn, expression="objectCategory=group", scope=SCOPE_SUBTREE, attrs=["cn"])
- assert(len(res) > 0)
-
- print "Testing ldb.search for objectCategory=group with domain scope control"
- res = ldb.search(base_dn, expression="objectCategory=group", scope=SCOPE_SUBTREE, attrs=["cn"], controls=["domain_scope:1"])
- assert(len(res) > 0)
-
-def basedn_tests(ldb, gc_ldb):
- print "Testing for all rootDSE attributes"
- res = ldb.search(scope=SCOPE_BASE, attrs=[])
- assertEquals(len(res), 1)
-
- print "Testing for highestCommittedUSN"
- res = ldb.search("", scope=SCOPE_BASE, attrs=["highestCommittedUSN"])
- assertEquals(len(res), 1)
- assert(int(res[0]["highestCommittedUSN"][0]) != 0)
-
- print "Testing for netlogon via LDAP"
- res = ldb.search("", scope=SCOPE_BASE, attrs=["netlogon"])
- assertEquals(len(res), 0)
-
- print "Testing for netlogon and highestCommittedUSN via LDAP"
- res = ldb.search("", scope=SCOPE_BASE,
- attrs=["netlogon", "highestCommittedUSN"])
- assertEquals(len(res), 0)
-
-
-def find_basedn(ldb):
- res = ldb.search(base="", expression="", scope=SCOPE_BASE,
- attrs=["defaultNamingContext"])
- assertEquals(len(res), 1)
- return res[0]["defaultNamingContext"][0]
-
-
-def find_configurationdn(ldb):
- res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["configurationNamingContext"])
- assertEquals(len(res), 1)
- return res[0]["configurationNamingContext"][0]
-
-
-def find_schemadn(ldb):
- res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["schemaNamingContext"])
- assertEquals(len(res), 1)
- return res[0]["schemaNamingContext"][0]
+ res = ldb.search(self.configuration_dn, expression="objectCategory=CN=ntDs-DSA," + self.schema_dn, scope=SCOPE_SUBTREE, attrs=["cn"])
+ self.assertTrue(len(res) > 0, "Didn't find any records with objectCategory=CN=ntDs-DSA," + self.schema_dn)
+ self.assertTrue(len(res) != 0)
+
+ print "Testing objectClass attribute order on "+ self.base_dn
+ res = ldb.search(expression="objectClass=domain", base=self.base_dn,
+ scope=SCOPE_BASE, attrs=["objectClass"])
+ self.assertEquals(len(res), 1)
+
+ self.assertEquals(res[0]["objectClass"], ["top", "domain", "domainDNS"])
+
+ # check enumeration
+
+ print "Testing ldb.search for objectCategory=person"
+ res = ldb.search(self.base_dn, expression="objectCategory=person", scope=SCOPE_SUBTREE, attrs=["cn"])
+ self.assertTrue(len(res) > 0)
+
+ print "Testing ldb.search for objectCategory=person with domain scope control"
+ res = ldb.search(self.base_dn, expression="objectCategory=person", scope=SCOPE_SUBTREE, attrs=["cn"], controls=["domain_scope:1"])
+ self.assertTrue(len(res) > 0)
+
+ print "Testing ldb.search for objectCategory=user"
+ res = ldb.search(self.base_dn, expression="objectCategory=user", scope=SCOPE_SUBTREE, attrs=["cn"])
+ self.assertTrue(len(res) > 0)
+
+ print "Testing ldb.search for objectCategory=user with domain scope control"
+ res = ldb.search(self.base_dn, expression="objectCategory=user", scope=SCOPE_SUBTREE, attrs=["cn"], controls=["domain_scope:1"])
+ self.assertTrue(len(res) > 0)
+
+ print "Testing ldb.search for objectCategory=group"
+ res = ldb.search(self.base_dn, expression="objectCategory=group", scope=SCOPE_SUBTREE, attrs=["cn"])
+ self.assertTrue(len(res) > 0)
+
+ print "Testing ldb.search for objectCategory=group with domain scope control"
+ res = ldb.search(self.base_dn, expression="objectCategory=group", scope=SCOPE_SUBTREE, attrs=["cn"], controls=["domain_scope:1"])
+ self.assertTrue(len(res) > 0)
+
+
+class BaseDnTests(unittest.TestCase):
+ def setUp(self):
+ self.ldb = ldb
+
+ def test_rootdse_attrs(self):
+ """Testing for all rootDSE attributes"""
+ res = self.ldb.search(scope=SCOPE_BASE, attrs=[])
+ self.assertEquals(len(res), 1)
+
+ def test_highestcommittedusn(self):
+ """Testing for highestCommittedUSN"""
+ res = self.ldb.search("", scope=SCOPE_BASE, attrs=["highestCommittedUSN"])
+ self.assertEquals(len(res), 1)
+ self.assertTrue(int(res[0]["highestCommittedUSN"][0]) != 0)
+
+ def test_netlogon(self):
+ """Testing for netlogon via LDAP"""
+ res = self.ldb.search("", scope=SCOPE_BASE, attrs=["netlogon"])
+ self.assertEquals(len(res), 0)
+
+ def test_netlogon_highestcommitted_usn(self):
+ """Testing for netlogon and highestCommittedUSN via LDAP"""
+ res = self.ldb.search("", scope=SCOPE_BASE,
+ attrs=["netlogon", "highestCommittedUSN"])
+ self.assertEquals(len(res), 0)
+
if not "://" in host:
host = "ldap://%s" % host
ldb = Ldb(host, credentials=creds, session_info=system_session(), lp=lp)
-base_dn = find_basedn(ldb)
-configuration_dn = find_configurationdn(ldb)
-schema_dn = find_schemadn(ldb)
-
-print "baseDN: %s\n" % base_dn
-
gc_ldb = Ldb("%s:3268" % host, credentials=creds,
session_info=system_session(), lp=lp)
-basic_tests(ldb, gc_ldb, base_dn, configuration_dn, schema_dn)
-basedn_tests(ldb, gc_ldb)
+runner = SubunitTestRunner()
+runner.run(unittest.makeSuite(BaseDnTests))
+runner.run(unittest.makeSuite(BasicTests))
diff --git a/source4/lib/ldb/tests/sample_module.c b/source4/lib/ldb/tests/sample_module.c
index 8ab1d33146..98d8e865dd 100644
--- a/source4/lib/ldb/tests/sample_module.c
+++ b/source4/lib/ldb/tests/sample_module.c
@@ -32,12 +32,7 @@ int sample_add(struct ldb_module *mod, struct ldb_request *req)
return ldb_next_request(mod, req);
}
-static const struct ldb_module_ops sample_ops = {
- .name = "sample_module",
+_PUBLIC_ const struct ldb_module_ops ldb_sample_module_ops = {
+ .name = "sample",
.add = sample_add,
};
-
-int init_module(void)
-{
- return ldb_register_module(&sample_ops);
-}
diff --git a/source4/lib/ldb/tools/ad2oLschema.c b/source4/lib/ldb/tools/ad2oLschema.c
index dec8a5f972..67b16dd06e 100644
--- a/source4/lib/ldb/tools/ad2oLschema.c
+++ b/source4/lib/ldb/tools/ad2oLschema.c
@@ -656,8 +656,6 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_
const char *target_str;
enum convert_target target;
- ldb_global_init();
-
ctx = talloc_new(NULL);
ldb = ldb_init(ctx);
diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c
index 8ee1994615..c9c77c4e47 100644
--- a/source4/lib/ldb/tools/cmdline.c
+++ b/source4/lib/ldb/tools/cmdline.c
@@ -80,8 +80,6 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb,
{ NULL }
};
- ldb_global_init();
-
#if (_SAMBA_BUILD_ >= 4)
r = ldb_register_samba_handlers(ldb);
if (r != 0) {
diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c
index d34193b86c..4ee66c4fc0 100644
--- a/source4/lib/ldb/tools/ldbadd.c
+++ b/source4/lib/ldb/tools/ldbadd.c
@@ -88,8 +88,6 @@ int main(int argc, const char **argv)
int i, ret=0, count=0;
struct ldb_cmdline *options;
- ldb_global_init();
-
ldb = ldb_init(NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c
index fcd0978779..184172b22b 100644
--- a/source4/lib/ldb/tools/ldbdel.c
+++ b/source4/lib/ldb/tools/ldbdel.c
@@ -77,8 +77,6 @@ int main(int argc, const char **argv)
int ret = 0, i;
struct ldb_cmdline *options;
- ldb_global_init();
-
ldb = ldb_init(NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c
index ed98a6d615..a9fd064bf8 100644
--- a/source4/lib/ldb/tools/ldbedit.c
+++ b/source4/lib/ldb/tools/ldbedit.c
@@ -279,8 +279,6 @@ int main(int argc, const char **argv)
const char *expression = "(|(objectClass=*)(distinguishedName=*))";
const char * const * attrs = NULL;
- ldb_global_init();
-
ldb = ldb_init(NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source4/lib/ldb/tools/ldbmodify.c b/source4/lib/ldb/tools/ldbmodify.c
index ed12380095..dd6206b824 100644
--- a/source4/lib/ldb/tools/ldbmodify.c
+++ b/source4/lib/ldb/tools/ldbmodify.c
@@ -89,8 +89,6 @@ int main(int argc, const char **argv)
int i, ret=LDB_SUCCESS;
struct ldb_cmdline *options;
- ldb_global_init();
-
ldb = ldb_init(NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source4/lib/ldb/tools/ldbrename.c b/source4/lib/ldb/tools/ldbrename.c
index c160e87ee4..b36310a500 100644
--- a/source4/lib/ldb/tools/ldbrename.c
+++ b/source4/lib/ldb/tools/ldbrename.c
@@ -56,8 +56,6 @@ int main(int argc, const char **argv)
struct ldb_cmdline *options;
struct ldb_dn *dn1, *dn2;
- ldb_global_init();
-
ldb = ldb_init(NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c
index 24ceb30963..e25bd19965 100644
--- a/source4/lib/ldb/tools/ldbsearch.c
+++ b/source4/lib/ldb/tools/ldbsearch.c
@@ -276,8 +276,6 @@ int main(int argc, const char **argv)
int ret = -1;
const char *expression = "(|(objectClass=*)(distinguishedName=*))";
- ldb_global_init();
-
ldb = ldb_init(NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source4/lib/ldb/tools/ldbtest.c b/source4/lib/ldb/tools/ldbtest.c
index 5c21dd3830..57a7848733 100644
--- a/source4/lib/ldb/tools/ldbtest.c
+++ b/source4/lib/ldb/tools/ldbtest.c
@@ -393,8 +393,6 @@ int main(int argc, const char **argv)
TALLOC_CTX *mem_ctx = talloc_new(NULL);
struct ldb_context *ldb;
- ldb_global_init();
-
ldb = ldb_init(mem_ctx);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source4/lib/ldb/tools/oLschema2ldif.c b/source4/lib/ldb/tools/oLschema2ldif.c
index 7b5f1b835c..1846a2c852 100644
--- a/source4/lib/ldb/tools/oLschema2ldif.c
+++ b/source4/lib/ldb/tools/oLschema2ldif.c
@@ -560,8 +560,6 @@ static void usage(void)
struct ldb_cmdline *options;
FILE *in = stdin;
FILE *out = stdout;
- ldb_global_init();
-
ctx = talloc_new(NULL);
ldb_ctx = ldb_init(ctx);
diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c
index 262859f64b..0c8a55396e 100644
--- a/source4/lib/registry/ldb.c
+++ b/source4/lib/registry/ldb.c
@@ -400,7 +400,7 @@ static WERROR ldb_add_key(TALLOC_CTX *mem_ctx, const struct hive_key *parent,
struct security_descriptor *sd,
struct hive_key **newkey)
{
- struct ldb_key_data *parentkd = (const struct ldb_key_data *)parent;
+ struct ldb_key_data *parentkd = discard_const_p(struct ldb_key_data, parent);
struct ldb_message *msg;
struct ldb_key_data *newkd;
int ret;
diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c
index 93f28f3e5a..d5c506ab31 100644
--- a/source4/lib/registry/tools/regshell.c
+++ b/source4/lib/registry/tools/regshell.c
@@ -116,6 +116,9 @@ static WERROR cmd_predef(struct regshell_context *ctx, int argc, char **argv)
argv[1], win_errstr(error));
return error;
}
+
+ ctx->path = strupper_talloc(ctx, argv[1]);
+ ctx->current = ret;
}
return WERR_OK;
diff --git a/source4/lib/replace/dlfcn.c b/source4/lib/replace/dlfcn.c
index 42848848e8..3b109d7e40 100644
--- a/source4/lib/replace/dlfcn.c
+++ b/source4/lib/replace/dlfcn.c
@@ -35,6 +35,8 @@ void *rep_dlopen(const char *name, int flags)
#endif
{
#ifdef HAVE_SHL_LOAD
+ if (name == NULL)
+ return PROG_HANDLE;
return (void *)shl_load(name, flags, 0);
#else
return NULL;
diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4
index 297a82d0c3..4cf86d89cc 100644
--- a/source4/lib/replace/getifaddrs.m4
+++ b/source4/lib/replace/getifaddrs.m4
@@ -7,7 +7,7 @@ AC_CHECK_MEMBERS([struct sockaddr.sa_len],
[#include <sys/socket.h>])
dnl test for getifaddrs and freeifaddrs
-AC_CACHE_CHECK([for getifaddrs and freeifaddrs],samba_cv_HAVE_GETIFADDRS,[
+AC_CACHE_CHECK([for getifaddrs and freeifaddrs],libreplace_cv_HAVE_GETIFADDRS,[
AC_TRY_COMPILE([
#include <sys/types.h>
#if STDC_HEADERS
@@ -24,8 +24,8 @@ struct ifaddrs *ifp = NULL;
int ret = getifaddrs (&ifp);
freeifaddrs(ifp);
],
-samba_cv_HAVE_GETIFADDRS=yes,samba_cv_HAVE_GETIFADDRS=no)])
-if test x"$samba_cv_HAVE_GETIFADDRS" = x"yes"; then
+libreplace_cv_HAVE_GETIFADDRS=yes,libreplace_cv_HAVE_GETIFADDRS=no)])
+if test x"$libreplace_cv_HAVE_GETIFADDRS" = x"yes"; then
AC_DEFINE(HAVE_GETIFADDRS,1,[Whether the system has getifaddrs])
AC_DEFINE(HAVE_FREEIFADDRS,1,[Whether the system has freeifaddrs])
AC_DEFINE(HAVE_STRUCT_IFADDRS,1,[Whether struct ifaddrs is available])
@@ -42,18 +42,15 @@ iface=no;
##################
# look for a method of finding the list of network interfaces
iface=no;
-AC_CACHE_CHECK([for iface getifaddrs],samba_cv_HAVE_IFACE_GETIFADDRS,[
-SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
+AC_CACHE_CHECK([for iface getifaddrs],libreplace_cv_HAVE_IFACE_GETIFADDRS,[
AC_TRY_RUN([
#define NO_CONFIG_H 1
#define HAVE_IFACE_GETIFADDRS 1
#define AUTOCONF_TEST 1
#include "$libreplacedir/replace.c"
#include "$libreplacedir/getifaddrs.c"],
- samba_cv_HAVE_IFACE_GETIFADDRS=yes,samba_cv_HAVE_IFACE_GETIFADDRS=no,samba_cv_HAVE_IFACE_GETIFADDRS=cross)])
-CPPFLAGS="$SAVE_CPPFLAGS"
-if test x"$samba_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then
+ libreplace_cv_HAVE_IFACE_GETIFADDRS=yes,libreplace_cv_HAVE_IFACE_GETIFADDRS=no,libreplace_cv_HAVE_IFACE_GETIFADDRS=cross)])
+if test x"$libreplace_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then
iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available])
else
LIBREPLACEOBJ="${LIBREPLACEOBJ} getifaddrs.o"
@@ -61,39 +58,39 @@ fi
if test $iface = no; then
-AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
+AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[
AC_TRY_RUN([
#define HAVE_IFACE_AIX 1
#define AUTOCONF_TEST 1
#undef _XOPEN_SOURCE_EXTENDED
#include "$libreplacedir/getifaddrs.c"],
- samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
-if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
+ libreplace_cv_HAVE_IFACE_AIX=yes,libreplace_cv_HAVE_IFACE_AIX=no,libreplace_cv_HAVE_IFACE_AIX=cross)])
+if test x"$libreplace_cv_HAVE_IFACE_AIX" = x"yes"; then
iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
fi
fi
if test $iface = no; then
-AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
+AC_CACHE_CHECK([for iface ifconf],libreplace_cv_HAVE_IFACE_IFCONF,[
AC_TRY_RUN([
#define HAVE_IFACE_IFCONF 1
#define AUTOCONF_TEST 1
#include "$libreplacedir/getifaddrs.c"],
- samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
-if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
+ libreplace_cv_HAVE_IFACE_IFCONF=yes,libreplace_cv_HAVE_IFACE_IFCONF=no,libreplace_cv_HAVE_IFACE_IFCONF=cross)])
+if test x"$libreplace_cv_HAVE_IFACE_IFCONF" = x"yes"; then
iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
fi
fi
if test $iface = no; then
-AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
+AC_CACHE_CHECK([for iface ifreq],libreplace_cv_HAVE_IFACE_IFREQ,[
AC_TRY_RUN([
#define HAVE_IFACE_IFREQ 1
#define AUTOCONF_TEST 1
#include "$libreplacedir/getifaddrs.c"],
- samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
-if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
+ libreplace_cv_HAVE_IFACE_IFREQ=yes,libreplace_cv_HAVE_IFACE_IFREQ=no,libreplace_cv_HAVE_IFACE_IFREQ=cross)])
+if test x"$libreplace_cv_HAVE_IFACE_IFREQ" = x"yes"; then
iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
fi
fi
diff --git a/source4/lib/replace/getpass.m4 b/source4/lib/replace/getpass.m4
index c4da9aae59..b93817f9d3 100644
--- a/source4/lib/replace/getpass.m4
+++ b/source4/lib/replace/getpass.m4
@@ -1,22 +1,22 @@
-AC_CHECK_FUNC(getpass, samba_cv_HAVE_GETPASS=yes)
-AC_CHECK_FUNC(getpassphrase, samba_cv_HAVE_GETPASSPHRASE=yes)
-if test x"$samba_cv_HAVE_GETPASS" = x"yes" -a x"$samba_cv_HAVE_GETPASSPHRASE" = x"yes"; then
+AC_CHECK_FUNC(getpass, libreplace_cv_HAVE_GETPASS=yes)
+AC_CHECK_FUNC(getpassphrase, libreplace_cv_HAVE_GETPASSPHRASE=yes)
+if test x"$libreplace_cv_HAVE_GETPASS" = x"yes" -a x"$libreplace_cv_HAVE_GETPASSPHRASE" = x"yes"; then
AC_DEFINE(REPLACE_GETPASS_BY_GETPASSPHRASE, 1, [getpass returns <9 chars where getpassphrase returns <265 chars])
AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
LIBREPLACEOBJ="${LIBREPLACEOBJ} getpass.o"
else
-AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
+AC_CACHE_CHECK([whether getpass should be replaced],libreplace_cv_REPLACE_GETPASS,[
SAVE_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I$libreplacedir/"
AC_TRY_COMPILE([
#include "confdefs.h"
#define NO_CONFIG_H
#include "$libreplacedir/getpass.c"
-],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
+],[],libreplace_cv_REPLACE_GETPASS=yes,libreplace_cv_REPLACE_GETPASS=no)
CPPFLAGS="$SAVE_CPPFLAGS"
])
-if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
+if test x"$libreplace_cv_REPLACE_GETPASS" = x"yes"; then
AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
LIBREPLACEOBJ="${LIBREPLACEOBJ} getpass.o"
fi
diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4
index 6d1d6b8afc..2e0cd34f4a 100644
--- a/source4/lib/replace/libreplace.m4
+++ b/source4/lib/replace/libreplace.m4
@@ -85,10 +85,10 @@ AC_INCLUDES_DEFAULT
#endif]
)
-AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
+AC_CACHE_CHECK([for working mmap],libreplace_cv_HAVE_MMAP,[
AC_TRY_RUN([#include "$libreplacedir/test/shared_mmap.c"],
- samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
-if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
+ libreplace_cv_HAVE_MMAP=yes,libreplace_cv_HAVE_MMAP=no,libreplace_cv_HAVE_MMAP=cross)])
+if test x"$libreplace_cv_HAVE_MMAP" = x"yes"; then
AC_DEFINE(HAVE_MMAP,1,[Whether mmap works])
fi
@@ -120,7 +120,7 @@ if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then
AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h)
fi
-AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
+AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[
AC_TRY_RUN([
#include <stdio.h>
#include <unistd.h>
@@ -133,8 +133,8 @@ main() { struct in_addr ip; ip.s_addr = 0x12345678;
if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); }
exit(1);}],
- samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
-if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
+ libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)])
+if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then
AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
fi
@@ -182,7 +182,7 @@ AC_HAVE_DECL(setresuid, [#include <unistd.h>])
AC_HAVE_DECL(setresgid, [#include <unistd.h>])
AC_HAVE_DECL(errno, [#include <errno.h>])
-AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
+AC_CACHE_CHECK([for secure mkstemp],libreplace_cv_HAVE_SECURE_MKSTEMP,[
AC_TRY_RUN([#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -197,10 +197,10 @@ main() {
if ((st.st_mode & 0777) != 0600) exit(1);
exit(0);
}],
-samba_cv_HAVE_SECURE_MKSTEMP=yes,
-samba_cv_HAVE_SECURE_MKSTEMP=no,
-samba_cv_HAVE_SECURE_MKSTEMP=cross)])
-if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
+libreplace_cv_HAVE_SECURE_MKSTEMP=yes,
+libreplace_cv_HAVE_SECURE_MKSTEMP=no,
+libreplace_cv_HAVE_SECURE_MKSTEMP=cross)])
+if test x"$libreplace_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
fi
@@ -209,7 +209,7 @@ AC_CHECK_HEADERS(stdio.h strings.h)
AC_CHECK_DECLS([snprintf, vsnprintf, asprintf, vasprintf])
AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
-AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
+AC_CACHE_CHECK([for C99 vsnprintf],libreplace_cv_HAVE_C99_VSNPRINTF,[
AC_TRY_RUN([
#include <sys/types.h>
#include <stdio.h>
@@ -243,43 +243,43 @@ void foo(const char *format, ...) {
}
main() { foo("hello"); }
],
-samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
-if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
+libreplace_cv_HAVE_C99_VSNPRINTF=yes,libreplace_cv_HAVE_C99_VSNPRINTF=no,libreplace_cv_HAVE_C99_VSNPRINTF=cross)])
+if test x"$libreplace_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
fi
dnl VA_COPY
-AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[
+AC_CACHE_CHECK([for va_copy],libreplace_cv_HAVE_VA_COPY,[
AC_TRY_LINK([#include <stdarg.h>
va_list ap1,ap2;], [va_copy(ap1,ap2);],
-samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)])
-if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
+libreplace_cv_HAVE_VA_COPY=yes,libreplace_cv_HAVE_VA_COPY=no)])
+if test x"$libreplace_cv_HAVE_VA_COPY" = x"yes"; then
AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
fi
-if test x"$samba_cv_HAVE_VA_COPY" != x"yes"; then
-AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[
+if test x"$libreplace_cv_HAVE_VA_COPY" != x"yes"; then
+AC_CACHE_CHECK([for __va_copy],libreplace_cv_HAVE___VA_COPY,[
AC_TRY_LINK([#include <stdarg.h>
va_list ap1,ap2;], [__va_copy(ap1,ap2);],
-samba_cv_HAVE___VA_COPY=yes,samba_cv_HAVE___VA_COPY=no)])
-if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then
+libreplace_cv_HAVE___VA_COPY=yes,libreplace_cv_HAVE___VA_COPY=no)])
+if test x"$libreplace_cv_HAVE___VA_COPY" = x"yes"; then
AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
fi
fi
dnl __FUNCTION__ macro
-AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
+AC_CACHE_CHECK([for __FUNCTION__ macro],libreplace_cv_HAVE_FUNCTION_MACRO,[
AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
-samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
-if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
+libreplace_cv_HAVE_FUNCTION_MACRO=yes,libreplace_cv_HAVE_FUNCTION_MACRO=no)])
+if test x"$libreplace_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
else
dnl __func__ macro
- AC_CACHE_CHECK([for __func__ macro],samba_cv_HAVE_func_MACRO,[
+ AC_CACHE_CHECK([for __func__ macro],libreplace_cv_HAVE_func_MACRO,[
AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __func__);],
- samba_cv_HAVE_func_MACRO=yes,samba_cv_HAVE_func_MACRO=no)])
- if test x"$samba_cv_HAVE_func_MACRO" = x"yes"; then
+ libreplace_cv_HAVE_func_MACRO=yes,libreplace_cv_HAVE_func_MACRO=no)])
+ if test x"$libreplace_cv_HAVE_func_MACRO" = x"yes"; then
AC_DEFINE(HAVE_func_MACRO,1,[Whether there is a __func__ macro])
fi
fi
@@ -302,7 +302,7 @@ eprintf("bla", "bar");
], AC_DEFINE(HAVE__VA_ARGS__MACRO, 1, [Whether the __VA_ARGS__ macro is available]))
-AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
+AC_CACHE_CHECK([for sig_atomic_t type],libreplace_cv_sig_atomic_t, [
AC_TRY_COMPILE([
#include <sys/types.h>
#if STDC_HEADERS
@@ -310,30 +310,30 @@ AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
#include <stddef.h>
#endif
#include <signal.h>],[sig_atomic_t i = 0],
- samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
-if test x"$samba_cv_sig_atomic_t" = x"yes"; then
+ libreplace_cv_sig_atomic_t=yes,libreplace_cv_sig_atomic_t=no)])
+if test x"$libreplace_cv_sig_atomic_t" = x"yes"; then
AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
fi
-AC_CACHE_CHECK([for O_DIRECT flag to open(2)],samba_cv_HAVE_OPEN_O_DIRECT,[
+AC_CACHE_CHECK([for O_DIRECT flag to open(2)],libreplace_cv_HAVE_OPEN_O_DIRECT,[
AC_TRY_COMPILE([
#include <unistd.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif],
[int fd = open("/dev/null", O_DIRECT);],
-samba_cv_HAVE_OPEN_O_DIRECT=yes,samba_cv_HAVE_OPEN_O_DIRECT=no)])
-if test x"$samba_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then
+libreplace_cv_HAVE_OPEN_O_DIRECT=yes,libreplace_cv_HAVE_OPEN_O_DIRECT=no)])
+if test x"$libreplace_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then
AC_DEFINE(HAVE_OPEN_O_DIRECT,1,[Whether the open(2) accepts O_DIRECT])
fi
dnl Check if the C compiler understands volatile (it should, being ANSI).
-AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
+AC_CACHE_CHECK([that the C compiler understands volatile],libreplace_cv_volatile, [
AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
- samba_cv_volatile=yes,samba_cv_volatile=no)])
-if test x"$samba_cv_volatile" = x"yes"; then
+ libreplace_cv_volatile=yes,libreplace_cv_volatile=no)])
+if test x"$libreplace_cv_volatile" = x"yes"; then
AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
fi
diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4
index 2aec698967..f0d10c1e3e 100644
--- a/source4/lib/replace/libreplace_ld.m4
+++ b/source4/lib/replace/libreplace_ld.m4
@@ -289,6 +289,9 @@ AC_DEFUN([AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR],
*linux*)
LIB_PATH_VAR=LD_LIBRARY_PATH
;;
+ *netbsd*)
+ LIB_PATH_VAR=LD_LIBRARY_PATH
+ ;;
*solaris*)
LIB_PATH_VAR=LD_LIBRARY_PATH
;;
diff --git a/source4/lib/replace/system/config.m4 b/source4/lib/replace/system/config.m4
index 1c05733126..66c2bd652a 100644
--- a/source4/lib/replace/system/config.m4
+++ b/source4/lib/replace/system/config.m4
@@ -18,7 +18,7 @@ AC_CHECK_HEADERS(sys/capability.h)
case "$host_os" in
*linux*)
-AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
+AC_CACHE_CHECK([for broken RedHat 7.2 system header files],libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
AC_TRY_COMPILE([
#ifdef HAVE_SYS_VFS_H
#include <sys/vfs.h>
@@ -29,14 +29,14 @@ AC_TRY_COMPILE([
],[
int i;
],
- samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,
- samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes
+ libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,
+ libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes
)])
-if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
+if test x"$libreplace_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files])
fi
-AC_CACHE_CHECK([for broken RHEL5 sys/capability.h],samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER,[
+AC_CACHE_CHECK([for broken RHEL5 sys/capability.h],libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER,[
AC_TRY_COMPILE([
#ifdef HAVE_SYS_CAPABILITY_H
#include <sys/capability.h>
@@ -45,10 +45,10 @@ AC_TRY_COMPILE([
],[
__s8 i;
],
- samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER=no,
- samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER=yes
+ libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER=no,
+ libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER=yes
)])
-if test x"$samba_cv_BROKEN_RHEL5_SYS_CAP_HEADER" = x"yes"; then
+if test x"$libreplace_cv_BROKEN_RHEL5_SYS_CAP_HEADER" = x"yes"; then
AC_DEFINE(BROKEN_RHEL5_SYS_CAP_HEADER,1,[Broken RHEL5 sys/capability.h])
fi
;;
diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h
index 53bef66d48..d09e3f71f8 100644
--- a/source4/lib/replace/system/network.h
+++ b/source4/lib/replace/system/network.h
@@ -163,8 +163,15 @@ void rep_freeifaddrs(struct ifaddrs *);
#endif
#ifndef AI_ADDRCONFIG
+/*
+ * logic copied from AI_NUMERICHOST
+ */
+#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
+#define AI_ADDRCONFIG 0
+#else
#define AI_ADDRCONFIG 0x0020
#endif
+#endif
#ifndef AI_NUMERICSERV
/*
diff --git a/source4/lib/samba3/config.mk b/source4/lib/samba3/config.mk
index 705bdd4002..2d129c5f8c 100644
--- a/source4/lib/samba3/config.mk
+++ b/source4/lib/samba3/config.mk
@@ -1,19 +1,5 @@
################################################
# Start SUBSYSTEM LIBSAMBA3
-[SUBSYSTEM::LIBSAMBA3]
-PRIVATE_PROTO_HEADER = samba3_proto.h
-PUBLIC_HEADERS = samba3.h
-OBJ_FILES = tdbsam.o policy.o \
- idmap.o winsdb.o samba3.o group.o \
- registry.o secrets.o share_info.o
-PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBTDB NDR_SECURITY \
- SMBPASSWD LIBSECURITY
-PUBLIC_DEPENDENCIES = CREDENTIALS
-# End SUBSYSTEM LIBSAMBA3
-################################################
-
-################################################
-# Start SUBSYSTEM LIBSAMBA3
[SUBSYSTEM::SMBPASSWD]
PRIVATE_PROTO_HEADER = samba3_smbpasswd_proto.h
OBJ_FILES = smbpasswd.o
diff --git a/source4/lib/samba3/group.c b/source4/lib/samba3/group.c
deleted file mode 100644
index a0b4c15f0c..0000000000
--- a/source4/lib/samba3/group.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * RPC Pipe client / server routines
- * Copyright (C) Andrew Tridgell 1992-2000,
- * Copyright (C) Jean François Micouleau 1998-2001.
- *
- * 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 "lib/samba3/samba3.h"
-#include "lib/tdb/include/tdb.h"
-#include "lib/util/util_tdb.h"
-#include "system/filesys.h"
-#include "libcli/security/security.h"
-
-#define DATABASE_VERSION_V1 1 /* native byte format. */
-#define DATABASE_VERSION_V2 2 /* le format. */
-
-#define GROUP_PREFIX "UNIXGROUP/"
-
-/* Alias memberships are stored reverse, as memberships. The performance
- * critical operation is to determine the aliases a SID is member of, not
- * listing alias members. So we store a list of alias SIDs a SID is member of
- * hanging of the member as key.
- */
-#define MEMBEROF_PREFIX "MEMBEROF/"
-
-/****************************************************************************
- Open the group mapping tdb.
-****************************************************************************/
-NTSTATUS samba3_read_grouptdb(const char *file, TALLOC_CTX *ctx, struct samba3_groupdb *db)
-{
- int32_t vers_id;
- TDB_DATA kbuf, dbuf, newkey;
- int ret;
- TDB_CONTEXT *tdb;
-
- tdb = tdb_open(file, 0, TDB_DEFAULT, O_RDONLY, 0600);
- if (!tdb) {
- DEBUG(0,("Failed to open group mapping database\n"));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- /* Cope with byte-reversed older versions of the db. */
- vers_id = tdb_fetch_int32(tdb, "INFO/version");
- if ((vers_id == DATABASE_VERSION_V1) || (IREV(vers_id) == DATABASE_VERSION_V1)) {
- /* Written on a bigendian machine with old fetch_int code. Save as le. */
- vers_id = DATABASE_VERSION_V2;
- }
-
- if (vers_id != DATABASE_VERSION_V2) {
- DEBUG(0, ("Group database version mismatch: %d\n", vers_id));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- db->groupmappings = NULL;
- db->groupmap_count = 0;
- db->aliases = NULL;
- db->alias_count = 0;
-
- for (kbuf = tdb_firstkey(tdb);
- kbuf.dptr;
- newkey = tdb_nextkey(tdb, kbuf), free(kbuf.dptr), kbuf=newkey) {
- struct samba3_groupmapping map;
- const char *k = (const char *)kbuf.dptr;
-
- if (strncmp(k, GROUP_PREFIX, strlen(GROUP_PREFIX)) == 0)
- {
- dbuf = tdb_fetch(tdb, kbuf);
- if (!dbuf.dptr)
- continue;
-
- ZERO_STRUCT(map);
-
- map.sid = dom_sid_parse_talloc(ctx, k+strlen(GROUP_PREFIX));
-
- ret = tdb_unpack(tdb, (char *)dbuf.dptr, dbuf.dsize, "dd",
- &map.gid, &map.sid_name_use);
-
- if ( ret == -1 ) {
- DEBUG(3,("enum_group_mapping: tdb_unpack failure\n"));
- continue;
- }
-
- map.nt_name = talloc_strdup(ctx, (const char *)(dbuf.dptr+ret));
- map.comment = talloc_strdup(ctx, (const char *)(dbuf.dptr+ret+strlen(map.nt_name)));
-
- db->groupmappings = talloc_realloc(ctx, db->groupmappings, struct samba3_groupmapping, db->groupmap_count+1);
-
- if (!db->groupmappings)
- return NT_STATUS_NO_MEMORY;
-
- db->groupmappings[db->groupmap_count] = map;
-
- db->groupmap_count++;
- } else if (strncmp(k, MEMBEROF_PREFIX, strlen(MEMBEROF_PREFIX)) == 0)
- {
- struct samba3_alias alias;
- const char **member_strlist;
- int i;
-
- dbuf = tdb_fetch(tdb, kbuf);
- if (!dbuf.dptr)
- continue;
-
- alias.sid = dom_sid_parse_talloc(ctx, k+strlen(MEMBEROF_PREFIX));
- alias.member_count = 0;
- alias.members = NULL;
-
- member_strlist = str_list_make_shell(ctx, (const char *)dbuf.dptr, " ");
-
- for (i = 0; member_strlist[i]; i++) {
- alias.members = talloc_realloc(ctx, alias.members, struct dom_sid *, alias.member_count+1);
- alias.members[alias.member_count] = dom_sid_parse_talloc(ctx, member_strlist[i]);
- alias.member_count++;
- }
-
- talloc_free(member_strlist);
-
- db->aliases = talloc_realloc(ctx, db->aliases, struct samba3_alias, db->alias_count+1);
- db->aliases[db->alias_count] = alias;
- db->alias_count++;
- }
- }
-
- tdb_close(tdb);
-
- return NT_STATUS_OK;
-}
diff --git a/source4/lib/samba3/idmap.c b/source4/lib/samba3/idmap.c
deleted file mode 100644
index 3eeb2931a8..0000000000
--- a/source4/lib/samba3/idmap.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- idmap TDB backend
-
- Copyright (C) Tim Potter 2000
- Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
- Copyright (C) Simo Sorce 2003
- Copyright (C) Jelmer Vernooij 2005
-
- 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 "lib/tdb/include/tdb.h"
-#include "lib/util/util_tdb.h"
-#include "lib/samba3/samba3.h"
-#include "system/filesys.h"
-#include "libcli/security/security.h"
-
-/* High water mark keys */
-#define HWM_GROUP "GROUP HWM"
-#define HWM_USER "USER HWM"
-
-/* idmap version determines auto-conversion */
-#define IDMAP_VERSION 2
-
-/*****************************************************************************
- Initialise idmap database.
-*****************************************************************************/
-
-NTSTATUS samba3_read_idmap(const char *fn, TALLOC_CTX *ctx, struct samba3_idmapdb *idmap)
-{
- TDB_CONTEXT *tdb;
- TDB_DATA key, val;
- int32_t version;
-
- /* Open idmap repository */
- if (!(tdb = tdb_open(fn, 0, TDB_DEFAULT, O_RDONLY, 0644))) {
- DEBUG(0, ("idmap_init: Unable to open idmap database '%s'\n", fn));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- idmap->mapping_count = 0;
- idmap->mappings = NULL;
- idmap->user_hwm = tdb_fetch_int32(tdb, HWM_USER);
- idmap->group_hwm = tdb_fetch_int32(tdb, HWM_GROUP);
-
- /* check against earlier versions */
- version = tdb_fetch_int32(tdb, "IDMAP_VERSION");
- if (version != IDMAP_VERSION) {
- DEBUG(0, ("idmap_init: Unable to open idmap database, it's in an old format!\n"));
- return NT_STATUS_INTERNAL_DB_ERROR;
- }
-
- for (key = tdb_firstkey(tdb); key.dptr; key = tdb_nextkey(tdb, key))
- {
- struct samba3_idmap_mapping map;
- const char *k = (const char *)key.dptr;
- const char *v;
-
- if (strncmp(k, "GID ", 4) == 0) {
- map.type = IDMAP_GROUP;
- map.unix_id = atoi(k+4);
- val = tdb_fetch(tdb, key);
- v = (const char *)val.dptr;
- map.sid = dom_sid_parse_talloc(ctx, v);
- } else if (strncmp(k, "UID ", 4) == 0) {
- map.type = IDMAP_USER;
- map.unix_id = atoi(k+4);
- val = tdb_fetch(tdb, key);
- v = (const char *)val.dptr;
- map.sid = dom_sid_parse_talloc(ctx, v);
- } else {
- continue;
- }
-
- idmap->mappings = talloc_realloc(ctx, idmap->mappings, struct samba3_idmap_mapping, idmap->mapping_count+1);
-
- idmap->mappings[idmap->mapping_count] = map;
- idmap->mapping_count++;
- }
-
- tdb_close(tdb);
-
- return NT_STATUS_OK;
-}
diff --git a/source4/lib/samba3/policy.c b/source4/lib/samba3/policy.c
deleted file mode 100644
index 44944770c1..0000000000
--- a/source4/lib/samba3/policy.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * account policy storage
- * Copyright (C) Jelmer Vernooij 2005
- *
- * 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 "lib/tdb/include/tdb.h"
-#include "lib/util/util_tdb.h"
-#include "lib/samba3/samba3.h"
-#include "system/filesys.h"
-
-NTSTATUS samba3_read_account_policy(const char *fn, TALLOC_CTX *ctx, struct samba3_policy *ret)
-{
- TDB_CONTEXT *tdb = tdb_open(fn, 0, TDB_DEFAULT, O_RDONLY, 0600);
- if (!tdb) {
- DEBUG(0,("Failed to open account policy database\n"));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- tdb_fetch_uint32(tdb, "min password length", &ret->min_password_length);
- tdb_fetch_uint32(tdb, "password history", &ret->password_history);
- tdb_fetch_uint32(tdb, "user must logon to change pasword", &ret->user_must_logon_to_change_password);
- tdb_fetch_uint32(tdb, "maximum password age", &ret->maximum_password_age);
- tdb_fetch_uint32(tdb, "minimum password age", &ret->minimum_password_age);
- tdb_fetch_uint32(tdb, "lockout duration", &ret->lockout_duration);
- tdb_fetch_uint32(tdb, "reset count minutes", &ret->reset_count_minutes);
- tdb_fetch_uint32(tdb, "bad lockout minutes", &ret->bad_lockout_minutes);
- tdb_fetch_uint32(tdb, "disconnect time", &ret->disconnect_time);
- tdb_fetch_uint32(tdb, "refuse machine password change", &ret->refuse_machine_password_change);
-
- /* FIXME: Read privileges as well */
-
- tdb_close(tdb);
-
- return NT_STATUS_OK;
-}
diff --git a/source4/lib/samba3/registry.c b/source4/lib/samba3/registry.c
deleted file mode 100644
index 69197883b7..0000000000
--- a/source4/lib/samba3/registry.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * Virtual Windows Registry Layer
- * Copyright (C) Gerald Carter 2002-2005
- * Copyright (C) Jelmer Vernooij 2005
- *
- * 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/>.
- */
-
-/* Implementation of internal registry database functions. */
-
-#include "includes.h"
-#include "lib/samba3/samba3.h"
-#include "librpc/gen_ndr/winreg.h"
-#include "lib/tdb/include/tdb.h"
-#include "lib/util/util_tdb.h"
-#include "system/filesys.h"
-#include "pstring.h"
-
-#define VALUE_PREFIX "SAMBA_REGVAL"
-#define REGVER_V1 1 /* first db version with write support */
-
-/****************************************************************************
- Unpack a list of registry values from the TDB
- ***************************************************************************/
-
-static int regdb_unpack_values(TDB_CONTEXT *tdb, TALLOC_CTX *ctx, struct samba3_regkey *key, TDB_DATA data )
-{
- int len = 0;
- uint32_t type;
- uint32_t size;
- uint8_t *data_p;
- uint32_t num_values = 0;
- int i;
- fstring valuename;
-
- /* loop and unpack the rest of the registry values */
-
- len += tdb_unpack(tdb, (char *)data.dptr+len, data.dsize-len, "d", &num_values);
-
- for ( i=0; i<num_values; i++ ) {
- struct samba3_regval val;
- /* unpack the next regval */
-
- type = REG_NONE;
- size = 0;
- data_p = NULL;
- len += tdb_unpack(tdb, (char *)data.dptr+len, data.dsize-len, "fdB",
- valuename,
- &val.type,
- &size,
- &data_p);
- val.name = talloc_strdup(ctx, valuename);
- val.data = data_blob_talloc(ctx, data_p, size);
-
- key->values = talloc_realloc(ctx, key->values, struct samba3_regval, key->value_count+1);
- key->values[key->value_count] = val;
- key->value_count++;
- }
-
- return len;
-}
-
-
-
-/***********************************************************************
- Open the registry database
- ***********************************************************************/
-
-NTSTATUS samba3_read_regdb ( const char *fn, TALLOC_CTX *ctx, struct samba3_regdb *db )
-{
- uint32_t vers_id;
- TDB_CONTEXT *tdb;
- TDB_DATA kbuf, vbuf;
-
- /* placeholder tdb; reinit upon startup */
-
- if ( !(tdb = tdb_open(fn, 0, TDB_DEFAULT, O_RDONLY, 0600)) )
- {
- DEBUG(0, ("Unable to open registry database %s\n", fn));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- vers_id = tdb_fetch_int32(tdb, "INFO/version");
-
- db->key_count = 0;
- db->keys = NULL;
-
- if (vers_id != -1 && vers_id >= REGVER_V1) {
- DEBUG(0, ("Registry version mismatch: %d\n", vers_id));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- for (kbuf = tdb_firstkey(tdb); kbuf.dptr; kbuf = tdb_nextkey(tdb, kbuf))
- {
- uint32_t len;
- int i;
- struct samba3_regkey key;
- char *skey;
-
- if (strncmp((char *)kbuf.dptr, VALUE_PREFIX, strlen(VALUE_PREFIX)) == 0)
- continue;
-
- vbuf = tdb_fetch(tdb, kbuf);
-
- key.name = talloc_strdup(ctx, (char *)kbuf.dptr);
-
- len = tdb_unpack(tdb, (char *)vbuf.dptr, vbuf.dsize, "d", &key.subkey_count);
-
- key.value_count = 0;
- key.values = NULL;
- key.subkeys = talloc_array(ctx, char *, key.subkey_count);
-
- for (i = 0; i < key.subkey_count; i++) {
- fstring tmp;
- len += tdb_unpack( tdb, (char *)vbuf.dptr+len, vbuf.dsize-len, "f", tmp );
- key.subkeys[i] = talloc_strdup(ctx, tmp);
- }
-
- skey = talloc_asprintf(ctx, "%s/%s", VALUE_PREFIX, kbuf.dptr );
-
- vbuf = tdb_fetch_bystring( tdb, skey );
-
- if ( vbuf.dptr ) {
- regdb_unpack_values( tdb, ctx, &key, vbuf );
- }
-
- db->keys = talloc_realloc(ctx, db->keys, struct samba3_regkey, db->key_count+1);
- db->keys[db->key_count] = key;
- db->key_count++;
- }
-
- tdb_close(tdb);
-
- return NT_STATUS_OK;
-}
diff --git a/source4/lib/samba3/samba3.c b/source4/lib/samba3/samba3.c
deleted file mode 100644
index 4bd08f188a..0000000000
--- a/source4/lib/samba3/samba3.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * Copyright (C) Jelmer Vernooij 2005
- *
- * 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 "lib/samba3/samba3.h"
-
-struct samba3_domainsecrets *samba3_find_domainsecrets(struct samba3 *db, const char *name)
-{
- int i;
-
- for (i = 0; i < db->secrets.domain_count; i++) {
- if (!strcasecmp_m(db->secrets.domains[i].name, name))
- return &db->secrets.domains[i];
- }
-
- return NULL;
-}
-
-NTSTATUS samba3_read_passdb_backends(TALLOC_CTX *ctx, const char *libdir, struct samba3 *samba3)
-{
- char *dbfile;
- NTSTATUS status = NT_STATUS_OK;
- int i;
- const char **backends = param_get_string_list(samba3->configuration, "passdb backend", NULL, NULL);
-
- /* Default to smbpasswd */
- if (backends == NULL)
- backends = str_list_make(ctx, "smbpasswd", LIST_SEP);
- else
- backends = str_list_copy(ctx, backends);
-
-
- for (i = 0; backends[i]; i++) {
- if (!strncmp(backends[i], "tdbsam", strlen("tdbsam"))) {
- const char *p = strchr(backends[i], ':');
- if (p && p[1]) {
- dbfile = talloc_strdup(ctx, p+1);
- } else {
- dbfile = talloc_asprintf(ctx, "%s/passdb.tdb", libdir);
- }
- samba3_read_tdbsam(dbfile, ctx, &samba3->samaccounts, &samba3->samaccount_count);
- talloc_free(dbfile);
- } else if (!strncmp(backends[i], "smbpasswd", strlen("smbpasswd"))) {
- const char *p = strchr(backends[i], ':');
- if (p && p[1]) {
- dbfile = talloc_strdup(ctx, p+1);
- } else if ((p = param_get_string(samba3->configuration, "smb passwd file", NULL))) {
- dbfile = talloc_strdup(ctx, p);
- } else {
- dbfile = talloc_strdup(ctx, "/etc/samba/smbpasswd");
- }
-
- samba3_read_smbpasswd(dbfile, ctx, &samba3->samaccounts, &samba3->samaccount_count);
- talloc_free(dbfile);
- } else if (!strncmp(backends[i], "ldapsam", strlen("ldapsam"))) {
- /* Will use samba3sam mapping module */
- } else {
- DEBUG(0, ("Upgrade from %s database not supported", backends[i]));
- status = NT_STATUS_NOT_SUPPORTED;
- continue;
- }
- }
-
- talloc_free(backends);
-
- return status;
-}
-
-NTSTATUS samba3_read(const char *libdir, const char *smbconf, TALLOC_CTX *ctx, struct samba3 **samba3)
-{
- struct samba3 *ret;
- char *dbfile = NULL;
-
- ret = talloc_zero(ctx, struct samba3);
-
- if (smbconf != NULL) {
- ret->configuration = param_init(ret);
- if (param_read(ret->configuration, smbconf) == -1) {
- talloc_free(ret);
- return NT_STATUS_UNSUCCESSFUL;
- }
- }
-
- dbfile = talloc_asprintf(ctx, "%s/account_policy.tdb", libdir);
- samba3_read_account_policy(dbfile, ctx, &ret->policy);
- talloc_free(dbfile);
-
- dbfile = talloc_asprintf(ctx, "%s/registry.tdb", libdir);
- samba3_read_regdb(dbfile, ctx, &ret->registry);
- talloc_free(dbfile);
-
- dbfile = talloc_asprintf(ctx, "%s/secrets.tdb", libdir);
- samba3_read_secrets(dbfile, ctx, &ret->secrets);
- talloc_free(dbfile);
-
- dbfile = talloc_asprintf(ctx, "%s/share_info.tdb", libdir);
- samba3_read_share_info(dbfile, ctx, ret);
- talloc_free(dbfile);
-
- dbfile = talloc_asprintf(ctx, "%s/winbindd_idmap.tdb", libdir);
- samba3_read_idmap(dbfile, ctx, &ret->idmap);
- talloc_free(dbfile);
-
- dbfile = talloc_asprintf(ctx, "%s/wins.dat", libdir);
- samba3_read_winsdb(dbfile, ret, &ret->winsdb_entries, &ret->winsdb_count);
- talloc_free(dbfile);
-
- samba3_read_passdb_backends(ctx, libdir, ret);
-
- dbfile = talloc_asprintf(ctx, "%s/group_mapping.tdb", libdir);
- samba3_read_grouptdb(dbfile, ctx, &ret->group);
- talloc_free(dbfile);
-
- *samba3 = ret;
-
- return NT_STATUS_OK;
-}
diff --git a/source4/lib/samba3/samba3.h b/source4/lib/samba3/samba3.h
index 202ac767ec..aea87dac14 100644
--- a/source4/lib/samba3/samba3.h
+++ b/source4/lib/samba3/samba3.h
@@ -209,7 +209,6 @@ struct samba3
struct samba3_regdb registry;
};
-#include "lib/samba3/samba3_proto.h"
#include "lib/samba3/samba3_smbpasswd_proto.h"
#endif /* _SAMBA3_H */
diff --git a/source4/lib/samba3/secrets.c b/source4/lib/samba3/secrets.c
deleted file mode 100644
index cd1df991a4..0000000000
--- a/source4/lib/samba3/secrets.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Copyright (C) Andrew Tridgell 1992-2001
- Copyright (C) Andrew Bartlett 2002
- Copyright (C) Rafal Szczesniak 2002
- Copyright (C) Tim Potter 2001
- Copyright (C) Jelmer Vernooij 2005
-
- 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/>.
-*/
-
-/* the Samba secrets database stores any generated, private information
- such as the local SID and machine trust password */
-
-#include "includes.h"
-#include "lib/tdb/include/tdb.h"
-#include "lib/util/util_tdb.h"
-#include "lib/samba3/samba3.h"
-#include "system/filesys.h"
-#include "librpc/gen_ndr/security.h"
-#include "auth/credentials/credentials.h"
-
-/**
- * Unpack SID into a pointer
- *
- * @param pack_buf pointer to buffer with packed representation
- * @param bufsize size of the buffer
- * @param sid pointer to sid structure to be filled with unpacked data
- *
- * @return size of structure unpacked from buffer
- **/
-static size_t tdb_sid_unpack(TDB_CONTEXT *tdb, char* pack_buf, int bufsize, struct dom_sid* sid)
-{
- int idx, len = 0;
-
- if (!sid || !pack_buf) return -1;
-
- len += tdb_unpack(tdb, pack_buf + len, bufsize - len, "bb",
- &sid->sid_rev_num, &sid->num_auths);
-
- for (idx = 0; idx < 6; idx++) {
- len += tdb_unpack(tdb, pack_buf + len, bufsize - len, "b", &sid->id_auth[idx]);
- }
-
- for (idx = 0; idx < 15; idx++) {
- len += tdb_unpack(tdb, pack_buf + len, bufsize - len, "d", &sid->sub_auths[idx]);
- }
-
- return len;
-}
-
-static struct samba3_domainsecrets *secrets_find_domain(TALLOC_CTX *ctx, struct samba3_secrets *db, const char *key)
-{
- int i;
-
- for (i = 0; i < db->domain_count; i++)
- {
- if (!strcasecmp_m(db->domains[i].name, key))
- return &db->domains[i];
- }
-
- db->domains = talloc_realloc(ctx, db->domains, struct samba3_domainsecrets, db->domain_count+1);
- ZERO_STRUCT(db->domains[db->domain_count]);
- db->domains[db->domain_count].name = talloc_strdup(db->domains, key);
-
- db->domain_count++;
-
- return &db->domains[db->domain_count-1];
-}
-
-static NTSTATUS ipc_password (TDB_CONTEXT *tdb, const char *key, TDB_DATA vbuf, TALLOC_CTX *ctx, struct samba3_secrets *db)
-{
- cli_credentials_set_password(db->ipc_cred, (const char *)vbuf.dptr, CRED_SPECIFIED);
- return NT_STATUS_OK;
-}
-
-static NTSTATUS ipc_username (TDB_CONTEXT *tdb, const char *key, TDB_DATA vbuf, TALLOC_CTX *ctx, struct samba3_secrets *db)
-{
- cli_credentials_set_username(db->ipc_cred, (const char *)vbuf.dptr, CRED_SPECIFIED);
- return NT_STATUS_OK;
-}
-
-static NTSTATUS ipc_domain (TDB_CONTEXT *tdb, const char *key, TDB_DATA vbuf, TALLOC_CTX *ctx, struct samba3_secrets *db)
-{
- cli_credentials_set_domain(db->ipc_cred, (const char *)vbuf.dptr, CRED_SPECIFIED);
- return NT_STATUS_OK;
-}
-
-static NTSTATUS domain_sid (TDB_CONTEXT *tdb, const char *key, TDB_DATA vbuf, TALLOC_CTX *ctx, struct samba3_secrets *db)
-{
- struct samba3_domainsecrets *domainsec = secrets_find_domain(ctx, db, key);
- domainsec->sid.sub_auths = talloc_array(ctx, uint32_t, 15);
- tdb_sid_unpack(tdb, (char *)vbuf.dptr, vbuf.dsize, &domainsec->sid);
- return NT_STATUS_OK;
-}
-
-static NTSTATUS domain_guid (TDB_CONTEXT *tdb, const char *key, TDB_DATA vbuf, TALLOC_CTX *ctx, struct samba3_secrets *db)
-{
- struct samba3_domainsecrets *domainsec = secrets_find_domain(ctx, db, key);
- memcpy(&domainsec->guid, vbuf.dptr, vbuf.dsize);
- return NT_STATUS_OK;
-}
-
-static NTSTATUS ldap_bind_pw (TDB_CONTEXT *tdb, const char *key, TDB_DATA vbuf, TALLOC_CTX *ctx, struct samba3_secrets *db)
-{
- struct samba3_ldappw pw;
- pw.dn = talloc_strdup(ctx, key);
- pw.password = talloc_strdup(ctx, (const char *)vbuf.dptr);
-
- db->ldappws = talloc_realloc(ctx, db->ldappws, struct samba3_ldappw, db->ldappw_count+1);
- db->ldappws[db->ldappw_count] = pw;
- db->ldappw_count++;
- return NT_STATUS_OK;
-}
-
-static NTSTATUS afs_keyfile (TDB_CONTEXT *tdb, const char *key, TDB_DATA vbuf, TALLOC_CTX *ctx, struct samba3_secrets *db)
-{
- struct samba3_afs_keyfile keyfile;
- memcpy(&keyfile, vbuf.dptr, vbuf.dsize);
- keyfile.cell = talloc_strdup(ctx, key);
-
- db->afs_keyfiles = talloc_realloc(ctx, db->afs_keyfiles, struct samba3_afs_keyfile, db->afs_keyfile_count+1);
- db->afs_keyfiles[db->afs_keyfile_count] = keyfile;
- db->afs_keyfile_count++;
-
- return NT_STATUS_OK;
-}
-
-static NTSTATUS machine_sec_channel_type (TDB_CONTEXT *tdb, const char *key, TDB_DATA vbuf, TALLOC_CTX *ctx, struct samba3_secrets *db)
-{
- struct samba3_domainsecrets *domainsec = secrets_find_domain(ctx, db, key);
-
- domainsec->sec_channel_type = IVAL(vbuf.dptr, 0);
- return NT_STATUS_OK;
-}
-
-static NTSTATUS machine_last_change_time (TDB_CONTEXT *tdb, const char *key, TDB_DATA vbuf, TALLOC_CTX *ctx, struct samba3_secrets *db)
-{
- struct samba3_domainsecrets *domainsec = secrets_find_domain(ctx, db, key);
- domainsec->last_change_time = IVAL(vbuf.dptr, 0);
- return NT_STATUS_OK;
-}
-
-static NTSTATUS machine_password (TDB_CONTEXT *tdb, const char *key, TDB_DATA vbuf, TALLOC_CTX *ctx, struct samba3_secrets *db)
-{
- struct samba3_domainsecrets *domainsec = secrets_find_domain(ctx, db, key);
- domainsec->plaintext_pw = talloc_strdup(ctx, (const char *)vbuf.dptr);
- return NT_STATUS_OK;
-}
-
-static NTSTATUS machine_acc (TDB_CONTEXT *tdb, const char *key, TDB_DATA vbuf, TALLOC_CTX *ctx, struct samba3_secrets *db)
-{
- struct samba3_domainsecrets *domainsec = secrets_find_domain(ctx, db, key);
-
- memcpy(&domainsec->hash_pw, vbuf.dptr, vbuf.dsize);
-
- return NT_STATUS_OK;
-}
-
-static NTSTATUS random_seed (TDB_CONTEXT *tdb, const char *key, TDB_DATA vbuf, TALLOC_CTX *ctx, struct samba3_secrets *db)
-{
- /* Ignore */
- return NT_STATUS_OK;
-}
-
-static NTSTATUS domtrust_acc (TDB_CONTEXT *tdb, const char *key, TDB_DATA vbuf, TALLOC_CTX *ctx, struct samba3_secrets *db)
-{
- int idx, len = 0;
- struct samba3_trusted_dom_pass pass;
- int pass_len;
-
- if (!vbuf.dptr)
- return NT_STATUS_UNSUCCESSFUL;
-
- /* unpack unicode domain name and plaintext password */
- len += tdb_unpack(tdb, (char *)vbuf.dptr, vbuf.dsize - len, "d", &pass.uni_name_len);
-
- for (idx = 0; idx < 32; idx++)
- len += tdb_unpack(tdb, (char *)(vbuf.dptr + len), vbuf.dsize - len, "w", &pass.uni_name[idx]);
-
- len += tdb_unpack(tdb, (char *)(vbuf.dptr + len), vbuf.dsize - len, "d", &pass_len);
- pass.pass = talloc_strdup(ctx, (char *)(vbuf.dptr+len));
- len += strlen((const char *)vbuf.dptr)+1;
- len += tdb_unpack(tdb, (char *)(vbuf.dptr + len), vbuf.dsize - len, "d", &pass.mod_time);
-
- pass.domain_sid.sub_auths = talloc_array(ctx, uint32_t, 15);
- /* unpack domain sid */
- len += tdb_sid_unpack(tdb, (char *)(vbuf.dptr + len), vbuf.dsize - len, &pass.domain_sid);
-
- /* FIXME: Add to list */
-
- return NT_STATUS_OK;
-}
-
-static const struct {
- const char *prefix;
- NTSTATUS (*handler) (TDB_CONTEXT *tdb, const char *key, TDB_DATA vbuf, TALLOC_CTX *ctx, struct samba3_secrets *db);
-} secrets_handlers[] = {
- { "SECRETS/AUTH_PASSWORD", ipc_password },
- { "SECRETS/AUTH_DOMAIN", ipc_domain },
- { "SECRETS/AUTH_USER", ipc_username },
- { "SECRETS/SID/", domain_sid },
- { "SECRETS/DOMGUID/", domain_guid },
- { "SECRETS/LDAP_BIND_PW/", ldap_bind_pw },
- { "SECRETS/AFS_KEYFILE/", afs_keyfile },
- { "SECRETS/MACHINE_SEC_CHANNEL_TYPE/", machine_sec_channel_type },
- { "SECRETS/MACHINE_LAST_CHANGE_TIME/", machine_last_change_time },
- { "SECRETS/MACHINE_PASSWORD/", machine_password },
- { "SECRETS/$MACHINE.ACC/", machine_acc },
- { "SECRETS/$DOMTRUST.ACC/", domtrust_acc },
- { "INFO/random_seed", random_seed },
-};
-
-
-NTSTATUS samba3_read_secrets(const char *fname, TALLOC_CTX *ctx, struct samba3_secrets *db)
-{
- TDB_CONTEXT *tdb = tdb_open(fname, 0, TDB_DEFAULT, O_RDONLY, 0600);
- TDB_DATA kbuf, vbuf;
-
- if (!tdb) {
- DEBUG(0,("Failed to open %s\n", fname));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- ZERO_STRUCTP(db);
-
- db->ipc_cred = cli_credentials_init(ctx);
-
- for (kbuf = tdb_firstkey(tdb); kbuf.dptr; kbuf = tdb_nextkey(tdb, kbuf))
- {
- int i;
- char *key;
- vbuf = tdb_fetch(tdb, kbuf);
-
- for (i = 0; secrets_handlers[i].prefix; i++) {
- if (!strncmp((const char *)kbuf.dptr, secrets_handlers[i].prefix, strlen(secrets_handlers[i].prefix))) {
- key = talloc_strndup(ctx, (const char *)(kbuf.dptr+strlen(secrets_handlers[i].prefix)), kbuf.dsize-strlen(secrets_handlers[i].prefix));
- secrets_handlers[i].handler(tdb, key, vbuf, ctx, db);
- talloc_free(key);
- break;
- }
- }
-
- if (!secrets_handlers[i].prefix) {
- DEBUG(0, ("Unable to find handler for string %s\n", kbuf.dptr));
- }
- }
-
- tdb_close(tdb);
-
- return NT_STATUS_OK;
-}
diff --git a/source4/lib/samba3/share_info.c b/source4/lib/samba3/share_info.c
deleted file mode 100644
index 4dd15aa918..0000000000
--- a/source4/lib/samba3/share_info.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- * Share Info parsing
- * Copyright (C) Andrew Tridgell 1992-1997,
- * Copyright (C) Jeremy Allison 2001.
- * Copyright (C) Nigel Williams 2001.
- * Copyright (C) Jelmer Vernooij 2005.
- *
- * 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 "librpc/gen_ndr/ndr_security.h"
-#include "lib/tdb/include/tdb.h"
-#include "lib/util/util_tdb.h"
-#include "lib/samba3/samba3.h"
-#include "system/filesys.h"
-
-#define SHARE_DATABASE_VERSION_V1 1
-#define SHARE_DATABASE_VERSION_V2 2 /* version id in little endian. */
-
-NTSTATUS samba3_read_share_info(const char *fn, TALLOC_CTX *ctx, struct samba3 *db)
-{
- int32_t vers_id;
- TDB_CONTEXT *tdb;
- TDB_DATA kbuf, vbuf;
- DATA_BLOB blob;
-
- tdb = tdb_open(fn, 0, TDB_DEFAULT, O_RDONLY, 0600);
- if (!tdb) {
- DEBUG(0,("Failed to open share info database %s (%s)\n",
- fn, strerror(errno) ));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- /* Cope with byte-reversed older versions of the db. */
- vers_id = tdb_fetch_int32(tdb, "INFO/version");
- if ((vers_id == SHARE_DATABASE_VERSION_V1) || (IREV(vers_id) == SHARE_DATABASE_VERSION_V1)) {
- /* Written on a bigendian machine with old fetch_int code. Save as le. */
- vers_id = SHARE_DATABASE_VERSION_V2;
- }
-
- if (vers_id != SHARE_DATABASE_VERSION_V2) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- for (kbuf = tdb_firstkey(tdb); kbuf.dptr; kbuf = tdb_nextkey(tdb, kbuf))
- {
- struct ndr_pull *pull;
- struct samba3_share_info *share;
- char *name;
-
- if (strncmp((char *)kbuf.dptr, "SECDESC/", strlen("SECDESC/")) != 0)
- continue;
-
- name = talloc_strndup(ctx, (char *)kbuf.dptr+strlen("SECDESC/"), kbuf.dsize-strlen("SECDESC/"));
-
- db->shares = talloc_realloc(db, db->shares, struct samba3_share_info, db->share_count+1);
- share = &db->shares[db->share_count];
- db->share_count++;
-
- share->name = talloc_strdup(db, name);
-
- vbuf = tdb_fetch(tdb, kbuf);
- blob.data = (uint8_t *)vbuf.dptr;
- blob.length = vbuf.dsize;
-
- pull = ndr_pull_init_blob(&blob, ctx, lp_iconv_convenience(global_loadparm));
-
- ndr_pull_security_descriptor(pull, NDR_SCALARS|NDR_BUFFERS, &share->secdesc);
-
- talloc_free(pull);
- }
-
- tdb_close(tdb);
-
- return NT_STATUS_OK;
-}
diff --git a/source4/lib/samba3/smbpasswd.c b/source4/lib/samba3/smbpasswd.c
index 39e2448b98..47c826f9df 100644
--- a/source4/lib/samba3/smbpasswd.c
+++ b/source4/lib/samba3/smbpasswd.c
@@ -204,142 +204,3 @@ char *smbpasswd_encode_acb_info(TALLOC_CTX *mem_ctx, uint16_t acb_info)
return acct_str;
}
-
-NTSTATUS samba3_read_smbpasswd(const char *filename, TALLOC_CTX *ctx, struct samba3_samaccount **accounts, uint32_t *count)
-{
- int numlines;
- char **lines;
- int i;
-
- *count = 0;
- *accounts = NULL;
-
- lines = file_lines_load(filename, &numlines, ctx);
-
- if (lines == NULL) {
- DEBUG(0, ("Unable to load lines from %s\n", filename));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- *accounts = talloc_array(ctx, struct samba3_samaccount, numlines);
-
- for (i = 0; i < numlines; i++) {
- char *p = lines[i], *q;
- uid_t uid;
- struct samba3_samaccount *acc = &((*accounts)[*count]);
-
- if (p[0] == '\0' || p[0] == '#')
- continue;
-
- ZERO_STRUCTP(acc);
-
- q = strchr(p, ':');
- if (!q) {
- DEBUG(0, ("%s:%d: expected ':'\n", filename, i));
- continue;
- }
-
- acc->username = talloc_strndup(ctx, p, PTR_DIFF(q, p));
- p = q+1;
-
- uid = atoi(p);
-
- /* uid is ignored here.. */
-
- q = strchr(p, ':');
- if (!q) {
- DEBUG(0, ("%s:%d: expected ':'\n", filename, i));
- continue;
- }
- p = q+1;
-
- if (strlen(p) < 33) {
- DEBUG(0, ("%s:%d: expected 32 byte password blob\n", filename, i));
- continue;
- }
-
- if (!strncmp(p, "NO PASSWORD", strlen("NO PASSWORD"))) {
- acc->acct_ctrl |= ACB_PWNOTREQ;
- } else if (p[0] == '*' || p[0] == 'X') {
- /* No password set */
- } else {
- struct samr_Password *pw = smbpasswd_gethexpwd(*accounts, p);
-
- if (!pw) {
- DEBUG(0, ("%s:%d: Malformed LM pw entry\n", filename, i));
- continue;
- }
-
- memcpy(acc->lm_pw.hash, pw, sizeof(*pw));
- }
-
- if (p[32] != ':') {
- DEBUG(0, ("%s:%d: expected ':' after 32 byte password blob\n", filename, i));
- continue;
- }
-
- p += 33;
-
- if (p[0] == '*' || p[0] == 'X') {
- /* No password set */
- } else {
- struct samr_Password *pw = smbpasswd_gethexpwd(*accounts, p);
-
- if (!pw) {
- DEBUG(0, ("%s:%d: Malformed LM pw entry\n", filename, i));
- continue;
- }
-
- memcpy(acc->nt_pw.hash, pw, sizeof(*pw));
- }
-
- if (p[32] != ':') {
- DEBUG(0, ("%s:%d: expected ':' after 32 byte password blob\n", filename, i));
- continue;
- }
-
- p += 33;
-
- if (p[0] == '[') {
- q = strchr(p, ']');
- if (!q) {
- DEBUG(0, ("%s:%d: expected ']'\n", filename, i));
- continue;
- }
-
- acc->acct_ctrl |= smbpasswd_decode_acb_info(p);
-
- p = q+1;
- if (p[0] == ':' && strncmp(p, "LCT-", 4) == 0) {
- int j;
- p += 4;
-
- for(j = 0; j < 8; j++) {
- if(p[j] == '\0' || !isxdigit(p[j])) {
- break;
- }
- }
- if(i == 8) {
- acc->pass_last_set_time = (time_t)strtol((char *)p, NULL, 16);
- }
- }
- } else {
- /* 'Old' style file. Fake up based on user name. */
- /*
- * Currently trust accounts are kept in the same
- * password file as 'normal accounts'. If this changes
- * we will have to fix this code. JRA.
- */
- if(acc->username[strlen(acc->username) - 1] == '$') {
- acc->acct_ctrl &= ~ACB_NORMAL;
- acc->acct_ctrl |= ACB_WSTRUST;
- }
- }
-
- (*count)++;
- }
-
- talloc_free(lines);
-
- return NT_STATUS_OK;
-}
diff --git a/source4/lib/samba3/tdbsam.c b/source4/lib/samba3/tdbsam.c
deleted file mode 100644
index 8e6b0daf2b..0000000000
--- a/source4/lib/samba3/tdbsam.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- tdb passdb backend format routines
-
- Copyright (C) Simo Sorce 2000-2003
- Copyright (C) Jelmer Vernooij 2005
-
- 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 "system/filesys.h"
-#include "lib/tdb/include/tdb.h"
-#include "lib/util/util_tdb.h"
-#include "lib/samba3/samba3.h"
-
-#define TDB_FORMAT_STRING_V0 "ddddddBBBBBBBBBBBBddBBwdwdBwwd"
-#define TDB_FORMAT_STRING_V1 "dddddddBBBBBBBBBBBBddBBwdwdBwwd"
-#define TDB_FORMAT_STRING_V2 "dddddddBBBBBBBBBBBBddBBBwwdBwwd"
-#define TDBSAM_VERSION_STRING "INFO/version"
-
-static bool init_sam_from_buffer_v0(TDB_CONTEXT *tdb, struct samba3_samaccount *sampass, TDB_DATA buf)
-{
- uint32_t username_len, domain_len, nt_username_len,
- dir_drive_len, unknown_str_len, munged_dial_len,
- fullname_len, homedir_len, logon_script_len,
- profile_path_len, acct_desc_len, workstations_len;
-
- uint32_t remove_me;
- uint32_t len = 0;
- uint32_t lm_pw_len, nt_pw_len, hourslen;
-
- if(sampass == NULL || buf.dptr == NULL) {
- DEBUG(0, ("init_sam_from_buffer_v0: NULL parameters found!\n"));
- return false;
- }
-
- /* unpack the buffer into variables */
- len = tdb_unpack (tdb, (char *)buf.dptr, buf.dsize, TDB_FORMAT_STRING_V0,
- &sampass->logon_time, /* d */
- &sampass->logoff_time, /* d */
- &sampass->kickoff_time, /* d */
- &sampass->pass_last_set_time, /* d */
- &sampass->pass_can_change_time, /* d */
- &sampass->pass_must_change_time, /* d */
- &username_len, &sampass->username, /* B */
- &domain_len, &sampass->domain, /* B */
- &nt_username_len, &sampass->nt_username, /* B */
- &fullname_len, &sampass->fullname, /* B */
- &homedir_len, &sampass->homedir, /* B */
- &dir_drive_len, &sampass->dir_drive, /* B */
- &logon_script_len, &sampass->logon_script, /* B */
- &profile_path_len, &sampass->profile_path, /* B */
- &acct_desc_len, &sampass->acct_desc, /* B */
- &workstations_len, &sampass->workstations, /* B */
- &unknown_str_len, &sampass->unknown_str, /* B */
- &munged_dial_len, &sampass->munged_dial, /* B */
- &sampass->user_rid, /* d */
- &sampass->group_rid, /* d */
- &lm_pw_len, sampass->lm_pw.hash, /* B */
- &nt_pw_len, sampass->nt_pw.hash, /* B */
- &sampass->acct_ctrl, /* w */
- &remove_me, /* remove on the next TDB_FORMAT upgarde */ /* d */
- &sampass->logon_divs, /* w */
- &sampass->hours_len, /* d */
- &hourslen, &sampass->hours, /* B */
- &sampass->bad_password_count, /* w */
- &sampass->logon_count, /* w */
- &sampass->unknown_6); /* d */
-
- if (len == (uint32_t) -1) {
- return false;
- }
-
- return true;
-}
-
-static bool init_sam_from_buffer_v1(TDB_CONTEXT *tdb, struct samba3_samaccount *sampass, TDB_DATA buf)
-{
- uint32_t username_len, domain_len, nt_username_len,
- dir_drive_len, unknown_str_len, munged_dial_len,
- fullname_len, homedir_len, logon_script_len,
- profile_path_len, acct_desc_len, workstations_len;
-
- uint32_t remove_me;
- uint32_t len = 0;
- uint32_t lm_pw_len, nt_pw_len, hourslen;
-
- if(sampass == NULL || buf.dptr == NULL) {
- DEBUG(0, ("init_sam_from_buffer_v1: NULL parameters found!\n"));
- return false;
- }
-
- /* unpack the buffer into variables */
- len = tdb_unpack (tdb, (char *)buf.dptr, buf.dsize, TDB_FORMAT_STRING_V1,
- &sampass->logon_time, /* d */
- &sampass->logoff_time, /* d */
- &sampass->kickoff_time, /* d */
- /* Change from V0 is addition of bad_password_time field. */
- &sampass->bad_password_time, /* d */
- &sampass->pass_last_set_time, /* d */
- &sampass->pass_can_change_time, /* d */
- &sampass->pass_must_change_time, /* d */
- &username_len, &sampass->username, /* B */
- &domain_len, &sampass->domain, /* B */
- &nt_username_len, &sampass->nt_username, /* B */
- &fullname_len, &sampass->fullname, /* B */
- &homedir_len, &sampass->homedir, /* B */
- &dir_drive_len, &sampass->dir_drive, /* B */
- &logon_script_len, &sampass->logon_script, /* B */
- &profile_path_len, &sampass->profile_path, /* B */
- &acct_desc_len, &sampass->acct_desc, /* B */
- &workstations_len, &sampass->workstations, /* B */
- &unknown_str_len, &sampass->unknown_str, /* B */
- &munged_dial_len, &sampass->munged_dial, /* B */
- &sampass->user_rid, /* d */
- &sampass->group_rid, /* d */
- &lm_pw_len, sampass->lm_pw.hash, /* B */
- &nt_pw_len, sampass->nt_pw.hash, /* B */
- &sampass->acct_ctrl, /* w */
- &remove_me, /* d */
- &sampass->logon_divs, /* w */
- &sampass->hours_len, /* d */
- &hourslen, &sampass->hours, /* B */
- &sampass->bad_password_count, /* w */
- &sampass->logon_count, /* w */
- &sampass->unknown_6); /* d */
-
- if (len == (uint32_t) -1) {
- return false;
- }
-
- return true;
-}
-
-static bool init_sam_from_buffer_v2(TDB_CONTEXT *tdb, struct samba3_samaccount *sampass, TDB_DATA buf)
-{
- uint32_t username_len, domain_len, nt_username_len,
- dir_drive_len, unknown_str_len, munged_dial_len,
- fullname_len, homedir_len, logon_script_len,
- profile_path_len, acct_desc_len, workstations_len;
-
- uint32_t len = 0;
- uint32_t lm_pw_len, nt_pw_len, nt_pw_hist_len, hourslen;
-
- if(sampass == NULL || buf.dptr == NULL) {
- DEBUG(0, ("init_sam_from_buffer_v2: NULL parameters found!\n"));
- return false;
- }
-
- /* unpack the buffer into variables */
- len = tdb_unpack (tdb, (char *)buf.dptr, buf.dsize, TDB_FORMAT_STRING_V2,
- &sampass->logon_time, /* d */
- &sampass->logoff_time, /* d */
- &sampass->kickoff_time, /* d */
- &sampass->bad_password_time, /* d */
- &sampass->pass_last_set_time, /* d */
- &sampass->pass_can_change_time, /* d */
- &sampass->pass_must_change_time, /* d */
- &username_len, &sampass->username, /* B */
- &domain_len, &sampass->domain, /* B */
- &nt_username_len, &sampass->nt_username, /* B */
- &fullname_len, &sampass->fullname, /* B */
- &homedir_len, &sampass->homedir, /* B */
- &dir_drive_len, &sampass->dir_drive, /* B */
- &logon_script_len, &sampass->logon_script, /* B */
- &profile_path_len, &sampass->profile_path, /* B */
- &acct_desc_len, &sampass->acct_desc, /* B */
- &workstations_len, &sampass->workstations, /* B */
- &unknown_str_len, &sampass->unknown_str, /* B */
- &munged_dial_len, &sampass->munged_dial, /* B */
- &sampass->user_rid, /* d */
- &sampass->group_rid, /* d */
- &lm_pw_len, sampass->lm_pw.hash, /* B */
- &nt_pw_len, sampass->nt_pw.hash, /* B */
- /* Change from V1 is addition of password history field. */
- &nt_pw_hist_len, &sampass->nt_pw_hist_ptr, /* B */
- &sampass->acct_ctrl, /* w */
- /* Also "remove_me" field was removed. */
- &sampass->logon_divs, /* w */
- &sampass->hours_len, /* d */
- &hourslen, &sampass->hours, /* B */
- &sampass->bad_password_count, /* w */
- &sampass->logon_count, /* w */
- &sampass->unknown_6); /* d */
-
- if (len == (uint32_t) -1) {
- return false;
- }
-
- return true;
-}
-
-NTSTATUS samba3_read_tdbsam(const char *filename, TALLOC_CTX *ctx, struct samba3_samaccount **accounts, uint32_t *count)
-{
- int32_t version;
- TDB_CONTEXT *tdb;
- TDB_DATA key, val;
-
- /* Try to open tdb passwd */
- if (!(tdb = tdb_open(filename, 0, TDB_DEFAULT, O_RDONLY, 0600))) {
- DEBUG(0, ("Unable to open TDB passwd file '%s'\n", filename));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- /* Check the version */
- version = tdb_fetch_int32(tdb,
- TDBSAM_VERSION_STRING);
- if (version == -1)
- version = 0; /* Version not found, assume version 0 */
-
- /* Compare the version */
- if (version > 2) {
- /* Version more recent than the latest known */
- DEBUG(0, ("TDBSAM version unknown: %d\n", version));
- tdb_close(tdb);
- return NT_STATUS_NOT_SUPPORTED;
- }
-
- *accounts = NULL;
- *count = 0;
-
- for (key = tdb_firstkey(tdb); key.dptr; key = tdb_nextkey(tdb, key))
- {
- bool ret;
- if (strncmp((const char *)key.dptr, "USER_", 5) != 0)
- continue;
-
- val = tdb_fetch(tdb, key);
-
- *accounts = talloc_realloc(ctx, *accounts, struct samba3_samaccount, (*count)+1);
-
- switch (version)
- {
- case 0: ret = init_sam_from_buffer_v0(tdb, &(*accounts)[*count], val); break;
- case 1: ret = init_sam_from_buffer_v1(tdb, &(*accounts)[*count], val); break;
- case 2: ret = init_sam_from_buffer_v2(tdb, &(*accounts)[*count], val); break;
- default: ret = false; break;
-
- }
-
- if (!ret) {
- DEBUG(0, ("Unable to parse SAM account %s\n", key.dptr));
- }
-
- (*count)++;
- }
-
- tdb_close(tdb);
-
- return NT_STATUS_OK;
-}
diff --git a/source4/lib/samba3/winsdb.c b/source4/lib/samba3/winsdb.c
deleted file mode 100644
index 5bed3523ea..0000000000
--- a/source4/lib/samba3/winsdb.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Wins Database
-
- Copyright (C) Jeremy Allison 1994-2003
- Copyright (C) Jelmer Vernooij 2005
-
- 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 "system/filesys.h"
-#include "lib/samba3/samba3.h"
-#include "system/network.h"
-
-#define WINS_VERSION 1
-
-NTSTATUS samba3_read_winsdb( const char *fn, TALLOC_CTX *ctx, struct samba3_winsdb_entry **entries, uint32_t *count )
-{
- XFILE *fp;
- char *line;
-
- if((fp = x_fopen(fn,O_RDONLY,0)) == NULL) {
- DEBUG(0,("initialise_wins: Can't open wins database file %s. Error was %s\n",
- fn, strerror(errno) ));
- return NT_STATUS_OPEN_FAILED;
- }
-
- *count = 0;
- *entries = NULL;
-
- while (!x_feof(fp)) {
- struct samba3_winsdb_entry entry;
- const char *name_str, *ttl_str, *nb_flags_str;
- const char **args;
- char *p;
- int i;
- unsigned int hash;
- int version;
-
- /* Read a line from the wins.dat file. Strips whitespace
- from the beginning and end of the line. */
- line = fgets_slash(NULL,8,fp);
- if (!line) {
- return NT_STATUS_UNEXPECTED_IO_ERROR;
- }
-
- if (*line == '#') {
- SAFE_FREE(line);
- continue;
- }
-
- if (strncmp(line,"VERSION ", 8) == 0) {
- if (sscanf(line,"VERSION %d %u", &version, &hash) != 2 ||
- version != WINS_VERSION) {
- DEBUG(0,("Discarding invalid wins.dat file [%s]\n",line));
- SAFE_FREE(line);
- x_fclose(fp);
- return NT_STATUS_REVISION_MISMATCH;
- }
- SAFE_FREE(line);
-
- continue;
- }
-
- args = str_list_make_shell(ctx, line, NULL);
-
- /*
- * Now we handle multiple IP addresses per name we need
- * to iterate over the line twice. The first time to
- * determine how many IP addresses there are, the second
- * time to actually parse them into the ip_list array.
- */
-
- name_str = args[0];
- if (!name_str) {
- DEBUG(0,("initialise_wins: Failed to parse name when parsing line %s\n", line ));
- SAFE_FREE(line);
- continue;
- }
-
- ttl_str = args[1];
- if (!ttl_str) {
- DEBUG(0,("initialise_wins: Failed to parse time to live when parsing line %s\n", line ));
- SAFE_FREE(line);
- continue;
- }
-
- /*
- * Determine the number of IP addresses per line.
- */
- entry.ip_count = 0;
- for (i = 2; args[i] && strchr(args[i], '.'); i++) entry.ip_count++;
-
- if(entry.ip_count == 0) {
- DEBUG(0,("initialise_wins: Missing IP address when parsing line %s\n", line ));
- SAFE_FREE(line);
- continue;
- }
-
- /* Allocate the space for the ip_list. */
- if((entry.ips = talloc_array ( ctx, struct in_addr, entry.ip_count)) == NULL) {
- DEBUG(0,("initialise_wins: Malloc fail !\n"));
- SAFE_FREE(line);
- return NT_STATUS_NO_MEMORY;
- }
-
- /* Reset and re-parse the line. */
- for(i = 0; i < entry.ip_count; i++) {
- entry.ips[i] = interpret_addr2(args[i+2]);
- }
- nb_flags_str = args[2 + entry.ip_count];
-
- SMB_ASSERT(nb_flags_str);
-
- /*
- * Deal with SELF or REGISTER name encoding. Default is REGISTER
- * for compatibility with old nmbds.
- */
-
- if(nb_flags_str[strlen(nb_flags_str)-1] == 'S') {
- DEBUG(5,("initialise_wins: Ignoring SELF name %s\n", line));
- talloc_free(entry.ips);
- SAFE_FREE(line);
- continue;
- }
-
- /* Netbios name. # divides the name from the type (hex): netbios#xx */
- entry.name = talloc_strdup(ctx, name_str);
-
- if((p = strchr(entry.name,'#')) != NULL) {
- *p = 0;
- sscanf(p+1,"%x",&entry.type);
- }
-
- /* Decode the netbios flags (hex) and the time-to-live (in seconds). */
- sscanf(nb_flags_str,"%x",&entry.nb_flags);
- entry.ttl = atol(ttl_str);
-
- *entries = talloc_realloc(ctx, *entries, struct samba3_winsdb_entry, (*count)+1);
- (*entries)[*count] = entry;
-
- (*count)++;
- }
-
- x_fclose(fp);
- return NT_STATUS_OK;
-}
diff --git a/source4/lib/socket/config.mk b/source4/lib/socket/config.mk
index fe64c90b81..5a7a62d8ae 100644
--- a/source4/lib/socket/config.mk
+++ b/source4/lib/socket/config.mk
@@ -13,7 +13,7 @@ PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL EXT_SOCKET EXT_NSL
# Start MODULE socket_ip
[MODULE::socket_ip]
SUBSYSTEM = samba-socket
-OUTPUT_TYPE = INTEGRATED
+OUTPUT_TYPE = MERGED_OBJ
OBJ_FILES = \
socket_ip.o
PRIVATE_DEPENDENCIES = EXT_SOCKET EXT_NSL LIBSAMBA-ERRORS
@@ -24,7 +24,7 @@ PRIVATE_DEPENDENCIES = EXT_SOCKET EXT_NSL LIBSAMBA-ERRORS
# Start MODULE socket_unix
[MODULE::socket_unix]
SUBSYSTEM = samba-socket
-OUTPUT_TYPE = INTEGRATED
+OUTPUT_TYPE = MERGED_OBJ
OBJ_FILES = \
socket_unix.o
PRIVATE_DEPENDENCIES = EXT_SOCKET EXT_NSL
diff --git a/source4/lib/socket/socket_ip.c b/source4/lib/socket/socket_ip.c
index e61b6d82fc..bca0aab924 100644
--- a/source4/lib/socket/socket_ip.c
+++ b/source4/lib/socket/socket_ip.c
@@ -540,7 +540,7 @@ static const struct socket_ops ipv4_ops = {
.fn_get_fd = ip_get_fd
};
-const struct socket_ops *socket_ipv4_ops(enum socket_type type)
+_PUBLIC_ const struct socket_ops *socket_ipv4_ops(enum socket_type type)
{
return &ipv4_ops;
}
@@ -977,7 +977,7 @@ static const struct socket_ops ipv6_tcp_ops = {
.fn_get_fd = ip_get_fd
};
-const struct socket_ops *socket_ipv6_ops(enum socket_type type)
+_PUBLIC_ const struct socket_ops *socket_ipv6_ops(enum socket_type type)
{
return &ipv6_tcp_ops;
}
diff --git a/source4/lib/socket/socket_unix.c b/source4/lib/socket/socket_unix.c
index cac4b8e913..af7d2bb79f 100644
--- a/source4/lib/socket/socket_unix.c
+++ b/source4/lib/socket/socket_unix.c
@@ -414,7 +414,7 @@ static const struct socket_ops unixdom_ops = {
.fn_get_fd = unixdom_get_fd
};
-const struct socket_ops *socket_unixdom_ops(enum socket_type type)
+_PUBLIC_ const struct socket_ops *socket_unixdom_ops(enum socket_type type)
{
return &unixdom_ops;
}
diff --git a/source4/lib/socket_wrapper/config.m4 b/source4/lib/socket_wrapper/config.m4
index f3ffb895a9..8ff91075bb 100644
--- a/source4/lib/socket_wrapper/config.m4
+++ b/source4/lib/socket_wrapper/config.m4
@@ -20,3 +20,10 @@ fi
AC_SUBST(DEFAULT_TEST_OPTIONS)
AC_SUBST(HAVE_SOCKET_WRAPPER)
AC_SUBST(SOCKET_WRAPPER_OBJS)
+
+# Look for the vdeplug library
+AC_CHECK_HEADERS(libvdeplug.h)
+if test x"$ac_cv_header_libvdeplug_h" = xyes; then
+ AC_DEFINE(HAVE_VDEPLUG, 1, [Whether the VDE plug library is available])
+ SMB_EXT_LIB(VDEPLUG,[-lvdeplug],[],[],[])
+fi
diff --git a/source4/lib/socket_wrapper/socket_wrapper.c b/source4/lib/socket_wrapper/socket_wrapper.c
index 574d8ec5e4..644365a665 100644
--- a/source4/lib/socket_wrapper/socket_wrapper.c
+++ b/source4/lib/socket_wrapper/socket_wrapper.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) Jelmer Vernooij 2005 <jelmer@samba.org>
+ * Copyright (C) Jelmer Vernooij 2005,2008 <jelmer@samba.org>
* Copyright (C) Stefan Metzmacher 2006 <metze@samba.org>
*
* All rights reserved.
@@ -212,7 +212,6 @@ struct socket_info
static struct socket_info *sockets;
-
const char *socket_wrapper_dir(void)
{
const char *s = getenv("SOCKET_WRAPPER_DIR");
@@ -908,40 +907,31 @@ static int swrap_get_pcap_fd(const char *fname)
return fd;
}
-static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *addr,
- enum swrap_packet_type type,
- const void *buf, size_t len)
+static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
+ const struct sockaddr *addr,
+ enum swrap_packet_type type,
+ const void *buf, size_t len,
+ size_t *packet_len)
{
const struct sockaddr_in *src_addr;
const struct sockaddr_in *dest_addr;
- const char *file_name;
unsigned long tcp_seq = 0;
unsigned long tcp_ack = 0;
unsigned char tcp_ctl = 0;
int unreachable = 0;
- struct timeval tv;
- struct swrap_packet *packet;
- size_t packet_len = 0;
- int fd;
- file_name = socket_wrapper_pcap_file();
- if (!file_name) {
- return;
- }
+ struct timeval tv;
switch (si->family) {
case AF_INET:
-#ifdef HAVE_IPV6
- case AF_INET6:
-#endif
break;
default:
- return;
+ return NULL;
}
switch (type) {
case SWRAP_CONNECT_SEND:
- if (si->type != SOCK_STREAM) return;
+ if (si->type != SOCK_STREAM) return NULL;
src_addr = (const struct sockaddr_in *)si->myname;
dest_addr = (const struct sockaddr_in *)addr;
@@ -955,7 +945,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add
break;
case SWRAP_CONNECT_RECV:
- if (si->type != SOCK_STREAM) return;
+ if (si->type != SOCK_STREAM) return NULL;
dest_addr = (const struct sockaddr_in *)si->myname;
src_addr = (const struct sockaddr_in *)addr;
@@ -969,7 +959,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add
break;
case SWRAP_CONNECT_UNREACH:
- if (si->type != SOCK_STREAM) return;
+ if (si->type != SOCK_STREAM) return NULL;
dest_addr = (const struct sockaddr_in *)si->myname;
src_addr = (const struct sockaddr_in *)addr;
@@ -983,7 +973,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add
break;
case SWRAP_CONNECT_ACK:
- if (si->type != SOCK_STREAM) return;
+ if (si->type != SOCK_STREAM) return NULL;
src_addr = (const struct sockaddr_in *)si->myname;
dest_addr = (const struct sockaddr_in *)addr;
@@ -995,7 +985,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add
break;
case SWRAP_ACCEPT_SEND:
- if (si->type != SOCK_STREAM) return;
+ if (si->type != SOCK_STREAM) return NULL;
dest_addr = (const struct sockaddr_in *)si->myname;
src_addr = (const struct sockaddr_in *)addr;
@@ -1009,7 +999,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add
break;
case SWRAP_ACCEPT_RECV:
- if (si->type != SOCK_STREAM) return;
+ if (si->type != SOCK_STREAM) return NULL;
src_addr = (const struct sockaddr_in *)si->myname;
dest_addr = (const struct sockaddr_in *)addr;
@@ -1023,7 +1013,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add
break;
case SWRAP_ACCEPT_ACK:
- if (si->type != SOCK_STREAM) return;
+ if (si->type != SOCK_STREAM) return NULL;
dest_addr = (const struct sockaddr_in *)si->myname;
src_addr = (const struct sockaddr_in *)addr;
@@ -1051,10 +1041,9 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add
src_addr = (const struct sockaddr_in *)si->peername;
if (si->type == SOCK_DGRAM) {
- swrap_dump_packet(si, si->peername,
+ return swrap_marshall_packet(si, si->peername,
SWRAP_SENDTO_UNREACH,
- buf, len);
- return;
+ buf, len, packet_len);
}
tcp_seq = si->io.pck_rcv;
@@ -1068,7 +1057,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add
src_addr = (const struct sockaddr_in *)si->peername;
if (si->type == SOCK_DGRAM) {
- return;
+ return NULL;
}
tcp_seq = si->io.pck_rcv;
@@ -1094,7 +1083,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add
src_addr = (const struct sockaddr_in *)si->peername;
if (si->type == SOCK_DGRAM) {
- return;
+ return NULL;
}
tcp_seq = si->io.pck_rcv;
@@ -1128,7 +1117,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add
break;
case SWRAP_CLOSE_SEND:
- if (si->type != SOCK_STREAM) return;
+ if (si->type != SOCK_STREAM) return NULL;
src_addr = (const struct sockaddr_in *)si->myname;
dest_addr = (const struct sockaddr_in *)si->peername;
@@ -1142,7 +1131,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add
break;
case SWRAP_CLOSE_RECV:
- if (si->type != SOCK_STREAM) return;
+ if (si->type != SOCK_STREAM) return NULL;
dest_addr = (const struct sockaddr_in *)si->myname;
src_addr = (const struct sockaddr_in *)si->peername;
@@ -1156,7 +1145,7 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add
break;
case SWRAP_CLOSE_ACK:
- if (si->type != SOCK_STREAM) return;
+ if (si->type != SOCK_STREAM) return NULL;
src_addr = (const struct sockaddr_in *)si->myname;
dest_addr = (const struct sockaddr_in *)si->peername;
@@ -1167,15 +1156,33 @@ static void swrap_dump_packet(struct socket_info *si, const struct sockaddr *add
break;
default:
- return;
+ return NULL;
}
swrapGetTimeOfDay(&tv);
- packet = swrap_packet_init(&tv, src_addr, dest_addr, si->type,
+ return swrap_packet_init(&tv, src_addr, dest_addr, si->type,
(const unsigned char *)buf, len,
tcp_seq, tcp_ack, tcp_ctl, unreachable,
- &packet_len);
+ packet_len);
+}
+
+static void swrap_dump_packet(struct socket_info *si,
+ const struct sockaddr *addr,
+ enum swrap_packet_type type,
+ const void *buf, size_t len)
+{
+ const char *file_name;
+ struct swrap_packet *packet;
+ size_t packet_len = 0;
+ int fd;
+
+ file_name = socket_wrapper_pcap_file();
+ if (!file_name) {
+ return;
+ }
+
+ packet = swrap_marshall_packet(si, addr, type, buf, len, &packet_len);
if (!packet) {
return;
}
diff --git a/source4/lib/talloc/Makefile.in b/source4/lib/talloc/Makefile.in
index a33085f95b..07b8fd4ff0 100644
--- a/source4/lib/talloc/Makefile.in
+++ b/source4/lib/talloc/Makefile.in
@@ -19,71 +19,25 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
SHLIBEXT = @SHLIBEXT@
SHLD = @SHLD@
SHLD_FLAGS = @SHLD_FLAGS@
+tallocdir = @tallocdir@
-.SUFFIXES: .c .o .3 .3.xml .xml .html
+LIBOBJ = $(TALLOC_OBJ) @LIBREPLACEOBJ@
-LIBOBJ = @TALLOC_OBJ@ @LIBREPLACEOBJ@
+all:: showflags $(EXTRA_TARGETS)
-SOLIB = libtalloc.$(SHLIBEXT).$(PACKAGE_VERSION)
-SONAME = libtalloc.$(SHLIBEXT).1
+include $(tallocdir)/rules.mk
+include $(tallocdir)/talloc.mk
-.c.o:
- $(CC) $(PICFLAG) -o $@ -c $< $(CFLAGS)
+$(TALLOC_SOLIB): $(LIBOBJ)
+ $(SHLD) $(SHLD_FLAGS) -o $@ $(LIBOBJ) @SONAMEFLAG@$(TALLOC_SONAME)
-all: showflags libtalloc.a $(SOLIB) testsuite $(EXTRA_TARGETS)
+check: test
-showflags:
- @echo 'talloc will be compiled with flags:'
- @echo ' CFLAGS = $(CFLAGS)'
- @echo ' LIBS = $(LIBS)'
+installcheck:: test install
-testsuite: $(LIBOBJ) testsuite.o
- $(CC) $(CFLAGS) -o testsuite testsuite.o $(LIBOBJ) $(LIBS)
-
-libtalloc.a: $(LIBOBJ)
- ar -rv $@ $(LIBOBJ)
- @-ranlib $@
-
-$(SOLIB): $(LIBOBJ)
- $(SHLD) $(SHLD_FLAGS) -o $@ $(LIBOBJ) @SONAMEFLAG@$(SONAME)
-
-install: all
- ${INSTALLCMD} -d $(DESTDIR)$(libdir)
- ${INSTALLCMD} -d $(DESTDIR)$(libdir)/pkgconfig
- ${INSTALLCMD} -m 755 libtalloc.a $(DESTDIR)$(libdir)
- ${INSTALLCMD} -m 755 $(SOLIB) $(DESTDIR)$(libdir)
- ${INSTALLCMD} -d $(DESTDIR)${includedir}
- ${INSTALLCMD} -m 644 $(srcdir)/talloc.h $(DESTDIR)$(includedir)
- ${INSTALLCMD} -m 644 talloc.pc $(DESTDIR)$(libdir)/pkgconfig
- if [ -f talloc.3 ];then ${INSTALLCMD} -d $(DESTDIR)$(mandir)/man3; fi
- if [ -f talloc.3 ];then ${INSTALLCMD} -m 644 talloc.3 $(DESTDIR)$(mandir)/man3; fi
- which swig >/dev/null 2>&1 && ${INSTALLCMD} -d $(DESTDIR)`swig -swiglib` || true
- which swig >/dev/null 2>&1 && ${INSTALLCMD} -m 644 talloc.i $(DESTDIR)`swig -swiglib` || true
-
-doc: talloc.3 talloc.3.html
-
-.3.xml.3:
- -test -z "$(XSLTPROC)" || $(XSLTPROC) --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
-
-.xml.html:
- -test -z "$(XSLTPROC)" || $(XSLTPROC) --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl $<
-
-clean:
- rm -f *~ $(LIBOBJ) $(SOLIB) libtalloc.a testsuite testsuite.o *.gc?? talloc.3 talloc.3.html
-
-test: testsuite
- ./testsuite
-
-gcov:
- gcov talloc.c
-
-installcheck:
- $(MAKE) test
-
-distclean: clean
- rm -f *~ */*~
+distclean:: clean
rm -f Makefile
rm -f config.log config.status config.h config.cache
-realdistclean: distclean
+realdistclean:: distclean
rm -f configure config.h.in
diff --git a/source4/lib/talloc/config.mk b/source4/lib/talloc/config.mk
index 16b5063f87..af1b590c98 100644
--- a/source4/lib/talloc/config.mk
+++ b/source4/lib/talloc/config.mk
@@ -1,8 +1,6 @@
[LIBRARY::LIBTALLOC]
-VERSION = 1.0.0
-SO_VERSION = 1
+OUTPUT_TYPE = STATIC_LIBRARY
OBJ_FILES = talloc.o
-PC_FILE = talloc.pc
MANPAGE = talloc.3
CFLAGS = -Ilib/talloc
PUBLIC_HEADERS = talloc.h
diff --git a/source4/lib/talloc/configure.ac b/source4/lib/talloc/configure.ac
index 7878d59300..4719aa04b5 100644
--- a/source4/lib/talloc/configure.ac
+++ b/source4/lib/talloc/configure.ac
@@ -1,5 +1,5 @@
AC_PREREQ(2.50)
-AC_INIT(talloc, 1.1.0)
+AC_INIT(talloc, 1.2.0)
AC_CONFIG_SRCDIR([talloc.c])
AC_SUBST(datarootdir)
AC_CONFIG_HEADER(config.h)
diff --git a/source4/lib/talloc/rules.mk b/source4/lib/talloc/rules.mk
new file mode 100644
index 0000000000..6cee126529
--- /dev/null
+++ b/source4/lib/talloc/rules.mk
@@ -0,0 +1,18 @@
+.SUFFIXES: .c .o .3 .3.xml .xml .html
+
+showflags::
+ @echo 'talloc will be compiled with flags:'
+ @echo ' CFLAGS = $(CFLAGS)'
+ @echo ' LIBS = $(LIBS)'
+
+.c.o:
+ $(CC) $(PICFLAG) -o $@ -c $< $(CFLAGS)
+
+.3.xml.3:
+ -test -z "$(XSLTPROC)" || $(XSLTPROC) --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
+
+.xml.html:
+ -test -z "$(XSLTPROC)" || $(XSLTPROC) --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl $<
+
+distclean::
+ rm -f *~ */*~
diff --git a/source4/lib/talloc/talloc.c b/source4/lib/talloc/talloc.c
index f9aefcd6de..12b85f5a65 100644
--- a/source4/lib/talloc/talloc.c
+++ b/source4/lib/talloc/talloc.c
@@ -60,6 +60,8 @@
#define TALLOC_MAGIC 0xe814ec70
#define TALLOC_FLAG_FREE 0x01
#define TALLOC_FLAG_LOOP 0x02
+#define TALLOC_FLAG_POOL 0x04 /* This is a talloc pool */
+#define TALLOC_FLAG_POOLMEM 0x08 /* This is allocated in a pool */
#define TALLOC_MAGIC_REFERENCE ((const char *)1)
/* by default we abort when given a bad pointer (such as when talloc_free() is called
@@ -109,6 +111,19 @@ struct talloc_chunk {
const char *name;
size_t size;
unsigned flags;
+
+ /*
+ * "pool" has dual use:
+ *
+ * For the talloc pool itself (i.e. TALLOC_FLAG_POOL is set), "pool"
+ * marks the end of the currently allocated area.
+ *
+ * For members of the pool (i.e. TALLOC_FLAG_POOLMEM is set), "pool"
+ * is a pointer to the struct talloc_chunk of the pool that it was
+ * allocated from. This way children can quickly find the pool to chew
+ * from.
+ */
+ void *pool;
};
/* 16 byte alignment seems to keep everyone happy */
@@ -200,12 +215,87 @@ const char *talloc_parent_name(const void *ptr)
return tc? tc->name : NULL;
}
+/*
+ A pool carries an in-pool object count count in the first 16 bytes.
+ bytes. This is done to support talloc_steal() to a parent outside of the
+ pool. The count includes the pool itself, so a talloc_free() on a pool will
+ only destroy the pool if the count has dropped to zero. A talloc_free() of a
+ pool member will reduce the count, and eventually also call free(3) on the
+ pool memory.
+
+ The object count is not put into "struct talloc_chunk" because it is only
+ relevant for talloc pools and the alignment to 16 bytes would increase the
+ memory footprint of each talloc chunk by those 16 bytes.
+*/
+
+#define TALLOC_POOL_HDR_SIZE 16
+
+static unsigned int *talloc_pool_objectcount(struct talloc_chunk *tc)
+{
+ return (unsigned int *)((char *)tc + sizeof(struct talloc_chunk));
+}
+
+/*
+ Allocate from a pool
+*/
+
+static struct talloc_chunk *talloc_alloc_pool(struct talloc_chunk *parent,
+ size_t size)
+{
+ struct talloc_chunk *pool_ctx = NULL;
+ size_t space_left;
+ struct talloc_chunk *result;
+ size_t chunk_size;
+
+ if (parent == NULL) {
+ return NULL;
+ }
+
+ if (parent->flags & TALLOC_FLAG_POOL) {
+ pool_ctx = parent;
+ }
+ else if (parent->flags & TALLOC_FLAG_POOLMEM) {
+ pool_ctx = (struct talloc_chunk *)parent->pool;
+ }
+
+ if (pool_ctx == NULL) {
+ return NULL;
+ }
+
+ space_left = ((char *)pool_ctx + TC_HDR_SIZE + pool_ctx->size)
+ - ((char *)pool_ctx->pool);
+
+ /*
+ * Align size to 16 bytes
+ */
+ chunk_size = ((size + 15) & ~15);
+
+ if (space_left < chunk_size) {
+ return NULL;
+ }
+
+ result = (struct talloc_chunk *)pool_ctx->pool;
+
+#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_UNDEFINED)
+ VALGRIND_MAKE_MEM_UNDEFINED(result, size);
+#endif
+
+ pool_ctx->pool = (void *)((char *)result + chunk_size);
+
+ result->flags = TALLOC_MAGIC | TALLOC_FLAG_POOLMEM;
+ result->pool = pool_ctx;
+
+ *talloc_pool_objectcount(pool_ctx) += 1;
+
+ return result;
+}
+
/*
Allocate a bit of memory as a child of an existing pointer
*/
static inline void *__talloc(const void *context, size_t size)
{
- struct talloc_chunk *tc;
+ struct talloc_chunk *tc = NULL;
if (unlikely(context == NULL)) {
context = null_context;
@@ -215,11 +305,19 @@ static inline void *__talloc(const void *context, size_t size)
return NULL;
}
- tc = (struct talloc_chunk *)malloc(TC_HDR_SIZE+size);
- if (unlikely(tc == NULL)) return NULL;
+ if (context != NULL) {
+ tc = talloc_alloc_pool(talloc_chunk_from_ptr(context),
+ TC_HDR_SIZE+size);
+ }
+
+ if (tc == NULL) {
+ tc = (struct talloc_chunk *)malloc(TC_HDR_SIZE+size);
+ if (unlikely(tc == NULL)) return NULL;
+ tc->flags = TALLOC_MAGIC;
+ tc->pool = NULL;
+ }
tc->size = size;
- tc->flags = TALLOC_MAGIC;
tc->destructor = NULL;
tc->child = NULL;
tc->name = NULL;
@@ -246,6 +344,33 @@ static inline void *__talloc(const void *context, size_t size)
}
/*
+ * Create a talloc pool
+ */
+
+void *talloc_pool(const void *context, size_t size)
+{
+ void *result = __talloc(context, size + TALLOC_POOL_HDR_SIZE);
+ struct talloc_chunk *tc;
+
+ if (unlikely(result == NULL)) {
+ return NULL;
+ }
+
+ tc = talloc_chunk_from_ptr(result);
+
+ tc->flags |= TALLOC_FLAG_POOL;
+ tc->pool = (char *)result + TALLOC_POOL_HDR_SIZE;
+
+ *talloc_pool_objectcount(tc) = 1;
+
+#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_NOACCESS)
+ VALGRIND_MAKE_MEM_NOACCESS(tc->pool, size);
+#endif
+
+ return result;
+}
+
+/*
setup a destructor to be called on free of a pointer
the destructor should return 0 on success, or -1 on failure.
if the destructor fails then the free is failed, and the memory can
@@ -420,7 +545,29 @@ static inline int _talloc_free(void *ptr)
}
tc->flags |= TALLOC_FLAG_FREE;
- free(tc);
+
+ if (tc->flags & (TALLOC_FLAG_POOL|TALLOC_FLAG_POOLMEM)) {
+ struct talloc_chunk *pool;
+ unsigned int *pool_object_count;
+
+ pool = (tc->flags & TALLOC_FLAG_POOL)
+ ? tc : (struct talloc_chunk *)tc->pool;
+
+ pool_object_count = talloc_pool_objectcount(pool);
+
+ if (*pool_object_count == 0) {
+ TALLOC_ABORT("Pool object count zero!");
+ }
+
+ *pool_object_count -= 1;
+
+ if (*pool_object_count == 0) {
+ free(pool);
+ }
+ }
+ else {
+ free(tc);
+ }
return 0;
}
@@ -718,6 +865,15 @@ void talloc_free_children(void *ptr)
talloc_steal(new_parent, child);
}
}
+
+ if ((tc->flags & TALLOC_FLAG_POOL)
+ && (*talloc_pool_objectcount(tc) == 1)) {
+ tc->pool = ((char *)tc + TC_HDR_SIZE + TALLOC_POOL_HDR_SIZE);
+#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_NOACCESS)
+ VALGRIND_MAKE_MEM_NOACCESS(
+ tc->pool, tc->size - TALLOC_POOL_HDR_SIZE);
+#endif
+ }
}
/*
@@ -769,6 +925,7 @@ void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *n
{
struct talloc_chunk *tc;
void *new_ptr;
+ bool malloced = false;
/* size zero is equivalent to free() */
if (unlikely(size == 0)) {
@@ -792,6 +949,12 @@ void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *n
return NULL;
}
+ /* don't shrink if we have less than 1k to gain */
+ if ((size < tc->size) && ((tc->size - size) < 1024)) {
+ tc->size = size;
+ return ptr;
+ }
+
/* by resetting magic we catch users of the old memory */
tc->flags |= TALLOC_FLAG_FREE;
@@ -802,7 +965,24 @@ void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *n
free(tc);
}
#else
- new_ptr = realloc(tc, size + TC_HDR_SIZE);
+ if (tc->flags & TALLOC_FLAG_POOLMEM) {
+
+ new_ptr = talloc_alloc_pool(tc, size + TC_HDR_SIZE);
+ *talloc_pool_objectcount((struct talloc_chunk *)
+ (tc->pool)) -= 1;
+
+ if (new_ptr == NULL) {
+ new_ptr = malloc(TC_HDR_SIZE+size);
+ malloced = true;
+ }
+
+ if (new_ptr) {
+ memcpy(new_ptr, tc, MIN(tc->size,size) + TC_HDR_SIZE);
+ }
+ }
+ else {
+ new_ptr = realloc(tc, size + TC_HDR_SIZE);
+ }
#endif
if (unlikely(!new_ptr)) {
tc->flags &= ~TALLOC_FLAG_FREE;
@@ -810,7 +990,10 @@ void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *n
}
tc = (struct talloc_chunk *)new_ptr;
- tc->flags &= ~TALLOC_FLAG_FREE;
+ tc->flags &= ~TALLOC_FLAG_FREE;
+ if (malloced) {
+ tc->flags &= ~TALLOC_FLAG_POOLMEM;
+ }
if (tc->parent) {
tc->parent->child = tc;
}
diff --git a/source4/lib/talloc/talloc.h b/source4/lib/talloc/talloc.h
index e103391681..5431971655 100644
--- a/source4/lib/talloc/talloc.h
+++ b/source4/lib/talloc/talloc.h
@@ -116,6 +116,7 @@ typedef void TALLOC_CTX;
/* The following definitions come from talloc.c */
void *_talloc(const void *context, size_t size);
+void *talloc_pool(const void *context, size_t size);
void _talloc_set_destructor(const void *ptr, int (*destructor)(void *));
int talloc_increase_ref_count(const void *ptr);
size_t talloc_reference_count(const void *ptr);
diff --git a/source4/lib/talloc/talloc.mk b/source4/lib/talloc/talloc.mk
new file mode 100644
index 0000000000..e1fe88c84b
--- /dev/null
+++ b/source4/lib/talloc/talloc.mk
@@ -0,0 +1,37 @@
+TALLOC_OBJ = $(tallocdir)/talloc.o
+
+TALLOC_SOLIB = libtalloc.$(SHLIBEXT).$(PACKAGE_VERSION)
+TALLOC_SONAME = libtalloc.$(SHLIBEXT).1
+
+all:: libtalloc.a $(TALLOC_SOLIB) testsuite
+
+testsuite:: $(LIBOBJ) testsuite.o
+ $(CC) $(CFLAGS) -o testsuite testsuite.o $(LIBOBJ) $(LIBS)
+
+libtalloc.a: $(LIBOBJ)
+ ar -rv $@ $(LIBOBJ)
+ @-ranlib $@
+
+install:: all
+ ${INSTALLCMD} -d $(DESTDIR)$(libdir)
+ ${INSTALLCMD} -d $(DESTDIR)$(libdir)/pkgconfig
+ ${INSTALLCMD} -m 755 libtalloc.a $(DESTDIR)$(libdir)
+ ${INSTALLCMD} -m 755 $(TALLOC_SOLIB) $(DESTDIR)$(libdir)
+ ${INSTALLCMD} -d $(DESTDIR)${includedir}
+ ${INSTALLCMD} -m 644 $(srcdir)/talloc.h $(DESTDIR)$(includedir)
+ ${INSTALLCMD} -m 644 talloc.pc $(DESTDIR)$(libdir)/pkgconfig
+ if [ -f talloc.3 ];then ${INSTALLCMD} -d $(DESTDIR)$(mandir)/man3; fi
+ if [ -f talloc.3 ];then ${INSTALLCMD} -m 644 talloc.3 $(DESTDIR)$(mandir)/man3; fi
+ which swig >/dev/null 2>&1 && ${INSTALLCMD} -d $(DESTDIR)`swig -swiglib` || true
+ which swig >/dev/null 2>&1 && ${INSTALLCMD} -m 644 talloc.i $(DESTDIR)`swig -swiglib` || true
+
+doc:: talloc.3 talloc.3.html
+
+clean::
+ rm -f *~ $(LIBOBJ) $(TALLOC_SOLIB) libtalloc.a testsuite testsuite.o *.gc?? talloc.3 talloc.3.html
+
+test:: testsuite
+ ./testsuite
+
+gcov::
+ gcov talloc.c
diff --git a/source4/lib/talloc/testsuite.c b/source4/lib/talloc/testsuite.c
index e16c91f8b9..fedbda95aa 100644
--- a/source4/lib/talloc/testsuite.c
+++ b/source4/lib/talloc/testsuite.c
@@ -813,6 +813,25 @@ static bool test_speed(void)
talloc_free(ctx);
+ ctx = talloc_pool(NULL, 1024);
+
+ tv = timeval_current();
+ count = 0;
+ do {
+ void *p1, *p2, *p3;
+ for (i=0;i<loop;i++) {
+ p1 = talloc_size(ctx, loop % 100);
+ p2 = talloc_strdup(p1, "foo bar");
+ p3 = talloc_size(p1, 300);
+ talloc_free_children(ctx);
+ }
+ count += 3 * loop;
+ } while (timeval_elapsed(&tv) < 5.0);
+
+ talloc_free(ctx);
+
+ fprintf(stderr, "talloc_pool: %.0f ops/sec\n", count/timeval_elapsed(&tv));
+
tv = timeval_current();
count = 0;
do {
@@ -1066,6 +1085,23 @@ static bool test_autofree(void)
return true;
}
+static bool test_pool(void)
+{
+ void *pool;
+ void *p1, *p2, *p3, *p4;
+
+ pool = talloc_pool(NULL, 1024);
+
+ p1 = talloc_size(pool, 80);
+ p2 = talloc_size(pool, 20);
+ p3 = talloc_size(p1, 50);
+ p4 = talloc_size(p3, 1000);
+
+ talloc_free(pool);
+
+ return true;
+}
+
struct torture_context;
bool torture_local_talloc(struct torture_context *tctx)
{
@@ -1094,6 +1130,7 @@ bool torture_local_talloc(struct torture_context *tctx)
ret &= test_free_parent_deny_child();
ret &= test_talloc_ptrtype();
ret &= test_talloc_free_in_destructor();
+ ret &= test_pool();
if (ret) {
ret &= test_speed();
diff --git a/source4/lib/talloc/web/index.html b/source4/lib/talloc/web/index.html
index 106920e8a5..628030ad4c 100644
--- a/source4/lib/talloc/web/index.html
+++ b/source4/lib/talloc/web/index.html
@@ -12,7 +12,7 @@ destructors. It is the core memory allocator used in Samba4, and has
made a huge difference in many aspects of Samba4 development.<p>
To get started with talloc, I would recommend you read the <a
-href="http://samba.org/ftp/unpacked/samba4/source/lib/talloc/talloc_guide.txt">talloc guide</a>.
+href="http://samba.org/ftp/unpacked/samba_4_0_test/source/lib/talloc/talloc_guide.txt">talloc guide</a>.
<h2>Discussion and bug reports</h2>
@@ -24,19 +24,20 @@ bugzilla</a> bug tracking system.
<h2>Download</h2>
-You can download the latest release either via rsync or anonymous
-svn. To fetch via svn use the following command:
+You can download the latest release either via rsync or git.
+To fetch via git use the following command:
<pre>
- svn co svn://svnanon.samba.org/samba/branches/SAMBA_4_0/source/lib/talloc talloc
- svn co svn://svnanon.samba.org/samba/branches/SAMBA_4_0/source/lib/replace libreplace
+ git-clone git://git.samba.org/samba.git samba
+ cd samba
+ git checkout -b samba4 origin/v4-0-test
</pre>
To fetch via rsync use this command:
<pre>
- rsync -Pavz samba.org::ftp/unpacked/samba4/source/lib/talloc .
- rsync -Pavz samba.org::ftp/unpacked/samba4/source/lib/libreplace .
+ rsync -Pavz samba.org::ftp/unpacked/samba_4_0_test/source/lib/talloc .
+ rsync -Pavz samba.org::ftp/unpacked/samba_4_0_test/source/lib/libreplace .
</pre>
<hr>
diff --git a/source4/lib/tdb/Makefile.in b/source4/lib/tdb/Makefile.in
index c98d7e0497..090bb6e2dc 100644
--- a/source4/lib/tdb/Makefile.in
+++ b/source4/lib/tdb/Makefile.in
@@ -22,122 +22,38 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PICFLAG = @PICFLAG@
SHLIBEXT = @SHLIBEXT@
SWIG = swig
-
-.PHONY: test
-
-PROGS = bin/tdbtool$(EXEEXT) bin/tdbdump$(EXEEXT) bin/tdbbackup$(EXEEXT)
-PROGS_NOINSTALL = bin/tdbtest$(EXEEXT) bin/tdbtorture$(EXEEXT)
-ALL_PROGS = $(PROGS) $(PROGS_NOINSTALL)
+PYTHON = @PYTHON@
+PYTHON_CONFIG = @PYTHON_CONFIG@
+PYTHON_BUILD_TARGET = @PYTHON_BUILD_TARGET@
+PYTHON_INSTALL_TARGET = @PYTHON_INSTALL_TARGET@
+PYTHON_CHECK_TARGET = @PYTHON_CHECK_TARGET@
+LIB_PATH_VAR = @LIB_PATH_VAR@
+tdbdir = @tdbdir@
TDB_OBJ = @TDB_OBJ@ @LIBREPLACEOBJ@
-DIRS = bin common tools
-
-SONAME = libtdb.$(SHLIBEXT).1
-SOLIB = libtdb.$(SHLIBEXT).$(PACKAGE_VERSION)
-
-all: showflags dirs $(PROGS) $(SOLIB) libtdb.a @PYTHON_BUILD_TARGET@
-
-showflags:
- @echo 'tdb will be compiled with flags:'
- @echo ' CFLAGS = $(CFLAGS)'
- @echo ' CPPFLAGS = $(CPPFLAGS)'
- @echo ' LDFLAGS = $(LDFLAGS)'
- @echo ' LIBS = $(LIBS)'
-
-.SUFFIXES: .c .o
-
-.c.o:
- @echo Compiling $*.c
- @mkdir -p `dirname $@`
- @$(CC) $(PICFLAG) $(CFLAGS) -c $< -o $@
-
-dirs:
- @mkdir -p $(DIRS)
-
-install: all installdirs installbin installheaders installlibs @PYTHON_INSTALL_TARGET@
-
-installdirs:
- mkdir -p $(DESTDIR)$(bindir)
- mkdir -p $(DESTDIR)$(includedir)
- mkdir -p $(DESTDIR)$(libdir)
- mkdir -p $(DESTDIR)$(libdir)/pkgconfig
-
-installbin: installdirs
- cp $(PROGS) $(DESTDIR)$(bindir)
-
-installheaders: installdirs
- cp $(srcdir)/include/tdb.h $(DESTDIR)$(includedir)
-
-installlibs: installdirs
- cp tdb.pc $(DESTDIR)$(libdir)/pkgconfig
- cp libtdb.a $(SOLIB) $(DESTDIR)$(libdir)
-
-libtdb.a: $(TDB_OBJ)
- ar -rv libtdb.a $(TDB_OBJ)
+default: all
-libtdb.$(SHLIBEXT): $(SOLIB)
- ln -fs $< $@
+include $(tdbdir)/tdb.mk
+include $(tdbdir)/rules.mk
-$(SONAME): $(SOLIB)
- ln -fs $< $@
+all:: showflags dirs $(PROGS) $(TDB_SOLIB) libtdb.a $(PYTHON_BUILD_TARGET)
-$(SOLIB): $(TDB_OBJ)
- $(SHLD) $(SHLD_FLAGS) -o $@ $(TDB_OBJ) @SONAMEFLAG@$(SONAME)
+install:: all
+$(TDB_SOLIB): $(TDB_OBJ)
+ $(SHLD) $(SHLD_FLAGS) -o $@ $(TDB_OBJ) @SONAMEFLAG@$(TDB_SONAME)
-TDB_LIB = libtdb.a
+check: test
-bin/tdbtest$(EXEEXT): tools/tdbtest.o $(TDB_LIB)
- $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbtest tools/tdbtest.o -L. -ltdb -lgdbm
+test:: $(PYTHON_CHECK_TARGET)
+installcheck:: test install
-bin/tdbtool$(EXEEXT): tools/tdbtool.o $(TDB_LIB)
- $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbtool tools/tdbtool.o -L. -ltdb
+clean::
+ rm -f *.o *.a */*.o
-bin/tdbtorture$(EXEEXT): tools/tdbtorture.o $(TDB_LIB)
- $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbtorture tools/tdbtorture.o -L. -ltdb
-
-bin/tdbdump$(EXEEXT): tools/tdbdump.o $(TDB_LIB)
- $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbdump tools/tdbdump.o -L. -ltdb
-
-bin/tdbbackup$(EXEEXT): tools/tdbbackup.o $(TDB_LIB)
- $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbbackup tools/tdbbackup.o -L. -ltdb
-
-test: bin/tdbtorture$(EXEEXT)
- bin/tdbtorture$(EXEEXT)
-
-installcheck: test install
-
-clean:
- rm -f $(ALL_PROGS) *.o *.a common/*.o tools/*.o tdb.pc
- rm -f test.db test.tdb torture.tdb test.gdbm
- rm -f $(SONAME) $(SOLIB) libtdb.a libtdb.$(SHLIBEXT)
-
-distclean: clean
- rm -f *~ */*~
+distclean:: clean
rm -f config.log config.status include/config.h config.cache
rm -f Makefile
-realdistclean: distclean
+realdistclean:: distclean
rm -f configure include/config.h.in
-
-.SUFFIXES: .i _wrap.c
-
-.i_wrap.c:
- $(SWIG) -O -Wall -python -keyword $<
-
-build-python: libtdb.$(SHLIBEXT) tdb_wrap.c
- ./setup.py build
-
-installpython: build-python
- ./setup.py install --prefix=$(DESTDIR)$(prefix)
-
-check-python: build-python
- # FIXME: Should be more portable:
- LD_LIBRARY_PATH=. PYTHONPATH=.:build/lib.linux-i686-2.4 trial python/tests/simple.py
-
-install-swig:
- mkdir -p $(DESTDIR)`$(SWIG) -swiglib`
- cp tdb.i $(DESTDIR)`$(SWIG) -swiglib`
-
-clean-python:
- ./setup.py clean
diff --git a/source4/lib/tdb/config.mk b/source4/lib/tdb/config.mk
index 820c55e363..89d6af9043 100644
--- a/source4/lib/tdb/config.mk
+++ b/source4/lib/tdb/config.mk
@@ -1,9 +1,7 @@
################################################
# Start SUBSYSTEM LIBTDB
[LIBRARY::LIBTDB]
-VERSION = 0.0.1
-SO_VERSION = 0
-PC_FILE = tdb.pc
+OUTPUT_TYPE = STATIC_LIBRARY
OBJ_FILES = \
common/tdb.o common/dump.o common/io.o common/lock.o \
common/open.o common/traverse.o common/freelist.o \
diff --git a/source4/lib/tdb/configure.ac b/source4/lib/tdb/configure.ac
index 5747107f38..9b16a82c33 100644
--- a/source4/lib/tdb/configure.ac
+++ b/source4/lib/tdb/configure.ac
@@ -11,15 +11,20 @@ AC_LD_PICFLAG
AC_LD_SHLIBEXT
AC_LIBREPLACE_SHLD
AC_LIBREPLACE_SHLD_FLAGS
+AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
m4_include(libtdb.m4)
AC_PATH_PROGS([PYTHON_CONFIG], [python2.6-config python2.5-config python2.4-config python-config])
+AC_PATH_PROGS([PYTHON], [python2.6 python2.5 python2.4 python])
PYTHON_BUILD_TARGET="build-python"
PYTHON_INSTALL_TARGET="install-python"
+PYTHON_CHECK_TARGET="check-python"
AC_SUBST(PYTHON_BUILD_TARGET)
AC_SUBST(PYTHON_INSTALL_TARGET)
+AC_SUBST(PYTHON_CHECK_TARGET)
if test -z "$PYTHON_CONFIG"; then
PYTHON_BUILD_TARGET=""
PYTHON_INSTALL_TARGET=""
+ PYTHON_CHECK_TARGET=""
fi
AC_OUTPUT(Makefile tdb.pc)
diff --git a/source4/lib/tdb/python/tests/simple.py b/source4/lib/tdb/python/tests/simple.py
index 1cc51aea07..94407b6398 100644
--- a/source4/lib/tdb/python/tests/simple.py
+++ b/source4/lib/tdb/python/tests/simple.py
@@ -142,3 +142,8 @@ class SimpleTdbTests(TestCase):
self.assertEquals(0, len(self.tdb))
self.tdb["entry"] = "value"
self.assertEquals(1, len(self.tdb))
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.TestProgram()
diff --git a/source4/lib/tdb/rules.mk b/source4/lib/tdb/rules.mk
new file mode 100644
index 0000000000..7b765625df
--- /dev/null
+++ b/source4/lib/tdb/rules.mk
@@ -0,0 +1,21 @@
+.SUFFIXES: .i _wrap.c
+
+.i_wrap.c:
+ $(SWIG) -O -Wall -python -keyword $<
+
+showflags::
+ @echo 'tdb will be compiled with flags:'
+ @echo ' CFLAGS = $(CFLAGS)'
+ @echo ' CPPFLAGS = $(CPPFLAGS)'
+ @echo ' LDFLAGS = $(LDFLAGS)'
+ @echo ' LIBS = $(LIBS)'
+
+.SUFFIXES: .c .o
+
+.c.o:
+ @echo Compiling $*.c
+ @mkdir -p `dirname $@`
+ @$(CC) $(PICFLAG) $(CFLAGS) -c $< -o $@
+
+distclean::
+ rm -f *~ */*~
diff --git a/source4/lib/tdb/setup.py b/source4/lib/tdb/setup.py
deleted file mode 100755
index 8be0c67e0b..0000000000
--- a/source4/lib/tdb/setup.py
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/python
-from distutils.core import setup
-from distutils.extension import Extension
-
-setup(name='tdb',
- version='1.0',
- url="http://tdb.samba.org/",
- py_modules=["tdb"],
- ext_modules=[Extension('_tdb', ['tdb_wrap.c'], include_dirs=['include'],
- library_dirs=["."], libraries=['tdb'])],
-)
diff --git a/source4/lib/tdb/tdb.mk b/source4/lib/tdb/tdb.mk
new file mode 100644
index 0000000000..0e53927366
--- /dev/null
+++ b/source4/lib/tdb/tdb.mk
@@ -0,0 +1,86 @@
+dirs::
+ @mkdir -p bin common tools
+
+PROGS = bin/tdbtool$(EXEEXT) bin/tdbdump$(EXEEXT) bin/tdbbackup$(EXEEXT)
+PROGS_NOINSTALL = bin/tdbtest$(EXEEXT) bin/tdbtorture$(EXEEXT)
+ALL_PROGS = $(PROGS) $(PROGS_NOINSTALL)
+
+TDB_SONAME = libtdb.$(SHLIBEXT).1
+TDB_SOLIB = libtdb.$(SHLIBEXT).$(PACKAGE_VERSION)
+
+TDB_LIB = libtdb.a
+
+bin/tdbtest$(EXEEXT): tools/tdbtest.o $(TDB_LIB)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbtest tools/tdbtest.o -L. -ltdb -lgdbm
+
+bin/tdbtool$(EXEEXT): tools/tdbtool.o $(TDB_LIB)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbtool tools/tdbtool.o -L. -ltdb
+
+bin/tdbtorture$(EXEEXT): tools/tdbtorture.o $(TDB_LIB)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbtorture tools/tdbtorture.o -L. -ltdb
+
+bin/tdbdump$(EXEEXT): tools/tdbdump.o $(TDB_LIB)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbdump tools/tdbdump.o -L. -ltdb
+
+bin/tdbbackup$(EXEEXT): tools/tdbbackup.o $(TDB_LIB)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o bin/tdbbackup tools/tdbbackup.o -L. -ltdb
+
+test:: bin/tdbtorture$(EXEEXT) $(TDB_SONAME)
+ $(LIB_PATH_VAR)=. bin/tdbtorture$(EXEEXT)
+
+clean::
+ rm -f test.db test.tdb torture.tdb test.gdbm
+ rm -f $(TDB_SONAME) $(TDB_SOLIB) libtdb.a libtdb.$(SHLIBEXT)
+ rm -f $(ALL_PROGS) tdb.pc
+
+build-python:: _tdb.$(SHLIBEXT)
+
+tdb_wrap.o: $(tdbdir)/tdb_wrap.c
+ $(CC) $(PICFLAG) -c $(tdbdir)/tdb_wrap.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags`
+
+_tdb.$(SHLIBEXT): libtdb.$(SHLIBEXT) tdb_wrap.o
+ $(SHLD) $(SHLD_FLAGS) -o $@ tdb_wrap.o -L. -ltdb `$(PYTHON_CONFIG) --libs`
+
+install:: installdirs installbin installheaders installlibs \
+ $(PYTHON_INSTALL_TARGET)
+
+install-python:: build-python
+ mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` \
+ $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"`
+ cp $(tdbdir)/tdb.py $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"`
+ cp _tdb.$(SHLIBEXT) $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"`
+
+check-python:: build-python
+ $(LIB_PATH_VAR)=. PYTHONPATH=".:$(tdbdir)" $(PYTHON) $(tdbdir)/python/tests/simple.py
+
+install-swig::
+ mkdir -p $(DESTDIR)`$(SWIG) -swiglib`
+ cp tdb.i $(DESTDIR)`$(SWIG) -swiglib`
+
+clean::
+ rm -f _tdb.$(SHLIBEXT)
+
+installdirs::
+ mkdir -p $(DESTDIR)$(bindir)
+ mkdir -p $(DESTDIR)$(includedir)
+ mkdir -p $(DESTDIR)$(libdir)
+ mkdir -p $(DESTDIR)$(libdir)/pkgconfig
+
+installbin:: all installdirs
+ cp $(PROGS) $(DESTDIR)$(bindir)
+
+installheaders:: installdirs
+ cp $(srcdir)/include/tdb.h $(DESTDIR)$(includedir)
+
+installlibs:: all installdirs
+ cp tdb.pc $(DESTDIR)$(libdir)/pkgconfig
+ cp libtdb.a $(TDB_SOLIB) $(DESTDIR)$(libdir)
+
+libtdb.a: $(TDB_OBJ)
+ ar -rv libtdb.a $(TDB_OBJ)
+
+libtdb.$(SHLIBEXT): $(TDB_SOLIB)
+ ln -fs $< $@
+
+$(TDB_SONAME): $(TDB_SOLIB)
+ ln -fs $< $@
diff --git a/source4/lib/tls/config.m4 b/source4/lib/tls/config.m4
index 00d4194b3a..8b6ad7dcbc 100644
--- a/source4/lib/tls/config.m4
+++ b/source4/lib/tls/config.m4
@@ -1,7 +1,9 @@
###############################
# start SMB_EXT_LIB_GNUTLS
# check for gnutls/gnutls.h and -lgnutls
-SMB_EXT_LIB_FROM_PKGCONFIG(GNUTLS, gnutls)
+SMB_EXT_LIB_FROM_PKGCONFIG(GNUTLS, gnutls,
+ [SMB_ENABLE_GNUTLS=YES],
+ [SMB_ENABLE_GNUTLS=NO])
if test x$SMB_ENABLE_GNUTLS = xNO; then
AC_CHECK_HEADERS(gnutls/gnutls.h)
diff --git a/source4/lib/util/attr.h b/source4/lib/util/attr.h
index 8f6c4f5d8a..f64b272a67 100644
--- a/source4/lib/util/attr.h
+++ b/source4/lib/util/attr.h
@@ -29,13 +29,11 @@
/** Feel free to add definitions for other compilers here. */
#endif
-#ifndef _PUBLIC_
#ifdef HAVE_VISIBILITY_ATTR
# define _PUBLIC_ __attribute__((visibility("default")))
#else
# define _PUBLIC_
#endif
-#endif
#ifndef _DEPRECATED_
#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
diff --git a/source4/lib/util/fault.c b/source4/lib/util/fault.c
index cd347a5ef9..cb51cbd859 100644
--- a/source4/lib/util/fault.c
+++ b/source4/lib/util/fault.c
@@ -178,7 +178,7 @@ _NORETURN_ static void sig_fault(int sig)
/* we have a fault handler, call it. It may not return. */
fault_handlers.fault_handler(sig);
}
- /* If it returns or doean't exist, use regular reporter */
+ /* If it returns or doesn't exist, use regular reporter */
fault_report(sig);
}
diff --git a/source4/lib/util/time.c b/source4/lib/util/time.c
index fc51498009..a181885806 100644
--- a/source4/lib/util/time.c
+++ b/source4/lib/util/time.c
@@ -612,3 +612,11 @@ _PUBLIC_ int get_time_zone(time_t t)
return 0;
return tm_diff(&tm_utc,tm);
}
+
+/**
+ check if 2 NTTIMEs are equal.
+*/
+bool nt_time_equal(NTTIME *t1, NTTIME *t2)
+{
+ return *t1 == *t2;
+}
diff --git a/source4/lib/util/time.h b/source4/lib/util/time.h
index 557c5d4eab..1ab976ca78 100644
--- a/source4/lib/util/time.h
+++ b/source4/lib/util/time.h
@@ -224,6 +224,9 @@ _PUBLIC_ void nttime_to_timeval(struct timeval *tv, NTTIME t);
*/
_PUBLIC_ int get_time_zone(time_t t);
-
+/**
+ check if 2 NTTIMEs are equal.
+*/
+bool nt_time_equal(NTTIME *t1, NTTIME *t2);
#endif /* _SAMBA_TIME_H_ */
diff --git a/source4/lib/util/util.h b/source4/lib/util/util.h
index 9e106052f2..550b60c625 100644
--- a/source4/lib/util/util.h
+++ b/source4/lib/util/util.h
@@ -21,6 +21,8 @@
#ifndef _SAMBA_UTIL_H_
#define _SAMBA_UTIL_H_
+#include "util/attr.h"
+
#include "charset/charset.h"
/* for TALLOC_CTX */
@@ -36,7 +38,6 @@ struct smbsrv_tcon;
extern const char *logfile;
extern const char *panic_action;
-#include "util/attr.h"
#include "util/time.h"
#include "util/data_blob.h"
#include "util/xfile.h"
diff --git a/source4/lib/util/util_ldb.c b/source4/lib/util/util_ldb.c
index a8719af190..f1b42effd8 100644
--- a/source4/lib/util/util_ldb.c
+++ b/source4/lib/util/util_ldb.c
@@ -1,21 +1,21 @@
-/*
+/*
Unix SMB/CIFS implementation.
common share info functions
Copyright (C) Andrew Tridgell 2004
Copyright (C) Tim Potter 2004
-
+
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/>.
*/
@@ -56,7 +56,7 @@ int gendb_search_v(struct ldb_context *ldb,
if (ret == LDB_SUCCESS) {
talloc_steal(mem_ctx, res->msgs);
- DEBUG(6,("gendb_search_v: %s %s -> %d\n",
+ DEBUG(6,("gendb_search_v: %s %s -> %d\n",
basedn?ldb_dn_get_linearized(basedn):"NULL",
expr?expr:"NULL", res->count));
@@ -67,7 +67,8 @@ int gendb_search_v(struct ldb_context *ldb,
ret = 0;
*msgs = NULL;
} else {
- DEBUG(4,("gendb_search_v: search failed: %s", ldb_errstring(ldb)));
+ DEBUG(4,("gendb_search_v: search failed: %s\n",
+ ldb_errstring(ldb)));
ret = -1;
}
@@ -80,7 +81,7 @@ int gendb_search_v(struct ldb_context *ldb,
search the LDB for the specified attributes - varargs variant
*/
int gendb_search(struct ldb_context *ldb,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
struct ldb_dn *basedn,
struct ldb_message ***res,
const char * const *attrs,
@@ -101,7 +102,7 @@ int gendb_search(struct ldb_context *ldb,
*/
int gendb_search_dn(struct ldb_context *ldb,
- TALLOC_CTX *mem_ctx,
+ TALLOC_CTX *mem_ctx,
struct ldb_dn *dn,
struct ldb_message ***res,
const char * const *attrs)
diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c
index 67d5885497..aab7487a42 100644
--- a/source4/libcli/composite/composite.c
+++ b/source4/libcli/composite/composite.c
@@ -64,23 +64,6 @@ _PUBLIC_ NTSTATUS composite_wait(struct composite_context *c)
return c->status;
}
-
-/*
- * Some composite helpers that are handy if you write larger composite
- * functions.
- */
-_PUBLIC_ bool composite_is_ok(struct composite_context *ctx)
-{
- if (NT_STATUS_IS_OK(ctx->status)) {
- return true;
- }
- ctx->state = COMPOSITE_STATE_ERROR;
- if (ctx->async.fn != NULL) {
- ctx->async.fn(ctx);
- }
- return false;
-}
-
/*
callback from composite_done() and composite_error()
@@ -110,7 +93,10 @@ _PUBLIC_ void composite_error(struct composite_context *ctx, NTSTATUS status)
event_add_timed(ctx->event_ctx, ctx, timeval_zero(), composite_trigger, ctx);
}
ctx->status = status;
- SMB_ASSERT(!composite_is_ok(ctx));
+ ctx->state = COMPOSITE_STATE_ERROR;
+ if (ctx->async.fn != NULL) {
+ ctx->async.fn(ctx);
+ }
}
_PUBLIC_ bool composite_nomem(const void *p, struct composite_context *ctx)
@@ -122,6 +108,15 @@ _PUBLIC_ bool composite_nomem(const void *p, struct composite_context *ctx)
return true;
}
+_PUBLIC_ bool composite_is_ok(struct composite_context *ctx)
+{
+ if (NT_STATUS_IS_OK(ctx->status)) {
+ return true;
+ }
+ composite_error(ctx, ctx->status);
+ return false;
+}
+
_PUBLIC_ void composite_done(struct composite_context *ctx)
{
if (!ctx->used_wait && !ctx->async.fn) {
diff --git a/source4/libcli/config.mk b/source4/libcli/config.mk
index cf87e6c045..e4b6c71c8c 100644
--- a/source4/libcli/config.mk
+++ b/source4/libcli/config.mk
@@ -1,6 +1,6 @@
-include auth/config.mk
-include ldap/config.mk
-include security/config.mk
+mkinclude auth/config.mk
+mkinclude ldap/config.mk
+mkinclude security/config.mk
[SUBSYSTEM::LIBSAMBA-ERRORS]
PUBLIC_HEADERS = util/error.h util/ntstatus.h util/doserr.h util/werror.h
@@ -118,7 +118,7 @@ PUBLIC_DEPENDENCIES = LIBCLI_RAW LIBSAMBA-ERRORS LIBCLI_AUTH \
[SUBSYSTEM::LIBCLI_RAW]
PRIVATE_PROTO_HEADER = raw/raw_proto.h
PRIVATE_DEPENDENCIES = LIBCLI_COMPOSITE LP_RESOLVE gensec LIBCLI_RESOLVE LIBSECURITY LIBNDR
-LDFLAGS = $(SUBSYSTEM_LIBCLI_SMB_COMPOSITE_OUTPUT)
+#LDFLAGS = $(LIBCLI_SMB_COMPOSITE_OUTPUT)
PUBLIC_DEPENDENCIES = samba-socket LIBPACKET gensec LIBCRYPTO CREDENTIALS
OBJ_FILES = raw/rawfile.o \
raw/smb_signing.o \
@@ -144,4 +144,4 @@ OBJ_FILES = raw/rawfile.o \
raw/rawlpq.o \
raw/rawshadow.o
-include smb2/config.mk
+mkinclude smb2/config.mk
diff --git a/source4/libcli/raw/clisession.c b/source4/libcli/raw/clisession.c
index 617131c53c..55cb3ef305 100644
--- a/source4/libcli/raw/clisession.c
+++ b/source4/libcli/raw/clisession.c
@@ -177,9 +177,9 @@ NTSTATUS smb_raw_sesssetup_recv(struct smbcli_request *req,
parms->old.out.action = SVAL(req->in.vwv, VWV(2));
p = req->in.data;
if (p) {
- p += smbcli_req_pull_string(req, mem_ctx, &parms->old.out.os, p, -1, STR_TERMINATE);
- p += smbcli_req_pull_string(req, mem_ctx, &parms->old.out.lanman, p, -1, STR_TERMINATE);
- p += smbcli_req_pull_string(req, mem_ctx, &parms->old.out.domain, p, -1, STR_TERMINATE);
+ p += smbcli_req_pull_string(&req->in.bufinfo, mem_ctx, &parms->old.out.os, p, -1, STR_TERMINATE);
+ p += smbcli_req_pull_string(&req->in.bufinfo, mem_ctx, &parms->old.out.lanman, p, -1, STR_TERMINATE);
+ p += smbcli_req_pull_string(&req->in.bufinfo, mem_ctx, &parms->old.out.domain, p, -1, STR_TERMINATE);
}
break;
@@ -190,10 +190,10 @@ NTSTATUS smb_raw_sesssetup_recv(struct smbcli_request *req,
parms->nt1.out.action = SVAL(req->in.vwv, VWV(2));
p = req->in.data;
if (p) {
- p += smbcli_req_pull_string(req, mem_ctx, &parms->nt1.out.os, p, -1, STR_TERMINATE);
- p += smbcli_req_pull_string(req, mem_ctx, &parms->nt1.out.lanman, p, -1, STR_TERMINATE);
+ p += smbcli_req_pull_string(&req->in.bufinfo, mem_ctx, &parms->nt1.out.os, p, -1, STR_TERMINATE);
+ p += smbcli_req_pull_string(&req->in.bufinfo, mem_ctx, &parms->nt1.out.lanman, p, -1, STR_TERMINATE);
if (p < (req->in.data + req->in.data_size)) {
- p += smbcli_req_pull_string(req, mem_ctx, &parms->nt1.out.domain, p, -1, STR_TERMINATE);
+ p += smbcli_req_pull_string(&req->in.bufinfo, mem_ctx, &parms->nt1.out.domain, p, -1, STR_TERMINATE);
}
}
break;
@@ -209,11 +209,11 @@ NTSTATUS smb_raw_sesssetup_recv(struct smbcli_request *req,
break;
}
- parms->spnego.out.secblob = smbcli_req_pull_blob(req, mem_ctx, p, len);
+ parms->spnego.out.secblob = smbcli_req_pull_blob(&req->in.bufinfo, mem_ctx, p, len);
p += parms->spnego.out.secblob.length;
- p += smbcli_req_pull_string(req, mem_ctx, &parms->spnego.out.os, p, -1, STR_TERMINATE);
- p += smbcli_req_pull_string(req, mem_ctx, &parms->spnego.out.lanman, p, -1, STR_TERMINATE);
- p += smbcli_req_pull_string(req, mem_ctx, &parms->spnego.out.workgroup, p, -1, STR_TERMINATE);
+ p += smbcli_req_pull_string(&req->in.bufinfo, mem_ctx, &parms->spnego.out.os, p, -1, STR_TERMINATE);
+ p += smbcli_req_pull_string(&req->in.bufinfo, mem_ctx, &parms->spnego.out.lanman, p, -1, STR_TERMINATE);
+ p += smbcli_req_pull_string(&req->in.bufinfo, mem_ctx, &parms->spnego.out.workgroup, p, -1, STR_TERMINATE);
break;
case RAW_SESSSETUP_SMB2:
diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c
index 62c32d3058..288f0612de 100644
--- a/source4/libcli/raw/clitransport.c
+++ b/source4/libcli/raw/clitransport.c
@@ -444,6 +444,8 @@ static NTSTATUS smbcli_transport_finish_recv(void *private, DATA_BLOB blob)
req->in.ptr = req->in.data;
req->flags2 = SVAL(req->in.hdr, HDR_FLG2);
+ smb_setup_bufinfo(req);
+
if (!(req->flags2 & FLAGS2_32_BIT_ERROR_CODES)) {
int class = CVAL(req->in.hdr,HDR_RCLS);
int code = SVAL(req->in.hdr,HDR_ERR);
@@ -637,7 +639,7 @@ NTSTATUS smb_raw_echo_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
p->out.data = talloc_array(mem_ctx, uint8_t, p->out.size);
NT_STATUS_HAVE_NO_MEMORY(p->out.data);
- if (!smbcli_raw_pull_data(req, req->in.data, p->out.size, p->out.data)) {
+ if (!smbcli_raw_pull_data(&req->in.bufinfo, req->in.data, p->out.size, p->out.data)) {
req->status = NT_STATUS_BUFFER_TOO_SMALL;
}
diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c
index 35f3335322..507bde999a 100644
--- a/source4/libcli/raw/clitree.c
+++ b/source4/libcli/raw/clitree.c
@@ -123,9 +123,9 @@ NTSTATUS smb_raw_tcon_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
p = req->in.data;
if (!p) break;
- p += smbcli_req_pull_string(req, mem_ctx, &parms->tconx.out.dev_type,
- p, -1, STR_ASCII | STR_TERMINATE);
- p += smbcli_req_pull_string(req, mem_ctx, &parms->tconx.out.fs_type,
+ p += smbcli_req_pull_string(&req->in.bufinfo, mem_ctx, &parms->tconx.out.dev_type,
+ p, -1, STR_ASCII | STR_TERMINATE);
+ p += smbcli_req_pull_string(&req->in.bufinfo, mem_ctx, &parms->tconx.out.fs_type,
p, -1, STR_TERMINATE);
break;
diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h
index 00ab788184..24e8ad4afc 100644
--- a/source4/libcli/raw/interfaces.h
+++ b/source4/libcli/raw/interfaces.h
@@ -260,20 +260,19 @@ union smb_tcon {
struct {
/* static body buffer 8 (0x08) bytes */
- /* uint16_t buffer_code; 0x09 = 0x08 + 1 */
- uint16_t unknown1; /* 0x0000 */
+ uint16_t reserved;
/* uint16_t path_ofs */
/* uint16_t path_size */
-
- /* dynamic body */
+ /* dynamic body */
const char *path; /* as non-terminated UTF-16 on the wire */
} in;
struct {
/* static body buffer 16 (0x10) bytes */
/* uint16_t buffer_code; 0x10 */
- uint16_t unknown1; /* 0x02 */
- uint32_t unknown2; /* 0x00 */
- uint32_t unknown3; /* 0x00 */
+ uint8_t share_type;
+ uint8_t reserved;
+ uint32_t flags;
+ uint32_t capabilities;
uint32_t access_mask;
/* extracted from the SMB2 header */
@@ -373,29 +372,22 @@ union smb_sesssetup {
enum smb_sesssetup_level level;
struct {
- /* NOTE: this was 0x11 = 0x10 + 1 in vista-CTP
- * and changed in vista-beta2, but both server's
- * can handle the 0x18 clients
- */
- /* static body buffer 24 (0x18) bytes */
- /* uint16_t buffer_code; 0x19 = 0x18 + 1 */
- uint16_t _pad;
- uint32_t unknown2; /* 0x0000000F(vista-CTP) 0x00000007(vista-beta2) */
- uint32_t unknown3; /* 0x0000000 */
+ /* static body 24 (0x18) bytes */
+ uint8_t vc_number;
+ uint8_t security_mode;
+ uint32_t capabilities;
+ uint32_t channel;
/* uint16_t secblob_ofs */
/* uint16_t secblob_size */
- uint64_t unknown4; /* 0x0000000000000000 only present in vista-beta2 */
-
+ uint64_t previous_sessionid;
/* dynamic body */
DATA_BLOB secblob;
} in;
struct {
- /* static body buffer 8 (0x08) bytes */
- /* uint16_t buffer_code; 0x09 = 0x08 +1 */
- uint16_t _pad;
+ /* body buffer 8 (0x08) bytes */
+ uint16_t session_flags;
/* uint16_t secblob_ofs */
/* uint16_t secblob_size */
-
/* dynamic body */
DATA_BLOB secblob;
@@ -910,7 +902,10 @@ enum smb_setfileinfo_level {
RAW_SFILEINFO_1029 = SMB_SFILEINFO_1029,
RAW_SFILEINFO_1032 = SMB_SFILEINFO_1032,
RAW_SFILEINFO_1039 = SMB_SFILEINFO_1039,
- RAW_SFILEINFO_1040 = SMB_SFILEINFO_1040
+ RAW_SFILEINFO_1040 = SMB_SFILEINFO_1040,
+
+ /* cope with breakage in SMB2 */
+ RAW_SFILEINFO_RENAME_INFORMATION_SMB2 = SMB_SFILEINFO_RENAME_INFORMATION|0x80000000,
};
/* union used in setfileinfo() and setpathinfo() calls */
@@ -1008,7 +1003,7 @@ union smb_setfileinfo {
struct {
union smb_handle_or_path file;
uint8_t overwrite;
- uint32_t root_fid;
+ uint64_t root_fid;
const char *new_name;
} in;
} rename_information;
@@ -1560,16 +1555,16 @@ union smb_open {
enum smb_open_level level;
struct {
/* static body buffer 56 (0x38) bytes */
- /* uint16_t buffer_code; 0x39 = 0x38 + 1 */
- uint16_t oplock_flags; /* SMB2_CREATE_FLAG_* */
- uint32_t impersonation;
- uint32_t unknown3[4];
- uint32_t access_mask;
-
- uint32_t file_attr;
- uint32_t share_access;
- uint32_t open_disposition;
- uint32_t create_options;
+ uint8_t security_flags; /* SMB2_SECURITY_* */
+ uint8_t oplock_level; /* SMB2_OPLOCK_LEVEL_* */
+ uint32_t impersonation_level; /* SMB2_IMPERSONATION_* */
+ uint64_t create_flags;
+ uint64_t reserved;
+ uint32_t desired_access;
+ uint32_t file_attributes;
+ uint32_t share_access; /* NTCREATEX_SHARE_ACCESS_* */
+ uint32_t create_disposition; /* NTCREATEX_DISP_* */
+ uint32_t create_options; /* NTCREATEX_OPTIONS_* */
/* uint16_t fname_ofs */
/* uint16_t fname_size */
@@ -1587,7 +1582,8 @@ union smb_open {
/* static body buffer 88 (0x58) bytes */
/* uint16_t buffer_code; 0x59 = 0x58 + 1 */
- uint16_t oplock_flags; /* SMB2_CREATE_FLAG_* */
+ uint8_t oplock_level;
+ uint8_t reserved;
uint32_t create_action;
NTTIME create_time;
NTTIME access_time;
@@ -1596,7 +1592,7 @@ union smb_open {
uint64_t alloc_size;
uint64_t size;
uint32_t file_attr;
- uint32_t _pad;
+ uint32_t reserved2;
/* struct smb2_handle handle;*/
/* uint32_t blob_ofs; */
/* uint32_t blob_size; */
diff --git a/source4/libcli/raw/libcliraw.h b/source4/libcli/raw/libcliraw.h
index 0032eb4e94..7111649fc1 100644
--- a/source4/libcli/raw/libcliraw.h
+++ b/source4/libcli/raw/libcliraw.h
@@ -250,8 +250,8 @@ struct smbcli_request {
/* the mid of this packet - used to match replies */
uint16_t mid;
- struct request_buffer in;
- struct request_buffer out;
+ struct smb_request_buffer in;
+ struct smb_request_buffer out;
/* information on what to do with a reply when it is received
asyncronously. If this is not setup when a reply is received then
diff --git a/source4/libcli/raw/rawfile.c b/source4/libcli/raw/rawfile.c
index 3b6ca68526..d9383401b7 100644
--- a/source4/libcli/raw/rawfile.c
+++ b/source4/libcli/raw/rawfile.c
@@ -616,7 +616,7 @@ NTSTATUS smb_raw_open_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, unio
case RAW_OPEN_CTEMP:
SMBCLI_CHECK_WCT(req, 1);
parms->ctemp.out.file.fnum = SVAL(req->in.vwv, VWV(0));
- smbcli_req_pull_string(req, mem_ctx, &parms->ctemp.out.name, req->in.data, -1, STR_TERMINATE | STR_ASCII);
+ smbcli_req_pull_string(&req->in.bufinfo, mem_ctx, &parms->ctemp.out.name, req->in.data, -1, STR_TERMINATE | STR_ASCII);
break;
case RAW_OPEN_SPLOPEN:
@@ -675,7 +675,7 @@ NTSTATUS smb_raw_open_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, unio
parms->openxreadx.out.nread = SVAL(req->in.vwv, VWV(5));
if (parms->openxreadx.out.nread >
MAX(parms->openxreadx.in.mincnt, parms->openxreadx.in.maxcnt) ||
- !smbcli_raw_pull_data(req, req->in.hdr + SVAL(req->in.vwv, VWV(6)),
+ !smbcli_raw_pull_data(&req->in.bufinfo, req->in.hdr + SVAL(req->in.vwv, VWV(6)),
parms->openxreadx.out.nread,
parms->openxreadx.out.data)) {
req->status = NT_STATUS_BUFFER_TOO_SMALL;
diff --git a/source4/libcli/raw/rawioctl.c b/source4/libcli/raw/rawioctl.c
index 9205f84e86..957e554c6b 100644
--- a/source4/libcli/raw/rawioctl.c
+++ b/source4/libcli/raw/rawioctl.c
@@ -59,7 +59,7 @@ static NTSTATUS smb_raw_smbioctl_recv(struct smbcli_request *req,
return smbcli_request_destroy(req);
}
- parms->ioctl.out.blob = smbcli_req_pull_blob(req, mem_ctx, req->in.data, -1);
+ parms->ioctl.out.blob = smbcli_req_pull_blob(&req->in.bufinfo, mem_ctx, req->in.data, -1);
return smbcli_request_destroy(req);
}
diff --git a/source4/libcli/raw/rawnegotiate.c b/source4/libcli/raw/rawnegotiate.c
index fc7725cc55..ec2ada53ff 100644
--- a/source4/libcli/raw/rawnegotiate.c
+++ b/source4/libcli/raw/rawnegotiate.c
@@ -40,6 +40,10 @@ static const struct {
{PROTOCOL_LANMAN2,"Samba"},
{PROTOCOL_NT1,"NT LANMAN 1.0"},
{PROTOCOL_NT1,"NT LM 0.12"},
+#if 0
+ /* we don't yet handle chaining a SMB transport onto SMB2 */
+ {PROTOCOL_SMB2,"SMB 2.002"},
+#endif
};
/*
@@ -131,14 +135,14 @@ NTSTATUS smb_raw_negotiate_recv(struct smbcli_request *req)
if (req->in.data_size < 16) {
goto failed;
}
- transport->negotiate.server_guid = smbcli_req_pull_blob(req, transport, req->in.data, 16);
- transport->negotiate.secblob = smbcli_req_pull_blob(req, transport, req->in.data + 16, req->in.data_size - 16);
+ transport->negotiate.server_guid = smbcli_req_pull_blob(&req->in.bufinfo, transport, req->in.data, 16);
+ transport->negotiate.secblob = smbcli_req_pull_blob(&req->in.bufinfo, transport, req->in.data + 16, req->in.data_size - 16);
} else {
if (req->in.data_size < (transport->negotiate.key_len)) {
goto failed;
}
- transport->negotiate.secblob = smbcli_req_pull_blob(req, transport, req->in.data, transport->negotiate.key_len);
- smbcli_req_pull_string(req, transport, &transport->negotiate.server_domain,
+ transport->negotiate.secblob = smbcli_req_pull_blob(&req->in.bufinfo, transport, req->in.data, transport->negotiate.key_len);
+ smbcli_req_pull_string(&req->in.bufinfo, transport, &transport->negotiate.server_domain,
req->in.data+transport->negotiate.key_len,
req->in.data_size-transport->negotiate.key_len, STR_UNICODE|STR_NOALIGN);
/* here comes the server name */
@@ -164,7 +168,7 @@ NTSTATUS smb_raw_negotiate_recv(struct smbcli_request *req)
if ((SVAL(req->in.vwv,VWV(5)) & 0x2)) {
transport->negotiate.writebraw_supported = 1;
}
- transport->negotiate.secblob = smbcli_req_pull_blob(req, transport,
+ transport->negotiate.secblob = smbcli_req_pull_blob(&req->in.bufinfo, transport,
req->in.data, req->in.data_size);
} else {
/* the old core protocol */
diff --git a/source4/libcli/raw/rawreadwrite.c b/source4/libcli/raw/rawreadwrite.c
index b0c49ddab7..9e4edaf99c 100644
--- a/source4/libcli/raw/rawreadwrite.c
+++ b/source4/libcli/raw/rawreadwrite.c
@@ -137,7 +137,7 @@ NTSTATUS smb_raw_read_recv(struct smbcli_request *req, union smb_read *parms)
SMBCLI_CHECK_WCT(req, 5);
parms->lockread.out.nread = SVAL(req->in.vwv, VWV(0));
if (parms->lockread.out.nread > parms->lockread.in.count ||
- !smbcli_raw_pull_data(req, req->in.data+3,
+ !smbcli_raw_pull_data(&req->in.bufinfo, req->in.data+3,
parms->lockread.out.nread, parms->lockread.out.data)) {
req->status = NT_STATUS_BUFFER_TOO_SMALL;
}
@@ -148,7 +148,7 @@ NTSTATUS smb_raw_read_recv(struct smbcli_request *req, union smb_read *parms)
SMBCLI_CHECK_WCT(req, 5);
parms->read.out.nread = SVAL(req->in.vwv, VWV(0));
if (parms->read.out.nread > parms->read.in.count ||
- !smbcli_raw_pull_data(req, req->in.data+3,
+ !smbcli_raw_pull_data(&req->in.bufinfo, req->in.data+3,
parms->read.out.nread, parms->read.out.data)) {
req->status = NT_STATUS_BUFFER_TOO_SMALL;
}
@@ -171,11 +171,14 @@ NTSTATUS smb_raw_read_recv(struct smbcli_request *req, union smb_read *parms)
parms->readx.out.nread <=
req->in.buffer + req->in.size) {
req->in.data_size += (SVAL(req->in.vwv, VWV(7)) << 16);
+
+ /* update the bufinfo with the new size */
+ smb_setup_bufinfo(req);
}
}
if (parms->readx.out.nread > MAX(parms->readx.in.mincnt, parms->readx.in.maxcnt) ||
- !smbcli_raw_pull_data(req, req->in.hdr + SVAL(req->in.vwv, VWV(6)),
+ !smbcli_raw_pull_data(&req->in.bufinfo, req->in.hdr + SVAL(req->in.vwv, VWV(6)),
parms->readx.out.nread,
parms->readx.out.data)) {
req->status = NT_STATUS_BUFFER_TOO_SMALL;
diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c
index e7dffaf054..355d092583 100644
--- a/source4/libcli/raw/rawrequest.c
+++ b/source4/libcli/raw/rawrequest.c
@@ -34,6 +34,20 @@
/* assume that a character will not consume more than 3 bytes per char */
#define MAX_BYTES_PER_CHAR 3
+/* setup the bufinfo used for strings and range checking */
+void smb_setup_bufinfo(struct smbcli_request *req)
+{
+ req->in.bufinfo.mem_ctx = req;
+ req->in.bufinfo.flags = 0;
+ if (req->flags2 & FLAGS2_UNICODE_STRINGS) {
+ req->in.bufinfo.flags = BUFINFO_FLAG_UNICODE;
+ }
+ req->in.bufinfo.align_base = req->in.buffer;
+ req->in.bufinfo.data = req->in.data;
+ req->in.bufinfo.data_size = req->in.data_size;
+}
+
+
/* destroy a request structure and return final status */
NTSTATUS smbcli_request_destroy(struct smbcli_request *req)
{
@@ -298,6 +312,9 @@ NTSTATUS smbcli_chained_advance(struct smbcli_request *req)
req->in.data = req->in.vwv + 2 + req->in.wct * 2;
req->in.data_size = SVAL(req->in.vwv, VWV(req->in.wct));
+ /* fix the bufinfo */
+ smb_setup_bufinfo(req);
+
if (buffer + 3 + req->in.wct*2 + req->in.data_size >
req->in.buffer + req->in.size) {
return NT_STATUS_BUFFER_TOO_SMALL;
@@ -544,13 +561,13 @@ size_t smbcli_req_append_var_block(struct smbcli_request *req, const uint8_t *by
on failure zero is returned and *dest is set to NULL, otherwise the number
of bytes consumed in the packet is returned
*/
-static size_t smbcli_req_pull_ucs2(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
+static size_t smbcli_req_pull_ucs2(struct request_bufinfo *bufinfo, TALLOC_CTX *mem_ctx,
char **dest, const uint8_t *src, int byte_len, uint_t flags)
{
int src_len, src_len2, alignment=0;
ssize_t ret;
- if (!(flags & STR_NOALIGN) && ucs2_align(req->in.buffer, src, flags)) {
+ if (!(flags & STR_NOALIGN) && ucs2_align(bufinfo->align_base, src, flags)) {
src++;
alignment=1;
if (byte_len != -1) {
@@ -558,7 +575,7 @@ static size_t smbcli_req_pull_ucs2(struct smbcli_request *req, TALLOC_CTX *mem_c
}
}
- src_len = req->in.data_size - PTR_DIFF(src, req->in.data);
+ src_len = bufinfo->data_size - PTR_DIFF(src, bufinfo->data);
if (src_len < 0) {
*dest = NULL;
return 0;
@@ -597,13 +614,13 @@ static size_t smbcli_req_pull_ucs2(struct smbcli_request *req, TALLOC_CTX *mem_c
on failure zero is returned and *dest is set to NULL, otherwise the number
of bytes consumed in the packet is returned
*/
-size_t smbcli_req_pull_ascii(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
+size_t smbcli_req_pull_ascii(struct request_bufinfo *bufinfo, TALLOC_CTX *mem_ctx,
char **dest, const uint8_t *src, int byte_len, uint_t flags)
{
int src_len, src_len2;
ssize_t ret;
- src_len = req->in.data_size - PTR_DIFF(src, req->in.data);
+ src_len = bufinfo->data_size - PTR_DIFF(src, bufinfo->data);
if (src_len < 0) {
*dest = NULL;
return 0;
@@ -640,15 +657,15 @@ size_t smbcli_req_pull_ascii(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
on failure zero is returned and *dest is set to NULL, otherwise the number
of bytes consumed in the packet is returned
*/
-size_t smbcli_req_pull_string(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
+size_t smbcli_req_pull_string(struct request_bufinfo *bufinfo, TALLOC_CTX *mem_ctx,
char **dest, const uint8_t *src, int byte_len, uint_t flags)
{
if (!(flags & STR_ASCII) &&
- (((flags & STR_UNICODE) || (req->flags2 & FLAGS2_UNICODE_STRINGS)))) {
- return smbcli_req_pull_ucs2(req, mem_ctx, dest, src, byte_len, flags);
+ (((flags & STR_UNICODE) || (bufinfo->flags & BUFINFO_FLAG_UNICODE)))) {
+ return smbcli_req_pull_ucs2(bufinfo, mem_ctx, dest, src, byte_len, flags);
}
- return smbcli_req_pull_ascii(req, mem_ctx, dest, src, byte_len, flags);
+ return smbcli_req_pull_ascii(bufinfo, mem_ctx, dest, src, byte_len, flags);
}
@@ -658,11 +675,11 @@ size_t smbcli_req_pull_string(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
if byte_len is -1 then limit the blob only by packet size
*/
-DATA_BLOB smbcli_req_pull_blob(struct smbcli_request *req, TALLOC_CTX *mem_ctx, const uint8_t *src, int byte_len)
+DATA_BLOB smbcli_req_pull_blob(struct request_bufinfo *bufinfo, TALLOC_CTX *mem_ctx, const uint8_t *src, int byte_len)
{
int src_len;
- src_len = req->in.data_size - PTR_DIFF(src, req->in.data);
+ src_len = bufinfo->data_size - PTR_DIFF(src, bufinfo->data);
if (src_len < 0) {
return data_blob(NULL, 0);
@@ -677,13 +694,13 @@ DATA_BLOB smbcli_req_pull_blob(struct smbcli_request *req, TALLOC_CTX *mem_ctx,
/* check that a lump of data in a request is within the bounds of the data section of
the packet */
-static bool smbcli_req_data_oob(struct smbcli_request *req, const uint8_t *ptr, uint32_t count)
+static bool smbcli_req_data_oob(struct request_bufinfo *bufinfo, const uint8_t *ptr, uint32_t count)
{
/* be careful with wraparound! */
- if (ptr < req->in.data ||
- ptr >= req->in.data + req->in.data_size ||
- count > req->in.data_size ||
- ptr + count > req->in.data + req->in.data_size) {
+ if (ptr < bufinfo->data ||
+ ptr >= bufinfo->data + bufinfo->data_size ||
+ count > bufinfo->data_size ||
+ ptr + count > bufinfo->data + bufinfo->data_size) {
return true;
}
return false;
@@ -694,11 +711,11 @@ static bool smbcli_req_data_oob(struct smbcli_request *req, const uint8_t *ptr,
return false if any part is outside the data portion of the packet
*/
-bool smbcli_raw_pull_data(struct smbcli_request *req, const uint8_t *src, int len, uint8_t *dest)
+bool smbcli_raw_pull_data(struct request_bufinfo *bufinfo, const uint8_t *src, int len, uint8_t *dest)
{
if (len == 0) return true;
- if (smbcli_req_data_oob(req, src, len)) {
+ if (smbcli_req_data_oob(bufinfo, src, len)) {
return false;
}
@@ -972,3 +989,44 @@ size_t smbcli_blob_append_string(struct smbcli_session *session,
return len;
}
+
+/*
+ pull a GUID structure from the wire. The buffer must be at least 16
+ bytes long
+ */
+enum ndr_err_code smbcli_pull_guid(void *base, uint16_t offset,
+ struct GUID *guid)
+{
+ DATA_BLOB blob;
+ TALLOC_CTX *tmp_ctx = talloc_new(NULL);
+ enum ndr_err_code ndr_err;
+
+ ZERO_STRUCTP(guid);
+
+ blob.data = offset + (uint8_t *)base;
+ blob.length = 16;
+ ndr_err = ndr_pull_struct_blob(&blob, tmp_ctx, NULL, guid,
+ (ndr_pull_flags_fn_t)ndr_pull_GUID);
+ talloc_free(tmp_ctx);
+ return ndr_err;
+}
+
+/*
+ push a guid onto the wire. The buffer must hold 16 bytes
+ */
+enum ndr_err_code smbcli_push_guid(void *base, uint16_t offset,
+ const struct GUID *guid)
+{
+ TALLOC_CTX *tmp_ctx = talloc_new(NULL);
+ enum ndr_err_code ndr_err;
+ DATA_BLOB blob;
+ ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, NULL,
+ guid, (ndr_push_flags_fn_t)ndr_push_GUID);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err) || blob.length != 16) {
+ talloc_free(tmp_ctx);
+ return ndr_err;
+ }
+ memcpy(offset + (uint8_t *)base, blob.data, blob.length);
+ talloc_free(tmp_ctx);
+ return ndr_err;
+}
diff --git a/source4/libcli/raw/rawsearch.c b/source4/libcli/raw/rawsearch.c
index 33fa90d68d..fb2b09467c 100644
--- a/source4/libcli/raw/rawsearch.c
+++ b/source4/libcli/raw/rawsearch.c
@@ -54,7 +54,7 @@ static void smb_raw_search_backend(struct smbcli_request *req,
search_data.search.write_time = raw_pull_dos_date(req->transport,
p + 22);
search_data.search.size = IVAL(p, 26);
- smbcli_req_pull_ascii(req, mem_ctx, &name, p+30, 13, STR_ASCII);
+ smbcli_req_pull_ascii(&req->in.bufinfo, mem_ctx, &name, p+30, 13, STR_ASCII);
search_data.search.name = name;
if (!callback(private, &search_data)) {
break;
diff --git a/source4/libcli/raw/rawsetfileinfo.c b/source4/libcli/raw/rawsetfileinfo.c
index a9a1a3547e..f1e4ee3686 100644
--- a/source4/libcli/raw/rawsetfileinfo.c
+++ b/source4/libcli/raw/rawsetfileinfo.c
@@ -75,6 +75,16 @@ bool smb_raw_setfileinfo_passthru(TALLOC_CTX *mem_ctx,
SIVAL(blob->data, 8, len - 2);
return true;
+ case RAW_SFILEINFO_RENAME_INFORMATION_SMB2:
+ NEED_BLOB(20);
+ SIVAL(blob->data, 0, parms->rename_information.in.overwrite);
+ SBVAL(blob->data, 8, parms->rename_information.in.root_fid);
+ len = smbcli_blob_append_string(NULL, mem_ctx, blob,
+ parms->rename_information.in.new_name,
+ STR_UNICODE|STR_TERMINATE);
+ SIVAL(blob->data, 16, len - 2);
+ return true;
+
case RAW_SFILEINFO_POSITION_INFORMATION:
NEED_BLOB(8);
SBVAL(blob->data, 0, parms->position_information.in.position);
@@ -229,6 +239,7 @@ static bool smb_raw_setinfo_backend(struct smbcli_tree *tree,
case RAW_SFILEINFO_UNIX_LINK:
case RAW_SFILEINFO_UNIX_HLINK:
+ case RAW_SFILEINFO_RENAME_INFORMATION_SMB2:
break;
}
diff --git a/source4/libcli/raw/request.h b/source4/libcli/raw/request.h
index 803a450e3c..2a572e58ee 100644
--- a/source4/libcli/raw/request.h
+++ b/source4/libcli/raw/request.h
@@ -22,11 +22,25 @@
#include "libcli/raw/signing.h"
+#define BUFINFO_FLAG_UNICODE 0x0001
+#define BUFINFO_FLAG_SMB2 0x0002
+
+/*
+ buffer limit structure used by both SMB and SMB2
+ */
+struct request_bufinfo {
+ TALLOC_CTX *mem_ctx;
+ uint32_t flags;
+ const uint8_t *align_base;
+ const uint8_t *data;
+ size_t data_size;
+};
+
/*
Shared state structure between client and server, representing the basic packet.
*/
-struct request_buffer {
+struct smb_request_buffer {
/* the raw SMB buffer, including the 4 byte length header */
uint8_t *buffer;
@@ -56,6 +70,9 @@ struct request_buffer {
* a send packet is done we need to move this
* pointer */
uint8_t *ptr;
+
+ /* this is used to range check and align strings and buffers */
+ struct request_bufinfo bufinfo;
};
#endif
diff --git a/source4/libcli/raw/smb_signing.c b/source4/libcli/raw/smb_signing.c
index 0053710aaf..4acfb9d16d 100644
--- a/source4/libcli/raw/smb_signing.c
+++ b/source4/libcli/raw/smb_signing.c
@@ -65,7 +65,7 @@ static bool smbcli_set_smb_signing_common(struct smbcli_transport *transport)
return true;
}
-void mark_packet_signed(struct request_buffer *out)
+void mark_packet_signed(struct smb_request_buffer *out)
{
uint16_t flags2;
flags2 = SVAL(out->hdr, HDR_FLG2);
@@ -101,7 +101,7 @@ bool signing_good(struct smb_signing_context *sign_info,
return true;
}
-void sign_outgoing_message(struct request_buffer *out, DATA_BLOB *mac_key, unsigned int seq_num)
+void sign_outgoing_message(struct smb_request_buffer *out, DATA_BLOB *mac_key, unsigned int seq_num)
{
uint8_t calc_md5_mac[16];
struct MD5Context md5_ctx;
@@ -133,7 +133,7 @@ void sign_outgoing_message(struct request_buffer *out, DATA_BLOB *mac_key, unsig
Uncomment this to test if the remote server actually verifies signitures...*/
}
-bool check_signed_incoming_message(struct request_buffer *in, DATA_BLOB *mac_key, uint_t seq_num)
+bool check_signed_incoming_message(struct smb_request_buffer *in, DATA_BLOB *mac_key, uint_t seq_num)
{
bool good;
uint8_t calc_md5_mac[16];
diff --git a/source4/libcli/smb2/cancel.c b/source4/libcli/smb2/cancel.c
index 096919f177..80127feea5 100644
--- a/source4/libcli/smb2/cancel.c
+++ b/source4/libcli/smb2/cancel.c
@@ -52,11 +52,11 @@ NTSTATUS smb2_cancel(struct smb2_request *r)
c->seqnum = 0;
SIVAL(c->out.hdr, SMB2_HDR_FLAGS, 0x00000002);
- SSVAL(c->out.hdr, SMB2_HDR_UNKNOWN1, 0x0030);
+ SSVAL(c->out.hdr, SMB2_HDR_CREDIT, 0x0030);
SIVAL(c->out.hdr, SMB2_HDR_PID, r->cancel.pending_id);
- SBVAL(c->out.hdr, SMB2_HDR_SEQNUM, c->seqnum);
+ SBVAL(c->out.hdr, SMB2_HDR_MESSAGE_ID, c->seqnum);
if (r->session) {
- SBVAL(c->out.hdr, SMB2_HDR_UID, r->session->uid);
+ SBVAL(c->out.hdr, SMB2_HDR_SESSION_ID, r->session->uid);
}
SSVAL(c->out.body, 0x02, 0);
diff --git a/source4/libcli/smb2/connect.c b/source4/libcli/smb2/connect.c
index 4518203183..85ddafc031 100644
--- a/source4/libcli/smb2/connect.c
+++ b/source4/libcli/smb2/connect.c
@@ -73,7 +73,7 @@ static void continue_session(struct composite_context *creq)
state->tree = smb2_tree_init(state->session, state, true);
if (composite_nomem(state->tree, c)) return;
- state->tcon.in.unknown1 = 0x09;
+ state->tcon.in.reserved = 0;
state->tcon.in.path = talloc_asprintf(state, "\\\\%s\\%s",
state->host, state->share);
if (composite_nomem(state->tcon.in.path, c)) return;
@@ -120,6 +120,7 @@ static void continue_socket(struct composite_context *creq)
struct smbcli_socket *sock;
struct smb2_transport *transport;
struct smb2_request *req;
+ uint16_t dialects[1];
c->status = smbcli_sock_connect_recv(creq, state, &sock);
if (!composite_is_ok(c)) return;
@@ -128,7 +129,12 @@ static void continue_socket(struct composite_context *creq)
if (composite_nomem(transport, c)) return;
ZERO_STRUCT(state->negprot);
- state->negprot.in.unknown1 = 0x0001;
+ state->negprot.in.dialect_count = 1;
+ state->negprot.in.security_mode = 0;
+ state->negprot.in.capabilities = 0;
+ unix_to_nt_time(&state->negprot.in.start_time, time(NULL));
+ dialects[0] = SMB2_DIALECT_REVISION;
+ state->negprot.in.dialects = dialects;
req = smb2_negprot_send(transport, &state->negprot);
if (composite_nomem(req, c)) return;
diff --git a/source4/libcli/smb2/create.c b/source4/libcli/smb2/create.c
index ba11c22e87..cca83a040c 100644
--- a/source4/libcli/smb2/create.c
+++ b/source4/libcli/smb2/create.c
@@ -24,34 +24,33 @@
#include "libcli/smb2/smb2.h"
#include "libcli/smb2/smb2_calls.h"
-#define CREATE_TAG_EXTA 0x41747845 /* "ExtA" */
-#define CREATE_TAG_MXAC 0x6341784D /* "MxAc" */
-
/*
add a blob to a smb2_create attribute blob
*/
NTSTATUS smb2_create_blob_add(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
- uint32_t tag,
+ const char *tag,
DATA_BLOB add, bool last)
{
uint32_t ofs = blob->length;
- uint8_t pad = smb2_padding_size(add.length, 8);
- if (!data_blob_realloc(mem_ctx, blob, blob->length + 0x18 + add.length + pad))
+ size_t tag_length = strlen(tag);
+ uint8_t pad = smb2_padding_size(add.length+tag_length, 8);
+ if (!data_blob_realloc(mem_ctx, blob,
+ blob->length + 0x14 + tag_length + add.length + pad))
return NT_STATUS_NO_MEMORY;
if (last) {
SIVAL(blob->data, ofs+0x00, 0);
} else {
- SIVAL(blob->data, ofs+0x00, 0x18 + add.length + pad);
+ SIVAL(blob->data, ofs+0x00, 0x14 + tag_length + add.length + pad);
}
SSVAL(blob->data, ofs+0x04, 0x10); /* offset of tag */
- SIVAL(blob->data, ofs+0x06, 0x04); /* tag length */
- SSVAL(blob->data, ofs+0x0A, 0x18); /* offset of data */
+ SIVAL(blob->data, ofs+0x06, tag_length); /* tag length */
+ SSVAL(blob->data, ofs+0x0A, 0x14 + tag_length); /* offset of data */
SIVAL(blob->data, ofs+0x0C, add.length);
- SIVAL(blob->data, ofs+0x10, tag);
- SIVAL(blob->data, ofs+0x14, 0); /* pad? */
- memcpy(blob->data+ofs+0x18, add.data, add.length);
- memset(blob->data+ofs+0x18+add.length, 0, pad);
+ memcpy(blob->data+ofs+0x10, tag, tag_length);
+ SIVAL(blob->data, ofs+0x10+tag_length, 0); /* pad? */
+ memcpy(blob->data+ofs+0x14+tag_length, add.data, add.length);
+ memset(blob->data+ofs+0x14+tag_length+add.length, 0, pad);
return NT_STATUS_OK;
}
@@ -68,16 +67,15 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
req = smb2_request_init_tree(tree, SMB2_OP_CREATE, 0x38, true, 0);
if (req == NULL) return NULL;
- SSVAL(req->out.body, 0x02, io->in.oplock_flags);
- SIVAL(req->out.body, 0x04, io->in.impersonation);
- SIVAL(req->out.body, 0x08, io->in.unknown3[0]);
- SIVAL(req->out.body, 0x0C, io->in.unknown3[1]);
- SIVAL(req->out.body, 0x10, io->in.unknown3[2]);
- SIVAL(req->out.body, 0x14, io->in.unknown3[3]);
- SIVAL(req->out.body, 0x18, io->in.access_mask);
- SIVAL(req->out.body, 0x1C, io->in.file_attr);
+ SCVAL(req->out.body, 0x02, io->in.security_flags);
+ SCVAL(req->out.body, 0x03, io->in.oplock_level);
+ SIVAL(req->out.body, 0x04, io->in.impersonation_level);
+ SBVAL(req->out.body, 0x08, io->in.create_flags);
+ SBVAL(req->out.body, 0x10, io->in.reserved);
+ SIVAL(req->out.body, 0x18, io->in.desired_access);
+ SIVAL(req->out.body, 0x1C, io->in.file_attributes);
SIVAL(req->out.body, 0x20, io->in.share_access);
- SIVAL(req->out.body, 0x24, io->in.open_disposition);
+ SIVAL(req->out.body, 0x24, io->in.create_disposition);
SIVAL(req->out.body, 0x28, io->in.create_options);
status = smb2_push_o16s16_string(&req->out, 0x2C, io->in.fname);
@@ -90,7 +88,7 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
DATA_BLOB b = data_blob_talloc(req, NULL,
ea_list_size_chained(io->in.eas.num_eas, io->in.eas.eas));
ea_put_list_chained(b.data, io->in.eas.num_eas, io->in.eas.eas);
- status = smb2_create_blob_add(req, &blob, CREATE_TAG_EXTA, b, false);
+ status = smb2_create_blob_add(req, &blob, SMB2_CREATE_TAG_EXTA, b, false);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(req);
return NULL;
@@ -100,7 +98,8 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
/* an empty MxAc tag seems to be used to ask the server to
return the maximum access mask allowed on the file */
- status = smb2_create_blob_add(req, &blob, CREATE_TAG_MXAC, data_blob(NULL, 0), true);
+ status = smb2_create_blob_add(req, &blob, SMB2_CREATE_TAG_MXAC,
+ data_blob(NULL, 0), true);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(req);
@@ -132,7 +131,8 @@ NTSTATUS smb2_create_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, struct
SMB2_CHECK_PACKET_RECV(req, 0x58, true);
- io->out.oplock_flags = SVAL(req->in.body, 0x02);
+ io->out.oplock_level = CVAL(req->in.body, 0x02);
+ io->out.reserved = CVAL(req->in.body, 0x03);
io->out.create_action = IVAL(req->in.body, 0x04);
io->out.create_time = smbcli_pull_nttime(req->in.body, 0x08);
io->out.access_time = smbcli_pull_nttime(req->in.body, 0x10);
@@ -141,7 +141,7 @@ NTSTATUS smb2_create_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx, struct
io->out.alloc_size = BVAL(req->in.body, 0x28);
io->out.size = BVAL(req->in.body, 0x30);
io->out.file_attr = IVAL(req->in.body, 0x38);
- io->out._pad = IVAL(req->in.body, 0x3C);
+ io->out.reserved2 = IVAL(req->in.body, 0x3C);
smb2_pull_handle(req->in.body+0x40, &io->out.file.handle);
status = smb2_pull_o32s32_blob(&req->in, mem_ctx, req->in.body+0x50, &io->out.blob);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c
index 0665dd441c..e9f47140f5 100644
--- a/source4/libcli/smb2/getinfo.c
+++ b/source4/libcli/smb2/getinfo.c
@@ -30,21 +30,27 @@
struct smb2_request *smb2_getinfo_send(struct smb2_tree *tree, struct smb2_getinfo *io)
{
struct smb2_request *req;
+ NTSTATUS status;
- req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, false, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, true,
+ io->in.blob.length);
if (req == NULL) return NULL;
- /* this seems to be a bug, they use 0x29 but only send 0x28 bytes */
- SSVAL(req->out.body, 0x00, 0x29);
-
- SSVAL(req->out.body, 0x02, io->in.level);
- SIVAL(req->out.body, 0x04, io->in.max_response_size);
- SIVAL(req->out.body, 0x08, io->in.unknown1);
- SIVAL(req->out.body, 0x0C, io->in.unknown2);
- SIVAL(req->out.body, 0x10, io->in.flags);
- SIVAL(req->out.body, 0x14, io->in.flags2);
+ SCVAL(req->out.body, 0x02, io->in.info_type);
+ SCVAL(req->out.body, 0x03, io->in.info_class);
+ SIVAL(req->out.body, 0x04, io->in.output_buffer_length);
+ SIVAL(req->out.body, 0x0C, io->in.reserved);
+ SIVAL(req->out.body, 0x08, io->in.input_buffer_length);
+ SIVAL(req->out.body, 0x10, io->in.additional_information);
+ SIVAL(req->out.body, 0x14, io->in.getinfo_flags);
smb2_push_handle(req->out.body+0x18, &io->in.file.handle);
+ /* this blob is used for quota queries */
+ status = smb2_push_o32s32_blob(&req->out, 0x08, io->in.blob);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(req);
+ return NULL;
+ }
smb2_transport_send(req);
return req;
@@ -116,15 +122,17 @@ struct smb2_request *smb2_getinfo_file_send(struct smb2_tree *tree, union smb_fi
}
ZERO_STRUCT(b);
- b.in.max_response_size = 0x10000;
- b.in.file.handle = io->generic.in.file.handle;
- b.in.level = smb2_level;
+ b.in.info_type = smb2_level & 0xFF;
+ b.in.info_class = smb2_level >> 8;
+ b.in.output_buffer_length = 0x10000;
+ b.in.input_buffer_length = 0;
+ b.in.file.handle = io->generic.in.file.handle;
if (io->generic.level == RAW_FILEINFO_SEC_DESC) {
- b.in.flags = io->query_secdesc.in.secinfo_flags;
+ b.in.additional_information = io->query_secdesc.in.secinfo_flags;
}
if (io->generic.level == RAW_FILEINFO_SMB2_ALL_EAS) {
- b.in.flags2 = io->all_eas.in.continue_flags;
+ b.in.getinfo_flags = io->all_eas.in.continue_flags;
}
return smb2_getinfo_send(tree, &b);
@@ -172,9 +180,10 @@ struct smb2_request *smb2_getinfo_fs_send(struct smb2_tree *tree, union smb_fsin
}
ZERO_STRUCT(b);
- b.in.max_response_size = 0x10000;
- b.in.file.handle = io->generic.handle;
- b.in.level = smb2_level;
+ b.in.output_buffer_length = 0x10000;
+ b.in.file.handle = io->generic.handle;
+ b.in.info_type = smb2_level & 0xFF;
+ b.in.info_class = smb2_level >> 8;
return smb2_getinfo_send(tree, &b);
}
diff --git a/source4/libcli/smb2/logoff.c b/source4/libcli/smb2/logoff.c
index 321a4db1a6..b38a08ca43 100644
--- a/source4/libcli/smb2/logoff.c
+++ b/source4/libcli/smb2/logoff.c
@@ -33,7 +33,7 @@ struct smb2_request *smb2_logoff_send(struct smb2_session *session)
req = smb2_request_init(session->transport, SMB2_OP_LOGOFF, 0x04, false, 0);
if (req == NULL) return NULL;
- SBVAL(req->out.hdr, SMB2_HDR_UID, session->uid);
+ SBVAL(req->out.hdr, SMB2_HDR_SESSION_ID, session->uid);
SSVAL(req->out.body, 0x02, 0);
diff --git a/source4/libcli/smb2/negprot.c b/source4/libcli/smb2/negprot.c
index 38fe0e7e53..6b879e2add 100644
--- a/source4/libcli/smb2/negprot.c
+++ b/source4/libcli/smb2/negprot.c
@@ -31,16 +31,28 @@ struct smb2_request *smb2_negprot_send(struct smb2_transport *transport,
struct smb2_negprot *io)
{
struct smb2_request *req;
-
- req = smb2_request_init(transport, SMB2_OP_NEGPROT, 0x26, false, 0);
+ uint16_t size = 0x24 + io->in.dialect_count*2;
+ enum ndr_err_code ndr_err;
+ int i;
+
+ req = smb2_request_init(transport, SMB2_OP_NEGPROT, size, false, 0);
if (req == NULL) return NULL;
- /* this seems to be a bug, they use 0x24 but the length is 0x26 */
- SSVAL(req->out.body, 0x00, 0x24);
- SSVAL(req->out.body, 0x02, io->in.unknown1);
- memcpy(req->out.body+0x04, io->in.unknown2, 32);
- SSVAL(req->out.body, 0x24, io->in.unknown3);
+ SSVAL(req->out.body, 0x00, 0x24);
+ SSVAL(req->out.body, 0x02, io->in.dialect_count);
+ SSVAL(req->out.body, 0x04, io->in.security_mode);
+ SSVAL(req->out.body, 0x06, io->in.reserved);
+ SIVAL(req->out.body, 0x08, io->in.capabilities);
+ ndr_err = smbcli_push_guid(req->out.body, 0x0C, &io->in.client_guid);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ talloc_free(req);
+ return NULL;
+ }
+ smbcli_push_nttime(req->out.body, 0x1C, io->in.start_time);
+ for (i=0;i<io->in.dialect_count;i++) {
+ SSVAL(req->out.body, 0x24 + i*2, io->in.dialects[i]);
+ }
smb2_transport_send(req);
@@ -54,6 +66,7 @@ NTSTATUS smb2_negprot_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx,
struct smb2_negprot *io)
{
NTSTATUS status;
+ enum ndr_err_code ndr_err;
if (!smb2_request_receive(req) ||
smb2_request_is_error(req)) {
@@ -62,24 +75,27 @@ NTSTATUS smb2_negprot_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx,
SMB2_CHECK_PACKET_RECV(req, 0x40, true);
- io->out._pad = SVAL(req->in.body, 0x02);
- io->out.unknown2 = IVAL(req->in.body, 0x04);
- memcpy(io->out.sessid, req->in.body + 0x08, 16);
- io->out.unknown3 = IVAL(req->in.body, 0x18);
- io->out.unknown4 = SVAL(req->in.body, 0x1C);
- io->out.unknown5 = IVAL(req->in.body, 0x1E);
- io->out.unknown6 = IVAL(req->in.body, 0x22);
- io->out.unknown7 = SVAL(req->in.body, 0x26);
- io->out.current_time = smbcli_pull_nttime(req->in.body, 0x28);
- io->out.boot_time = smbcli_pull_nttime(req->in.body, 0x30);
+ io->out.security_mode = SVAL(req->in.body, 0x02);
+ io->out.dialect_revision = SVAL(req->in.body, 0x04);
+ io->out.reserved = SVAL(req->in.body, 0x06);
+ ndr_err = smbcli_pull_guid(req->in.body, 0x08, &io->in.client_guid);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ smb2_request_destroy(req);
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+ io->out.capabilities = IVAL(req->in.body, 0x18);
+ io->out.max_transact_size = IVAL(req->in.body, 0x1C);
+ io->out.max_read_size = IVAL(req->in.body, 0x20);
+ io->out.max_write_size = IVAL(req->in.body, 0x24);
+ io->out.system_time = smbcli_pull_nttime(req->in.body, 0x28);
+ io->out.server_start_time = smbcli_pull_nttime(req->in.body, 0x30);
+ io->out.reserved2 = IVAL(req->in.body, 0x3C);
status = smb2_pull_o16s16_blob(&req->in, mem_ctx, req->in.body+0x38, &io->out.secblob);
if (!NT_STATUS_IS_OK(status)) {
smb2_request_destroy(req);
return status;
}
-
- io->out.unknown9 = IVAL(req->in.body, 0x3C);
return smb2_request_destroy(req);
}
diff --git a/source4/libcli/smb2/notify.c b/source4/libcli/smb2/notify.c
index a3bea41eb0..e7c38a27f9 100644
--- a/source4/libcli/smb2/notify.c
+++ b/source4/libcli/smb2/notify.c
@@ -35,7 +35,7 @@ struct smb2_request *smb2_notify_send(struct smb2_tree *tree, struct smb2_notify
req = smb2_request_init_tree(tree, SMB2_OP_NOTIFY, 0x20, false, 0);
if (req == NULL) return NULL;
- SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, 0x0030);
+ SSVAL(req->out.hdr, SMB2_HDR_CREDIT, 0x0030);
SSVAL(req->out.body, 0x02, io->in.recursive);
SIVAL(req->out.body, 0x04, io->in.buffer_size);
diff --git a/source4/libcli/smb2/request.c b/source4/libcli/smb2/request.c
index 73c74dcfeb..2471fcaa4d 100644
--- a/source4/libcli/smb2/request.c
+++ b/source4/libcli/smb2/request.c
@@ -28,6 +28,21 @@
#include "libcli/smb2/smb2_calls.h"
#include "param/param.h"
+/* fill in the bufinfo */
+void smb2_setup_bufinfo(struct smb2_request *req)
+{
+ req->in.bufinfo.mem_ctx = req;
+ req->in.bufinfo.flags = BUFINFO_FLAG_UNICODE | BUFINFO_FLAG_SMB2;
+ req->in.bufinfo.align_base = req->in.buffer;
+ if (req->in.dynamic) {
+ req->in.bufinfo.data = req->in.dynamic;
+ req->in.bufinfo.data_size = req->in.body_size - req->in.body_fixed;
+ } else {
+ req->in.bufinfo.data = NULL;
+ req->in.bufinfo.data_size = 0;
+ }
+}
+
/*
initialise a smb2 request
*/
@@ -83,17 +98,17 @@ struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_
SIVAL(req->out.hdr, 0, SMB2_MAGIC);
SSVAL(req->out.hdr, SMB2_HDR_LENGTH, SMB2_HDR_BODY);
- SSVAL(req->out.hdr, SMB2_HDR_PAD1, 0);
+ SSVAL(req->out.hdr, SMB2_HDR_EPOCH, 0);
SIVAL(req->out.hdr, SMB2_HDR_STATUS, 0);
SSVAL(req->out.hdr, SMB2_HDR_OPCODE, opcode);
- SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, 0);
+ SSVAL(req->out.hdr, SMB2_HDR_CREDIT, 0);
SIVAL(req->out.hdr, SMB2_HDR_FLAGS, 0);
- SIVAL(req->out.hdr, SMB2_HDR_CHAIN_OFFSET, 0);
- SBVAL(req->out.hdr, SMB2_HDR_SEQNUM, req->seqnum);
+ SIVAL(req->out.hdr, SMB2_HDR_NEXT_COMMAND, 0);
+ SBVAL(req->out.hdr, SMB2_HDR_MESSAGE_ID, req->seqnum);
SIVAL(req->out.hdr, SMB2_HDR_PID, 0);
SIVAL(req->out.hdr, SMB2_HDR_TID, 0);
- SBVAL(req->out.hdr, SMB2_HDR_UID, 0);
- memset(req->out.hdr+SMB2_HDR_SIG, 0, 16);
+ SBVAL(req->out.hdr, SMB2_HDR_SESSION_ID, 0);
+ memset(req->out.hdr+SMB2_HDR_SIGNATURE, 0, 16);
/* set the length of the fixed body part and +1 if there's a dynamic part also */
SSVAL(req->out.body, 0, body_fixed_size + (body_dynamic_size?1:0));
@@ -122,7 +137,7 @@ struct smb2_request *smb2_request_init_tree(struct smb2_tree *tree, uint16_t opc
body_dynamic_size);
if (req == NULL) return NULL;
- SBVAL(req->out.hdr, SMB2_HDR_UID, tree->session->uid);
+ SBVAL(req->out.hdr, SMB2_HDR_SESSION_ID, tree->session->uid);
SIVAL(req->out.hdr, SMB2_HDR_TID, tree->tid);
req->session = tree->session;
req->tree = tree;
@@ -191,6 +206,10 @@ bool smb2_request_is_ok(struct smb2_request *req)
*/
bool smb2_oob(struct smb2_request_buffer *buf, const uint8_t *ptr, size_t size)
{
+ if (size == 0) {
+ /* zero bytes is never out of range */
+ return false;
+ }
/* be careful with wraparound! */
if (ptr < buf->body ||
ptr >= buf->body + buf->body_size ||
@@ -255,7 +274,7 @@ NTSTATUS smb2_pull_o16s16_blob(struct smb2_request_buffer *buf, TALLOC_CTX *mem_
}
ofs = SVAL(ptr, 0);
size = SVAL(ptr, 2);
- if (ofs == 0 || size == 0) {
+ if (ofs == 0) {
*blob = data_blob(NULL, 0);
return NT_STATUS_OK;
}
@@ -295,7 +314,10 @@ NTSTATUS smb2_push_o16s16_blob(struct smb2_request_buffer *buf,
return NT_STATUS_BUFFER_TOO_SMALL;
}
- if (blob.length == 0) {
+ if (blob.data == NULL) {
+ if (blob.length != 0) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
SSVAL(ptr, 0, 0);
SSVAL(ptr, 2, 0);
return NT_STATUS_OK;
@@ -348,7 +370,10 @@ NTSTATUS smb2_push_o16s32_blob(struct smb2_request_buffer *buf,
return NT_STATUS_BUFFER_TOO_SMALL;
}
- if (blob.length == 0) {
+ if (blob.data == NULL) {
+ if (blob.length != 0) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
SSVAL(ptr, 0, 0);
SIVAL(ptr, 2, 0);
return NT_STATUS_OK;
@@ -401,7 +426,10 @@ NTSTATUS smb2_push_o32s32_blob(struct smb2_request_buffer *buf,
return NT_STATUS_BUFFER_TOO_SMALL;
}
- if (blob.length == 0) {
+ if (blob.data == NULL) {
+ if (blob.length != 0) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
SIVAL(ptr, 0, 0);
SIVAL(ptr, 4, 0);
return NT_STATUS_OK;
@@ -454,7 +482,10 @@ NTSTATUS smb2_push_s32o32_blob(struct smb2_request_buffer *buf,
return NT_STATUS_BUFFER_TOO_SMALL;
}
- if (blob.length == 0) {
+ if (blob.data == NULL) {
+ if (blob.length != 0) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
SIVAL(ptr, 0, 0);
SIVAL(ptr, 4, 0);
return NT_STATUS_OK;
@@ -497,7 +528,7 @@ NTSTATUS smb2_pull_o16s32_blob(struct smb2_request_buffer *buf, TALLOC_CTX *mem_
}
ofs = SVAL(ptr, 0);
size = IVAL(ptr, 2);
- if (ofs == 0 || size == 0) {
+ if (ofs == 0) {
*blob = data_blob(NULL, 0);
return NT_STATUS_OK;
}
@@ -521,7 +552,34 @@ NTSTATUS smb2_pull_o32s32_blob(struct smb2_request_buffer *buf, TALLOC_CTX *mem_
}
ofs = IVAL(ptr, 0);
size = IVAL(ptr, 4);
- if (ofs == 0 || size == 0) {
+ if (ofs == 0) {
+ *blob = data_blob(NULL, 0);
+ return NT_STATUS_OK;
+ }
+ if (smb2_oob(buf, buf->hdr + ofs, size)) {
+ return NT_STATUS_BUFFER_TOO_SMALL;
+ }
+ *blob = data_blob_talloc(mem_ctx, buf->hdr + ofs, size);
+ NT_STATUS_HAVE_NO_MEMORY(blob->data);
+ return NT_STATUS_OK;
+}
+
+/*
+ pull a uint16_t ofs/ uint32_t length/blob triple from a data blob
+ the ptr points to the start of the offset/length pair
+
+ In this varient the uint16_t is padded by an extra 2 bytes, making
+ the size aligned on 4 byte boundary
+*/
+NTSTATUS smb2_pull_o16As32_blob(struct smb2_request_buffer *buf, TALLOC_CTX *mem_ctx, uint8_t *ptr, DATA_BLOB *blob)
+{
+ uint32_t ofs, size;
+ if (smb2_oob(buf, ptr, 8)) {
+ return NT_STATUS_BUFFER_TOO_SMALL;
+ }
+ ofs = SVAL(ptr, 0);
+ size = IVAL(ptr, 4);
+ if (ofs == 0) {
*blob = data_blob(NULL, 0);
return NT_STATUS_OK;
}
@@ -545,7 +603,7 @@ NTSTATUS smb2_pull_s32o32_blob(struct smb2_request_buffer *buf, TALLOC_CTX *mem_
}
size = IVAL(ptr, 0);
ofs = IVAL(ptr, 4);
- if (ofs == 0 || size == 0) {
+ if (ofs == 0) {
*blob = data_blob(NULL, 0);
return NT_STATUS_OK;
}
@@ -572,6 +630,11 @@ NTSTATUS smb2_pull_o16s16_string(struct smb2_request_buffer *buf, TALLOC_CTX *me
status = smb2_pull_o16s16_blob(buf, mem_ctx, ptr, &blob);
NT_STATUS_NOT_OK_RETURN(status);
+ if (blob.data == NULL) {
+ *str = NULL;
+ return NT_STATUS_OK;
+ }
+
if (blob.length == 0) {
char *s;
s = talloc_strdup(mem_ctx, "");
@@ -601,10 +664,16 @@ NTSTATUS smb2_push_o16s16_string(struct smb2_request_buffer *buf,
NTSTATUS status;
ssize_t size;
- if (strcmp("", str) == 0) {
+ if (str == NULL) {
return smb2_push_o16s16_blob(buf, ofs, data_blob(NULL, 0));
}
+ if (*str == 0) {
+ blob.data = str;
+ blob.length = 0;
+ return smb2_push_o16s16_blob(buf, ofs, blob);
+ }
+
size = convert_string_talloc(buf->buffer, lp_iconv_convenience(global_loadparm), CH_UNIX, CH_UTF16,
str, strlen(str), (void **)&blob.data);
if (size == -1) {
diff --git a/source4/libcli/smb2/session.c b/source4/libcli/smb2/session.c
index a784ea65d8..18fe3486a4 100644
--- a/source4/libcli/smb2/session.c
+++ b/source4/libcli/smb2/session.c
@@ -74,10 +74,12 @@ struct smb2_request *smb2_session_setup_send(struct smb2_session *session,
0x18, true, io->in.secblob.length);
if (req == NULL) return NULL;
- SBVAL(req->out.hdr, SMB2_HDR_UID, session->uid);
- SSVAL(req->out.body, 0x02, io->in._pad); /* pad */
- SIVAL(req->out.body, 0x04, io->in.unknown2);
- SIVAL(req->out.body, 0x08, io->in.unknown3);
+ SBVAL(req->out.hdr, SMB2_HDR_SESSION_ID, session->uid);
+ SCVAL(req->out.body, 0x02, io->in.vc_number);
+ SCVAL(req->out.body, 0x03, io->in.security_mode);
+ SIVAL(req->out.body, 0x04, io->in.capabilities);
+ SIVAL(req->out.body, 0x08, io->in.channel);
+ SBVAL(req->out.body, 0x10, io->in.previous_sessionid);
req->session = session;
@@ -86,7 +88,6 @@ struct smb2_request *smb2_session_setup_send(struct smb2_session *session,
talloc_free(req);
return NULL;
}
- SBVAL(req->out.body, 0x10, io->in.unknown4);
smb2_transport_send(req);
@@ -110,8 +111,8 @@ NTSTATUS smb2_session_setup_recv(struct smb2_request *req, TALLOC_CTX *mem_ctx,
SMB2_CHECK_PACKET_RECV(req, 0x08, true);
- io->out._pad = SVAL(req->in.body, 0x02);
- io->out.uid = BVAL(req->in.hdr, SMB2_HDR_UID);
+ io->out.session_flags = SVAL(req->in.body, 0x02);
+ io->out.uid = BVAL(req->in.hdr, SMB2_HDR_SESSION_ID);
status = smb2_pull_o16s16_blob(&req->in, mem_ctx, req->in.body+0x04, &io->out.secblob);
if (!NT_STATUS_IS_OK(status)) {
@@ -206,10 +207,11 @@ struct composite_context *smb2_session_setup_spnego_send(struct smb2_session *se
c->private_data = state;
ZERO_STRUCT(state->io);
- state->io.in._pad = 0x0000;
- state->io.in.unknown2 = 0x0000000F;
- state->io.in.unknown3 = 0x00000000;
- state->io.in.unknown4 = 0; /* uint64_t */
+ state->io.in.vc_number = 0;
+ state->io.in.security_mode = 0;
+ state->io.in.capabilities = 0;
+ state->io.in.channel = 0;
+ state->io.in.previous_sessionid = 0;
c->status = gensec_set_credentials(session->gensec, credentials);
if (!composite_is_ok(c)) return c;
diff --git a/source4/libcli/smb2/setinfo.c b/source4/libcli/smb2/setinfo.c
index d942568a2d..a6e22d9a68 100644
--- a/source4/libcli/smb2/setinfo.c
+++ b/source4/libcli/smb2/setinfo.c
@@ -92,6 +92,12 @@ struct smb2_request *smb2_setinfo_file_send(struct smb2_tree *tree, union smb_se
ZERO_STRUCT(b);
b.in.level = smb2_level;
b.in.file.handle = io->generic.in.file.handle;
+
+ /* change levels so the parsers know it is SMB2 */
+ if (io->generic.level == RAW_SFILEINFO_RENAME_INFORMATION) {
+ io->generic.level = RAW_SFILEINFO_RENAME_INFORMATION_SMB2;
+ }
+
if (!smb_raw_setfileinfo_passthru(tree, io->generic.level, io, &b.in.blob)) {
return NULL;
}
diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h
index 33876c6f7c..726df64090 100644
--- a/source4/libcli/smb2/smb2.h
+++ b/source4/libcli/smb2/smb2.h
@@ -19,6 +19,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "libcli/raw/request.h"
+
struct smb2_options {
uint32_t timeout;
};
@@ -102,6 +104,9 @@ struct smb2_request_buffer {
* this will be moved when some dynamic data is pushed
*/
uint8_t *dynamic;
+
+ /* this is used to range check and align strings and buffers */
+ struct request_bufinfo bufinfo;
};
@@ -156,19 +161,20 @@ struct smb2_request {
#define SMB2_MIN_SIZE 0x42
-/* offsets into header elements */
+/* offsets into header elements for a sync SMB2 request */
+#define SMB2_HDR_PROTOCOL_ID 0x00
#define SMB2_HDR_LENGTH 0x04
-#define SMB2_HDR_PAD1 0x06
+#define SMB2_HDR_EPOCH 0x06
#define SMB2_HDR_STATUS 0x08
#define SMB2_HDR_OPCODE 0x0c
-#define SMB2_HDR_UNKNOWN1 0x0e
+#define SMB2_HDR_CREDIT 0x0e
#define SMB2_HDR_FLAGS 0x10
-#define SMB2_HDR_CHAIN_OFFSET 0x14
-#define SMB2_HDR_SEQNUM 0x18
+#define SMB2_HDR_NEXT_COMMAND 0x14
+#define SMB2_HDR_MESSAGE_ID 0x18
#define SMB2_HDR_PID 0x20
#define SMB2_HDR_TID 0x24
-#define SMB2_HDR_UID 0x28 /* 64 bit */
-#define SMB2_HDR_SIG 0x30 /* guess ... */
+#define SMB2_HDR_SESSION_ID 0x28
+#define SMB2_HDR_SIGNATURE 0x30 /* 16 bytes */
#define SMB2_HDR_BODY 0x40
/* SMB2 opcodes */
@@ -194,6 +200,59 @@ struct smb2_request {
#define SMB2_MAGIC 0x424D53FE /* 0xFE 'S' 'M' 'B' */
+/* the dialect we support */
+#define SMB2_DIALECT_REVISION 0x202
+
+/* SMB2 negotiate security_mode */
+#define SMB2_NEGOTIATE_SIGNING_ENABLED 0x01
+#define SMB2_NEGOTIATE_SIGNING_REQUIRED 0x02
+
+/* SMB2 capabilities - only 1 so far. I'm sure more will be added */
+#define SMB2_CAP_DFS 0x0
+/* so we can spot new caps as added */
+#define SMB2_CAP_ALL SMB2_CAP_DFS
+
+/* SMB2 share flags */
+#define SMB2_SHAREFLAG_MANUAL_CACHING 0x0000
+#define SMB2_SHAREFLAG_AUTO_CACHING 0x0010
+#define SMB2_SHAREFLAG_VDO_CACHING 0x0020
+#define SMB2_SHAREFLAG_NO_CACHING 0x0030
+#define SMB2_SHAREFLAG_DFS 0x0001
+#define SMB2_SHAREFLAG_DFS_ROOT 0x0002
+#define SMB2_SHAREFLAG_RESTRICT_EXCLUSIVE_OPENS 0x0100
+#define SMB2_SHAREFLAG_FORCE_SHARED_DELETE 0x0200
+#define SMB2_SHAREFLAG_ALLOW_NAMESPACE_CACHING 0x0400
+#define SMB2_SHAREFLAG_ACCESS_BASED_DIRECTORY_ENUM 0x0800
+#define SMB2_SHAREFLAG_ALL 0x0F33
+
+/* SMB2 create security flags */
+#define SMB2_SECURITY_DYNAMIC_TRACKING 0x01
+#define SMB2_SECURITY_EFFECTIVE_ONLY 0x02
+
+/* SMB2 requested oplock levels */
+#define SMB2_OPLOCK_LEVEL_NONE 0x00
+#define SMB2_OPLOCK_LEVEL_II 0x01
+#define SMB2_OPLOCK_LEVEL_EXCLUSIVE 0x08
+#define SMB2_OPLOCK_LEVEL_BATCH 0x09
+
+/* SMB2 impersonation levels */
+#define SMB2_IMPERSONATION_ANONYMOUS 0x00
+#define SMB2_IMPERSONATION_IDENTIFICATION 0x01
+#define SMB2_IMPERSONATION_IMPERSONATION 0x02
+#define SMB2_IMPERSONATION_DELEGATE 0x03
+
+/* SMB2 create tags */
+#define SMB2_CREATE_TAG_EXTA "ExtA"
+#define SMB2_CREATE_TAG_MXAC "MxAc"
+#define SMB2_CREATE_TAG_SECD "SecD"
+#define SMB2_CREATE_TAG_DHNQ "DHnQ"
+#define SMB2_CREATE_TAG_DHNC "DHnC"
+#define SMB2_CREATE_TAG_ALSI "AlSi"
+#define SMB2_CREATE_TAG_TWRP "TWrp"
+#define SMB2_CREATE_TAG_QFID "QFid"
+
+
+
/*
check that a body has the expected size
*/
diff --git a/source4/libcli/smb2/smb2_calls.h b/source4/libcli/smb2/smb2_calls.h
index 6a551da4ae..f66236af30 100644
--- a/source4/libcli/smb2/smb2_calls.h
+++ b/source4/libcli/smb2/smb2_calls.h
@@ -23,30 +23,31 @@
struct smb2_negprot {
struct {
- /* static body buffer 38 (0x26) bytes */
- /* uint16_t buffer_code; 0x24 (why?) */
- uint16_t unknown1; /* 0x0001 */
- uint8_t unknown2[32]; /* all zero */
- uint16_t unknown3; /* 0x00000 */
+ uint16_t dialect_count; /* size of dialects array */
+ uint16_t security_mode; /* 0==signing disabled
+ 1==signing enabled */
+ uint16_t reserved;
+ uint32_t capabilities;
+ struct GUID client_guid;
+ NTTIME start_time;
+ uint16_t *dialects;
} in;
struct {
/* static body buffer 64 (0x40) bytes */
/* uint16_t buffer_code; 0x41 = 0x40 + 1 */
- uint16_t _pad;
- uint32_t unknown2; /* 0x06 */
- uint8_t sessid[16];
- uint32_t unknown3; /* 0x0d */
- uint16_t unknown4; /* 0x00 */
- uint32_t unknown5; /* 0x01 */
- uint32_t unknown6; /* 0x01 */
- uint16_t unknown7; /* 0x01 */
- NTTIME current_time;
- NTTIME boot_time;
+ uint16_t security_mode; /* SMB2_NEGOTIATE_SIGNING_* */
+ uint16_t dialect_revision;
+ uint16_t reserved;
+ struct GUID server_guid;
+ uint32_t capabilities;
+ uint32_t max_transact_size;
+ uint32_t max_read_size;
+ uint32_t max_write_size;
+ NTTIME system_time;
+ NTTIME server_start_time;
/* uint16_t secblob_ofs */
/* uint16_t secblob_size */
- uint32_t unknown9; /* 0x204d4c20 */
-
- /* dynamic body buffer */
+ uint32_t reserved2;
DATA_BLOB secblob;
} out;
};
@@ -55,6 +56,13 @@ struct smb2_negprot {
#define SMB2_GETINFO_FILE 0x01
#define SMB2_GETINFO_FS 0x02
#define SMB2_GETINFO_SECURITY 0x03
+#define SMB2_GETINFO_QUOTA 0x04
+
+#define SMB2_GETINFO_ADD_OWNER_SECURITY 0x01
+#define SMB2_GETINFO_ADD_GROUP_SECURITY 0x02
+#define SMB2_GETINFO_ADD_DACL_SECURITY 0x04
+#define SMB2_GETINFO_ADD_SACL_SECURITY 0x08
+#define SMB2_GETINFO_ADD_LABEL_SECURITY 0x10
/* NOTE! the getinfo fs and file levels exactly match up with the
'passthru' SMB levels, which are levels >= 1000. The SMB2 client
@@ -63,14 +71,17 @@ struct smb2_negprot {
struct smb2_getinfo {
struct {
/* static body buffer 40 (0x28) bytes */
- /* uint16_t buffer_code; 0x29 = 0x28 + 1 (why???) */
- uint16_t level;
- uint32_t max_response_size;
- uint32_t unknown1;
- uint32_t unknown2;
- uint32_t flags; /* level specific */
- uint32_t flags2; /* used by all_eas level */
+ /* uint16_t buffer_code; 0x29 = 0x28 + 1 */
+ uint8_t info_type;
+ uint8_t info_class;
+ uint32_t output_buffer_length;
+ /* uint32_t input_buffer_offset; */
+ uint32_t reserved;
+ uint32_t input_buffer_length;
+ uint32_t additional_information; /* SMB2_GETINFO_ADD_* */
+ uint32_t getinfo_flags; /* level specific */
union smb_handle file;
+ DATA_BLOB blob;
} in;
struct {
diff --git a/source4/libcli/smb2/tcon.c b/source4/libcli/smb2/tcon.c
index ad1ba4c92d..db35669d41 100644
--- a/source4/libcli/smb2/tcon.c
+++ b/source4/libcli/smb2/tcon.c
@@ -56,9 +56,9 @@ struct smb2_request *smb2_tree_connect_send(struct smb2_tree *tree,
0x08, true, 0);
if (req == NULL) return NULL;
- SBVAL(req->out.hdr, SMB2_HDR_UID, tree->session->uid);
+ SBVAL(req->out.hdr, SMB2_HDR_SESSION_ID, tree->session->uid);
- SSVAL(req->out.body, 0x02, io->in.unknown1);
+ SSVAL(req->out.body, 0x02, io->in.reserved);
status = smb2_push_o16s16_string(&req->out, 0x04, io->in.path);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(req);
@@ -85,10 +85,18 @@ NTSTATUS smb2_tree_connect_recv(struct smb2_request *req, struct smb2_tree_conne
io->out.tid = IVAL(req->in.hdr, SMB2_HDR_TID);
- io->out.unknown1 = SVAL(req->in.body, 0x02);
- io->out.unknown2 = IVAL(req->in.body, 0x04);
- io->out.unknown3 = IVAL(req->in.body, 0x08);
+ io->out.share_type = CVAL(req->in.body, 0x02);
+ io->out.reserved = CVAL(req->in.body, 0x03);
+ io->out.flags = IVAL(req->in.body, 0x04);
+ io->out.capabilities= IVAL(req->in.body, 0x08);
io->out.access_mask = IVAL(req->in.body, 0x0C);
+
+ if (io->out.capabilities & ~SMB2_CAP_ALL) {
+ DEBUG(0,("Unknown capabilities mask 0x%x\n", io->out.capabilities));
+ }
+ if (io->out.flags & ~SMB2_SHAREFLAG_ALL) {
+ DEBUG(0,("Unknown tcon shareflag 0x%x\n", io->out.flags));
+ }
return smb2_request_destroy(req);
}
diff --git a/source4/libcli/smb2/transport.c b/source4/libcli/smb2/transport.c
index 83e9436a58..1d601fdbfe 100644
--- a/source4/libcli/smb2/transport.c
+++ b/source4/libcli/smb2/transport.c
@@ -167,7 +167,7 @@ static NTSTATUS smb2_transport_finish_recv(void *private, DATA_BLOB blob)
}
flags = IVAL(hdr, SMB2_HDR_FLAGS);
- seqnum = BVAL(hdr, SMB2_HDR_SEQNUM);
+ seqnum = BVAL(hdr, SMB2_HDR_MESSAGE_ID);
/* match the incoming request against the list of pending requests */
for (req=transport->pending_recv; req; req=req->next) {
@@ -216,6 +216,8 @@ static NTSTATUS smb2_transport_finish_recv(void *private, DATA_BLOB blob)
}
}
+ smb2_setup_bufinfo(req);
+
DEBUG(2, ("SMB2 RECV seqnum=0x%llx\n", (long long)req->seqnum));
dump_data(5, req->in.body, req->in.body_size);
diff --git a/source4/libnet/config.mk b/source4/libnet/config.mk
index 9041ff5a23..a72ae5b51f 100644
--- a/source4/libnet/config.mk
+++ b/source4/libnet/config.mk
@@ -27,7 +27,7 @@ OBJ_FILES = \
userman.o \
groupman.o \
prereq_domain.o
-PUBLIC_DEPENDENCIES = CREDENTIALS dcerpc dcerpc_samr RPC_NDR_LSA RPC_NDR_SRVSVC RPC_NDR_DRSUAPI LIBCLI_COMPOSITE LIBCLI_RESOLVE LIBCLI_FINDDCS LIBSAMBA3 LIBCLI_CLDAP LIBCLI_FINDDCS gensec_schannel LIBCLI_AUTH LIBNDR
+PUBLIC_DEPENDENCIES = CREDENTIALS dcerpc dcerpc_samr RPC_NDR_LSA RPC_NDR_SRVSVC RPC_NDR_DRSUAPI LIBCLI_COMPOSITE LIBCLI_RESOLVE LIBCLI_FINDDCS LIBCLI_CLDAP LIBCLI_FINDDCS gensec_schannel LIBCLI_AUTH LIBNDR SMBPASSWD
[PYTHON::swig_net]
PRIVATE_DEPENDENCIES = LIBSAMBA-NET
diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk
index 0f5a65121c..2fdef41b2a 100644
--- a/source4/librpc/config.mk
+++ b/source4/librpc/config.mk
@@ -277,7 +277,7 @@ OBJ_FILES = gen_ndr/ndr_winbind.o
PUBLIC_HEADERS = gen_ndr/winbind.h
PUBLIC_DEPENDENCIES = LIBNDR NDR_NETLOGON
-include ../heimdal_build/perl_path_wrapper.sh ../librpc/idl-deps.pl librpc/idl/*.idl|
+mkinclude ../heimdal_build/perl_path_wrapper.sh ../librpc/idl-deps.pl librpc/idl/*.idl|
librpc/gen_ndr/tables.c: $(IDL_NDR_PARSE_H_FILES)
@echo Generating librpc/gen_ndr/tables.c
diff --git a/source4/librpc/idl/dcerpc.idl b/source4/librpc/idl/dcerpc.idl
index fcb0be4639..b2c67542f5 100644
--- a/source4/librpc/idl/dcerpc.idl
+++ b/source4/librpc/idl/dcerpc.idl
@@ -64,7 +64,8 @@ interface dcerpc
uint16 max_xmit_frag;
uint16 max_recv_frag;
uint32 assoc_group_id;
- ascstr3 secondary_address;
+ [value(strlen(secondary_address)+1)] uint16 secondary_address_size;
+ [charset(DOS)] uint8 secondary_address[secondary_address_size];
[flag(NDR_ALIGN4)] DATA_BLOB _pad1;
uint8 num_results;
dcerpc_ack_ctx ctx_list[num_results];
diff --git a/source4/librpc/idl/drsblobs.idl b/source4/librpc/idl/drsblobs.idl
index 1e80597f4a..27f3a99551 100644
--- a/source4/librpc/idl/drsblobs.idl
+++ b/source4/librpc/idl/drsblobs.idl
@@ -85,7 +85,8 @@ interface drsblobs {
* w2k3 uses version 1
*/
typedef [public,gensize] struct {
- asclstr dns_name;
+ [value(strlen(dns_name)+1)] uint32 __dns_name_size;
+ [charset(DOS)] uint8 dns_name[__dns_name_size];
} repsFromTo1OtherInfo;
typedef [public,gensize,flag(NDR_PAHEX)] struct {
diff --git a/source4/librpc/idl/drsuapi.idl b/source4/librpc/idl/drsuapi.idl
index f298b7e321..fb24122e26 100644
--- a/source4/librpc/idl/drsuapi.idl
+++ b/source4/librpc/idl/drsuapi.idl
@@ -130,7 +130,8 @@ interface drsuapi
[value(ndr_size_dom_sid28(&sid, ndr->flags))] uint32 __ndr_size_sid;
GUID guid;
dom_sid28 sid;
- [flag(STR_SIZE4|STR_CHARLEN|STR_CONFORMANT)] string dn;
+ [value(strlen_m(dn))] uint32 __ndr_size_dn;
+ [charset(UTF16),size_is(__ndr_size_dn+1)] uint16 dn[];
} drsuapi_DsReplicaObjectIdentifier;
typedef [public] bitmap {
@@ -451,7 +452,8 @@ interface drsuapi
[value(ndr_size_dom_sid28(&sid,ndr->flags))] uint32 __ndr_size_sid;
GUID guid;
dom_sid28 sid;
- [flag(STR_SIZE4|STR_CHARLEN)] string dn;
+ [value(strlen_m(dn))] uint32 __ndr_size_dn;
+ [charset(UTF16)] uint16 dn[__ndr_size_dn+1];
} drsuapi_DsReplicaObjectIdentifier3;
typedef [public,gensize] struct {
@@ -459,7 +461,8 @@ interface drsuapi
[value(ndr_size_dom_sid28(&sid,ndr->flags))] uint32 __ndr_size_sid;
GUID guid;
dom_sid28 sid;
- [flag(STR_SIZE4|STR_CHARLEN)] string dn;
+ [value(strlen_m(dn))] uint32 __ndr_size_dn;
+ [charset(UTF16)] uint16 dn[__ndr_size_dn+1];
[value(binary.length + 4)] uint32 __ndr_size_binary;
[flag(NDR_REMAINING)] DATA_BLOB binary;
} drsuapi_DsReplicaObjectIdentifier3Binary;
diff --git a/source4/librpc/idl/epmapper.idl b/source4/librpc/idl/epmapper.idl
index baf9f23877..60ff338ec4 100644
--- a/source4/librpc/idl/epmapper.idl
+++ b/source4/librpc/idl/epmapper.idl
@@ -3,6 +3,7 @@
/*
endpoint mapper interface
Related links:
+ http://www.opengroup.org/onlinepubs/9629399/apdxo.htm : The official IDL for this pipe
http://www.opengroup.org/onlinepubs/9629399/apdxl.htm : Details on towers
http://www.opengroup.org/onlinepubs/9629399/chap6.htm#tagcjh_11_02_03_01: binding strings
@@ -222,7 +223,16 @@ interface epmapper
typedef struct {
GUID object;
epm_twr_t *tower;
- ascstr2 annotation;
+ /*
+ * In theory this should be:
+ * [charset(DOS),string] uint8 annotation[64]
+ * But midl treats this as:
+ * [charset(DOS),string] uint8 annotation[]
+ * and pidl doesn't support this yet
+ */
+ [value(0)] uint32 __annotation_offset;
+ [value(strlen(annotation)+1)] uint32 __annotation_length;
+ [charset(DOS)] uint8 annotation[__annotation_length];
} epm_entry_t;
typedef struct {
diff --git a/source4/librpc/idl/idl_types.h b/source4/librpc/idl/idl_types.h
index f21f3e660d..9885ca5bf6 100644
--- a/source4/librpc/idl/idl_types.h
+++ b/source4/librpc/idl/idl_types.h
@@ -5,33 +5,16 @@
#define STR_NOTERM LIBNDR_FLAG_STR_NOTERM
#define STR_NULLTERM LIBNDR_FLAG_STR_NULLTERM
#define STR_BYTESIZE LIBNDR_FLAG_STR_BYTESIZE
-#define STR_FIXLEN32 LIBNDR_FLAG_STR_FIXLEN32
-#define STR_FIXLEN15 LIBNDR_FLAG_STR_FIXLEN15
#define STR_CONFORMANT LIBNDR_FLAG_STR_CONFORMANT
#define STR_CHARLEN LIBNDR_FLAG_STR_CHARLEN
#define STR_UTF8 LIBNDR_FLAG_STR_UTF8
/*
- a UCS2 string prefixed with [size], 32 bits
-*/
-#define lstring [flag(STR_SIZE4)] string
-
-/*
a null terminated UCS2 string
*/
#define nstring [flag(STR_NULLTERM)] string
/*
- fixed length 32 character UCS-2 string
-*/
-#define string32 [flag(STR_FIXLEN32)] string
-
-/*
- fixed length 16 character ascii string
-*/
-#define astring15 [flag(STR_ASCII|STR_FIXLEN15)] string
-
-/*
an ascii string prefixed with [offset] [length], both 32 bits
null terminated
*/
diff --git a/source4/librpc/idl/initshutdown.idl b/source4/librpc/idl/initshutdown.idl
index 868e48e28a..ac30be70dd 100644
--- a/source4/librpc/idl/initshutdown.idl
+++ b/source4/librpc/idl/initshutdown.idl
@@ -4,6 +4,8 @@
initshutdown interface definition
*/
+import "lsa.idl";
+
[
uuid("894de0c0-0d55-11d3-a322-00c04fa321a1"),
version(1.0),
@@ -12,20 +14,13 @@
helpstring("Init shutdown service")
] interface initshutdown
{
- typedef struct {
- [value(strlen_m_term(name))] uint32 name_size;
- [flag(STR_LEN4|STR_NOTERM)] string name;
- } initshutdown_String_sub;
-
- typedef [public] struct {
- [value(strlen_m(name->name)*2)] uint16 name_len;
- [value(strlen_m_term(name->name)*2)] uint16 name_size;
- initshutdown_String_sub *name;
- } initshutdown_String;
-
WERROR initshutdown_Init(
[in,unique] uint16 *hostname,
- [in,unique] initshutdown_String *message,
+ /*
+ * Note: lsa_String and winreg_String both result
+ * in WERR_INVALID_PARAM
+ */
+ [in,unique] lsa_StringLarge *message,
[in] uint32 timeout,
[in] uint8 force_apps,
[in] uint8 reboot
@@ -37,7 +32,11 @@
WERROR initshutdown_InitEx(
[in,unique] uint16 *hostname,
- [in,unique] initshutdown_String *message,
+ /*
+ * Note: lsa_String and winreg_String both result
+ * in WERR_INVALID_PARAM
+ */
+ [in,unique] lsa_StringLarge *message,
[in] uint32 timeout,
[in] uint8 force_apps,
[in] uint8 reboot,
diff --git a/source4/librpc/idl/krb5pac.idl b/source4/librpc/idl/krb5pac.idl
index fa6bf51e44..efd4aa860f 100644
--- a/source4/librpc/idl/krb5pac.idl
+++ b/source4/librpc/idl/krb5pac.idl
@@ -16,7 +16,8 @@ interface krb5pac
{
typedef struct {
NTTIME logon_time;
- [flag(STR_SIZE2|STR_NOTERM|STR_BYTESIZE)] string account_name;
+ [value(2*strlen_m(account_name))] uint16 size;
+ [charset(UTF16)] uint8 account_name[size];
} PAC_LOGON_NAME;
typedef [public,flag(NDR_PAHEX)] struct {
diff --git a/source4/librpc/idl/lsa.idl b/source4/librpc/idl/lsa.idl
index 8d26ec0aad..3159a7d16d 100644
--- a/source4/librpc/idl/lsa.idl
+++ b/source4/librpc/idl/lsa.idl
@@ -23,7 +23,7 @@ import "security.idl";
typedef [public] struct {
[value(2*strlen_m(string))] uint16 length;
- [value(2*(strlen_m(string)+1))] uint16 size;
+ [value(2*strlen_m_term(string))] uint16 size;
[charset(UTF16),size_is(size/2),length_is(length/2)] uint16 *string;
} lsa_StringLarge;
@@ -35,9 +35,15 @@ import "security.idl";
typedef [public] struct {
[value(strlen_m(string))] uint16 length;
[value(strlen_m(string))] uint16 size;
- ascstr_noterm *string;
+ [charset(DOS),size_is(size),length_is(length)] uint8 *string;
} lsa_AsciiString;
+ typedef [public] struct {
+ [value(strlen_m(string))] uint16 length;
+ [value(strlen_m_term(string))] uint16 size;
+ [charset(DOS),size_is(size),length_is(length)] uint8 *string;
+ } lsa_AsciiStringLarge;
+
/******************/
/* Function: 0x00 */
NTSTATUS lsa_Close (
diff --git a/source4/librpc/idl/nbt.idl b/source4/librpc/idl/nbt.idl
index d4c2bf1ad0..17304bfa0d 100644
--- a/source4/librpc/idl/nbt.idl
+++ b/source4/librpc/idl/nbt.idl
@@ -143,7 +143,7 @@ interface nbt
} nbt_statistics;
typedef struct {
- astring15 name;
+ [charset(DOS)] uint8 name[15];
nbt_name_type type;
nb_flags nb_flags;
} nbt_status_name;
diff --git a/source4/librpc/idl/spoolss.idl b/source4/librpc/idl/spoolss.idl
index 114c06a00d..2144393ebd 100644
--- a/source4/librpc/idl/spoolss.idl
+++ b/source4/librpc/idl/spoolss.idl
@@ -58,7 +58,7 @@ import "security.idl", "winreg.idl";
} spoolss_PrinterInfo0;
typedef [public,gensize] struct {
- string32 devicename;
+ [charset(UTF16)] uint16 devicename[32];
uint16 specversion;
uint16 driverversion;
uint16 size;
@@ -77,7 +77,7 @@ import "security.idl", "winreg.idl";
uint16 yresolution;
uint16 ttoption;
uint16 collate;
- string32 formname;
+ [charset(UTF16)] uint16 formname[32];
uint16 logpixels;
uint32 bitsperpel;
uint32 pelswidth;
@@ -1407,12 +1407,13 @@ import "security.idl", "winreg.idl";
WERROR spoolss_EnumPrinterData(
[in,ref] policy_handle *handle,
[in] uint32 enum_index,
+ [out,ref,size_is(value_offered/2),charset(UTF16)] uint16 *value_name,
[in] uint32 value_offered,
- [out] lstring value_name,
- [out] uint32 value_needed,
- [out] uint32 printerdata_type,
- [out] DATA_BLOB buffer,
- [in,out,ref] uint32 *data_size
+ [out,ref] uint32 *value_needed,
+ [out,ref] uint32 *printerdata_type,
+ [out,ref] DATA_BLOB *buffer,
+ [in] uint32 data_offered,
+ [out,ref] uint32 *data_needed
);
/******************/
diff --git a/source4/librpc/idl/winreg.idl b/source4/librpc/idl/winreg.idl
index b489e86c38..5e5d5542b6 100644
--- a/source4/librpc/idl/winreg.idl
+++ b/source4/librpc/idl/winreg.idl
@@ -2,7 +2,7 @@
winreg interface definition
*/
-import "lsa.idl", "initshutdown.idl", "security.idl";
+import "lsa.idl", "security.idl";
[
uuid("338cd001-2244-31f1-aaaa-900038001003"),
@@ -302,7 +302,11 @@ import "lsa.idl", "initshutdown.idl", "security.idl";
/* Function: 0x18 */
WERROR winreg_InitiateSystemShutdown(
[in,unique] uint16 *hostname,
- [in,unique] initshutdown_String *message,
+ /*
+ * Note: lsa_String and winreg_String both result
+ * in WERR_INVALID_PARAM
+ */
+ [in,unique] lsa_StringLarge *message,
[in] uint32 timeout,
[in] uint8 force_apps,
[in] uint8 reboot
@@ -358,7 +362,11 @@ import "lsa.idl", "initshutdown.idl", "security.idl";
/* Function: 0x1e */
WERROR winreg_InitiateSystemShutdownEx(
[in,unique] uint16 *hostname,
- [in,unique] initshutdown_String *message,
+ /*
+ * Note: lsa_String and winreg_String both result
+ * in WERR_INVALID_PARAM
+ */
+ [in,unique] lsa_StringLarge *message,
[in] uint32 timeout,
[in] uint8 force_apps,
[in] uint8 reboot,
diff --git a/source4/librpc/ndr/libndr.h b/source4/librpc/ndr/libndr.h
index 1ecc6f3c38..731ef0f60b 100644
--- a/source4/librpc/ndr/libndr.h
+++ b/source4/librpc/ndr/libndr.h
@@ -109,11 +109,9 @@ struct ndr_print {
#define LIBNDR_FLAG_STR_NULLTERM (1<<6)
#define LIBNDR_FLAG_STR_SIZE2 (1<<7)
#define LIBNDR_FLAG_STR_BYTESIZE (1<<8)
-#define LIBNDR_FLAG_STR_FIXLEN32 (1<<9)
#define LIBNDR_FLAG_STR_CONFORMANT (1<<10)
#define LIBNDR_FLAG_STR_CHARLEN (1<<11)
#define LIBNDR_FLAG_STR_UTF8 (1<<12)
-#define LIBNDR_FLAG_STR_FIXLEN15 (1<<13)
#define LIBNDR_STRING_FLAGS (0x7FFC)
diff --git a/source4/librpc/ndr/ndr_sec_helper.c b/source4/librpc/ndr/ndr_sec_helper.c
index 30eaf9c6f4..5a0178bd25 100644
--- a/source4/librpc/ndr/ndr_sec_helper.c
+++ b/source4/librpc/ndr/ndr_sec_helper.c
@@ -187,6 +187,9 @@ enum ndr_err_code ndr_pull_dom_sid28(struct ndr_pull *ndr, int ndr_flags, struct
if (!NDR_ERR_CODE_IS_SUCCESS(status)) {
/* handle a w2k bug which send random data in the buffer */
ZERO_STRUCTP(sid);
+ } else if (sid->num_auths == 0 && sid->sub_auths) {
+ talloc_free(sid->sub_auths);
+ sid->sub_auths = NULL;
}
return NDR_ERR_SUCCESS;
diff --git a/source4/librpc/ndr/ndr_string.c b/source4/librpc/ndr/ndr_string.c
index 69a7eca1a8..79548f81bc 100644
--- a/source4/librpc/ndr/ndr_string.c
+++ b/source4/librpc/ndr/ndr_string.c
@@ -259,24 +259,6 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
*s = as;
break;
- case LIBNDR_FLAG_STR_FIXLEN15:
- case LIBNDR_FLAG_STR_FIXLEN32:
- len1 = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15;
- NDR_PULL_NEED_BYTES(ndr, len1*byte_mul);
- ret = convert_string_talloc(ndr->current_mem_ctx,
- ndr->iconv_convenience,
- chset, CH_UNIX,
- ndr->data+ndr->offset,
- len1*byte_mul,
- (void **)&as);
- if (ret == -1) {
- return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
- }
- NDR_CHECK(ndr_pull_advance(ndr, len1*byte_mul));
- *s = as;
- break;
-
case LIBNDR_FLAG_STR_NOTERM:
if (!(ndr->flags & LIBNDR_FLAG_REMAINING)) {
return ndr_pull_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x (missing NDR_REMAINING)\n",
@@ -349,10 +331,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags,
flags &= ~LIBNDR_FLAG_STR_CONFORMANT;
- if (!(flags &
- (LIBNDR_FLAG_STR_NOTERM |
- LIBNDR_FLAG_STR_FIXLEN15 |
- LIBNDR_FLAG_STR_FIXLEN32))) {
+ if (!(flags & LIBNDR_FLAG_STR_NOTERM)) {
s_len++;
}
d_len = convert_string_talloc(ndr, ndr->iconv_convenience, CH_UNIX, chset, s, s_len, (void **)&dest);
@@ -399,21 +378,6 @@ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags,
NDR_CHECK(ndr_push_bytes(ndr, dest, d_len));
break;
- case LIBNDR_FLAG_STR_FIXLEN15:
- case LIBNDR_FLAG_STR_FIXLEN32: {
- ssize_t fix_len = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15;
- uint32_t pad_len = fix_len - d_len;
- if (d_len > fix_len) {
- return ndr_push_error(ndr, NDR_ERR_CHARCNV,
- "Bad character conversion");
- }
- NDR_CHECK(ndr_push_bytes(ndr, dest, d_len));
- if (pad_len != 0) {
- NDR_CHECK(ndr_push_zero(ndr, pad_len));
- }
- break;
- }
-
default:
if (ndr->flags & LIBNDR_FLAG_REMAINING) {
NDR_CHECK(ndr_push_bytes(ndr, dest, d_len));
@@ -439,13 +403,6 @@ _PUBLIC_ size_t ndr_string_array_size(struct ndr_push *ndr, const char *s)
unsigned byte_mul = 2;
unsigned c_len_term = 1;
- if (flags & LIBNDR_FLAG_STR_FIXLEN32) {
- return 32;
- }
- if (flags & LIBNDR_FLAG_STR_FIXLEN15) {
- return 15;
- }
-
c_len = s?strlen_m(s):0;
if (flags & (LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_UTF8)) {
diff --git a/source4/librpc/rpc/dcerpc_smb2.c b/source4/librpc/rpc/dcerpc_smb2.c
index b06964d331..a0094b8bae 100644
--- a/source4/librpc/rpc/dcerpc_smb2.c
+++ b/source4/librpc/rpc/dcerpc_smb2.c
@@ -410,7 +410,7 @@ struct composite_context *dcerpc_pipe_open_smb2_send(struct dcerpc_pipe *p,
state->ctx = ctx;
ZERO_STRUCT(io);
- io.in.access_mask =
+ io.in.desired_access =
SEC_STD_READ_CONTROL |
SEC_FILE_READ_ATTRIBUTE |
SEC_FILE_WRITE_ATTRIBUTE |
@@ -423,11 +423,11 @@ struct composite_context *dcerpc_pipe_open_smb2_send(struct dcerpc_pipe *p,
io.in.share_access =
NTCREATEX_SHARE_ACCESS_READ |
NTCREATEX_SHARE_ACCESS_WRITE;
- io.in.open_disposition = NTCREATEX_DISP_OPEN;
+ io.in.create_disposition = NTCREATEX_DISP_OPEN;
io.in.create_options =
NTCREATEX_OPTIONS_NON_DIRECTORY_FILE |
NTCREATEX_OPTIONS_UNKNOWN_400000;
- io.in.impersonation = NTCREATEX_IMPERSONATION_IMPERSONATION;
+ io.in.impersonation_level = NTCREATEX_IMPERSONATION_IMPERSONATION;
if ((strncasecmp(pipe_name, "/pipe/", 6) == 0) ||
(strncasecmp(pipe_name, "\\pipe\\", 6) == 0)) {
diff --git a/source4/main.mk b/source4/main.mk
index 7be6032256..b8364aca5a 100644
--- a/source4/main.mk
+++ b/source4/main.mk
@@ -1,371 +1,31 @@
-default: all
-
-include dynconfig.mk
-include heimdal_build/config.mk
-include config.mk
-include dsdb/config.mk
-include smbd/config.mk
-include cluster/config.mk
-include smbd/process_model.mk
-include libnet/config.mk
-include auth/config.mk
-include nsswitch/config.mk
-include lib/basic.mk
-include param/config.mk
-include smb_server/config.mk
-include rpc_server/config.mk
-include ldap_server/config.mk
-include web_server/config.mk
-include winbind/config.mk
-include nbt_server/config.mk
-include wrepl_server/config.mk
-include cldap_server/config.mk
-include utils/net/config.mk
-include utils/config.mk
-include ntvfs/config.mk
-include ntptr/config.mk
-include torture/config.mk
-include librpc/config.mk
-include client/config.mk
-include libcli/config.mk
-include scripting/ejs/config.mk
-include scripting/python/config.mk
-include kdc/config.mk
-
-DEFAULT_HEADERS = $(srcdir)/lib/util/dlinklist.h \
- $(srcdir)/version.h
-
-binaries: $(BINARIES)
-libraries: $(STATIC_LIBS) $(SHARED_LIBS)
-modules: $(SHARED_MODULES)
-headers: $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
-manpages: $(MANPAGES)
-all: showflags $(ALL_PREDEP) bin/asn1_compile bin/compile_et binaries modules pythonmods
-everything: all libraries headers
-
-LD_LIBPATH_OVERRIDE = $(LIB_PATH_VAR)=$(builddir)/bin/shared
-
-# 'make testsuite' creates all binaries which are
-# needed by samba3's 'make test' and the build-farm
-# scripts use that it as fallback in case
-# 'make everything' fails
-testsuite: bin/smbclient bin/cifsdd bin/smbtorture bin/nmblookup
-
-showlayout:
- @echo 'Samba will be installed into:'
- @echo ' basedir: $(BASEDIR)'
- @echo ' bindir: $(BINDIR)'
- @echo ' sbindir: $(SBINDIR)'
- @echo ' libdir: $(LIBDIR)'
- @echo ' modulesdir: $(MODULESDIR)'
- @echo ' includedir: $(INCLUDEDIR)'
- @echo ' vardir: $(VARDIR)'
- @echo ' privatedir: $(PRIVATEDIR)'
- @echo ' piddir: $(PIDDIR)'
- @echo ' lockdir: $(LOCKDIR)'
- @echo ' logfilebase: $(LOGFILEBASE)'
- @echo ' setupdir: $(SETUPDIR)'
- @echo ' jsdir: $(JSDIR)'
- @echo ' swatdir: $(SWATDIR)'
- @echo ' mandir: $(MANDIR)'
- @echo ' torturedir: $(TORTUREDIR)'
- @echo ' datadir: $(DATADIR)'
- @echo ' winbindd_socket_dir: $(WINBINDD_SOCKET_DIR)'
-
-showflags:
- @echo 'Samba will be compiled with flags:'
- @echo ' CPP = $(CPP)'
- @echo ' CPPFLAGS = $(CPPFLAGS)'
- @echo ' CC = $(CC)'
- @echo ' CFLAGS = $(CFLAGS)'
- @echo ' PICFLAG = $(PICFLAG)'
- @echo ' BNLD = $(BNLD)'
- @echo ' BNLD_FLAGS = $(BNLD_FLAGS)'
- @echo ' STLD = $(STLD)'
- @echo ' STLD_FLAGS = $(STLD_FLAGS)'
- @echo ' SHLD = $(SHLD)'
- @echo ' SHLD_FLAGS = $(SHLD_FLAGS)'
- @echo ' MDLD = $(MDLD)'
- @echo ' MDLD_FLAGS = $(MDLD_FLAGS)'
- @echo ' SHLIBEXT = $(SHLIBEXT)'
- @echo ' srcdir = $(srcdir)'
- @echo ' builddir = $(builddir)'
- @echo ' pwd = '`/bin/pwd`
-
-# The permissions to give the executables
-INSTALLPERMS = 0755
-
-install: showlayout everything installbin installdat installswat installmisc installlib \
- installheader installpc installplugins
-
-# DESTDIR is used here to prevent packagers wasting their time
-# duplicating the Makefile. Remove it and you will have the privilege
-# of packaging each samba release for multiple versions of multiple
-# distributions and operating systems, or at least supplying patches
-# to all the packaging files required for this, prior to committing
-# the removal of DESTDIR. Do not remove it even though you think it
-# is not used.
-
-installdirs:
- @$(SHELL) $(srcdir)/script/installdirs.sh \
- $(DESTDIR)$(BASEDIR) \
- $(DESTDIR)$(BINDIR) \
- $(DESTDIR)$(SBINDIR) \
- $(DESTDIR)$(TORTUREDIR) \
- $(DESTDIR)$(LIBDIR) \
- $(DESTDIR)$(MODULESDIR) \
- $(DESTDIR)$(MANDIR) \
- $(DESTDIR)$(VARDIR) \
- $(DESTDIR)$(PRIVATEDIR) \
- $(DESTDIR)$(DATADIR) \
- $(DESTDIR)$(PIDDIR) \
- $(DESTDIR)$(LOCKDIR) \
- $(DESTDIR)$(LOGFILEBASE) \
- $(DESTDIR)$(PRIVATEDIR)/tls \
- $(DESTDIR)$(INCLUDEDIR) \
- $(DESTDIR)$(PKGCONFIGDIR) \
- $(DESTDIR)$(CONFIGDIR) \
-
-installbin: $(SBIN_PROGS) $(BIN_PROGS) $(TORTURE_PROGS) installdirs
- @$(SHELL) $(srcdir)/script/installbin.sh \
- $(INSTALLPERMS) \
- $(DESTDIR)$(BASEDIR) \
- $(DESTDIR)$(SBINDIR) \
- $(DESTDIR)$(LIBDIR) \
- $(DESTDIR)$(VARDIR) \
- $(SBIN_PROGS)
- @$(SHELL) $(srcdir)/script/installbin.sh \
- $(INSTALLPERMS) \
- $(DESTDIR)$(BASEDIR) \
- $(DESTDIR)$(BINDIR) \
- $(DESTDIR)$(LIBDIR) \
- $(DESTDIR)$(VARDIR) \
- $(BIN_PROGS)
- @$(SHELL) $(srcdir)/script/installtorture.sh \
- $(INSTALLPERMS) \
- $(DESTDIR)$(TORTUREDIR) \
- $(TORTURE_PROGS)
-
-installlib: $(INSTALLABLE_SHARED_LIBS) $(STATIC_LIBS) installdirs
- @$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(LIBDIR) "$(SHLIBEXT)" $(INSTALLABLE_SHARED_LIBS)
- #@$(SHELL) $(srcdir)/script/installlib.sh $(DESTDIR)$(LIBDIR) "$(STLIBEXT)" $(STATIC_LIBS)
-
-installheader: headers installdirs
- @srcdir=$(srcdir) builddir=$(builddir) $(PERL) $(srcdir)/script/installheader.pl $(DESTDIR)$(INCLUDEDIR) $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
-
-installdat: installdirs
- @$(SHELL) $(srcdir)/script/installdat.sh $(DESTDIR)$(DATADIR) $(srcdir)
-
-installswat: installdirs
- @$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir)
-
-installman: manpages installdirs
- @$(SHELL) $(srcdir)/script/installman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
-
-installmisc: installdirs
- @$(SHELL) $(srcdir)/script/installmisc.sh $(srcdir) $(DESTDIR)$(JSDIR) $(DESTDIR)$(SETUPDIR) $(DESTDIR)$(BINDIR)
-
-installpc: installdirs
- @$(SHELL) $(srcdir)/script/installpc.sh $(builddir) $(DESTDIR)$(PKGCONFIGDIR) $(PC_FILES)
-
-uninstall: uninstallbin uninstallman uninstallmisc uninstalllib uninstallheader \
- uninstallplugins
-
-uninstallmisc:
- #FIXME
-
-uninstallbin:
- @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(SBINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(SBIN_PROGS)
- @$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(DESTDIR)$(BIN_PROGS)
- @$(SHELL) $(srcdir)/script/uninstalltorture.sh $(DESTDIR)$(TORTUREDIR) $(TORTURE_PROGS)
-
-uninstalllib:
- @$(SHELL) $(srcdir)/script/uninstalllib.sh $(DESTDIR)$(LIBDIR) $(SHARED_LIBS)
- #@$(SHELL) $(srcdir)/script/uninstalllib.sh $(DESTDIR)$(LIBDIR) $(STATIC_LIBS)
-
-uninstallheader:
- @$(SHELL) $(srcdir)/script/uninstallheader.sh $(DESTDIR)$(INCLUDEDIR) $(PUBLIC_HEADERS)
-
-uninstallman:
- @$(SHELL) $(srcdir)/script/uninstallman.sh $(DESTDIR)$(MANDIR) $(MANPAGES)
-
-Makefile: config.status $(MK_FILES)
- ./config.status
-
-etags:
- etags `find $(srcdir) -name "*.[ch]"`
-
-ctags:
- ctags `find $(srcdir) -name "*.[ch]"`
-
-pidl/Makefile: pidl/Makefile.PL
- cd pidl && $(PERL) Makefile.PL
-
-testcov-html:: pidl-testcov
-
-pidl-testcov: pidl/Makefile
- cd pidl && cover -test
-
-installpidl: pidl/Makefile
- $(MAKE) -C pidl install
-
-uninstallpidl: pidl/Makefile
- $(MAKE) -C pidl uninstall
-
-$(IDL_HEADER_FILES) \
- $(IDL_NDR_PARSE_H_FILES) $(IDL_NDR_PARSE_C_FILES) \
- $(IDL_NDR_CLIENT_C_FILES) $(IDL_NDR_CLIENT_H_FILES) \
- $(IDL_NDR_SERVER_C_FILES) $(IDL_SWIG_FILES) \
- $(IDL_NDR_EJS_C_FILES) $(IDL_NDR_EJS_H_FILES) \
- $(IDL_NDR_PY_C_FILES) $(IDL_NDR_PY_H_FILES): idl
-
-idl_full: pidl/lib/Parse/Pidl/IDL.pm pidl/lib/Parse/Pidl/Expr.pm
- @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh FULL
-
-idl: pidl/lib/Parse/Pidl/IDL.pm pidl/lib/Parse/Pidl/Expr.pm
- @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh PARTIAL
-
-pidl/lib/Parse/Pidl/IDL.pm: pidl/idl.yp
- -$(YAPP) -m 'Parse::Pidl::IDL' -o pidl/lib/Parse/Pidl/IDL.pm pidl/idl.yp ||\
- touch pidl/lib/Parse/Pidl/IDL.pm
-
-pidl/lib/Parse/Pidl/Expr.pm: pidl/idl.yp
- -$(YAPP) -m 'Parse::Pidl::Expr' -o pidl/lib/Parse/Pidl/Expr.pm pidl/expr.yp ||\
- touch pidl/lib/Parse/Pidl/Expr.pm
-
-include/config.h:
- @echo "include/config.h not present"
- @echo "You need to rerun ./autogen.sh and ./configure"
- @/bin/false
-
-$(srcdir)/version.h: $(srcdir)/VERSION
- @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
-
-regen_version:
- @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
-
-clean_pch:
- @echo "Removing precompiled headers"
- @-rm -f include/includes.h.gch
-
-pch: clean_pch include/includes.h.gch
-
-clean:: clean_pch
- @echo Removing objects
- @-find . -name '*.o' -exec rm -f '{}' \;
- @echo Removing hostcc objects
- @-find . -name '*.ho' -exec rm -f '{}' \;
- @echo Removing binaries
- @-rm -f $(BIN_PROGS) $(SBIN_PROGS) $(BINARIES) $(TORTURE_PROGS)
- @echo Removing libraries
- @-rm -f $(STATIC_LIBRARIES) $(SHARED_LIBRARIES)
- @-rm -f bin/static/*.a bin/shared/*.$(SHLIBEXT)
- @echo Removing modules
- @-rm -f bin/modules/*/*.$(SHLIBEXT)
- @-rm -f bin/*_init_module.c
- @echo Removing dummy targets
- @-rm -f bin/.*_*
- @echo Removing generated files
- @-rm -f bin/*_init_module.c
- @-rm -rf librpc/gen_*
- @echo Removing proto headers
- @-rm -f $(PROTO_HEADERS)
-
-distclean: clean
- -rm -f include/config.h include/config_tmp.h include/build.h
- -rm -f Makefile
- -rm -f config.status
- -rm -f config.log config.cache
- -rm -f config.pm config.mk
- -rm -f $(PC_FILES)
-
-removebackup:
- -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~
-
-realdistclean:: distclean removebackup
- -rm -f include/config_tmp.h.in
- -rm -f version.h
- -rm -f configure
- -rm -f $(MANPAGES)
-
-check:: test
-
-include selftest/config.mk
-
-unused_macros:
- $(srcdir)/script/find_unused_macros.pl `find . -name "*.[ch]"` | sort
-
-###############################################################################
-# File types
-###############################################################################
-
-.SUFFIXES: .x .c .et .y .l .d .o .h .h.gch .a .$(SHLIBEXT) .1 .1.xml .3 .3.xml .5 .5.xml .7 .7.xml .8 .8.xml .ho .idl .hd
-
-.c.d:
- @echo "Generating dependencies for $<"
- @$(DEPENDS)
-
-.c.hd:
- @echo "Generating host-compiler dependencies for $<"
- @$(HDEPENDS)
-
-include/includes.d: include/includes.h
- @echo "Generating dependencies for $<"
- @$(PCHDEPENDS)
-
-.c.o:
- @if test -n "$(CC_CHECKER)"; then \
- echo "Checking $< with '$(CC_CHECKER)'"; \
- $(CHECK) ; \
- fi
- @echo "Compiling $<"
- @-mkdir -p `dirname $@`
- @$(COMPILE) && exit 0 ; \
- echo "The following command failed:" 1>&2;\
- echo "$(COMPILE)" 1>&2;\
- $(COMPILE) >/dev/null 2>&1
-
-.c.ho:
- @echo "Compiling $< with host compiler"
- @-mkdir -p `dirname $@`
- @$(HCOMPILE) && exit 0;\
- echo "The following command failed:" 1>&2;\
- echo "$(HCOMPILE)" 1>&2;\
- $(HCOMPILE) >/dev/null 2>&1
-
-.h.h.gch:
- @echo "Precompiling $<"
- @$(PCHCOMPILE)
-
-.y.c:
- @echo "Building $< with $(YACC)"
- @-$(srcdir)/script/yacc_compile.sh "$(YACC)" "$<" "$@"
-
-.l.c:
- @echo "Building $< with $(LEX)"
- @-$(srcdir)/script/lex_compile.sh "$(LEX)" "$<" "$@"
-
-DOCBOOK_MANPAGE_URL = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
-
-.1.xml.1:
- $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
-
-.3.xml.3:
- $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
-
-.5.xml.5:
- $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
-
-.7.xml.7:
- $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
-
-.8.xml.8:
- $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
-
-DEP_FILES = $(patsubst %.ho,%.hd,$(patsubst %.o,%.d,$(ALL_OBJS))) \
- include/includes.d
-
-dist:: idl_full manpages configure distclean
-
-configure:
- ./autogen.sh
+mkinclude dynconfig.mk
+mkinclude heimdal_build/config.mk
+mkinclude config.mk
+mkinclude dsdb/config.mk
+mkinclude smbd/config.mk
+mkinclude cluster/config.mk
+mkinclude smbd/process_model.mk
+mkinclude libnet/config.mk
+mkinclude auth/config.mk
+mkinclude nsswitch/config.mk
+mkinclude lib/basic.mk
+mkinclude param/config.mk
+mkinclude smb_server/config.mk
+mkinclude rpc_server/config.mk
+mkinclude ldap_server/config.mk
+mkinclude web_server/config.mk
+mkinclude winbind/config.mk
+mkinclude nbt_server/config.mk
+mkinclude wrepl_server/config.mk
+mkinclude cldap_server/config.mk
+mkinclude utils/net/config.mk
+mkinclude utils/config.mk
+mkinclude ntvfs/config.mk
+mkinclude ntptr/config.mk
+mkinclude torture/config.mk
+mkinclude librpc/config.mk
+mkinclude client/config.mk
+mkinclude libcli/config.mk
+mkinclude scripting/ejs/config.mk
+mkinclude scripting/python/config.mk
+mkinclude kdc/config.mk
diff --git a/source4/nbt_server/config.mk b/source4/nbt_server/config.mk
index 68ef56c11e..9285044768 100644
--- a/source4/nbt_server/config.mk
+++ b/source4/nbt_server/config.mk
@@ -17,7 +17,7 @@ PUBLIC_DEPENDENCIES = \
[MODULE::ldb_wins_ldb]
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
-INIT_FUNCTION = wins_ldb_module_init
+INIT_FUNCTION = &ldb_wins_ldb_module_ops
OBJ_FILES = \
wins/wins_ldb.o
PRIVATE_DEPENDENCIES = \
diff --git a/source4/nbt_server/wins/wins_ldb.c b/source4/nbt_server/wins/wins_ldb.c
index 47aa415667..02ea306243 100644
--- a/source4/nbt_server/wins/wins_ldb.c
+++ b/source4/nbt_server/wins/wins_ldb.c
@@ -112,16 +112,9 @@ failed:
return LDB_ERR_OTHER;
}
-static const struct ldb_module_ops wins_ldb_ops = {
+_PUBLIC_ const struct ldb_module_ops ldb_wins_ldb_module_ops = {
.name = "wins_ldb",
.add = wins_ldb_verify,
.modify = wins_ldb_verify,
.init_context = wins_ldb_init
};
-
-
-/* the init function */
-int wins_ldb_module_init(void)
-{
- return ldb_register_module(&wins_ldb_ops);
-}
diff --git a/source4/nsswitch/config.mk b/source4/nsswitch/config.mk
index 621939256c..e53e064272 100644
--- a/source4/nsswitch/config.mk
+++ b/source4/nsswitch/config.mk
@@ -10,7 +10,8 @@ OBJ_FILES = \
nsstest.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-UTIL \
- LIBREPLACE_EXT
+ LIBREPLACE_EXT \
+ LIBSAMBA-CONFIG
# End BINARY nsstest
#################################
diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c
index 910401f157..901dd2cf7c 100644
--- a/source4/ntvfs/cifs/vfs_cifs.c
+++ b/source4/ntvfs/cifs/vfs_cifs.c
@@ -64,12 +64,16 @@ struct async_info {
#define SETUP_PID private->tree->session->pid = req->smbpid
-#define SETUP_FILE do { \
- struct cvfs_file *f; \
+#define SETUP_FILE_HERE(f) do { \
f = ntvfs_handle_get_backend_data(io->generic.in.file.ntvfs, ntvfs); \
if (!f) return NT_STATUS_INVALID_HANDLE; \
io->generic.in.file.fnum = f->fnum; \
-} while (0)
+} while (0)
+
+#define SETUP_FILE do { \
+ struct cvfs_file *f; \
+ SETUP_FILE_HERE(f); \
+} while (0)
#define SETUP_PID_AND_FILE do { \
SETUP_PID; \
@@ -484,6 +488,7 @@ static void async_open(struct smbcli_request *c_req)
req->async_states->status = ntvfs_handle_set_backend_data(f->h, cvfs->ntvfs, f);
if (!NT_STATUS_IS_OK(req->async_states->status)) goto failed;
file->ntvfs = f->h;
+ DLIST_ADD(cvfs->files, f);
failed:
req->async_states->send_fn(req);
}
@@ -526,6 +531,7 @@ static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs,
status = ntvfs_handle_set_backend_data(f->h, private->ntvfs, f);
NT_STATUS_NOT_OK_RETURN(status);
file->ntvfs = f->h;
+ DLIST_ADD(private->files, f);
return NT_STATUS_OK;
}
@@ -752,6 +758,7 @@ static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs,
{
struct cvfs_private *private = ntvfs->private_data;
struct smbcli_request *c_req;
+ struct cvfs_file *f;
SETUP_PID;
@@ -759,7 +766,12 @@ static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs,
private->map_generic) {
return ntvfs_map_close(ntvfs, req, io);
}
- SETUP_FILE;
+ SETUP_FILE_HERE(f);
+ /* Note, we aren't free-ing f, or it's h here. Should we?
+ even if file-close fails, we'll remove it from the list,
+ what else would we do? Maybe we should not remove until
+ after the proxied call completes? */
+ DLIST_REMOVE(private->files, f);
if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) {
return smb_raw_close(private->tree, io);
diff --git a/source4/ntvfs/config.mk b/source4/ntvfs/config.mk
index 017614b7be..dbc1a4c277 100644
--- a/source4/ntvfs/config.mk
+++ b/source4/ntvfs/config.mk
@@ -1,8 +1,8 @@
# NTVFS Server subsystem
-include posix/config.mk
-include common/config.mk
-include unixuid/config.mk
-include sysdep/config.mk
+mkinclude posix/config.mk
+mkinclude common/config.mk
+mkinclude unixuid/config.mk
+mkinclude sysdep/config.mk
################################################
# Start MODULE ntvfs_cifs
diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c
index 81cd984f0b..92f0eadae1 100644
--- a/source4/ntvfs/ipc/vfs_ipc.c
+++ b/source4/ntvfs/ipc/vfs_ipc.c
@@ -322,7 +322,7 @@ static NTSTATUS ipc_open_smb2(struct ntvfs_module_context *ntvfs,
NT_STATUS_NOT_OK_RETURN(status);
oi->smb2.out.file.ntvfs = p->handle;
- oi->smb2.out.oplock_flags = oi->smb2.in.oplock_flags;
+ oi->smb2.out.oplock_level = oi->smb2.in.oplock_level;
oi->smb2.out.create_action = NTCREATEX_ACTION_EXISTED;
oi->smb2.out.create_time = 0;
oi->smb2.out.access_time = 0;
@@ -331,7 +331,7 @@ static NTSTATUS ipc_open_smb2(struct ntvfs_module_context *ntvfs,
oi->smb2.out.alloc_size = 4096;
oi->smb2.out.size = 0;
oi->smb2.out.file_attr = FILE_ATTRIBUTE_NORMAL;
- oi->smb2.out._pad = 0;
+ oi->smb2.out.reserved2 = 0;
oi->smb2.out.blob = data_blob(NULL, 0);
return status;
diff --git a/source4/ntvfs/ntvfs.h b/source4/ntvfs/ntvfs.h
index fe5f956426..a708dbff51 100644
--- a/source4/ntvfs/ntvfs.h
+++ b/source4/ntvfs/ntvfs.h
@@ -32,9 +32,11 @@ struct ntvfs_module_context;
struct ntvfs_request;
/* each backend has to be one one of the following 3 basic types. In
- * earlier versions of Samba backends needed to handle all types, now
- * we implement them separately. */
-enum ntvfs_type {NTVFS_DISK, NTVFS_PRINT, NTVFS_IPC};
+ earlier versions of Samba backends needed to handle all types, now
+ we implement them separately.
+ The values 1..3 match the SMB2 SMB2_SHARE_TYPE_* values
+ */
+enum ntvfs_type {NTVFS_DISK=1, NTVFS_IPC=2, NTVFS_PRINT=3};
/* the ntvfs operations structure - contains function pointers to
the backend implementations of each operation */
diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c
index 7708f4fc80..5092e732b4 100644
--- a/source4/ntvfs/ntvfs_generic.c
+++ b/source4/ntvfs/ntvfs_generic.c
@@ -208,7 +208,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs,
case RAW_OPEN_SMB2:
io->smb2.out.file.ntvfs = io2->generic.out.file.ntvfs;
- io->smb2.out.oplock_flags = 0;
+ io->smb2.out.oplock_level = 0;
io->smb2.out.create_action = io2->generic.out.create_action;
io->smb2.out.create_time = io2->generic.out.create_time;
io->smb2.out.access_time = io2->generic.out.access_time;
@@ -217,7 +217,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs,
io->smb2.out.alloc_size = io2->generic.out.alloc_size;
io->smb2.out.size = io2->generic.out.size;
io->smb2.out.file_attr = io2->generic.out.attrib;
- io->smb2.out._pad = 0;
+ io->smb2.out.reserved2 = 0;
io->smb2.out.blob = data_blob(NULL, 0);
break;
@@ -486,13 +486,13 @@ _PUBLIC_ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs,
case RAW_OPEN_SMB2:
io2->generic.in.flags = 0;
io2->generic.in.root_fid = 0;
- io2->generic.in.access_mask = io->smb2.in.access_mask;
+ io2->generic.in.access_mask = io->smb2.in.desired_access;
io2->generic.in.alloc_size = 0;
- io2->generic.in.file_attr = io->smb2.in.file_attr;
+ io2->generic.in.file_attr = io->smb2.in.file_attributes;
io2->generic.in.share_access = io->smb2.in.share_access;
- io2->generic.in.open_disposition= io->smb2.in.open_disposition;
+ io2->generic.in.open_disposition= io->smb2.in.create_disposition;
io2->generic.in.create_options = io->smb2.in.create_options;
- io2->generic.in.impersonation = io->smb2.in.impersonation;
+ io2->generic.in.impersonation = io->smb2.in.impersonation_level;
io2->generic.in.security_flags = 0;
io2->generic.in.fname = io->smb2.in.fname;
io2->generic.in.sec_desc = NULL;
diff --git a/source4/ntvfs/posix/config.mk b/source4/ntvfs/posix/config.mk
index 6588be11ae..6879940337 100644
--- a/source4/ntvfs/posix/config.mk
+++ b/source4/ntvfs/posix/config.mk
@@ -31,7 +31,7 @@ PRIVATE_DEPENDENCIES = LIBAIO_LINUX
# Start MODULE ntvfs_posix
[MODULE::ntvfs_posix]
SUBSYSTEM = ntvfs
-OUTPUT_TYPE = INTEGRATED
+OUTPUT_TYPE = MERGED_OBJ
INIT_FUNCTION = ntvfs_posix_init
PRIVATE_PROTO_HEADER = vfs_posix_proto.h
OBJ_FILES = \
diff --git a/source4/ntvfs/posix/pvfs_setfileinfo.c b/source4/ntvfs/posix/pvfs_setfileinfo.c
index 340913cd4d..9c78699edb 100644
--- a/source4/ntvfs/posix/pvfs_setfileinfo.c
+++ b/source4/ntvfs/posix/pvfs_setfileinfo.c
@@ -63,6 +63,11 @@ static uint32_t pvfs_setfileinfo_access(union smb_setfileinfo *info)
}
break;
+ case RAW_SFILEINFO_RENAME_INFORMATION:
+ case RAW_SFILEINFO_RENAME_INFORMATION_SMB2:
+ needed = SEC_STD_DELETE;
+ break;
+
default:
needed = SEC_FILE_WRITE_ATTRIBUTE;
break;
@@ -84,7 +89,8 @@ static NTSTATUS pvfs_setfileinfo_rename(struct pvfs_state *pvfs,
char *new_name, *p;
/* renames are only allowed within a directory */
- if (strchr_m(info->rename_information.in.new_name, '\\')) {
+ if (strchr_m(info->rename_information.in.new_name, '\\') &&
+ (req->ctx->protocol != PROTOCOL_SMB2)) {
return NT_STATUS_NOT_SUPPORTED;
}
@@ -98,24 +104,32 @@ static NTSTATUS pvfs_setfileinfo_rename(struct pvfs_state *pvfs,
return NT_STATUS_INVALID_PARAMETER;
}
- /* w2k3 does not appear to allow relative rename */
- if (info->rename_information.in.root_fid != 0) {
+ /* w2k3 does not appear to allow relative rename. On SMB2, vista sends it sometimes,
+ but I suspect it is just uninitialised memory */
+ if (info->rename_information.in.root_fid != 0 &&
+ (req->ctx->protocol != PROTOCOL_SMB2)) {
return NT_STATUS_INVALID_PARAMETER;
}
/* construct the fully qualified windows name for the new file name */
- new_name = talloc_strdup(req, name->original_name);
- if (new_name == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- p = strrchr_m(new_name, '\\');
- if (p == NULL) {
- return NT_STATUS_OBJECT_NAME_INVALID;
- }
- *p = 0;
+ if (req->ctx->protocol == PROTOCOL_SMB2) {
+ /* SMB2 sends the full path of the new name */
+ new_name = talloc_asprintf(req, "\\%s", info->rename_information.in.new_name);
+ } else {
+ new_name = talloc_strdup(req, name->original_name);
+ if (new_name == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ p = strrchr_m(new_name, '\\');
+ if (p == NULL) {
+ return NT_STATUS_OBJECT_NAME_INVALID;
+ } else {
+ *p = 0;
+ }
- new_name = talloc_asprintf(req, "%s\\%s", new_name,
- info->rename_information.in.new_name);
+ new_name = talloc_asprintf(req, "%s\\%s", new_name,
+ info->rename_information.in.new_name);
+ }
if (new_name == NULL) {
return NT_STATUS_NO_MEMORY;
}
@@ -369,6 +383,7 @@ NTSTATUS pvfs_setfileinfo(struct ntvfs_module_context *ntvfs,
break;
case RAW_SFILEINFO_RENAME_INFORMATION:
+ case RAW_SFILEINFO_RENAME_INFORMATION_SMB2:
return pvfs_setfileinfo_rename(pvfs, req, h->name,
info);
@@ -566,6 +581,7 @@ NTSTATUS pvfs_setpathinfo(struct ntvfs_module_context *ntvfs,
return NT_STATUS_OK;
case RAW_SFILEINFO_RENAME_INFORMATION:
+ case RAW_SFILEINFO_RENAME_INFORMATION_SMB2:
return pvfs_setfileinfo_rename(pvfs, req, name,
info);
diff --git a/source4/param/config.mk b/source4/param/config.mk
index 8ded5f1a13..c3f50b13fe 100644
--- a/source4/param/config.mk
+++ b/source4/param/config.mk
@@ -1,7 +1,4 @@
-[LIBRARY::LIBSAMBA-CONFIG]
-VERSION = 0.0.1
-SO_VERSION = 0
-PC_FILE = samba-config.pc
+[SUBSYSTEM::LIBSAMBA-CONFIG]
OBJ_FILES = loadparm.o \
params.o \
generic.o \
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index 9ec5a59d15..e850d82193 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -11,17 +11,17 @@
Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
Copyright (C) James Myers 2003 <myersjj@samba.org>
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/>.
*/
@@ -40,7 +40,7 @@
* 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
* 4) If it's a global then initialise it in init_globals. If a local
* (ie. service) parameter then initialise it in the sDefault structure
- *
+ *
*
* Notes:
* The configuration file is processed sequentially for speed. It is NOT
@@ -150,7 +150,7 @@ struct loadparm_global
char *socket_options;
int bWINSsupport;
int bWINSdnsProxy;
- char *szWINSHook;
+ char *szWINSHook;
int bLocalMaster;
int bPreferredMaster;
int bEncryptPasswords;
@@ -182,7 +182,7 @@ struct loadparm_global
/**
- * This structure describes a single service.
+ * This structure describes a single service.
*/
struct loadparm_service
{
@@ -228,28 +228,28 @@ struct loadparm_service sDefault = {
.szPath = NULL,
.szCopy = NULL,
.szInclude = NULL,
- .szPrintername = NULL,
- .szHostsallow = NULL,
- .szHostsdeny = NULL,
- .comment = NULL,
- .volume = NULL,
- .fstype = NULL,
- .ntvfs_handler = NULL,
- .iMaxPrintJobs = 1000,
- .iMaxConnections = 0,
- .iCSCPolicy = 0,
- .bAvailable = true,
- .bBrowseable = true,
- .bRead_only = true,
- .bPrint_ok = false,
- .bMap_system = false,
- .bMap_hidden = false,
- .bMap_archive = true,
- .bStrictLocking = true,
- .iCreate_mask = 0744,
+ .szPrintername = NULL,
+ .szHostsallow = NULL,
+ .szHostsdeny = NULL,
+ .comment = NULL,
+ .volume = NULL,
+ .fstype = NULL,
+ .ntvfs_handler = NULL,
+ .iMaxPrintJobs = 1000,
+ .iMaxConnections = 0,
+ .iCSCPolicy = 0,
+ .bAvailable = true,
+ .bBrowseable = true,
+ .bRead_only = true,
+ .bPrint_ok = false,
+ .bMap_system = false,
+ .bMap_hidden = false,
+ .bMap_archive = true,
+ .bStrictLocking = true,
+ .iCreate_mask = 0744,
.iCreate_force_mode = 0000,
- .iDir_mask = 0755,
- .iDir_force_mode = 0000,
+ .iDir_mask = 0755,
+ .iDir_force_mode = 0000,
.copymap = NULL,
.bMSDfsRoot = false,
.bStrictSync = false,
@@ -261,9 +261,9 @@ struct loadparm_context *global_loadparm = NULL;
#define NUMPARAMETERS (sizeof(parm_table) / sizeof(struct parm_struct))
/* prototypes for the special type handlers */
-static bool handle_include(struct loadparm_context *lp_ctx,
+static bool handle_include(struct loadparm_context *lp_ctx,
const char *pszParmValue, char **ptr);
-static bool handle_copy(struct loadparm_context *lp_ctx,
+static bool handle_copy(struct loadparm_context *lp_ctx,
const char *pszParmValue, char **ptr);
static bool handle_debuglevel(struct loadparm_context *lp_ctx,
const char *pszParmValue, char **ptr);
@@ -308,9 +308,9 @@ static const struct enum_list enum_bool_auto[] = {
};
/* Client-side offline caching policy types */
-enum csc_policy {
- CSC_POLICY_MANUAL=0,
- CSC_POLICY_DOCUMENTS=1,
+enum csc_policy {
+ CSC_POLICY_MANUAL=0,
+ CSC_POLICY_DOCUMENTS=1,
CSC_POLICY_PROGRAMS=2,
CSC_POLICY_DISABLE=3
};
@@ -397,12 +397,12 @@ static struct parm_struct parm_table[] = {
{"client lanman auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientLanManAuth), NULL, NULL},
{"client plaintext auth", P_BOOL, P_GLOBAL, GLOBAL_VAR(bClientPlaintextAuth), NULL, NULL},
{"client use spnego principal", P_BOOL, P_GLOBAL, GLOBAL_VAR(client_use_spnego_principal), NULL, NULL},
-
+
{"read only", P_BOOL, P_LOCAL, LOCAL_VAR(bRead_only), NULL, NULL},
- {"create mask", P_OCTAL, P_LOCAL, LOCAL_VAR(iCreate_mask), NULL, NULL},
+ {"create mask", P_OCTAL, P_LOCAL, LOCAL_VAR(iCreate_mask), NULL, NULL},
{"force create mode", P_OCTAL, P_LOCAL, LOCAL_VAR(iCreate_force_mode), NULL, NULL},
- {"directory mask", P_OCTAL, P_LOCAL, LOCAL_VAR(iDir_mask), NULL, NULL},
+ {"directory mask", P_OCTAL, P_LOCAL, LOCAL_VAR(iDir_mask), NULL, NULL},
{"force directory mode", P_OCTAL, P_LOCAL, LOCAL_VAR(iDir_force_mode), NULL, NULL},
{"hosts allow", P_LIST, P_LOCAL, LOCAL_VAR(szHostsallow), NULL, NULL},
@@ -411,7 +411,7 @@ static struct parm_struct parm_table[] = {
{"log level", P_INTEGER, P_GLOBAL, GLOBAL_VAR(debuglevel), handle_debuglevel, NULL},
{"debuglevel", P_INTEGER, P_GLOBAL, GLOBAL_VAR(debuglevel), handle_debuglevel, NULL},
{"log file", P_STRING, P_GLOBAL, GLOBAL_VAR(logfile), handle_logfile, NULL},
-
+
{"smb ports", P_LIST, P_GLOBAL, GLOBAL_VAR(smb_ports), NULL, NULL},
{"nbt port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(nbt_port), NULL, NULL},
{"dgram port", P_INTEGER, P_GLOBAL, GLOBAL_VAR(dgram_port), NULL, NULL},
@@ -435,7 +435,7 @@ static struct parm_struct parm_table[] = {
{"read raw", P_BOOL, P_GLOBAL, GLOBAL_VAR(bReadRaw), NULL, NULL},
{"write raw", P_BOOL, P_GLOBAL, GLOBAL_VAR(bWriteRaw), NULL, NULL},
{"disable netbios", P_BOOL, P_GLOBAL, GLOBAL_VAR(bDisableNetbios), NULL, NULL},
-
+
{"nt status support", P_BOOL, P_GLOBAL, GLOBAL_VAR(bNTStatusSupport), NULL, NULL},
{"announce version", P_STRING, P_GLOBAL, GLOBAL_VAR(szAnnounceVersion), NULL, NULL},
@@ -457,13 +457,13 @@ static struct parm_struct parm_table[] = {
{"paranoid server security", P_BOOL, P_GLOBAL, GLOBAL_VAR(paranoid_server_security), NULL, NULL},
{"socket options", P_STRING, P_GLOBAL, GLOBAL_VAR(socket_options), NULL, NULL},
- {"strict sync", P_BOOL, P_LOCAL, LOCAL_VAR(bStrictSync), NULL, NULL},
+ {"strict sync", P_BOOL, P_LOCAL, LOCAL_VAR(bStrictSync), NULL, NULL},
{"case insensitive filesystem", P_BOOL, P_LOCAL, LOCAL_VAR(bCIFileSystem), NULL, NULL},
{"max print jobs", P_INTEGER, P_LOCAL, LOCAL_VAR(iMaxPrintJobs), NULL, NULL},
{"printable", P_BOOL, P_LOCAL, LOCAL_VAR(bPrint_ok), NULL, NULL},
{"print ok", P_BOOL, P_LOCAL, LOCAL_VAR(bPrint_ok), NULL, NULL},
-
+
{"printer name", P_STRING, P_LOCAL, LOCAL_VAR(szPrintername), NULL, NULL},
{"printer", P_STRING, P_LOCAL, LOCAL_VAR(szPrintername), NULL, NULL},
@@ -483,7 +483,7 @@ static struct parm_struct parm_table[] = {
{"wins hook", P_STRING, P_GLOBAL, GLOBAL_VAR(szWINSHook), NULL, NULL},
{"csc policy", P_ENUM, P_LOCAL, LOCAL_VAR(iCSCPolicy), NULL, enum_csc_policy},
-
+
{"strict locking", P_BOOL, P_LOCAL, LOCAL_VAR(bStrictLocking), NULL, NULL},
{"share backend", P_STRING, P_GLOBAL, GLOBAL_VAR(szShareBackend), NULL, NULL},
@@ -495,11 +495,11 @@ static struct parm_struct parm_table[] = {
{"pid directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szPidDir), NULL, NULL},
{"js include", P_LIST, P_GLOBAL, GLOBAL_VAR(jsInclude), NULL, NULL},
{"setup directory", P_STRING, P_GLOBAL, GLOBAL_VAR(szSetupDir), NULL, NULL},
-
+
{"socket address", P_STRING, P_GLOBAL, GLOBAL_VAR(szSocketAddress), NULL, NULL},
{"copy", P_STRING, P_LOCAL, LOCAL_VAR(szCopy), handle_copy, NULL},
{"include", P_STRING, P_LOCAL, LOCAL_VAR(szInclude), handle_include, NULL},
-
+
{"available", P_BOOL, P_LOCAL, LOCAL_VAR(bAvailable), NULL, NULL},
{"volume", P_STRING, P_LOCAL, LOCAL_VAR(volume), NULL, NULL },
{"fstype", P_STRING, P_LOCAL, LOCAL_VAR(fstype), NULL, NULL},
@@ -547,7 +547,7 @@ struct parm_struct *lp_parm_table(void)
/**
* Convenience routine to grab string parameters into temporary memory
- * and run standard_sub_basic on them.
+ * and run standard_sub_basic on them.
*
* The buffers can be written to by
* callers without affecting the source string.
@@ -595,8 +595,8 @@ static const char *lp_string(const char *s)
}
/*
- In this section all the functions that are used to access the
- parameters from the rest of the program are defined
+ In this section all the functions that are used to access the
+ parameters from the rest of the program are defined
*/
#define FN_GLOBAL_STRING(fn_name,var_name) \
@@ -750,7 +750,7 @@ static int map_parameter(const char *pszParmName);
static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx,
const char *pszServiceName);
static void copy_service(struct loadparm_service *pserviceDest,
- struct loadparm_service *pserviceSource,
+ struct loadparm_service *pserviceSource,
int *pcopymapDest);
static bool service_ok(struct loadparm_service *service);
static bool do_section(const char *pszSectionName, void *);
@@ -759,8 +759,8 @@ static void init_copymap(struct loadparm_service *pservice);
/* This is a helper function for parametrical options support. */
/* It returns a pointer to parametrical option value if it exists or NULL otherwise */
/* Actual parametrical functions are quite simple */
-const char *lp_get_parametric(struct loadparm_context *lp_ctx,
- struct loadparm_service *service,
+const char *lp_get_parametric(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
const char *type, const char *option)
{
char *vfskey;
@@ -768,9 +768,9 @@ const char *lp_get_parametric(struct loadparm_context *lp_ctx,
if (lp_ctx == NULL)
return NULL;
-
+
data = (service == NULL ? lp_ctx->globals->param_opt : service->param_opt);
-
+
asprintf(&vfskey, "%s:%s", type, option);
strlower(vfskey);
@@ -785,7 +785,7 @@ const char *lp_get_parametric(struct loadparm_context *lp_ctx,
if (service != NULL) {
/* Try to fetch the same option but from globals */
/* but only if we are not already working with globals */
- for (data = lp_ctx->globals->param_opt; data;
+ for (data = lp_ctx->globals->param_opt; data;
data = data->next) {
if (strcmp(data->key, vfskey) == 0) {
free(vfskey);
@@ -795,7 +795,7 @@ const char *lp_get_parametric(struct loadparm_context *lp_ctx,
}
free(vfskey);
-
+
return NULL;
}
@@ -811,7 +811,7 @@ static int lp_int(const char *s)
return -1;
}
- return strtol(s, NULL, 0);
+ return strtol(s, NULL, 0);
}
/**
@@ -853,7 +853,7 @@ static bool lp_bool(const char *s)
DEBUG(0,("lp_bool(%s): is called with NULL!\n",s));
return false;
}
-
+
if (!set_boolean(s, &ret)) {
DEBUG(0,("lp_bool(%s): value is not boolean!\n",s));
return false;
@@ -866,11 +866,11 @@ static bool lp_bool(const char *s)
/**
* Return parametric option from a given service. Type is a part of option before ':'
* Parametric option has following syntax: 'Type: option = value'
- * Returned value is allocated in 'lp_talloc' context
+ * Returned value is allocated in 'lp_talloc' context
*/
-const char *lp_parm_string(struct loadparm_context *lp_ctx,
- struct loadparm_service *service, const char *type,
+const char *lp_parm_string(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
const char *option)
{
const char *value = lp_get_parametric(lp_ctx, service, type, option);
@@ -888,13 +888,13 @@ const char *lp_parm_string(struct loadparm_context *lp_ctx,
*/
const char **lp_parm_string_list(TALLOC_CTX *mem_ctx,
- struct loadparm_context *lp_ctx,
- struct loadparm_service *service,
- const char *type,
+ struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
+ const char *type,
const char *option, const char *separator)
{
const char *value = lp_get_parametric(lp_ctx, service, type, option);
-
+
if (value != NULL)
return str_list_make(mem_ctx, value, separator);
@@ -906,12 +906,12 @@ const char **lp_parm_string_list(TALLOC_CTX *mem_ctx,
* Parametric option has following syntax: 'Type: option = value'
*/
-int lp_parm_int(struct loadparm_context *lp_ctx,
- struct loadparm_service *service, const char *type,
+int lp_parm_int(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
const char *option, int default_v)
{
const char *value = lp_get_parametric(lp_ctx, service, type, option);
-
+
if (value)
return lp_int(value);
@@ -924,8 +924,8 @@ int lp_parm_int(struct loadparm_context *lp_ctx,
* Parametric option has following syntax: 'Type: option = value'.
*/
-int lp_parm_bytes(struct loadparm_context *lp_ctx,
- struct loadparm_service *service, const char *type,
+int lp_parm_bytes(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
const char *option, int default_v)
{
uint64_t bval;
@@ -942,16 +942,16 @@ int lp_parm_bytes(struct loadparm_context *lp_ctx,
}
/**
- * Return parametric option from a given service.
+ * Return parametric option from a given service.
* Type is a part of option before ':'
* Parametric option has following syntax: 'Type: option = value'
*/
-unsigned long lp_parm_ulong(struct loadparm_context *lp_ctx,
- struct loadparm_service *service, const char *type,
+unsigned long lp_parm_ulong(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
const char *option, unsigned long default_v)
{
const char *value = lp_get_parametric(lp_ctx, service, type, option);
-
+
if (value)
return lp_ulong(value);
@@ -959,12 +959,12 @@ unsigned long lp_parm_ulong(struct loadparm_context *lp_ctx,
}
-double lp_parm_double(struct loadparm_context *lp_ctx,
- struct loadparm_service *service, const char *type,
+double lp_parm_double(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
const char *option, double default_v)
{
const char *value = lp_get_parametric(lp_ctx, service, type, option);
-
+
if (value != NULL)
return lp_double(value);
@@ -976,12 +976,12 @@ double lp_parm_double(struct loadparm_context *lp_ctx,
* Parametric option has following syntax: 'Type: option = value'
*/
-bool lp_parm_bool(struct loadparm_context *lp_ctx,
- struct loadparm_service *service, const char *type,
+bool lp_parm_bool(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service, const char *type,
const char *option, bool default_v)
{
const char *value = lp_get_parametric(lp_ctx, service, type, option);
-
+
if (value != NULL)
return lp_bool(value);
@@ -995,7 +995,7 @@ bool lp_parm_bool(struct loadparm_context *lp_ctx,
static struct loadparm_service *init_service(TALLOC_CTX *mem_ctx)
{
- struct loadparm_service *pservice =
+ struct loadparm_service *pservice =
talloc_zero(mem_ctx, struct loadparm_service);
copy_service(pservice, &sDefault, NULL);
return pservice;
@@ -1009,7 +1009,7 @@ static bool string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
{
talloc_free(*dest);
- if (src == NULL)
+ if (src == NULL)
src = "";
*dest = talloc_strdup(mem_ctx, src);
@@ -1024,12 +1024,12 @@ static bool string_set(TALLOC_CTX *mem_ctx, char **dest, const char *src)
/**
- * Add a new service to the services array initialising it with the given
- * service.
+ * Add a new service to the services array initialising it with the given
+ * service.
*/
-struct loadparm_service *lp_add_service(struct loadparm_context *lp_ctx,
- const struct loadparm_service *pservice,
+struct loadparm_service *lp_add_service(struct loadparm_context *lp_ctx,
+ const struct loadparm_service *pservice,
const char *name)
{
int i;
@@ -1041,7 +1041,7 @@ struct loadparm_service *lp_add_service(struct loadparm_context *lp_ctx,
/* it might already exist */
if (name) {
- struct loadparm_service *service = getservicebyname(lp_ctx,
+ struct loadparm_service *service = getservicebyname(lp_ctx,
name);
if (service != NULL) {
/* Clean all parametric options for service */
@@ -1065,9 +1065,9 @@ struct loadparm_service *lp_add_service(struct loadparm_context *lp_ctx,
/* if not, then create one */
if (i == lp_ctx->iNumServices) {
struct loadparm_service **tsp;
-
+
tsp = talloc_realloc(lp_ctx, lp_ctx->services, struct loadparm_service *, num_to_alloc);
-
+
if (!tsp) {
DEBUG(0,("lp_add_service: failed to enlarge services!\n"));
return NULL;
@@ -1077,7 +1077,7 @@ struct loadparm_service *lp_add_service(struct loadparm_context *lp_ctx,
}
lp_ctx->iNumServices++;
- }
+ }
lp_ctx->services[i] = init_service(lp_ctx->services);
if (lp_ctx->services[i] == NULL) {
@@ -1091,12 +1091,12 @@ struct loadparm_service *lp_add_service(struct loadparm_context *lp_ctx,
}
/**
- * Add a new home service, with the specified home directory, defaults coming
+ * Add a new home service, with the specified home directory, defaults coming
* from service ifrom.
*/
-bool lp_add_home(struct loadparm_context *lp_ctx,
- const char *pszHomename,
+bool lp_add_home(struct loadparm_context *lp_ctx,
+ const char *pszHomename,
struct loadparm_service *default_service,
const char *user, const char *pszHomedir)
{
@@ -1120,9 +1120,9 @@ bool lp_add_home(struct loadparm_context *lp_ctx,
service->bAvailable = default_service->bAvailable;
service->bBrowseable = default_service->bBrowseable;
- DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n",
+ DEBUG(3, ("adding home's share [%s] for user '%s' at '%s'\n",
pszHomename, user, service->szPath));
-
+
return true;
}
@@ -1130,7 +1130,7 @@ bool lp_add_home(struct loadparm_context *lp_ctx,
* Add the IPC service.
*/
-static bool lp_add_hidden(struct loadparm_context *lp_ctx, const char *name,
+static bool lp_add_hidden(struct loadparm_context *lp_ctx, const char *name,
const char *fstype)
{
struct loadparm_service *service = lp_add_service(lp_ctx, &sDefault, name);
@@ -1140,7 +1140,7 @@ static bool lp_add_hidden(struct loadparm_context *lp_ctx, const char *name,
string_set(service, &service->szPath, tmpdir());
- service->comment = talloc_asprintf(service, "%s Service (%s)",
+ service->comment = talloc_asprintf(service, "%s Service (%s)",
fstype, lp_ctx->globals->szServerString);
string_set(service, &service->fstype, fstype);
service->iMaxConnections = -1;
@@ -1150,7 +1150,7 @@ static bool lp_add_hidden(struct loadparm_context *lp_ctx, const char *name,
service->bBrowseable = false;
if (strcasecmp(fstype, "IPC") == 0) {
- lp_do_service_parameter(lp_ctx, service, "ntvfs handler",
+ lp_do_service_parameter(lp_ctx, service, "ntvfs handler",
"default");
}
@@ -1164,7 +1164,7 @@ static bool lp_add_hidden(struct loadparm_context *lp_ctx, const char *name,
*/
bool lp_add_printer(struct loadparm_context *lp_ctx,
- const char *pszPrintername,
+ const char *pszPrintername,
struct loadparm_service *default_service)
{
const char *comment = "From Printcap";
@@ -1194,7 +1194,7 @@ bool lp_add_printer(struct loadparm_context *lp_ctx,
}
/**
- * Map a parameter's string representation to something we can use.
+ * Map a parameter's string representation to something we can use.
* Returns False if the parameter string is not recognised, else TRUE.
*/
@@ -1269,8 +1269,8 @@ static struct loadparm_service *getservicebyname(struct loadparm_context *lp_ctx
* If pcopymapDest is NULL then copy all fields
*/
-static void copy_service(struct loadparm_service *pserviceDest,
- struct loadparm_service *pserviceSource,
+static void copy_service(struct loadparm_service *pserviceDest,
+ struct loadparm_service *pserviceSource,
int *pcopymapDest)
{
int i;
@@ -1298,13 +1298,13 @@ static void copy_service(struct loadparm_service *pserviceDest,
break;
case P_STRING:
- string_set(pserviceDest,
+ string_set(pserviceDest,
(char **)dest_ptr,
*(char **)src_ptr);
break;
case P_USTRING:
- string_set(pserviceDest,
+ string_set(pserviceDest,
(char **)dest_ptr,
*(char **)src_ptr);
strupper(*(char **)dest_ptr);
@@ -1325,7 +1325,7 @@ static void copy_service(struct loadparm_service *pserviceDest,
(void *)pserviceSource->copymap,
sizeof(int) * NUMPARAMETERS);
}
-
+
data = pserviceSource->param_opt;
while (data) {
not_added = true;
@@ -1335,7 +1335,7 @@ static void copy_service(struct loadparm_service *pserviceDest,
/* If we already have same option, override it */
if (strcmp(pdata->key, data->key) == 0) {
talloc_free(pdata->value);
- pdata->value = talloc_reference(pdata,
+ pdata->value = talloc_reference(pdata,
data->value);
not_added = false;
break;
@@ -1392,11 +1392,11 @@ static bool service_ok(struct loadparm_service *service)
/*******************************************************************
- Keep a linked list of all config files so we know when one has changed
+ Keep a linked list of all config files so we know when one has changed
it's date and needs to be reloaded.
********************************************************************/
-static void add_to_file_list(struct loadparm_context *lp_ctx,
+static void add_to_file_list(struct loadparm_context *lp_ctx,
const char *fname, const char *subfname)
{
struct file_lists *f = lp_ctx->file_lists;
@@ -1466,7 +1466,7 @@ bool lp_file_list_changed(struct loadparm_context *lp_ctx)
Handle the include operation.
***************************************************************************/
-static bool handle_include(struct loadparm_context *lp_ctx,
+static bool handle_include(struct loadparm_context *lp_ctx,
const char *pszParmValue, char **ptr)
{
char *fname = standard_sub_basic(lp_ctx, pszParmValue);
@@ -1487,7 +1487,7 @@ static bool handle_include(struct loadparm_context *lp_ctx,
Handle the interpretation of the copy parameter.
***************************************************************************/
-static bool handle_copy(struct loadparm_context *lp_ctx,
+static bool handle_copy(struct loadparm_context *lp_ctx,
const char *pszParmValue, char **ptr)
{
bool bRetval;
@@ -1509,7 +1509,7 @@ static bool handle_copy(struct loadparm_context *lp_ctx,
bRetval = true;
}
} else {
- DEBUG(0, ("Unable to copy service - source not found: %s\n",
+ DEBUG(0, ("Unable to copy service - source not found: %s\n",
pszParmValue));
bRetval = false;
}
@@ -1517,7 +1517,7 @@ static bool handle_copy(struct loadparm_context *lp_ctx,
return bRetval;
}
-static bool handle_debuglevel(struct loadparm_context *lp_ctx,
+static bool handle_debuglevel(struct loadparm_context *lp_ctx,
const char *pszParmValue, char **ptr)
{
DEBUGLEVEL = atoi(pszParmValue);
@@ -1525,7 +1525,7 @@ static bool handle_debuglevel(struct loadparm_context *lp_ctx,
return true;
}
-static bool handle_logfile(struct loadparm_context *lp_ctx,
+static bool handle_logfile(struct loadparm_context *lp_ctx,
const char *pszParmValue, char **ptr)
{
logfile = pszParmValue;
@@ -1554,9 +1554,9 @@ static void init_copymap(struct loadparm_service *pservice)
/**
* Process a parametric option
*/
-static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
- struct loadparm_service *service,
- const char *pszParmName,
+static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
+ const char *pszParmName,
const char *pszParmValue, int flags)
{
struct param_opt *paramo, *data;
@@ -1611,18 +1611,18 @@ static bool lp_do_parameter_parametric(struct loadparm_context *lp_ctx,
}
free(name);
-
+
return true;
}
-static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
+static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
const char *pszParmName, const char *pszParmValue,
struct loadparm_context *lp_ctx)
{
int i;
/* if it is a special case then go ahead */
if (parm_table[parmnum].special) {
- parm_table[parmnum].special(lp_ctx, pszParmValue,
+ parm_table[parmnum].special(lp_ctx, pszParmValue,
(char **)parm_ptr);
return true;
}
@@ -1664,7 +1664,7 @@ static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
}
case P_LIST:
- *(const char ***)parm_ptr = str_list_make(mem_ctx,
+ *(const char ***)parm_ptr = str_list_make(mem_ctx,
pszParmValue, NULL);
break;
@@ -1710,7 +1710,7 @@ static bool set_variable(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr,
}
-bool lp_do_global_parameter(struct loadparm_context *lp_ctx,
+bool lp_do_global_parameter(struct loadparm_context *lp_ctx,
const char *pszParmName, const char *pszParmValue)
{
int parmnum = map_parameter(pszParmName);
@@ -1732,12 +1732,12 @@ bool lp_do_global_parameter(struct loadparm_context *lp_ctx,
parm_ptr = lp_parm_ptr(lp_ctx, NULL, &parm_table[parmnum]);
- return set_variable(lp_ctx, parmnum, parm_ptr,
+ return set_variable(lp_ctx, parmnum, parm_ptr,
pszParmName, pszParmValue, lp_ctx);
}
-bool lp_do_service_parameter(struct loadparm_context *lp_ctx,
- struct loadparm_service *service,
+bool lp_do_service_parameter(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
const char *pszParmName, const char *pszParmValue)
{
void *parm_ptr;
@@ -1769,14 +1769,14 @@ bool lp_do_service_parameter(struct loadparm_context *lp_ctx,
if (!service->copymap)
init_copymap(service);
- /* this handles the aliases - set the copymap for other
+ /* this handles the aliases - set the copymap for other
* entries with the same data pointer */
for (i = 0; parm_table[i].label; i++)
- if (parm_table[i].offset == parm_table[parmnum].offset &&
+ if (parm_table[i].offset == parm_table[parmnum].offset &&
parm_table[i].class == parm_table[parmnum].class)
service->copymap[i] = false;
- return set_variable(service, parmnum, parm_ptr, pszParmName,
+ return set_variable(service, parmnum, parm_ptr, pszParmName,
pszParmValue, lp_ctx);
}
@@ -1784,15 +1784,15 @@ bool lp_do_service_parameter(struct loadparm_context *lp_ctx,
* Process a parameter.
*/
-static bool do_parameter(const char *pszParmName, const char *pszParmValue,
+static bool do_parameter(const char *pszParmName, const char *pszParmValue,
void *userdata)
{
struct loadparm_context *lp_ctx = (struct loadparm_context *)userdata;
- if (lp_ctx->bInGlobalSection)
- return lp_do_global_parameter(lp_ctx, pszParmName,
+ if (lp_ctx->bInGlobalSection)
+ return lp_do_global_parameter(lp_ctx, pszParmName,
pszParmValue);
- else
+ else
return lp_do_service_parameter(lp_ctx, lp_ctx->currentService,
pszParmName, pszParmValue);
}
@@ -1801,14 +1801,14 @@ static bool do_parameter(const char *pszParmName, const char *pszParmValue,
variable argument do parameter
*/
bool lp_do_global_parameter_var(struct loadparm_context *lp_ctx, const char *pszParmName, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
-bool lp_do_global_parameter_var(struct loadparm_context *lp_ctx,
- const char *pszParmName, const char *fmt, ...)
+bool lp_do_global_parameter_var(struct loadparm_context *lp_ctx,
+ const char *pszParmName, const char *fmt, ...)
{
char *s;
bool ret;
va_list ap;
- va_start(ap, fmt);
+ va_start(ap, fmt);
s = talloc_vasprintf(NULL, fmt, ap);
va_end(ap);
ret = lp_do_global_parameter(lp_ctx, pszParmName, s);
@@ -1822,7 +1822,7 @@ bool lp_do_global_parameter_var(struct loadparm_context *lp_ctx,
parsing code. It sets the parameter then marks the parameter as unable to be modified
by smb.conf processing
*/
-bool lp_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
+bool lp_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
const char *pszParmValue)
{
int parmnum = map_parameter(pszParmName);
@@ -1833,7 +1833,7 @@ bool lp_set_cmdline(struct loadparm_context *lp_ctx, const char *pszParmName,
if (parmnum < 0 && strchr(pszParmName, ':')) {
/* set a parametric option */
- return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName,
+ return lp_do_parameter_parametric(lp_ctx, NULL, pszParmName,
pszParmValue, FLAG_CMDLINE);
}
@@ -1926,7 +1926,7 @@ static void print_parameter(struct parm_struct *p, void *ptr, FILE * f)
case P_LIST:
if ((char ***)ptr && *(char ***)ptr) {
char **list = *(char ***)ptr;
-
+
for (; *list; list++)
fprintf(f, "%s%s", *list,
((*(list+1))?", ":""));
@@ -1959,7 +1959,7 @@ static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
return (*((int *)ptr1) == *((int *)ptr2));
case P_LIST:
- return str_list_equal((const char **)(*(char ***)ptr1),
+ return str_list_equal((const char **)(*(char ***)ptr1),
(const char **)(*(char ***)ptr2));
case P_STRING:
@@ -1977,11 +1977,11 @@ static bool equal_parameter(parm_type type, void *ptr1, void *ptr2)
}
/**
- * Process a new section (service).
+ * Process a new section (service).
*
* At this stage all sections are services.
* Later we'll have special sections that permit server parameters to be set.
- * Returns True on success, False on failure.
+ * Returns True on success, False on failure.
*/
static bool do_section(const char *pszSectionName, void *userdata)
@@ -2013,7 +2013,7 @@ static bool do_section(const char *pszSectionName, void *userdata)
/* issued by the post-processing of a previous section. */
DEBUG(2, ("Processing section \"[%s]\"\n", pszSectionName));
- if ((lp_ctx->currentService = lp_add_service(lp_ctx, &sDefault,
+ if ((lp_ctx->currentService = lp_add_service(lp_ctx, &sDefault,
pszSectionName))
== NULL) {
DEBUG(0, ("Failed to add a new service\n"));
@@ -2059,12 +2059,12 @@ static bool is_default(int i)
*Display the contents of the global structure.
*/
-static void dump_globals(struct loadparm_context *lp_ctx, FILE *f,
+static void dump_globals(struct loadparm_context *lp_ctx, FILE *f,
bool show_defaults)
{
int i;
struct param_opt *data;
-
+
fprintf(f, "# Global parameters\n[global]\n");
for (i = 0; parm_table[i].label; i++)
@@ -2078,7 +2078,7 @@ static void dump_globals(struct loadparm_context *lp_ctx, FILE *f,
fprintf(f, "\n");
}
if (lp_ctx->globals->param_opt != NULL) {
- for (data = lp_ctx->globals->param_opt; data;
+ for (data = lp_ctx->globals->param_opt; data;
data = data->next) {
fprintf(f, "\t%s = %s\n", data->key, data->value);
}
@@ -2094,7 +2094,7 @@ static void dump_a_service(struct loadparm_service * pService, FILE * f)
{
int i;
struct param_opt *data;
-
+
if (pService != &sDefault)
fprintf(f, "\n[%s]\n", pService->szService);
@@ -2127,20 +2127,20 @@ static void dump_a_service(struct loadparm_service * pService, FILE * f)
}
}
-bool lp_dump_a_parameter(struct loadparm_context *lp_ctx,
- struct loadparm_service *service,
+bool lp_dump_a_parameter(struct loadparm_context *lp_ctx,
+ struct loadparm_service *service,
const char *parm_name, FILE * f)
{
struct parm_struct *parm;
void *ptr;
-
+
parm = lp_parm_struct(parm_name);
if (!parm) {
return false;
}
ptr = lp_parm_ptr(lp_ctx, service,parm);
-
+
print_parameter(parm, ptr, f);
fprintf(f, "\n");
return true;
@@ -2199,7 +2199,7 @@ struct parm_struct *lp_next_parameter(struct loadparm_context *lp_ctx, int snum,
/**
* Auto-load some home services.
*/
-static void lp_add_auto_services(struct loadparm_context *lp_ctx,
+static void lp_add_auto_services(struct loadparm_context *lp_ctx,
const char *str)
{
return;
@@ -2210,8 +2210,8 @@ static void lp_add_auto_services(struct loadparm_context *lp_ctx,
* Unload unused services.
*/
-void lp_killunused(struct loadparm_context *lp_ctx,
- struct smbsrv_connection *smb,
+void lp_killunused(struct loadparm_context *lp_ctx,
+ struct smbsrv_connection *smb,
bool (*snumused) (struct smbsrv_connection *, int))
{
int i;
@@ -2279,7 +2279,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
}
lp_do_global_parameter(lp_ctx, "share backend", "classic");
-
+
lp_do_global_parameter(lp_ctx, "server role", "standalone");
/* options that can be set on the command line must be initialised via
@@ -2315,7 +2315,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
data from the sam, but for the moment leave it in a tdb to
keep regedt32 from popping up an annoying dialog. */
lp_do_global_parameter(lp_ctx, "registry:HKEY_USERS", "hku.ldb");
-
+
/* using UTF8 by default allows us to support all chars */
lp_do_global_parameter(lp_ctx, "unix charset", "UTF8");
@@ -2333,10 +2333,10 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
lp_do_global_parameter(lp_ctx, "ncalrpc dir", dyn_NCALRPCDIR);
lp_do_global_parameter(lp_ctx, "socket address", "0.0.0.0");
- lp_do_global_parameter_var(lp_ctx, "server string",
+ lp_do_global_parameter_var(lp_ctx, "server string",
"Samba %s", SAMBA_VERSION_STRING);
- lp_do_global_parameter_var(lp_ctx, "announce version", "%d.%d",
+ lp_do_global_parameter_var(lp_ctx, "announce version", "%d.%d",
DEFAULT_MAJOR_VERSION,
DEFAULT_MINOR_VERSION);
@@ -2366,7 +2366,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
lp_do_global_parameter(lp_ctx, "LanmanAuth", "True");
lp_do_global_parameter(lp_ctx, "NTLMAuth", "True");
lp_do_global_parameter(lp_ctx, "client use spnego principal", "False");
-
+
lp_do_global_parameter(lp_ctx, "UnixExtensions", "False");
lp_do_global_parameter(lp_ctx, "PreferredMaster", "Auto");
@@ -2405,7 +2405,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
lp_do_global_parameter(lp_ctx, "tls certfile", "tls/cert.pem");
lp_do_global_parameter(lp_ctx, "tls cafile", "tls/ca.pem");
lp_do_global_parameter_var(lp_ctx, "js include", "%s", dyn_JSDIR);
- lp_do_global_parameter_var(lp_ctx, "setup directory", "%s",
+ lp_do_global_parameter_var(lp_ctx, "setup directory", "%s",
dyn_SETUPDIR);
lp_do_global_parameter(lp_ctx, "prefork children:smb", "4");
@@ -2430,7 +2430,7 @@ bool lp_load_default(struct loadparm_context *lp_ctx)
}
/**
- * Load the services array from the services file.
+ * Load the services array from the services file.
*
* Return True on success, False on failure.
*/
@@ -2442,11 +2442,11 @@ bool lp_load(struct loadparm_context *lp_ctx, const char *filename)
filename = talloc_strdup(lp_ctx, filename);
lp_ctx->szConfigFile = filename;
-
+
lp_ctx->bInGlobalSection = true;
n2 = standard_sub_basic(lp_ctx, lp_ctx->szConfigFile);
DEBUG(2, ("lp_load: refreshing parameters from %s\n", n2));
-
+
add_to_file_list(lp_ctx, lp_ctx->szConfigFile, n2);
/* We get sections first, so have to start 'behind' to make up */
@@ -2494,7 +2494,7 @@ int lp_numservices(struct loadparm_context *lp_ctx)
* Display the contents of the services array in human-readable form.
*/
-void lp_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
+void lp_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
int maxtoprint)
{
int iService;
@@ -2528,14 +2528,14 @@ struct loadparm_service *lp_servicebynum(struct loadparm_context *lp_ctx,
return lp_ctx->services[snum];
}
-struct loadparm_service *lp_service(struct loadparm_context *lp_ctx,
+struct loadparm_service *lp_service(struct loadparm_context *lp_ctx,
const char *service_name)
{
int iService;
char *serviceName;
for (iService = lp_ctx->iNumServices - 1; iService >= 0; iService--) {
- if (lp_ctx->services[iService] &&
+ if (lp_ctx->services[iService] &&
lp_ctx->services[iService]->szService) {
/*
* The substitution here is used to support %U is
@@ -2555,7 +2555,7 @@ struct loadparm_service *lp_service(struct loadparm_context *lp_ctx,
/**
- * A useful volume label function.
+ * A useful volume label function.
*/
const char *volume_label(struct loadparm_service *service)
{
@@ -2609,10 +2609,10 @@ _PUBLIC_ void reload_charcnv(struct loadparm_context *lp_ctx)
lp_ctx->iconv_convenience = smb_iconv_convenience_init_lp(lp_ctx, lp_ctx);
}
-void lp_smbcli_options(struct loadparm_context *lp_ctx,
+void lp_smbcli_options(struct loadparm_context *lp_ctx,
struct smbcli_options *options)
{
- options->max_xmit = lp_max_xmit(lp_ctx);
+ options->max_xmit = lp_max_xmit(lp_ctx);
options->max_mux = lp_maxmux(lp_ctx);
options->use_spnego = lp_nt_status_support(lp_ctx) && lp_use_spnego(lp_ctx);
options->signing = lp_client_signing(lp_ctx);
diff --git a/source4/pidl/config.mk b/source4/pidl/config.mk
new file mode 100644
index 0000000000..3793008319
--- /dev/null
+++ b/source4/pidl/config.mk
@@ -0,0 +1,36 @@
+pidl/Makefile: pidl/Makefile.PL
+ cd pidl && $(PERL) Makefile.PL
+
+pidl-testcov: pidl/Makefile
+ cd pidl && cover -test
+
+installpidl:: pidl/Makefile
+ $(MAKE) -C pidl install
+
+uninstallpidl:: pidl/Makefile
+ $(MAKE) -C pidl uninstall
+
+idl_full:: pidl/lib/Parse/Pidl/IDL.pm pidl/lib/Parse/Pidl/Expr.pm
+ @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh FULL
+
+idl:: pidl/lib/Parse/Pidl/IDL.pm pidl/lib/Parse/Pidl/Expr.pm
+ @CPP="$(CPP)" PERL="$(PERL)" srcdir=$(srcdir) $(srcdir)/script/build_idl.sh PARTIAL
+
+pidl/lib/Parse/Pidl/IDL.pm: pidl/idl.yp
+ -$(YAPP) -m 'Parse::Pidl::IDL' -o pidl/lib/Parse/Pidl/IDL.pm pidl/idl.yp ||\
+ touch pidl/lib/Parse/Pidl/IDL.pm
+
+pidl/lib/Parse/Pidl/Expr.pm: pidl/idl.yp
+ -$(YAPP) -m 'Parse::Pidl::Expr' -o pidl/lib/Parse/Pidl/Expr.pm pidl/expr.yp ||\
+ touch pidl/lib/Parse/Pidl/Expr.pm
+
+testcov-html:: pidl-testcov
+
+$(IDL_HEADER_FILES) \
+ $(IDL_NDR_PARSE_H_FILES) $(IDL_NDR_PARSE_C_FILES) \
+ $(IDL_NDR_CLIENT_C_FILES) $(IDL_NDR_CLIENT_H_FILES) \
+ $(IDL_NDR_SERVER_C_FILES) $(IDL_SWIG_FILES) \
+ $(IDL_NDR_EJS_C_FILES) $(IDL_NDR_EJS_H_FILES) \
+ $(IDL_NDR_PY_C_FILES) $(IDL_NDR_PY_H_FILES): idl
+
+
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm b/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
index ca9e7d15db..4af9da0f52 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
@@ -100,7 +100,7 @@ sub ParseFunction($$)
pidl "";
pidl "call = &ndr_table_$if->{NAME}.calls[$op];";
pidl "";
- pidl "r = talloc(NULL, struct $fn->{NAME});";
+ pidl "r = talloc(talloc_tos(), struct $fn->{NAME});";
pidl "if (r == NULL) {";
pidl "\treturn false;";
pidl "}";
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index 6e6d227681..ef3eb3dbcf 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -1611,7 +1611,7 @@ sub ParseUnionPushPrimitives($$$)
if ($el->{CASE} eq "default") {
$have_default = 1;
}
- $self->pidl("$el->{CASE}:");
+ $self->pidl("$el->{CASE}: {");
if ($el->{TYPE} ne "EMPTY") {
$self->indent;
@@ -1625,7 +1625,7 @@ sub ParseUnionPushPrimitives($$$)
$self->ParseElementPush($el, "ndr", {$el->{NAME} => "$varname->$el->{NAME}"}, 1, 0);
$self->deindent;
}
- $self->pidl("break;");
+ $self->pidl("break; }");
$self->pidl("");
}
if (! $have_default) {
@@ -2149,9 +2149,9 @@ sub ParseFunctionPull($$)
$self->pidl("NDR_PULL_ALLOC_N(ndr, r->out.$e->{NAME}, $size);");
if (grep(/in/, @{$e->{DIRECTION}})) {
- $self->pidl("memcpy(r->out.$e->{NAME}, r->in.$e->{NAME}, $size * sizeof(*r->in.$e->{NAME}));");
+ $self->pidl("memcpy(r->out.$e->{NAME}, r->in.$e->{NAME}, ($size) * sizeof(*r->in.$e->{NAME}));");
} else {
- $self->pidl("memset(r->out.$e->{NAME}, 0, $size * sizeof(*r->out.$e->{NAME}));");
+ $self->pidl("memset(r->out.$e->{NAME}, 0, ($size) * sizeof(*r->out.$e->{NAME}));");
}
} else {
$self->pidl("NDR_PULL_ALLOC(ndr, r->out.$e->{NAME});");
diff --git a/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm b/source4/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
index b53c56e741..5c37b4a0c4 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_FIELD> ett
+
+Register a custom ett field
+
=item I<STRIP_PREFIX> prefix
Remove the specified prefix from all function names (if present).
@@ -70,6 +74,10 @@ Change description for the specified header field. `field' is the hf name of the
Code to insert when generating the specified dissector. @HF@ and
@PARAM@ will be substituted.
+=item I<INCLUDE> filename
+
+Include conformance data from the specified filename in the dissector.
+
=item I<TFS> hf_name "true string" "false string"
Override the text shown when a bitmap boolean value is enabled or disabled.
@@ -313,6 +321,34 @@ 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);
+}
+
+sub handle_include
+{
+ my $pos = shift @_;
+ my $data = shift @_;
+ my $fn = shift @_;
+
+ unless(defined($fn)) {
+ error($pos, "incomplete INCLUDE command");
+ return;
+ }
+
+ ReadConformance($fn, $data);
+}
+
my %field_handlers = (
TYPE => \&handle_type,
NOEMIT => \&handle_noemit,
@@ -320,11 +356,13 @@ 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,
FIELD_DESCRIPTION => \&handle_fielddescription,
- IMPORT => \&handle_import
+ IMPORT => \&handle_import,
+ INCLUDE => \&handle_include
);
sub ReadConformance($$)
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) {
diff --git a/source4/pidl/tests/ndr_compat.pl b/source4/pidl/tests/ndr_compat.pl
index 11b585c118..355e7f6732 100755
--- a/source4/pidl/tests/ndr_compat.pl
+++ b/source4/pidl/tests/ndr_compat.pl
@@ -3,7 +3,7 @@
# Published under the GNU General Public License
use strict;
-use Test::More tests => 3;
+use Test::More tests => 2;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
diff --git a/source4/pidl/tests/wireshark-conf.pl b/source4/pidl/tests/wireshark-conf.pl
index d6fe3158aa..9da5c7d1ed 100755
--- a/source4/pidl/tests/wireshark-conf.pl
+++ b/source4/pidl/tests/wireshark-conf.pl
@@ -5,7 +5,7 @@
use strict;
use warnings;
-use Test::More tests => 47;
+use Test::More tests => 49;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
@@ -35,7 +35,6 @@ test_warnings("nofile:1: Unknown command `foobar'\n",
test_warnings("nofile:1: incomplete HF_RENAME command\n",
sub { parse_conf("HF_RENAME\n"); });
-
is_deeply(parse_conf("HF_RENAME foo bar\n")->{hf_renames}->{foo},
{ OLDNAME => "foo", NEWNAME => "bar", POS => {FILE => "nofile", LINE => 1}, USED => 0});
@@ -47,6 +46,9 @@ test_warnings("nofile:1: incomplete MANUAL command\n",
is_deeply(parse_conf("MANUAL foo\n"), { manual => {foo => 1}});
+test_errors("nofile:1: incomplete INCLUDE command\n",
+ sub { parse_conf("INCLUDE\n"); } );
+
test_warnings("nofile:1: incomplete FIELD_DESCRIPTION command\n",
sub { parse_conf("FIELD_DESCRIPTION foo\n"); });
@@ -164,6 +166,9 @@ test_errors("nofile:1: no dissectorname specified\n",
test_errors("nofile:1: incomplete HF_FIELD command\n",
sub { parse_conf("HF_FIELD hf_idx\n"); });
+test_errors("nofile:1: incomplete ETT_FIELD command\n",
+ sub { parse_conf("ETT_FIELD\n"); });
+
is_deeply(parse_conf("TYPE winreg_String dissect_myminregstring(); FT_STRING BASE_DEC 0 0 0 2\n"), {
types => {
winreg_String => {
diff --git a/source4/rpc_server/config.mk b/source4/rpc_server/config.mk
index d794b9470d..0032a867d1 100644
--- a/source4/rpc_server/config.mk
+++ b/source4/rpc_server/config.mk
@@ -108,7 +108,7 @@ PRIVATE_DEPENDENCIES = \
[MODULE::dcerpc_winreg]
INIT_FUNCTION = dcerpc_server_winreg_init
SUBSYSTEM = dcerpc_server
-OUTPUT_TYPE = INTEGRATED
+OUTPUT_TYPE = MERGED_OBJ
OBJ_FILES = \
winreg/rpc_winreg.o
PRIVATE_DEPENDENCIES = \
@@ -155,7 +155,7 @@ PRIVATE_DEPENDENCIES = \
[MODULE::dcerpc_spoolss]
INIT_FUNCTION = dcerpc_server_spoolss_init
SUBSYSTEM = dcerpc_server
-OUTPUT_TYPE = INTEGRATED
+OUTPUT_TYPE = MERGED_OBJ
OBJ_FILES = \
spoolss/dcesrv_spoolss.o
PRIVATE_DEPENDENCIES = \
diff --git a/source4/rules.mk b/source4/rules.mk
new file mode 100644
index 0000000000..b6a54fae25
--- /dev/null
+++ b/source4/rules.mk
@@ -0,0 +1,199 @@
+# Dependencies command
+DEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.o) -MT $@ \
+ $(CFLAGS) `$(PERL) $(srcdir)/script/cflags.pl $@` \
+ $(CPPFLAGS) $(FIRST_PREREQ) -o $@
+# Dependencies for host objects
+HDEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.ho) -MT $@ \
+ $(HOSTCC_FLAGS) `$(PERL) $(srcdir)/script/cflags.pl $@` \
+ $(CPPFLAGS) $(FIRST_PREREQ) -o $@
+# Dependencies for precompiled headers
+PCHDEPENDS = $(CC) -M -MG -MT include/includes.h.gch -MT $@ \
+ $(CFLAGS) $(CPPFLAGS) $(FIRST_PREREQ) -o $@
+
+# $< is broken in older BSD versions:
+# when $@ is foo/bar.o, $< could be torture/foo/bar.c
+# if it also exists. So better use $* which is foo/bar
+# and append .c manually to get foo/bar.c
+#
+# If we have GNU Make, it is safe to use $<, which also lets
+# building with $srcdir != $builddir work.
+
+# Run a static analysis checker
+CHECK = $(CC_CHECKER) $(CFLAGS) `$(PERL) $(srcdir)/script/cflags.pl $@` \
+ $(PICFLAG) $(CPPLAGS) -c $(FIRST_PREREQ) -o $@
+
+# Run the configured compiler
+COMPILE = $(CC) $(CFLAGS) $(PICFLAG) \
+ `$(PERL) $(srcdir)/script/cflags.pl $@` \
+ $(CPPFLAGS) \
+ -c $(FIRST_PREREQ) -o $@
+
+# Run the compiler for the build host
+HCOMPILE = $(HOSTCC) $(HOSTCC_FLAGS) `$(PERL) $(srcdir)/script/cflags.pl $@` \
+ $(CPPFLAGS) -c $(FIRST_PREREQ) -o $@
+
+# Precompile headers
+PCHCOMPILE = @$(CC) -Ilib/replace \
+ $(CFLAGS) `$(PERL) $(srcdir)/script/cflags.pl $@` \
+ $(PICFLAG) $(CPPFLAGS) -c $(FIRST_PREREQ) -o $@
+
+# Partial linking
+PARTLINK = @$(PROG_LD) -r
+
+include/config.h:
+ @echo "include/config.h not present"
+ @echo "You need to rerun ./autogen.sh and ./configure"
+ @/bin/false
+
+$(srcdir)/version.h: $(srcdir)/VERSION
+ @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
+
+regen_version::
+ @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
+
+clean_pch::
+ @echo "Removing precompiled headers"
+ @-rm -f include/includes.h.gch
+
+pch:: clean_pch include/includes.h.gch
+
+clean:: clean_pch
+ @echo Removing objects
+ @-find . -name '*.o' -exec rm -f '{}' \;
+ @echo Removing hostcc objects
+ @-find . -name '*.ho' -exec rm -f '{}' \;
+ @echo Removing binaries
+ @-rm -f $(BIN_PROGS) $(SBIN_PROGS) $(BINARIES) $(TORTURE_PROGS)
+ @echo Removing libraries
+ @-rm -f $(STATIC_LIBRARIES) $(SHARED_LIBRARIES)
+ @-rm -f bin/static/*.a bin/shared/*.$(SHLIBEXT) bin/mergedobj/*.o
+ @echo Removing modules
+ @-rm -f bin/modules/*/*.$(SHLIBEXT)
+ @-rm -f bin/*_init_module.c
+ @echo Removing dummy targets
+ @-rm -f bin/.*_*
+ @echo Removing generated files
+ @-rm -f bin/*_init_module.c
+ @-rm -rf librpc/gen_*
+ @echo Removing proto headers
+ @-rm -f $(PROTO_HEADERS)
+
+distclean:: clean
+ -rm -f include/config.h include/config_tmp.h include/build.h
+ -rm -f data.mk
+ -rm -f config.status
+ -rm -f config.log config.cache
+ -rm -f config.pm config.mk
+ -rm -f $(PC_FILES)
+
+removebackup::
+ -rm -f *.bak *~ */*.bak */*~ */*/*.bak */*/*~ */*/*/*.bak */*/*/*~
+
+realdistclean:: distclean removebackup
+ -rm -f include/config_tmp.h.in
+ -rm -f version.h
+ -rm -f configure
+ -rm -f $(MANPAGES)
+
+check:: test
+
+unused_macros:
+ $(srcdir)/script/find_unused_macros.pl `find . -name "*.[ch]"` | sort
+
+###############################################################################
+# File types
+###############################################################################
+
+.SUFFIXES: .x .c .et .y .l .d .o .h .h.gch .a .$(SHLIBEXT) .1 .1.xml .3 .3.xml .5 .5.xml .7 .7.xml .8 .8.xml .ho .idl .hd
+
+.c.d:
+ @echo "Generating dependencies for $<"
+ @$(DEPENDS)
+
+.c.hd:
+ @echo "Generating host-compiler dependencies for $<"
+ @$(HDEPENDS)
+
+include/includes.d: include/includes.h
+ @echo "Generating dependencies for $<"
+ @$(PCHDEPENDS)
+
+.c.o:
+ @if test -n "$(CC_CHECKER)"; then \
+ echo "Checking $< with '$(CC_CHECKER)'"; \
+ $(CHECK) ; \
+ fi
+ @echo "Compiling $<"
+ @-mkdir -p `dirname $@`
+ @$(COMPILE) && exit 0 ; \
+ echo "The following command failed:" 1>&2;\
+ echo "$(COMPILE)" 1>&2;\
+ $(COMPILE) >/dev/null 2>&1
+
+.c.ho:
+ @echo "Compiling $< with host compiler"
+ @-mkdir -p `dirname $@`
+ @$(HCOMPILE) && exit 0;\
+ echo "The following command failed:" 1>&2;\
+ echo "$(HCOMPILE)" 1>&2;\
+ $(HCOMPILE) >/dev/null 2>&1
+
+.h.h.gch:
+ @echo "Precompiling $<"
+ @$(PCHCOMPILE)
+
+.y.c:
+ @echo "Building $< with $(YACC)"
+ @-$(srcdir)/script/yacc_compile.sh "$(YACC)" "$<" "$@"
+
+.l.c:
+ @echo "Building $< with $(LEX)"
+ @-$(srcdir)/script/lex_compile.sh "$(LEX)" "$<" "$@"
+
+DOCBOOK_MANPAGE_URL = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
+
+.1.xml.1:
+ $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
+
+.3.xml.3:
+ $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
+
+.5.xml.5:
+ $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
+
+.7.xml.7:
+ $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
+
+.8.xml.8:
+ $(XSLTPROC) -o $@ $(DOCBOOK_MANPAGE_URL) $<
+
+DEP_FILES = $(patsubst %.ho,%.hd,$(patsubst %.o,%.d,$(ALL_OBJS))) \
+ include/includes.d
+
+dist:: idl_full manpages configure distclean
+
+configure:
+ ./autogen.sh
+
+showflags::
+ @echo 'Samba will be compiled with flags:'
+ @echo ' CPP = $(CPP)'
+ @echo ' CPPFLAGS = $(CPPFLAGS)'
+ @echo ' CC = $(CC)'
+ @echo ' CFLAGS = $(CFLAGS)'
+ @echo ' PICFLAG = $(PICFLAG)'
+ @echo ' BNLD = $(BNLD)'
+ @echo ' BNLD_FLAGS = $(BNLD_FLAGS)'
+ @echo ' STLD = $(STLD)'
+ @echo ' STLD_FLAGS = $(STLD_FLAGS)'
+ @echo ' SHLD = $(SHLD)'
+ @echo ' SHLD_FLAGS = $(SHLD_FLAGS)'
+ @echo ' MDLD = $(MDLD)'
+ @echo ' MDLD_FLAGS = $(MDLD_FLAGS)'
+ @echo ' SHLIBEXT = $(SHLIBEXT)'
+
+etags:
+ etags `find $(srcdir) -name "*.[ch]"`
+
+ctags:
+ ctags `find $(srcdir) -name "*.[ch]"`
diff --git a/source4/samba4-knownfail b/source4/samba4-knownfail
index b1b2140fec..651111221f 100644
--- a/source4/samba4-knownfail
+++ b/source4/samba4-knownfail
@@ -1,36 +1,39 @@
-LOCAL-RESOLVE.*.async
-LOCAL-ICONV.*.next_codepoint()
-BASE-DELAYWRITE.finfo update on close
-BASE-DELETE.*.deltest20a
-BASE-DELETE.*.deltest20b
-RAW-OPLOCK.*.OPLOCK
-RPC-WINREG
-LOCAL-REGISTRY.*.security # Not implemented yet
-RPC-WKSSVC
-RPC-HANDLES.*.lsarpc-shared
-RPC-HANDLES.*.mixed-shared
-RPC-EPMAPPER.*.Insert
-RPC-EPMAPPER.*.InqObject
-RPC-DFS.*
-RPC-DRSUAPI.*
-RPC-LSALOOKUP
-RPC-CRACKNAMES
-RPC-NETLOGON.*.LogonUasLogon
-RPC-NETLOGON.*.LogonUasLogoff
-RPC-NETLOGON.*.DatabaseSync
-RPC-NETLOGON.*.DatabaseSync2
-RPC-NETLOGON.*.GetDcName
-RPC-NETLOGON.*.LogonControl
-RPC-NETLOGON.*.LogonControl2
-RPC-NETLOGON.*.GetAnyDCName
-RPC-NETLOGON.*.DsrEnumerateDomainTrusts
-RPC-NETLOGON.*.NetrEnumerateTrustedDomains
-RPC-NETLOGON.*.NetrEnumerateTrustedDomainsEx
-RPC-NETLOGON.*.DsrGetDcSiteCoverageW
-RPC-NETLOGON.*.DsRAddressToSitenamesW
-RPC-NETLOGON.*.DsRAddressToSitenamesExW
-RPC-NETLOGON.*.GetPassword
-RPC-NETLOGON.*.GetTrustPasswords
-BASE-CHARSET.*.Testing partial surrogate
-.*NET-API-DELSHARE.* # DelShare isn't implemented yet
-RAP.*netservergetinfo
+local.resolve.*.async
+local.iconv.*.next_codepoint()
+base.delaywrite.finfo update on close
+base.delete.*.deltest20a
+base.delete.*.deltest20b
+raw.oplock.*.OPLOCK
+rpc.winreg
+local.registry.*.security # Not implemented yet
+rpc.wkssvc
+rpc.handles.*.lsarpc-shared
+rpc.handles.*.mixed-shared
+rpc.epmapper.*.Insert
+rpc.epmapper.*.InqObject
+rpc.dfs.*
+rpc.drsuapi.*
+rpc.lsalookup
+rpc.cracknames
+rpc.netlogon.*.LogonUasLogon
+rpc.netlogon.*.LogonUasLogoff
+rpc.netlogon.*.DatabaseSync
+rpc.netlogon.*.DatabaseSync2
+rpc.netlogon.*.GetDcName
+rpc.netlogon.*.LogonControl
+rpc.netlogon.*.LogonControl2
+rpc.netlogon.*.GetAnyDCName
+rpc.netlogon.*.DsrEnumerateDomainTrusts
+rpc.netlogon.*.NetrEnumerateTrustedDomains
+rpc.netlogon.*.NetrEnumerateTrustedDomainsEx
+rpc.netlogon.*.DsrGetDcSiteCoverageW
+rpc.netlogon.*.DsRAddressToSitenamesW
+rpc.netlogon.*.DsRAddressToSitenamesExW
+rpc.netlogon.*.GetPassword
+rpc.netlogon.*.GetTrustPasswords
+base.charset.*.Testing partial surrogate
+.*net.api.delshare.* # DelShare isn't implemented yet
+rap.*netservergetinfo
+kinit with pkinit # fails with: salt type 3 not supported
+samba4.blackbox.provision.py.reprovision # Fails with entry already exists
+local.torture.provision
diff --git a/source4/samba4-quick b/source4/samba4-quick
index 796435ee16..aec9098854 100644
--- a/source4/samba4-quick
+++ b/source4/samba4-quick
@@ -1,32 +1,32 @@
-BASE-UNLINK
-BASE-ATTR
-BASE-DELETE
-BASE-TCON
-BASE-OPEN
-BASE-CHKPATH
-RAW-QFSINFO
-RAW-QFILEINFO
-RAW-SFILEINFO
-RAW-MKDIR
-RAW-SEEK
-RAW-OPEN
-RAW-WRITE
-RAW-UNLINK
-RAW-READ
-RAW-CLOSE
-RAW-IOCTL
-RAW-RENAME
-RAW-EAS
-RAW-STREAMS
-BASE-OPEN
-RPC-ALTERCONTEXT
-RPC-JOIN
-RPC-ECHO
-RPC-SCHANNEL
-RPC-NETLOGON
-RPC-UNIXINFO
-RPC-HANDLES
-RPC-ALTERCONTEXT
-RPC-JOIN
-RPC-HANDLES
-RPC-ECHO
+base.unlink
+base.attr
+base.delete
+base.tcon
+base.open
+base.chkpath
+raw.qfsinfo
+raw.qfileinfo
+raw.sfileinfo
+raw.mkdir
+raw.seek
+raw.open
+raw.write
+raw.unlink
+raw.read
+raw.close
+raw.ioctl
+raw.rename
+raw.eas
+raw.streams
+base.open
+rpc.altercontext
+rpc.join
+rpc.echo
+rpc.schannel
+rpc.netlogon
+rpc.unixinfo
+rpc.handles
+rpc.altercontext
+rpc.join
+rpc.handles
+rpc.echo
diff --git a/source4/samba4-skip b/source4/samba4-skip
index b53f444c9c..e3d2b182d1 100644
--- a/source4/samba4-skip
+++ b/source4/samba4-skip
@@ -1,53 +1,54 @@
-BASE-DEFER_OPEN
-BASE-DELAYWRITE
-RAW-COMPOSITE
-RAW-OPLOCK
-BASE-IOMETER
-BASE-CASETABLE
-BASE-NTTRANS
-.*BASE-BENCH-HOLDCON.* # Very slow
-BASE-SCAN-MAXFID
-RAW-BENCH-OPLOCK
-RAW-HOLD-OPLOCK
-RAW-PING-PONG
-RPC-SAMR_ACCESSMASK
-RAW-SCAN-EAMAX
-RAW-QFILEINFO-IPC
-BASE-UTABLE
-BASE-SMB
-SMB2-NOTIFY
-SMB2-SCAN
-ntvfs.cifs.BASE-CHARSET
-ntvfs.cifs.BASE-DEFER_OPEN
-ntvfs.cifs.BASE-DELAYWRITE
-ntvfs.cifs.BASE-IOMETER
-ntvfs.cifs.BASE-CASETABLE
-ntvfs.cifs.BASE-NTTRANS
-ntvfs.cifs.BASE-SCAN-MAXFID
-ntvfs.cifs.BASE-UTABLE
-ntvfs.cifs.BASE-SMB
-ntvfs.cifs.RAW-COMPOSITE
-ntvfs.cifs.RAW-OPLOCK
-ntvfs.cifs.RAW-NOTIFY
-ntvfs.cifs.RAW-BENCH-OPLOCK
-ntvfs.cifs.RAW-SCAN-EAMAX
-ntvfs.cifs.RAW-CONTEXT
-ntvfs.cifs.RAW-QFILEINFO-IPC
-RPC-DSSYNC
-RPC-SAMSYNC
-LDAP-UPTODATEVECTOR # Segfaults
-RPC-SCANNER # Very slow
-RPC-REMACT # Not provided by Samba 4
-RPC-OXIDRESOLVE # Not provided by Samba 4
-RPC-EVENTLOG # Not provided by Samba 4
-RPC-INITSHUTDOWN # Not provided by Samba 4
-RPC-SVCCTL # Not provided by Samba 4
-RPC-ATSVC # Not provided by Samba 4
-RPC-FRSAPI # Not provided by Samba 4
-.*SAMBA3.* # Samba3-specific test
-^samba4.NET-DOMOPEN.*$ # Hangs for some reason
-^samba4.NET-API-BECOME-DC.*$ # Fails
-WINBIND # FIXME: This should not be skipped
-NSS-TEST # Fails
+base.defer_open
+base.delaywrite
+raw.composite
+raw.oplock
+base.iometer
+base.casetable
+base.nttrans
+.*base.bench.holdcon.* # Very slow
+base.scan.maxfid
+raw.bench.oplock
+raw.hold.oplock
+raw.ping.pong
+rpc.samr_accessmask
+raw.scan.eamax
+raw.qfileinfo.ipc
+base.utable
+base.smb
+smb2.notify
+smb2.scan
+ntvfs.cifs.base.charset
+ntvfs.cifs.base.defer_open
+ntvfs.cifs.base.delaywrite
+ntvfs.cifs.base.iometer
+ntvfs.cifs.base.casetable
+ntvfs.cifs.base.nttrans
+ntvfs.cifs.base.scan-maxfid
+ntvfs.cifs.base.utable
+ntvfs.cifs.base.smb
+ntvfs.cifs.raw.composite
+ntvfs.cifs.raw.oplock
+ntvfs.cifs.raw.notify
+ntvfs.cifs.raw.bench-oplock
+ntvfs.cifs.raw.scan-eamax
+ntvfs.cifs.raw.context
+ntvfs.cifs.raw.qfileinfo.ipc
+rpc.dssync
+rpc.samsync
+ldap.uptodatevector # Segfaults
+rpc.scanner # Very slow
+rpc.remact # Not provided by Samba 4
+rpc.oxidresolve # Not provided by Samba 4
+rpc.eventlog # Not provided by Samba 4
+rpc.initshutdown # Not provided by Samba 4
+rpc.svcctl # Not provided by Samba 4
+rpc.atsvc # Not provided by Samba 4
+rpc.frsapi # Not provided by Samba 4
+.*samba3.* # Samba3-specific test
+^samba4.net.domopen.*$ # Hangs for some reason
+^samba4.net.api.become.dc.*$ # Fails
+winbind # FIXME: This should not be skipped
+nss.test # Fails
samba4.samba3sam.python # Conversion from EJS not yet finished
-RAW-OFFLINE # Samba 4 doesn't have much offline support yet
+samba4.samdb.python # Not finished yet
+raw.offline # Samba 4 doesn't have much offline support yet
diff --git a/source4/script/cflags.pl b/source4/script/cflags.pl
index 7f435d46f5..37b5aa7e71 100755
--- a/source4/script/cflags.pl
+++ b/source4/script/cflags.pl
@@ -8,20 +8,35 @@ use strict;
my $target = shift;
-sub check_flags($)
+my $vars = {};
+
+sub check_flags($$);
+sub check_flags($$)
{
- my ($name)=@_;
- open (IN, "extra_cflags.txt");
- while (<IN> =~ /^([^:]+): (.*)$/) {
- next unless (grep(/^$target$/, (split / /, $1)));
- $_ = $2;
- s/^CFLAGS\+=//;
- print "$_ ";
+ my ($path, $name)=@_;
+ open (IN, $path);
+ foreach my $line (<IN>) {
+ if ($line =~ /^include (.*)$/) {
+ check_flags($1, $name);
+ } elsif ($line =~ /^([A-Za-z0-9_]+) =(.*)$/) {
+ $vars->{$1} = $2;
+ } elsif ($line =~ /^([^:]+): (.*)$/) {
+ next unless (grep(/^$target$/, (split / /, $1)));
+ my $data = $2;
+ $data =~ s/^CFLAGS\+=//;
+ foreach my $key (keys %$vars) {
+ my $val = $vars->{$key};
+ $data =~ s/\$\($key\)/$val/g;
+ }
+ # Remove undefined variables
+ $data =~ s/\$\([A-Za-z0-9_]+\)//g;
+ print "$data ";
+ }
}
close(IN);
- print "\n";
}
-check_flags($target);
+check_flags("extra_cflags.txt", $target);
+print "\n";
exit 0;
diff --git a/source4/scripting/bin/minschema.py b/source4/scripting/bin/minschema.py
new file mode 100755
index 0000000000..fb9d7b05aa
--- /dev/null
+++ b/source4/scripting/bin/minschema.py
@@ -0,0 +1,579 @@
+#!/usr/bin/python
+#
+# work out the minimal schema for a set of objectclasses
+#
+
+import optparse
+import samba
+from samba import getopt as options
+import sys
+
+parser = optparse.OptionParser("minschema <URL> <classfile>")
+sambaopts = options.SambaOptions(parser)
+parser.add_option_group(sambaopts)
+credopts = options.CredentialsOptions(parser)
+parser.add_option_group(credopts)
+parser.add_option_group(options.VersionOptions(parser))
+parser.add_option("--verbose", help="Be verbose", action="store_true")
+parser.add_option("--dump-classes", action="store_true")
+parser.add_option("--dump-attributes", action="store_true")
+parser.add_option("--dump-subschema", action="store_true")
+parser.add_option("--dump-subschema-auto", action="store_true")
+
+opts, args = parser.parse_args()
+opts.dump_all = True
+
+if opts.dump_classes:
+ opts.dump_all = False
+if opts.dump_attributes:
+ opts.dump_all = False
+if opts.dump_subschema:
+ opts.dump_all = False
+if opts.dump_subschema_auto:
+ opts.dump_all = False
+ opts.dump_subschema = True
+if opts.dump_all:
+ opts.dump_classes = True
+ opts.dump_attributes = True
+ opts.dump_subschema = True
+ opts.dump_subschema_auto = True
+
+if len(args) != 2:
+ parser.print_usage()
+ sys.exit(1)
+
+(url, classfile) = args
+
+creds = credopts.get_credentials()
+ldb = Ldb(url, credentials=creds)
+
+objectclasses = []
+attributes = []
+
+objectclasses_expanded = set()
+
+# the attributes we need for objectclasses
+class_attrs = ["objectClass",
+ "subClassOf",
+ "governsID",
+ "possSuperiors",
+ "possibleInferiors",
+ "mayContain",
+ "mustContain",
+ "auxiliaryClass",
+ "rDNAttID",
+ "showInAdvancedViewOnly",
+ "adminDisplayName",
+ "adminDescription",
+ "objectClassCategory",
+ "lDAPDisplayName",
+ "schemaIDGUID",
+ "systemOnly",
+ "systemPossSuperiors",
+ "systemMayContain",
+ "systemMustContain",
+ "systemAuxiliaryClass",
+ "defaultSecurityDescriptor",
+ "systemFlags",
+ "defaultHidingValue",
+ "objectCategory",
+ "defaultObjectCategory",
+
+ # this attributes are not used by w2k3
+ "schemaFlagsEx",
+ "msDs-IntId",
+ "msDs-Schema-Extensions",
+ "classDisplayName",
+ "isDefunct"]
+
+attrib_attrs = ["objectClass",
+ "attributeID",
+ "attributeSyntax",
+ "isSingleValued",
+ "rangeLower",
+ "rangeUpper",
+ "mAPIID",
+ "linkID",
+ "showInAdvancedViewOnly",
+ "adminDisplayName",
+ "oMObjectClass",
+ "adminDescription",
+ "oMSyntax",
+ "searchFlags",
+ "extendedCharsAllowed",
+ "lDAPDisplayName",
+ "schemaIDGUID",
+ "attributeSecurityGUID",
+ "systemOnly",
+ "systemFlags",
+ "isMemberOfPartialAttributeSet",
+ "objectCategory",
+
+ # this attributes are not used by w2k3
+ "schemaFlagsEx",
+ "msDs-IntId",
+ "msDs-Schema-Extensions",
+ "classDisplayName",
+ "isEphemeral",
+ "isDefunct"]
+
+#
+# notes:
+#
+# objectClassCategory
+# 1: structural
+# 2: abstract
+# 3: auxiliary
+
+#
+# print only if verbose is set
+#
+def dprintf(text):
+ if verbose is not None:
+ print text
+
+def get_object_cn(ldb, name):
+ attrs = ["cn"]
+
+ res = ldb.search("(ldapDisplayName=%s)" % name, rootDse["schemaNamingContext"], ldb.SCOPE_SUBTREE, attrs)
+ assert len(res) == 1
+
+ return res[0]["cn"]
+
+class Objectclass:
+ def __init__(self, ldb, name):
+ """create an objectclass object"""
+ self.name = name
+ self.cn = get_object_cn(ldb, name)
+
+
+class Attribute:
+ def __init__(self, ldb, name):
+ """create an attribute object"""
+ self.name = name
+ self.cn = get_object_cn(ldb, name)
+
+
+syntaxmap = dict()
+
+syntaxmap['2.5.5.1'] = '1.3.6.1.4.1.1466.115.121.1.12'
+syntaxmap['2.5.5.2'] = '1.3.6.1.4.1.1466.115.121.1.38'
+syntaxmap['2.5.5.3'] = '1.2.840.113556.1.4.1362'
+syntaxmap['2.5.5.4'] = '1.2.840.113556.1.4.905'
+syntaxmap['2.5.5.5'] = '1.3.6.1.4.1.1466.115.121.1.26'
+syntaxmap['2.5.5.6'] = '1.3.6.1.4.1.1466.115.121.1.36'
+syntaxmap['2.5.5.7'] = '1.2.840.113556.1.4.903'
+syntaxmap['2.5.5.8'] = '1.3.6.1.4.1.1466.115.121.1.7'
+syntaxmap['2.5.5.9'] = '1.3.6.1.4.1.1466.115.121.1.27'
+syntaxmap['2.5.5.10'] = '1.3.6.1.4.1.1466.115.121.1.40'
+syntaxmap['2.5.5.11'] = '1.3.6.1.4.1.1466.115.121.1.24'
+syntaxmap['2.5.5.12'] = '1.3.6.1.4.1.1466.115.121.1.15'
+syntaxmap['2.5.5.13'] = '1.3.6.1.4.1.1466.115.121.1.43'
+syntaxmap['2.5.5.14'] = '1.2.840.113556.1.4.904'
+syntaxmap['2.5.5.15'] = '1.2.840.113556.1.4.907'
+syntaxmap['2.5.5.16'] = '1.2.840.113556.1.4.906'
+syntaxmap['2.5.5.17'] = '1.3.6.1.4.1.1466.115.121.1.40'
+
+
+def map_attribute_syntax(s):
+ """map some attribute syntaxes from some apparently MS specific
+ syntaxes to the standard syntaxes"""
+ if syntaxmap.has_key(s):
+ return syntaxmap[s]
+ return s
+
+
+def fix_dn(dn):
+ """fix a string DN to use ${SCHEMADN}"""
+ return dn.replace(rootDse["schemaNamingContext"], "${SCHEMADN}")
+
+
+def write_ldif_one(o, attrs):
+ """dump an object as ldif"""
+ print "dn: CN=%s,${SCHEMADN}\n" % o["cn"]
+ for a in attrs:
+ if not o.has_key(a):
+ continue
+ # special case for oMObjectClass, which is a binary object
+ if a == "oMObjectClass":
+ print "%s:: %s\n" % (a, o[a])
+ continue
+ v = o[a]
+ if isinstance(v, str):
+ v = [v]
+ for j in v:
+ print "%s: %s\n" % (a, fix_dn(j))
+ print "\n"
+
+def write_ldif(o, attrs):
+ """dump an array of objects as ldif"""
+ for i in o:
+ write_ldif_one(i, attrs)
+
+
+def create_testdn(exampleDN):
+ """create a testDN based an an example DN
+ the idea is to ensure we obey any structural rules"""
+ a = exampleDN.split(",")
+ a[0] = "CN=TestDN"
+ return ",".join(a)
+
+
+def find_objectclass_properties(ldb, o):
+ """the properties of an objectclass"""
+ res = ldb.search(
+ expression="(ldapDisplayName=%s)" % o.name,
+ basedn=rootDse["schemaNamingContext"], scope=ldb.SCOPE_SUBTREE, attrs=class_attrs)
+ assert(len(res) == 1)
+ msg = res[0]
+ for a in msg:
+ o[a] = msg[a]
+
+def find_attribute_properties(ldb, o):
+ """find the properties of an attribute"""
+ res = ldb.search(
+ expression="(ldapDisplayName=%s)" % o.name,
+ basedn=rootDse["schemaNamingContext"], scope=ldb.SCOPE_SUBTREE,
+ attrs=attrib_attrs)
+ assert(len(res) == 1)
+ msg = res[0]
+ for a in msg:
+ # special case for oMObjectClass, which is a binary object
+ if a == "oMObjectClass":
+ o[a] = ldb.encode(msg[a])
+ continue
+ o[a] = msg[a]
+
+
+def find_objectclass_auto(ldb, o):
+ """find the auto-created properties of an objectclass. Only works for
+ classes that can be created using just a DN and the objectclass"""
+ if not o.has_key("exampleDN"):
+ return
+ testdn = create_testdn(o.exampleDN)
+
+ print "testdn is '%s'\n" % testdn
+
+ ldif = "dn: " + testdn
+ ldif += "\nobjectClass: " + o.name
+ try:
+ ldb.add(ldif)
+ except LdbError, e:
+ print "error adding %s: %s\n" % (o.name, e)
+ print "%s\n" % ldif
+ return
+
+ res = ldb.search("", testdn, ldb.SCOPE_BASE)
+ ldb.delete(testdn)
+
+ for a in res.msgs[0]:
+ attributes[a].autocreate = True
+
+
+def expand_objectclass(ldb, o):
+ """look at auxiliary information from a class to intuit the existance of
+ more classes needed for a minimal schema"""
+ attrs = ["auxiliaryClass", "systemAuxiliaryClass",
+ "possSuperiors", "systemPossSuperiors",
+ "subClassOf"]
+ res = ldb.search(
+ expression="(&(objectClass=classSchema)(ldapDisplayName=%s))" % o.name,
+ basedn=rootDse["schemaNamingContext"], scope=ldb.SCOPE_SUBTREE,
+ attrs=attrs)
+ print "Expanding class %s\n" % o.name
+ assert(len(res) == 1)
+ msg = res[0]
+ for a in attrs:
+ if not msg.has_key(aname):
+ continue
+ list = msg[aname]
+ if isinstance(list, str):
+ list = [msg[aname]]
+ for name in list:
+ if not objectclasses.has_key(name):
+ print "Found new objectclass '%s'\n" % name
+ objectclasses[name] = Objectclass(ldb, name)
+
+
+def add_objectclass_attributes(ldb, objectclass):
+ """add the must and may attributes from an objectclass to the full list
+ of attributes"""
+ attrs = ["mustContain", "systemMustContain",
+ "mayContain", "systemMayContain"]
+ for aname in attrs:
+ if not objectclass.has_key(aname):
+ continue
+ alist = objectclass[aname]
+ if isinstance(alist, str):
+ alist = [alist]
+ for a in alist:
+ if not attributes.has_key(a):
+ attributes[a] = Attribute(ldb, a)
+
+
+def walk_dn(ldb, dn):
+ """process an individual record, working out what attributes it has"""
+ # get a list of all possible attributes for this object
+ attrs = ["allowedAttributes"]
+ try:
+ res = ldb.search("objectClass=*", dn, ldb.SCOPE_BASE, attrs)
+ except LdbError, e:
+ print "Unable to fetch allowedAttributes for '%s' - %r\n" % (dn, e)
+ return
+ allattrs = res[0]["allowedAttributes"]
+ try:
+ res = ldb.search("objectClass=*", dn, ldb.SCOPE_BASE, allattrs)
+ except LdbError, e:
+ print "Unable to fetch all attributes for '%s' - %s\n" % (dn, e)
+ return
+ msg = res[0]
+ for a in msg:
+ if not attributes.has_key(a):
+ attributes[a] = Attribute(ldb, a)
+
+def walk_naming_context(ldb, namingContext):
+ """walk a naming context, looking for all records"""
+ try:
+ res = ldb.search("objectClass=*", namingContext, ldb.SCOPE_DEFAULT,
+ ["objectClass"])
+ except LdbError, e:
+ print "Unable to fetch objectClasses for '%s' - %s\n" % (namingContext, e)
+ return
+ for msg in res:
+ msg = res.msgs[r]["objectClass"]
+ for objectClass in msg:
+ if not objectclasses.has_key(objectClass):
+ objectclasses[objectClass] = Objectclass(ldb, objectClass)
+ objectclasses[objectClass].exampleDN = res.msgs[r]["dn"]
+ walk_dn(ldb, res.msgs[r].dn)
+
+def trim_objectclass_attributes(ldb, objectclass):
+ """trim the may attributes for an objectClass"""
+ # trim possibleInferiors,
+ # include only the classes we extracted
+ if objectclass.has_key("possibleInferiors"):
+ possinf = objectclass["possibleInferiors"]
+ newpossinf = []
+ if isinstance(possinf, str):
+ possinf = [possinf]
+ for x in possinf:
+ if objectclasses.has_key(x):
+ newpossinf[n] = x
+ n+=1
+ objectclass["possibleInferiors"] = newpossinf
+
+ # trim systemMayContain,
+ # remove duplicates
+ if objectclass.has_key("systemMayContain"):
+ sysmay = objectclass["systemMayContain"]
+ newsysmay = []
+ if isinstance(sysmay, str):
+ sysmay = [sysmay]
+ for x in sysmay:
+ if not x in newsysmay:
+ newsysmay.append(x)
+ objectclass["systemMayContain"] = newsysmay
+
+ # trim mayContain,
+ # remove duplicates
+ if not objectclass.has_key("mayContain"):
+ may = objectclass["mayContain"]
+ newmay = []
+ if isinstance(may, str):
+ may = [may]
+ for x in may:
+ if not x in newmay:
+ newmay.append(x)
+ objectclass["mayContain"] = newmay
+
+def build_objectclass(ldb, name):
+ """load the basic attributes of an objectClass"""
+ attrs = ["name"]
+ try:
+ res = ldb.search(
+ expression="(&(objectClass=classSchema)(ldapDisplayName=%s))" % name,
+ basedn=rootDse["schemaNamingContext"], scope=ldb.SCOPE_SUBTREE,
+ attrs=attrs)
+ except LdbError, e:
+ print "unknown class '%s'\n" % name
+ return None
+ if len(res) == 0:
+ print "unknown class '%s'\n" % name
+ return None
+ return Objectclass(ldb, name)
+
+def attribute_list(objectclass, attr1, attr2):
+ """form a coalesced attribute list"""
+ a1 = objectclass[attr1]
+ a2 = objectclass[attr2]
+ if isinstance(a1, str):
+ a1 = [a1]
+ if isinstance(a2, str):
+ a2 = [a2]
+ return a1 + a2
+
+def aggregate_list(name, list):
+ """write out a list in aggregate form"""
+ if list is None:
+ return
+ print "%s ( %s )" % (name, "$ ".join(list))
+
+def write_aggregate_objectclass(objectclass):
+ """write the aggregate record for an objectclass"""
+ print "objectClasses: ( %s NAME '%s' " % (objectclass.governsID, objectclass.name)
+ if not objectclass.has_key('subClassOf'):
+ print "SUP %s " % objectclass['subClassOf']
+ if objectclass.objectClassCategory == 1:
+ print "STRUCTURAL "
+ elif objectclass.objectClassCategory == 2:
+ print "ABSTRACT "
+ elif objectclass.objectClassCategory == 3:
+ print "AUXILIARY "
+
+ list = attribute_list(objectclass, "systemMustContain", "mustContain")
+ aggregate_list("MUST", list)
+
+ list = attribute_list(objectclass, "systemMayContain", "mayContain")
+ aggregate_list("MAY", list)
+
+ print ")\n"
+
+
+def write_aggregate_ditcontentrule(objectclass):
+ """write the aggregate record for an ditcontentrule"""
+ list = attribute_list(objectclass, "auxiliaryClass", "systemAuxiliaryClass")
+ if list is None:
+ return
+
+ print "dITContentRules: ( %s NAME '%s' " % (objectclass.governsID, objectclass.name)
+
+ aggregate_list("AUX", list)
+
+ may_list = None
+ must_list = None
+
+ for c in list:
+ list2 = attribute_list(objectclasses[c],
+ "mayContain", "systemMayContain")
+ may_list = may_list + list2
+ list2 = attribute_list(objectclasses[c],
+ "mustContain", "systemMustContain")
+ must_list = must_list + list2
+
+ aggregate_list("MUST", must_list)
+ aggregate_list("MAY", may_list)
+
+ print ")\n"
+
+def write_aggregate_attribute(attrib):
+ """write the aggregate record for an attribute"""
+ print "attributeTypes: ( %s NAME '%s' SYNTAX '%s' " % (
+ attrib.attributeID, attrib.name,
+ map_attribute_syntax(attrib.attributeSyntax))
+ if attrib['isSingleValued'] == "TRUE":
+ print "SINGLE-VALUE "
+ if attrib['systemOnly'] == "TRUE":
+ print "NO-USER-MODIFICATION "
+
+ print ")\n"
+
+
+def write_aggregate():
+ """write the aggregate record"""
+ print "dn: CN=Aggregate,${SCHEMADN}\n"
+ print """objectClass: top
+objectClass: subSchema
+objectCategory: CN=SubSchema,${SCHEMADN}
+"""
+ if not opts.dump_subschema_auto:
+ return
+
+ for objectclass in objectclasses:
+ write_aggregate_objectclass(objectclass)
+ for attr in attributes:
+ write_aggregate_attribute(attr)
+ for objectclass in objectclasses:
+ write_aggregate_ditcontentrule(objectclass)
+
+def load_list(file):
+ """load a list from a file"""
+ return open(file, 'r').splitlines()
+
+# get the rootDSE
+res = ldb.search("", "", ldb.SCOPE_BASE)
+rootDse = res[0]
+
+# load the list of classes we are interested in
+classes = load_list(classfile)
+for classname in classes:
+ objectclass = build_objectclass(ldb, classname)
+ if objectclass is not None:
+ objectclasses[classname] = objectclass
+
+
+#
+# expand the objectclass list as needed
+#
+expanded = 0
+
+# so EJS do not have while nor the break statement
+# cannot find any other way than doing more loops
+# than necessary to recursively expand all classes
+#
+for inf in range(500):
+ for n in objectclasses:
+ if not n in objectclasses_expanded:
+ expand_objectclass(ldb, objectclasses[i])
+ objectclasses_expanded.add(n)
+
+#
+# find objectclass properties
+#
+for objectclass in objectclasses:
+ find_objectclass_properties(ldb, objectclass)
+
+
+#
+# form the full list of attributes
+#
+for objectclass in objectclasses:
+ add_objectclass_attributes(ldb, objectclass)
+
+# and attribute properties
+for attr in attributes:
+ find_attribute_properties(ldb, attr)
+
+#
+# trim the 'may' attribute lists to those really needed
+#
+for objectclass in objectclasses:
+ trim_objectclass_attributes(ldb, objectclass)
+
+#
+# dump an ldif form of the attributes and objectclasses
+#
+if opts.dump_attributes:
+ write_ldif(attributes, attrib_attrs)
+if opts.dump_classes:
+ write_ldif(objectclasses, class_attrs)
+if opts.dump_subschema:
+ write_aggregate()
+
+if not opts.verbose:
+ sys.exit(0)
+
+#
+# dump list of objectclasses
+#
+print "objectClasses:\n"
+for objectclass in objectclasses:
+ print "\t%s\n" % objectclass
+
+print "attributes:\n"
+for attr in attributes:
+ print "\t%s\n" % attr
+
+print "autocreated attributes:\n"
+for attr in attributes:
+ if attr.autocreate:
+ print "\t%s\n" % i
diff --git a/source4/scripting/bin/subunitrun b/source4/scripting/bin/subunitrun
index 7142abed85..11ac426589 100755
--- a/source4/scripting/bin/subunitrun
+++ b/source4/scripting/bin/subunitrun
@@ -21,6 +21,5 @@ from subunit import SubunitTestRunner
import sys
from unittest import TestProgram
-program = TestProgram(module=None, argv=sys.argv,
- testRunner=SubunitTestRunner())
-program.runTests()
+runner = SubunitTestRunner()
+TestProgram(module=None, argv=sys.argv, testRunner=runner)
diff --git a/source4/scripting/ejs/config.mk b/source4/scripting/ejs/config.mk
index 656ecdae16..c1f07367fb 100644
--- a/source4/scripting/ejs/config.mk
+++ b/source4/scripting/ejs/config.mk
@@ -4,13 +4,13 @@ OBJ_FILES = \
[MODULE::smbcalls_config]
OBJ_FILES = smbcalls_config.o
-OUTPUT_TYPE = INTEGRATED
+OUTPUT_TYPE = MERGED_OBJ
SUBSYSTEM = smbcalls
INIT_FUNCTION = smb_setup_ejs_config
[MODULE::smbcalls_ldb]
OBJ_FILES = smbcalls_ldb.o
-OUTPUT_TYPE = INTEGRATED
+OUTPUT_TYPE = MERGED_OBJ
SUBSYSTEM = smbcalls
INIT_FUNCTION = smb_setup_ejs_ldb
PRIVATE_DEPENDENCIES = LIBLDB SAMDB LIBNDR
@@ -18,45 +18,38 @@ PRIVATE_DEPENDENCIES = LIBLDB SAMDB LIBNDR
[MODULE::smbcalls_reg]
OBJ_FILES = smbcalls_reg.o
SUBSYSTEM = smbcalls
-OUTPUT_TYPE = INTEGRATED
+OUTPUT_TYPE = MERGED_OBJ
INIT_FUNCTION = smb_setup_ejs_reg
PRIVATE_DEPENDENCIES = registry SAMDB LIBNDR
[MODULE::smbcalls_nbt]
OBJ_FILES = smbcalls_nbt.o
SUBSYSTEM = smbcalls
-OUTPUT_TYPE = INTEGRATED
+OUTPUT_TYPE = MERGED_OBJ
INIT_FUNCTION = smb_setup_ejs_nbt
-[MODULE::smbcalls_samba3]
-OBJ_FILES = smbcalls_samba3.o
-SUBSYSTEM = smbcalls
-OUTPUT_TYPE = INTEGRATED
-INIT_FUNCTION = smb_setup_ejs_samba3
-PRIVATE_DEPENDENCIES = LIBSAMBA3
-
[MODULE::smbcalls_rand]
OBJ_FILES = smbcalls_rand.o
SUBSYSTEM = smbcalls
-OUTPUT_TYPE = INTEGRATED
+OUTPUT_TYPE = MERGED_OBJ
INIT_FUNCTION = smb_setup_ejs_random
[MODULE::smbcalls_nss]
OBJ_FILES = smbcalls_nss.o
SUBSYSTEM = smbcalls
-OUTPUT_TYPE = INTEGRATED
+OUTPUT_TYPE = MERGED_OBJ
INIT_FUNCTION = smb_setup_ejs_nss
PRIVATE_DEPENDENCIES = NSS_WRAPPER
[MODULE::smbcalls_data]
OBJ_FILES = smbcalls_data.o
SUBSYSTEM = smbcalls
-OUTPUT_TYPE = INTEGRATED
+OUTPUT_TYPE = MERGED_OBJ
INIT_FUNCTION = smb_setup_ejs_datablob
[MODULE::smbcalls_auth]
OBJ_FILES = smbcalls_auth.o
-OUTPUT_TYPE = INTEGRATED
+OUTPUT_TYPE = MERGED_OBJ
SUBSYSTEM = smbcalls
INIT_FUNCTION = smb_setup_ejs_auth
PRIVATE_DEPENDENCIES = auth
@@ -64,16 +57,16 @@ PRIVATE_DEPENDENCIES = auth
[MODULE::smbcalls_string]
OBJ_FILES = smbcalls_string.o
SUBSYSTEM = smbcalls
-OUTPUT_TYPE = INTEGRATED
+OUTPUT_TYPE = MERGED_OBJ
INIT_FUNCTION = smb_setup_ejs_string
[MODULE::smbcalls_sys]
OBJ_FILES = smbcalls_sys.o
SUBSYSTEM = smbcalls
-OUTPUT_TYPE = INTEGRATED
+OUTPUT_TYPE = MERGED_OBJ
INIT_FUNCTION = smb_setup_ejs_system
-include ejsnet/config.mk
+mkinclude ejsnet/config.mk
[SUBSYSTEM::smbcalls]
PRIVATE_PROTO_HEADER = proto.h
diff --git a/source4/scripting/ejs/smbcalls_samba3.c b/source4/scripting/ejs/smbcalls_samba3.c
deleted file mode 100644
index 36ec2a54e4..0000000000
--- a/source4/scripting/ejs/smbcalls_samba3.c
+++ /dev/null
@@ -1,501 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- provide hooks into smbd C calls from ejs scripts
-
- Copyright (C) Jelmer Vernooij 2005
-
- 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 "scripting/ejs/smbcalls.h"
-#include "lib/appweb/ejs/ejs.h"
-#include "lib/samba3/samba3.h"
-#include "libcli/security/security.h"
-#include "librpc/gen_ndr/ndr_misc.h"
-#include "system/network.h"
-
-
-static struct MprVar mprRegistry(struct samba3_regdb *reg)
-{
- struct MprVar mpv = mprObject("registry"), ks, vs, k, v;
- int i, j;
-
- ks = mprArray("array");
-
- for (i = 0; i < reg->key_count; i++) {
- k = mprObject("regkey");
-
- mprSetVar(&k, "name", mprString(reg->keys[i].name));
-
- vs = mprArray("array");
-
- for (j = 0; j < reg->keys[i].value_count; j++) {
- v = mprObject("regval");
-
- mprSetVar(&v, "name", mprString(reg->keys[i].values[j].name));
- mprSetVar(&v, "type", mprCreateIntegerVar(reg->keys[i].values[j].type));
- mprSetVar(&v, "data", mprDataBlob(reg->keys[i].values[j].data));
-
- mprAddArray(&vs, j, v);
- }
-
- mprSetVar(&k, "values", vs);
-
- mprAddArray(&ks, i, k);
- }
-
- if (i == 0) {
- mprSetVar(&ks, "length", mprCreateIntegerVar(i));
- }
-
- mprSetVar(&mpv, "keys", ks);
-
- return mpv;
-}
-
-static struct MprVar mprPolicy(struct samba3_policy *pol)
-{
- struct MprVar mpv = mprObject("policy");
-
- mprSetVar(&mpv, "min_password_length", mprCreateIntegerVar(pol->min_password_length));
- mprSetVar(&mpv, "password_history", mprCreateIntegerVar(pol->password_history));
- mprSetVar(&mpv, "user_must_logon_to_change_password", mprCreateIntegerVar(pol->user_must_logon_to_change_password));
- mprSetVar(&mpv, "maximum_password_age", mprCreateIntegerVar(pol->maximum_password_age));
- mprSetVar(&mpv, "minimum_password_age", mprCreateIntegerVar(pol->minimum_password_age));
- mprSetVar(&mpv, "lockout_duration", mprCreateIntegerVar(pol->lockout_duration));
- mprSetVar(&mpv, "reset_count_minutes", mprCreateIntegerVar(pol->reset_count_minutes));
- mprSetVar(&mpv, "bad_lockout_minutes", mprCreateIntegerVar(pol->bad_lockout_minutes));
- mprSetVar(&mpv, "disconnect_time", mprCreateIntegerVar(pol->disconnect_time));
- mprSetVar(&mpv, "refuse_machine_password_change", mprCreateIntegerVar(pol->refuse_machine_password_change));
-
- return mpv;
-}
-
-static struct MprVar mprIdmapDb(struct samba3_idmapdb *db)
-{
- struct MprVar mpv = mprObject("idmapdb"), mps, mp;
- int i;
-
- mprSetVar(&mpv, "user_hwm", mprCreateIntegerVar(db->user_hwm));
- mprSetVar(&mpv, "group_hwm", mprCreateIntegerVar(db->group_hwm));
-
- mps = mprArray("array");
-
- for (i = 0; i < db->mapping_count; i++) {
- char *tmp;
- mp = mprObject("idmap");
-
- mprSetVar(&mp, "IDMAP_GROUP", mprCreateIntegerVar(IDMAP_GROUP));
- mprSetVar(&mp, "IDMAP_USER", mprCreateIntegerVar(IDMAP_USER));
- mprSetVar(&mp, "type", mprCreateIntegerVar(db->mappings[i].type));
- mprSetVar(&mp, "unix_id", mprCreateIntegerVar(db->mappings[i].unix_id));
-
- tmp = dom_sid_string(NULL, db->mappings[i].sid);
- mprSetVar(&mp, "sid", mprString(tmp));
- talloc_free(tmp);
-
- mprAddArray(&mps, i, mp);
- }
-
- if (i == 0) {
- mprSetVar(&mpv, "length", mprCreateIntegerVar(i));
- }
-
-
- mprSetVar(&mpv, "mappings", mps);
-
- return mpv;
-}
-
-static struct MprVar mprGroupMappings(struct samba3_groupdb *db)
-{
- struct MprVar mpv = mprArray("array"), g;
- int i;
-
- for (i = 0; i < db->groupmap_count; i++) {
- char *tmp;
- g = mprObject("group");
-
- mprSetVar(&g, "gid", mprCreateIntegerVar(db->groupmappings[i].gid));
-
- tmp = dom_sid_string(NULL, db->groupmappings[i].sid);
- mprSetVar(&g, "sid", mprString(tmp));
- talloc_free(tmp);
-
- mprSetVar(&g, "sid_name_use", mprCreateIntegerVar(db->groupmappings[i].sid_name_use));
- mprSetVar(&g, "nt_name", mprString(db->groupmappings[i].nt_name));
- mprSetVar(&g, "comment", mprString(db->groupmappings[i].comment));
-
- mprAddArray(&mpv, i, g);
- }
-
- if (i == 0) {
- mprSetVar(&mpv, "length", mprCreateIntegerVar(i));
- }
-
-
- return mpv;
-}
-
-static struct MprVar mprAliases(struct samba3_groupdb *db)
-{
- struct MprVar mpv = mprObject("array"), a, am;
- int i, j;
-
- for (i = 0; i < db->alias_count; i++) {
- char *tmp;
- a = mprObject("alias");
-
- tmp = dom_sid_string(NULL, db->aliases[i].sid);
- mprSetVar(&a, "sid", mprString(tmp));
- talloc_free(tmp);
-
- am = mprArray("array");
-
- for (j = 0; j < db->aliases[i].member_count; j++) {
- tmp = dom_sid_string(NULL, db->aliases[i].members[j]);
- mprAddArray(&am, j, mprString(tmp));
- talloc_free(tmp);
- }
-
- mprSetVar(&a, "members", am);
- }
-
- if (i == 0) {
- mprSetVar(&mpv, "length", mprCreateIntegerVar(i));
- }
-
- return mpv;
-}
-
-static struct MprVar mprDomainSecrets(struct samba3_domainsecrets *ds)
-{
- struct MprVar v, e = mprObject("domainsecrets");
- char *tmp;
- DATA_BLOB blob;
-
- mprSetVar(&e, "name", mprString(ds->name));
-
- tmp = dom_sid_string(NULL, &ds->sid);
- mprSetVar(&e, "sid", mprString(tmp));
- talloc_free(tmp);
-
- tmp = GUID_string(NULL, &ds->guid);
- mprSetVar(&e, "guid", mprString(tmp));
- talloc_free(tmp);
-
- mprSetVar(&e, "plaintext_pw", mprString(ds->plaintext_pw));
-
- mprSetVar(&e, "last_change_time", mprCreateIntegerVar(ds->last_change_time));
- mprSetVar(&e, "sec_channel_type", mprCreateIntegerVar(ds->sec_channel_type));
-
- v = mprObject("hash_pw");
-
- blob.data = ds->hash_pw.hash;
- blob.length = 16;
- mprSetVar(&v, "hash", mprDataBlob(blob));
-
- mprSetVar(&v, "mod_time", mprCreateIntegerVar(ds->hash_pw.mod_time));
-
- mprSetVar(&e, "hash_pw", v);
-
- return e;
-}
-
-static struct MprVar mprSecrets(struct samba3_secrets *sec)
-{
- struct MprVar mpv = mprObject("samba3_secrets"), es, e;
- int i;
-
- es = mprArray("array");
-
- for (i = 0; i < sec->ldappw_count; i++) {
- e = mprObject("ldappw");
-
- mprSetVar(&e, "dn", mprString(sec->ldappws[i].dn));
- mprSetVar(&e, "password", mprString(sec->ldappws[i].password));
-
- mprAddArray(&es, i, e);
- }
-
- mprSetVar(&mpv, "ldappws", es);
-
- es = mprArray("array");
-
- for (i = 0; i < sec->domain_count; i++) {
- mprAddArray(&es, i, mprDomainSecrets(&sec->domains[i]));
- }
-
- if (i == 0) {
- mprSetVar(&es, "length", mprCreateIntegerVar(i));
- }
-
- mprSetVar(&mpv, "domains", es);
-
- es = mprArray("trusted_domains");
-
- for (i = 0; i < sec->trusted_domain_count; i++) {
- struct MprVar ns;
- char *tmp;
- int j;
- e = mprObject("trusted_domain");
-
- ns = mprArray("array");
-
- for (j = 0; j < sec->trusted_domains[i].uni_name_len; j++) {
- mprAddArray(&ns, j, mprString(sec->trusted_domains[i].uni_name[j]));
- }
-
- mprSetVar(&e, "uni_name", ns);
-
- mprSetVar(&e, "pass", mprString(sec->trusted_domains[i].pass));
- mprSetVar(&e, "mod_time", mprCreateIntegerVar(sec->trusted_domains[i].mod_time));
-
- tmp = dom_sid_string(NULL, &sec->trusted_domains[i].domain_sid);
- mprSetVar(&e, "domains_sid", mprString(tmp));
- talloc_free(tmp);
-
- mprAddArray(&es, i, e);
- }
-
- if (i == 0) {
- mprSetVar(&es, "length", mprCreateIntegerVar(i));
- }
-
- mprSetVar(&mpv, "trusted_domains", es);
-
- es = mprArray("array");
-
- for (i = 0; i < sec->afs_keyfile_count; i++) {
- struct MprVar ks;
- int j;
- e = mprObject("afs_keyfile");
-
- mprSetVar(&e, "cell", mprString(sec->afs_keyfiles[i].cell));
-
- ks = mprArray("array");
-
- for (j = 0; j < 8; j++) {
- struct MprVar k = mprObject("entry");
- DATA_BLOB blob;
-
- mprSetVar(&k, "kvno", mprCreateIntegerVar(sec->afs_keyfiles[i].entry[j].kvno));
- blob.data = (uint8_t*)sec->afs_keyfiles[i].entry[j].key;
- blob.length = 8;
- mprSetVar(&k, "key", mprDataBlob(blob));
-
- mprAddArray(&ks, j, k);
- }
-
- mprSetVar(&e, "entry", ks);
-
- mprSetVar(&e, "nkeys", mprCreateIntegerVar(sec->afs_keyfiles[i].nkeys));
-
- mprAddArray(&es, i, e);
- }
-
- if (i == 0) {
- mprSetVar(&es, "length", mprCreateIntegerVar(i));
- }
-
- mprSetVar(&mpv, "afs_keyfiles", es);
-
- mprSetVar(&mpv, "ipc_cred", mprCredentials(sec->ipc_cred));
-
- return mpv;
-}
-
-static struct MprVar mprShares(struct samba3 *samba3)
-{
- struct MprVar mpv = mprArray("array"), s;
- int i;
-
- for (i = 0; i < samba3->share_count; i++) {
- s = mprObject("share");
-
- mprSetVar(&s, "name", mprString(samba3->shares[i].name));
-
- /* FIXME: secdesc */
-
- mprAddArray(&mpv, i, s);
- }
-
- if (i == 0) {
- mprSetVar(&mpv, "length", mprCreateIntegerVar(i));
- }
-
- return mpv;
-}
-
-static struct MprVar mprSamAccounts(struct samba3 *samba3)
-{
- struct MprVar mpv = mprArray("array"), m;
- int i;
-
- for (i = 0; i < samba3->samaccount_count; i++) {
- struct samba3_samaccount *a = &samba3->samaccounts[i];
- DATA_BLOB blob;
-
- m = mprObject("samba3_samaccount");
-
- mprSetVar(&m, "logon_time", mprCreateIntegerVar(a->logon_time));
- mprSetVar(&m, "logoff_time", mprCreateIntegerVar(a->logoff_time));
- mprSetVar(&m, "kickoff_time", mprCreateIntegerVar(a->kickoff_time));
- mprSetVar(&m, "bad_password_time", mprCreateIntegerVar(a->bad_password_time));
- mprSetVar(&m, "pass_last_set_time", mprCreateIntegerVar(a->pass_last_set_time));
- mprSetVar(&m, "pass_can_change_time", mprCreateIntegerVar(a->pass_can_change_time));
- mprSetVar(&m, "pass_must_change_time", mprCreateIntegerVar(a->pass_must_change_time));
- mprSetVar(&m, "user_rid", mprCreateIntegerVar(a->user_rid));
- mprSetVar(&m, "group_rid", mprCreateIntegerVar(a->group_rid));
- mprSetVar(&m, "acct_ctrl", mprCreateIntegerVar(a->acct_ctrl));
- mprSetVar(&m, "logon_divs", mprCreateIntegerVar(a->logon_divs));
- mprSetVar(&m, "bad_password_count", mprCreateIntegerVar(a->bad_password_count));
- mprSetVar(&m, "logon_count", mprCreateIntegerVar(a->logon_count));
- mprSetVar(&m, "username", mprString(a->username));
- mprSetVar(&m, "domain", mprString(a->domain));
- mprSetVar(&m, "nt_username", mprString(a->nt_username));
- mprSetVar(&m, "dir_drive", mprString(a->dir_drive));
- mprSetVar(&m, "munged_dial", mprString(a->munged_dial));
- mprSetVar(&m, "fullname", mprString(a->fullname));
- mprSetVar(&m, "homedir", mprString(a->homedir));
- mprSetVar(&m, "logon_script", mprString(a->logon_script));
- mprSetVar(&m, "profile_path", mprString(a->profile_path));
- mprSetVar(&m, "acct_desc", mprString(a->acct_desc));
- mprSetVar(&m, "workstations", mprString(a->workstations));
- blob.length = 16;
- blob.data = a->lm_pw.hash;
- mprSetVar(&m, "lm_pw", mprDataBlob(blob));
- blob.data = a->nt_pw.hash;
- mprSetVar(&m, "nt_pw", mprDataBlob(blob));
-
- mprAddArray(&mpv, i, m);
- }
-
- if (i == 0) {
- mprSetVar(&mpv, "length", mprCreateIntegerVar(i));
- }
-
- return mpv;
-}
-
-static struct MprVar mprWinsEntries(struct samba3 *samba3)
-{
- struct MprVar mpv = mprArray("array");
- int i, j;
-
- for (i = 0; i < samba3->winsdb_count; i++) {
- struct MprVar w = mprObject("wins_entry"), ips;
-
- mprSetVar(&w, "name", mprString(samba3->winsdb_entries[i].name));
- mprSetVar(&w, "nb_flags", mprCreateIntegerVar(samba3->winsdb_entries[i].nb_flags));
- mprSetVar(&w, "type", mprCreateIntegerVar(samba3->winsdb_entries[i].type));
- mprSetVar(&w, "ttl", mprCreateIntegerVar(samba3->winsdb_entries[i].ttl));
-
- ips = mprObject("array");
-
- for (j = 0; j < samba3->winsdb_entries[i].ip_count; j++) {
- const char *addr;
- addr = inet_ntoa(samba3->winsdb_entries[i].ips[j]);
- mprAddArray(&ips, j, mprString(addr));
- }
-
- mprSetVar(&w, "ips", ips);
-
- mprAddArray(&mpv, i, w);
- }
-
- if (i == 0) {
- mprSetVar(&mpv, "length", mprCreateIntegerVar(i));
- }
-
- return mpv;
-}
-
-static int ejs_find_domainsecrets(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- struct samba3 *samba3 = NULL;
- struct samba3_domainsecrets *sec;
-
- if (argc < 1) {
- ejsSetErrorMsg(eid, "find_domainsecrets invalid arguments");
- return -1;
- }
-
- samba3 = (struct samba3 *)mprGetThisPtr(eid, "samba3");
- mprAssert(samba3);
- sec = samba3_find_domainsecrets(samba3, mprToString(argv[0]));
-
- if (sec == NULL) {
- mpr_Return(eid, mprCreateUndefinedVar());
- } else {
- mpr_Return(eid, mprDomainSecrets(sec));
- }
-
- return 0;
-}
-
-/*
- initialise samba3 ejs subsystem
-
- samba3 = samba3_read(libdir,smbconf)
-*/
-static int ejs_samba3_read(MprVarHandle eid, int argc, struct MprVar **argv)
-{
- struct MprVar mpv = mprObject("samba3");
- struct samba3 *samba3;
- NTSTATUS status;
-
- if (argc < 2) {
- ejsSetErrorMsg(eid, "samba3_read invalid arguments");
- return -1;
- }
-
- status = samba3_read(mprToString(argv[0]), mprToString(argv[1]), mprMemCtx(), &samba3);
-
- if (NT_STATUS_IS_ERR(status)) {
- ejsSetErrorMsg(eid, "samba3_read: error");
- return -1;
- }
-
- mprAssert(samba3);
-
- mprSetPtrChild(&mpv, "samba3", samba3);
- mprSetVar(&mpv, "winsentries", mprWinsEntries(samba3));
- mprSetVar(&mpv, "samaccounts", mprSamAccounts(samba3));
- mprSetVar(&mpv, "shares", mprShares(samba3));
- mprSetVar(&mpv, "secrets", mprSecrets(&samba3->secrets));
- mprSetVar(&mpv, "groupmappings", mprGroupMappings(&samba3->group));
- mprSetVar(&mpv, "aliases", mprAliases(&samba3->group));
- mprSetVar(&mpv, "idmapdb", mprIdmapDb(&samba3->idmap));
- mprSetVar(&mpv, "policy", mprPolicy(&samba3->policy));
- mprSetVar(&mpv, "registry", mprRegistry(&samba3->registry));
- mprSetVar(&mpv, "configuration", mprParam(samba3->configuration));
- mprSetCFunction(&mpv, "find_domainsecrets", ejs_find_domainsecrets);
-
- mpr_Return(eid, mpv);
-
- return 0;
-}
-
-
-/*
- setup C functions that be called from ejs
-*/
-NTSTATUS smb_setup_ejs_samba3(void)
-{
- ejsDefineCFunction(-1, "samba3_read", ejs_samba3_read, NULL, MPR_VAR_SCRIPT_HANDLE);
- return NT_STATUS_OK;
-}
diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c
index a4f2e1cd43..9ed4aa490f 100644
--- a/source4/scripting/ejs/smbscript.c
+++ b/source4/scripting/ejs/smbscript.c
@@ -61,8 +61,6 @@ int main(int argc, const char **argv)
lp_load(lp_ctx, dyn_CONFIGFILE);
}
- ldb_global_init();
-
gensec_init(lp_ctx);
mprSetCtx(mem_ctx);
diff --git a/source4/scripting/libjs/provision.js b/source4/scripting/libjs/provision.js
index e71498010c..dc9eae8e72 100644
--- a/source4/scripting/libjs/provision.js
+++ b/source4/scripting/libjs/provision.js
@@ -1124,7 +1124,7 @@ unixName: %s
sambaPassword: %s
objectClass: user
",
- user_dn, username, dom_users,
+ user_dn, username,
unixname, password);
/*
add the user to the users group as well
@@ -1134,7 +1134,7 @@ dn: %s
changetype: modify
add: member
member: %s
-",
+",
dom_users, user_dn);
diff --git a/source4/scripting/python/config.m4 b/source4/scripting/python/config.m4
index e4a34ece1e..2142cd9abd 100644
--- a/source4/scripting/python/config.m4
+++ b/source4/scripting/python/config.m4
@@ -54,7 +54,7 @@ fi
if test x$PYTHON != x
then
- DISTUTILS_CFLAGS=`$PYTHON -c "from distutils import sysconfig; print '-I%s -I%s %s' % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=True), sysconfig.get_config_var('CFLAGS'))"`
+ DISTUTILS_CFLAGS=`$PYTHON -c "from distutils import sysconfig; print '-I%s -I%s %s' % (sysconfig.get_python_inc(), sysconfig.get_python_inc(plat_specific=1), sysconfig.get_config_var('CFLAGS'))"`
DISTUTILS_LDFLAGS=`$PYTHON -c "from distutils import sysconfig; print '%s %s -lpython%s -L%s' % (sysconfig.get_config_var('LIBS'), sysconfig.get_config_var('SYSLIBS'), sysconfig.get_config_var('VERSION'), sysconfig.get_config_var('LIBPL'))"`
TRY_LINK_PYTHON($DISTUTILS_LDFLAGS, $DISTUTILS_CFLAGS)
fi
@@ -66,12 +66,8 @@ if test $working_python = yes; then
SMB_ENABLE(EXT_LIB_PYTHON,YES)
SMB_ENABLE(smbpython,YES)
SMB_ENABLE(LIBPYTHON,YES)
- dnl AC_DEFINE(HAVE_WORKING_PYTHON, 1, [Whether we have working python support])
AC_MSG_RESULT([yes])
else
- SMB_ENABLE(EXT_LIB_PYTHON,NO)
- SMB_ENABLE(LIBPYTHONyy,NO)
- SMB_ENABLE(smbpython,NO)
- AC_MSG_RESULT([no])
+ AC_MSG_ERROR([Python not found. Please install Python 2.x and its development headers/libraries.])
fi
diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk
index 450da0e90a..b15e1fcda7 100644
--- a/source4/scripting/python/config.mk
+++ b/source4/scripting/python/config.mk
@@ -33,7 +33,7 @@ pythonmods:: $(PYTHON_DSOS) $(PYTHON_PYS)
PYDOCTOR_MODULES=bin/python/ldb.py bin/python/auth.py bin/python/credentials.py bin/python/registry.py bin/python/tdb.py bin/python/security.py bin/python/events.py bin/python/net.py
pydoctor:: pythonmods
- LD_LIBRARY_PATH=bin/shared PYTHONPATH=bin/python pydoctor --make-html --docformat=restructuredtext --add-package scripting/python/samba/ $(addprefix --add-module , $(PYDOCTOR_MODULES))
+ LD_LIBRARY_PATH=bin/shared PYTHONPATH=bin/python pydoctor --project-name=Samba --make-html --docformat=restructuredtext --add-package scripting/python/samba/ $(addprefix --add-module , $(PYDOCTOR_MODULES))
installpython:: pythonmods
@$(SHELL) $(srcdir)/script/installpython.sh \
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 7dd564fae1..3e88b68509 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -271,20 +271,19 @@ def setup_name_mappings(ldb, sid, domaindn, root, nobody, nogroup, users,
def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
credentials, configdn, schemadn, domaindn,
hostname, netbiosname, dnsdomain, realm,
- rootdn, serverrole, ldap_backend=None,
+ rootdn, serverrole, sitename, ldap_backend=None,
ldap_backend_type=None, erase=False):
"""Setup the partitions for the SAM database.
Alternatively, provision() may call this, and then populate the database.
:param erase: Remove the existing data present in the database.
- :param
:note: This will wipe the Sam Database!
:note: This function always removes the local SAM LDB file. The erase
- parameter controls whether to erase the existing data, which
- may not be stored locally but in LDAP.
+ parameter controls whether to erase the existing data, which
+ may not be stored locally but in LDAP.
"""
assert session_info is not None
@@ -333,13 +332,12 @@ 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":
- backend_modules = ["nsuniqueid","paged_searches"]
+ backend_modules = ["nsuniqueid", "paged_searches"]
elif ldap_backend_type == "openldap":
- backend_modules = ["normalise","entryuuid","paged_searches"]
+ backend_modules = ["normalise", "entryuuid", "paged_searches"]
elif serverrole == "domain controller":
backend_modules = ["repl_meta_data"]
else:
@@ -380,7 +378,8 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
message("Setting up sam.ldb rootDSE")
setup_samdb_rootdse(samdb, setup_path, schemadn, domaindn, hostname,
- dnsdomain, realm, rootdn, configdn, netbiosname)
+ dnsdomain, realm, rootdn, configdn, netbiosname,
+ sitename)
if erase:
message("Erasing data from partitions")
@@ -474,18 +473,18 @@ def setup_registry(path, setup_path, session_info, credentials, lp):
def setup_samdb_rootdse(samdb, setup_path, schemadn, domaindn, hostname,
- dnsdomain, realm, rootdn, configdn, netbiosname):
+ dnsdomain, realm, rootdn, configdn, netbiosname,
+ sitename):
"""Setup the SamDB rootdse.
:param samdb: Sam Database handle
:param setup_path: Obtain setup path
- ...
"""
setup_add_ldif(samdb, setup_path("provision_rootdse_add.ldif"), {
"SCHEMADN": schemadn,
"NETBIOSNAME": netbiosname,
"DNSDOMAIN": dnsdomain,
- "DEFAULTSITE": DEFAULTSITE,
+ "DEFAULTSITE": sitename,
"REALM": realm,
"DNSNAME": "%s.%s" % (hostname, dnsdomain),
"DOMAINDN": domaindn,
@@ -498,7 +497,7 @@ def setup_samdb_rootdse(samdb, setup_path, schemadn, domaindn, hostname,
def setup_self_join(samdb, configdn, schemadn, domaindn,
netbiosname, hostname, dnsdomain, machinepass, dnspass,
realm, domainname, domainsid, invocationid, setup_path,
- policyguid, hostguid=None):
+ policyguid, sitename, hostguid=None):
"""Join a host to its own domain."""
if hostguid is not None:
hostguid_add = "objectGUID: %s" % hostguid
@@ -511,7 +510,7 @@ def setup_self_join(samdb, configdn, schemadn, domaindn,
"DOMAINDN": domaindn,
"INVOCATIONID": invocationid,
"NETBIOSNAME": netbiosname,
- "DEFAULTSITE": DEFAULTSITE,
+ "DEFAULTSITE": sitename,
"DNSNAME": "%s.%s" % (hostname, dnsdomain),
"MACHINEPASS_B64": b64encode(machinepass),
"DNSPASS_B64": b64encode(dnspass),
@@ -532,12 +531,15 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
domainsid, aci, domainguid, policyguid,
domainname, fill, adminpass, krbtgtpass,
machinepass, hostguid, invocationid, dnspass,
- serverrole, ldap_backend=None, ldap_backend_type=None):
+ serverrole, sitename, ldap_backend=None,
+ ldap_backend_type=None):
"""Setup a complete SAM Database.
: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,
@@ -545,7 +547,8 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
hostname=hostname, netbiosname=netbiosname,
dnsdomain=dnsdomain, realm=realm, rootdn=rootdn,
ldap_backend=ldap_backend, serverrole=serverrole,
- ldap_backend_type=ldap_backend_type, erase=erase)
+ ldap_backend_type=ldap_backend_type, erase=erase,
+ sitename=sitename)
samdb = SamDB(path, session_info=session_info,
credentials=credentials, lp=lp)
@@ -563,7 +566,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
if lp.get("server role") == "domain controller":
samdb.set_invocation_id(invocationid)
- load_schema(setup_path, samdb, schemadn, netbiosname, configdn)
+ load_schema(setup_path, samdb, schemadn, netbiosname, configdn, sitename)
samdb.transaction_start()
@@ -585,7 +588,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
"DOMAINSID": str(domainsid),
"SCHEMADN": schemadn,
"NETBIOSNAME": netbiosname,
- "DEFAULTSITE": DEFAULTSITE,
+ "DEFAULTSITE": sitename,
"CONFIGDN": configdn,
"POLICYGUID": policyguid,
"DOMAINDN": domaindn,
@@ -615,7 +618,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
setup_path("provision_schema_basedn_modify.ldif"), {
"SCHEMADN": schemadn,
"NETBIOSNAME": netbiosname,
- "DEFAULTSITE": DEFAULTSITE,
+ "DEFAULTSITE": sitename,
"CONFIGDN": configdn,
})
@@ -630,7 +633,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
setup_add_ldif(samdb, setup_path("provision_configuration.ldif"), {
"CONFIGDN": configdn,
"NETBIOSNAME": netbiosname,
- "DEFAULTSITE": DEFAULTSITE,
+ "DEFAULTSITE": sitename,
"DNSDOMAIN": dnsdomain,
"DOMAIN": domainname,
"SCHEMADN": schemadn,
@@ -657,7 +660,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
setup_add_ldif(samdb, setup_path("provision.ldif"), {
"DOMAINDN": domaindn,
"NETBIOSNAME": netbiosname,
- "DEFAULTSITE": DEFAULTSITE,
+ "DEFAULTSITE": sitename,
"CONFIGDN": configdn,
})
@@ -680,7 +683,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
machinepass=machinepass, domainname=domainname,
domainsid=domainsid, policyguid=policyguid,
hostname=hostname, hostguid=hostguid,
- setup_path=setup_path)
+ setup_path=setup_path, sitename=sitename)
#We want to setup the index last, as adds are faster unindexed
message("Setting up sam.ldb index")
@@ -692,6 +695,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
samdb.transaction_commit()
return samdb
+
FILL_FULL = "FULL"
FILL_NT4SYNC = "NT4SYNC"
FILL_DRS = "DRS"
@@ -703,7 +707,7 @@ def provision(lp, setup_dir, message, paths, session_info,
policyguid=None, invocationid=None, machinepass=None,
dnspass=None, root=None, nobody=None, nogroup=None, users=None,
wheel=None, backup=None, aci=None, serverrole=None, erase=False,
- ldap_backend=None, ldap_backend_type=None):
+ ldap_backend=None, ldap_backend_type=None, sitename=DEFAULTSITE):
"""Provision samba4
:note: caution, this wipes all existing data!
@@ -852,7 +856,7 @@ def provision(lp, setup_dir, message, paths, session_info,
hostguid=hostguid, invocationid=invocationid,
machinepass=machinepass, dnspass=dnspass,
serverrole=serverrole, ldap_backend=ldap_backend,
- ldap_backend_type=ldap_backend_type)
+ ldap_backend_type=ldap_backend_type, sitename=sitename)
if lp.get("server role") == "domain controller":
policy_path = os.path.join(paths.sysvol, dnsdomain, "Policies",
@@ -946,7 +950,7 @@ def create_zone_file(path, setup_path, samdb, dnsdomain, domaindn,
})
-def load_schema(setup_path, samdb, schemadn, netbiosname, configdn):
+def load_schema(setup_path, samdb, schemadn, netbiosname, configdn, sitename):
"""Load schema for the SamDB.
:param samdb: Load a schema into a SamDB.
@@ -963,7 +967,7 @@ def load_schema(setup_path, samdb, schemadn, netbiosname, configdn):
"SCHEMADN": schemadn,
"NETBIOSNAME": netbiosname,
"CONFIGDN": configdn,
- "DEFAULTSITE": DEFAULTSITE
+ "DEFAULTSITE":sitename
})
samdb.attach_schema_from_ldif(head_data, schema_data)
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)
diff --git a/source4/scripting/python/samba/tests/__init__.py b/source4/scripting/python/samba/tests/__init__.py
index 9402002674..c8673d3fae 100644
--- a/source4/scripting/python/samba/tests/__init__.py
+++ b/source4/scripting/python/samba/tests/__init__.py
@@ -84,3 +84,9 @@ class LdbExtensionTests(TestCaseInTempDir):
del l
os.unlink(path)
+
+def get_loadparm():
+ import param
+ lp = param.LoadParm()
+ lp.load(os.getenv("SMB_CONF_PATH"))
+ return lp
diff --git a/source4/scripting/python/samba/tests/dcerpc/registry.py b/source4/scripting/python/samba/tests/dcerpc/registry.py
index f3f0b0fb1a..147acc5098 100644
--- a/source4/scripting/python/samba/tests/dcerpc/registry.py
+++ b/source4/scripting/python/samba/tests/dcerpc/registry.py
@@ -20,11 +20,11 @@
import winreg
from param import LoadParm
import unittest
+from samba.tests import get_loadparm
class WinregTests(unittest.TestCase):
def setUp(self):
- lp_ctx = LoadParm()
- lp_ctx.load("st/client/client.conf")
+ lp_ctx = get_loadparm()
self.conn = winreg.winreg("ncalrpc:", lp_ctx)
def get_hklm(self):
diff --git a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py
index 52c2bb8c72..8c1a8bec71 100644
--- a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py
+++ b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py
@@ -18,13 +18,12 @@
#
import echo
-from param import LoadParm
import unittest
+from samba.tests import get_loadparm
class RpcEchoTests(unittest.TestCase):
def setUp(self):
- lp_ctx = LoadParm()
- lp_ctx.load("st/client/client.conf")
+ lp_ctx = get_loadparm()
self.conn = echo.rpcecho("ncalrpc:", lp_ctx)
def test_addone(self):
diff --git a/source4/scripting/python/samba/tests/dcerpc/sam.py b/source4/scripting/python/samba/tests/dcerpc/sam.py
index 50caaf2348..96348f2f69 100644
--- a/source4/scripting/python/samba/tests/dcerpc/sam.py
+++ b/source4/scripting/python/samba/tests/dcerpc/sam.py
@@ -19,10 +19,11 @@
import samr
import unittest
+from samba.tests import get_loadparm
class SamrTests(unittest.TestCase):
def setUp(self):
- self.conn = samr.samr("ncalrpc:", "st/client/client.conf")
+ self.conn = samr.samr("ncalrpc:", get_loadparm())
def test_connect5(self):
(level, info, handle) = self.conn.Connect5(None, 0, 1, samr.ConnectInfo1())
diff --git a/source4/scripting/python/samba/tests/provision.py b/source4/scripting/python/samba/tests/provision.py
index eb49f7af83..514582cbe4 100644
--- a/source4/scripting/python/samba/tests/provision.py
+++ b/source4/scripting/python/samba/tests/provision.py
@@ -24,8 +24,7 @@ from ldb import Dn
import param
import unittest
-lp = param.LoadParm()
-lp.load("st/dc/etc/smb.conf")
+lp = samba.tests.get_loadparm()
setup_dir = "setup"
def setup_path(file):
@@ -33,6 +32,8 @@ def setup_path(file):
class ProvisionTestCase(samba.tests.TestCaseInTempDir):
+ """Some simple tests for individual functions in the provisioning code.
+ """
def test_setup_secretsdb(self):
path = os.path.join(self.tempdir, "secrets.ldb")
ldb = setup_secretsdb(path, setup_path, None, None, 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 <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/>.
+#
+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/scripting/python/samba/tests/upgrade.py b/source4/scripting/python/samba/tests/upgrade.py
index ddafa00691..4dc86ace8a 100644
--- a/source4/scripting/python/samba/tests/upgrade.py
+++ b/source4/scripting/python/samba/tests/upgrade.py
@@ -17,6 +17,21 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-import samba.upgrade
-from unittest import TestCase
+from samba import Ldb
+from samba.upgrade import import_wins
+from samba.tests import LdbTestCase
+class WinsUpgradeTests(LdbTestCase):
+ def test_upgrade(self):
+ winsdb = {
+ "FOO#20": (200, ["127.0.0.1", "127.0.0.2"], 0x60)
+ }
+ import_wins(self.ldb, winsdb)
+
+ self.assertEquals(['name=FOO,type=0x20'],
+ [str(m.dn) for m in self.ldb.search(expression="(objectClass=winsRecord)")])
+
+ def test_version(self):
+ import_wins(self.ldb, {})
+ self.assertEquals("VERSION",
+ self.ldb.search(expression="(objectClass=winsMaxVersion)")[0]["cn"])
diff --git a/source4/scripting/python/samba/upgrade.py b/source4/scripting/python/samba/upgrade.py
index b332bb89ae..01b62ff984 100644
--- a/source4/scripting/python/samba/upgrade.py
+++ b/source4/scripting/python/samba/upgrade.py
@@ -10,6 +10,7 @@
from provision import findnss, provision, FILL_DRS
import grp
import ldb
+import time
import pwd
import uuid
import registry
@@ -17,6 +18,7 @@ from samba import Ldb
from samba.samdb import SamDB
def import_sam_policy(samldb, samba3_policy, domaindn):
+ """Import a Samba 3 policy database."""
samldb.modify_ldif("""
dn: %s
changetype: modify
@@ -162,7 +164,6 @@ def import_wins(samba4_winsdb, samba3_winsdb):
:param samba3_winsdb: WINS database to import from
"""
version_id = 0
- import time
for (name, (ttl, ips, nb_flags)) in samba3_winsdb.items():
version_id+=1
@@ -201,7 +202,8 @@ def import_wins(samba4_winsdb, samba3_winsdb):
"versionID": str(version_id),
"address": ips})
- samba4_winsdb.add({"dn": "CN=VERSION",
+ samba4_winsdb.add({"dn": "cn=VERSION",
+ "cn": "VERSION",
"objectClass": "winsMaxVersion",
"maxVersion": str(version_id)})
diff --git a/source4/scripting/python/subunit/__init__.py b/source4/scripting/python/subunit/__init__.py
index 4d3434a3ea..3abfbf522e 100644
--- a/source4/scripting/python/subunit/__init__.py
+++ b/source4/scripting/python/subunit/__init__.py
@@ -209,7 +209,7 @@ class TestProtocolClient(unittest.TestResult):
"""A class that looks like a TestResult and informs a TestProtocolServer."""
def __init__(self, stream):
- unittest.TestResult.__init__(self)
+ super(TestProtocolClient, self).__init__()
self._stream = stream
def addError(self, test, error):
@@ -218,6 +218,7 @@ class TestProtocolClient(unittest.TestResult):
for line in self._exc_info_to_string(error, test).splitlines():
self._stream.write("%s\n" % line)
self._stream.write("]\n")
+ super(TestProtocolClient, self).addError(test, error)
def addFailure(self, test, error):
"""Report a failure in test test."""
@@ -225,14 +226,17 @@ class TestProtocolClient(unittest.TestResult):
for line in self._exc_info_to_string(error, test).splitlines():
self._stream.write("%s\n" % line)
self._stream.write("]\n")
+ super(TestProtocolClient, self).addFailure(test, error)
def addSuccess(self, test):
"""Report a success in a test."""
self._stream.write("successful: %s\n" % (test.shortDescription() or str(test)))
+ super(TestProtocolClient, self).addSuccess(test)
def startTest(self, test):
"""Mark a test as starting its test run."""
self._stream.write("test: %s\n" % (test.shortDescription() or str(test)))
+ super(TestProtocolClient, self).startTest(test)
def RemoteError(description=""):
diff --git a/source4/selftest/README b/source4/selftest/README
index 3250f32ec7..e8e87c8b3f 100644
--- a/source4/selftest/README
+++ b/source4/selftest/README
@@ -39,3 +39,24 @@ The following environments are currently available:
* DOMAIN: Domain name
* REALM: Realm name
* SERVER: Name of the member server
+
+
+=============
+Running tests
+=============
+
+To run all the tests use:
+
+ make test
+
+To run a quick subset (aiming for about 1 minute of testing) run:
+
+ make quicktest
+
+To run a specific test, use this syntax
+
+ make test TESTS=testname
+
+for example
+
+ make test TESTS=samba4.BASE-DELETE
diff --git a/source4/selftest/config.mk b/source4/selftest/config.mk
index 0d5f4d6ab4..4e9d31b684 100644
--- a/source4/selftest/config.mk
+++ b/source4/selftest/config.mk
@@ -7,65 +7,66 @@ SELFTEST = $(LD_LIBPATH_OVERRIDE) $(PERL) $(srcdir)/selftest/selftest.pl --prefi
--exclude=$(srcdir)/samba4-skip --testlist="./selftest/samba4_tests.sh|" \
$(TEST_OPTIONS)
-test: everything
+test:: everything
$(SELFTEST) $(DEFAULT_TEST_OPTIONS) --immediate $(TESTS)
-testone: everything
+kvmtest:: everything
+ $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --immediate --target=kvm --image=$(KVM_IMAGE)
+
+kvmquicktest:: everything
+ $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --immediate --quick --target=kvm --image=$(KVM_IMAGE)
+
+testone:: everything
$(SELFTEST) $(DEFAULT_TEST_OPTIONS) --one $(TESTS)
-test-swrap: everything
+test-swrap:: everything
$(SELFTEST) --socket-wrapper --immediate $(TESTS)
-test-swrap-pcap: everything
+test-swrap-pcap:: everything
$(SELFTEST) --socket-wrapper-pcap --immediate $(TESTS)
-test-swrap-keep-pcap: everything
+test-swrap-keep-pcap:: everything
$(SELFTEST) --socket-wrapper-keep-pcap --immediate $(TESTS)
-test-noswrap: everything
+test-noswrap:: everything
$(SELFTEST) --immediate $(TESTS)
-quicktest: all
+quicktest:: all
$(SELFTEST) --quick --socket-wrapper --immediate $(TESTS)
-quicktestone: all
+quicktestone:: all
$(SELFTEST) --quick --socket-wrapper --one $(TESTS)
-testenv: everything
+testenv:: everything
$(SELFTEST) --socket-wrapper --testenv
-valgrindtest: valgrindtest-all
+valgrindtest:: valgrindtest-all
-valgrindtest-quick: all
+valgrindtest-quick:: all
SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/valgrind_run $(LD_LIBPATH_OVERRIDE)" \
VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
$(SELFTEST) --quick --immediate --socket-wrapper $(TESTS)
-valgrindtest-all: everything
+valgrindtest-all:: everything
SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/valgrind_run $(LD_LIBPATH_OVERRIDE)" \
VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
$(SELFTEST) --immediate --socket-wrapper $(TESTS)
-valgrindtest-env: everything
+valgrindtest-env:: everything
SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/valgrind_run $(LD_LIBPATH_OVERRIDE)" \
VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
$(SELFTEST) --socket-wrapper --testenv
-gdbtest: gdbtest-all
+gdbtest:: gdbtest-all
-gdbtest-quick: all
+gdbtest-quick:: all
SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/gdb_run $(LD_LIBPATH_OVERRIDE)" \
$(SELFTEST) --immediate --quick --socket-wrapper $(TESTS)
-gdbtest-all: everything
+gdbtest-all:: everything
SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/gdb_run $(LD_LIBPATH_OVERRIDE)" \
$(SELFTEST) --immediate --socket-wrapper $(TESTS)
-gdbtest-env: everything
+gdbtest-env:: everything
SMBD_VALGRIND="xterm -n smbd -e $(srcdir)/script/gdb_run $(LD_LIBPATH_OVERRIDE)" \
$(SELFTEST) --socket-wrapper --testenv
-
-wintest: all
- $(SELFTEST) win
-
-
diff --git a/source4/selftest/output/plain.pm b/source4/selftest/output/plain.pm
index 1e6dead326..e491a999ab 100644
--- a/source4/selftest/output/plain.pm
+++ b/source4/selftest/output/plain.pm
@@ -46,8 +46,15 @@ sub start_testsuite($$)
my $out = "";
$out .= "[$self->{index}/$self->{totalsuites} in ".$duration."s";
$out .= sprintf(", %d errors", ($#{$self->{suitesfailed}}+1)) if ($#{$self->{suitesfailed}} > -1);
- $out .= "] $name\n",
- print "$out";
+ $out .= "] $name";
+ if ($self->{immediate}) {
+ print "$out\n";
+ } else {
+ require Term::ReadKey;
+ my ($wchar, $hchar, $wpixels, $hpixels) = Term::ReadKey::GetTerminalSize();
+ foreach (1..$wchar) { $out.= " "; }
+ print "\r".substr($out, 0, $wchar);
+ }
}
sub output_msg($$)
diff --git a/source4/selftest/samba4_tests.sh b/source4/selftest/samba4_tests.sh
index d00b492953..c57ec4d6bd 100755
--- a/source4/selftest/samba4_tests.sh
+++ b/source4/selftest/samba4_tests.sh
@@ -40,6 +40,22 @@ plantest() {
echo $cmdline
}
+normalize_testname() {
+ name=$1
+ shift 1
+ echo $name | tr "A-Z-" "a-z."
+}
+
+plansmbtorturetest() {
+ name=$1
+ env=$2
+ shift 2
+ other_args="$*"
+ modname=`normalize_testname $name`
+ cmdline="$VALGRIND $smb4torture $other_args $name"
+ plantest "$modname" "$env" $cmdline
+}
+
$incdir/../bin/smbtorture -V
samba4srcdir=$incdir/..
@@ -67,7 +83,7 @@ if grep ENABLE_GNUTLS.1 include/config.h > /dev/null; then
fi
for t in LDAP-CLDAP LDAP-BASIC LDAP-SCHEMA LDAP-UPTODATEVECTOR
do
- plantest "$t" dc $smb4torture "-U\$USERNAME%\$PASSWORD" //\$SERVER_IP/_none_ $t
+ plansmbtorturetest "$t" dc "-U\$USERNAME%\$PASSWORD" //\$SERVER_IP/_none_
done
# only do the ldb tests when not in quick mode - they are quite slow, and ldb
@@ -75,7 +91,6 @@ done
LDBDIR=$samba4srcdir/lib/ldb
export LDBDIR
plantest "ldb" none TEST_DATA_PREFIX=\$PREFIX $LDBDIR/tests/test-tdb.sh
-
plantest "js.ldap" dc $SCRIPTDIR/ldap.js $CONFIGURATION -d 10 \$SERVER -U\$USERNAME%\$PASSWORD
# Tests for RPC
@@ -109,15 +124,15 @@ for bindoptions in seal,padcheck $VALIDATE bigendian; do
ncacn_ip_tcp) tests=$ncacn_ip_tcp_tests ;;
esac
for t in $tests; do
- plantest "$t on $transport with $bindoptions" dc $VALGRIND $smb4torture $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*"
+ plantest "`normalize_testname $t` on $transport with $bindoptions" dc $VALGRIND $smb4torture $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*"
done
- plantest "RPC-SAMBA3-SHARESEC on $transport with $bindoptions" dc $VALGRIND $smb4torture $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN --option=torture:share=tmp $t "$*"
+ plantest "rpc.samba3.sharesec on $transport with $bindoptions" dc $VALGRIND $smb4torture $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN --option=torture:share=tmp RPC-SAMBA3-SHARESEC "$*"
done
done
for bindoptions in "" $VALIDATE bigendian; do
for t in $auto_rpc_tests; do
- plantest "$t with $bindoptions" dc $VALGRIND $smb4torture "\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*"
+ plantest "`normalize_testname $t` with $bindoptions" dc $VALGRIND $smb4torture "\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*"
done
done
@@ -129,7 +144,7 @@ for bindoptions in connect $VALIDATE ; do
ncacn_ip_tcp) tests=$slow_ncacn_ip_tcp_tests ;;
esac
for t in $tests; do
- plantest "$t on $transport with $bindoptions" dc $VALGRIND $smb4torture $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*"
+ plantest "`normalize_testname $t` on $transport with $bindoptions" dc $VALGRIND $smb4torture $transport:"\$SERVER[$bindoptions]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN $t "$*"
done
done
done
@@ -140,7 +155,7 @@ done
net=`$smb4torture --list | grep ^NET-`
for t in $net; do
- plantest "$t" dc $VALGRIND $smb4torture "\$SERVER[$VALIDATE]" -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" $t "$*"
+ plansmbtorturetest "$t" dc "\$SERVER[$VALIDATE]" -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" "$*"
done
# Tests for session keys
@@ -160,13 +175,13 @@ for ntlmoptions in \
"-k no --option=usespnego=no --option=clientntlmv2auth=yes" \
"-k no --option=gensec:spnego=no --option=clientntlmv2auth=yes" \
"-k no --option=usespnego=no"; do
- name="RPC-SECRETS on $transport with $bindoptions with $ntlmoptions"
+ name="rpc.secrets on $transport with $bindoptions with $ntlmoptions"
plantest "$name" dc $smb4torture $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN --option=gensec:target_hostname=\$NETBIOSNAME RPC-SECRETS "$*"
done
-plantest "RPC-SECRETS on $transport with $bindoptions with Kerberos" dc $smb4torture $transport:"\$SERVER[$bindoptions]" -k yes -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN "--option=gensec:target_hostname=\$NETBIOSNAME" RPC-SECRETS "$*"
-plantest "RPC-SECRETS on $transport with $bindoptions with Kerberos - use target principal" dc $smb4torture $transport:"\$SERVER[$bindoptions]" -k yes -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN "--option=clientusespnegoprincipal=yes" "--option=gensec:target_hostname=\$NETBIOSNAME" RPC-SECRETS "$*"
- plantest "RPC-SECRETS on $transport with Kerberos - use Samba3 style login" dc $smb4torture $transport:"\$SERVER" -k yes -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" "--option=gensec:fake_gssapi_krb5=yes" "--option=gensec:gssapi_krb5=no" "--option=gensec:target_hostname=\$NETBIOSNAME" "RPC-SECRETS-none*" "$*"
- plantest "RPC-SECRETS on $transport with Kerberos - use Samba3 style login, use target principal" dc $smb4torture $transport:"\$SERVER" -k yes -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" "--option=clientusespnegoprincipal=yes" "--option=gensec:fake_gssapi_krb5=yes" "--option=gensec:gssapi_krb5=no" "--option=gensec:target_hostname=\$NETBIOSNAME" "RPC-SECRETS-none*" "$*"
+plantest "rpc.secrets on $transport with $bindoptions with Kerberos" dc $smb4torture $transport:"\$SERVER[$bindoptions]" -k yes -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN "--option=gensec:target_hostname=\$NETBIOSNAME" RPC-SECRETS "$*"
+plantest "rpc.secrets on $transport with $bindoptions with Kerberos - use target principal" dc $smb4torture $transport:"\$SERVER[$bindoptions]" -k yes -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN "--option=clientusespnegoprincipal=yes" "--option=gensec:target_hostname=\$NETBIOSNAME" RPC-SECRETS "$*"
+plantest "rpc.secrets on $transport with Kerberos - use Samba3 style login" dc $smb4torture $transport:"\$SERVER" -k yes -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" "--option=gensec:fake_gssapi_krb5=yes" "--option=gensec:gssapi_krb5=no" "--option=gensec:target_hostname=\$NETBIOSNAME" "RPC-SECRETS-none*" "$*"
+plantest "rpc.secrets on $transport with Kerberos - use Samba3 style login, use target principal" dc $smb4torture $transport:"\$SERVER" -k yes -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" "--option=clientusespnegoprincipal=yes" "--option=gensec:fake_gssapi_krb5=yes" "--option=gensec:gssapi_krb5=no" "--option=gensec:target_hostname=\$NETBIOSNAME" "RPC-SECRETS-none*" "$*"
# Echo tests
transports="ncacn_np ncacn_ip_tcp ncalrpc"
@@ -175,7 +190,7 @@ for transport in $transports; do
for bindoptions in connect spnego spnego,sign spnego,seal $VALIDATE padcheck bigendian bigendian,seal; do
for ntlmoptions in \
"--option=socket:testnonblock=True --option=torture:quick=yes"; do
- plantest "RPC-ECHO on $transport with $bindoptions and $ntlmoptions" dc $smb4torture $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" RPC-ECHO "$*"
+ plantest "rpc.echo on $transport with $bindoptions and $ntlmoptions" dc $smb4torture $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" RPC-ECHO "$*"
done
done
done
@@ -193,12 +208,12 @@ for transport in $transports; do
"--option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:keyexchange=yes --option=torture:quick=yes" \
"--option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes" \
; do
- plantest "RPC-ECHO on $transport with $bindoptions and $ntlmoptions" dc $smb4torture $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN RPC-ECHO "$*"
+ plantest "rpc.echo on $transport with $bindoptions and $ntlmoptions" dc $smb4torture $transport:"\$SERVER[$bindoptions]" $ntlmoptions -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN RPC-ECHO "$*"
done
done
done
-plantest "RPC-ECHO on ncacn_np over smb2" dc $smb4torture ncacn_np:"\$SERVER[smb2]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN RPC-ECHO "$*"
+plantest "rpc.echo on ncacn_np over smb2" dc $smb4torture ncacn_np:"\$SERVER[smb2]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN RPC-ECHO "$*"
# Tests against the NTVFS POSIX backend
smb2=`$smb4torture --list | grep "^SMB2-" | xargs`
@@ -206,28 +221,28 @@ raw=`$smb4torture --list | grep "^RAW-" | xargs`
base=`$smb4torture --list | grep "^BASE-" | xargs`
for t in $base $raw $smb2; do
- plantest "$t" dc $VALGRIND $smb4torture $ADDARGS //\$SERVER/tmp -U"\$USERNAME"%"\$PASSWORD" $t
+ plansmbtorturetest "$t" dc $ADDARGS //\$SERVER/tmp -U"\$USERNAME"%"\$PASSWORD"
done
rap=`$smb4torture --list | grep "^RAP-" | xargs`
for t in $rap; do
- plantest "$t" dc $VALGRIND $smb4torture $ADDARGS //\$SERVER/IPC\\\$ -U"\$USERNAME"%"\$PASSWORD" $t
+ plansmbtorturetest "$t" dc $ADDARGS //\$SERVER/IPC\\\$ -U"\$USERNAME"%"\$PASSWORD"
done
# Tests against the NTVFS CIFS backend
for t in $base $raw; do
- plantest "ntvfs.cifs.$t" dc $VALGRIND $smb4torture //\$NETBIOSNAME/cifs -U"\$USERNAME"%"\$PASSWORD" $t
+ plantest "ntvfs.cifs.`normalize_testname $t`" dc $VALGRIND $smb4torture //\$NETBIOSNAME/cifs -U"\$USERNAME"%"\$PASSWORD" $t
done
# Local tests
for t in `$smb4torture --list | grep "^LOCAL-" | xargs`; do
- plantest "$t" none $VALGRIND $smb4torture ncalrpc: $t "$*"
+ plansmbtorturetest "$t" none ncalrpc: "$*"
done
if test -f $samba4bindir/tdbtorture
then
- plantest "tdb stress" none $VALGRIND $samba4bindir/tdbtorture
+ plantest "tdb.stress" none $VALGRIND $samba4bindir/tdbtorture
fi
# Pidl tests
@@ -251,33 +266,35 @@ bbdir=$incdir/../../testprogs/blackbox
plantest "blackbox.smbclient" dc $bbdir/test_smbclient.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX"
plantest "blackbox.kinit" dc $bbdir/test_kinit.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$REALM" "\$DOMAIN" "$PREFIX"
plantest "blackbox.cifsdd" dc $bbdir/test_cifsdd.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN"
-plantest "blackbox.nmblookup" dc $bbdir/test_nmblookup.sh "\$NETBIOSNAME" "\$NETBIOSALIAS" "\$SERVER" "\$SERVER_IP"
-plantest "blackbox.nmblookup" member $bbdir/test_nmblookup.sh "\$NETBIOSNAME" "\$NETBIOSALIAS" "\$SERVER" "\$SERVER_IP"
+plantest "blackbox.nmblookup" dc $samba4srcdir/utils/tests/test_nmblookup.sh "\$NETBIOSNAME" "\$NETBIOSALIAS" "\$SERVER" "\$SERVER_IP"
+plantest "blackbox.nmblookup" member $samba4srcdir/utils/tests/test_nmblookup.sh "\$NETBIOSNAME" "\$NETBIOSALIAS" "\$SERVER" "\$SERVER_IP"
+plantest "blackbox.locktest" dc $bbdir/test_locktest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX"
+plantest "blackbox.masktest" dc $bbdir/test_masktest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX"
+plantest "blackbox.gentest" dc $bbdir/test_gentest.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN" "$PREFIX"
# Tests using the "Simple" NTVFS backend
for t in "BASE-RW1"; do
- plantest "ntvfs/simple $t" dc $VALGRIND $smb4torture $ADDARGS //\$SERVER/simple -U"\$USERNAME"%"\$PASSWORD" $t
+ plantest "ntvfs.simple.`normalize_testname $t`" dc $VALGRIND $smb4torture $ADDARGS //\$SERVER/simple -U"\$USERNAME"%"\$PASSWORD" $t
done
DATADIR=$samba4srcdir/../testdata
-plantest "parse samba3" none $samba4bindir/smbscript $DATADIR/samba3/verify $CONFIGURATION $DATADIR/samba3
plantest "js.samba3sam" none $SCRIPTDIR/samba3sam.js $CONFIGURATION `pwd` $DATADIR/samba3/
# Domain Member Tests
-plantest "RPC-ECHO against member server with local creds" member $VALGRIND $smb4torture ncacn_np:"\$NETBIOSNAME" -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" RPC-ECHO "$*"
-plantest "RPC-ECHO against member server with domain creds" member $VALGRIND $smb4torture ncacn_np:"\$NETBIOSNAME" -U"\$DOMAIN/\$DC_USERNAME"%"\$DC_PASSWORD" RPC-ECHO "$*"
-plantest "RPC-SAMR against member server with local creds" member $VALGRIND $smb4torture ncacn_np:"\$NETBIOSNAME" -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" "RPC-SAMR" "$*"
-plantest "RPC-SAMR-USERS against member server with local creds" member $VALGRIND $smb4torture ncacn_np:"\$NETBIOSNAME" -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" "RPC-SAMR-USERS" "$*"
-plantest "RPC-SAMR-PASSWORDS against member server with local creds" member $VALGRIND $smb4torture ncacn_np:"\$NETBIOSNAME" -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" "RPC-SAMR-PASSWORDS" "$*"
+plantest "rpc.echo against member server with local creds" member $VALGRIND $smb4torture ncacn_np:"\$NETBIOSNAME" -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" RPC-ECHO "$*"
+plantest "rpc.echo against member server with domain creds" member $VALGRIND $smb4torture ncacn_np:"\$NETBIOSNAME" -U"\$DOMAIN/\$DC_USERNAME"%"\$DC_PASSWORD" RPC-ECHO "$*"
+plantest "rpc.samr against member server with local creds" member $VALGRIND $smb4torture ncacn_np:"\$NETBIOSNAME" -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" "RPC-SAMR" "$*"
+plantest "rpc.samr.users against member server with local creds" member $VALGRIND $smb4torture ncacn_np:"\$NETBIOSNAME" -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" "RPC-SAMR-USERS" "$*"
+plantest "rpc.samr.passwords against member server with local creds" member $VALGRIND $smb4torture ncacn_np:"\$NETBIOSNAME" -U"\$NETBIOSNAME/\$USERNAME"%"\$PASSWORD" "RPC-SAMR-PASSWORDS" "$*"
plantest "wbinfo -a against member server with domain creds" member $VALGRIND $samba4bindir/wbinfo -a "\$DOMAIN/\$DC_USERNAME"%"\$DC_PASSWORD"
NBT_TESTS=`$smb4torture --list | grep "^NBT-" | xargs`
-for f in $NBT_TESTS; do
- plantest $f dc $smb4torture //\$SERVER/_none_ $f -U\$USERNAME%\$PASSWORD
+for t in $NBT_TESTS; do
+ plansmbtorturetest "$t" dc //\$SERVER/_none_ -U\$USERNAME%\$PASSWORD
done
WB_OPTS="--option=\"torture:strict mode=yes\""
@@ -291,44 +308,42 @@ WINBIND_STRUCT_TESTS=`$smb4torture --list | grep "^WINBIND-STRUCT" | xargs`
WINBIND_NDR_TESTS=`$smb4torture --list | grep "^WINBIND-NDR" | xargs`
for env in dc member; do
for t in $WINBIND_STRUCT_TESTS; do
- plantest $t $env $smb4torture $WB_OPTS //_none_/_none_ $t
+ plansmbtorturetest $t $env $WB_OPTS //_none_/_none_
done
for t in $WINBIND_NDR_TESTS; do
- plantest $t $env $smb4torture $WB_OPTS //_none_/_none_ $t
+ plansmbtorturetest $t $env $WB_OPTS //_none_/_none_
done
done
if test -f $samba4bindir/nsstest
then
- plantest "NSS-TEST using winbind" member $VALGRIND $samba4bindir/nsstest $samba4bindir/shared/libnss_winbind.so
+ plantest "nss.test using winbind" member $VALGRIND $samba4bindir/nsstest $samba4bindir/shared/libnss_winbind.so
fi
-# if python is available, run the python tests:
-if test -f $samba4bindir/smbpython
-then
- PYTHON=bin/smbpython
- SUBUNITRUN="$PYTHON ./scripting/bin/subunitrun"
- plantest "ldb.python" none PYTHONPATH="$PYTHONPATH:lib/ldb/tests/python/" $SUBUNITRUN api
- plantest "credentials.python" none PYTHONPATH="$PYTHONPATH:auth/credentials/tests" $SUBUNITRUN bindings
- plantest "registry.python" none PYTHONPATH="$PYTHONPATH:lib/registry/tests/" $SUBUNITRUN bindings
- plantest "tdb.python" none PYTHONPATH="$PYTHONPATH:lib/tdb/python/tests" $SUBUNITRUN simple
- plantest "auth.python" none PYTHONPATH="$PYTHONPATH:auth/tests/" $SUBUNITRUN bindings
- plantest "security.python" none PYTHONPATH="$PYTHONPATH:libcli/security/tests" $SUBUNITRUN bindings
- plantest "param.python" none PYTHONPATH="$PYTHONPATH:param/tests" $SUBUNITRUN bindings
- plantest "upgrade.python" none $SUBUNITRUN samba.tests.upgrade
- plantest "samba.python" none $SUBUNITRUN samba.tests
- 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 "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
- plantest "winreg.python" dc $SUBUNITRUN samba.tests.dcerpc.registry
- plantest "ldap.python" dc $PYTHON $samba4srcdir/lib/ldb/tests/python/ldap.py $CONFIGURATION \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN
- plantest "blackbox.samba3dump" none $PYTHON scripting/bin/samba3dump $samba4srcdir/../testdata/samba3
- rm -rf $PREFIX/upgrade
- plantest "blackbox.upgrade" none $PYTHON setup/upgrade.py $CONFIGURATION --targetdir=$PREFIX/upgrade ../testdata/samba3 ../testdata/samba3/smb.conf
- rm -rf $PREFIX/provision
- plantest "blackbox.provision.py" none $PYTHON ./setup/provision.py $CONFIGURATION --domain=FOO --realm=foo.example.com --targetdir=$PREFIX/provision
-fi
+PYTHON=bin/smbpython
+SUBUNITRUN="$PYTHON ./scripting/bin/subunitrun"
+plantest "ldb.python" none PYTHONPATH="$PYTHONPATH:lib/ldb/tests/python/" $SUBUNITRUN api
+plantest "credentials.python" none PYTHONPATH="$PYTHONPATH:auth/credentials/tests" $SUBUNITRUN bindings
+plantest "registry.python" none PYTHONPATH="$PYTHONPATH:lib/registry/tests/" $SUBUNITRUN bindings
+plantest "tdb.python" none PYTHONPATH="$PYTHONPATH:lib/tdb/python/tests" $SUBUNITRUN simple
+plantest "auth.python" none PYTHONPATH="$PYTHONPATH:auth/tests/" $SUBUNITRUN bindings
+plantest "security.python" none PYTHONPATH="$PYTHONPATH:libcli/security/tests" $SUBUNITRUN bindings
+plantest "param.python" none PYTHONPATH="$PYTHONPATH:param/tests" $SUBUNITRUN bindings
+plantest "upgrade.python" none $SUBUNITRUN samba.tests.upgrade
+plantest "samba.python" none $SUBUNITRUN samba.tests
+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
+plantest "winreg.python" dc $SUBUNITRUN samba.tests.dcerpc.registry
+plantest "ldap.python" dc $PYTHON $samba4srcdir/lib/ldb/tests/python/ldap.py $CONFIGURATION \$SERVER -U\$USERNAME%\$PASSWORD -W \$DOMAIN
+plantest "blackbox.samba3dump" none $PYTHON scripting/bin/samba3dump $samba4srcdir/../testdata/samba3
+rm -rf $PREFIX/upgrade
+plantest "blackbox.upgrade" none $PYTHON setup/upgrade.py $CONFIGURATION --targetdir=$PREFIX/upgrade ../testdata/samba3 ../testdata/samba3/smb.conf
+rm -rf $PREFIX/provision
+mkdir $PREFIX/provision
+plantest "blackbox.provision.py" none PYTHON="$PYTHON" $samba4srcdir/setup/tests/blackbox_provision.sh "$PREFIX/provision" "$CONFIGURATION"
diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl
index aab2ca8f07..aa4423c7e2 100755
--- a/source4/selftest/selftest.pl
+++ b/source4/selftest/selftest.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
# Bootstrap Samba and run a number of tests against it.
-# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
+# Copyright (C) 2005-2008 Jelmer Vernooij <jelmer@samba.org>
# Published under the GNU GPL, v3 or later.
=pod
@@ -13,7 +13,7 @@ selftest - Samba test runner
selftest --help
-selftest [--srcdir=DIR] [--builddir=DIR] [--target=samba4|samba3|win] [--socket-wrapper] [--quick] [--exclude=FILE] [--include=FILE] [--one] [--prefix=prefix] [--immediate] [--testlist=FILE] [TESTS]
+selftest [--srcdir=DIR] [--builddir=DIR] [--target=samba4|samba3|win|kvm] [--socket-wrapper] [--quick] [--exclude=FILE] [--include=FILE] [--one] [--prefix=prefix] [--immediate] [--testlist=FILE] [TESTS]
=head1 DESCRIPTION
@@ -43,7 +43,7 @@ Change directory to run tests in. Default is 'st'.
Show errors as soon as they happen rather than at the end of the test run.
-=item I<--target samba4|samba3|win>
+=item I<--target samba4|samba3|win|kvm>
Specify test target against which to run. Default is 'samba4'.
@@ -144,6 +144,7 @@ my $opt_expected_failures = undef;
my @opt_exclude = ();
my @opt_include = ();
my $opt_verbose = 0;
+my $opt_image = undef;
my $opt_testenv = 0;
my $ldap = undef;
my $opt_analyse_cmd = undef;
@@ -280,7 +281,7 @@ Usage: $Script [OPTIONS] PREFIX
Generic options:
--help this help page
- --target=samba4|samba3|win Samba version to target
+ --target=samba[34]|win|kvm Samba version to target
--testlist=FILE file to read available tests from
Paths:
@@ -301,6 +302,9 @@ Samba4 Specific:
Samba3 Specific:
--bindir=PATH path to binaries
+Kvm Specific:
+ --image=PATH path to KVM image
+
Behaviour:
--quick run quick overall test
--one abort when the first test fails
@@ -334,6 +338,7 @@ my $result = GetOptions (
'resetup-environment' => \$opt_resetup_env,
'bindir:s' => \$opt_bindir,
'format=s' => \$opt_format,
+ 'image=s' => \$opt_image,
'testlist=s' => \@testlists
);
@@ -442,6 +447,37 @@ if ($opt_target eq "samba4") {
$testenv_default = "dc";
require target::Windows;
$target = new Windows();
+} elsif ($opt_target eq "kvm") {
+ die("Kvm tests will not run with socket wrapper enabled.")
+ if ($opt_socket_wrapper);
+ require target::Kvm;
+ die("No image specified") unless ($opt_image);
+ $target = new Kvm($opt_image, undef);
+}
+
+#
+# Start a Virtual Distributed Ethernet Switch
+# Returns the pid of the switch.
+#
+sub start_vde_switch($)
+{
+ my ($path) = @_;
+
+ system("vde_switch --pidfile $path/vde.pid --sock $path/vde.sock --daemon");
+
+ open(PID, "$path/vde.pid");
+ <PID> =~ /([0-9]+)/;
+ my $pid = $1;
+ close(PID);
+
+ return $pid;
+}
+
+# Stop a Virtual Distributed Ethernet Switch
+sub stop_vde_switch($)
+{
+ my ($pid) = @_;
+ kill 9, $pid;
}
sub read_test_regexes($)
@@ -522,11 +558,13 @@ sub write_clientconf($$)
if (defined($vars->{WINBINDD_SOCKET_DIR})) {
print CF "\twinbindd socket directory = $vars->{WINBINDD_SOCKET_DIR}\n";
}
+ if ($opt_socket_wrapper) {
+ print CF "\tinterfaces = $interfaces\n";
+ }
print CF "
private dir = $prefix_abs/client/private
js include = $srcdir_abs/scripting/libjs
name resolve order = bcast
- interfaces = $interfaces
panic action = $srcdir_abs/script/gdb_backtrace \%PID\% \%PROG\%
max xmit = 32K
notify:inotify = false
diff --git a/source4/selftest/target/Kvm.pm b/source4/selftest/target/Kvm.pm
new file mode 100644
index 0000000000..3b17a2909c
--- /dev/null
+++ b/source4/selftest/target/Kvm.pm
@@ -0,0 +1,167 @@
+#!/usr/bin/perl
+# Start a KVM machine and run a number of tests against it.
+# Copyright (C) 2005-2008 Jelmer Vernooij <jelmer@samba.org>
+# Published under the GNU GPL, v3 or later.
+
+package Kvm;
+
+use strict;
+use Cwd qw(abs_path);
+use FindBin qw($RealBin);
+use POSIX;
+
+sub new($$$$) {
+ my ($classname, $dc_image, $vdesocket) = @_;
+ my $self = {
+ dc_image => $dc_image,
+ vdesocket => $vdesocket,
+ };
+ bless $self;
+ return $self;
+}
+
+sub write_kvm_ifup($$$)
+{
+ my ($self, $path, $ip_prefix) = @_;
+ open(SCRIPT, ">$path/kvm-ifup");
+
+ print SCRIPT <<__EOF__;
+#!/bin/sh
+
+PREFIX=$ip_prefix
+
+/sbin/ifconfig \$1 \$PREFIX.1 up
+
+cat <<EOF>$path/udhcpd.conf
+interface \$1
+start \$PREFIX.20
+end \$PREFIX.20
+max_leases 1
+lease_file $path/udhcpd.leases
+pidfile $path/udhcpd.pid
+EOF
+
+touch $path/udhcpd.leases
+
+/usr/sbin/udhcpd $path/udhcpd.conf
+
+exit 0
+__EOF__
+ close(SCRIPT);
+ chmod(0755, "$path/kvm-ifup");
+
+ return ("$path/kvm-ifup", "$path/udhcpd.pid", "$ip_prefix.20");
+}
+
+sub teardown_env($$)
+{
+ my ($self, $envvars) = @_;
+
+ print "Killing kvm instance $envvars->{KVM_PID}\n";
+
+ kill 9, $envvars->{KVM_PID};
+
+ if (defined($envvars->{DHCPD_PID})) {
+ print "Killing dhcpd instance $envvars->{DHCPD_PID}\n";
+ kill 9, $envvars->{DHCPD_PID};
+ }
+
+ return 0;
+}
+
+sub getlog_env($$)
+{
+ my ($self, $envvars) = @_;
+
+ return "";
+}
+
+sub check_env($$)
+{
+ my ($self, $envvars) = @_;
+
+ # FIXME: Check whether $self->{pid} is still running
+
+ return 1;
+}
+
+sub read_pidfile($)
+{
+ my ($path) = @_;
+
+ open(PID, $path);
+ <PID> =~ /([0-9]+)/;
+ my ($pid) = $1;
+ close(PID);
+ return $pid;
+}
+
+sub start($$$)
+{
+ my ($self, $path, $image) = @_;
+
+ my $pidfile = "$path/kvm.pid";
+
+ my $opts = (defined($ENV{KVM_OPTIONS})?$ENV{KVM_OPTIONS}:"-nographic");
+
+ if (defined($ENV{KVM_SNAPSHOT})) {
+ $opts .= " -loadvm $ENV{KVM_SNAPSHOT}";
+ }
+
+ my $netopts;
+ my $dhcp_pid;
+ my $ip_address;
+
+ if ($self->{vdesocket}) {
+ $netopts = "vde,socket=$self->{vdesocket}";
+ } else {
+ my $ifup_script, $dhcpd_pidfile;
+ ($ifup_script, $dhcpd_pidfile, $ip_address) = $self->write_kvm_ifup($path, "192.168.9");
+ $netopts = "tap,script=$ifup_script";
+ $dhcp_pid = read_pidfile($dhcpd_pidfile);
+ }
+
+ system("kvm -name \"Samba 4 Test Subject\" $opts -monitor unix:$path/kvm.monitor,server,nowait -daemonize -pidfile $pidfile -snapshot $image -net nic -net $netopts");
+
+ return (read_pidfile($pidfile), $dhcp_pid, $ip_address);
+}
+
+sub setup_env($$$)
+{
+ my ($self, $envname, $path) = @_;
+
+ if ($envname eq "dc") {
+ ($self->{dc_pid}, $self->{dc_dhcpd_pid}, $self->{dc_ip}) = $self->start($path, $self->{dc_image});
+
+ sub choose_var($$) {
+ my ($name, $default) = @_;
+ return defined($ENV{"KVM_DC_$name"})?$ENV{"KVM_DC_$name"}:$default;
+ }
+
+ if ($envname eq "dc") {
+ return {
+ KVM_PID => $self->{dc_pid},
+ DHCPD_PID => $self->{dc_dhcpd_pid},
+ USERNAME => choose_var("USERNAME", "Administrator"),
+ PASSWORD => choose_var("PASSWORD", "penguin"),
+ DOMAIN => choose_var("DOMAIN", "SAMBA"),
+ REALM => choose_var("REALM", "SAMBA"),
+ SERVER => choose_var("SERVER", "DC"),
+ SERVER_IP => $self->{dc_ip},
+ NETBIOSNAME => choose_var("NETBIOSNAME", "DC"),
+ NETBIOSALIAS => choose_var("NETBIOSALIAS", "DC"),
+ };
+ } else {
+ return undef;
+ }
+ } else {
+ return undef;
+ }
+}
+
+sub stop($)
+{
+ my ($self) = @_;
+}
+
+1;
diff --git a/source4/selftest/target/Samba4.pm b/source4/selftest/target/Samba4.pm
index 87a86ef06f..563aca876e 100644
--- a/source4/selftest/target/Samba4.pm
+++ b/source4/selftest/target/Samba4.pm
@@ -525,7 +525,7 @@ sub provision($$$$$$)
(system("rm -rf $prefix/*") == 0) or die("Unable to clean up");
mkdir($_, 0777) foreach ($privatedir, $etcdir, $piddir, $ncalrpcdir, $lockdir,
- $tmpdir);
+ $tmpdir, "$tmpdir/test1", "$tmpdir/test2");
my $localbasedn = $basedn;
@@ -569,6 +569,20 @@ sub provision($$$$$$)
posix:sharedelay = 100000
posix:eadb = $lockdir/eadb.tdb
+[test1]
+ path = $tmpdir/test1
+ read only = no
+ ntvfs handler = posix
+ posix:sharedelay = 100000
+ posix:eadb = $lockdir/eadb.tdb
+
+[test2]
+ path = $tmpdir/test2
+ read only = no
+ ntvfs handler = posix
+ posix:sharedelay = 100000
+ posix:eadb = $lockdir/eadb.tdb
+
[cifs]
read only = no
ntvfs handler = cifs
@@ -660,12 +674,12 @@ nogroup:x:65534:nobody
my @provision_options = ();
push (@provision_options, "NSS_WRAPPER_PASSWD=\"$nsswrap_passwd\"");
push (@provision_options, "NSS_WRAPPER_GROUP=\"$nsswrap_group\"");
- if (defined($ENV{PROVISION_PYTHON})) {
- push (@provision_options, "$self->{bindir}/smbpython");
- push (@provision_options, "$self->{setupdir}/provision.py");
- } else {
+ if (defined($ENV{PROVISION_EJS})) {
push (@provision_options, "$self->{bindir}/smbscript");
push (@provision_options, "$self->{setupdir}/provision");
+ } else {
+ push (@provision_options, "$self->{bindir}/smbpython");
+ push (@provision_options, "$self->{setupdir}/provision.py");
}
push (@provision_options, split(' ', $configuration));
push (@provision_options, "--host-name=$netbiosname");
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] <username> [<password>]")
+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)
diff --git a/source4/setup/tests/blackbox_provision.sh b/source4/setup/tests/blackbox_provision.sh
new file mode 100755
index 0000000000..57b11eae5f
--- /dev/null
+++ b/source4/setup/tests/blackbox_provision.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+if [ $# -lt 2 ]; then
+cat <<EOF
+Usage: blackbox_provision.sh PREFIX CONFIGURATION
+EOF
+exit 1;
+fi
+
+PREFIX="$1"
+CONFIGURATION="$2"
+shift 2
+
+testit() {
+ name="$1"
+ shift
+ cmdline="$*"
+ echo "test: $name"
+ $cmdline
+ status=$?
+ if [ x$status = x0 ]; then
+ echo "success: $name"
+ else
+ echo "failure: $name"
+ failed=`expr $failed + 1`
+ fi
+ return $status
+}
+
+testit "simple" $PYTHON ./setup/provision.py $CONFIGURATION --domain=FOO --realm=foo.example.com --targetdir=$PREFIX/simple
+
+reprovision() {
+ $PYTHON ./setup/provision.py $CONFIGURATION --domain=FOO --realm=foo.example.com --targetdir="$PREFIX/reprovision"
+ $PYTHON ./setup/provision.py $CONFIGURATION --domain=FOO --realm=foo.example.com --targetdir="$PREFIX/reprovision"
+}
+
+testit "reprovision" reprovision
+
+exit $failed
diff --git a/source4/smb_server/blob.c b/source4/smb_server/blob.c
index 2b870118ba..8c813204f3 100644
--- a/source4/smb_server/blob.c
+++ b/source4/smb_server/blob.c
@@ -78,7 +78,7 @@ NTSTATUS smbsrv_blob_fill_data(TALLOC_CTX *mem_ctx,
/*
pull a string from a blob in a trans2 request
*/
-size_t smbsrv_blob_pull_string(struct smbsrv_request *req,
+size_t smbsrv_blob_pull_string(struct request_bufinfo *bufinfo,
const DATA_BLOB *blob,
uint16_t offset,
const char **str,
@@ -92,7 +92,7 @@ size_t smbsrv_blob_pull_string(struct smbsrv_request *req,
return 0;
}
- return req_pull_string(req, str,
+ return req_pull_string(bufinfo, str,
blob->data + offset,
blob->length - offset,
STR_NO_RANGE_CHECK | flags);
@@ -521,9 +521,9 @@ NTSTATUS smbsrv_pull_passthru_sfileinfo(TALLOC_CTX *mem_ctx,
union smb_setfileinfo *st,
const DATA_BLOB *blob,
int default_str_flags,
- struct smbsrv_request *req)
+ struct request_bufinfo *bufinfo)
{
- uint32_t len;
+ uint32_t len, ofs;
DATA_BLOB str_blob;
switch (level) {
@@ -560,21 +560,38 @@ NTSTATUS smbsrv_pull_passthru_sfileinfo(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
case RAW_SFILEINFO_RENAME_INFORMATION:
- if (!req) {
- /*
- * TODO: get rid of smbsrv_request argument of
- * smbsrv_blob_pull_string()
- */
- return NT_STATUS_NOT_IMPLEMENTED;
+ if (!bufinfo) {
+ return NT_STATUS_INTERNAL_ERROR;
}
BLOB_CHECK_MIN_SIZE(blob, 12);
-
st->rename_information.in.overwrite = CVAL(blob->data, 0);
st->rename_information.in.root_fid = IVAL(blob->data, 4);
len = IVAL(blob->data, 8);
- str_blob.data = blob->data+12;
- str_blob.length = MIN(blob->length, len);
- smbsrv_blob_pull_string(req, &str_blob, 0,
+ ofs = 12;
+ str_blob = *blob;
+ str_blob.length = MIN(str_blob.length, ofs+len);
+ smbsrv_blob_pull_string(bufinfo, &str_blob, ofs,
+ &st->rename_information.in.new_name,
+ STR_UNICODE);
+ if (st->rename_information.in.new_name == NULL) {
+ return NT_STATUS_FOOBAR;
+ }
+
+ return NT_STATUS_OK;
+
+ case RAW_SFILEINFO_RENAME_INFORMATION_SMB2:
+ /* SMB2 uses a different format for rename information */
+ if (!bufinfo) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+ BLOB_CHECK_MIN_SIZE(blob, 20);
+ st->rename_information.in.overwrite = CVAL(blob->data, 0);
+ st->rename_information.in.root_fid = BVAL(blob->data, 8);
+ len = IVAL(blob->data,16);
+ ofs = 20;
+ str_blob = *blob;
+ str_blob.length = MIN(str_blob.length, ofs+len);
+ smbsrv_blob_pull_string(bufinfo, &str_blob, ofs,
&st->rename_information.in.new_name,
STR_UNICODE);
if (st->rename_information.in.new_name == NULL) {
diff --git a/source4/smb_server/config.mk b/source4/smb_server/config.mk
index f21336ae69..85c969df59 100644
--- a/source4/smb_server/config.mk
+++ b/source4/smb_server/config.mk
@@ -25,5 +25,5 @@ PUBLIC_DEPENDENCIES = \
# End SUBSYSTEM SMB
#######################
-include smb/config.mk
-include smb2/config.mk
+mkinclude smb/config.mk
+mkinclude smb2/config.mk
diff --git a/source4/smb_server/smb/config.mk b/source4/smb_server/smb/config.mk
index 22151ebd3b..7927f295b9 100644
--- a/source4/smb_server/smb/config.mk
+++ b/source4/smb_server/smb/config.mk
@@ -16,6 +16,5 @@ OBJ_FILES = \
signing.o
PUBLIC_DEPENDENCIES = \
ntvfs LIBPACKET CREDENTIALS
-LDFLAGS = $(SUBSYSTEM_SMB_SERVER_OUTPUT)
# End SUBSYSTEM SMB_PROTOCOL
#######################
diff --git a/source4/smb_server/smb/negprot.c b/source4/smb_server/smb/negprot.c
index 6d9ff838cb..00ff3862f5 100644
--- a/source4/smb_server/smb/negprot.c
+++ b/source4/smb_server/smb/negprot.c
@@ -466,6 +466,7 @@ static const struct {
void (*proto_reply_fn)(struct smbsrv_request *req, uint16_t choice);
int protocol_level;
} supported_protocols[] = {
+ {"SMB 2.002", "SMB2", reply_smb2, PROTOCOL_SMB2},
{"SMB 2.001", "SMB2", reply_smb2, PROTOCOL_SMB2},
{"NT LANMAN 1.0", "NT1", reply_nt1, PROTOCOL_NT1},
{"NT LM 0.12", "NT1", reply_nt1, PROTOCOL_NT1},
@@ -508,7 +509,7 @@ void smbsrv_reply_negprot(struct smbsrv_request *req)
return;
}
protos[protos_count] = NULL;
- len = req_pull_ascii4(req, (const char **)&protos[protos_count], p, STR_ASCII|STR_TERMINATE);
+ len = req_pull_ascii4(&req->in.bufinfo, (const char **)&protos[protos_count], p, STR_ASCII|STR_TERMINATE);
p += len;
if (len == 0 || !protos[protos_count]) break;
diff --git a/source4/smb_server/smb/nttrans.c b/source4/smb_server/smb/nttrans.c
index dd2ec15e39..f6edc407d6 100644
--- a/source4/smb_server/smb/nttrans.c
+++ b/source4/smb_server/smb/nttrans.c
@@ -134,7 +134,7 @@ static NTSTATUS nttrans_create(struct smbsrv_request *req,
io->ntcreatex.in.sec_desc = NULL;
io->ntcreatex.in.ea_list = NULL;
- req_pull_string(req, &io->ntcreatex.in.fname,
+ req_pull_string(&req->in.bufinfo, &io->ntcreatex.in.fname,
params + 53,
MIN(fname_len+1, trans->in.params.length - 53),
STR_NO_RANGE_CHECK | STR_TERMINATE);
@@ -622,8 +622,8 @@ void smbsrv_reply_nttrans(struct smbsrv_request *req)
memcpy(trans->in.setup, (char *)(req->in.vwv) + VWV(19),
sizeof(uint16_t) * trans->in.setup_count);
- if (!req_pull_blob(req, req->in.hdr + param_ofs, param_count, &trans->in.params) ||
- !req_pull_blob(req, req->in.hdr + data_ofs, data_count, &trans->in.data)) {
+ if (!req_pull_blob(&req->in.bufinfo, req->in.hdr + param_ofs, param_count, &trans->in.params) ||
+ !req_pull_blob(&req->in.bufinfo, req->in.hdr + data_ofs, data_count, &trans->in.data)) {
smbsrv_send_error(req, NT_STATUS_FOOBAR);
return;
}
diff --git a/source4/smb_server/smb/receive.c b/source4/smb_server/smb/receive.c
index 3f590decca..e3d247cbc0 100644
--- a/source4/smb_server/smb/receive.c
+++ b/source4/smb_server/smb/receive.c
@@ -151,6 +151,9 @@ NTSTATUS smbsrv_recv_smb_request(void *private, DATA_BLOB blob)
req->flags2 = SVAL(req->in.hdr, HDR_FLG2);
+ /* fix the bufinfo */
+ smbsrv_setup_bufinfo(req);
+
if (!smbsrv_signing_check_incoming(req)) {
smbsrv_send_error(req, NT_STATUS_ACCESS_DENIED);
return NT_STATUS_OK;
@@ -620,6 +623,9 @@ void smbsrv_chain_reply(struct smbsrv_request *req)
req->in.data_size = data_size;
req->in.ptr = data;
+ /* fix the bufinfo */
+ smbsrv_setup_bufinfo(req);
+
req->chain_count++;
SSVAL(req->out.vwv, VWV(0), chain_cmd);
diff --git a/source4/smb_server/smb/reply.c b/source4/smb_server/smb/reply.c
index aff0587bc6..40cad91062 100644
--- a/source4/smb_server/smb/reply.c
+++ b/source4/smb_server/smb/reply.c
@@ -58,9 +58,9 @@ void smbsrv_reply_tcon(struct smbsrv_request *req)
con.tcon.level = RAW_TCON_TCON;
p = req->in.data;
- p += req_pull_ascii4(req, &con.tcon.in.service, p, STR_TERMINATE);
- p += req_pull_ascii4(req, &con.tcon.in.password, p, STR_TERMINATE);
- p += req_pull_ascii4(req, &con.tcon.in.dev, p, STR_TERMINATE);
+ p += req_pull_ascii4(&req->in.bufinfo, &con.tcon.in.service, p, STR_TERMINATE);
+ p += req_pull_ascii4(&req->in.bufinfo, &con.tcon.in.password, p, STR_TERMINATE);
+ p += req_pull_ascii4(&req->in.bufinfo, &con.tcon.in.dev, p, STR_TERMINATE);
if (!con.tcon.in.service || !con.tcon.in.password || !con.tcon.in.dev) {
smbsrv_send_error(req, NT_STATUS_INVALID_PARAMETER);
@@ -106,14 +106,14 @@ void smbsrv_reply_tcon_and_X(struct smbsrv_request *req)
p = req->in.data;
- if (!req_pull_blob(req, p, passlen, &con.tconx.in.password)) {
+ if (!req_pull_blob(&req->in.bufinfo, p, passlen, &con.tconx.in.password)) {
smbsrv_send_error(req, NT_STATUS_ILL_FORMED_PASSWORD);
return;
}
p += passlen;
- p += req_pull_string(req, &con.tconx.in.path, p, -1, STR_TERMINATE);
- p += req_pull_string(req, &con.tconx.in.device, p, -1, STR_ASCII);
+ p += req_pull_string(&req->in.bufinfo, &con.tconx.in.path, p, -1, STR_TERMINATE);
+ p += req_pull_string(&req->in.bufinfo, &con.tconx.in.device, p, -1, STR_ASCII);
if (!con.tconx.in.path || !con.tconx.in.device) {
smbsrv_send_error(req, NT_STATUS_BAD_DEVICE_TYPE);
@@ -223,7 +223,7 @@ void smbsrv_reply_chkpth(struct smbsrv_request *req)
SMBSRV_TALLOC_IO_PTR(io, union smb_chkpath);
SMBSRV_SETUP_NTVFS_REQUEST(reply_simple_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
- req_pull_ascii4(req, &io->chkpath.in.path, req->in.data, STR_TERMINATE);
+ req_pull_ascii4(&req->in.bufinfo, &io->chkpath.in.path, req->in.data, STR_TERMINATE);
SMBSRV_CALL_NTVFS_BACKEND(ntvfs_chkpath(req->ntvfs, io));
}
@@ -264,7 +264,7 @@ void smbsrv_reply_getatr(struct smbsrv_request *req)
st->getattr.level = RAW_FILEINFO_GETATTR;
/* parse request */
- req_pull_ascii4(req, &st->getattr.in.file.path, req->in.data, STR_TERMINATE);
+ req_pull_ascii4(&req->in.bufinfo, &st->getattr.in.file.path, req->in.data, STR_TERMINATE);
if (!st->getattr.in.file.path) {
smbsrv_send_error(req, NT_STATUS_OBJECT_NAME_NOT_FOUND);
return;
@@ -290,7 +290,7 @@ void smbsrv_reply_setatr(struct smbsrv_request *req)
st->setattr.in.attrib = SVAL(req->in.vwv, VWV(0));
st->setattr.in.write_time = srv_pull_dos_date3(req->smb_conn, req->in.vwv + VWV(1));
- req_pull_ascii4(req, &st->setattr.in.file.path, req->in.data, STR_TERMINATE);
+ req_pull_ascii4(&req->in.bufinfo, &st->setattr.in.file.path, req->in.data, STR_TERMINATE);
if (!st->setattr.in.file.path) {
smbsrv_send_error(req, NT_STATUS_OBJECT_NAME_NOT_FOUND);
@@ -379,7 +379,7 @@ void smbsrv_reply_open(struct smbsrv_request *req)
oi->openold.in.open_mode = SVAL(req->in.vwv, VWV(0));
oi->openold.in.search_attrs = SVAL(req->in.vwv, VWV(1));
- req_pull_ascii4(req, &oi->openold.in.fname, req->in.data, STR_TERMINATE);
+ req_pull_ascii4(&req->in.bufinfo, &oi->openold.in.fname, req->in.data, STR_TERMINATE);
if (!oi->openold.in.fname) {
smbsrv_send_error(req, NT_STATUS_OBJECT_NAME_NOT_FOUND);
@@ -452,7 +452,7 @@ void smbsrv_reply_open_and_X(struct smbsrv_request *req)
oi->openx.in.size = IVAL(req->in.vwv, VWV(9));
oi->openx.in.timeout = IVAL(req->in.vwv, VWV(11));
- req_pull_ascii4(req, &oi->openx.in.fname, req->in.data, STR_TERMINATE);
+ req_pull_ascii4(&req->in.bufinfo, &oi->openx.in.fname, req->in.data, STR_TERMINATE);
if (!oi->openx.in.fname) {
smbsrv_send_error(req, NT_STATUS_OBJECT_NAME_NOT_FOUND);
@@ -502,7 +502,7 @@ void smbsrv_reply_mknew(struct smbsrv_request *req)
oi->mknew.in.attrib = SVAL(req->in.vwv, VWV(0));
oi->mknew.in.write_time = srv_pull_dos_date3(req->smb_conn, req->in.vwv + VWV(1));
- req_pull_ascii4(req, &oi->mknew.in.fname, req->in.data, STR_TERMINATE);
+ req_pull_ascii4(&req->in.bufinfo, &oi->mknew.in.fname, req->in.data, STR_TERMINATE);
if (!oi->mknew.in.fname) {
smbsrv_send_error(req, NT_STATUS_OBJECT_NAME_NOT_FOUND);
@@ -551,7 +551,7 @@ void smbsrv_reply_ctemp(struct smbsrv_request *req)
/* the filename is actually a directory name, the server provides a filename
in that directory */
- req_pull_ascii4(req, &oi->ctemp.in.directory, req->in.data, STR_TERMINATE);
+ req_pull_ascii4(&req->in.bufinfo, &oi->ctemp.in.directory, req->in.data, STR_TERMINATE);
if (!oi->ctemp.in.directory) {
smbsrv_send_error(req, NT_STATUS_OBJECT_NAME_NOT_FOUND);
@@ -576,7 +576,7 @@ void smbsrv_reply_unlink(struct smbsrv_request *req)
unl->unlink.in.attrib = SVAL(req->in.vwv, VWV(0));
- req_pull_ascii4(req, &unl->unlink.in.pattern, req->in.data, STR_TERMINATE);
+ req_pull_ascii4(&req->in.bufinfo, &unl->unlink.in.pattern, req->in.data, STR_TERMINATE);
SMBSRV_CALL_NTVFS_BACKEND(ntvfs_unlink(req->ntvfs, unl));
}
@@ -958,7 +958,7 @@ void smbsrv_reply_write(struct smbsrv_request *req)
io->write.in.data = req->in.data + 3;
/* make sure they gave us the data they promised */
- if (req_data_oob(req, io->write.in.data, io->write.in.count)) {
+ if (req_data_oob(&req->in.bufinfo, io->write.in.data, io->write.in.count)) {
smbsrv_send_error(req, NT_STATUS_FOOBAR);
return;
}
@@ -1027,7 +1027,7 @@ void smbsrv_reply_write_and_X(struct smbsrv_request *req)
}
/* make sure the data is in bounds */
- if (req_data_oob(req, io->writex.in.data, io->writex.in.count)) {
+ if (req_data_oob(&req->in.bufinfo, io->writex.in.data, io->writex.in.count)) {
smbsrv_send_error(req, NT_STATUS_FOOBAR);
return;
}
@@ -1163,7 +1163,7 @@ void smbsrv_reply_writeclose(struct smbsrv_request *req)
io->writeclose.in.data = req->in.data + 1;
/* make sure they gave us the data they promised */
- if (req_data_oob(req, io->writeclose.in.data, io->writeclose.in.count)) {
+ if (req_data_oob(&req->in.bufinfo, io->writeclose.in.data, io->writeclose.in.count)) {
smbsrv_send_error(req, NT_STATUS_FOOBAR);
return;
}
@@ -1313,7 +1313,7 @@ void smbsrv_reply_printopen(struct smbsrv_request *req)
oi->splopen.in.setup_length = SVAL(req->in.vwv, VWV(0));
oi->splopen.in.mode = SVAL(req->in.vwv, VWV(1));
- req_pull_ascii4(req, &oi->splopen.in.ident, req->in.data, STR_TERMINATE);
+ req_pull_ascii4(&req->in.bufinfo, &oi->splopen.in.ident, req->in.data, STR_TERMINATE);
SMBSRV_CALL_NTVFS_BACKEND(ntvfs_open(req->ntvfs, oi));
}
@@ -1426,7 +1426,7 @@ void smbsrv_reply_printwrite(struct smbsrv_request *req)
io->splwrite.in.data = req->in.data + 3;
/* make sure they gave us the data they promised */
- if (req_data_oob(req, io->splwrite.in.data, io->splwrite.in.count)) {
+ if (req_data_oob(&req->in.bufinfo, io->splwrite.in.data, io->splwrite.in.count)) {
smbsrv_send_error(req, NT_STATUS_FOOBAR);
return;
}
@@ -1449,7 +1449,7 @@ void smbsrv_reply_mkdir(struct smbsrv_request *req)
SMBSRV_SETUP_NTVFS_REQUEST(reply_simple_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
io->generic.level = RAW_MKDIR_MKDIR;
- req_pull_ascii4(req, &io->mkdir.in.path, req->in.data, STR_TERMINATE);
+ req_pull_ascii4(&req->in.bufinfo, &io->mkdir.in.path, req->in.data, STR_TERMINATE);
SMBSRV_CALL_NTVFS_BACKEND(ntvfs_mkdir(req->ntvfs, io));
}
@@ -1467,7 +1467,7 @@ void smbsrv_reply_rmdir(struct smbsrv_request *req)
SMBSRV_TALLOC_IO_PTR(io, struct smb_rmdir);
SMBSRV_SETUP_NTVFS_REQUEST(reply_simple_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
- req_pull_ascii4(req, &io->in.path, req->in.data, STR_TERMINATE);
+ req_pull_ascii4(&req->in.bufinfo, &io->in.path, req->in.data, STR_TERMINATE);
SMBSRV_CALL_NTVFS_BACKEND(ntvfs_rmdir(req->ntvfs, io));
}
@@ -1490,8 +1490,8 @@ void smbsrv_reply_mv(struct smbsrv_request *req)
io->rename.in.attrib = SVAL(req->in.vwv, VWV(0));
p = req->in.data;
- p += req_pull_ascii4(req, &io->rename.in.pattern1, p, STR_TERMINATE);
- p += req_pull_ascii4(req, &io->rename.in.pattern2, p, STR_TERMINATE);
+ p += req_pull_ascii4(&req->in.bufinfo, &io->rename.in.pattern1, p, STR_TERMINATE);
+ p += req_pull_ascii4(&req->in.bufinfo, &io->rename.in.pattern2, p, STR_TERMINATE);
if (!io->rename.in.pattern1 || !io->rename.in.pattern2) {
smbsrv_send_error(req, NT_STATUS_FOOBAR);
@@ -1521,8 +1521,8 @@ void smbsrv_reply_ntrename(struct smbsrv_request *req)
io->ntrename.in.cluster_size = IVAL(req->in.vwv, VWV(2));
p = req->in.data;
- p += req_pull_ascii4(req, &io->ntrename.in.old_name, p, STR_TERMINATE);
- p += req_pull_ascii4(req, &io->ntrename.in.new_name, p, STR_TERMINATE);
+ p += req_pull_ascii4(&req->in.bufinfo, &io->ntrename.in.old_name, p, STR_TERMINATE);
+ p += req_pull_ascii4(&req->in.bufinfo, &io->ntrename.in.new_name, p, STR_TERMINATE);
if (!io->ntrename.in.old_name || !io->ntrename.in.new_name) {
smbsrv_send_error(req, NT_STATUS_FOOBAR);
@@ -1568,8 +1568,8 @@ void smbsrv_reply_copy(struct smbsrv_request *req)
cp->in.flags = SVAL(req->in.vwv, VWV(2));
p = req->in.data;
- p += req_pull_ascii4(req, &cp->in.path1, p, STR_TERMINATE);
- p += req_pull_ascii4(req, &cp->in.path2, p, STR_TERMINATE);
+ p += req_pull_ascii4(&req->in.bufinfo, &cp->in.path1, p, STR_TERMINATE);
+ p += req_pull_ascii4(&req->in.bufinfo, &cp->in.path2, p, STR_TERMINATE);
if (!cp->in.path1 || !cp->in.path2) {
smbsrv_send_error(req, NT_STATUS_FOOBAR);
@@ -1638,7 +1638,7 @@ void smbsrv_reply_lockingX(struct smbsrv_request *req)
}
/* make sure we got the promised data */
- if (req_data_oob(req, req->in.data, total_locks * lck_size)) {
+ if (req_data_oob(&req->in.bufinfo, req->in.data, total_locks * lck_size)) {
smbsrv_send_error(req, NT_STATUS_FOOBAR);
return;
}
@@ -1877,22 +1877,22 @@ static void reply_sesssetup_old(struct smbsrv_request *req)
passlen = SVAL(req->in.vwv, VWV(7));
/* check the request isn't malformed */
- if (req_data_oob(req, req->in.data, passlen)) {
+ if (req_data_oob(&req->in.bufinfo, req->in.data, passlen)) {
smbsrv_send_error(req, NT_STATUS_FOOBAR);
return;
}
p = req->in.data;
- if (!req_pull_blob(req, p, passlen, &io->old.in.password)) {
+ if (!req_pull_blob(&req->in.bufinfo, p, passlen, &io->old.in.password)) {
smbsrv_send_error(req, NT_STATUS_FOOBAR);
return;
}
p += passlen;
- p += req_pull_string(req, &io->old.in.user, p, -1, STR_TERMINATE);
- p += req_pull_string(req, &io->old.in.domain, p, -1, STR_TERMINATE);
- p += req_pull_string(req, &io->old.in.os, p, -1, STR_TERMINATE);
- p += req_pull_string(req, &io->old.in.lanman, p, -1, STR_TERMINATE);
+ p += req_pull_string(&req->in.bufinfo, &io->old.in.user, p, -1, STR_TERMINATE);
+ p += req_pull_string(&req->in.bufinfo, &io->old.in.domain, p, -1, STR_TERMINATE);
+ p += req_pull_string(&req->in.bufinfo, &io->old.in.os, p, -1, STR_TERMINATE);
+ p += req_pull_string(&req->in.bufinfo, &io->old.in.lanman, p, -1, STR_TERMINATE);
/* call the generic handler */
smbsrv_sesssetup_backend(req, io);
@@ -1921,28 +1921,28 @@ static void reply_sesssetup_nt1(struct smbsrv_request *req)
io->nt1.in.capabilities = IVAL(req->in.vwv, VWV(11));
/* check the request isn't malformed */
- if (req_data_oob(req, req->in.data, passlen1) ||
- req_data_oob(req, req->in.data + passlen1, passlen2)) {
+ if (req_data_oob(&req->in.bufinfo, req->in.data, passlen1) ||
+ req_data_oob(&req->in.bufinfo, req->in.data + passlen1, passlen2)) {
smbsrv_send_error(req, NT_STATUS_FOOBAR);
return;
}
p = req->in.data;
- if (!req_pull_blob(req, p, passlen1, &io->nt1.in.password1)) {
+ if (!req_pull_blob(&req->in.bufinfo, p, passlen1, &io->nt1.in.password1)) {
smbsrv_send_error(req, NT_STATUS_FOOBAR);
return;
}
p += passlen1;
- if (!req_pull_blob(req, p, passlen2, &io->nt1.in.password2)) {
+ if (!req_pull_blob(&req->in.bufinfo, p, passlen2, &io->nt1.in.password2)) {
smbsrv_send_error(req, NT_STATUS_FOOBAR);
return;
}
p += passlen2;
- p += req_pull_string(req, &io->nt1.in.user, p, -1, STR_TERMINATE);
- p += req_pull_string(req, &io->nt1.in.domain, p, -1, STR_TERMINATE);
- p += req_pull_string(req, &io->nt1.in.os, p, -1, STR_TERMINATE);
- p += req_pull_string(req, &io->nt1.in.lanman, p, -1, STR_TERMINATE);
+ p += req_pull_string(&req->in.bufinfo, &io->nt1.in.user, p, -1, STR_TERMINATE);
+ p += req_pull_string(&req->in.bufinfo, &io->nt1.in.domain, p, -1, STR_TERMINATE);
+ p += req_pull_string(&req->in.bufinfo, &io->nt1.in.os, p, -1, STR_TERMINATE);
+ p += req_pull_string(&req->in.bufinfo, &io->nt1.in.lanman, p, -1, STR_TERMINATE);
/* call the generic handler */
smbsrv_sesssetup_backend(req, io);
@@ -1971,15 +1971,15 @@ static void reply_sesssetup_spnego(struct smbsrv_request *req)
io->spnego.in.capabilities = IVAL(req->in.vwv, VWV(10));
p = req->in.data;
- if (!req_pull_blob(req, p, blob_len, &io->spnego.in.secblob)) {
+ if (!req_pull_blob(&req->in.bufinfo, p, blob_len, &io->spnego.in.secblob)) {
smbsrv_send_error(req, NT_STATUS_FOOBAR);
return;
}
p += blob_len;
- p += req_pull_string(req, &io->spnego.in.os, p, -1, STR_TERMINATE);
- p += req_pull_string(req, &io->spnego.in.lanman, p, -1, STR_TERMINATE);
- p += req_pull_string(req, &io->spnego.in.workgroup, p, -1, STR_TERMINATE);
+ p += req_pull_string(&req->in.bufinfo, &io->spnego.in.os, p, -1, STR_TERMINATE);
+ p += req_pull_string(&req->in.bufinfo, &io->spnego.in.lanman, p, -1, STR_TERMINATE);
+ p += req_pull_string(&req->in.bufinfo, &io->spnego.in.workgroup, p, -1, STR_TERMINATE);
/* call the generic handler */
smbsrv_sesssetup_backend(req, io);
@@ -2199,7 +2199,7 @@ void smbsrv_reply_ntcreate_and_X(struct smbsrv_request *req)
fname_len++;
}
- req_pull_string(req, &io->ntcreatex.in.fname, req->in.data, fname_len, STR_TERMINATE);
+ req_pull_string(&req->in.bufinfo, &io->ntcreatex.in.fname, req->in.data, fname_len, STR_TERMINATE);
if (!io->ntcreatex.in.fname) {
smbsrv_send_error(req, NT_STATUS_FOOBAR);
return;
diff --git a/source4/smb_server/smb/request.c b/source4/smb_server/smb/request.c
index 8f6d664500..d7f3793f23 100644
--- a/source4/smb_server/smb/request.c
+++ b/source4/smb_server/smb/request.c
@@ -33,6 +33,20 @@
/* we over allocate the data buffer to prevent too many realloc calls */
#define REQ_OVER_ALLOCATION 0
+/* setup the bufinfo used for strings and range checking */
+void smbsrv_setup_bufinfo(struct smbsrv_request *req)
+{
+ req->in.bufinfo.mem_ctx = req;
+ req->in.bufinfo.flags = 0;
+ if (req->flags2 & FLAGS2_UNICODE_STRINGS) {
+ req->in.bufinfo.flags |= BUFINFO_FLAG_UNICODE;
+ }
+ req->in.bufinfo.align_base = req->in.buffer;
+ req->in.bufinfo.data = req->in.data;
+ req->in.bufinfo.data_size = req->in.data_size;
+}
+
+
static int smbsrv_request_destructor(struct smbsrv_request *req)
{
DLIST_REMOVE(req->smb_conn->requests, req);
@@ -461,13 +475,13 @@ size_t req_append_var_block(struct smbsrv_request *req,
on failure zero is returned and *dest is set to NULL, otherwise the number
of bytes consumed in the packet is returned
*/
-static size_t req_pull_ucs2(struct smbsrv_request *req, const char **dest, const uint8_t *src, int byte_len, uint_t flags)
+static size_t req_pull_ucs2(struct request_bufinfo *bufinfo, const char **dest, const uint8_t *src, int byte_len, uint_t flags)
{
int src_len, src_len2, alignment=0;
ssize_t ret;
char *dest2;
- if (!(flags & STR_NOALIGN) && ucs2_align(req->in.buffer, src, flags)) {
+ if (!(flags & STR_NOALIGN) && ucs2_align(bufinfo->align_base, src, flags)) {
src++;
alignment=1;
if (byte_len != -1) {
@@ -478,7 +492,7 @@ static size_t req_pull_ucs2(struct smbsrv_request *req, const char **dest, const
if (flags & STR_NO_RANGE_CHECK) {
src_len = byte_len;
} else {
- src_len = req->in.data_size - PTR_DIFF(src, req->in.data);
+ src_len = bufinfo->data_size - PTR_DIFF(src, bufinfo->data);
if (byte_len != -1 && src_len > byte_len) {
src_len = byte_len;
}
@@ -491,11 +505,11 @@ static size_t req_pull_ucs2(struct smbsrv_request *req, const char **dest, const
src_len2 = utf16_len_n(src, src_len);
if (src_len2 == 0) {
- *dest = talloc_strdup(req, "");
+ *dest = talloc_strdup(bufinfo->mem_ctx, "");
return src_len2 + alignment;
}
- ret = convert_string_talloc(req, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2);
+ ret = convert_string_talloc(bufinfo->mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2);
if (ret == -1) {
*dest = NULL;
@@ -519,7 +533,7 @@ static size_t req_pull_ucs2(struct smbsrv_request *req, const char **dest, const
on failure zero is returned and *dest is set to NULL, otherwise the number
of bytes consumed in the packet is returned
*/
-static size_t req_pull_ascii(struct smbsrv_request *req, const char **dest, const uint8_t *src, int byte_len, uint_t flags)
+static size_t req_pull_ascii(struct request_bufinfo *bufinfo, const char **dest, const uint8_t *src, int byte_len, uint_t flags)
{
int src_len, src_len2;
ssize_t ret;
@@ -528,7 +542,7 @@ static size_t req_pull_ascii(struct smbsrv_request *req, const char **dest, cons
if (flags & STR_NO_RANGE_CHECK) {
src_len = byte_len;
} else {
- src_len = req->in.data_size - PTR_DIFF(src, req->in.data);
+ src_len = bufinfo->data_size - PTR_DIFF(src, bufinfo->data);
if (src_len < 0) {
*dest = NULL;
return 0;
@@ -544,7 +558,7 @@ static size_t req_pull_ascii(struct smbsrv_request *req, const char **dest, cons
src_len2++;
}
- ret = convert_string_talloc(req, lp_iconv_convenience(global_loadparm), CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2);
+ ret = convert_string_talloc(bufinfo->mem_ctx, lp_iconv_convenience(global_loadparm), CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2);
if (ret == -1) {
*dest = NULL;
@@ -568,14 +582,14 @@ static size_t req_pull_ascii(struct smbsrv_request *req, const char **dest, cons
on failure zero is returned and *dest is set to NULL, otherwise the number
of bytes consumed in the packet is returned
*/
-size_t req_pull_string(struct smbsrv_request *req, const char **dest, const uint8_t *src, int byte_len, uint_t flags)
+size_t req_pull_string(struct request_bufinfo *bufinfo, const char **dest, const uint8_t *src, int byte_len, uint_t flags)
{
if (!(flags & STR_ASCII) &&
- (((flags & STR_UNICODE) || (req->flags2 & FLAGS2_UNICODE_STRINGS)))) {
- return req_pull_ucs2(req, dest, src, byte_len, flags);
+ (((flags & STR_UNICODE) || (bufinfo->flags & BUFINFO_FLAG_UNICODE)))) {
+ return req_pull_ucs2(bufinfo, dest, src, byte_len, flags);
}
- return req_pull_ascii(req, dest, src, byte_len, flags);
+ return req_pull_ascii(bufinfo, dest, src, byte_len, flags);
}
@@ -588,13 +602,13 @@ size_t req_pull_string(struct smbsrv_request *req, const char **dest, const uint
on failure *dest is set to the zero length string. This seems to
match win2000 behaviour
*/
-size_t req_pull_ascii4(struct smbsrv_request *req, const char **dest, const uint8_t *src, uint_t flags)
+size_t req_pull_ascii4(struct request_bufinfo *bufinfo, const char **dest, const uint8_t *src, uint_t flags)
{
ssize_t ret;
- if (PTR_DIFF(src, req->in.data) + 1 > req->in.data_size) {
+ if (PTR_DIFF(src, bufinfo->data) + 1 > bufinfo->data_size) {
/* win2000 treats this as the empty string! */
- (*dest) = talloc_strdup(req, "");
+ (*dest) = talloc_strdup(bufinfo->mem_ctx, "");
return 0;
}
@@ -603,9 +617,9 @@ size_t req_pull_ascii4(struct smbsrv_request *req, const char **dest, const uint
behaviour */
src++;
- ret = req_pull_string(req, dest, src, -1, flags);
+ ret = req_pull_string(bufinfo, dest, src, -1, flags);
if (ret == -1) {
- (*dest) = talloc_strdup(req, "");
+ (*dest) = talloc_strdup(bufinfo->mem_ctx, "");
return 1;
}
@@ -617,30 +631,30 @@ size_t req_pull_ascii4(struct smbsrv_request *req, const char **dest, const uint
return false if any part is outside the data portion of the packet
*/
-bool req_pull_blob(struct smbsrv_request *req, const uint8_t *src, int len, DATA_BLOB *blob)
+bool req_pull_blob(struct request_bufinfo *bufinfo, const uint8_t *src, int len, DATA_BLOB *blob)
{
- if (len != 0 && req_data_oob(req, src, len)) {
+ if (len != 0 && req_data_oob(bufinfo, src, len)) {
return false;
}
- (*blob) = data_blob_talloc(req, src, len);
+ (*blob) = data_blob_talloc(bufinfo->mem_ctx, src, len);
return true;
}
/* check that a lump of data in a request is within the bounds of the data section of
the packet */
-bool req_data_oob(struct smbsrv_request *req, const uint8_t *ptr, uint32_t count)
+bool req_data_oob(struct request_bufinfo *bufinfo, const uint8_t *ptr, uint32_t count)
{
if (count == 0) {
return false;
}
/* be careful with wraparound! */
- if (ptr < req->in.data ||
- ptr >= req->in.data + req->in.data_size ||
- count > req->in.data_size ||
- ptr + count > req->in.data + req->in.data_size) {
+ if (ptr < bufinfo->data ||
+ ptr >= bufinfo->data + bufinfo->data_size ||
+ count > bufinfo->data_size ||
+ ptr + count > bufinfo->data + bufinfo->data_size) {
return true;
}
return false;
diff --git a/source4/smb_server/smb/search.c b/source4/smb_server/smb/search.c
index ccf2ff7365..90b2331271 100644
--- a/source4/smb_server/smb/search.c
+++ b/source4/smb_server/smb/search.c
@@ -129,14 +129,14 @@ void smbsrv_reply_search(struct smbsrv_request *req)
SMBSRV_TALLOC_IO_PTR(sf, union smb_search_first);
p = req->in.data;
- p += req_pull_ascii4(req, &sf->search_first.in.pattern,
+ p += req_pull_ascii4(&req->in.bufinfo, &sf->search_first.in.pattern,
p, STR_TERMINATE);
if (!sf->search_first.in.pattern) {
smbsrv_send_error(req, NT_STATUS_OBJECT_NAME_NOT_FOUND);
return;
}
- if (req_data_oob(req, p, 3)) {
+ if (req_data_oob(&req->in.bufinfo, p, 3)) {
smbsrv_send_error(req, NT_STATUS_INVALID_PARAMETER);
return;
}
@@ -167,7 +167,7 @@ void smbsrv_reply_search(struct smbsrv_request *req)
union smb_search_next *sn;
if (resume_key_length != 21 ||
- req_data_oob(req, p, 21) ||
+ req_data_oob(&req->in.bufinfo, p, 21) ||
level == RAW_SEARCH_FUNIQUE) {
smbsrv_send_error(req, NT_STATUS_INVALID_PARAMETER);
return;
@@ -242,13 +242,13 @@ void smbsrv_reply_fclose(struct smbsrv_request *req)
SMBSRV_SETUP_NTVFS_REQUEST(reply_fclose_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
p = req->in.data;
- p += req_pull_ascii4(req, &pattern, p, STR_TERMINATE);
+ p += req_pull_ascii4(&req->in.bufinfo, &pattern, p, STR_TERMINATE);
if (pattern && *pattern) {
smbsrv_send_error(req, NT_STATUS_INVALID_PARAMETER);
return;
}
- if (req_data_oob(req, p, 3)) {
+ if (req_data_oob(&req->in.bufinfo, p, 3)) {
smbsrv_send_error(req, NT_STATUS_INVALID_PARAMETER);
return;
}
@@ -264,7 +264,7 @@ void smbsrv_reply_fclose(struct smbsrv_request *req)
return;
}
- if (req_data_oob(req, p, 21)) {
+ if (req_data_oob(&req->in.bufinfo, p, 21)) {
smbsrv_send_error(req, NT_STATUS_INVALID_PARAMETER);
return;
}
diff --git a/source4/smb_server/smb/trans2.c b/source4/smb_server/smb/trans2.c
index 45ea234d09..3336169bb0 100644
--- a/source4/smb_server/smb/trans2.c
+++ b/source4/smb_server/smb/trans2.c
@@ -248,7 +248,7 @@ static NTSTATUS trans2_open(struct smbsrv_request *req, struct trans_op *op)
io->t2open.in.num_eas = 0;
io->t2open.in.eas = NULL;
- smbsrv_blob_pull_string(req, &trans->in.params, 28, &io->t2open.in.fname, 0);
+ smbsrv_blob_pull_string(&req->in.bufinfo, &trans->in.params, 28, &io->t2open.in.fname, 0);
if (io->t2open.in.fname == NULL) {
return NT_STATUS_FOOBAR;
}
@@ -296,7 +296,7 @@ static NTSTATUS trans2_mkdir(struct smbsrv_request *req, struct trans_op *op)
NT_STATUS_HAVE_NO_MEMORY(io);
io->t2mkdir.level = RAW_MKDIR_T2MKDIR;
- smbsrv_blob_pull_string(req, &trans->in.params, 4, &io->t2mkdir.in.path, 0);
+ smbsrv_blob_pull_string(&req->in.bufinfo, &trans->in.params, 4, &io->t2mkdir.in.path, 0);
if (io->t2mkdir.in.path == NULL) {
return NT_STATUS_FOOBAR;
}
@@ -461,7 +461,7 @@ static NTSTATUS trans2_qpathinfo(struct smbsrv_request *req, struct trans_op *op
level = SVAL(trans->in.params.data, 0);
- smbsrv_blob_pull_string(req, &trans->in.params, 6, &st->generic.in.file.path, 0);
+ smbsrv_blob_pull_string(&req->in.bufinfo, &trans->in.params, 6, &st->generic.in.file.path, 0);
if (st->generic.in.file.path == NULL) {
return NT_STATUS_FOOBAR;
}
@@ -602,7 +602,7 @@ static NTSTATUS trans2_parse_sfileinfo(struct smbsrv_request *req,
return smbsrv_pull_passthru_sfileinfo(st, passthru_level, st,
blob, SMBSRV_REQ_DEFAULT_STR_FLAGS(req),
- req);
+ &req->in.bufinfo);
}
/*
@@ -661,7 +661,7 @@ static NTSTATUS trans2_setpathinfo(struct smbsrv_request *req, struct trans_op *
level = SVAL(trans->in.params.data, 0);
- smbsrv_blob_pull_string(req, &trans->in.params, 6, &st->generic.in.file.path, 0);
+ smbsrv_blob_pull_string(&req->in.bufinfo, &trans->in.params, 6, &st->generic.in.file.path, 0);
if (st->generic.in.file.path == NULL) {
return NT_STATUS_FOOBAR;
}
@@ -859,7 +859,7 @@ static NTSTATUS trans2_findfirst(struct smbsrv_request *req, struct trans_op *op
level = SVAL(trans->in.params.data, 6);
search->t2ffirst.in.storage_type = IVAL(trans->in.params.data, 8);
- smbsrv_blob_pull_string(req, &trans->in.params, 12, &search->t2ffirst.in.pattern, 0);
+ smbsrv_blob_pull_string(&req->in.bufinfo, &trans->in.params, 12, &search->t2ffirst.in.pattern, 0);
if (search->t2ffirst.in.pattern == NULL) {
return NT_STATUS_FOOBAR;
}
@@ -945,7 +945,7 @@ static NTSTATUS trans2_findnext(struct smbsrv_request *req, struct trans_op *op)
search->t2fnext.in.resume_key = IVAL(trans->in.params.data, 6);
search->t2fnext.in.flags = SVAL(trans->in.params.data, 10);
- smbsrv_blob_pull_string(req, &trans->in.params, 12, &search->t2fnext.in.last_name, 0);
+ smbsrv_blob_pull_string(&req->in.bufinfo, &trans->in.params, 12, &search->t2fnext.in.last_name, 0);
if (search->t2fnext.in.last_name == NULL) {
return NT_STATUS_FOOBAR;
}
@@ -1240,11 +1240,11 @@ static void reply_trans_generic(struct smbsrv_request *req, uint8_t command)
}
if (command == SMBtrans) {
- req_pull_string(req, &trans->in.trans_name, req->in.data, -1, STR_TERMINATE);
+ req_pull_string(&req->in.bufinfo, &trans->in.trans_name, req->in.data, -1, STR_TERMINATE);
}
- if (!req_pull_blob(req, req->in.hdr + param_ofs, param_count, &trans->in.params) ||
- !req_pull_blob(req, req->in.hdr + data_ofs, data_count, &trans->in.data)) {
+ if (!req_pull_blob(&req->in.bufinfo, req->in.hdr + param_ofs, param_count, &trans->in.params) ||
+ !req_pull_blob(&req->in.bufinfo, req->in.hdr + data_ofs, data_count, &trans->in.data)) {
smbsrv_send_error(req, NT_STATUS_FOOBAR);
return;
}
@@ -1302,8 +1302,8 @@ static void reply_transs_generic(struct smbsrv_request *req, uint8_t command)
data_ofs = SVAL(req->in.vwv, VWV(6));
data_disp = SVAL(req->in.vwv, VWV(7));
- if (!req_pull_blob(req, req->in.hdr + param_ofs, param_count, &params) ||
- !req_pull_blob(req, req->in.hdr + data_ofs, data_count, &data)) {
+ if (!req_pull_blob(&req->in.bufinfo, req->in.hdr + param_ofs, param_count, &params) ||
+ !req_pull_blob(&req->in.bufinfo, req->in.hdr + data_ofs, data_count, &data)) {
smbsrv_send_error(req, NT_STATUS_INVALID_PARAMETER);
return;
}
diff --git a/source4/smb_server/smb2/config.mk b/source4/smb_server/smb2/config.mk
index b878d404c8..d5ba43b3a8 100644
--- a/source4/smb_server/smb2/config.mk
+++ b/source4/smb_server/smb2/config.mk
@@ -13,6 +13,5 @@ OBJ_FILES = \
keepalive.o
PUBLIC_DEPENDENCIES = \
ntvfs LIBPACKET LIBCLI_SMB2
-LDFLAGS = $(SUBSYSTEM_SMB_SERVER_OUTPUT)
# End SUBSYSTEM SMB2_PROTOCOL
#######################
diff --git a/source4/smb_server/smb2/fileinfo.c b/source4/smb_server/smb2/fileinfo.c
index 00c455e351..d6db61eaba 100644
--- a/source4/smb_server/smb2/fileinfo.c
+++ b/source4/smb_server/smb2/fileinfo.c
@@ -79,19 +79,21 @@ static NTSTATUS smb2srv_getinfo_file_send(struct smb2srv_getinfo_op *op)
static NTSTATUS smb2srv_getinfo_file(struct smb2srv_getinfo_op *op, uint8_t smb2_level)
{
union smb_fileinfo *io;
+ uint16_t level;
io = talloc(op, union smb_fileinfo);
NT_STATUS_HAVE_NO_MEMORY(io);
- switch (op->info->in.level) {
+ level = op->info->in.info_type | (op->info->in.info_class << 8);
+ switch (level) {
case RAW_FILEINFO_SMB2_ALL_EAS:
- io->all_eas.level = op->info->in.level;
+ io->all_eas.level = level;
io->all_eas.in.file.ntvfs = op->info->in.file.ntvfs;
- io->all_eas.in.continue_flags = op->info->in.flags2;
+ io->all_eas.in.continue_flags = op->info->in.getinfo_flags;
break;
case RAW_FILEINFO_SMB2_ALL_INFORMATION:
- io->all_info2.level = op->info->in.level;
+ io->all_info2.level = level;
io->all_info2.in.file.ntvfs = op->info->in.file.ntvfs;
break;
@@ -166,7 +168,7 @@ static NTSTATUS smb2srv_getinfo_security(struct smb2srv_getinfo_op *op, uint8_t
io->query_secdesc.level = RAW_FILEINFO_SEC_DESC;
io->query_secdesc.in.file.ntvfs = op->info->in.file.ntvfs;
- io->query_secdesc.in.secinfo_flags = op->info->in.flags;
+ io->query_secdesc.in.secinfo_flags = op->info->in.additional_information;
op->io_ptr = io;
op->send_fn = smb2srv_getinfo_security_send;
@@ -179,23 +181,17 @@ static NTSTATUS smb2srv_getinfo_security(struct smb2srv_getinfo_op *op, uint8_t
static NTSTATUS smb2srv_getinfo_backend(struct smb2srv_getinfo_op *op)
{
- uint8_t smb2_class;
- uint8_t smb2_level;
-
- smb2_class = 0xFF & op->info->in.level;
- smb2_level = 0xFF & (op->info->in.level>>8);
-
- switch (smb2_class) {
+ switch (op->info->in.info_type) {
case SMB2_GETINFO_FILE:
- return smb2srv_getinfo_file(op, smb2_level);
+ return smb2srv_getinfo_file(op, op->info->in.info_class);
case SMB2_GETINFO_FS:
- return smb2srv_getinfo_fs(op, smb2_level);
+ return smb2srv_getinfo_fs(op, op->info->in.info_class);
case SMB2_GETINFO_SECURITY:
- return smb2srv_getinfo_security(op, smb2_level);
+ return smb2srv_getinfo_security(op, op->info->in.info_class);
- case 0x04:
+ case SMB2_GETINFO_QUOTA:
return NT_STATUS_NOT_SUPPORTED;
}
@@ -217,13 +213,15 @@ void smb2srv_getinfo_recv(struct smb2srv_request *req)
op->send_fn = NULL;
SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_getinfo_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
- info->in.level = SVAL(req->in.body, 0x02);
- info->in.max_response_size = IVAL(req->in.body, 0x04);
- info->in.unknown1 = IVAL(req->in.body, 0x08);
- info->in.unknown2 = IVAL(req->in.body, 0x0C);
- info->in.flags = IVAL(req->in.body, 0x10);
- info->in.flags2 = IVAL(req->in.body, 0x14);
+ info->in.info_type = CVAL(req->in.body, 0x02);
+ info->in.info_class = CVAL(req->in.body, 0x03);
+ info->in.output_buffer_length = IVAL(req->in.body, 0x04);
+ info->in.reserved = IVAL(req->in.body, 0x0C);
+ info->in.additional_information = IVAL(req->in.body, 0x10);
+ info->in.getinfo_flags = IVAL(req->in.body, 0x14);
info->in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x18);
+ SMB2SRV_CHECK(smb2_pull_o16As32_blob(&req->in, op,
+ req->in.body+0x08, &info->in.blob));
SMB2SRV_CHECK_FILE_HANDLE(info->in.file.ntvfs);
SMB2SRV_CALL_NTVFS_BACKEND(smb2srv_getinfo_backend(op));
@@ -266,9 +264,14 @@ static NTSTATUS smb2srv_setinfo_file(struct smb2srv_setinfo_op *op, uint8_t smb2
io->generic.level = smb2_level + 1000;
io->generic.in.file.ntvfs = op->info->in.file.ntvfs;
+ /* handle cases that don't map directly */
+ if (io->generic.level == RAW_SFILEINFO_RENAME_INFORMATION) {
+ io->generic.level = RAW_SFILEINFO_RENAME_INFORMATION_SMB2;
+ }
+
status = smbsrv_pull_passthru_sfileinfo(io, io->generic.level, io,
&op->info->in.blob,
- STR_UNICODE, NULL);
+ STR_UNICODE, &op->req->in.bufinfo);
NT_STATUS_NOT_OK_RETURN(status);
return ntvfs_setfileinfo(op->req->ntvfs, io);
diff --git a/source4/smb_server/smb2/fileio.c b/source4/smb_server/smb2/fileio.c
index 0e83c78615..0e3df56b42 100644
--- a/source4/smb_server/smb2/fileio.c
+++ b/source4/smb_server/smb2/fileio.c
@@ -34,7 +34,8 @@ static void smb2srv_create_send(struct ntvfs_request *ntvfs)
SMB2SRV_CHECK_ASYNC_STATUS(io, union smb_open);
SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x58, true, io->smb2.out.blob.length));
- SSVAL(req->out.body, 0x02, io->smb2.out.oplock_flags);
+ SCVAL(req->out.body, 0x02, io->smb2.out.oplock_level);
+ SCVAL(req->out.body, 0x03, io->smb2.out.reserved);
SIVAL(req->out.body, 0x04, io->smb2.out.create_action);
SBVAL(req->out.body, 0x08, io->smb2.out.create_time);
SBVAL(req->out.body, 0x10, io->smb2.out.access_time);
@@ -43,7 +44,7 @@ static void smb2srv_create_send(struct ntvfs_request *ntvfs)
SBVAL(req->out.body, 0x28, io->smb2.out.alloc_size);
SBVAL(req->out.body, 0x30, io->smb2.out.size);
SIVAL(req->out.body, 0x38, io->smb2.out.file_attr);
- SIVAL(req->out.body, 0x3C, io->smb2.out._pad);
+ SIVAL(req->out.body, 0x3C, io->smb2.out.reserved2);
smb2srv_push_handle(req->out.body, 0x40, io->smb2.out.file.ntvfs);
SMB2SRV_CHECK(smb2_push_o32s32_blob(&req->out, 0x50, io->smb2.out.blob));
@@ -64,22 +65,26 @@ void smb2srv_create_recv(struct smb2srv_request *req)
SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_create_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
io->smb2.level = RAW_OPEN_SMB2;
- io->smb2.in.oplock_flags = SVAL(req->in.body, 0x02);
- io->smb2.in.impersonation = IVAL(req->in.body, 0x04);
- io->smb2.in.unknown3[0] = IVAL(req->in.body, 0x08);
- io->smb2.in.unknown3[1] = IVAL(req->in.body, 0x0C);
- io->smb2.in.unknown3[2] = IVAL(req->in.body, 0x10);
- io->smb2.in.unknown3[3] = IVAL(req->in.body, 0x14);
- io->smb2.in.access_mask = IVAL(req->in.body, 0x18);
- io->smb2.in.file_attr = IVAL(req->in.body, 0x1C);
+ io->smb2.in.security_flags = CVAL(req->in.body, 0x02);
+ io->smb2.in.oplock_level = CVAL(req->in.body, 0x03);
+ io->smb2.in.impersonation_level = IVAL(req->in.body, 0x04);
+ io->smb2.in.create_flags = BVAL(req->in.body, 0x08);
+ io->smb2.in.reserved = BVAL(req->in.body, 0x10);
+ io->smb2.in.desired_access = IVAL(req->in.body, 0x18);
+ io->smb2.in.file_attributes = IVAL(req->in.body, 0x1C);
io->smb2.in.share_access = IVAL(req->in.body, 0x20);
- io->smb2.in.open_disposition = IVAL(req->in.body, 0x24);
+ io->smb2.in.create_disposition = IVAL(req->in.body, 0x24);
io->smb2.in.create_options = IVAL(req->in.body, 0x28);
SMB2SRV_CHECK(smb2_pull_o16s16_string(&req->in, io, req->in.body+0x2C, &io->smb2.in.fname));
SMB2SRV_CHECK(smb2_pull_o32s32_blob(&req->in, io, req->in.body+0x30, &blob));
/* TODO: parse the blob */
ZERO_STRUCT(io->smb2.in.eas);
+ /* the VFS backend does not yet handle NULL filenames */
+ if (io->smb2.in.fname == NULL) {
+ io->smb2.in.fname = "";
+ }
+
SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_open(req->ntvfs, io));
}
diff --git a/source4/smb_server/smb2/find.c b/source4/smb_server/smb2/find.c
index c594adf7a0..6018f1958f 100644
--- a/source4/smb_server/smb2/find.c
+++ b/source4/smb_server/smb2/find.c
@@ -161,6 +161,11 @@ void smb2srv_find_recv(struct smb2srv_request *req)
SMB2SRV_CHECK(smb2_pull_o16s16_string(&req->in, info, req->in.body+0x18, &info->in.pattern));
info->in.max_response_size = IVAL(req->in.body, 0x1C);
+ /* the VFS backend does not yet handle NULL patterns */
+ if (info->in.pattern == NULL) {
+ info->in.pattern = "";
+ }
+
SMB2SRV_CHECK_FILE_HANDLE(info->in.file.ntvfs);
SMB2SRV_CALL_NTVFS_BACKEND(smb2srv_find_backend(state));
}
diff --git a/source4/smb_server/smb2/negprot.c b/source4/smb_server/smb2/negprot.c
index 8e3cfd3547..5bbd7f7d5e 100644
--- a/source4/smb_server/smb2/negprot.c
+++ b/source4/smb_server/smb2/negprot.c
@@ -21,6 +21,7 @@
#include "includes.h"
#include "auth/credentials/credentials.h"
#include "auth/gensec/gensec.h"
+#include "libcli/raw/libcliraw.h"
#include "libcli/smb2/smb2.h"
#include "libcli/smb2/smb2_calls.h"
#include "smb_server/smb_server.h"
@@ -92,24 +93,33 @@ static NTSTATUS smb2srv_negprot_backend(struct smb2srv_request *req, struct smb2
struct timeval current_time;
struct timeval boot_time;
+ /* we only do one dialect for now */
+ if (io->in.dialect_count < 1) {
+ return NT_STATUS_NOT_SUPPORTED;
+ }
+ if (io->in.dialects[0] != 0 &&
+ io->in.dialects[0] != SMB2_DIALECT_REVISION) {
+ DEBUG(0,("Got unexpected SMB2 dialect %u\n", io->in.dialects[0]));
+ return NT_STATUS_NOT_SUPPORTED;
+ }
+
req->smb_conn->negotiate.protocol = PROTOCOL_SMB2;
current_time = timeval_current(); /* TODO: handle timezone?! */
boot_time = timeval_current(); /* TODO: fix me */
- io->out._pad = 0;
- io->out.unknown2 = 0x06;
- ZERO_STRUCT(io->out.sessid);
- io->out.unknown3 = 0x0d;
- io->out.unknown4 = 0x00;
- io->out.unknown5 = 0x01;
- io->out.unknown6 = 0x01;
- io->out.unknown7 = 0x01;
- io->out.current_time = timeval_to_nttime(&current_time);
- io->out.boot_time = timeval_to_nttime(&boot_time);
+ ZERO_STRUCT(io->out);
+ io->out.security_mode = 0; /* no signing yet */
+ io->out.dialect_revision = SMB2_DIALECT_REVISION;
+ io->out.capabilities = 0;
+ io->out.max_transact_size = 0x10000;
+ io->out.max_read_size = 0x10000;
+ io->out.max_write_size = 0x10000;
+ io->out.system_time = timeval_to_nttime(&current_time);
+ io->out.server_start_time = timeval_to_nttime(&boot_time);
+ io->out.reserved2 = 0;
status = smb2srv_negprot_secblob(req, &io->out.secblob);
NT_STATUS_NOT_OK_RETURN(status);
- io->out.unknown9 = 0x204d4c20;
return NT_STATUS_OK;
}
@@ -117,6 +127,7 @@ static NTSTATUS smb2srv_negprot_backend(struct smb2srv_request *req, struct smb2
static void smb2srv_negprot_send(struct smb2srv_request *req, struct smb2_negprot *io)
{
NTSTATUS status;
+ enum ndr_err_code ndr_err;
if (NT_STATUS_IS_ERR(req->status)) {
smb2srv_send_error(req, req->status); /* TODO: is this correct? */
@@ -130,16 +141,22 @@ static void smb2srv_negprot_send(struct smb2srv_request *req, struct smb2_negpro
return;
}
- SSVAL(req->out.body, 0x02, io->out._pad);
- SIVAL(req->out.body, 0x04, io->out.unknown2);
- memcpy(req->out.body+0x08, io->out.sessid, 16);
- SIVAL(req->out.body, 0x18, io->out.unknown3);
- SSVAL(req->out.body, 0x1C, io->out.unknown4);
- SIVAL(req->out.body, 0x1E, io->out.unknown5);
- SIVAL(req->out.body, 0x22, io->out.unknown6);
- SSVAL(req->out.body, 0x26, io->out.unknown7);
- push_nttime(req->out.body, 0x28, io->out.current_time);
- push_nttime(req->out.body, 0x30, io->out.boot_time);
+ SSVAL(req->out.body, 0x02, io->out.security_mode);
+ SIVAL(req->out.body, 0x04, io->out.dialect_revision);
+ SIVAL(req->out.body, 0x06, io->out.reserved);
+ ndr_err = smbcli_push_guid(req->out.body, 0x08, &io->out.server_guid);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
+ talloc_free(req);
+ return;
+ }
+ SIVAL(req->out.body, 0x18, io->out.capabilities);
+ SIVAL(req->out.body, 0x1C, io->out.max_transact_size);
+ SIVAL(req->out.body, 0x20, io->out.max_read_size);
+ SIVAL(req->out.body, 0x24, io->out.max_write_size);
+ push_nttime(req->out.body, 0x28, io->out.system_time);
+ push_nttime(req->out.body, 0x30, io->out.server_start_time);
+ SIVAL(req->out.body, 0x3C, io->out.reserved2);
status = smb2_push_o16s16_blob(&req->out, 0x38, io->out.secblob);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
@@ -147,14 +164,14 @@ static void smb2srv_negprot_send(struct smb2srv_request *req, struct smb2_negpro
return;
}
- SIVAL(req->out.body, 0x3C, io->out.unknown9);
-
smb2srv_send_reply(req);
}
void smb2srv_negprot_recv(struct smb2srv_request *req)
{
struct smb2_negprot *io;
+ int i;
+ enum ndr_err_code ndr_err;
if (req->in.body_size < 0x26) {
smb2srv_send_error(req, NT_STATUS_FOOBAR);
@@ -168,9 +185,27 @@ void smb2srv_negprot_recv(struct smb2srv_request *req)
return;
}
- io->in.unknown1 = SVAL(req->in.body, 0x02);
- memcpy(io->in.unknown2, req->in.body + 0x04, 0x20);
- io->in.unknown3 = SVAL(req->in.body, 0x24);
+ io->in.dialect_count = SVAL(req->in.body, 0x02);
+ io->in.security_mode = SVAL(req->in.body, 0x04);
+ io->in.reserved = SVAL(req->in.body, 0x06);
+ io->in.capabilities = IVAL(req->in.body, 0x08);
+ ndr_err = smbcli_pull_guid(req->in.body, 0xC, &io->in.client_guid);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ smbsrv_terminate_connection(req->smb_conn, nt_errstr(NT_STATUS_FOOBAR));
+ talloc_free(req);
+ return;
+ }
+ io->in.start_time = smbcli_pull_nttime(req->in.body, 0x1C);
+
+ io->in.dialects = talloc_array(req, uint16_t, io->in.dialect_count);
+ if (io->in.dialects == NULL) {
+ smbsrv_terminate_connection(req->smb_conn, nt_errstr(NT_STATUS_NO_MEMORY));
+ talloc_free(req);
+ return;
+ }
+ for (i=0;i<io->in.dialect_count;i++) {
+ io->in.dialects[i] = SVAL(req->in.body, 0x24+i*2);
+ }
req->status = smb2srv_negprot_backend(req, io);
@@ -182,14 +217,13 @@ void smb2srv_negprot_recv(struct smb2srv_request *req)
}
/*
- * reply to a SMB negprot request with dialect "SMB 2.001"
+ * reply to a SMB negprot request with dialect "SMB 2.002"
*/
void smb2srv_reply_smb_negprot(struct smbsrv_request *smb_req)
{
struct smb2srv_request *req;
uint32_t body_fixed_size = 0x26;
- /* create a fake SMB2 negprot request */
req = talloc_zero(smb_req->smb_conn, struct smb2srv_request);
if (!req) goto nomem;
req->smb_conn = smb_req->smb_conn;
@@ -205,19 +239,21 @@ void smb2srv_reply_smb_negprot(struct smbsrv_request *smb_req)
req->in.body_size = body_fixed_size;
req->in.dynamic = NULL;
+ smb2srv_setup_bufinfo(req);
+
SIVAL(req->in.hdr, 0, SMB2_MAGIC);
SSVAL(req->in.hdr, SMB2_HDR_LENGTH, SMB2_HDR_BODY);
- SSVAL(req->in.hdr, SMB2_HDR_PAD1, 0);
+ SSVAL(req->in.hdr, SMB2_HDR_EPOCH, 0);
SIVAL(req->in.hdr, SMB2_HDR_STATUS, 0);
SSVAL(req->in.hdr, SMB2_HDR_OPCODE, SMB2_OP_NEGPROT);
- SSVAL(req->in.hdr, SMB2_HDR_UNKNOWN1, 0);
+ SSVAL(req->in.hdr, SMB2_HDR_CREDIT, 0);
SIVAL(req->in.hdr, SMB2_HDR_FLAGS, 0);
- SIVAL(req->in.hdr, SMB2_HDR_CHAIN_OFFSET, 0);
- SBVAL(req->in.hdr, SMB2_HDR_SEQNUM, 0);
+ SIVAL(req->in.hdr, SMB2_HDR_NEXT_COMMAND, 0);
+ SBVAL(req->in.hdr, SMB2_HDR_MESSAGE_ID, 0);
SIVAL(req->in.hdr, SMB2_HDR_PID, 0);
SIVAL(req->in.hdr, SMB2_HDR_TID, 0);
- SBVAL(req->in.hdr, SMB2_HDR_UID, 0);
- memset(req->in.hdr+SMB2_HDR_SIG, 0, 16);
+ SBVAL(req->in.hdr, SMB2_HDR_SESSION_ID, 0);
+ memset(req->in.hdr+SMB2_HDR_SIGNATURE, 0, 16);
/* this seems to be a bug, they use 0x24 but the length is 0x26 */
SSVAL(req->in.body, 0x00, 0x24);
diff --git a/source4/smb_server/smb2/receive.c b/source4/smb_server/smb2/receive.c
index cfae2dbe52..dea7c9e79e 100644
--- a/source4/smb_server/smb2/receive.c
+++ b/source4/smb_server/smb2/receive.c
@@ -30,6 +30,22 @@
#include "ntvfs/ntvfs.h"
#include "param/param.h"
+
+/* fill in the bufinfo */
+void smb2srv_setup_bufinfo(struct smb2srv_request *req)
+{
+ req->in.bufinfo.mem_ctx = req;
+ req->in.bufinfo.flags = BUFINFO_FLAG_UNICODE | BUFINFO_FLAG_SMB2;
+ req->in.bufinfo.align_base = req->in.buffer;
+ if (req->in.dynamic) {
+ req->in.bufinfo.data = req->in.dynamic;
+ req->in.bufinfo.data_size = req->in.body_size - req->in.body_fixed;
+ } else {
+ req->in.bufinfo.data = NULL;
+ req->in.bufinfo.data_size = 0;
+ }
+}
+
static int smb2srv_request_destructor(struct smb2srv_request *req)
{
DLIST_REMOVE(req->smb_conn->requests2.list, req);
@@ -94,17 +110,17 @@ NTSTATUS smb2srv_setup_reply(struct smb2srv_request *req, uint16_t body_fixed_si
SIVAL(req->out.hdr, 0, SMB2_MAGIC);
SSVAL(req->out.hdr, SMB2_HDR_LENGTH, SMB2_HDR_BODY);
- SSVAL(req->out.hdr, SMB2_HDR_PAD1, 0);
+ SSVAL(req->out.hdr, SMB2_HDR_EPOCH, 0);
SIVAL(req->out.hdr, SMB2_HDR_STATUS, NT_STATUS_V(req->status));
SSVAL(req->out.hdr, SMB2_HDR_OPCODE, SVAL(req->in.hdr, SMB2_HDR_OPCODE));
- SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, 0x0001);
+ SSVAL(req->out.hdr, SMB2_HDR_CREDIT, 0x0001);
SIVAL(req->out.hdr, SMB2_HDR_FLAGS, flags);
- SIVAL(req->out.hdr, SMB2_HDR_CHAIN_OFFSET, 0);
- SBVAL(req->out.hdr, SMB2_HDR_SEQNUM, req->seqnum);
+ SIVAL(req->out.hdr, SMB2_HDR_NEXT_COMMAND, 0);
+ SBVAL(req->out.hdr, SMB2_HDR_MESSAGE_ID, req->seqnum);
SIVAL(req->out.hdr, SMB2_HDR_PID, pid);
SIVAL(req->out.hdr, SMB2_HDR_TID, tid);
- SBVAL(req->out.hdr, SMB2_HDR_UID, BVAL(req->in.hdr, SMB2_HDR_UID));
- memset(req->out.hdr+SMB2_HDR_SIG, 0, 16);
+ SBVAL(req->out.hdr, SMB2_HDR_SESSION_ID, BVAL(req->in.hdr, SMB2_HDR_SESSION_ID));
+ memset(req->out.hdr+SMB2_HDR_SIGNATURE, 0, 16);
/* set the length of the fixed body part and +1 if there's a dynamic part also */
SSVAL(req->out.body, 0, body_fixed_size + (body_dynamic_size?1:0));
@@ -180,6 +196,8 @@ static void smb2srv_chain_reply(struct smb2srv_request *p_req)
}
}
+ smb2srv_setup_bufinfo(req);
+
if (p_req->chained_file_handle) {
memcpy(req->_chained_file_handle,
p_req->_chained_file_handle,
@@ -259,10 +277,10 @@ static NTSTATUS smb2srv_reply(struct smb2srv_request *req)
uint64_t uid;
opcode = SVAL(req->in.hdr, SMB2_HDR_OPCODE);
- req->chain_offset = IVAL(req->in.hdr, SMB2_HDR_CHAIN_OFFSET);
- req->seqnum = BVAL(req->in.hdr, SMB2_HDR_SEQNUM);
+ req->chain_offset = IVAL(req->in.hdr, SMB2_HDR_NEXT_COMMAND);
+ req->seqnum = BVAL(req->in.hdr, SMB2_HDR_MESSAGE_ID);
tid = IVAL(req->in.hdr, SMB2_HDR_TID);
- uid = BVAL(req->in.hdr, SMB2_HDR_UID);
+ uid = BVAL(req->in.hdr, SMB2_HDR_SESSION_ID);
req->session = smbsrv_session_find(req->smb_conn, uid, req->request_time);
req->tcon = smbsrv_smb2_tcon_find(req->session, tid, req->request_time);
@@ -430,6 +448,8 @@ NTSTATUS smbsrv_recv_smb2_request(void *private, DATA_BLOB blob)
}
}
+ smb2srv_setup_bufinfo(req);
+
/*
* TODO: - make sure the length field is 64
* - make sure it's a request
diff --git a/source4/smb_server/smb2/sesssetup.c b/source4/smb_server/smb2/sesssetup.c
index 636f5f0e27..1aaacf897c 100644
--- a/source4/smb_server/smb2/sesssetup.c
+++ b/source4/smb_server/smb2/sesssetup.c
@@ -32,12 +32,12 @@
static void smb2srv_sesssetup_send(struct smb2srv_request *req, union smb_sesssetup *io)
{
- uint16_t unknown1;
+ uint16_t credit;
if (NT_STATUS_IS_OK(req->status)) {
- unknown1 = 0x0003;
+ credit = 0x0003;
} else if (NT_STATUS_EQUAL(req->status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
- unknown1 = 0x0002;
+ credit = 0x0002;
} else {
smb2srv_send_error(req, req->status);
return;
@@ -45,10 +45,10 @@ static void smb2srv_sesssetup_send(struct smb2srv_request *req, union smb_sessse
SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x08, true, io->smb2.out.secblob.length));
- SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, unknown1);
- SBVAL(req->out.hdr, SMB2_HDR_UID, io->smb2.out.uid);
+ SSVAL(req->out.hdr, SMB2_HDR_CREDIT, credit);
+ SBVAL(req->out.hdr, SMB2_HDR_SESSION_ID, io->smb2.out.uid);
- SSVAL(req->out.body, 0x02, io->smb2.out._pad);
+ SSVAL(req->out.body, 0x02, io->smb2.out.session_flags);
SMB2SRV_CHECK(smb2_push_o16s16_blob(&req->out, 0x04, io->smb2.out.secblob));
smb2srv_send_reply(req);
@@ -108,11 +108,11 @@ static void smb2srv_sesssetup_backend(struct smb2srv_request *req, union smb_ses
struct smbsrv_session *smb_sess = NULL;
uint64_t vuid;
- io->smb2.out._pad = 0;
+ io->smb2.out.session_flags = 0;
io->smb2.out.uid = 0;
io->smb2.out.secblob = data_blob(NULL, 0);
- vuid = BVAL(req->in.hdr, SMB2_HDR_UID);
+ vuid = BVAL(req->in.hdr, SMB2_HDR_SESSION_ID);
/*
* only when we got '0' we should allocate a new session
@@ -192,12 +192,13 @@ void smb2srv_sesssetup_recv(struct smb2srv_request *req)
SMB2SRV_CHECK_BODY_SIZE(req, 0x18, true);
SMB2SRV_TALLOC_IO_PTR(io, union smb_sesssetup);
- io->smb2.level = RAW_SESSSETUP_SMB2;
- io->smb2.in._pad = SVAL(req->in.body, 0x02);
- io->smb2.in.unknown2 = IVAL(req->in.body, 0x04);
- io->smb2.in.unknown3 = IVAL(req->in.body, 0x08);
+ io->smb2.level = RAW_SESSSETUP_SMB2;
+ io->smb2.in.vc_number = CVAL(req->in.body, 0x02);
+ io->smb2.in.security_mode = CVAL(req->in.body, 0x03);
+ io->smb2.in.capabilities = IVAL(req->in.body, 0x04);
+ io->smb2.in.channel = IVAL(req->in.body, 0x08);
+ io->smb2.in.previous_sessionid = BVAL(req->in.body, 0x10);
SMB2SRV_CHECK(smb2_pull_o16s16_blob(&req->in, io, req->in.body+0x0C, &io->smb2.in.secblob));
- io->smb2.in.unknown4 = BVAL(req->in.body, 0x10);
smb2srv_sesssetup_backend(req, io);
}
diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c
index 6d0d98554c..7f7d558b16 100644
--- a/source4/smb_server/smb2/tcon.c
+++ b/source4/smb_server/smb2/tcon.c
@@ -55,26 +55,28 @@ static NTSTATUS smb2srv_send_oplock_break(void *p, struct ntvfs_handle *h, uint8
req->seqnum = UINT64_MAX;
+ smb2srv_setup_bufinfo(req);
+
SIVAL(req->in.hdr, 0, SMB2_MAGIC);
SSVAL(req->in.hdr, SMB2_HDR_LENGTH, SMB2_HDR_BODY);
- SSVAL(req->in.hdr, SMB2_HDR_PAD1, 0);
+ SSVAL(req->in.hdr, SMB2_HDR_EPOCH, 0);
SIVAL(req->in.hdr, SMB2_HDR_STATUS, 0);
SSVAL(req->in.hdr, SMB2_HDR_OPCODE, SMB2_OP_BREAK);
- SSVAL(req->in.hdr, SMB2_HDR_UNKNOWN1, 0);
+ SSVAL(req->in.hdr, SMB2_HDR_CREDIT, 0);
SIVAL(req->in.hdr, SMB2_HDR_FLAGS, 0);
- SIVAL(req->in.hdr, SMB2_HDR_CHAIN_OFFSET, 0);
- SBVAL(req->in.hdr, SMB2_HDR_SEQNUM, 0);
+ SIVAL(req->in.hdr, SMB2_HDR_NEXT_COMMAND, 0);
+ SBVAL(req->in.hdr, SMB2_HDR_MESSAGE_ID, 0);
SIVAL(req->in.hdr, SMB2_HDR_PID, 0);
SIVAL(req->in.hdr, SMB2_HDR_TID, 0);
- SBVAL(req->in.hdr, SMB2_HDR_UID, 0);
- memset(req->in.hdr+SMB2_HDR_SIG, 0, 16);
+ SBVAL(req->in.hdr, SMB2_HDR_SESSION_ID, 0);
+ memset(req->in.hdr+SMB2_HDR_SIGNATURE, 0, 16);
SSVAL(req->in.body, 0, 2);
status = smb2srv_setup_reply(req, 0x18, false, 0);
NT_STATUS_NOT_OK_RETURN(status);
- SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1, 0x0000);
+ SSVAL(req->out.hdr, SMB2_HDR_CREDIT, 0x0000);
SSVAL(req->out.body, 0x02, 0x0001);
SIVAL(req->out.body, 0x04, 0x00000000);
@@ -240,8 +242,6 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon
struct smbsrv_tcon *tcon;
NTSTATUS status;
enum ntvfs_type type;
- uint16_t type_smb2;
- uint32_t unknown2;
const char *service = io->smb2.in.path;
struct share_config *scfg;
const char *sharetype;
@@ -270,16 +270,10 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon
sharetype = share_string_option(scfg, SHARE_TYPE, "DISK");
if (sharetype && strcmp(sharetype, "IPC") == 0) {
type = NTVFS_IPC;
- type_smb2 = 0x0002;
- unknown2 = 0x00000030;
} else if (sharetype && strcmp(sharetype, "PRINTER") == 0) {
type = NTVFS_PRINT;
- type_smb2 = 0x0003;
- unknown2 = 0x00000000;
} else {
type = NTVFS_DISK;
- type_smb2 = 0x0001;
- unknown2 = 0x00000800;
}
tcon = smbsrv_smb2_tcon_new(req->session, scfg->name);
@@ -344,10 +338,11 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon
goto failed;
}
- io->smb2.out.unknown1 = type_smb2; /* 1 - DISK, 2 - Print, 3 - IPC */
- io->smb2.out.unknown2 = unknown2;
- io->smb2.out.unknown3 = 0x00000000;
- io->smb2.out.access_mask= SEC_RIGHTS_FILE_ALL;
+ io->smb2.out.share_type = (unsigned)type; /* 1 - DISK, 2 - Print, 3 - IPC */
+ io->smb2.out.reserved = 0;
+ io->smb2.out.flags = 0x00000000;
+ io->smb2.out.capabilities = 0;
+ io->smb2.out.access_mask = SEC_RIGHTS_FILE_ALL;
io->smb2.out.tid = tcon->tid;
@@ -361,27 +356,28 @@ failed:
static void smb2srv_tcon_send(struct smb2srv_request *req, union smb_tcon *io)
{
- uint16_t unknown1;
+ uint16_t credit;
if (!NT_STATUS_IS_OK(req->status)) {
smb2srv_send_error(req, req->status);
return;
}
- if (io->smb2.out.unknown1 == 0x0002) {
+ if (io->smb2.out.share_type == NTVFS_IPC) {
/* if it's an IPC share vista returns 0x0005 */
- unknown1 = 0x0005;
+ credit = 0x0005;
} else {
- unknown1 = 0x0001;
+ credit = 0x0001;
}
SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x10, false, 0));
SIVAL(req->out.hdr, SMB2_HDR_TID, io->smb2.out.tid);
- SSVAL(req->out.hdr, SMB2_HDR_UNKNOWN1,unknown1);
+ SSVAL(req->out.hdr, SMB2_HDR_CREDIT,credit);
- SSVAL(req->out.body, 0x02, io->smb2.out.unknown1);
- SIVAL(req->out.body, 0x04, io->smb2.out.unknown2);
- SIVAL(req->out.body, 0x08, io->smb2.out.unknown3);
+ SCVAL(req->out.body, 0x02, io->smb2.out.share_type);
+ SCVAL(req->out.body, 0x03, io->smb2.out.reserved);
+ SIVAL(req->out.body, 0x04, io->smb2.out.flags);
+ SIVAL(req->out.body, 0x08, io->smb2.out.capabilities);
SIVAL(req->out.body, 0x0C, io->smb2.out.access_mask);
smb2srv_send_reply(req);
@@ -395,9 +391,14 @@ void smb2srv_tcon_recv(struct smb2srv_request *req)
SMB2SRV_TALLOC_IO_PTR(io, union smb_tcon);
io->smb2.level = RAW_TCON_SMB2;
- io->smb2.in.unknown1 = SVAL(req->in.body, 0x02);
+ io->smb2.in.reserved = SVAL(req->in.body, 0x02);
SMB2SRV_CHECK(smb2_pull_o16s16_string(&req->in, io, req->in.body+0x04, &io->smb2.in.path));
+ /* the VFS backend does not yet handle NULL paths */
+ if (io->smb2.in.path == NULL) {
+ io->smb2.in.path = "";
+ }
+
req->status = smb2srv_tcon_backend(req, io);
if (req->control_flags & SMB2SRV_REQ_CTRL_FLAG_NOT_REPLY) {
diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h
index 5644dfe6fb..776fe1b71b 100644
--- a/source4/smb_server/smb_server.h
+++ b/source4/smb_server/smb_server.h
@@ -254,8 +254,8 @@ struct smbsrv_request {
/* the sequence number for signing */
uint64_t seq_num;
- struct request_buffer in;
- struct request_buffer out;
+ struct smb_request_buffer in;
+ struct smb_request_buffer out;
};
enum security_types {SEC_SHARE,SEC_USER};
@@ -291,7 +291,7 @@ struct smbsrv_connection {
/* the negotiatiated protocol */
enum protocol_types protocol;
-
+
/* authentication context for multi-part negprot */
struct auth_context *auth_context;
diff --git a/source4/smbd/server.c b/source4/smbd/server.c
index c256eed96c..dd63ca1eca 100644
--- a/source4/smbd/server.c
+++ b/source4/smbd/server.c
@@ -282,8 +282,6 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
exit(1);
}
- ldb_global_init(); /* FIXME: */
-
share_init();
gensec_init(cmdline_lp_ctx); /* FIXME: */
diff --git a/source4/torture/config.mk b/source4/torture/config.mk
index 0ee7873628..626349a45d 100644
--- a/source4/torture/config.mk
+++ b/source4/torture/config.mk
@@ -11,12 +11,12 @@ OBJ_FILES = \
PUBLIC_DEPENDENCIES = \
LIBSAMBA-CONFIG \
LIBSAMBA-UTIL \
- LIBTALLOC
+ LIBTALLOC \
+ LIBPOPT
[SUBSYSTEM::TORTURE_UTIL]
-OBJ_FILES = util.o util_smb.o
-PRIVATE_DEPENDENCIES = LIBCLI_RAW
-PUBLIC_PROTO_HEADER = util.h
+OBJ_FILES = util_smb.o util_provision.o
+PRIVATE_DEPENDENCIES = LIBCLI_RAW LIBPYTHON smbcalls
PUBLIC_DEPENDENCIES = POPT_CREDENTIALS
#################################
@@ -96,8 +96,8 @@ PRIVATE_DEPENDENCIES = \
# End SUBSYSTEM TORTURE_RAW
#################################
-include smb2/config.mk
-include winbind/config.mk
+mkinclude smb2/config.mk
+mkinclude winbind/config.mk
[SUBSYSTEM::TORTURE_NDR]
PRIVATE_PROTO_HEADER = ndr/proto.h
@@ -114,7 +114,7 @@ OBJ_FILES = ndr/ndr.o \
[MODULE::torture_rpc]
# TORTURE_NET and TORTURE_NBT use functions from torture_rpc...
-#OUTPUT_TYPE = INTEGRATED
+#OUTPUT_TYPE = MERGED_OBJ
SUBSYSTEM = torture
INIT_FUNCTION = torture_rpc_init
PRIVATE_PROTO_HEADER = \
@@ -196,12 +196,12 @@ OBJ_FILES = \
auth/ntlmssp.o \
auth/pac.o
PRIVATE_DEPENDENCIES = \
- LIBCLI_SMB gensec auth LIBSAMBA3 KERBEROS \
- POPT_CREDENTIALS
+ LIBCLI_SMB gensec auth KERBEROS \
+ POPT_CREDENTIALS SMBPASSWD
# End SUBSYSTEM TORTURE_AUTH
#################################
-include local/config.mk
+mkinclude local/config.mk
#################################
# Start MODULE TORTURE_NBENCH
@@ -295,7 +295,6 @@ OBJ_FILES = \
libnet/libnet_BecomeDC.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-NET \
- smbcalls \
POPT_CREDENTIALS \
torture_rpc
# End SUBSYSTEM TORTURE_NET
@@ -361,6 +360,9 @@ INSTALLDIR = BINDIR
OBJ_FILES = \
locktest.o
PRIVATE_DEPENDENCIES = \
+ LIBPOPT \
+ POPT_SAMBA \
+ POPT_CREDENTIALS \
LIBSAMBA-UTIL \
LIBCLI_SMB \
LIBSAMBA-CONFIG
@@ -368,21 +370,14 @@ MANPAGE = man/locktest.1
# End BINARY locktest
#################################
-GCOV_CFLAGS = -ftest-coverage -fprofile-arcs
-GCOV_LDFLAGS = $(GCOV_CFLAGS) -lgcov
-
COV_TARGET = test
COV_VARS = \
- CFLAGS="$(CFLAGS) $(GCOV_CFLAGS)" \
- BNLD_FLAGS="$(BNLD_FLAGS) $(GCOV_LDFLAGS)" \
- SHLD_FLAGS="$(SHLD_FLAGS) $(GCOV_LDFLAGS)" \
- MDLD_FLAGS="$(MDLD_FLAGS) $(GCOV_LDFLAGS)" \
- HOSTCC_FLAGS="$(HOSTCC_FLAGS) $(GCOV_CFLAGS)" \
- HOSTLD_FLAGS="$(HOSTLD_FLAGS) $(GCOV_LDFLAGS)"
+ CFLAGS="$(CFLAGS) --coverage" \
+ LDFLAGS="$(LDFLAGS) --coverage"
test_cov:
- @$(MAKE) $(COV_TARGET) $(COV_VARS)
+ -$(MAKE) $(COV_TARGET) $(COV_VARS)
gcov: test_cov
for I in $(sort $(dir $(ALL_OBJS))); \
@@ -394,10 +389,12 @@ lcov-split:
@$(MAKE) $(COV_TARGET) $(COV_VARS) \
TEST_OPTIONS="--analyse-cmd=\"lcov --base-directory `pwd` --directory . --capture --output-file samba.info -t\""
-rm heimdal/lib/*/{lex,parse}.{gcda,gcno}
+ -rm lib/policy/*/{lex,parse}.{gcda,gcno}
genhtml -o coverage samba.info
lcov: test_cov
-rm heimdal/lib/*/{lex,parse}.{gcda,gcno}
+ -rm lib/policy/*/{lex,parse}.{gcda,gcno}
lcov --base-directory `pwd` --directory . --capture --output-file samba.info
genhtml -o coverage samba.info
diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c
index d50393baf0..d5fc855f17 100644
--- a/source4/torture/gentest.c
+++ b/source4/torture/gentest.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "lib/cmdline/popt_common.h"
#include "system/time.h"
#include "system/filesys.h"
#include "libcli/raw/request.h"
@@ -1755,6 +1756,7 @@ static void gen_setfileinfo(int instance, union smb_setfileinfo *info)
info->end_of_file_info.in.size = gen_offset();
break;
case RAW_SFILEINFO_RENAME_INFORMATION:
+ case RAW_SFILEINFO_RENAME_INFORMATION_SMB2:
info->rename_information.in.overwrite = gen_bool();
info->rename_information.in.root_fid = gen_root_fid(instance);
info->rename_information.in.new_name = gen_fname_open(instance);
@@ -2129,25 +2131,13 @@ static bool start_gentest(struct loadparm_context *lp_ctx)
}
-static void usage(void)
+static void usage(poptContext pc)
{
printf(
"Usage:\n\
- gentest2 //server1/share1 //server2/share2 [options..]\n\
- options:\n\
- -U user%%pass (can be specified twice)\n\
- -s seed\n\
- -o numops\n\
- -a (show all ops)\n\
- -A backtrack to find minimal ops\n\
- -i FILE add a list of wildcard exclusions\n\
- -O enable oplocks\n\
- -S FILE set preset seeds file\n\
- -L use preset seeds\n\
- -F fast reconnect (just close files)\n\
- -C continuous analysis mode\n\
- -X analyse even when test OK\n\
+ gentest //server1/share1 //server2/share2 [options..]\n\
");
+ poptPrintUsage(pc, stdout, 0);
}
/**
@@ -2180,105 +2170,106 @@ static bool split_unc_name(const char *unc, char **server, char **share)
int opt;
int i, username_count=0;
bool ret;
+ char *ignore_file=NULL;
struct loadparm_context *lp_ctx;
+ poptContext pc;
+ int argc_new;
+ char **argv_new;
+ enum {OPT_UNCLIST=1000};
+ struct poptOption long_options[] = {
+ POPT_AUTOHELP
+ {"seed", 0, POPT_ARG_INT, &options.seed, 0, "Seed to use for randomizer", NULL},
+ {"num-ops", 0, POPT_ARG_INT, &options.numops, 0, "num ops", NULL},
+ {"oplocks", 0, POPT_ARG_NONE, &options.use_oplocks,0, "use oplocks", NULL},
+ {"showall", 0, POPT_ARG_NONE, &options.showall, 0, "display all operations", NULL},
+ {"analyse", 0, POPT_ARG_NONE, &options.analyze, 0, "do backtrack analysis", NULL},
+ {"analysealways", 0, POPT_ARG_NONE, &options.analyze_always, 0, "analysis always", NULL},
+ {"analysecontinuous", 0, POPT_ARG_NONE, &options.analyze_continuous, 0, "analysis continuous", NULL},
+ {"ignore", 0, POPT_ARG_STRING, &ignore_file, 0, "ignore from file", NULL},
+ {"preset", 0, POPT_ARG_NONE, &options.use_preset_seeds, 0, "use preset seeds", NULL},
+ {"fast", 0, POPT_ARG_NONE, &options.fast_reconnect, 0, "use fast reconnect", NULL},
+ {"unclist", 0, POPT_ARG_STRING, NULL, OPT_UNCLIST, "unclist", NULL},
+ {"seedsfile", 0, POPT_ARG_STRING, &options.seeds_file, 0, "seed file", NULL},
+ { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "[DOMAIN/]USERNAME[%PASSWORD]" },
+ POPT_COMMON_SAMBA
+ POPT_COMMON_CONNECTION
+ POPT_COMMON_CREDENTIALS
+ POPT_COMMON_VERSION
+ { NULL }
+ };
setlinebuf(stdout);
+ options.seed = time(NULL);
+ options.numops = 1000;
+ options.max_open_handles = 20;
+ options.seeds_file = "gentest_seeds.dat";
- setup_logging("gentest", DEBUG_STDOUT);
-
- if (argc < 3 || argv[1][0] == '-') {
- usage();
- exit(1);
- }
-
- setup_logging(argv[0], DEBUG_STDOUT);
-
- for (i=0;i<NSERVERS;i++) {
- const char *share = argv[1+i];
- servers[i].credentials = cli_credentials_init(NULL);
- if (!split_unc_name(share, &servers[i].server_name, &servers[i].share_name)) {
- printf("Invalid share name '%s'\n", share);
- return -1;
- }
- }
-
- argc -= NSERVERS;
- argv += NSERVERS;
+ pc = poptGetContext("gentest", argc, (const char **) argv, long_options,
+ POPT_CONTEXT_KEEP_FIRST);
- lp_ctx = loadparm_init(talloc_autofree_context());
- lp_load(lp_ctx, dyn_CONFIGFILE);
+ poptSetOtherOptionHelp(pc, "<unc1> <unc2>");
+ lp_ctx = cmdline_lp_ctx;
servers[0].credentials = cli_credentials_init(talloc_autofree_context());
servers[1].credentials = cli_credentials_init(talloc_autofree_context());
cli_credentials_guess(servers[0].credentials, lp_ctx);
cli_credentials_guess(servers[1].credentials, lp_ctx);
- options.seed = time(NULL);
- options.numops = 1000;
- options.max_open_handles = 20;
- options.seeds_file = "gentest_seeds.dat";
-
- while ((opt = getopt(argc, argv, "U:s:o:ad:i:AOhS:LFXC")) != EOF) {
+ while((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
+ case OPT_UNCLIST:
+ lp_set_cmdline(cmdline_lp_ctx, "torture:unclist", poptGetOptArg(pc));
+ break;
case 'U':
if (username_count == 2) {
- usage();
+ usage(pc);
exit(1);
}
- cli_credentials_parse_string(servers[username_count].credentials,
- optarg, CRED_SPECIFIED);
+ cli_credentials_parse_string(servers[username_count].credentials, poptGetOptArg(pc), CRED_SPECIFIED);
username_count++;
break;
- case 'd':
- DEBUGLEVEL = atoi(optarg);
- setup_logging(NULL, DEBUG_STDOUT);
- break;
- case 's':
- options.seed = atoi(optarg);
- break;
- case 'S':
- options.seeds_file = optarg;
- break;
- case 'L':
- options.use_preset_seeds = true;
- break;
- case 'F':
- options.fast_reconnect = true;
- break;
- case 'o':
- options.numops = atoi(optarg);
- break;
- case 'O':
- options.use_oplocks = true;
- break;
- case 'a':
- options.showall = true;
- break;
- case 'A':
- options.analyze = true;
- break;
- case 'X':
- options.analyze_always = true;
- break;
- case 'C':
- options.analyze_continuous = true;
- break;
- case 'i':
- options.ignore_patterns = file_lines_load(optarg, NULL, NULL);
+ }
+ }
+
+ if (ignore_file) {
+ options.ignore_patterns = file_lines_load(ignore_file, NULL, NULL);
+ }
+
+ argv_new = discard_const_p(char *, poptGetArgs(pc));
+ argc_new = argc;
+ for (i=0; i<argc; i++) {
+ if (argv_new[i] == NULL) {
+ argc_new = i;
break;
- case 'h':
- usage();
- exit(1);
- default:
- printf("Unknown option %c (%d)\n", (char)opt, opt);
- exit(1);
}
}
- gensec_init(lp_ctx);
+ if (!(argc_new >= 3)) {
+ usage(pc);
+ exit(1);
+ }
+
+ setlinebuf(stdout);
+
+ setup_logging("gentest", DEBUG_STDOUT);
+
+ if (argc < 3 || argv[1][0] == '-') {
+ usage(pc);
+ exit(1);
+ }
+
+ setup_logging(argv[0], DEBUG_STDOUT);
+
+ for (i=0;i<NSERVERS;i++) {
+ const char *share = argv[1+i];
+ if (!split_unc_name(share, &servers[i].server_name, &servers[i].share_name)) {
+ printf("Invalid share name '%s'\n", share);
+ return -1;
+ }
+ }
if (username_count == 0) {
- usage();
+ usage(pc);
return -1;
}
if (username_count == 1) {
@@ -2287,6 +2278,8 @@ static bool split_unc_name(const char *unc, char **server, char **share)
printf("seed=%u\n", options.seed);
+ gensec_init(lp_ctx);
+
ret = start_gentest(lp_ctx);
if (ret) {
diff --git a/source4/torture/libnet/libnet_BecomeDC.c b/source4/torture/libnet/libnet_BecomeDC.c
index 0ef6a03a6a..9566f5ee29 100644
--- a/source4/torture/libnet/libnet_BecomeDC.c
+++ b/source4/torture/libnet/libnet_BecomeDC.c
@@ -34,8 +34,10 @@
#include "librpc/gen_ndr/ndr_drsblobs.h"
#include "librpc/gen_ndr/ndr_misc.h"
#include "system/time.h"
-#include "auth/auth.h"
#include "lib/ldb_wrap.h"
+#include "auth/auth.h"
+#include "param/param.h"
+#include "torture/util.h"
struct test_become_dc_state {
struct libnet_context *ctx;
@@ -66,6 +68,35 @@ struct test_become_dc_state {
} path;
};
+static NTSTATUS test_become_dc_prepare_db(void *private_data,
+ const struct libnet_BecomeDC_PrepareDB *p)
+{
+ struct test_become_dc_state *s = talloc_get_type(private_data, struct test_become_dc_state);
+ struct provision_settings settings;
+
+ settings.dns_name = p->dest_dsa->dns_name;
+ settings.site_name = p->dest_dsa->site_name;
+ settings.root_dn_str = p->forest->root_dn_str;
+ settings.domain_dn_str = p->domain->dn_str;
+ settings.config_dn_str = p->forest->config_dn_str;
+ settings.schema_dn_str = p->forest->schema_dn_str;
+ settings.invocation_id = &p->dest_dsa->invocation_id;
+ settings.netbios_name = p->dest_dsa->netbios_name;
+ settings.realm = torture_join_dom_dns_name(s->tj);
+ settings.domain = torture_join_dom_netbios_name(s->tj);
+ settings.ntds_guid = &p->dest_dsa->ntds_guid;
+ settings.ntds_dn_str = p->dest_dsa->ntds_dn_str;
+ settings.machine_password = cli_credentials_get_password(s->machine_account);
+ settings.samdb_ldb = s->path.samdb_ldb;
+ settings.secrets_ldb = s->path.secrets_ldb;
+ settings.secrets_keytab = s->path.secrets_keytab;
+ settings.schemadn_ldb = s->path.schemadn_ldb;
+ settings.configdn_ldb = s->path.configdn_ldb;
+ settings.domaindn_ldb = s->path.domaindn_ldb;
+
+ return provision_bare(s, s->tctx->lp_ctx, &settings);
+}
+
static NTSTATUS test_become_dc_check_options(void *private_data,
const struct libnet_BecomeDC_CheckOptions *o)
{
@@ -90,299 +121,6 @@ static NTSTATUS test_become_dc_check_options(void *private_data,
return NT_STATUS_OK;
}
-#include "lib/appweb/ejs/ejs.h"
-#include "lib/appweb/ejs/ejsInternal.h"
-#include "scripting/ejs/smbcalls.h"
-
-static EjsId eid;
-static int ejs_error;
-
-static void test_ejs_exception(const char *reason)
-{
- Ejs *ep = ejsPtr(eid);
- ejsSetErrorMsg(eid, "%s", reason);
- fprintf(stderr, "%s", ep->error);
- ejs_error = 127;
-}
-
-static int test_run_ejs(char *script)
-{
- EjsHandle handle = 0;
- MprVar result;
- char *emsg;
- TALLOC_CTX *mem_ctx = talloc_new(NULL);
- struct MprVar *return_var;
-
- mprSetCtx(mem_ctx);
-
- if (ejsOpen(NULL, NULL, NULL) != 0) {
- d_printf("ejsOpen(): unable to initialise EJS subsystem\n");
- ejs_error = 127;
- goto failed;
- }
-
- smb_setup_ejs_functions(test_ejs_exception);
-
- if ((eid = ejsOpenEngine(handle, 0)) == (EjsId)-1) {
- d_printf("smbscript: ejsOpenEngine(): unable to initialise an EJS engine\n");
- ejs_error = 127;
- goto failed;
- }
-
- mprSetVar(ejsGetGlobalObject(eid), "ARGV", mprList("ARGV", NULL));
-
- /* run the script */
- if (ejsEvalScript(eid, script, &result, &emsg) == -1) {
- d_printf("smbscript: ejsEvalScript(): %s\n", emsg);
- if (ejs_error == 0) ejs_error = 127;
- goto failed;
- }
-
- return_var = ejsGetReturnValue(eid);
- ejs_error = mprVarToNumber(return_var);
-
-failed:
- ejsClose();
- talloc_free(mem_ctx);
- return ejs_error;
-}
-
-static NTSTATUS test_become_dc_prepare_db_ejs(void *private_data,
- const struct libnet_BecomeDC_PrepareDB *p)
-{
- struct test_become_dc_state *s = talloc_get_type(private_data, struct test_become_dc_state);
- char *ejs;
- int ret;
- bool ok;
-
- DEBUG(0,("Provision for Become-DC test using EJS\n"));
-
- DEBUG(0,("New Server[%s] in Site[%s]\n",
- p->dest_dsa->dns_name, p->dest_dsa->site_name));
-
- DEBUG(0,("DSA Instance [%s]\n"
- "\tobjectGUID[%s]\n"
- "\tinvocationId[%s]\n",
- p->dest_dsa->ntds_dn_str,
- GUID_string(s, &p->dest_dsa->ntds_guid),
- GUID_string(s, &p->dest_dsa->invocation_id)));
-
- DEBUG(0,("Pathes under PRIVATEDIR[%s]\n"
- "SAMDB[%s] SECRETS[%s] KEYTAB[%s]\n",
- lp_private_dir(s->tctx->lp_ctx),
- s->path.samdb_ldb,
- s->path.secrets_ldb,
- s->path.secrets_keytab));
-
- DEBUG(0,("Schema Partition[%s => %s]\n",
- p->forest->schema_dn_str, s->path.schemadn_ldb));
-
- DEBUG(0,("Config Partition[%s => %s]\n",
- p->forest->config_dn_str, s->path.configdn_ldb));
-
- DEBUG(0,("Domain Partition[%s => %s]\n",
- p->domain->dn_str, s->path.domaindn_ldb));
-
- ejs = talloc_asprintf(s,
- "libinclude(\"base.js\");\n"
- "libinclude(\"provision.js\");\n"
- "\n"
- "function message() { print(vsprintf(arguments)); }\n"
- "\n"
- "var subobj = provision_guess();\n"
- "subobj.ROOTDN = \"%s\";\n"
- "subobj.DOMAINDN = \"%s\";\n"
- "subobj.DOMAINDN_LDB = \"%s\";\n"
- "subobj.CONFIGDN = \"%s\";\n"
- "subobj.CONFIGDN_LDB = \"%s\";\n"
- "subobj.SCHEMADN = \"%s\";\n"
- "subobj.SCHEMADN_LDB = \"%s\";\n"
- "subobj.HOSTNAME = \"%s\";\n"
- "subobj.REALM = \"%s\";\n"
- "subobj.DOMAIN = \"%s\";\n"
- "subobj.DEFAULTSITE = \"%s\";\n"
- "\n"
- "subobj.KRBTGTPASS = \"_NOT_USED_\";\n"
- "subobj.MACHINEPASS = \"%s\";\n"
- "subobj.ADMINPASS = \"_NOT_USED_\";\n"
- "\n"
- "var paths = provision_default_paths(subobj);\n"
- "paths.samdb = \"%s\";\n"
- "paths.secrets = \"%s\";\n"
- "paths.templates = \"%s\";\n"
- "paths.keytab = \"%s\";\n"
- "paths.dns_keytab = \"%s\";\n"
- "\n"
- "var system_session = system_session();\n"
- "\n"
- "var ok = provision_become_dc(subobj, message, true, paths, system_session);\n"
- "assert(ok);\n"
- "\n"
- "return 0;\n",
- p->forest->root_dn_str, /* subobj.ROOTDN */
- p->domain->dn_str, /* subobj.DOMAINDN */
- s->path.domaindn_ldb, /* subobj.DOMAINDN_LDB */
- p->forest->config_dn_str, /* subobj.CONFIGDN */
- s->path.configdn_ldb, /* subobj.CONFIGDN_LDB */
- p->forest->schema_dn_str, /* subobj.SCHEMADN */
- s->path.schemadn_ldb, /* subobj.SCHEMADN_LDB */
- p->dest_dsa->netbios_name, /* subobj.HOSTNAME */
- torture_join_dom_dns_name(s->tj),/* subobj.REALM */
- torture_join_dom_netbios_name(s->tj),/* subobj.DOMAIN */
- p->dest_dsa->site_name, /* subobj.DEFAULTSITE */
- cli_credentials_get_password(s->machine_account),/* subobj.MACHINEPASS */
- s->path.samdb_ldb, /* paths.samdb */
- s->path.templates_ldb, /* paths.templates */
- s->path.secrets_ldb, /* paths.secrets */
- s->path.secrets_keytab, /* paths.keytab */
- s->path.dns_keytab); /* paths.dns_keytab */
- NT_STATUS_HAVE_NO_MEMORY(ejs);
-
- ret = test_run_ejs(ejs);
- if (ret != 0) {
- DEBUG(0,("Failed to run ejs script: %d:\n%s",
- ret, ejs));
- talloc_free(ejs);
- return NT_STATUS_FOOBAR;
- }
- talloc_free(ejs);
-
- talloc_free(s->ldb);
-
- DEBUG(0,("Open the SAM LDB with system credentials: %s\n",
- s->path.samdb_ldb));
-
- s->ldb = ldb_wrap_connect(s, s->tctx->lp_ctx, s->path.samdb_ldb,
- system_session(s, s->tctx->lp_ctx),
- NULL, 0, NULL);
- if (!s->ldb) {
- DEBUG(0,("Failed to open '%s'\n",
- s->path.samdb_ldb));
- return NT_STATUS_INTERNAL_DB_ERROR;
- }
-
- ok = samdb_set_ntds_invocation_id(s->ldb, &p->dest_dsa->invocation_id);
- if (!ok) {
- DEBUG(0,("Failed to set cached ntds invocationId\n"));
- return NT_STATUS_FOOBAR;
- }
- ok = samdb_set_ntds_objectGUID(s->ldb, &p->dest_dsa->ntds_guid);
- if (!ok) {
- DEBUG(0,("Failed to set cached ntds objectGUID\n"));
- return NT_STATUS_FOOBAR;
- }
-
- return NT_STATUS_OK;
-}
-
-#ifdef HAVE_WORKING_PYTHON
-#include "param/param.h"
-#include <Python.h>
-#include "scripting/python/modules.h"
-
-static NTSTATUS test_become_dc_prepare_db_py(void *private_data,
- const struct libnet_BecomeDC_PrepareDB *p)
-{
- struct test_become_dc_state *s = talloc_get_type(private_data, struct test_become_dc_state);
- bool ok;
- PyObject *provision_fn, *result, *parameters;
-
- DEBUG(0,("Provision for Become-DC test using PYTHON\n"));
-
- py_load_samba_modules();
- Py_Initialize();
-
- py_update_path("bin"); /* FIXME: Can't assume this always runs in source/... */
-
- provision_fn = PyImport_Import(PyString_FromString("samba.provision.provision"));
-
- if (provision_fn == NULL) {
- DEBUG(0, ("Unable to import provision Python module.\n"));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- DEBUG(0,("New Server[%s] in Site[%s]\n",
- p->dest_dsa->dns_name, p->dest_dsa->site_name));
-
- DEBUG(0,("DSA Instance [%s]\n"
- "\tobjectGUID[%s]\n"
- "\tinvocationId[%s]\n",
- p->dest_dsa->ntds_dn_str,
- GUID_string(s, &p->dest_dsa->ntds_guid),
- GUID_string(s, &p->dest_dsa->invocation_id)));
-
- DEBUG(0,("Pathes under PRIVATEDIR[%s]\n"
- "SAMDB[%s] SECRETS[%s] KEYTAB[%s]\n",
- lp_private_dir(s->tctx->lp_ctx),
- s->path.samdb_ldb,
- s->path.secrets_ldb,
- s->path.secrets_keytab));
-
- DEBUG(0,("Schema Partition[%s => %s]\n",
- p->forest->schema_dn_str, s->path.schemadn_ldb));
-
- DEBUG(0,("Config Partition[%s => %s]\n",
- p->forest->config_dn_str, s->path.configdn_ldb));
-
- DEBUG(0,("Domain Partition[%s => %s]\n",
- p->domain->dn_str, s->path.domaindn_ldb));
-
- parameters = PyDict_New();
-
- PyDict_SetItemString(parameters, "rootdn", PyString_FromString(p->forest->root_dn_str));
- PyDict_SetItemString(parameters, "domaindn", PyString_FromString(p->domain->dn_str));
- PyDict_SetItemString(parameters, "domaindn_ldb", PyString_FromString(s->path.domaindn_ldb));
- PyDict_SetItemString(parameters, "configdn", PyString_FromString(p->forest->config_dn_str));
- PyDict_SetItemString(parameters, "configdn_ldb", PyString_FromString(s->path.configdn_ldb));
- PyDict_SetItemString(parameters, "schema_dn_str", PyString_FromString(p->forest->schema_dn_str));
- PyDict_SetItemString(parameters, "schemadn_ldb", PyString_FromString(s->path.schemadn_ldb));
- PyDict_SetItemString(parameters, "netbios_name", PyString_FromString(p->dest_dsa->netbios_name));
- PyDict_SetItemString(parameters, "dnsname", PyString_FromString(p->dest_dsa->dns_name));
- PyDict_SetItemString(parameters, "defaultsite", PyString_FromString(p->dest_dsa->site_name));
- PyDict_SetItemString(parameters, "machinepass", PyString_FromString(cli_credentials_get_password(s->machine_account)));
- PyDict_SetItemString(parameters, "samdb", PyString_FromString(s->path.samdb_ldb));
- PyDict_SetItemString(parameters, "secrets_ldb", PyString_FromString(s->path.secrets_ldb));
- PyDict_SetItemString(parameters, "secrets_keytab", PyString_FromString(s->path.secrets_keytab));
-
- result = PyEval_CallObjectWithKeywords(provision_fn, NULL, parameters);
-
- Py_DECREF(parameters);
-
- if (result == NULL) {
- PyErr_Print();
- PyErr_Clear();
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- talloc_free(s->ldb);
-
- DEBUG(0,("Open the SAM LDB with system credentials: %s\n",
- s->path.samdb_ldb));
-
- s->ldb = ldb_wrap_connect(s, s->tctx->lp_ctx, s->path.samdb_ldb,
- system_session(s, s->tctx->lp_ctx),
- NULL, 0, NULL);
- if (!s->ldb) {
- DEBUG(0,("Failed to open '%s'\n",
- s->path.samdb_ldb));
- return NT_STATUS_INTERNAL_DB_ERROR;
- }
-
- ok = samdb_set_ntds_invocation_id(s->ldb, &p->dest_dsa->invocation_id);
- if (!ok) {
- DEBUG(0,("Failed to set cached ntds invocationId\n"));
- return NT_STATUS_FOOBAR;
- }
- ok = samdb_set_ntds_objectGUID(s->ldb, &p->dest_dsa->ntds_guid);
- if (!ok) {
- DEBUG(0,("Failed to set cached ntds objectGUID\n"));
- return NT_STATUS_FOOBAR;
- }
-
- return NT_STATUS_OK;
-}
-#endif /* HAVE_WORKING_PYTHON */
-
static NTSTATUS test_apply_schema(struct test_become_dc_state *s,
const struct libnet_BecomeDC_StoreChunk *c)
{
@@ -878,12 +616,7 @@ bool torture_net_become_dc(struct torture_context *torture)
b.in.callbacks.private_data = s;
b.in.callbacks.check_options = test_become_dc_check_options;
- b.in.callbacks.prepare_db = test_become_dc_prepare_db_ejs;
-#ifdef HAVE_WORKING_PYTHON
- if (getenv("PROVISION_PYTHON")) {
- b.in.callbacks.prepare_db = test_become_dc_prepare_db_py;
- }
-#endif
+ b.in.callbacks.prepare_db = test_become_dc_prepare_db;
b.in.callbacks.schema_chunk = test_become_dc_schema_chunk;
b.in.callbacks.config_chunk = test_become_dc_store_chunk;
b.in.callbacks.domain_chunk = test_become_dc_store_chunk;
diff --git a/source4/torture/local/torture.c b/source4/torture/local/torture.c
index b57361bc8d..3273015347 100644
--- a/source4/torture/local/torture.c
+++ b/source4/torture/local/torture.c
@@ -39,12 +39,47 @@ static bool test_tempdir(struct torture_context *tctx)
return true;
}
+static bool test_provision(struct torture_context *tctx)
+{
+ NTSTATUS status;
+ struct provision_settings settings;
+
+ settings.dns_name = "example.com";
+ settings.site_name = "SOME-SITE-NAME";
+ settings.root_dn_str = "DC=EXAMPLE,DC=COM";
+ settings.domain_dn_str = "DC=EXAMPLE,DC=COM";
+ settings.config_dn_str = NULL;
+ settings.schema_dn_str = NULL;
+ settings.invocation_id = NULL;
+ settings.netbios_name = "FOO";
+ settings.realm = "EXAMPLE.COM";
+ settings.domain = "EXAMPLE";
+ settings.ntds_guid = NULL;
+ settings.ntds_dn_str = NULL;
+ settings.machine_password = "geheim";
+ settings.samdb_ldb = NULL;
+ settings.secrets_ldb = NULL;
+ settings.secrets_keytab = NULL;
+ settings.schemadn_ldb = NULL;
+ settings.configdn_ldb = NULL;
+ settings.domaindn_ldb = NULL;
+ settings.templates_ldb = NULL;
+ settings.dns_keytab = NULL;
+
+ status = provision_bare(tctx, tctx->lp_ctx, &settings);
+
+ torture_assert_ntstatus_ok(tctx, status, "provision");
+
+ return true;
+}
+
struct torture_suite *torture_local_torture(TALLOC_CTX *mem_ctx)
{
struct torture_suite *suite = torture_suite_create(mem_ctx,
"TORTURE");
torture_suite_add_simple_test(suite, "tempdir", test_tempdir);
+ torture_suite_add_simple_test(suite, "provision", test_provision);
return suite;
}
diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c
index 90e2eec2be..618568acf9 100644
--- a/source4/torture/locktest.c
+++ b/source4/torture/locktest.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "lib/cmdline/popt_common.h"
#include "system/filesys.h"
#include "system/time.h"
#include "pstring.h"
@@ -29,15 +30,15 @@
#include "libcli/resolve/resolve.h"
static int numops = 1000;
-static bool showall;
-static bool analyze;
-static bool hide_unlock_fails;
-static bool use_oplocks;
+static int showall;
+static int analyze;
+static int hide_unlock_fails;
+static int use_oplocks;
static uint_t lock_range = 100;
static uint_t lock_base = 0;
static uint_t min_length = 0;
-static bool exact_error_codes;
-static bool zero_zero;
+static int exact_error_codes;
+static int zero_zero;
#define FILENAME "\\locktest.dat"
@@ -395,7 +396,7 @@ static int retest(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
we then do random locking ops in tamdem on the 4 fnums from each
server and ensure that the results match
*/
-static void test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
+static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
{
struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
int fnum[NSERVERS][NCONNECTIONS][NFILES];
@@ -450,7 +451,12 @@ static void test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
open_files(cli, fnum);
n = retest(cli, fnum, numops);
- if (n == numops || !analyze) return;
+ if (n == numops || !analyze) {
+ if (n != numops) {
+ return 1;
+ }
+ return 0;
+ }
n++;
skip = n/2;
@@ -516,30 +522,16 @@ static void test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
(double)recorded[i].len,
recorded[i].needed);
}
+
+ return 1;
}
-static void usage(void)
+static void usage(poptContext pc)
{
- printf(
-"Usage:\n\
- locktest //server1/share1 //server2/share2 [options..]\n\
- options:\n\
- -U user%%pass (may be specified twice)\n\
- -s seed\n\
- -o numops\n\
- -u hide unlock fails\n\
- -a (show all ops)\n\
- -A analyse for minimal ops\n\
- -O use oplocks\n\
- -E enable exact error code checking\n\
- -Z enable the zero/zero lock\n\
- -R range set lock range\n\
- -B base set lock base\n\
- -M min set min lock length\n\
- -l filename unclist file\n\
-");
+ printf("Usage:\n\tlocktest //server1/share1 //server2/share2 [options..]\n");
+ poptPrintUsage(pc, stdout, 0);
}
/****************************************************************************
@@ -552,97 +544,87 @@ static void usage(void)
int seed, server;
int username_count=0;
struct loadparm_context *lp_ctx;
+ poptContext pc;
+ int argc_new, i;
+ char **argv_new;
+ enum {OPT_UNCLIST=1000};
+ struct poptOption long_options[] = {
+ POPT_AUTOHELP
+ {"seed", 0, POPT_ARG_INT, &seed, 0, "Seed to use for randomizer", NULL},
+ {"num-ops", 0, POPT_ARG_INT, &numops, 0, "num ops", NULL},
+ {"lockrange", 0, POPT_ARG_INT, &lock_range,0, "locking range", NULL},
+ {"lockbase", 0, POPT_ARG_INT, &lock_base, 0, "locking base", NULL},
+ {"minlength", 0, POPT_ARG_INT, &min_length,0, "min lock length", NULL},
+ {"hidefails", 0, POPT_ARG_NONE, &hide_unlock_fails,0,"hide unlock fails", NULL},
+ {"oplocks", 0, POPT_ARG_NONE, &use_oplocks,0, "use oplocks", NULL},
+ {"showall", 0, POPT_ARG_NONE, &showall, 0, "display all operations", NULL},
+ {"analyse", 0, POPT_ARG_NONE, &analyze, 0, "do backtrack analysis", NULL},
+ {"zerozero", 0, POPT_ARG_NONE, &zero_zero, 0, "do zero/zero lock", NULL},
+ {"exacterrors", 0, POPT_ARG_NONE, &exact_error_codes,0,"use exact error codes", NULL},
+ {"unclist", 0, POPT_ARG_STRING, NULL, OPT_UNCLIST, "unclist", NULL},
+ { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "[DOMAIN/]USERNAME[%PASSWORD]" },
+ POPT_COMMON_SAMBA
+ POPT_COMMON_CONNECTION
+ POPT_COMMON_CREDENTIALS
+ POPT_COMMON_VERSION
+ { NULL }
+ };
setlinebuf(stdout);
+ seed = time(NULL);
- setup_logging("locktest", DEBUG_STDOUT);
-
- if (argc < 3 || argv[1][0] == '-') {
- usage();
- exit(1);
- }
-
- setup_logging(argv[0], DEBUG_STDOUT);
-
- for (server=0;server<NSERVERS;server++) {
- share[server] = argv[1+server];
- all_string_sub(share[server],"/","\\",0);
- }
-
- argc -= NSERVERS;
- argv += NSERVERS;
+ pc = poptGetContext("locktest", argc, (const char **) argv, long_options,
+ POPT_CONTEXT_KEEP_FIRST);
- lp_ctx = loadparm_init(talloc_autofree_context());
- lp_load(lp_ctx, dyn_CONFIGFILE);
+ poptSetOtherOptionHelp(pc, "<unc1> <unc2>");
+ lp_ctx = cmdline_lp_ctx;
servers[0] = cli_credentials_init(talloc_autofree_context());
servers[1] = cli_credentials_init(talloc_autofree_context());
cli_credentials_guess(servers[0], lp_ctx);
cli_credentials_guess(servers[1], lp_ctx);
- seed = time(NULL);
-
- while ((opt = getopt(argc, argv, "U:s:ho:aAW:OR:B:M:EZW:l:")) != EOF) {
+ while((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
+ case OPT_UNCLIST:
+ lp_set_cmdline(cmdline_lp_ctx, "torture:unclist", poptGetOptArg(pc));
+ break;
case 'U':
if (username_count == 2) {
- usage();
+ usage(pc);
exit(1);
}
- cli_credentials_parse_string(servers[username_count],
- optarg, CRED_SPECIFIED);
+ cli_credentials_parse_string(servers[username_count], poptGetOptArg(pc), CRED_SPECIFIED);
username_count++;
break;
- case 'R':
- lock_range = strtol(optarg, NULL, 0);
- break;
- case 'B':
- lock_base = strtol(optarg, NULL, 0);
- break;
- case 'M':
- min_length = strtol(optarg, NULL, 0);
- break;
- case 's':
- seed = atoi(optarg);
- break;
- case 'u':
- hide_unlock_fails = true;
- break;
- case 'o':
- numops = atoi(optarg);
- break;
- case 'O':
- use_oplocks = true;
- break;
- case 'a':
- showall = true;
- break;
- case 'A':
- analyze = true;
- break;
- case 'Z':
- zero_zero = true;
- break;
- case 'E':
- exact_error_codes = true;
- break;
- case 'l':
- lp_set_cmdline(lp_ctx, "torture:unclist", optarg);
- break;
- case 'W':
- lp_set_cmdline(lp_ctx, "workgroup", optarg);
+ }
+ }
+
+ argv_new = discard_const_p(char *, poptGetArgs(pc));
+ argc_new = argc;
+ for (i=0; i<argc; i++) {
+ if (argv_new[i] == NULL) {
+ argc_new = i;
break;
- case 'h':
- usage();
- exit(1);
- default:
- printf("Unknown option %c (%d)\n", (char)opt, opt);
- exit(1);
}
}
+ if (!(argc_new >= 3)) {
+ usage(pc);
+ exit(1);
+ }
+
+ setup_logging("locktest", DEBUG_STDOUT);
+
+ for (server=0;server<NSERVERS;server++) {
+ share[server] = argv_new[1+server];
+ all_string_sub(share[server],"/","\\",0);
+ }
+
+ lp_ctx = cmdline_lp_ctx;
+
if (username_count == 0) {
- usage();
+ usage(pc);
return -1;
}
if (username_count == 1) {
@@ -651,15 +633,10 @@ static void usage(void)
gensec_init(lp_ctx);
- argc -= optind;
- argv += optind;
-
DEBUG(0,("seed=%u base=%d range=%d min_length=%d\n",
seed, lock_base, lock_range, min_length));
srandom(seed);
- test_locks(lp_ctx, share);
-
- return(0);
+ return test_locks(lp_ctx, share);
}
diff --git a/source4/torture/masktest.c b/source4/torture/masktest.c
index d1b853de72..ac7029aa50 100644
--- a/source4/torture/masktest.c
+++ b/source4/torture/masktest.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "lib/cmdline/popt_common.h"
#include "system/filesys.h"
#include "system/dir.h"
#include "libcli/libcli.h"
@@ -30,12 +31,10 @@
#include "dynconfig.h"
#include "libcli/resolve/resolve.h"
-static struct cli_credentials *credentials;
static bool showall = false;
static bool old_list = false;
static const char *maskchars = "<>\"?*abc.";
static const char *filechars = "abcdefghijklm.";
-static int verbose;
static int die_on_error;
static int NumLoops = 0;
static int max_length = 20;
@@ -87,13 +86,13 @@ static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx,
*share = 0;
share++;
- cli_credentials_set_workstation(credentials, "masktest", CRED_SPECIFIED);
+ cli_credentials_set_workstation(cmdline_credentials, "masktest", CRED_SPECIFIED);
status = smbcli_full_connection(NULL, &c,
server,
ports,
share, NULL,
- credentials, resolve_ctx, NULL,
+ cmdline_credentials, resolve_ctx, NULL,
options);
if (!NT_STATUS_IS_OK(status)) {
@@ -112,7 +111,7 @@ static bool f_info_hit;
static void listfn(struct clilist_file_info *f, const char *s, void *state)
{
- struct masktest_state *m = talloc_get_type(state,struct masktest_state);
+ struct masktest_state *m = (struct masktest_state *)state;
if (ISDOT(f->name)) {
resultp[0] = '+';
@@ -128,7 +127,7 @@ static void listfn(struct clilist_file_info *f, const char *s, void *state)
}
static void get_real_name(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
- char *long_name, fstring short_name)
+ char **long_name, fstring short_name)
{
const char *mask;
struct masktest_state state;
@@ -151,12 +150,12 @@ static void get_real_name(TALLOC_CTX *mem_ctx, struct smbcli_state *cli,
if (f_info_hit) {
fstrcpy(short_name, last_hit.short_name);
strlower(short_name);
- long_name = talloc_strdup(mem_ctx, last_hit.long_name);
- strlower(long_name);
+ *long_name = talloc_strdup(mem_ctx, last_hit.long_name);
+ strlower(*long_name);
}
if (*short_name == '\0') {
- fstrcpy(short_name, long_name);
+ fstrcpy(short_name, *long_name);
}
}
@@ -168,7 +167,7 @@ static void testpair(TALLOC_CTX *mem_ctx, struct smbcli_state *cli, char *mask,
char *res2;
static int count;
fstring short_name;
- char *long_name;
+ char *long_name = NULL;
struct masktest_state state;
count++;
@@ -186,7 +185,7 @@ static void testpair(TALLOC_CTX *mem_ctx, struct smbcli_state *cli, char *mask,
resultp = res1;
fstrcpy(short_name, "");
- get_real_name(mem_ctx, cli, long_name, short_name);
+ get_real_name(mem_ctx, cli, &long_name, short_name);
fstrcpy(res1, "---");
smbcli_list_new(cli->tree, mask,
FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,
@@ -241,6 +240,8 @@ static void test_mask(int argc, char *argv[],
l2 = 1 + random() % max_length;
mask = talloc_strdup(mem_ctx, "\\masktest\\");
file = talloc_strdup(mem_ctx, "\\masktest\\");
+ mask = talloc_realloc_size(mem_ctx, mask, strlen(mask)+l1+1);
+ file = talloc_realloc_size(mem_ctx, file, strlen(file)+l2+1);
l = strlen(mask);
for (i=0;i<l1;i++) {
mask[i+l] = maskchars[random() % mc_len];
@@ -269,30 +270,16 @@ static void test_mask(int argc, char *argv[],
}
-static void usage(void)
+static void usage(poptContext pc)
{
printf(
"Usage:\n\
masktest //server/share [options..]\n\
- options:\n\
- -d debuglevel\n\
- -n numloops\n\
- -W workgroup\n\
- -U user%%pass\n\
- -s seed\n\
- -l max test length\n\
- -M max protocol\n\
- -f filechars (default %s)\n\
- -m maskchars (default %s)\n\
- -v verbose mode\n\
- -E die on error\n\
- -a show all tests\n\
\n\
This program tests wildcard matching between two servers. It generates\n\
random pairs of filenames/masks and tests that they match in the same\n\
- way on the servers and internally\n\
-",
- filechars, maskchars);
+ way on the servers and internally\n");
+ poptPrintUsage(pc, stdout, 0);
}
/****************************************************************************
@@ -306,85 +293,67 @@ static void usage(void)
int seed;
struct loadparm_context *lp_ctx;
struct smbcli_options options;
+ poptContext pc;
+ int argc_new, i;
+ char **argv_new;
+ enum {OPT_UNCLIST=1000};
+ struct poptOption long_options[] = {
+ POPT_AUTOHELP
+ {"seed", 0, POPT_ARG_INT, &seed, 0, "Seed to use for randomizer", NULL},
+ {"num-ops", 0, POPT_ARG_INT, &NumLoops, 0, "num ops", NULL},
+ {"maxlength", 0, POPT_ARG_INT, &max_length,0, "maximum length", NULL},
+ {"dieonerror", 0, POPT_ARG_NONE, &die_on_error, 0, "die on errors", NULL},
+ {"showall", 0, POPT_ARG_NONE, &showall, 0, "display all operations", NULL},
+ {"oldlist", 0, POPT_ARG_NONE, &old_list, 0, "use old list call", NULL},
+ {"maskchars", 0, POPT_ARG_STRING, &maskchars, 0,"mask characters", NULL},
+ {"filechars", 0, POPT_ARG_STRING, &filechars, 0,"file characters", NULL},
+ POPT_COMMON_SAMBA
+ POPT_COMMON_CONNECTION
+ POPT_COMMON_CREDENTIALS
+ POPT_COMMON_VERSION
+ { NULL }
+ };
setlinebuf(stdout);
+ seed = time(NULL);
- setup_logging("masktest", DEBUG_STDOUT);
+ pc = poptGetContext("locktest", argc, (const char **) argv, long_options,
+ POPT_CONTEXT_KEEP_FIRST);
- if (argc < 2 || argv[1][0] == '-') {
- usage();
- exit(1);
- }
+ poptSetOtherOptionHelp(pc, "<unc>");
- share = argv[1];
-
- all_string_sub(share,"/","\\",0);
+ while((opt = poptGetNextOpt(pc)) != -1) {
+ switch (opt) {
+ case OPT_UNCLIST:
+ lp_set_cmdline(cmdline_lp_ctx, "torture:unclist", poptGetOptArg(pc));
+ break;
+ }
+ }
- setup_logging(argv[0], DEBUG_STDOUT);
+ argv_new = discard_const_p(char *, poptGetArgs(pc));
+ argc_new = argc;
+ for (i=0; i<argc; i++) {
+ if (argv_new[i] == NULL) {
+ argc_new = i;
+ break;
+ }
+ }
- argc -= 1;
- argv += 1;
+ if (!(argc_new >= 2)) {
+ usage(pc);
+ exit(1);
+ }
- lp_ctx = loadparm_init(talloc_autofree_context());
- lp_load(lp_ctx, dyn_CONFIGFILE);
+ setup_logging("masktest", DEBUG_STDOUT);
- credentials = cli_credentials_init(talloc_autofree_context());
- cli_credentials_guess(credentials, lp_ctx);
+ share = argv_new[1];
- seed = time(NULL);
+ all_string_sub(share,"/","\\",0);
- while ((opt = getopt(argc, argv, "n:d:U:s:hm:f:aoW:M:vEl:")) != EOF) {
- switch (opt) {
- case 'n':
- NumLoops = atoi(optarg);
- break;
- case 'd':
- DEBUGLEVEL = atoi(optarg);
- break;
- case 'E':
- die_on_error = 1;
- break;
- case 'v':
- verbose++;
- break;
- case 'M':
- lp_set_cmdline(lp_ctx, "max protocol", optarg);
- break;
- case 'U':
- cli_credentials_parse_string(credentials, optarg, CRED_SPECIFIED);
- break;
- case 's':
- seed = atoi(optarg);
- break;
- case 'h':
- usage();
- exit(1);
- case 'm':
- maskchars = optarg;
- break;
- case 'l':
- max_length = atoi(optarg);
- break;
- case 'f':
- filechars = optarg;
- break;
- case 'a':
- showall = 1;
- break;
- case 'o':
- old_list = true;
- break;
- default:
- printf("Unknown option %c (%d)\n", (char)opt, opt);
- exit(1);
- }
- }
+ lp_ctx = cmdline_lp_ctx;
gensec_init(lp_ctx);
- argc -= optind;
- argv += optind;
-
lp_smbcli_options(lp_ctx, &options);
cli = connect_one(lp_resolve_context(lp_ctx), share,
@@ -398,7 +367,7 @@ static void usage(void)
DEBUG(0,("seed=%d format --- --- (server, correct)\n", seed));
srandom(seed);
- test_mask(argc, argv, cli);
+ test_mask(argc_new-1, argv_new+1, cli);
return(0);
}
diff --git a/source4/torture/rpc/eventlog.c b/source4/torture/rpc/eventlog.c
index 047146edaf..feeeb9330b 100644
--- a/source4/torture/rpc/eventlog.c
+++ b/source4/torture/rpc/eventlog.c
@@ -67,11 +67,14 @@ static bool test_GetNumRecords(struct torture_context *tctx, struct dcerpc_pipe
struct eventlog_GetNumRecords r;
struct eventlog_CloseEventLog cr;
struct policy_handle handle;
+ uint32_t number = 0;
if (!get_policy_handle(tctx, p, &handle))
return false;
+ ZERO_STRUCT(r);
r.in.handle = &handle;
+ r.out.number = &number;
torture_assert_ntstatus_ok(tctx,
dcerpc_eventlog_GetNumRecords(p, tctx, &r),
@@ -98,6 +101,7 @@ static bool test_ReadEventLog(struct torture_context *tctx,
if (!get_policy_handle(tctx, p, &handle))
return false;
+ ZERO_STRUCT(r);
r.in.offset = 0;
r.in.handle = &handle;
r.in.flags = EVENTLOG_BACKWARDS_READ|EVENTLOG_SEQUENTIAL_READ;
@@ -107,11 +111,15 @@ static bool test_ReadEventLog(struct torture_context *tctx,
struct eventlog_Record rec;
struct ndr_pull *ndr;
enum ndr_err_code ndr_err;
+ uint32_t sent_size = 0;
+ uint32_t real_size = 0;
/* Read first for number of bytes in record */
r.in.number_of_bytes = 0;
r.out.data = NULL;
+ r.out.sent_size = &sent_size;
+ r.out.real_size = &real_size;
status = dcerpc_eventlog_ReadEventLogW(p, tctx, &r);
@@ -119,8 +127,6 @@ static bool test_ReadEventLog(struct torture_context *tctx,
break;
}
- torture_assert_ntstatus_ok(tctx, status, "ReadEventLog failed");
-
torture_assert_ntstatus_equal(tctx, r.out.result, NT_STATUS_BUFFER_TOO_SMALL,
"ReadEventLog failed");
diff --git a/source4/torture/rpc/initshutdown.c b/source4/torture/rpc/initshutdown.c
index 9f6f1735ee..92fec5be0c 100644
--- a/source4/torture/rpc/initshutdown.c
+++ b/source4/torture/rpc/initshutdown.c
@@ -24,10 +24,9 @@
#include "librpc/gen_ndr/ndr_initshutdown_c.h"
#include "torture/rpc/rpc.h"
-static void init_initshutdown_String(TALLOC_CTX *mem_ctx, struct initshutdown_String *name, const char *s)
+static void init_lsa_StringLarge(struct lsa_StringLarge *name, const char *s)
{
- name->name = talloc(mem_ctx, struct initshutdown_String_sub);
- name->name->name = s;
+ name->string = s;
}
@@ -58,8 +57,8 @@ static bool test_Init(struct torture_context *tctx,
uint16_t hostname = 0x0;
r.in.hostname = &hostname;
- r.in.message = talloc(tctx, struct initshutdown_String);
- init_initshutdown_String(tctx, r.in.message, "spottyfood");
+ r.in.message = talloc(tctx, struct lsa_StringLarge);
+ init_lsa_StringLarge(r.in.message, "spottyfood");
r.in.force_apps = 1;
r.in.timeout = 30;
r.in.reboot = 1;
@@ -80,8 +79,8 @@ static bool test_InitEx(struct torture_context *tctx,
uint16_t hostname = 0x0;
r.in.hostname = &hostname;
- r.in.message = talloc(tctx, struct initshutdown_String);
- init_initshutdown_String(tctx, r.in.message, "spottyfood");
+ r.in.message = talloc(tctx, struct lsa_StringLarge);
+ init_lsa_StringLarge(r.in.message, "spottyfood");
r.in.force_apps = 1;
r.in.timeout = 30;
r.in.reboot = 1;
diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c
index b08cd05bdb..779a28e126 100644
--- a/source4/torture/rpc/samba3rpc.c
+++ b/source4/torture/rpc/samba3rpc.c
@@ -806,6 +806,7 @@ static bool join3(struct smbcli_state *cli,
*/
static bool auth2(struct smbcli_state *cli,
+ struct loadparm_context *lp_ctx,
struct cli_credentials *wks_cred)
{
TALLOC_CTX *mem_ctx;
@@ -829,7 +830,7 @@ static bool auth2(struct smbcli_state *cli,
net_pipe = dcerpc_pipe_init(mem_ctx,
cli->transport->socket->event.ctx,
- lp_iconv_convenience(global_loadparm));
+ lp_iconv_convenience(lp_ctx));
if (net_pipe == NULL) {
d_printf("dcerpc_pipe_init failed\n");
goto done;
@@ -1204,7 +1205,7 @@ bool torture_netlogon_samba3(struct torture_context *torture)
int j;
- if (!auth2(cli, wks_creds)) {
+ if (!auth2(cli, torture->lp_ctx, wks_creds)) {
d_printf("auth2 failed\n");
goto done;
}
@@ -1283,7 +1284,7 @@ static bool test_join3(struct torture_context *tctx,
cmdline_credentials, cli_credentials_get_domain(wks_creds),
CRED_SPECIFIED);
- if (!auth2(cli, wks_creds)) {
+ if (!auth2(cli, tctx->lp_ctx, wks_creds)) {
d_printf("auth2 failed\n");
goto done;
}
@@ -1381,6 +1382,7 @@ bool torture_samba3_sessionkey(struct torture_context *torture)
*/
static NTSTATUS pipe_bind_smb(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
struct smbcli_tree *tree,
const char *pipe_name,
const struct ndr_interface_table *iface,
@@ -1391,7 +1393,7 @@ static NTSTATUS pipe_bind_smb(TALLOC_CTX *mem_ctx,
if (!(result = dcerpc_pipe_init(
mem_ctx, tree->session->transport->socket->event.ctx,
- lp_iconv_convenience(global_loadparm)))) {
+ lp_iconv_convenience(lp_ctx)))) {
return NT_STATUS_NO_MEMORY;
}
@@ -1507,7 +1509,9 @@ static struct dom_sid *name2sid(TALLOC_CTX *mem_ctx,
* Find out the user SID on this connection
*/
-static struct dom_sid *whoami(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree)
+static struct dom_sid *whoami(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
+ struct smbcli_tree *tree)
{
struct dcerpc_pipe *lsa;
struct lsa_GetUserName r;
@@ -1515,7 +1519,7 @@ static struct dom_sid *whoami(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree)
struct lsa_StringPointer authority_name_p;
struct dom_sid *result;
- status = pipe_bind_smb(mem_ctx, tree, "\\pipe\\lsarpc",
+ status = pipe_bind_smb(mem_ctx, lp_ctx, tree, "\\pipe\\lsarpc",
&ndr_table_lsarpc, &lsa);
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) Could not bind to LSA: %s\n",
@@ -1631,7 +1635,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
goto done;
}
- if (!(user_sid = whoami(mem_ctx, cli->tree))) {
+ if (!(user_sid = whoami(mem_ctx, torture->lp_ctx, cli->tree))) {
d_printf("(%s) whoami on auth'ed connection failed\n",
__location__);
ret = false;
@@ -1658,7 +1662,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
goto done;
}
- if (!(user_sid = whoami(mem_ctx, cli->tree))) {
+ if (!(user_sid = whoami(mem_ctx, torture->lp_ctx, cli->tree))) {
d_printf("(%s) whoami on anon connection failed\n",
__location__);
ret = false;
@@ -1732,7 +1736,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
goto done;
}
- if (!(user_sid = whoami(mem_ctx, tree))) {
+ if (!(user_sid = whoami(mem_ctx, torture->lp_ctx, tree))) {
d_printf("(%s) whoami on user connection failed\n",
__location__);
ret = false;
@@ -1870,8 +1874,8 @@ bool torture_samba3_rpc_srvsvc(struct torture_context *torture)
return false;
}
- status = pipe_bind_smb(mem_ctx, cli->tree, "\\pipe\\srvsvc",
- &ndr_table_srvsvc, &p);
+ status = pipe_bind_smb(mem_ctx, torture->lp_ctx, cli->tree,
+ "\\pipe\\srvsvc", &ndr_table_srvsvc, &p);
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) could not bind to srvsvc pipe: %s\n",
__location__, nt_errstr(status));
@@ -2007,6 +2011,7 @@ bool torture_samba3_rpc_randomauth2(struct torture_context *torture)
}
static struct security_descriptor *get_sharesec(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
struct smbcli_session *sess,
const char *sharename)
{
@@ -2028,7 +2033,7 @@ static struct security_descriptor *get_sharesec(TALLOC_CTX *mem_ctx,
return NULL;
}
- status = pipe_bind_smb(mem_ctx, tree, "\\pipe\\srvsvc",
+ status = pipe_bind_smb(mem_ctx, lp_ctx, tree, "\\pipe\\srvsvc",
&ndr_table_srvsvc, &p);
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) could not bind to srvsvc pipe: %s\n",
@@ -2060,6 +2065,7 @@ static struct security_descriptor *get_sharesec(TALLOC_CTX *mem_ctx,
}
static NTSTATUS set_sharesec(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
struct smbcli_session *sess,
const char *sharename,
struct security_descriptor *sd)
@@ -2083,7 +2089,7 @@ static NTSTATUS set_sharesec(TALLOC_CTX *mem_ctx,
return NT_STATUS_UNSUCCESSFUL;
}
- status = pipe_bind_smb(mem_ctx, tree, "\\pipe\\srvsvc",
+ status = pipe_bind_smb(mem_ctx, lp_ctx, tree, "\\pipe\\srvsvc",
&ndr_table_srvsvc, &p);
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) could not bind to srvsvc pipe: %s\n",
@@ -2115,6 +2121,7 @@ static NTSTATUS set_sharesec(TALLOC_CTX *mem_ctx,
}
bool try_tcon(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
struct security_descriptor *orig_sd,
struct smbcli_session *session,
const char *sharename, const struct dom_sid *user_sid,
@@ -2162,7 +2169,7 @@ bool try_tcon(TALLOC_CTX *mem_ctx,
return false;
}
- status = set_sharesec(mem_ctx, session, sharename, sd);
+ status = set_sharesec(mem_ctx, lp_ctx, session, sharename, sd);
if (!NT_STATUS_IS_OK(status)) {
d_printf("custom set_sharesec failed: %s\n",
nt_errstr(status));
@@ -2193,7 +2200,7 @@ bool try_tcon(TALLOC_CTX *mem_ctx,
done:
smbcli_rmdir(rmdir_tree, "sharesec_testdir");
- status = set_sharesec(mem_ctx, session, sharename, orig_sd);
+ status = set_sharesec(mem_ctx, lp_ctx, session, sharename, orig_sd);
if (!NT_STATUS_IS_OK(status)) {
d_printf("custom set_sharesec failed: %s\n",
nt_errstr(status));
@@ -2225,25 +2232,25 @@ bool torture_samba3_rpc_sharesec(struct torture_context *torture)
return false;
}
- if (!(user_sid = whoami(mem_ctx, cli->tree))) {
+ if (!(user_sid = whoami(mem_ctx, torture->lp_ctx, cli->tree))) {
d_printf("whoami failed\n");
talloc_free(mem_ctx);
return false;
}
- sd = get_sharesec(mem_ctx, cli->session, torture_setting_string(torture,
- "share", NULL));
+ sd = get_sharesec(mem_ctx, torture->lp_ctx, cli->session,
+ torture_setting_string(torture, "share", NULL));
- ret &= try_tcon(mem_ctx, sd, cli->session,
+ ret &= try_tcon(mem_ctx, torture->lp_ctx, sd, cli->session,
torture_setting_string(torture, "share", NULL),
user_sid, 0, NT_STATUS_ACCESS_DENIED, NT_STATUS_OK);
- ret &= try_tcon(mem_ctx, sd, cli->session,
+ ret &= try_tcon(mem_ctx, torture->lp_ctx, sd, cli->session,
torture_setting_string(torture, "share", NULL),
user_sid, SEC_FILE_READ_DATA, NT_STATUS_OK,
NT_STATUS_MEDIA_WRITE_PROTECTED);
- ret &= try_tcon(mem_ctx, sd, cli->session,
+ ret &= try_tcon(mem_ctx, torture->lp_ctx, sd, cli->session,
torture_setting_string(torture, "share", NULL),
user_sid, SEC_FILE_ALL, NT_STATUS_OK, NT_STATUS_OK);
@@ -2273,7 +2280,7 @@ bool torture_samba3_rpc_lsa(struct torture_context *torture)
return false;
}
- status = pipe_bind_smb(mem_ctx, cli->tree, "\\lsarpc",
+ status = pipe_bind_smb(mem_ctx, torture->lp_ctx, cli->tree, "\\lsarpc",
&ndr_table_lsarpc, &p);
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) pipe_bind_smb failed: %s\n", __location__,
@@ -2356,7 +2363,8 @@ static NTSTATUS get_servername(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree,
}
-static NTSTATUS find_printers(TALLOC_CTX *ctx, struct smbcli_tree *tree,
+static NTSTATUS find_printers(TALLOC_CTX *ctx, struct loadparm_context *lp_ctx,
+ struct smbcli_tree *tree,
const char ***printers, int *num_printers)
{
TALLOC_CTX *mem_ctx;
@@ -2372,7 +2380,8 @@ static NTSTATUS find_printers(TALLOC_CTX *ctx, struct smbcli_tree *tree,
return NT_STATUS_NO_MEMORY;
}
- status = pipe_bind_smb(mem_ctx, tree, "\\srvsvc", &ndr_table_srvsvc,
+ status = pipe_bind_smb(mem_ctx, lp_ctx,
+ tree, "\\srvsvc", &ndr_table_srvsvc,
&p);
if (!NT_STATUS_IS_OK(status)) {
d_printf("could not bind to srvsvc pipe\n");
@@ -2560,7 +2569,7 @@ bool torture_samba3_rpc_spoolss(struct torture_context *torture)
return false;
}
- if (!NT_STATUS_IS_OK(find_printers(mem_ctx, cli->tree,
+ if (!NT_STATUS_IS_OK(find_printers(mem_ctx, torture->lp_ctx, cli->tree,
&printers, &num_printers))) {
talloc_free(mem_ctx);
return false;
@@ -2572,7 +2581,7 @@ bool torture_samba3_rpc_spoolss(struct torture_context *torture)
return true;
}
- status = pipe_bind_smb(mem_ctx, cli->tree, "\\spoolss",
+ status = pipe_bind_smb(mem_ctx, torture->lp_ctx, cli->tree, "\\spoolss",
&ndr_table_spoolss, &p);
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) pipe_bind_smb failed: %s\n", __location__,
@@ -2746,7 +2755,7 @@ bool torture_samba3_rpc_wkssvc(struct torture_context *torture)
return false;
}
- status = pipe_bind_smb(mem_ctx, cli->tree, "\\wkssvc",
+ status = pipe_bind_smb(mem_ctx, torture->lp_ctx, cli->tree, "\\wkssvc",
&ndr_table_wkssvc, &p);
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) pipe_bind_smb failed: %s\n", __location__,
@@ -2995,6 +3004,7 @@ bool torture_samba3_rpc_winreg(struct torture_context *torture)
}
static NTSTATUS get_shareinfo(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
struct smbcli_state *cli,
const char *share,
struct srvsvc_NetShareInfo502 **info)
@@ -3006,7 +3016,7 @@ static NTSTATUS get_shareinfo(TALLOC_CTX *mem_ctx,
if (!(p = dcerpc_pipe_init(cli,
cli->transport->socket->event.ctx,
- lp_iconv_convenience(global_loadparm)))) {
+ lp_iconv_convenience(lp_ctx)))) {
status = NT_STATUS_NO_MEMORY;
goto fail;
}
@@ -3176,7 +3186,8 @@ static NTSTATUS torture_samba3_createshare(struct smbcli_state *cli,
return status;
}
-static NTSTATUS torture_samba3_deleteshare(struct smbcli_state *cli,
+static NTSTATUS torture_samba3_deleteshare(struct torture_context *torture,
+ struct smbcli_state *cli,
const char *sharename)
{
struct dcerpc_pipe *p;
@@ -3301,7 +3312,7 @@ bool torture_samba3_regconfig(struct torture_context *torture)
goto done;
}
- status = get_shareinfo(torture, cli, "blubber", &i);
+ status = get_shareinfo(torture, torture->lp_ctx, cli, "blubber", &i);
if (!NT_STATUS_IS_OK(status)) {
torture_warning(torture, "get_shareinfo failed: "
"%s\n", nt_errstr(status));
@@ -3314,7 +3325,7 @@ bool torture_samba3_regconfig(struct torture_context *torture)
goto done;
}
- status = torture_samba3_deleteshare(cli, "blubber");
+ status = torture_samba3_deleteshare(torture, cli, "blubber");
if (!NT_STATUS_IS_OK(status)) {
torture_warning(torture, "torture_samba3_deleteshare failed: "
"%s\n", nt_errstr(status));
diff --git a/source4/torture/rpc/samsync.c b/source4/torture/rpc/samsync.c
index 1f7f9f463e..865ebf9fd2 100644
--- a/source4/torture/rpc/samsync.c
+++ b/source4/torture/rpc/samsync.c
@@ -398,7 +398,7 @@ static bool samsync_handle_policy(TALLOC_CTX *mem_ctx, struct samsync_state *sam
return true;
}
-static bool samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state,
+static bool samsync_handle_user(struct torture_context *tctx, TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state,
int database_id, struct netr_DELTA_ENUM *delta)
{
uint32_t rid = delta->delta_id_union.rid;
@@ -548,7 +548,7 @@ static bool samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy
data.data = user->user_private_info.SensitiveData;
data.length = user->user_private_info.DataLength;
creds_arcfour_crypt(samsync_state->creds, data.data, data.length);
- ndr_err = ndr_pull_struct_blob(&data, mem_ctx, lp_iconv_convenience(global_loadparm), &keys, (ndr_pull_flags_fn_t)ndr_pull_netr_USER_KEYS);
+ ndr_err = ndr_pull_struct_blob(&data, mem_ctx, lp_iconv_convenience(tctx->lp_ctx), &keys, (ndr_pull_flags_fn_t)ndr_pull_netr_USER_KEYS);
if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
if (keys.keys.keys2.lmpassword.length == 16) {
sam_rid_crypt(rid, keys.keys.keys2.lmpassword.pwd.hash, lm_hash.hash, 0);
@@ -1101,8 +1101,9 @@ static bool samsync_handle_account(TALLOC_CTX *mem_ctx, struct samsync_state *sa
/*
try a netlogon DatabaseSync
*/
-static bool test_DatabaseSync(struct samsync_state *samsync_state,
- TALLOC_CTX *mem_ctx)
+static bool test_DatabaseSync(struct torture_context *tctx,
+ struct samsync_state *samsync_state,
+ TALLOC_CTX *mem_ctx)
{
NTSTATUS status;
TALLOC_CTX *loop_ctx, *delta_ctx, *trustdom_ctx;
@@ -1162,7 +1163,7 @@ static bool test_DatabaseSync(struct samsync_state *samsync_state,
}
break;
case NETR_DELTA_USER:
- if (!samsync_handle_user(delta_ctx, samsync_state,
+ if (!samsync_handle_user(tctx, delta_ctx, samsync_state,
r.in.database_id, &r.out.delta_enum_array->delta_enum[d])) {
printf("Failed to handle DELTA_USER\n");
ret = false;
@@ -1611,7 +1612,7 @@ bool torture_rpc_samsync(struct torture_context *torture)
ret = false;
}
- if (!test_DatabaseSync(samsync_state, mem_ctx)) {
+ if (!test_DatabaseSync(torture, samsync_state, mem_ctx)) {
printf("DatabaseSync failed\n");
ret = false;
}
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index 23b4aad30b..4a6ff480c4 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -1178,16 +1178,23 @@ static bool test_EnumPrinterData(struct torture_context *tctx, struct dcerpc_pip
NTSTATUS status;
struct spoolss_EnumPrinterData r;
+ ZERO_STRUCT(r);
r.in.handle = handle;
r.in.enum_index = 0;
do {
- uint32_t data_size;
-
- r.in.value_offered = 0;
- data_size = 0;
- r.in.data_size = &data_size;
- r.out.data_size = &data_size;
+ uint32_t value_size = 0;
+ uint32_t data_size = 0;
+ uint32_t printerdata_type = 0;
+ DATA_BLOB data = data_blob(NULL,0);
+
+ r.in.value_offered = value_size;
+ r.out.value_needed = &value_size;
+ r.in.data_offered = data_size;
+ r.out.data_needed = &data_size;
+
+ r.out.printerdata_type = &printerdata_type;
+ r.out.buffer = &data;
torture_comment(tctx, "Testing EnumPrinterData\n");
@@ -1195,7 +1202,8 @@ static bool test_EnumPrinterData(struct torture_context *tctx, struct dcerpc_pip
torture_assert_ntstatus_ok(tctx, status, "EnumPrinterData failed");
- r.in.value_offered = r.out.value_needed;
+ r.in.value_offered = value_size;
+ r.in.data_offered = data_size;
status = dcerpc_spoolss_EnumPrinterData(p, tctx, &r);
diff --git a/source4/torture/rpc/winreg.c b/source4/torture/rpc/winreg.c
index d77295605f..4695733671 100644
--- a/source4/torture/rpc/winreg.c
+++ b/source4/torture/rpc/winreg.c
@@ -38,12 +38,9 @@
#define TEST_SID "S-1-5-21-1234567890-1234567890-1234567890-500"
-static void init_initshutdown_String(TALLOC_CTX *mem_ctx,
- struct initshutdown_String *name,
- const char *s)
+static void init_lsa_StringLarge(struct lsa_StringLarge *name, const char *s)
{
- name->name = talloc(mem_ctx, struct initshutdown_String_sub);
- name->name->name = s;
+ name->string = s;
}
static void init_winreg_String(struct winreg_String *name, const char *s)
@@ -1636,8 +1633,8 @@ static bool test_InitiateSystemShutdown(struct torture_context *tctx,
uint16_t hostname = 0x0;
r.in.hostname = &hostname;
- r.in.message = talloc(tctx, struct initshutdown_String);
- init_initshutdown_String(tctx, r.in.message, "spottyfood");
+ r.in.message = talloc(tctx, struct lsa_StringLarge);
+ init_lsa_StringLarge(r.in.message, "spottyfood");
r.in.force_apps = 1;
r.in.timeout = 30;
r.in.reboot = 1;
@@ -1660,8 +1657,8 @@ static bool test_InitiateSystemShutdownEx(struct torture_context *tctx,
uint16_t hostname = 0x0;
r.in.hostname = &hostname;
- r.in.message = talloc(tctx, struct initshutdown_String);
- init_initshutdown_String(tctx, r.in.message, "spottyfood");
+ r.in.message = talloc(tctx, struct lsa_StringLarge);
+ init_lsa_StringLarge(r.in.message, "spottyfood");
r.in.force_apps = 1;
r.in.timeout = 30;
r.in.reboot = 1;
diff --git a/source4/torture/smb2/connect.c b/source4/torture/smb2/connect.c
index f1bc63dbbb..0004ea958e 100644
--- a/source4/torture/smb2/connect.c
+++ b/source4/torture/smb2/connect.c
@@ -147,10 +147,10 @@ static struct smb2_handle torture_smb2_create(struct smb2_tree *tree,
TALLOC_CTX *tmp_ctx = talloc_new(tree);
ZERO_STRUCT(io);
- io.in.oplock_flags = 0;
- io.in.access_mask = SEC_RIGHTS_FILE_ALL;
- io.in.file_attr = FILE_ATTRIBUTE_NORMAL;
- io.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.in.oplock_level = 0;
+ io.in.desired_access = SEC_RIGHTS_FILE_ALL;
+ io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ io.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
io.in.share_access =
NTCREATEX_SHARE_ACCESS_DELETE|
NTCREATEX_SHARE_ACCESS_READ|
@@ -166,7 +166,7 @@ static struct smb2_handle torture_smb2_create(struct smb2_tree *tree,
if (DEBUGLVL(1)) {
printf("Open gave:\n");
- printf("oplock_flags = 0x%x\n", io.out.oplock_flags);
+ printf("oplock_flags = 0x%x\n", io.out.oplock_level);
printf("create_action = 0x%x\n", io.out.create_action);
printf("create_time = %s\n", nt_time_string(tmp_ctx, io.out.create_time));
printf("access_time = %s\n", nt_time_string(tmp_ctx, io.out.access_time));
diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c
index f561b62d47..c47a26277c 100644
--- a/source4/torture/smb2/getinfo.c
+++ b/source4/torture/smb2/getinfo.c
@@ -51,7 +51,9 @@ static struct {
{ LEVEL(RAW_FILEINFO_COMPRESSION_INFORMATION) },
{ LEVEL(RAW_FILEINFO_NETWORK_OPEN_INFORMATION) },
{ LEVEL(RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION) },
- { LEVEL(RAW_FILEINFO_SMB2_ALL_EAS) },
+/*
+disabled until we know how the alignment now works
+{ LEVEL(RAW_FILEINFO_SMB2_ALL_EAS) }, */
{ LEVEL(RAW_FILEINFO_SMB2_ALL_INFORMATION) },
{ LEVEL(RAW_FILEINFO_SEC_DESC) }
};
@@ -85,13 +87,13 @@ static bool torture_smb2_fileinfo(struct torture_context *tctx, struct smb2_tree
status = torture_smb2_testfile(tree, FNAME, &hfile);
if (!NT_STATUS_IS_OK(status)) {
- printf("Unable to create test file '%s' - %s\n", FNAME, nt_errstr(status));
+ printf(__location__ " Unable to create test file '%s' - %s\n", FNAME, nt_errstr(status));
goto failed;
}
status = torture_smb2_testdir(tree, DNAME, &hdir);
if (!NT_STATUS_IS_OK(status)) {
- printf("Unable to create test directory '%s' - %s\n", DNAME, nt_errstr(status));
+ printf(__location__ " Unable to create test directory '%s' - %s\n", DNAME, nt_errstr(status));
goto failed;
}
@@ -150,7 +152,7 @@ static bool torture_smb2_fsinfo(struct smb2_tree *tree)
printf("Testing fsinfo levels\n");
status = smb2_util_roothandle(tree, &handle);
if (!NT_STATUS_IS_OK(status)) {
- printf("Unable to create test directory '%s' - %s\n", DNAME, nt_errstr(status));
+ printf(__location__ " Unable to create root handle - %s\n", nt_errstr(status));
return false;
}
diff --git a/source4/torture/smb2/lock.c b/source4/torture/smb2/lock.c
index 98e412817b..3cf2e93ee0 100644
--- a/source4/torture/smb2/lock.c
+++ b/source4/torture/smb2/lock.c
@@ -238,10 +238,10 @@ static bool test_lock_read_write(struct torture_context *torture,
CHECK_VALUE(lck.out.unknown1, 0);
ZERO_STRUCT(cr);
- cr.in.oplock_flags = 0;
- cr.in.access_mask = SEC_RIGHTS_FILE_ALL;
- cr.in.file_attr = FILE_ATTRIBUTE_NORMAL;
- cr.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ cr.in.oplock_level = 0;
+ cr.in.desired_access = SEC_RIGHTS_FILE_ALL;
+ cr.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ cr.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
cr.in.share_access =
NTCREATEX_SHARE_ACCESS_DELETE|
NTCREATEX_SHARE_ACCESS_READ|
diff --git a/source4/torture/smb2/scan.c b/source4/torture/smb2/scan.c
index 84be11c047..0f4c9fefdf 100644
--- a/source4/torture/smb2/scan.c
+++ b/source4/torture/smb2/scan.c
@@ -68,19 +68,21 @@ bool torture_smb2_getinfo_scan(struct torture_context *torture)
ZERO_STRUCT(io);
- io.in.max_response_size = 0xFFFF;
+ io.in.output_buffer_length = 0xFFFF;
for (c=1;c<5;c++) {
for (i=0;i<0x100;i++) {
- io.in.level = (i<<8) | c;
+ io.in.info_type = c;
+ io.in.info_class = i;
io.in.file.handle = fhandle;
status = smb2_getinfo(tree, torture, &io);
if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS) &&
!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER) &&
!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
- printf("file level 0x%04x is %ld bytes - %s\n",
- io.in.level, (long)io.out.blob.length, nt_errstr(status));
+ printf("file level 0x%02x:%02x is %ld bytes - %s\n",
+ io.in.info_type, io.in.info_class,
+ (long)io.out.blob.length, nt_errstr(status));
dump_data(1, io.out.blob.data, io.out.blob.length);
}
@@ -89,8 +91,9 @@ bool torture_smb2_getinfo_scan(struct torture_context *torture)
if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS) &&
!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER) &&
!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
- printf("dir level 0x%04x is %ld bytes - %s\n",
- io.in.level, (long)io.out.blob.length, nt_errstr(status));
+ printf("dir level 0x%02x:%02x is %ld bytes - %s\n",
+ io.in.info_type, io.in.info_class,
+ (long)io.out.blob.length, nt_errstr(status));
dump_data(1, io.out.blob.data, io.out.blob.length);
}
}
diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c
index fe88296a32..f85b1c42ff 100644
--- a/source4/torture/smb2/util.c
+++ b/source4/torture/smb2/util.c
@@ -55,9 +55,9 @@ NTSTATUS smb2_util_unlink(struct smb2_tree *tree, const char *fname)
NTSTATUS status;
ZERO_STRUCT(io);
- io.in.access_mask = SEC_RIGHTS_FILE_ALL;
- io.in.file_attr = FILE_ATTRIBUTE_NORMAL;
- io.in.open_disposition = NTCREATEX_DISP_OPEN;
+ io.in.desired_access = SEC_RIGHTS_FILE_ALL;
+ io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ io.in.create_disposition = NTCREATEX_DISP_OPEN;
io.in.share_access =
NTCREATEX_SHARE_ACCESS_DELETE|
NTCREATEX_SHARE_ACCESS_READ|
@@ -107,9 +107,9 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname,
smb2_util_unlink(tree, fname);
ZERO_STRUCT(io);
- io.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- io.in.file_attr = FILE_ATTRIBUTE_NORMAL;
- io.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF;
+ io.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
+ io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ io.in.create_disposition = NTCREATEX_DISP_OVERWRITE_IF;
io.in.share_access =
NTCREATEX_SHARE_ACCESS_DELETE|
NTCREATEX_SHARE_ACCESS_READ|
@@ -119,10 +119,11 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname,
if (dir) {
io.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
io.in.share_access &= ~NTCREATEX_SHARE_ACCESS_DELETE;
- io.in.file_attr = FILE_ATTRIBUTE_DIRECTORY;
- io.in.open_disposition = NTCREATEX_DISP_CREATE;
+ io.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
+ io.in.create_disposition = NTCREATEX_DISP_CREATE;
}
+ /* it seems vista is now fussier about alignment? */
if (strchr(fname, ':') == NULL) {
/* setup some EAs */
io.in.eas.num_eas = 2;
@@ -334,10 +335,10 @@ NTSTATUS torture_smb2_testfile(struct smb2_tree *tree, const char *fname,
NTSTATUS status;
ZERO_STRUCT(io);
- io.in.oplock_flags = 0;
- io.in.access_mask = SEC_RIGHTS_FILE_ALL;
- io.in.file_attr = FILE_ATTRIBUTE_NORMAL;
- io.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.in.oplock_level = 0;
+ io.in.desired_access = SEC_RIGHTS_FILE_ALL;
+ io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ io.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
io.in.share_access =
NTCREATEX_SHARE_ACCESS_DELETE|
NTCREATEX_SHARE_ACCESS_READ|
@@ -370,10 +371,10 @@ NTSTATUS torture_smb2_testdir(struct smb2_tree *tree, const char *fname,
NTSTATUS status;
ZERO_STRUCT(io);
- io.in.oplock_flags = 0;
- io.in.access_mask = SEC_RIGHTS_DIR_ALL;
- io.in.file_attr = FILE_ATTRIBUTE_DIRECTORY;
- io.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.in.oplock_level = 0;
+ io.in.desired_access = SEC_RIGHTS_DIR_ALL;
+ io.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
+ io.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
io.in.share_access = NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE;
io.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
io.in.fname = fname;
@@ -422,13 +423,13 @@ NTSTATUS smb2_util_roothandle(struct smb2_tree *tree, struct smb2_handle *handle
NTSTATUS status;
ZERO_STRUCT(io);
- io.in.oplock_flags = 0;
- io.in.access_mask = SEC_STD_SYNCHRONIZE | SEC_DIR_READ_ATTRIBUTE | SEC_DIR_LIST;
- io.in.file_attr = 0;
- io.in.open_disposition = NTCREATEX_DISP_OPEN;
+ io.in.oplock_level = 0;
+ io.in.desired_access = SEC_STD_SYNCHRONIZE | SEC_DIR_READ_ATTRIBUTE | SEC_DIR_LIST;
+ io.in.file_attributes = 0;
+ io.in.create_disposition = NTCREATEX_DISP_OPEN;
io.in.share_access = NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_DELETE;
io.in.create_options = NTCREATEX_OPTIONS_ASYNC_ALERT;
- io.in.fname = "";
+ io.in.fname = NULL;
status = smb2_create(tree, tree, &io);
NT_STATUS_NOT_OK_RETURN(status);
diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c
index 371ddc7297..4eeea73003 100644
--- a/source4/torture/smbtorture.c
+++ b/source4/torture/smbtorture.c
@@ -615,8 +615,6 @@ int main(int argc,char *argv[])
alarm(max_runtime);
}
- ldb_global_init();
-
if (extra_module != NULL) {
init_module_fn fn = load_module(talloc_autofree_context(), poptGetOptArg(pc));
diff --git a/source4/torture/util.c b/source4/torture/util.c
deleted file mode 100644
index 0e9dda42fa..0000000000
--- a/source4/torture/util.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- SMB torture tester utility functions
- Copyright (C) Jelmer Vernooij 2006
-
- 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 "system/filesys.h"
-#include "system/wait.h"
-#include "torture/torture.h"
-#include "libcli/raw/interfaces.h"
-#include "libcli/raw/libcliraw.h"
-
-/**
- check if 2 NTTIMEs are equal.
-*/
-bool nt_time_equal(NTTIME *t1, NTTIME *t2)
-{
- return *t1 == *t2;
-}
-
-NTSTATUS torture_second_tcon(TALLOC_CTX *mem_ctx,
- struct smbcli_session *session,
- const char *sharename,
- struct smbcli_tree **res)
-{
- union smb_tcon tcon;
- struct smbcli_tree *result;
- TALLOC_CTX *tmp_ctx;
- NTSTATUS status;
-
- if ((tmp_ctx = talloc_new(mem_ctx)) == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- result = smbcli_tree_init(session, tmp_ctx, false);
- if (result == NULL) {
- talloc_free(tmp_ctx);
- return NT_STATUS_NO_MEMORY;
- }
-
- tcon.generic.level = RAW_TCON_TCONX;
- tcon.tconx.in.flags = 0;
-
- /* Ignore share mode security here */
- tcon.tconx.in.password = data_blob(NULL, 0);
- tcon.tconx.in.path = sharename;
- tcon.tconx.in.device = "?????";
-
- status = smb_raw_tcon(result, tmp_ctx, &tcon);
- if (!NT_STATUS_IS_OK(status)) {
- talloc_free(tmp_ctx);
- return status;
- }
-
- result->tid = tcon.tconx.out.tid;
- *res = talloc_steal(mem_ctx, result);
- talloc_free(tmp_ctx);
- return NT_STATUS_OK;
-}
diff --git a/source4/torture/util.h b/source4/torture/util.h
new file mode 100644
index 0000000000..c5219a5aaa
--- /dev/null
+++ b/source4/torture/util.h
@@ -0,0 +1,120 @@
+/*
+ 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 _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 struct GUID *invocation_id;
+ const char *netbios_name;
+ const char *realm;
+ const char *domain;
+ const struct GUID *ntds_guid;
+ const char *ntds_dn_str;
+ const char *machine_password;
+ const char *samdb_ldb;
+ const char *secrets_ldb;
+ const char *secrets_keytab;
+ const char *schemadn_ldb;
+ const char *configdn_ldb;
+ const char *domaindn_ldb;
+ const char *templates_ldb;
+ const char *dns_keytab;
+};
+
+NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
+ struct provision_settings *settings);
+
+
+/**
+ setup a directory ready for a test
+*/
+_PUBLIC_ bool torture_setup_dir(struct smbcli_state *cli, const char *dname);
+NTSTATUS create_directory_handle(struct smbcli_tree *tree, const char *dname, int *fnum);
+
+/**
+ sometimes we need a fairly complex file to work with, so we can test
+ all possible attributes.
+*/
+_PUBLIC_ int create_complex_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx, const char *fname);
+int create_complex_dir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx, const char *dname);
+void *shm_setup(int size);
+
+/**
+ check that a wire string matches the flags specified
+ not 100% accurate, but close enough for testing
+*/
+bool wire_bad_flags(struct smb_wire_string *str, int flags,
+ struct smbcli_transport *transport);
+void dump_all_info(TALLOC_CTX *mem_ctx, union smb_fileinfo *finfo);
+void torture_all_info(struct smbcli_tree *tree, const char *fname);
+bool torture_set_file_attribute(struct smbcli_tree *tree, const char *fname, uint16_t attrib);
+NTSTATUS torture_set_sparse(struct smbcli_tree *tree, int fnum);
+NTSTATUS torture_check_ea(struct smbcli_state *cli,
+ const char *fname, const char *eaname, const char *value);
+_PUBLIC_ bool torture_open_connection_share(TALLOC_CTX *mem_ctx,
+ struct smbcli_state **c,
+ struct torture_context *tctx,
+ const char *hostname,
+ const char *sharename,
+ struct event_context *ev);
+_PUBLIC_ bool torture_get_conn_index(int conn_index,
+ TALLOC_CTX *mem_ctx,
+ struct torture_context *tctx,
+ char **host, char **share);
+_PUBLIC_ bool torture_open_connection_ev(struct smbcli_state **c,
+ int conn_index,
+ struct torture_context *tctx,
+ struct event_context *ev);
+_PUBLIC_ bool torture_open_connection(struct smbcli_state **c, struct torture_context *tctx, int conn_index);
+_PUBLIC_ bool torture_close_connection(struct smbcli_state *c);
+_PUBLIC_ bool check_error(const char *location, struct smbcli_state *c,
+ uint8_t eclass, uint32_t ecode, NTSTATUS nterr);
+double torture_create_procs(struct torture_context *tctx,
+ bool (*fn)(struct torture_context *, struct smbcli_state *, int), bool *result);
+_PUBLIC_ struct torture_test *torture_suite_add_smb_multi_test(
+ struct torture_suite *suite,
+ const char *name,
+ bool (*run) (struct torture_context *,
+ struct smbcli_state *,
+ int i));
+_PUBLIC_ struct torture_test *torture_suite_add_2smb_test(
+ struct torture_suite *suite,
+ const char *name,
+ bool (*run) (struct torture_context *,
+ struct smbcli_state *,
+ struct smbcli_state *));
+_PUBLIC_ struct torture_test *torture_suite_add_1smb_test(
+ struct torture_suite *suite,
+ const char *name,
+ bool (*run) (struct torture_context *, struct smbcli_state *));
+NTSTATUS torture_second_tcon(TALLOC_CTX *mem_ctx,
+ struct smbcli_session *session,
+ const char *sharename,
+ struct smbcli_tree **res);
+
+
+
+#endif /* _TORTURE_PROVISION_H_ */
diff --git a/source4/torture/util_provision.c b/source4/torture/util_provision.c
new file mode 100644
index 0000000000..2a1e9256f5
--- /dev/null
+++ b/source4/torture/util_provision.c
@@ -0,0 +1,355 @@
+/*
+ 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 "dsdb/samdb/samdb.h"
+#include "lib/appweb/ejs/ejs.h"
+#include "lib/appweb/ejs/ejsInternal.h"
+#include "scripting/ejs/smbcalls.h"
+#include "auth/auth.h"
+#include "lib/ldb_wrap.h"
+#include "torture/util.h"
+
+static EjsId eid;
+static int ejs_error;
+
+static void test_ejs_exception(const char *reason)
+{
+ Ejs *ep = ejsPtr(eid);
+ ejsSetErrorMsg(eid, "%s", reason);
+ fprintf(stderr, "%s", ep->error);
+ ejs_error = 127;
+}
+
+static int test_run_ejs(char *script)
+{
+ EjsHandle handle = 0;
+ MprVar result;
+ char *emsg;
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
+ struct MprVar *return_var;
+
+ mprSetCtx(mem_ctx);
+
+ if (ejsOpen(NULL, NULL, NULL) != 0) {
+ d_printf("ejsOpen(): unable to initialise EJS subsystem\n");
+ ejs_error = 127;
+ goto failed;
+ }
+
+ smb_setup_ejs_functions(test_ejs_exception);
+
+ if ((eid = ejsOpenEngine(handle, 0)) == (EjsId)-1) {
+ d_printf("smbscript: ejsOpenEngine(): unable to initialise an EJS engine\n");
+ ejs_error = 127;
+ goto failed;
+ }
+
+ mprSetVar(ejsGetGlobalObject(eid), "ARGV", mprList("ARGV", NULL));
+
+ /* run the script */
+ if (ejsEvalScript(eid, script, &result, &emsg) == -1) {
+ d_printf("smbscript: ejsEvalScript(): %s\n", emsg);
+ if (ejs_error == 0) ejs_error = 127;
+ goto failed;
+ }
+
+ return_var = ejsGetReturnValue(eid);
+ ejs_error = mprVarToNumber(return_var);
+
+failed:
+ ejsClose();
+ talloc_free(mem_ctx);
+ return ejs_error;
+}
+
+static NTSTATUS provision_bare_ejs(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
+ struct provision_settings *settings)
+{
+ char *ejs;
+ int ret;
+ bool ok;
+ struct ldb_context *ldb;
+
+ DEBUG(0,("Provision for Become-DC test using EJS\n"));
+
+ DEBUG(0,("New Server[%s] in Site[%s]\n", settings->dns_name,
+ settings->site_name));
+
+ DEBUG(0,("DSA Instance [%s]\n"
+ "\tobjectGUID[%s]\n"
+ "\tinvocationId[%s]\n",
+ settings->ntds_dn_str,
+ GUID_string(mem_ctx, settings->ntds_guid),
+ GUID_string(mem_ctx, settings->invocation_id)));
+
+ DEBUG(0,("Pathes under PRIVATEDIR[%s]\n"
+ "SAMDB[%s] SECRETS[%s] KEYTAB[%s]\n",
+ lp_private_dir(lp_ctx),
+ settings->samdb_ldb,
+ settings->secrets_ldb,
+ settings->secrets_keytab));
+
+ DEBUG(0,("Schema Partition[%s => %s]\n",
+ settings->schema_dn_str, settings->schemadn_ldb));
+
+ DEBUG(0,("Config Partition[%s => %s]\n",
+ settings->config_dn_str, settings->configdn_ldb));
+
+ DEBUG(0,("Domain Partition[%s => %s]\n",
+ settings->domain_dn_str, settings->domaindn_ldb));
+
+ ejs = talloc_asprintf(mem_ctx,
+ "libinclude(\"base.js\");\n"
+ "libinclude(\"provision.js\");\n"
+ "\n"
+ "function message() { print(vsprintf(arguments)); }\n"
+ "\n"
+ "var subobj = provision_guess();\n"
+ "subobj.ROOTDN = \"%s\";\n"
+ "subobj.DOMAINDN = \"%s\";\n"
+ "subobj.DOMAINDN_LDB = \"%s\";\n"
+ "subobj.CONFIGDN = \"%s\";\n"
+ "subobj.CONFIGDN_LDB = \"%s\";\n"
+ "subobj.SCHEMADN = \"%s\";\n"
+ "subobj.SCHEMADN_LDB = \"%s\";\n"
+ "subobj.HOSTNAME = \"%s\";\n"
+ "subobj.REALM = \"%s\";\n"
+ "subobj.DOMAIN = \"%s\";\n"
+ "subobj.DEFAULTSITE = \"%s\";\n"
+ "\n"
+ "subobj.KRBTGTPASS = \"_NOT_USED_\";\n"
+ "subobj.MACHINEPASS = \"%s\";\n"
+ "subobj.ADMINPASS = \"_NOT_USED_\";\n"
+ "\n"
+ "var paths = provision_default_paths(subobj);\n"
+ "paths.samdb = \"%s\";\n"
+ "paths.secrets = \"%s\";\n"
+ "paths.templates = \"%s\";\n"
+ "paths.keytab = \"%s\";\n"
+ "paths.dns_keytab = \"%s\";\n"
+ "\n"
+ "var system_session = system_session();\n"
+ "\n"
+ "var ok = provision_become_dc(subobj, message, true, paths, system_session);\n"
+ "assert(ok);\n"
+ "\n"
+ "return 0;\n",
+ settings->root_dn_str, /* subobj.ROOTDN */
+ settings->domain_dn_str, /* subobj.DOMAINDN */
+ settings->domaindn_ldb, /* subobj.DOMAINDN_LDB */
+ settings->config_dn_str, /* subobj.CONFIGDN */
+ settings->configdn_ldb, /* subobj.CONFIGDN_LDB */
+ settings->schema_dn_str, /* subobj.SCHEMADN */
+ settings->schemadn_ldb, /* subobj.SCHEMADN_LDB */
+ settings->netbios_name, /* subobj.HOSTNAME */
+ settings->realm,/* subobj.REALM */
+ settings->domain,/* subobj.DOMAIN */
+ settings->site_name, /* subobj.DEFAULTSITE */
+ settings->machine_password,/* subobj.MACHINEPASS */
+ settings->samdb_ldb, /* paths.samdb */
+ settings->templates_ldb, /* paths.templates */
+ settings->secrets_ldb, /* paths.secrets */
+ settings->secrets_keytab, /* paths.keytab */
+ settings->dns_keytab); /* paths.dns_keytab */
+ NT_STATUS_HAVE_NO_MEMORY(ejs);
+
+ ret = test_run_ejs(ejs);
+ if (ret != 0) {
+ DEBUG(0,("Failed to run ejs script: %d:\n%s",
+ ret, ejs));
+ talloc_free(ejs);
+ return NT_STATUS_FOOBAR;
+ }
+ talloc_free(ejs);
+
+ DEBUG(0,("Open the SAM LDB with system credentials: %s\n",
+ settings->samdb_ldb));
+
+ ldb = ldb_wrap_connect(mem_ctx, lp_ctx, settings->samdb_ldb,
+ system_session(mem_ctx, lp_ctx),
+ NULL, 0, NULL);
+ if (!ldb) {
+ DEBUG(0,("Failed to open '%s'\n",
+ settings->samdb_ldb));
+ return NT_STATUS_INTERNAL_DB_ERROR;
+ }
+
+ ok = samdb_set_ntds_invocation_id(ldb, settings->invocation_id);
+ if (!ok) {
+ DEBUG(0,("Failed to set cached ntds invocationId\n"));
+ return NT_STATUS_FOOBAR;
+ }
+ ok = samdb_set_ntds_objectGUID(ldb, settings->ntds_guid);
+ if (!ok) {
+ DEBUG(0,("Failed to set cached ntds objectGUID\n"));
+ return NT_STATUS_FOOBAR;
+ }
+
+ return NT_STATUS_OK;
+}
+
+#include "param/param.h"
+#include <Python.h>
+#include "scripting/python/modules.h"
+
+static NTSTATUS provision_bare_py(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
+ struct provision_settings *settings)
+{
+ bool ok;
+ PyObject *provision_mod, *provision_dict, *provision_fn, *result, *parameters;
+ struct ldb_context *ldb;
+
+ DEBUG(0,("Provision for Become-DC test using python\n"));
+
+ py_load_samba_modules();
+ Py_Initialize();
+ py_update_path("bin"); /* FIXME: Can't assume this is always the case */
+
+ provision_mod = PyImport_Import(PyString_FromString("samba.provision"));
+
+ if (provision_mod == NULL) {
+ PyErr_Print();
+ DEBUG(0, ("Unable to import provision Python module.\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ provision_dict = PyModule_GetDict(provision_mod);
+
+ if (provision_dict == NULL) {
+ DEBUG(0, ("Unable to get dictionary for provision module\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ provision_fn = PyDict_GetItemString(provision_dict, "provision");
+ if (provision_fn == NULL) {
+ PyErr_Print();
+ DEBUG(0, ("Unable to get provision function\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ DEBUG(0,("New Server[%s] in Site[%s]\n", settings->dns_name,
+ settings->site_name));
+
+ DEBUG(0,("DSA Instance [%s]\n"
+ "\tobjectGUID[%s]\n"
+ "\tinvocationId[%s]\n",
+ settings->ntds_dn_str,
+ settings->ntds_guid == NULL?"None":GUID_string(mem_ctx, settings->ntds_guid),
+ settings->invocation_id == NULL?"None":GUID_string(mem_ctx, settings->invocation_id)));
+
+ DEBUG(0,("Pathes under PRIVATEDIR[%s]\n"
+ "SAMDB[%s] SECRETS[%s] KEYTAB[%s]\n",
+ lp_private_dir(lp_ctx),
+ settings->samdb_ldb,
+ settings->secrets_ldb,
+ settings->secrets_keytab));
+
+ DEBUG(0,("Schema Partition[%s => %s]\n",
+ settings->schema_dn_str, settings->schemadn_ldb));
+
+ DEBUG(0,("Config Partition[%s => %s]\n",
+ settings->config_dn_str, settings->configdn_ldb));
+
+ DEBUG(0,("Domain Partition[%s => %s]\n",
+ settings->domain_dn_str, settings->domaindn_ldb));
+
+ parameters = PyDict_New();
+
+ PyDict_SetItemString(parameters, "rootdn",
+ PyString_FromString(settings->root_dn_str));
+ if (settings->domaindn_ldb != NULL)
+ PyDict_SetItemString(parameters, "domaindn_ldb",
+ PyString_FromString(settings->domaindn_ldb));
+ if (settings->config_dn_str != NULL)
+ PyDict_SetItemString(parameters, "configdn",
+ PyString_FromString(settings->config_dn_str));
+ if (settings->configdn_ldb != NULL)
+ PyDict_SetItemString(parameters, "configdn_ldb",
+ PyString_FromString(settings->configdn_ldb));
+ if (settings->schema_dn_str != NULL)
+ PyDict_SetItemString(parameters, "schema_dn_str",
+ PyString_FromString(settings->schema_dn_str));
+ if (settings->schemadn_ldb != NULL)
+ PyDict_SetItemString(parameters, "schemadn_ldb",
+ PyString_FromString(settings->schemadn_ldb));
+ PyDict_SetItemString(parameters, "hostname",
+ PyString_FromString(settings->netbios_name));
+ PyDict_SetItemString(parameters, "sitename",
+ PyString_FromString(settings->site_name));
+ PyDict_SetItemString(parameters, "machinepass",
+ PyString_FromString(settings->machine_password));
+ if (settings->samdb_ldb != NULL)
+ PyDict_SetItemString(parameters, "samdb",
+ PyString_FromString(settings->samdb_ldb));
+ if (settings->secrets_ldb != NULL)
+ PyDict_SetItemString(parameters, "secrets_ldb",
+ PyString_FromString(settings->secrets_ldb));
+ if (settings->secrets_keytab != NULL)
+ PyDict_SetItemString(parameters, "secrets_keytab",
+ PyString_FromString(settings->secrets_keytab));
+
+ result = PyEval_CallObjectWithKeywords(provision_fn, NULL, parameters);
+
+ Py_DECREF(parameters);
+
+ if (result == NULL) {
+ PyErr_Print();
+ PyErr_Clear();
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ DEBUG(0,("Open the SAM LDB with system credentials: %s\n",
+ settings->samdb_ldb));
+
+ ldb = ldb_wrap_connect(mem_ctx, lp_ctx, settings->samdb_ldb,
+ system_session(mem_ctx, lp_ctx),
+ NULL, 0, NULL);
+ if (!ldb) {
+ DEBUG(0,("Failed to open '%s'\n", settings->samdb_ldb));
+ return NT_STATUS_INTERNAL_DB_ERROR;
+ }
+
+ ok = samdb_set_ntds_invocation_id(ldb, settings->invocation_id);
+ if (!ok) {
+ DEBUG(0,("Failed to set cached ntds invocationId\n"));
+ return NT_STATUS_FOOBAR;
+ }
+ ok = samdb_set_ntds_objectGUID(ldb, settings->ntds_guid);
+ if (!ok) {
+ DEBUG(0,("Failed to set cached ntds objectGUID\n"));
+ return NT_STATUS_FOOBAR;
+ }
+
+ return NT_STATUS_OK;
+}
+
+NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
+ struct provision_settings *settings)
+{
+ if (getenv("PROVISION_EJS")) {
+ return provision_bare_ejs(mem_ctx, lp_ctx, settings);
+ } else {
+ return provision_bare_py(mem_ctx, lp_ctx, settings);
+ }
+}
+
+
diff --git a/source4/torture/util_smb.c b/source4/torture/util_smb.c
index de7303bac8..ddf7b85c63 100644
--- a/source4/torture/util_smb.c
+++ b/source4/torture/util_smb.c
@@ -863,3 +863,42 @@ _PUBLIC_ struct torture_test *torture_suite_add_1smb_test(
}
+NTSTATUS torture_second_tcon(TALLOC_CTX *mem_ctx,
+ struct smbcli_session *session,
+ const char *sharename,
+ struct smbcli_tree **res)
+{
+ union smb_tcon tcon;
+ struct smbcli_tree *result;
+ TALLOC_CTX *tmp_ctx;
+ NTSTATUS status;
+
+ if ((tmp_ctx = talloc_new(mem_ctx)) == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ result = smbcli_tree_init(session, tmp_ctx, false);
+ if (result == NULL) {
+ talloc_free(tmp_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ tcon.generic.level = RAW_TCON_TCONX;
+ tcon.tconx.in.flags = 0;
+
+ /* Ignore share mode security here */
+ tcon.tconx.in.password = data_blob(NULL, 0);
+ tcon.tconx.in.path = sharename;
+ tcon.tconx.in.device = "?????";
+
+ status = smb_raw_tcon(result, tmp_ctx, &tcon);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(tmp_ctx);
+ return status;
+ }
+
+ result->tid = tcon.tconx.out.tid;
+ *res = talloc_steal(mem_ctx, result);
+ talloc_free(tmp_ctx);
+ return NT_STATUS_OK;
+}
diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c
index 2c95e9033d..e0865c4416 100644
--- a/source4/utils/net/net.c
+++ b/source4/utils/net/net.c
@@ -182,8 +182,6 @@ static int binary_net(int argc, const char **argv)
dcerpc_init();
- ldb_global_init();
-
mem_ctx = talloc_init("net_context");
ctx = talloc(mem_ctx, struct net_context);
if (!ctx) {
diff --git a/source4/utils/tests/test_nmblookup.sh b/source4/utils/tests/test_nmblookup.sh
new file mode 100755
index 0000000000..ad9b3ba799
--- /dev/null
+++ b/source4/utils/tests/test_nmblookup.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Blackbox tests for nmblookup
+
+NETBIOSNAME=$1
+NETBIOSALIAS=$2
+SERVER=$3
+SERVER_IP=$4
+shift 4
+TORTURE_OPTIONS=$*
+
+failed=0
+
+testit() {
+ name="$1"
+ shift
+ cmdline="$*"
+ echo "test: $name"
+ $cmdline
+ status=$?
+ if [ x$status = x0 ]; then
+ echo "success: $name"
+ else
+ echo "failure: $name"
+ failed=`expr $failed + 1`
+ fi
+ return $status
+}
+
+testit "nmblookup -U \$SERVER_IP \$SERVER" bin/nmblookup $TORTURE_OPTIONS -U $SERVER_IP $SERVER
+testit "nmblookup -U \$SERVER_IP \$NETBIOSNAME" bin/nmblookup $TORTURE_OPTIONS -U $SERVER_IP $NETBIOSNAME
+testit "nmblookup -U \$SERVER_IP \$NETBIOSALIAS" bin/nmblookup $TORTURE_OPTIONS -U $SERVER_IP $NETBIOSALIAS
+testit "nmblookup \$SERVER" bin/nmblookup $TORTURE_OPTIONS $SERVER
+testit "nmblookup \$NETBIOSNAME" bin/nmblookup $TORTURE_OPTIONS $NETBIOSNAME
+testit "nmblookup \$NETBIOSALIAS" bin/nmblookup $TORTURE_OPTIONS $NETBIOSALIAS
+
+exit $failed