summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore7
-rw-r--r--howto.txt2
-rw-r--r--source4/Makefile32
-rw-r--r--source4/auth/auth.py2
-rw-r--r--source4/auth/auth_server.c377
-rw-r--r--source4/auth/auth_wrap.c65
-rw-r--r--source4/auth/config.mk102
-rw-r--r--source4/auth/credentials/config.mk21
-rw-r--r--source4/auth/credentials/credentials.c42
-rw-r--r--source4/auth/credentials/credentials.h25
-rw-r--r--source4/auth/credentials/credentials.i35
-rw-r--r--source4/auth/credentials/credentials.py94
-rw-r--r--source4/auth/credentials/credentials_files.c16
-rw-r--r--source4/auth/credentials/credentials_krb5.c35
-rw-r--r--source4/auth/credentials/credentials_krb5.h1
-rw-r--r--source4/auth/credentials/credentials_ntlm.c52
-rw-r--r--source4/auth/credentials/credentials_wrap.c242
-rw-r--r--source4/auth/credentials/tests/bindings.py2
-rw-r--r--source4/auth/gensec/config.mk45
-rw-r--r--source4/auth/gensec/gensec.c29
-rw-r--r--source4/auth/gensec/gensec_gssapi.c14
-rw-r--r--source4/auth/gensec/gensec_krb5.c16
-rw-r--r--source4/auth/gensec/schannel.c5
-rw-r--r--source4/auth/gensec/schannel_state.c11
-rw-r--r--source4/auth/kerberos/config.mk18
-rw-r--r--source4/auth/ntlm/auth.c (renamed from source4/auth/auth.c)9
-rw-r--r--source4/auth/ntlm/auth_anonymous.c (renamed from source4/auth/auth_anonymous.c)2
-rw-r--r--source4/auth/ntlm/auth_developer.c (renamed from source4/auth/auth_developer.c)2
-rw-r--r--source4/auth/ntlm/auth_proto.h50
-rw-r--r--source4/auth/ntlm/auth_sam.c (renamed from source4/auth/auth_sam.c)5
-rw-r--r--source4/auth/ntlm/auth_server.c225
-rw-r--r--source4/auth/ntlm/auth_simple.c (renamed from source4/auth/auth_simple.c)2
-rw-r--r--source4/auth/ntlm/auth_unix.c (renamed from source4/auth/auth_unix.c)4
-rw-r--r--source4/auth/ntlm/auth_util.c (renamed from source4/auth/auth_util.c)0
-rw-r--r--source4/auth/ntlm/auth_winbind.c (renamed from source4/auth/auth_winbind.c)2
-rw-r--r--source4/auth/ntlm/config.mk86
-rw-r--r--source4/auth/ntlm/ntlm_check.c (renamed from source4/auth/ntlm_check.c)1
-rw-r--r--source4/auth/ntlm/ntlm_check.h75
-rw-r--r--source4/auth/ntlm/pam_errors.c (renamed from source4/auth/pam_errors.c)0
-rw-r--r--source4/auth/ntlm/pam_errors.h47
-rw-r--r--source4/auth/ntlmssp/config.mk17
-rw-r--r--source4/auth/ntlmssp/ntlmssp.c2
-rw-r--r--source4/auth/ntlmssp/ntlmssp_server.c4
-rw-r--r--source4/auth/sam.c3
-rw-r--r--source4/auth/session.c8
-rw-r--r--source4/auth/session.h17
-rw-r--r--source4/auth/system_session.c7
-rw-r--r--source4/auth/tests/bindings.py2
-rw-r--r--source4/build/m4/check_ld.m434
-rw-r--r--source4/build/m4/public.m485
-rwxr-xr-xsource4/build/make/lex_compile.sh (renamed from source4/script/lex_compile.sh)0
-rw-r--r--source4/build/make/python.mk66
-rw-r--r--source4/build/make/rules.mk (renamed from source4/rules.mk)40
-rw-r--r--source4/build/make/templates.mk108
-rwxr-xr-xsource4/build/make/yacc_compile.sh (renamed from source4/script/yacc_compile.sh)0
-rw-r--r--source4/build/smb_build/config_mk.pm38
-rwxr-xr-xsource4/build/smb_build/dot.pl4
-rw-r--r--source4/build/smb_build/header.pm92
-rw-r--r--source4/build/smb_build/input.pm72
-rw-r--r--source4/build/smb_build/main.pl49
-rw-r--r--source4/build/smb_build/makefile.pm214
-rw-r--r--source4/build/smb_build/output.pm63
-rw-r--r--source4/build/tests/unixsock.c93
-rw-r--r--source4/cldap_server/cldap_server.c2
-rw-r--r--source4/cldap_server/config.mk14
-rw-r--r--source4/cldap_server/netlogon.c293
-rw-r--r--source4/client/cifsdd.c17
-rw-r--r--source4/client/cifsdd.h2
-rw-r--r--source4/client/cifsddio.c12
-rw-r--r--source4/client/client.c65
-rw-r--r--source4/client/config.mk8
-rw-r--r--source4/cluster/config.mk6
-rw-r--r--source4/cluster/ctdb/config.mk14
-rw-r--r--source4/cluster/ctdb/include/includes.h2
-rw-r--r--source4/configure.ac58
-rw-r--r--source4/dsdb/common/sidmap.c5
-rw-r--r--source4/dsdb/config.mk48
-rw-r--r--source4/dsdb/repl/drepl_service.c2
-rw-r--r--source4/dsdb/samdb/cracknames.c6
-rw-r--r--source4/dsdb/samdb/ldb_modules/config.mk182
-rw-r--r--source4/dsdb/samdb/ldb_modules/rootdse.c8
-rw-r--r--source4/dsdb/samdb/ldb_modules/samldb.c3
-rw-r--r--source4/dsdb/samdb/ldb_modules/update_keytab.c4
-rw-r--r--source4/dsdb/samdb/samdb.c20
-rw-r--r--source4/dsdb/samdb/samdb.h2
-rw-r--r--source4/dsdb/samdb/samdb_privilege.c5
-rw-r--r--source4/dynconfig.mk15
-rw-r--r--source4/headermap.txt5
-rwxr-xr-xsource4/heimdal_build/asn1_deps.pl7
-rw-r--r--source4/heimdal_build/config.mk801
-rw-r--r--source4/kdc/config.mk17
-rw-r--r--source4/kdc/hdb-ldb.c6
-rw-r--r--source4/kdc/kdc.c2
-rw-r--r--source4/kdc/kpasswdd.c6
-rw-r--r--source4/ldap_server/config.mk16
-rw-r--r--source4/ldap_server/ldap_backend.c2
-rw-r--r--source4/ldap_server/ldap_bind.c2
-rw-r--r--source4/ldap_server/ldap_server.c5
-rw-r--r--source4/lib/appweb/config.mk16
-rw-r--r--source4/lib/appweb/mpr/miniMpr.c6
-rw-r--r--source4/lib/appweb/mpr/miniMpr.h2
-rw-r--r--source4/lib/basic.mk37
-rw-r--r--source4/lib/charset/config.mk10
-rw-r--r--source4/lib/cmdline/config.mk17
-rw-r--r--source4/lib/crypto/config.mk25
-rw-r--r--source4/lib/crypto/sha1test.c2
-rw-r--r--source4/lib/dbwrap/config.mk6
-rw-r--r--source4/lib/events/Makefile.in66
-rwxr-xr-xsource4/lib/events/autogen.sh17
-rw-r--r--source4/lib/events/config.mk37
-rw-r--r--source4/lib/events/configure.ac35
-rw-r--r--source4/lib/events/events.c19
-rw-r--r--source4/lib/events/events.i7
-rw-r--r--source4/lib/events/events.mk59
-rw-r--r--source4/lib/events/events.pc.in11
-rw-r--r--source4/lib/events/events.py21
-rw-r--r--source4/lib/events/events_epoll.c15
-rw-r--r--source4/lib/events/events_select.c13
-rw-r--r--source4/lib/events/events_signal.c13
-rw-r--r--source4/lib/events/events_standard.c11
-rw-r--r--source4/lib/events/events_timed.c11
-rw-r--r--source4/lib/events/events_util.c129
-rw-r--r--source4/lib/events/events_util.h123
-rw-r--r--source4/lib/events/events_wrap.c77
-rw-r--r--source4/lib/events/libevents.m421
-rw-r--r--source4/lib/events/tests.py2
-rw-r--r--source4/lib/ldb-samba/config.mk5
-rw-r--r--source4/lib/ldb/common/ldb_modules.c13
-rw-r--r--source4/lib/ldb/config.mk108
-rw-r--r--source4/lib/ldb/include/ldb_private.h6
-rw-r--r--source4/lib/ldb/ldb.i185
-rw-r--r--source4/lib/ldb/ldb.mk2
-rw-r--r--source4/lib/ldb/ldb.py276
-rw-r--r--source4/lib/ldb/ldb_ildap/config.mk3
-rw-r--r--source4/lib/ldb/ldb_ildap/ldb_ildap.c16
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_index.c4
-rw-r--r--source4/lib/ldb/ldb_wrap.c519
-rw-r--r--source4/lib/ldb/python.mk8
-rwxr-xr-xsource4/lib/ldb/tests/python/api.py42
-rwxr-xr-xsource4/lib/ldb/tests/python/ldap.py6
-rw-r--r--source4/lib/ldb/tools/ad2oLschema.c4
-rw-r--r--source4/lib/ldb/tools/config.mk28
-rw-r--r--source4/lib/ldb_wrap.c11
-rw-r--r--source4/lib/ldb_wrap.h2
-rw-r--r--source4/lib/messaging/config.mk4
-rw-r--r--source4/lib/messaging/messaging.c14
-rw-r--r--source4/lib/messaging/tests/messaging.c1
-rw-r--r--source4/lib/nss_wrapper/config.mk3
-rw-r--r--source4/lib/policy/adm.h47
-rw-r--r--source4/lib/policy/config.mk12
-rw-r--r--source4/lib/policy/dumpadm.c54
-rw-r--r--source4/lib/policy/lex.c2085
-rw-r--r--source4/lib/policy/lex.l142
-rw-r--r--source4/lib/policy/parse_adm.c1726
-rw-r--r--source4/lib/policy/parse_adm.h135
-rw-r--r--source4/lib/policy/parse_adm.y138
-rw-r--r--source4/lib/popt/config.mk8
-rw-r--r--source4/lib/registry/config.mk85
-rw-r--r--source4/lib/registry/hive.c21
-rw-r--r--source4/lib/registry/interface.c26
-rw-r--r--source4/lib/registry/ldb.c3
-rw-r--r--source4/lib/registry/local.c26
-rw-r--r--source4/lib/registry/patchfile.c27
-rw-r--r--source4/lib/registry/patchfile_dotreg.c10
-rw-r--r--source4/lib/registry/patchfile_preg.c97
-rw-r--r--source4/lib/registry/regf.c64
-rw-r--r--source4/lib/registry/registry.h34
-rw-r--r--source4/lib/registry/registry.i33
-rw-r--r--source4/lib/registry/registry.py63
-rw-r--r--source4/lib/registry/registry_wrap.c307
-rw-r--r--source4/lib/registry/samba.c16
-rw-r--r--source4/lib/registry/tests/bindings.py2
-rw-r--r--source4/lib/registry/tests/diff.c242
-rw-r--r--source4/lib/registry/tests/hive.c94
-rw-r--r--source4/lib/registry/tests/registry.c46
-rw-r--r--source4/lib/registry/tools/common.c11
-rw-r--r--source4/lib/registry/tools/regdiff.c12
-rw-r--r--source4/lib/registry/tools/regpatch.c6
-rw-r--r--source4/lib/registry/tools/regshell.c7
-rw-r--r--source4/lib/registry/tools/regtree.c7
-rw-r--r--source4/lib/replace/README2
-rw-r--r--source4/lib/replace/configure.ac1
-rw-r--r--source4/lib/replace/getaddrinfo.m432
-rw-r--r--source4/lib/replace/getifaddrs.m4128
-rw-r--r--source4/lib/replace/inet_aton.m41
-rw-r--r--source4/lib/replace/inet_ntoa.m419
-rw-r--r--source4/lib/replace/inet_ntop.m41
-rw-r--r--source4/lib/replace/inet_pton.m41
-rw-r--r--source4/lib/replace/libreplace.m465
-rw-r--r--source4/lib/replace/libreplace_cc.m43
-rw-r--r--source4/lib/replace/libreplace_ld.m43
-rw-r--r--source4/lib/replace/libreplace_network.m4377
-rw-r--r--source4/lib/replace/replace.c29
-rw-r--r--source4/lib/replace/replace.h12
-rw-r--r--source4/lib/replace/samba.m41
-rw-r--r--source4/lib/replace/socket.m439
-rw-r--r--source4/lib/replace/socketpair.m41
-rw-r--r--source4/lib/replace/system/config.m41
-rw-r--r--source4/lib/replace/system/network.h4
-rw-r--r--source4/lib/replace/system/time.h15
-rw-r--r--source4/lib/replace/test/testsuite.c145
-rw-r--r--source4/lib/samba3/config.mk6
-rw-r--r--source4/lib/socket/config.m454
-rw-r--r--source4/lib/socket/config.mk24
-rw-r--r--source4/lib/socket/testsuite.c8
-rw-r--r--source4/lib/socket_wrapper/config.mk3
-rw-r--r--source4/lib/stream/config.mk8
-rw-r--r--source4/lib/talloc/config.mk5
-rw-r--r--source4/lib/talloc/testsuite.c3
-rw-r--r--source4/lib/tdb/common/traverse.c22
-rw-r--r--source4/lib/tdb/config.mk25
-rw-r--r--source4/lib/tdb/configure.ac2
-rw-r--r--source4/lib/tdb/python.mk9
-rw-r--r--source4/lib/tdb/python/tests/simple.py7
-rw-r--r--source4/lib/tdb/tdb.i47
-rw-r--r--source4/lib/tdb/tdb.mk4
-rw-r--r--source4/lib/tdb/tdb.py186
-rw-r--r--source4/lib/tdb/tdb_wrap.c283
-rw-r--r--source4/lib/tdr/config.mk8
-rw-r--r--source4/lib/tls/config.mk10
-rw-r--r--source4/lib/torture/config.mk14
-rw-r--r--source4/lib/torture/torture.c (renamed from source4/torture/ui.c)12
-rw-r--r--source4/lib/torture/torture.h (renamed from source4/torture/ui.h)11
-rw-r--r--source4/lib/torture/torture.pc.in (renamed from source4/torture/torture.pc.in)0
-rw-r--r--source4/lib/util/config.mk45
-rw-r--r--source4/lib/util/tests/file.c4
-rw-r--r--source4/lib/util/tests/str.c2
-rw-r--r--source4/lib/util/time.c2
-rw-r--r--source4/lib/util/time.h2
-rw-r--r--source4/lib/util/util.h2
-rw-r--r--source4/libcli/auth/config.mk13
-rw-r--r--source4/libcli/cldap/cldap.c44
-rw-r--r--source4/libcli/cldap/cldap.h7
-rw-r--r--source4/libcli/cliconnect.c5
-rw-r--r--source4/libcli/clifile.c11
-rw-r--r--source4/libcli/composite/composite.c25
-rw-r--r--source4/libcli/composite/composite.h1
-rw-r--r--source4/libcli/config.mk200
-rw-r--r--source4/libcli/dgram/dgramsocket.c6
-rw-r--r--source4/libcli/dgram/libdgram.h34
-rw-r--r--source4/libcli/dgram/netlogon.c45
-rw-r--r--source4/libcli/dgram/ntlogon.c128
-rw-r--r--source4/libcli/ldap/config.mk19
-rw-r--r--source4/libcli/ldap/ldap_bind.c5
-rw-r--r--source4/libcli/ldap/ldap_client.c12
-rw-r--r--source4/libcli/ldap/ldap_ndr.h2
-rw-r--r--source4/libcli/nbt/libnbt.h2
-rw-r--r--source4/libcli/nbt/nbtsocket.c6
-rw-r--r--source4/libcli/ndr_netlogon.c209
-rw-r--r--source4/libcli/netlogon.c239
-rw-r--r--source4/libcli/netlogon.h54
-rw-r--r--source4/libcli/raw/clisocket.c22
-rw-r--r--source4/libcli/raw/clitree.c5
-rw-r--r--source4/libcli/raw/interfaces.h87
-rw-r--r--source4/libcli/raw/raweas.c9
-rw-r--r--source4/libcli/raw/rawfile.c4
-rw-r--r--source4/libcli/raw/rawfileinfo.c3
-rw-r--r--source4/libcli/raw/rawrequest.c6
-rw-r--r--source4/libcli/raw/rawtrans.c6
-rw-r--r--source4/libcli/raw/smb.h1
-rw-r--r--source4/libcli/resolve/host.c1
-rw-r--r--source4/libcli/resolve/nbtlist.c3
-rw-r--r--source4/libcli/resolve/resolve.c16
-rw-r--r--source4/libcli/security/config.mk21
-rw-r--r--source4/libcli/security/security.py2
-rw-r--r--source4/libcli/security/security_wrap.c65
-rw-r--r--source4/libcli/security/tests/bindings.py2
-rw-r--r--source4/libcli/smb2/break.c74
-rw-r--r--source4/libcli/smb2/config.mk31
-rw-r--r--source4/libcli/smb2/connect.c18
-rw-r--r--source4/libcli/smb2/create.c98
-rw-r--r--source4/libcli/smb2/find.c2
-rw-r--r--source4/libcli/smb2/flush.c6
-rw-r--r--source4/libcli/smb2/lock.c24
-rw-r--r--source4/libcli/smb2/read.c13
-rw-r--r--source4/libcli/smb2/request.c33
-rw-r--r--source4/libcli/smb2/session.c4
-rw-r--r--source4/libcli/smb2/smb2.h20
-rw-r--r--source4/libcli/smb2/transport.c43
-rw-r--r--source4/libcli/smb2/util.c200
-rw-r--r--source4/libcli/smb_composite/connect.c89
-rw-r--r--source4/libcli/smb_composite/fetchfile.c2
-rw-r--r--source4/libcli/smb_composite/fsinfo.c2
-rw-r--r--source4/libcli/smb_composite/sesssetup.c2
-rw-r--r--source4/libcli/smb_composite/smb2.c371
-rw-r--r--source4/libcli/smb_composite/smb_composite.h5
-rw-r--r--source4/libcli/swig/libcli_nbt.py2
-rw-r--r--source4/libcli/swig/libcli_nbt_wrap.c73
-rw-r--r--source4/libcli/swig/libcli_smb.py2
-rw-r--r--source4/libcli/swig/libcli_smb_wrap.c65
-rw-r--r--source4/libcli/wbclient/config.mk3
-rw-r--r--source4/libcli/wrepl/winsrepl.c6
-rw-r--r--source4/libnet/config.mk44
-rw-r--r--source4/libnet/libnet.c13
-rw-r--r--source4/libnet/libnet.h1
-rw-r--r--source4/libnet/libnet_become_dc.c26
-rw-r--r--source4/libnet/libnet_join.c198
-rw-r--r--source4/libnet/libnet_join.h17
-rw-r--r--source4/libnet/libnet_samdump_keytab.c7
-rw-r--r--source4/libnet/libnet_samsync.c399
-rw-r--r--source4/libnet/libnet_samsync.h84
-rw-r--r--source4/libnet/libnet_samsync_ldb.c2
-rw-r--r--source4/libnet/libnet_site.c15
-rw-r--r--source4/libnet/libnet_unbecome_dc.c23
-rw-r--r--source4/libnet/libnet_user.c97
-rw-r--r--source4/libnet/libnet_user.h11
-rw-r--r--source4/libnet/libnet_vampire.c945
-rw-r--r--source4/libnet/libnet_vampire.h70
-rw-r--r--source4/libnet/net.i73
-rw-r--r--source4/libnet/net.py103
-rw-r--r--source4/libnet/net_wrap.c4711
-rw-r--r--source4/libnet/py_net.c85
-rw-r--r--source4/librpc/config.mk612
-rwxr-xr-xsource4/librpc/idl-deps.pl22
-rw-r--r--source4/librpc/idl/audiosrv.idl30
-rw-r--r--source4/librpc/idl/browser.idl24
-rw-r--r--source4/librpc/idl/dcerpc.idl1
-rw-r--r--source4/librpc/idl/dfs.idl14
-rw-r--r--source4/librpc/idl/drsuapi.idl24
-rw-r--r--source4/librpc/idl/dsbackup.idl34
-rw-r--r--source4/librpc/idl/dssetup.idl20
-rw-r--r--source4/librpc/idl/efs.idl14
-rw-r--r--source4/librpc/idl/epmapper.idl2
-rw-r--r--source4/librpc/idl/eventlog.idl36
-rw-r--r--source4/librpc/idl/frsapi.idl12
-rw-r--r--source4/librpc/idl/frsrpc.idl20
-rw-r--r--source4/librpc/idl/lsa.idl66
-rw-r--r--source4/librpc/idl/msgsvc.idl10
-rw-r--r--source4/librpc/idl/nbt.idl342
-rw-r--r--source4/librpc/idl/netlogon.idl14
-rw-r--r--source4/librpc/idl/ntsvcs.idl130
-rw-r--r--source4/librpc/idl/policyagent.idl2
-rw-r--r--source4/librpc/idl/security.idl3
-rw-r--r--source4/librpc/idl/spoolss.idl102
-rw-r--r--source4/librpc/idl/srvsvc.idl24
-rw-r--r--source4/librpc/idl/svcctl.idl14
-rw-r--r--source4/librpc/idl/w32time.idl6
-rw-r--r--source4/librpc/idl/winreg.idl8
-rw-r--r--source4/librpc/idl/xattr.idl12
-rw-r--r--source4/librpc/ndr/libndr.h4
-rw-r--r--source4/librpc/ndr/ndr_basic.c4
-rw-r--r--source4/librpc/ndr/ndr_sec_helper.c51
-rw-r--r--source4/librpc/rpc/binding.c724
-rw-r--r--source4/librpc/rpc/dcerpc.c15
-rw-r--r--source4/librpc/rpc/dcerpc.py4
-rw-r--r--source4/librpc/rpc/dcerpc_connect.c15
-rw-r--r--source4/librpc/rpc/dcerpc_smb2.c16
-rw-r--r--source4/librpc/rpc/dcerpc_util.c710
-rw-r--r--source4/librpc/rpc/dcerpc_wrap.c65
-rwxr-xr-xsource4/librpc/scripts/build_idl.sh (renamed from source4/script/build_idl.sh)16
-rw-r--r--source4/main.mk64
-rw-r--r--source4/nbt_server/config.mk58
-rw-r--r--source4/nbt_server/dgram/netlogon.c149
-rw-r--r--source4/nbt_server/dgram/request.c4
-rw-r--r--source4/nbt_server/irpc.c83
-rw-r--r--source4/nbt_server/nbt_server.c2
-rw-r--r--source4/nbt_server/wins/winsdb.c13
-rw-r--r--source4/nbt_server/wins/winsserver.c3
-rw-r--r--source4/nsswitch/config.m43
-rw-r--r--source4/nsswitch/config.mk12
-rw-r--r--source4/ntptr/config.mk14
-rw-r--r--source4/ntptr/ntptr.h1
-rw-r--r--source4/ntptr/ntptr_base.c6
-rw-r--r--source4/ntptr/simple_ldb/ntptr_simple_ldb.c6
-rw-r--r--source4/ntvfs/cifs/vfs_cifs.c2
-rw-r--r--source4/ntvfs/common/config.mk18
-rw-r--r--source4/ntvfs/common/notify.c4
-rw-r--r--source4/ntvfs/config.mk64
-rw-r--r--source4/ntvfs/ipc/ipc_rap.c11
-rw-r--r--source4/ntvfs/ipc/rap_server.c3
-rw-r--r--source4/ntvfs/ipc/vfs_ipc.c2
-rw-r--r--source4/ntvfs/ntvfs_base.c12
-rw-r--r--source4/ntvfs/ntvfs_generic.c114
-rw-r--r--source4/ntvfs/posix/config.mk29
-rw-r--r--source4/ntvfs/posix/pvfs_acl.c2
-rw-r--r--source4/ntvfs/posix/pvfs_fileinfo.c7
-rw-r--r--source4/ntvfs/posix/pvfs_open.c44
-rw-r--r--source4/ntvfs/posix/pvfs_qfileinfo.c9
-rw-r--r--source4/ntvfs/posix/pvfs_resolve.c8
-rw-r--r--source4/ntvfs/posix/pvfs_setfileinfo.c2
-rw-r--r--source4/ntvfs/posix/pvfs_streams.c7
-rw-r--r--source4/ntvfs/posix/pvfs_xattr.c32
-rw-r--r--source4/ntvfs/posix/vfs_posix.c2
-rw-r--r--source4/ntvfs/posix/vfs_posix.h3
-rw-r--r--source4/ntvfs/smb2/vfs_smb2.c844
-rw-r--r--source4/ntvfs/sysdep/config.mk29
-rw-r--r--source4/ntvfs/sysdep/sys_lease.c8
-rw-r--r--source4/ntvfs/sysdep/sys_notify.c4
-rw-r--r--source4/ntvfs/unixuid/config.mk4
-rw-r--r--source4/param/config.mk44
-rw-r--r--source4/param/param.i35
-rw-r--r--source4/param/param.py76
-rw-r--r--source4/param/param_wrap.c126
-rw-r--r--source4/param/provision.c (renamed from source4/torture/util_provision.c)33
-rw-r--r--source4/param/provision.h51
-rw-r--r--source4/param/share.c6
-rw-r--r--source4/param/share.h5
-rw-r--r--source4/param/share_classic.c1
-rw-r--r--source4/param/share_ldb.c6
-rw-r--r--source4/param/tests/bindings.py2
-rw-r--r--source4/param/tests/share.c4
-rw-r--r--source4/pidl/TODO15
-rw-r--r--source4/pidl/config.mk44
-rw-r--r--source4/pidl/lib/Parse/Pidl/NDR.pm1
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm65
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm54
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm37
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/Python.pm362
-rwxr-xr-xsource4/pidl/tests/samba-ndr.pl16
-rwxr-xr-xsource4/pidl/tests/samba3-cli.pl13
-rw-r--r--source4/rpc_server/common/server_info.c4
-rw-r--r--source4/rpc_server/config.mk120
-rw-r--r--source4/rpc_server/dcerpc_server.c13
-rw-r--r--source4/rpc_server/drsuapi/dcesrv_drsuapi.c2
-rw-r--r--source4/rpc_server/lsa/lsa_init.c2
-rw-r--r--source4/rpc_server/lsa/lsa_lookup.c15
-rw-r--r--source4/rpc_server/netlogon/dcerpc_netlogon.c29
-rw-r--r--source4/rpc_server/samr/dcesrv_samr.c4
-rw-r--r--source4/rpc_server/samr/samr_password.c6
-rw-r--r--source4/rpc_server/service_rpc.c17
-rw-r--r--source4/rpc_server/spoolss/dcesrv_spoolss.c5
-rw-r--r--source4/rpc_server/srvsvc/dcesrv_srvsvc.c20
-rw-r--r--source4/rpc_server/srvsvc/srvsvc_ntvfs.c2
-rw-r--r--source4/rpc_server/winreg/rpc_winreg.c2
-rw-r--r--source4/samba4-knownfail11
-rw-r--r--source4/samba4-skip15
-rwxr-xr-xsource4/script/harness2subunit.pl6
-rwxr-xr-xsource4/script/installheader.pl2
-rwxr-xr-xsource4/scripting/bin/minschema.py6
-rwxr-xr-xsource4/scripting/bin/rpcclient4
-rwxr-xr-xsource4/scripting/bin/samba3dump5
-rwxr-xr-xsource4/scripting/bin/samr.py114
-rwxr-xr-xsource4/scripting/bin/subunitrun27
-rwxr-xr-xsource4/scripting/bin/winreg.py4
-rw-r--r--source4/scripting/ejs/config.mk65
-rw-r--r--source4/scripting/ejs/ejsnet/config.mk14
-rw-r--r--source4/scripting/ejs/ejsnet/net_ctx.c2
-rw-r--r--source4/scripting/ejs/ejsnet/net_user.c5
-rw-r--r--source4/scripting/ejs/smbcalls.c27
-rw-r--r--source4/scripting/ejs/smbcalls_auth.c4
-rw-r--r--source4/scripting/ejs/smbcalls_ldb.c2
-rw-r--r--source4/scripting/ejs/smbcalls_nbt.c2
-rw-r--r--source4/scripting/ejs/smbcalls_reg.c2
-rw-r--r--source4/scripting/ejs/smbcalls_rpc.c4
-rw-r--r--source4/scripting/libjs/provision.js1254
-rw-r--r--source4/scripting/libjs/samr.js170
-rw-r--r--source4/scripting/libjs/winreg.js291
-rw-r--r--source4/scripting/python/config.m48
-rw-r--r--source4/scripting/python/config.mk52
-rw-r--r--source4/scripting/python/misc.i20
-rw-r--r--source4/scripting/python/misc.py51
-rw-r--r--source4/scripting/python/misc_wrap.c142
-rw-r--r--source4/scripting/python/modules.c7
-rw-r--r--source4/scripting/python/pyrpc.h7
-rw-r--r--source4/scripting/python/pytalloc.c13
-rw-r--r--source4/scripting/python/samba/__init__.py10
-rw-r--r--source4/scripting/python/samba/getopt.py25
-rw-r--r--source4/scripting/python/samba/idmap.py9
-rw-r--r--source4/scripting/python/samba/provision.py263
-rw-r--r--source4/scripting/python/samba/samba3.py5
-rw-r--r--source4/scripting/python/samba/samdb.py30
-rw-r--r--source4/scripting/python/samba/tests/__init__.py15
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/registry.py11
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/rpcecho.py11
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/sam.py29
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/unix.py37
-rw-r--r--source4/scripting/python/samba/tests/provision.py4
-rw-r--r--source4/scripting/python/samba/tests/samdb.py12
-rw-r--r--source4/scripting/python/samba/upgrade.py2
-rw-r--r--source4/scripting/python/smbpython.c34
-rw-r--r--source4/scripting/python/uuidmodule.c6
-rw-r--r--source4/selftest/README81
-rw-r--r--source4/selftest/Subunit.pm15
-rw-r--r--source4/selftest/output/plain.pm7
-rwxr-xr-xsource4/selftest/samba4_tests.sh27
-rwxr-xr-xsource4/selftest/selftest.pl34
-rw-r--r--source4/selftest/target/Samba4.pm15
-rwxr-xr-x[-rw-r--r--]source4/setup/enableaccount8
-rw-r--r--source4/setup/idmap_init.ldif5
-rw-r--r--source4/setup/krb5.conf17
-rw-r--r--source4/setup/named.conf121
-rwxr-xr-xsource4/setup/newuser18
-rwxr-xr-xsource4/setup/provision9
-rwxr-xr-xsource4/setup/provision-backend24
-rw-r--r--source4/setup/provision-backend.js188
-rw-r--r--source4/setup/provision.ldif4
-rw-r--r--source4/setup/provision_basedn_modify.ldif4
-rw-r--r--source4/setup/provision_configuration.ldif2
-rw-r--r--source4/setup/provision_rootdse_add.ldif5
-rw-r--r--source4/setup/provision_schema_basedn_modify.ldif2
-rw-r--r--source4/setup/provision_self_join.ldif4
-rw-r--r--source4/setup/secrets_dc.ldif1
-rw-r--r--source4/setup/setpassword15
-rwxr-xr-xsource4/setup/tests/blackbox_newuser.sh21
-rwxr-xr-xsource4/setup/tests/blackbox_provision.sh18
-rwxr-xr-xsource4/setup/tests/blackbox_setpassword.sh22
-rwxr-xr-xsource4/setup/upgrade (renamed from source4/setup/upgrade.py)8
-rwxr-xr-xsource4/setup/vampire.py53
-rw-r--r--source4/smb_server/blob.c7
-rw-r--r--source4/smb_server/config.mk24
-rw-r--r--source4/smb_server/smb/config.mk16
-rw-r--r--source4/smb_server/smb/receive.c230
-rw-r--r--source4/smb_server/smb/request.c6
-rw-r--r--source4/smb_server/smb/sesssetup.c5
-rw-r--r--source4/smb_server/smb2/config.mk16
-rw-r--r--source4/smb_server/smb2/fileio.c79
-rw-r--r--source4/smb_server/smb2/find.c4
-rw-r--r--source4/smb_server/smb2/negprot.c9
-rw-r--r--source4/smb_server/smb2/smb2_server.h6
-rw-r--r--source4/smb_server/smb_server.c3
-rw-r--r--source4/smbd/config.mk32
-rw-r--r--source4/smbd/process_model.c4
-rw-r--r--source4/smbd/process_model.mk23
-rw-r--r--source4/smbd/server.c15
-rw-r--r--source4/smbd/service_stream.c2
-rw-r--r--source4/smbd/service_stream.h6
-rw-r--r--source4/static_deps.mk8
-rw-r--r--source4/torture/auth/ntlmssp.c10
-rw-r--r--source4/torture/basic/base.c7
-rw-r--r--source4/torture/basic/delaywrite.c278
-rw-r--r--source4/torture/basic/locking.c3
-rw-r--r--source4/torture/basic/misc.c2
-rw-r--r--source4/torture/config.mk402
-rw-r--r--source4/torture/gentest.c47
-rw-r--r--source4/torture/gentest_smb2.c1907
-rw-r--r--source4/torture/ldap/cldap.c105
-rw-r--r--source4/torture/ldap/cldapbench.c6
-rw-r--r--source4/torture/ldap/common.c4
-rw-r--r--source4/torture/ldap/schema.c2
-rw-r--r--source4/torture/ldap/uptodatevector.c2
-rw-r--r--source4/torture/libnet/domain.c4
-rw-r--r--source4/torture/libnet/libnet.c2
-rw-r--r--source4/torture/libnet/libnet_BecomeDC.c48
-rw-r--r--source4/torture/libnet/libnet_domain.c15
-rw-r--r--source4/torture/libnet/libnet_group.c6
-rw-r--r--source4/torture/libnet/libnet_lookup.c8
-rw-r--r--source4/torture/libnet/libnet_rpc.c2
-rw-r--r--source4/torture/libnet/libnet_share.c4
-rw-r--r--source4/torture/libnet/libnet_user.c16
-rw-r--r--source4/torture/local/config.mk66
-rw-r--r--source4/torture/local/dbspeed.c4
-rw-r--r--source4/torture/local/local.c2
-rw-r--r--source4/torture/local/torture.c41
-rw-r--r--source4/torture/locktest.c26
-rw-r--r--source4/torture/locktest2.c26
-rw-r--r--source4/torture/masktest.c9
-rw-r--r--source4/torture/nbench/nbench.c3
-rw-r--r--source4/torture/nbt/browse.c2
-rw-r--r--source4/torture/nbt/dgram.c416
-rw-r--r--source4/torture/nbt/nbt.c4
-rw-r--r--source4/torture/nbt/query.c2
-rw-r--r--source4/torture/nbt/register.c4
-rw-r--r--source4/torture/nbt/wins.c2
-rw-r--r--source4/torture/nbt/winsbench.c2
-rw-r--r--source4/torture/nbt/winsreplication.c18
-rw-r--r--source4/torture/ndr/ndr.c2
-rw-r--r--source4/torture/ndr/netlogon.c12
-rw-r--r--source4/torture/rap/rap.c2
-rw-r--r--source4/torture/raw/composite.c4
-rw-r--r--source4/torture/raw/lockbench.c9
-rw-r--r--source4/torture/raw/lookuprate.c320
-rw-r--r--source4/torture/raw/offline.c13
-rw-r--r--source4/torture/raw/open.c10
-rw-r--r--source4/torture/raw/openbench.c9
-rw-r--r--source4/torture/raw/oplock.c3
-rw-r--r--source4/torture/raw/raw.c8
-rw-r--r--source4/torture/raw/samba3hide.c2
-rw-r--r--source4/torture/raw/samba3misc.c2
-rw-r--r--source4/torture/raw/streams.c95
-rw-r--r--source4/torture/raw/tconrate.c201
-rw-r--r--source4/torture/rpc/async_bind.c7
-rw-r--r--source4/torture/rpc/dfs.c8
-rw-r--r--source4/torture/rpc/dssync.c17
-rw-r--r--source4/torture/rpc/join.c4
-rw-r--r--source4/torture/rpc/rpc.c11
-rw-r--r--source4/torture/rpc/rpc.h2
-rw-r--r--source4/torture/rpc/samba3rpc.c26
-rw-r--r--source4/torture/rpc/samlogon.c2
-rw-r--r--source4/torture/rpc/samsync.c4
-rw-r--r--source4/torture/rpc/schannel.c365
-rw-r--r--source4/torture/rpc/session_key.c6
-rw-r--r--source4/torture/rpc/spoolss_notify.c1
-rw-r--r--source4/torture/rpc/spoolss_win.c1
-rw-r--r--source4/torture/rpc/testjoin.c18
-rw-r--r--source4/torture/smb2/config.mk22
-rw-r--r--source4/torture/smb2/getinfo.c12
-rw-r--r--source4/torture/smb2/lock.c162
-rw-r--r--source4/torture/smb2/oplocks.c178
-rw-r--r--source4/torture/smb2/persistent_handles.c184
-rw-r--r--source4/torture/smb2/scan.c4
-rw-r--r--source4/torture/smb2/smb2.c65
-rw-r--r--source4/torture/smb2/util.c44
-rw-r--r--source4/torture/smbtorture.c34
-rw-r--r--source4/torture/smbtorture.h (renamed from source4/torture/torture.h)9
-rw-r--r--source4/torture/torture.c15
-rw-r--r--source4/torture/unix/unix.c2
-rw-r--r--source4/torture/unix/unix_info2.c4
-rw-r--r--source4/torture/unix/whoami.c2
-rw-r--r--source4/torture/util.h23
-rw-r--r--source4/torture/util_smb.c4
-rw-r--r--source4/torture/winbind/config.mk12
-rw-r--r--source4/torture/winbind/struct_based.c28
-rw-r--r--source4/torture/winbind/winbind.c2
-rw-r--r--source4/utils/config.mk29
-rw-r--r--source4/utils/net/config.mk21
-rw-r--r--source4/utils/net/net.c21
-rw-r--r--source4/utils/net/net.h2
-rw-r--r--source4/utils/net/net_join.c78
-rw-r--r--source4/utils/net/net_password.c19
-rw-r--r--source4/utils/net/net_time.c5
-rw-r--r--source4/utils/net/net_user.c13
-rw-r--r--source4/utils/net/net_vampire.c13
-rw-r--r--source4/utils/nmblookup.c14
-rw-r--r--source4/utils/ntlm_auth.c11
-rw-r--r--source4/web_server/config.mk10
-rw-r--r--source4/winbind/config.mk47
-rw-r--r--source4/winbind/idmap.c7
-rw-r--r--source4/winbind/idmap.h2
-rw-r--r--source4/winbind/wb_async_helpers.c67
-rw-r--r--source4/winbind/wb_cmd_getpwnam.c3
-rw-r--r--source4/winbind/wb_cmd_getpwuid.c9
-rw-r--r--source4/winbind/wb_cmd_list_trustdom.c3
-rw-r--r--source4/winbind/wb_connect_lsa.c11
-rw-r--r--source4/winbind/wb_init_domain.c3
-rw-r--r--source4/winbind/wb_pam_auth.c19
-rw-r--r--source4/winbind/wb_samba3_cmd.c92
-rw-r--r--source4/winbind/wb_samba3_protocol.c3
-rw-r--r--source4/winbind/wb_server.c2
-rw-r--r--source4/winbind/wb_sids2xids.c10
-rw-r--r--source4/winbind/wb_xids2sids.c10
-rw-r--r--source4/wrepl_server/config.mk18
-rw-r--r--source4/wrepl_server/wrepl_in_connection.c2
-rw-r--r--source4/wrepl_server/wrepl_server.c7
-rw-r--r--testdata/samba3/provision_samba3sam_templates.ldif5
-rw-r--r--testprogs/blackbox/ndrdump/samr-CreateUser-in.datbin0 -> 60 bytes
-rw-r--r--testprogs/blackbox/ndrdump/samr-CreateUser-out.datbin0 -> 32 bytes
-rwxr-xr-xtestprogs/blackbox/subunit.sh67
-rwxr-xr-xtestprogs/blackbox/test_cifsdd.sh24
-rwxr-xr-xtestprogs/blackbox/test_gentest.sh15
-rwxr-xr-xtestprogs/blackbox/test_kinit.sh26
-rwxr-xr-xtestprogs/blackbox/test_ldb.sh2
-rwxr-xr-xtestprogs/blackbox/test_locktest.sh15
-rwxr-xr-xtestprogs/blackbox/test_masktest.sh15
-rwxr-xr-xtestprogs/blackbox/test_ndrdump.sh20
-rwxr-xr-xtestprogs/blackbox/test_smbclient.sh43
-rwxr-xr-xtestprogs/blackbox/test_wbinfo.sh187
-rwxr-xr-xtestprogs/ejs/echo.js235
-rw-r--r--testprogs/ejs/loadparm.js25
-rw-r--r--testprogs/ejs/resolveName.js13
-rwxr-xr-xtestprogs/ejs/samr.js126
650 files changed, 19982 insertions, 20321 deletions
diff --git a/.gitignore b/.gitignore
index 1ad2e2501f..1e574f0059 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,7 +22,6 @@ source/heimdal/lib/des/hcrypto
source/build/smb_build/config.pm
source/auth/auth_proto.h
source/auth/auth_sam.h
-source/auth/pam_errors.h
source/auth/credentials/credentials_proto.h
source/auth/gensec/gensec_proto.h
source/auth/gensec/schannel_proto.h
@@ -195,3 +194,9 @@ source/apidocs
source/mkconfig.mk
source/data.mk
source/librpc/idl-deps
+source/libcli/netlogon_proto.h
+source/libcli/ndr_netlogon_proto.h
+source/foo.tdb
+source/gentest_seeds.dat
+source/templates.ldb
+source/torture.tdb
diff --git a/howto.txt b/howto.txt
index d128baa5bd..ae9b0e2848 100644
--- a/howto.txt
+++ b/howto.txt
@@ -27,7 +27,7 @@ There are 2 methods of doing this:
method 1: "rsync -avz samba.org::ftp/unpacked/samba_4_0_test/ samba4"
- method 2: "git clone git://git.samba.org/samba.git samba4; cd samba4; git checkout v4-0-test; cd .."
+ method 2: "git clone git://git.samba.org/samba.git samba4; cd samba4 && git checkout -b v4-0-test origin/v4-0-test; cd .."
both methods will create a directory called "samba4" in the current
directory. If you don't have rsync or git then install one of them.
diff --git a/source4/Makefile b/source4/Makefile
index ab3ef47fed..0ee36ec830 100644
--- a/source4/Makefile
+++ b/source4/Makefile
@@ -4,6 +4,8 @@
include mkconfig.mk
+pidldir := $(srcdir)/pidl
+
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)
@@ -19,16 +21,40 @@ BNLD_FLAGS = $(LDFLAGS) $(SYS_LDFLAGS)
HOSTCC_FLAGS = -D_SAMBA_HOSTCC_ $(CFLAGS)
HOSTLD_FLAGS = $(LDFLAGS) $(SYS_LDFLAGS)
+$(srcdir)/version.h: $(srcdir)/VERSION
+ @$(SHELL) script/mkversion.sh VERSION $(srcdir)/version.h $(srcdir)/
+
.DEFAULT_GOAL := all
ifneq ($(automatic_dependencies),yes)
-ALL_PREDEP = proto
+ALL_PREDEP = basics
.NOTPARALLEL:
endif
-include rules.mk
+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
+
+.DEFAULT_GOAL := all
+
+ifneq ($(automatic_dependencies),yes)
+ALL_PREDEP = basics
+.NOTPARALLEL:
+endif
+
+include build/make/rules.mk
+include build/make/python.mk
include data.mk
+BINARIES += $(BIN_PROGS) $(SBIN_PROGS)
+
+pythonmods:: $(PYTHON_PYS) $(PYTHON_SO)
+
DEP_FILES = $(patsubst %.ho,%.hd,$(patsubst %.o,%.d,$(ALL_OBJS))) \
include/includes.d
@@ -55,7 +81,7 @@ endif
DEFAULT_HEADERS = $(srcdir)/lib/util/dlinklist.h \
$(srcdir)/version.h
-binaries::
+binaries:: $(BINARIES)
libraries:: $(STATIC_LIBS) $(SHARED_LIBS)
modules:: $(PLUGINS)
headers:: $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
diff --git a/source4/auth/auth.py b/source4/auth/auth.py
index 88675f3626..1a7aa6d0e7 100644
--- a/source4/auth/auth.py
+++ b/source4/auth/auth.py
@@ -1,5 +1,5 @@
# This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.33
+# Version 1.3.35
#
# Don't modify this file, modify the SWIG interface instead.
diff --git a/source4/auth/auth_server.c b/source4/auth/auth_server.c
deleted file mode 100644
index f200ad9665..0000000000
--- a/source4/auth/auth_server.c
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Authenticate to a remote server
- Copyright (C) Andrew Tridgell 1992-1998
- Copyright (C) Andrew Bartlett 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"
-
-/****************************************************************************
- Support for server level security.
-****************************************************************************/
-
-static struct smbcli_state *server_cryptkey(TALLOC_CTX *mem_ctx, bool unicode, int maxprotocol, struct resolve_context *resolve_ctx)
-{
- struct smbcli_state *cli = NULL;
- fstring desthost;
- struct in_addr dest_ip;
- const char *p;
- char *pserver;
- bool connected_ok = false;
-
- if (!(cli = smbcli_initialise(cli)))
- return NULL;
-
- /* security = server just can't function with spnego */
- cli->use_spnego = false;
-
- pserver = talloc_strdup(mem_ctx, lp_passwordserver());
- p = pserver;
-
- while(next_token( &p, desthost, LIST_SEP, sizeof(desthost))) {
- strupper(desthost);
-
- if(!resolve_name(resolve_ctx, desthost, &dest_ip, 0x20)) {
- DEBUG(1,("server_cryptkey: Can't resolve address for %s\n",desthost));
- continue;
- }
-
- if (ismyip(dest_ip)) {
- DEBUG(1,("Password server loop - disabling password server %s\n",desthost));
- continue;
- }
-
- /* we use a mutex to prevent two connections at once - when a
- Win2k PDC get two connections where one hasn't completed a
- session setup yet it will send a TCP reset to the first
- connection (tridge) */
-
- if (!grab_server_mutex(desthost)) {
- return NULL;
- }
-
- if (smbcli_connect(cli, desthost, &dest_ip)) {
- DEBUG(3,("connected to password server %s\n",desthost));
- connected_ok = true;
- break;
- }
- }
-
- if (!connected_ok) {
- release_server_mutex();
- DEBUG(0,("password server not available\n"));
- talloc_free(cli);
- return NULL;
- }
-
- if (!attempt_netbios_session_request(cli, lp_netbios_name(),
- desthost, &dest_ip)) {
- release_server_mutex();
- DEBUG(1,("password server fails session request\n"));
- talloc_free(cli);
- return NULL;
- }
-
- if (strequal(desthost,myhostname(mem_ctx))) {
- exit_server("Password server loop!");
- }
-
- DEBUG(3,("got session\n"));
-
- if (!smbcli_negprot(cli, unicode, maxprotocol)) {
- DEBUG(1,("%s rejected the negprot\n",desthost));
- release_server_mutex();
- talloc_free(cli);
- return NULL;
- }
-
- if (cli->protocol < PROTOCOL_LANMAN2 ||
- !(cli->sec_mode & NEGOTIATE_SECURITY_USER_LEVEL)) {
- DEBUG(1,("%s isn't in user level security mode\n",desthost));
- release_server_mutex();
- talloc_free(cli);
- return NULL;
- }
-
- /* Get the first session setup done quickly, to avoid silly
- Win2k bugs. (The next connection to the server will kill
- this one...
- */
-
- if (!smbcli_session_setup(cli, "", "", 0, "", 0,
- "")) {
- DEBUG(0,("%s rejected the initial session setup (%s)\n",
- desthost, smbcli_errstr(cli)));
- release_server_mutex();
- talloc_free(cli);
- return NULL;
- }
-
- release_server_mutex();
-
- DEBUG(3,("password server OK\n"));
-
- return cli;
-}
-
-/****************************************************************************
- Clean up our allocated cli.
-****************************************************************************/
-
-static void free_server_private_data(void **private_data_pointer)
-{
- struct smbcli_state **cli = (struct smbcli_state **)private_data_pointer;
- if (*cli && (*cli)->initialised) {
- talloc_free(*cli);
- }
-}
-
-/****************************************************************************
- Get the challenge out of a password server.
-****************************************************************************/
-
-static DATA_BLOB auth_get_challenge_server(const struct auth_context *auth_context,
- void **my_private_data,
- TALLOC_CTX *mem_ctx)
-{
- struct smbcli_state *cli = server_cryptkey(mem_ctx, lp_cli_maxprotocol(auth_context->lp_ctx));
-
- if (cli) {
- DEBUG(3,("using password server validation\n"));
-
- if ((cli->sec_mode & NEGOTIATE_SECURITY_CHALLENGE_RESPONSE) == 0) {
- /* We can't work with unencrypted password servers
- unless 'encrypt passwords = no' */
- DEBUG(5,("make_auth_info_server: Server is unencrypted, no challenge available..\n"));
-
- /* However, it is still a perfectly fine connection
- to pass that unencrypted password over */
- *my_private_data = (void *)cli;
- return data_blob(NULL, 0);
-
- } else if (cli->secblob.length < 8) {
- /* We can't do much if we don't get a full challenge */
- DEBUG(2,("make_auth_info_server: Didn't receive a full challenge from server\n"));
- talloc_free(cli);
- return data_blob(NULL, 0);
- }
-
- *my_private_data = (void *)cli;
-
- /* The return must be allocated on the caller's mem_ctx, as our own will be
- destoyed just after the call. */
- return data_blob_talloc(auth_context->mem_ctx, cli->secblob.data,8);
- } else {
- return data_blob(NULL, 0);
- }
-}
-
-
-/****************************************************************************
- Check for a valid username and password in security=server mode.
- - Validate a password with the password server.
-****************************************************************************/
-
-static NTSTATUS check_smbserver_security(const struct auth_context *auth_context,
- void *my_private_data,
- TALLOC_CTX *mem_ctx,
- const auth_usersupplied_info *user_info,
- auth_serversupplied_info **server_info)
-{
- struct smbcli_state *cli;
- static uint8_t badpass[24];
- static fstring baduser;
- static bool tested_password_server = false;
- static bool bad_password_server = false;
- NTSTATUS nt_status = NT_STATUS_LOGON_FAILURE;
- bool locally_made_cli = false;
-
- /*
- * Check that the requested domain is not our own machine name.
- * If it is, we should never check the PDC here, we use our own local
- * password file.
- */
-
- if (lp_is_myname(auth_context->lp_ctx, user_info->domain.str)) {
- DEBUG(3,("check_smbserver_security: Requested domain was for this machine.\n"));
- return NT_STATUS_LOGON_FAILURE;
- }
-
- cli = my_private_data;
-
- if (cli) {
- } else {
- cli = server_cryptkey(mem_ctx, lp_unicode(auth_context->lp_ctx), lp_cli_maxprotocol(auth_context->lp_ctx), lp_resolve_context(auth_context->lp_ctx));
- locally_made_cli = true;
- }
-
- if (!cli || !cli->initialised) {
- DEBUG(1,("password server is not connected (cli not initilised)\n"));
- return NT_STATUS_LOGON_FAILURE;
- }
-
- if ((cli->sec_mode & NEGOTIATE_SECURITY_CHALLENGE_RESPONSE) == 0) {
- if (user_info->encrypted) {
- DEBUG(1,("password server %s is plaintext, but we are encrypted. This just can't work :-(\n", cli->desthost));
- return NT_STATUS_LOGON_FAILURE;
- }
- } else {
- if (memcmp(cli->secblob.data, auth_context->challenge.data, 8) != 0) {
- DEBUG(1,("the challenge that the password server (%s) supplied us is not the one we gave our client. This just can't work :-(\n", cli->desthost));
- return NT_STATUS_LOGON_FAILURE;
- }
- }
-
- if(badpass[0] == 0)
- memset(badpass, 0x1f, sizeof(badpass));
-
- if((user_info->nt_resp.length == sizeof(badpass)) &&
- !memcmp(badpass, user_info->nt_resp.data, sizeof(badpass))) {
- /*
- * Very unlikely, our random bad password is the same as the users
- * password.
- */
- memset(badpass, badpass[0]+1, sizeof(badpass));
- }
-
- if(baduser[0] == 0) {
- fstrcpy(baduser, INVALID_USER_PREFIX);
- fstrcat(baduser, lp_netbios_name());
- }
-
- /*
- * Attempt a session setup with a totally incorrect password.
- * If this succeeds with the guest bit *NOT* set then the password
- * server is broken and is not correctly setting the guest bit. We
- * need to detect this as some versions of NT4.x are broken. JRA.
- */
-
- /* I sure as hell hope that there aren't servers out there that take
- * NTLMv2 and have this bug, as we don't test for that...
- * - abartlet@samba.org
- */
-
- if ((!tested_password_server) && (lp_paranoid_server_security())) {
- if (smbcli_session_setup(cli, baduser, (char *)badpass, sizeof(badpass),
- (char *)badpass, sizeof(badpass), user_info->domain.str)) {
-
- /*
- * We connected to the password server so we
- * can say we've tested it.
- */
- tested_password_server = true;
-
- if ((SVAL(cli->inbuf,smb_vwv2) & 1) == 0) {
- DEBUG(0,("server_validate: password server %s allows users as non-guest \
-with a bad password.\n", cli->desthost));
- DEBUG(0,("server_validate: This is broken (and insecure) behaviour. Please do not \
-use this machine as the password server.\n"));
- smbcli_ulogoff(cli);
-
- /*
- * Password server has the bug.
- */
- bad_password_server = true;
- return NT_STATUS_LOGON_FAILURE;
- }
- smbcli_ulogoff(cli);
- }
- } else {
-
- /*
- * We have already tested the password server.
- * Fail immediately if it has the bug.
- */
-
- if(bad_password_server) {
- DEBUG(0,("server_validate: [1] password server %s allows users as non-guest \
-with a bad password.\n", cli->desthost));
- DEBUG(0,("server_validate: [1] This is broken (and insecure) behaviour. Please do not \
-use this machine as the password server.\n"));
- return NT_STATUS_LOGON_FAILURE;
- }
- }
-
- /*
- * Now we know the password server will correctly set the guest bit, or is
- * not guest enabled, we can try with the real password.
- */
-
- if (!user_info->encrypted) {
- /* Plaintext available */
- if (!smbcli_session_setup(cli, user_info->smb_name.str,
- (char *)user_info->plaintext_password.data,
- user_info->plaintext_password.length,
- NULL, 0,
- user_info->domain.str)) {
- DEBUG(1,("password server %s rejected the password\n", cli->desthost));
- /* Make this smbcli_nt_error() when the conversion is in */
- nt_status = smbcli_nt_error(cli);
- } else {
- nt_status = NT_STATUS_OK;
- }
- } else {
- if (!smbcli_session_setup(cli, user_info->smb_name.str,
- (char *)user_info->lm_resp.data,
- user_info->lm_resp.length,
- (char *)user_info->nt_resp.data,
- user_info->nt_resp.length,
- user_info->domain.str)) {
- DEBUG(1,("password server %s rejected the password\n", cli->desthost));
- /* Make this smbcli_nt_error() when the conversion is in */
- nt_status = smbcli_nt_error(cli);
- } else {
- nt_status = NT_STATUS_OK;
- }
- }
-
- /* if logged in as guest then reject */
- if ((SVAL(cli->inbuf,smb_vwv2) & 1) != 0) {
- DEBUG(1,("password server %s gave us guest only\n", cli->desthost));
- nt_status = NT_STATUS_LOGON_FAILURE;
- }
-
- smbcli_ulogoff(cli);
-
- if NT_STATUS_IS_OK(nt_status) {
- struct passwd *pass = Get_Pwnam(user_info->internal_username.str);
- if (pass) {
- nt_status = make_server_info_pw(auth_context, server_info, pass);
- } else {
- nt_status = NT_STATUS_NO_SUCH_USER;
- }
- }
-
- if (locally_made_cli) {
- talloc_free(cli);
- }
-
- return(nt_status);
-}
-
-NTSTATUS auth_init_smbserver(struct auth_context *auth_context, const char* param, auth_methods **auth_method)
-{
- if (!make_auth_methods(auth_context, auth_method)) {
- return NT_STATUS_NO_MEMORY;
- }
- (*auth_method)->name = "smbserver";
- (*auth_method)->auth = check_smbserver_security;
- (*auth_method)->get_chal = auth_get_challenge_server;
- (*auth_method)->send_keepalive = send_server_keepalive;
- (*auth_method)->free_private_data = free_server_private_data;
- return NT_STATUS_OK;
-}
diff --git a/source4/auth/auth_wrap.c b/source4/auth/auth_wrap.c
index af1827adc9..dea76ef87d 100644
--- a/source4/auth/auth_wrap.c
+++ b/source4/auth/auth_wrap.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.33
+ * Version 1.3.35
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
@@ -126,7 +126,7 @@
/* This should only be incremented when either the layout of swig_type_info changes,
or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "3"
+#define SWIG_RUNTIME_VERSION "4"
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
#ifdef SWIG_TYPE_TABLE
@@ -161,6 +161,7 @@
/* Flags for pointer conversions */
#define SWIG_POINTER_DISOWN 0x1
+#define SWIG_CAST_NEW_MEMORY 0x2
/* Flags for new pointer objects */
#define SWIG_POINTER_OWN 0x1
@@ -301,10 +302,10 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) {
extern "C" {
#endif
-typedef void *(*swig_converter_func)(void *);
+typedef void *(*swig_converter_func)(void *, int *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);
-/* Structure to store inforomation on one type */
+/* Structure to store information on one type */
typedef struct swig_type_info {
const char *name; /* mangled name of this type */
const char *str; /* human readable name of this type */
@@ -431,8 +432,8 @@ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
Cast a pointer up an inheritance hierarchy
*/
SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
- return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
+SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
}
/*
@@ -856,7 +857,7 @@ SWIG_Python_AddErrorMsg(const char* mesg)
Py_DECREF(old_str);
Py_DECREF(value);
} else {
- PyErr_Format(PyExc_RuntimeError, mesg);
+ PyErr_SetString(PyExc_RuntimeError, mesg);
}
}
@@ -1416,7 +1417,7 @@ PySwigObject_dealloc(PyObject *v)
{
PySwigObject *sobj = (PySwigObject *) v;
PyObject *next = sobj->next;
- if (sobj->own) {
+ if (sobj->own == SWIG_POINTER_OWN) {
swig_type_info *ty = sobj->ty;
PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
PyObject *destroy = data ? data->destroy : 0;
@@ -1434,12 +1435,13 @@ PySwigObject_dealloc(PyObject *v)
res = ((*meth)(mself, v));
}
Py_XDECREF(res);
- } else {
- const char *name = SWIG_TypePrettyName(ty);
+ }
#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
- printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
-#endif
+ else {
+ const char *name = SWIG_TypePrettyName(ty);
+ printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
}
+#endif
}
Py_XDECREF(next);
PyObject_DEL(v);
@@ -1944,7 +1946,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
SWIGRUNTIME int
SWIG_Python_AcquirePtr(PyObject *obj, int own) {
- if (own) {
+ if (own == SWIG_POINTER_OWN) {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
if (sobj) {
int oldown = sobj->own;
@@ -1965,6 +1967,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
return SWIG_OK;
} else {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+ if (own)
+ *own = 0;
while (sobj) {
void *vptr = sobj->ptr;
if (ty) {
@@ -1978,7 +1982,15 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
if (!tc) {
sobj = (PySwigObject *)sobj->next;
} else {
- if (ptr) *ptr = SWIG_TypeCast(tc,vptr);
+ if (ptr) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
+ assert(own);
+ if (own)
+ *own = *own | SWIG_CAST_NEW_MEMORY;
+ }
+ }
break;
}
}
@@ -1988,7 +2000,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
}
}
if (sobj) {
- if (own) *own = sobj->own;
+ if (own)
+ *own = *own | sobj->own;
if (flags & SWIG_POINTER_DISOWN) {
sobj->own = 0;
}
@@ -2053,8 +2066,13 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
}
if (ty) {
swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
- if (!tc) return SWIG_ERROR;
- *ptr = SWIG_TypeCast(tc,vptr);
+ if (tc) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ assert(!newmemory); /* newmemory handling not yet implemented */
+ } else {
+ return SWIG_ERROR;
+ }
} else {
*ptr = vptr;
}
@@ -2505,7 +2523,7 @@ static swig_module_info swig_module = {swig_types, 16, 0, 0, 0, 0};
#define SWIG_name "_auth"
-#define SWIGVERSION 0x010333
+#define SWIGVERSION 0x010335
#define SWIG_VERSION SWIGVERSION
@@ -2733,7 +2751,7 @@ SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
- int found;
+ int found, init;
clientdata = clientdata;
@@ -2743,6 +2761,9 @@ SWIG_InitializeModule(void *clientdata) {
swig_module.type_initial = swig_type_initial;
swig_module.cast_initial = swig_cast_initial;
swig_module.next = &swig_module;
+ init = 1;
+ } else {
+ init = 0;
}
/* Try and load any already created modules */
@@ -2771,6 +2792,12 @@ SWIG_InitializeModule(void *clientdata) {
module_head->next = &swig_module;
}
+ /* When multiple interpeters are used, a module could have already been initialized in
+ a different interpreter, but not yet have a pointer in this interpreter.
+ In this case, we do not want to continue adding types... everything should be
+ set up already */
+ if (init == 0) return;
+
/* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: size %d\n", swig_module.size);
diff --git a/source4/auth/config.mk b/source4/auth/config.mk
index 63aec09847..f13c2e5758 100644
--- a/source4/auth/config.mk
+++ b/source4/auth/config.mk
@@ -1,100 +1,48 @@
# auth server subsystem
+gensecsrcdir := $(authsrcdir)/gensec
mkinclude gensec/config.mk
mkinclude kerberos/config.mk
mkinclude ntlmssp/config.mk
+mkinclude ntlm/config.mk
mkinclude credentials/config.mk
[SUBSYSTEM::auth_session]
-OBJ_FILES = session.o
-PRIVATE_PROTO_HEADER = session_proto.h
PUBLIC_DEPENDENCIES = CREDENTIALS
-# PUBLIC_HEADERS += auth/session.h
+PUBLIC_HEADERS += $(authsrcdir)/session.h
+
+auth_session_OBJ_FILES = $(addprefix $(authsrcdir)/, session.o)
+
+$(eval $(call proto_header_template,$(authsrcdir)/session_proto.h,$(auth_session_OBJ_FILES:.o=.c)))
[SUBSYSTEM::auth_system_session]
-OBJ_FILES = system_session.o
-PRIVATE_PROTO_HEADER = system_session_proto.h
PUBLIC_DEPENDENCIES = CREDENTIALS
PRIVATE_DEPENDENCIES = auth_session LIBSAMBA-UTIL LIBSECURITY
+auth_system_session_OBJ_FILES = $(addprefix $(authsrcdir)/, system_session.o)
+$(eval $(call proto_header_template,$(authsrcdir)/system_session_proto.h,$(auth_system_session_OBJ_FILES:.o=.c)))
+
[SUBSYSTEM::auth_sam]
-PRIVATE_PROTO_HEADER = auth_sam.h
-OBJ_FILES = sam.o ntlm_check.o
PUBLIC_DEPENDENCIES = SAMDB UTIL_LDB LIBSECURITY
PRIVATE_DEPENDENCIES = LDAP_ENCODE
+auth_sam_OBJ_FILES = $(addprefix $(authsrcdir)/, sam.o)
+
+$(eval $(call proto_header_template,$(authsrcdir)/auth_sam.h,$(auth_sam_OBJ_FILES:.o=.c)))
+
[SUBSYSTEM::auth_sam_reply]
-PRIVATE_PROTO_HEADER = auth_sam_reply.h
-OBJ_FILES = auth_sam_reply.o
-
-#######################
-# Start MODULE auth_sam
-[MODULE::auth_sam_module]
-# gensec_krb5 and gensec_gssapi depend on it
-INIT_FUNCTION = auth_sam_init
-SUBSYSTEM = auth
-OBJ_FILES = auth_sam.o
-PRIVATE_DEPENDENCIES = \
- SAMDB auth_sam
-# End MODULE auth_sam
-#######################
-
-#######################
-# Start MODULE auth_anonymous
-[MODULE::auth_anonymous]
-INIT_FUNCTION = auth_anonymous_init
-SUBSYSTEM = auth
-OBJ_FILES = auth_anonymous.o
-# End MODULE auth_anonymous
-#######################
-
-#######################
-# Start MODULE auth_winbind
-[MODULE::auth_winbind]
-INIT_FUNCTION = auth_winbind_init
-SUBSYSTEM = auth
-OBJ_FILES = auth_winbind.o
-PRIVATE_DEPENDENCIES = NDR_WINBIND MESSAGING LIBWINBIND-CLIENT
-# End MODULE auth_winbind
-#######################
-
-#######################
-# Start MODULE auth_developer
-[MODULE::auth_developer]
-INIT_FUNCTION = auth_developer_init
-SUBSYSTEM = auth
-OBJ_FILES = auth_developer.o
-# End MODULE auth_developer
-#######################
-
-[MODULE::auth_unix]
-INIT_FUNCTION = auth_unix_init
-SUBSYSTEM = auth
-OBJ_FILES = auth_unix.o
-PRIVATE_DEPENDENCIES = CRYPT PAM PAM_ERRORS NSS_WRAPPER
-
-[SUBSYSTEM::PAM_ERRORS]
-PRIVATE_PROTO_HEADER = pam_errors.h
-OBJ_FILES = pam_errors.o
-
-#######################
-# Start SUBSYSTEM auth
-[SUBSYSTEM::auth]
-#VERSION = 0.0.1
-#SO_VERSION = 0
-PRIVATE_PROTO_HEADER = auth_proto.h
-OBJ_FILES = \
- auth.o \
- auth_util.o \
- auth_simple.o
-PUBLIC_DEPENDENCIES = LIBSECURITY SAMDB CREDENTIALS
-PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL
-# End SUBSYSTEM auth
-#######################
-
-# PUBLIC_HEADERS += auth/auth.h
+
+auth_sam_reply_OBJ_FILES = $(addprefix $(authsrcdir)/, auth_sam_reply.o)
+
+$(eval $(call proto_header_template,$(authsrcdir)/auth_sam_reply.h,$(auth_sam_reply_OBJ_FILES:.o=.c)))
[PYTHON::swig_auth]
+LIBRARY_REALNAME = samba/_auth.$(SHLIBEXT)
PUBLIC_DEPENDENCIES = auth_system_session
PRIVATE_DEPENDENCIES = SAMDB
-SWIG_FILE = auth.i
+
+$(eval $(call python_py_module_template,samba/auth.py,$(authsrcdir)/auth.py))
+
+swig_auth_OBJ_FILES = $(authsrcdir)/auth_wrap.o
+
+$(swig_auth_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
diff --git a/source4/auth/credentials/config.mk b/source4/auth/credentials/config.mk
index 83f2f0db93..2eeeec20ec 100644
--- a/source4/auth/credentials/config.mk
+++ b/source4/auth/credentials/config.mk
@@ -1,19 +1,24 @@
#################################
# Start SUBSYSTEM CREDENTIALS
[SUBSYSTEM::CREDENTIALS]
-PRIVATE_PROTO_HEADER = credentials_proto.h
-OBJ_FILES = credentials.o \
- credentials_files.o \
- credentials_ntlm.o \
- credentials_krb5.o \
- ../kerberos/kerberos_util.o
PUBLIC_DEPENDENCIES = \
LIBCLI_AUTH SECRETS LIBCRYPTO KERBEROS UTIL_LDB HEIMDAL_GSSAPI
PRIVATE_DEPENDENCIES = \
SECRETS
-PUBLIC_HEADERS += auth/credentials/credentials.h
+
+CREDENTIALS_OBJ_FILES = $(addprefix $(authsrcdir)/credentials/, credentials.o credentials_files.o credentials_ntlm.o credentials_krb5.o ../kerberos/kerberos_util.o)
+
+$(eval $(call proto_header_template,$(authsrcdir)/credentials/credentials_proto.h,$(CREDENTIALS_OBJ_FILES:.o=.c)))
+
+PUBLIC_HEADERS += $(authsrcdir)/credentials/credentials.h
[PYTHON::swig_credentials]
+LIBRARY_REALNAME = samba/_credentials.$(SHLIBEXT)
PUBLIC_DEPENDENCIES = CREDENTIALS LIBCMDLINE_CREDENTIALS
-SWIG_FILE = credentials.i
+
+$(eval $(call python_py_module_template,samba/credentials.py,$(authsrcdir)/credentials/credentials.py))
+
+swig_credentials_OBJ_FILES = $(authsrcdir)/credentials/credentials_wrap.o
+
+$(swig_credentials_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
diff --git a/source4/auth/credentials/credentials.c b/source4/auth/credentials/credentials.c
index 89dddc9e05..adabe49cb4 100644
--- a/source4/auth/credentials/credentials.c
+++ b/source4/auth/credentials/credentials.c
@@ -65,7 +65,6 @@ _PUBLIC_ struct cli_credentials *cli_credentials_init(TALLOC_CTX *mem_ctx)
cred->tries = 3;
cred->callback_running = false;
- cred->ev = NULL;
cli_credentials_set_kerberos_state(cred, CRED_AUTO_USE_KERBEROS);
cli_credentials_set_gensec_features(cred, 0);
@@ -307,6 +306,8 @@ _PUBLIC_ bool cli_credentials_set_password(struct cli_credentials *cred,
cli_credentials_invalidate_ccache(cred, cred->password_obtained);
cred->nt_hash = NULL;
+ cred->lm_response = data_blob(NULL, 0);
+ cred->nt_response = data_blob(NULL, 0);
return true;
}
@@ -377,24 +378,6 @@ _PUBLIC_ const struct samr_Password *cli_credentials_get_nt_hash(struct cli_cred
}
}
-_PUBLIC_ bool cli_credentials_set_nt_hash(struct cli_credentials *cred,
- const struct samr_Password *nt_hash,
- enum credentials_obtained obtained)
-{
- if (obtained >= cred->password_obtained) {
- cli_credentials_set_password(cred, NULL, obtained);
- if (nt_hash) {
- cred->nt_hash = talloc(cred, struct samr_Password);
- *cred->nt_hash = *nt_hash;
- } else {
- cred->nt_hash = NULL;
- }
- return true;
- }
-
- return false;
-}
-
/**
* Obtain the 'short' or 'NetBIOS' domain for this credentials context.
* @param cred credentials context
@@ -675,7 +658,7 @@ _PUBLIC_ void cli_credentials_guess(struct cli_credentials *cred,
}
if (cli_credentials_get_kerberos_state(cred) != CRED_DONT_USE_KERBEROS) {
- cli_credentials_set_ccache(cred, lp_ctx, NULL, CRED_GUESS_FILE);
+ cli_credentials_set_ccache(cred, event_context_find(cred), lp_ctx, NULL, CRED_GUESS_FILE);
}
}
@@ -775,22 +758,3 @@ _PUBLIC_ bool cli_credentials_wrong_password(struct cli_credentials *cred)
return (cred->tries > 0);
}
-
-/*
- set the common event context for this set of credentials
- */
-_PUBLIC_ void cli_credentials_set_event_context(struct cli_credentials *cred, struct event_context *ev)
-{
- cred->ev = ev;
-}
-
-/*
- set the common event context for this set of credentials
- */
-_PUBLIC_ struct event_context *cli_credentials_get_event_context(struct cli_credentials *cred)
-{
- if (cred->ev == NULL) {
- cred->ev = event_context_find(cred);
- }
- return cred->ev;
-}
diff --git a/source4/auth/credentials/credentials.h b/source4/auth/credentials/credentials.h
index afcb300638..79c50ae5af 100644
--- a/source4/auth/credentials/credentials.h
+++ b/source4/auth/credentials/credentials.h
@@ -26,6 +26,7 @@
#include "librpc/gen_ndr/misc.h"
struct ccache_container;
+struct event_context;
/* In order of priority */
enum credentials_obtained {
@@ -79,8 +80,13 @@ struct cli_credentials {
const char *bind_dn;
+ /* Allows authentication from a keytab or similar */
struct samr_Password *nt_hash;
+ /* Allows NTLM pass-though authentication */
+ DATA_BLOB lm_response;
+ DATA_BLOB nt_response;
+
struct ccache_container *ccache;
struct gssapi_creds_container *client_gss_creds;
struct keytab_container *keytab;
@@ -121,9 +127,6 @@ struct cli_credentials {
/* Whether any callback is currently running */
bool callback_running;
-
- /* an event context for anyone wanting to use the credentials */
- struct event_context *ev;
};
struct ldb_context;
@@ -152,12 +155,15 @@ NTSTATUS cli_credentials_get_ntlm_response(struct cli_credentials *cred, TALLOC_
const char *cli_credentials_get_realm(struct cli_credentials *cred);
const char *cli_credentials_get_username(struct cli_credentials *cred);
int cli_credentials_get_krb5_context(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct smb_krb5_context **smb_krb5_context);
int cli_credentials_get_ccache(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct ccache_container **ccc);
int cli_credentials_get_keytab(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct keytab_container **_ktc);
const char *cli_credentials_get_domain(struct cli_credentials *cred);
@@ -168,15 +174,15 @@ void cli_credentials_set_conf(struct cli_credentials *cred,
struct loadparm_context *lp_ctx);
const char *cli_credentials_get_principal(struct cli_credentials *cred, TALLOC_CTX *mem_ctx);
int cli_credentials_get_server_gss_creds(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct gssapi_creds_container **_gcc);
int cli_credentials_get_client_gss_creds(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct gssapi_creds_container **_gcc);
-void cli_credentials_set_event_context(struct cli_credentials *cred, struct event_context *ev);
void cli_credentials_set_kerberos_state(struct cli_credentials *creds,
enum credentials_use_kerberos use_kerberos);
-struct event_context *cli_credentials_get_event_context(struct cli_credentials *cred);
bool cli_credentials_set_domain(struct cli_credentials *cred,
const char *val,
enum credentials_obtained obtained);
@@ -199,6 +205,7 @@ void cli_credentials_set_netlogon_creds(struct cli_credentials *cred,
NTSTATUS cli_credentials_set_krb5_context(struct cli_credentials *cred,
struct smb_krb5_context *smb_krb5_context);
NTSTATUS cli_credentials_set_stored_principal(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
const char *serviceprincipal);
NTSTATUS cli_credentials_set_machine_account(struct cli_credentials *cred,
@@ -219,15 +226,22 @@ void cli_credentials_set_kvno(struct cli_credentials *cred,
bool cli_credentials_set_nt_hash(struct cli_credentials *cred,
const struct samr_Password *nt_hash,
enum credentials_obtained obtained);
+bool cli_credentials_set_ntlm_response(struct cli_credentials *cred,
+ const DATA_BLOB *lm_response,
+ const DATA_BLOB *nt_response,
+ enum credentials_obtained obtained);
int cli_credentials_set_keytab_name(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
const char *keytab_name,
enum credentials_obtained obtained);
int cli_credentials_update_keytab(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx);
void cli_credentials_set_gensec_features(struct cli_credentials *creds, uint32_t gensec_features);
uint32_t cli_credentials_get_gensec_features(struct cli_credentials *creds);
int cli_credentials_set_ccache(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
const char *name,
enum credentials_obtained obtained);
@@ -239,6 +253,7 @@ void cli_credentials_invalidate_ccache(struct cli_credentials *cred,
void cli_credentials_set_salt_principal(struct cli_credentials *cred, const char *principal);
enum credentials_use_kerberos cli_credentials_get_kerberos_state(struct cli_credentials *creds);
NTSTATUS cli_credentials_set_secrets(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct ldb_context *ldb,
const char *base,
diff --git a/source4/auth/credentials/credentials.i b/source4/auth/credentials/credentials.i
index 0a604cf002..89eb4924b3 100644
--- a/source4/auth/credentials/credentials.i
+++ b/source4/auth/credentials/credentials.i
@@ -59,42 +59,61 @@ typedef struct cli_credentials {
return cli_credentials_init(NULL);
}
/* username */
+ %feature("docstring") get_username "S.get_username() -> username\nObtain username.";
const char *get_username(void);
+ %feature("docstring") set_username "S.set_username(name, obtained=CRED_SPECIFIED) -> None\nChange username.";
bool set_username(const char *value,
- enum credentials_obtained=CRED_SPECIFIED);
+ enum credentials_obtained obtained=CRED_SPECIFIED);
/* password */
+ %feature("docstring") get_password "S.get_password() -> password\n" \
+ "Obtain password.";
const char *get_password(void);
+ %feature("docstring") set_password "S.set_password(password, obtained=CRED_SPECIFIED) -> None\n" \
+ "Change password.";
bool set_password(const char *val,
- enum credentials_obtained=CRED_SPECIFIED);
+ enum credentials_obtained obtained=CRED_SPECIFIED);
/* domain */
+ %feature("docstring") get_password "S.get_domain() -> domain\nObtain domain name.";
const char *get_domain(void);
+ %feature("docstring") set_domain "S.set_domain(domain, obtained=CRED_SPECIFIED) -> None\n" \
+ "Change domain name.";
bool set_domain(const char *val,
- enum credentials_obtained=CRED_SPECIFIED);
+ enum credentials_obtained obtained=CRED_SPECIFIED);
/* realm */
+ %feature("docstring") get_realm "S.get_realm() -> realm\nObtain realm name.";
const char *get_realm(void);
+ %feature("docstring") set_realm "S.set_realm(realm, obtained=CRED_SPECIFIED) -> None\n" \
+ "Change realm name.";
bool set_realm(const char *val,
- enum credentials_obtained=CRED_SPECIFIED);
+ enum credentials_obtained obtained=CRED_SPECIFIED);
- /* Kerberos */
+ /* Kerberos */
void set_kerberos_state(enum credentials_use_kerberos use_kerberos);
+ %feature("docstring") parse_string "S.parse_string(text, obtained=CRED_SPECIFIED) -> None\n" \
+ "Parse credentials string.";
void parse_string(const char *text,
- enum credentials_obtained=CRED_SPECIFIED);
+ enum credentials_obtained obtained=CRED_SPECIFIED);
/* bind dn */
+ %feature("docstring") get_bind_dn "S.get_bind_dn() -> bind dn\nObtain bind DN.";
const char *get_bind_dn(void);
+ %feature("docstring") set_bind_dn "S.set_bind_dn(bind_dn) -> None\nChange bind DN.";
bool set_bind_dn(const char *bind_dn);
- void set_anonymous();
+ %feature("docstring") set_anonymous "S.set_anonymous() -> None\nUse anonymous credentials.";
+ void set_anonymous();
/* workstation name */
const char *get_workstation(void);
bool set_workstation(const char *workstation,
enum credentials_obtained obtained=CRED_SPECIFIED);
+ NTSTATUS set_machine_account(struct loadparm_context *lp_ctx);
+
void guess(struct loadparm_context *lp_ctx);
bool is_anonymous(void);
@@ -102,8 +121,10 @@ typedef struct cli_credentials {
bool authentication_requested(void);
+ %feature("docstring") wrong_password "S.wrong_password() -> bool\nIndicate the returned password was incorrect.";
bool wrong_password(void);
+ %feature("docstring") set_cmdline_callbacks "S.set_cmdline_callbacks() -> bool\nUse command-line to obtain credentials not explicitly set.";
bool set_cmdline_callbacks();
}
} cli_credentials;
diff --git a/source4/auth/credentials/credentials.py b/source4/auth/credentials/credentials.py
index 2b40fbeead..fd00a8e6f0 100644
--- a/source4/auth/credentials/credentials.py
+++ b/source4/auth/credentials/credentials.py
@@ -1,5 +1,5 @@
# This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.33
+# Version 1.3.35
#
# Don't modify this file, modify the SWIG interface instead.
@@ -66,6 +66,97 @@ class Credentials(object):
__repr__ = _swig_repr
def __init__(self, *args, **kwargs):
_credentials.Credentials_swiginit(self,_credentials.new_Credentials(*args, **kwargs))
+ def get_username(*args, **kwargs):
+ """
+ S.get_username() -> username
+ Obtain username.
+ """
+ return _credentials.Credentials_get_username(*args, **kwargs)
+
+ def set_username(*args, **kwargs):
+ """
+ S.set_username(name, obtained=CRED_SPECIFIED) -> None
+ Change username.
+ """
+ return _credentials.Credentials_set_username(*args, **kwargs)
+
+ def get_password(*args, **kwargs):
+ """
+ S.get_password() -> password
+ Obtain password.
+ """
+ return _credentials.Credentials_get_password(*args, **kwargs)
+
+ def set_password(*args, **kwargs):
+ """
+ S.set_password(password, obtained=CRED_SPECIFIED) -> None
+ Change password.
+ """
+ return _credentials.Credentials_set_password(*args, **kwargs)
+
+ def set_domain(*args, **kwargs):
+ """
+ S.set_domain(domain, obtained=CRED_SPECIFIED) -> None
+ Change domain name.
+ """
+ return _credentials.Credentials_set_domain(*args, **kwargs)
+
+ def get_realm(*args, **kwargs):
+ """
+ S.get_realm() -> realm
+ Obtain realm name.
+ """
+ return _credentials.Credentials_get_realm(*args, **kwargs)
+
+ def set_realm(*args, **kwargs):
+ """
+ S.set_realm(realm, obtained=CRED_SPECIFIED) -> None
+ Change realm name.
+ """
+ return _credentials.Credentials_set_realm(*args, **kwargs)
+
+ def parse_string(*args, **kwargs):
+ """
+ S.parse_string(text, obtained=CRED_SPECIFIED) -> None
+ Parse credentials string.
+ """
+ return _credentials.Credentials_parse_string(*args, **kwargs)
+
+ def get_bind_dn(*args, **kwargs):
+ """
+ S.get_bind_dn() -> bind dn
+ Obtain bind DN.
+ """
+ return _credentials.Credentials_get_bind_dn(*args, **kwargs)
+
+ def set_bind_dn(*args, **kwargs):
+ """
+ S.set_bind_dn(bind_dn) -> None
+ Change bind DN.
+ """
+ return _credentials.Credentials_set_bind_dn(*args, **kwargs)
+
+ def set_anonymous(*args, **kwargs):
+ """
+ S.set_anonymous() -> None
+ Use anonymous credentials.
+ """
+ return _credentials.Credentials_set_anonymous(*args, **kwargs)
+
+ def wrong_password(*args, **kwargs):
+ """
+ S.wrong_password() -> bool
+ Indicate the returned password was incorrect.
+ """
+ return _credentials.Credentials_wrong_password(*args, **kwargs)
+
+ def set_cmdline_callbacks(*args, **kwargs):
+ """
+ S.set_cmdline_callbacks() -> bool
+ Use command-line to obtain credentials not explicitly set.
+ """
+ return _credentials.Credentials_set_cmdline_callbacks(*args, **kwargs)
+
__swig_destroy__ = _credentials.delete_Credentials
Credentials.get_username = new_instancemethod(_credentials.Credentials_get_username,None,Credentials)
Credentials.set_username = new_instancemethod(_credentials.Credentials_set_username,None,Credentials)
@@ -82,6 +173,7 @@ Credentials.set_bind_dn = new_instancemethod(_credentials.Credentials_set_bind_d
Credentials.set_anonymous = new_instancemethod(_credentials.Credentials_set_anonymous,None,Credentials)
Credentials.get_workstation = new_instancemethod(_credentials.Credentials_get_workstation,None,Credentials)
Credentials.set_workstation = new_instancemethod(_credentials.Credentials_set_workstation,None,Credentials)
+Credentials.set_machine_account = new_instancemethod(_credentials.Credentials_set_machine_account,None,Credentials)
Credentials.guess = new_instancemethod(_credentials.Credentials_guess,None,Credentials)
Credentials.is_anonymous = new_instancemethod(_credentials.Credentials_is_anonymous,None,Credentials)
Credentials.get_nt_hash = new_instancemethod(_credentials.Credentials_get_nt_hash,None,Credentials)
diff --git a/source4/auth/credentials/credentials_files.c b/source4/auth/credentials/credentials_files.c
index 8bcbc65575..ab76ea2cde 100644
--- a/source4/auth/credentials/credentials_files.c
+++ b/source4/auth/credentials/credentials_files.c
@@ -30,6 +30,7 @@
#include "auth/credentials/credentials.h"
#include "auth/credentials/credentials_krb5.h"
#include "param/param.h"
+#include "lib/events/events.h"
/**
* Read a file descriptor, and parse it for a password (eg from a file or stdin)
@@ -169,6 +170,7 @@ _PUBLIC_ bool cli_credentials_parse_file(struct cli_credentials *cred, const cha
* @retval NTSTATUS error detailing any failure
*/
_PUBLIC_ NTSTATUS cli_credentials_set_secrets(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct ldb_context *ldb,
const char *base,
@@ -305,13 +307,13 @@ _PUBLIC_ NTSTATUS cli_credentials_set_secrets(struct cli_credentials *cred,
* (chewing CPU time) from the password */
keytab = ldb_msg_find_attr_as_string(msgs[0], "krb5Keytab", NULL);
if (keytab) {
- cli_credentials_set_keytab_name(cred, lp_ctx, keytab, CRED_SPECIFIED);
+ cli_credentials_set_keytab_name(cred, event_ctx, lp_ctx, keytab, CRED_SPECIFIED);
} else {
keytab = ldb_msg_find_attr_as_string(msgs[0], "privateKeytab", NULL);
if (keytab) {
keytab = talloc_asprintf(mem_ctx, "FILE:%s", private_path(mem_ctx, lp_ctx, keytab));
if (keytab) {
- cli_credentials_set_keytab_name(cred, lp_ctx, keytab, CRED_SPECIFIED);
+ cli_credentials_set_keytab_name(cred, event_ctx, lp_ctx, keytab, CRED_SPECIFIED);
}
}
}
@@ -327,7 +329,7 @@ _PUBLIC_ NTSTATUS cli_credentials_set_secrets(struct cli_credentials *cred,
* @retval NTSTATUS error detailing any failure
*/
_PUBLIC_ NTSTATUS cli_credentials_set_machine_account(struct cli_credentials *cred,
- struct loadparm_context *lp_ctx)
+ struct loadparm_context *lp_ctx)
{
char *filter;
/* Bleh, nasty recursion issues: We are setting a machine
@@ -336,7 +338,7 @@ _PUBLIC_ NTSTATUS cli_credentials_set_machine_account(struct cli_credentials *cr
cred->machine_account_pending = false;
filter = talloc_asprintf(cred, SECRETS_PRIMARY_DOMAIN_FILTER,
cli_credentials_get_domain(cred));
- return cli_credentials_set_secrets(cred, lp_ctx, NULL,
+ return cli_credentials_set_secrets(cred, event_context_find(cred), lp_ctx, NULL,
SECRETS_PRIMARY_DOMAIN_DN,
filter);
}
@@ -348,6 +350,7 @@ _PUBLIC_ NTSTATUS cli_credentials_set_machine_account(struct cli_credentials *cr
* @retval NTSTATUS error detailing any failure
*/
NTSTATUS cli_credentials_set_krbtgt(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx)
{
char *filter;
@@ -358,7 +361,7 @@ NTSTATUS cli_credentials_set_krbtgt(struct cli_credentials *cred,
filter = talloc_asprintf(cred, SECRETS_KRBTGT_SEARCH,
cli_credentials_get_realm(cred),
cli_credentials_get_domain(cred));
- return cli_credentials_set_secrets(cred, lp_ctx, NULL,
+ return cli_credentials_set_secrets(cred, event_ctx, lp_ctx, NULL,
SECRETS_PRINCIPALS_DN,
filter);
}
@@ -370,6 +373,7 @@ NTSTATUS cli_credentials_set_krbtgt(struct cli_credentials *cred,
* @retval NTSTATUS error detailing any failure
*/
_PUBLIC_ NTSTATUS cli_credentials_set_stored_principal(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
const char *serviceprincipal)
{
@@ -382,7 +386,7 @@ _PUBLIC_ NTSTATUS cli_credentials_set_stored_principal(struct cli_credentials *c
cli_credentials_get_realm(cred),
cli_credentials_get_domain(cred),
serviceprincipal);
- return cli_credentials_set_secrets(cred, lp_ctx, NULL,
+ return cli_credentials_set_secrets(cred, event_ctx, lp_ctx, NULL,
SECRETS_PRINCIPALS_DN, filter);
}
diff --git a/source4/auth/credentials/credentials_krb5.c b/source4/auth/credentials/credentials_krb5.c
index cd9285b09d..3bc1764448 100644
--- a/source4/auth/credentials/credentials_krb5.c
+++ b/source4/auth/credentials/credentials_krb5.c
@@ -30,6 +30,7 @@
#include "param/param.h"
_PUBLIC_ int cli_credentials_get_krb5_context(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct smb_krb5_context **smb_krb5_context)
{
@@ -39,8 +40,7 @@ _PUBLIC_ int cli_credentials_get_krb5_context(struct cli_credentials *cred,
return 0;
}
- ret = smb_krb5_init_context(cred, cli_credentials_get_event_context(cred),
- lp_ctx, &cred->smb_krb5_context);
+ ret = smb_krb5_init_context(cred, event_ctx, lp_ctx, &cred->smb_krb5_context);
if (ret) {
cred->smb_krb5_context = NULL;
return ret;
@@ -128,6 +128,7 @@ static int free_dccache(struct ccache_container *ccc) {
}
_PUBLIC_ int cli_credentials_set_ccache(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
const char *name,
enum credentials_obtained obtained)
@@ -144,7 +145,7 @@ _PUBLIC_ int cli_credentials_set_ccache(struct cli_credentials *cred,
return ENOMEM;
}
- ret = cli_credentials_get_krb5_context(cred, lp_ctx,
+ ret = cli_credentials_get_krb5_context(cred, event_ctx, lp_ctx,
&ccc->smb_krb5_context);
if (ret) {
talloc_free(ccc);
@@ -203,6 +204,7 @@ _PUBLIC_ int cli_credentials_set_ccache(struct cli_credentials *cred,
static int cli_credentials_new_ccache(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct ccache_container **_ccc)
{
@@ -221,7 +223,7 @@ static int cli_credentials_new_ccache(struct cli_credentials *cred,
return ENOMEM;
}
- ret = cli_credentials_get_krb5_context(cred, lp_ctx,
+ ret = cli_credentials_get_krb5_context(cred, event_ctx, lp_ctx,
&ccc->smb_krb5_context);
if (ret) {
talloc_free(ccc);
@@ -253,6 +255,7 @@ static int cli_credentials_new_ccache(struct cli_credentials *cred,
}
_PUBLIC_ int cli_credentials_get_ccache(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct ccache_container **ccc)
{
@@ -271,7 +274,7 @@ _PUBLIC_ int cli_credentials_get_ccache(struct cli_credentials *cred,
return EINVAL;
}
- ret = cli_credentials_new_ccache(cred, lp_ctx, ccc);
+ ret = cli_credentials_new_ccache(cred, event_ctx, lp_ctx, ccc);
if (ret) {
return ret;
}
@@ -348,6 +351,7 @@ static int free_gssapi_creds(struct gssapi_creds_container *gcc)
}
_PUBLIC_ int cli_credentials_get_client_gss_creds(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct gssapi_creds_container **_gcc)
{
@@ -360,7 +364,7 @@ _PUBLIC_ int cli_credentials_get_client_gss_creds(struct cli_credentials *cred,
*_gcc = cred->client_gss_creds;
return 0;
}
- ret = cli_credentials_get_ccache(cred, lp_ctx,
+ ret = cli_credentials_get_ccache(cred, event_ctx, lp_ctx,
&ccache);
if (ret) {
DEBUG(1, ("Failed to get CCACHE for GSSAPI client: %s\n", error_message(ret)));
@@ -402,6 +406,7 @@ _PUBLIC_ int cli_credentials_get_client_gss_creds(struct cli_credentials *cred,
*/
int cli_credentials_set_client_gss_creds(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
gss_cred_id_t gssapi_cred,
enum credentials_obtained obtained)
@@ -419,7 +424,7 @@ _PUBLIC_ int cli_credentials_get_client_gss_creds(struct cli_credentials *cred,
return ENOMEM;
}
- ret = cli_credentials_new_ccache(cred, lp_ctx, &ccc);
+ ret = cli_credentials_new_ccache(cred, event_ctx, lp_ctx, &ccc);
if (ret != 0) {
return ret;
}
@@ -456,6 +461,7 @@ _PUBLIC_ int cli_credentials_get_client_gss_creds(struct cli_credentials *cred,
* it will be generated from the password.
*/
_PUBLIC_ int cli_credentials_get_keytab(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct keytab_container **_ktc)
{
@@ -475,7 +481,7 @@ _PUBLIC_ int cli_credentials_get_keytab(struct cli_credentials *cred,
return EINVAL;
}
- ret = cli_credentials_get_krb5_context(cred, lp_ctx,
+ ret = cli_credentials_get_krb5_context(cred, event_ctx, lp_ctx,
&smb_krb5_context);
if (ret) {
return ret;
@@ -510,6 +516,7 @@ _PUBLIC_ int cli_credentials_get_keytab(struct cli_credentials *cred,
* FILE:/etc/krb5.keytab), open it and attach it */
_PUBLIC_ int cli_credentials_set_keytab_name(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
const char *keytab_name,
enum credentials_obtained obtained)
@@ -523,7 +530,7 @@ _PUBLIC_ int cli_credentials_set_keytab_name(struct cli_credentials *cred,
return 0;
}
- ret = cli_credentials_get_krb5_context(cred, lp_ctx, &smb_krb5_context);
+ ret = cli_credentials_get_krb5_context(cred, event_ctx, lp_ctx, &smb_krb5_context);
if (ret) {
return ret;
}
@@ -549,6 +556,7 @@ _PUBLIC_ int cli_credentials_set_keytab_name(struct cli_credentials *cred,
}
_PUBLIC_ int cli_credentials_update_keytab(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx)
{
krb5_error_code ret;
@@ -562,7 +570,7 @@ _PUBLIC_ int cli_credentials_update_keytab(struct cli_credentials *cred,
return ENOMEM;
}
- ret = cli_credentials_get_krb5_context(cred, lp_ctx, &smb_krb5_context);
+ ret = cli_credentials_get_krb5_context(cred, event_ctx, lp_ctx, &smb_krb5_context);
if (ret) {
talloc_free(mem_ctx);
return ret;
@@ -570,7 +578,7 @@ _PUBLIC_ int cli_credentials_update_keytab(struct cli_credentials *cred,
enctype_strings = cli_credentials_get_enctype_strings(cred);
- ret = cli_credentials_get_keytab(cred, lp_ctx, &ktc);
+ ret = cli_credentials_get_keytab(cred, event_ctx, lp_ctx, &ktc);
if (ret != 0) {
talloc_free(mem_ctx);
return ret;
@@ -585,6 +593,7 @@ _PUBLIC_ int cli_credentials_update_keytab(struct cli_credentials *cred,
/* Get server gss credentials (in gsskrb5, this means the keytab) */
_PUBLIC_ int cli_credentials_get_server_gss_creds(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct gssapi_creds_container **_gcc)
{
@@ -603,12 +612,12 @@ _PUBLIC_ int cli_credentials_get_server_gss_creds(struct cli_credentials *cred,
return 0;
}
- ret = cli_credentials_get_krb5_context(cred, lp_ctx, &smb_krb5_context);
+ ret = cli_credentials_get_krb5_context(cred, event_ctx, lp_ctx, &smb_krb5_context);
if (ret) {
return ret;
}
- ret = cli_credentials_get_keytab(cred, lp_ctx, &ktc);
+ ret = cli_credentials_get_keytab(cred, event_ctx, lp_ctx, &ktc);
if (ret) {
DEBUG(1, ("Failed to get keytab for GSSAPI server: %s\n", error_message(ret)));
return ret;
diff --git a/source4/auth/credentials/credentials_krb5.h b/source4/auth/credentials/credentials_krb5.h
index aaa7d7f0da..f672b0ad9a 100644
--- a/source4/auth/credentials/credentials_krb5.h
+++ b/source4/auth/credentials/credentials_krb5.h
@@ -32,6 +32,7 @@ struct gssapi_creds_container {
/* Manually prototyped here to avoid needing gss headers in most callers */
int cli_credentials_set_client_gss_creds(struct cli_credentials *cred,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
gss_cred_id_t gssapi_cred,
enum credentials_obtained obtained);
diff --git a/source4/auth/credentials/credentials_ntlm.c b/source4/auth/credentials/credentials_ntlm.c
index b88f2018df..22e273c35a 100644
--- a/source4/auth/credentials/credentials_ntlm.c
+++ b/source4/auth/credentials/credentials_ntlm.c
@@ -52,6 +52,20 @@ _PUBLIC_ NTSTATUS cli_credentials_get_ntlm_response(struct cli_credentials *cred
const struct samr_Password *nt_hash;
lm_session_key = data_blob(NULL, 0);
+ /* We may already have an NTLM response we prepared earlier.
+ * This is used for NTLM pass-though authentication */
+ if (cred->nt_response.data || cred->lm_response.data) {
+ *_nt_response = cred->nt_response;
+ *_lm_response = cred->lm_response;
+
+ if (!cred->lm_response.data) {
+ *flags = *flags & ~CLI_CRED_LANMAN_AUTH;
+ }
+ *_lm_session_key = data_blob(NULL, 0);
+ *_session_key = data_blob(NULL, 0);
+ return NT_STATUS_OK;
+ }
+
nt_hash = cli_credentials_get_nt_hash(cred, mem_ctx);
cli_credentials_get_ntlm_username_domain(cred, mem_ctx, &user, &domain);
@@ -215,3 +229,41 @@ _PUBLIC_ NTSTATUS cli_credentials_get_ntlm_response(struct cli_credentials *cred
return NT_STATUS_OK;
}
+_PUBLIC_ bool cli_credentials_set_nt_hash(struct cli_credentials *cred,
+ const struct samr_Password *nt_hash,
+ enum credentials_obtained obtained)
+{
+ if (obtained >= cred->password_obtained) {
+ cli_credentials_set_password(cred, NULL, obtained);
+ if (nt_hash) {
+ cred->nt_hash = talloc(cred, struct samr_Password);
+ *cred->nt_hash = *nt_hash;
+ } else {
+ cred->nt_hash = NULL;
+ }
+ return true;
+ }
+
+ return false;
+}
+
+_PUBLIC_ bool cli_credentials_set_ntlm_response(struct cli_credentials *cred,
+ const DATA_BLOB *lm_response,
+ const DATA_BLOB *nt_response,
+ enum credentials_obtained obtained)
+{
+ if (obtained >= cred->password_obtained) {
+ cli_credentials_set_password(cred, NULL, obtained);
+ if (nt_response) {
+ cred->nt_response = data_blob_talloc(cred, nt_response->data, nt_response->length);
+ talloc_steal(cred, cred->nt_response.data);
+ }
+ if (nt_response) {
+ cred->lm_response = data_blob_talloc(cred, lm_response->data, lm_response->length);
+ }
+ return true;
+ }
+
+ return false;
+}
+
diff --git a/source4/auth/credentials/credentials_wrap.c b/source4/auth/credentials/credentials_wrap.c
index 909233aaff..81ba426e45 100644
--- a/source4/auth/credentials/credentials_wrap.c
+++ b/source4/auth/credentials/credentials_wrap.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.33
+ * Version 1.3.35
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
@@ -126,7 +126,7 @@
/* This should only be incremented when either the layout of swig_type_info changes,
or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "3"
+#define SWIG_RUNTIME_VERSION "4"
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
#ifdef SWIG_TYPE_TABLE
@@ -161,6 +161,7 @@
/* Flags for pointer conversions */
#define SWIG_POINTER_DISOWN 0x1
+#define SWIG_CAST_NEW_MEMORY 0x2
/* Flags for new pointer objects */
#define SWIG_POINTER_OWN 0x1
@@ -301,10 +302,10 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) {
extern "C" {
#endif
-typedef void *(*swig_converter_func)(void *);
+typedef void *(*swig_converter_func)(void *, int *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);
-/* Structure to store inforomation on one type */
+/* Structure to store information on one type */
typedef struct swig_type_info {
const char *name; /* mangled name of this type */
const char *str; /* human readable name of this type */
@@ -431,8 +432,8 @@ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
Cast a pointer up an inheritance hierarchy
*/
SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
- return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
+SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
}
/*
@@ -856,7 +857,7 @@ SWIG_Python_AddErrorMsg(const char* mesg)
Py_DECREF(old_str);
Py_DECREF(value);
} else {
- PyErr_Format(PyExc_RuntimeError, mesg);
+ PyErr_SetString(PyExc_RuntimeError, mesg);
}
}
@@ -1416,7 +1417,7 @@ PySwigObject_dealloc(PyObject *v)
{
PySwigObject *sobj = (PySwigObject *) v;
PyObject *next = sobj->next;
- if (sobj->own) {
+ if (sobj->own == SWIG_POINTER_OWN) {
swig_type_info *ty = sobj->ty;
PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
PyObject *destroy = data ? data->destroy : 0;
@@ -1434,12 +1435,13 @@ PySwigObject_dealloc(PyObject *v)
res = ((*meth)(mself, v));
}
Py_XDECREF(res);
- } else {
- const char *name = SWIG_TypePrettyName(ty);
+ }
#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
- printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
-#endif
+ else {
+ const char *name = SWIG_TypePrettyName(ty);
+ printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
}
+#endif
}
Py_XDECREF(next);
PyObject_DEL(v);
@@ -1944,7 +1946,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
SWIGRUNTIME int
SWIG_Python_AcquirePtr(PyObject *obj, int own) {
- if (own) {
+ if (own == SWIG_POINTER_OWN) {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
if (sobj) {
int oldown = sobj->own;
@@ -1965,6 +1967,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
return SWIG_OK;
} else {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+ if (own)
+ *own = 0;
while (sobj) {
void *vptr = sobj->ptr;
if (ty) {
@@ -1978,7 +1982,15 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
if (!tc) {
sobj = (PySwigObject *)sobj->next;
} else {
- if (ptr) *ptr = SWIG_TypeCast(tc,vptr);
+ if (ptr) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
+ assert(own);
+ if (own)
+ *own = *own | SWIG_CAST_NEW_MEMORY;
+ }
+ }
break;
}
}
@@ -1988,7 +2000,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
}
}
if (sobj) {
- if (own) *own = sobj->own;
+ if (own)
+ *own = *own | sobj->own;
if (flags & SWIG_POINTER_DISOWN) {
sobj->own = 0;
}
@@ -2053,8 +2066,13 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
}
if (ty) {
swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
- if (!tc) return SWIG_ERROR;
- *ptr = SWIG_TypeCast(tc,vptr);
+ if (tc) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ assert(!newmemory); /* newmemory handling not yet implemented */
+ } else {
+ return SWIG_ERROR;
+ }
} else {
*ptr = vptr;
}
@@ -2456,24 +2474,25 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
/* -------- TYPES TABLE (BEGIN) -------- */
-#define SWIGTYPE_p_TALLOC_CTX swig_types[0]
-#define SWIGTYPE_p_char swig_types[1]
-#define SWIGTYPE_p_cli_credentials swig_types[2]
-#define SWIGTYPE_p_int swig_types[3]
-#define SWIGTYPE_p_loadparm_context swig_types[4]
-#define SWIGTYPE_p_loadparm_service swig_types[5]
-#define SWIGTYPE_p_long swig_types[6]
-#define SWIGTYPE_p_param_context swig_types[7]
-#define SWIGTYPE_p_param_opt swig_types[8]
-#define SWIGTYPE_p_param_section swig_types[9]
-#define SWIGTYPE_p_short swig_types[10]
-#define SWIGTYPE_p_signed_char swig_types[11]
-#define SWIGTYPE_p_unsigned_char swig_types[12]
-#define SWIGTYPE_p_unsigned_int swig_types[13]
-#define SWIGTYPE_p_unsigned_long swig_types[14]
-#define SWIGTYPE_p_unsigned_short swig_types[15]
-static swig_type_info *swig_types[17];
-static swig_module_info swig_module = {swig_types, 16, 0, 0, 0, 0};
+#define SWIGTYPE_p_NTSTATUS swig_types[0]
+#define SWIGTYPE_p_TALLOC_CTX swig_types[1]
+#define SWIGTYPE_p_char swig_types[2]
+#define SWIGTYPE_p_cli_credentials swig_types[3]
+#define SWIGTYPE_p_int swig_types[4]
+#define SWIGTYPE_p_loadparm_context swig_types[5]
+#define SWIGTYPE_p_loadparm_service swig_types[6]
+#define SWIGTYPE_p_long_long swig_types[7]
+#define SWIGTYPE_p_param_context swig_types[8]
+#define SWIGTYPE_p_param_opt swig_types[9]
+#define SWIGTYPE_p_param_section swig_types[10]
+#define SWIGTYPE_p_short swig_types[11]
+#define SWIGTYPE_p_signed_char swig_types[12]
+#define SWIGTYPE_p_unsigned_char swig_types[13]
+#define SWIGTYPE_p_unsigned_int swig_types[14]
+#define SWIGTYPE_p_unsigned_long_long swig_types[15]
+#define SWIGTYPE_p_unsigned_short swig_types[16]
+static swig_type_info *swig_types[18];
+static swig_module_info swig_module = {swig_types, 17, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
@@ -2505,7 +2524,7 @@ static swig_module_info swig_module = {swig_types, 16, 0, 0, 0, 0};
#define SWIG_name "_credentials"
-#define SWIGVERSION 0x010333
+#define SWIGVERSION 0x010335
#define SWIG_VERSION SWIGVERSION
@@ -2862,7 +2881,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_username(PyObject *SWIGUNUSEDPARM(sel
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "value",(char *)"arg3", NULL
+ (char *) "self",(char *) "value",(char *) "obtained", NULL
};
arg1 = NULL;
@@ -2943,7 +2962,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_password(PyObject *SWIGUNUSEDPARM(sel
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "val",(char *)"arg3", NULL
+ (char *) "self",(char *) "val",(char *) "obtained", NULL
};
arg1 = NULL;
@@ -3024,7 +3043,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_domain(PyObject *SWIGUNUSEDPARM(self)
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "val",(char *)"arg3", NULL
+ (char *) "self",(char *) "val",(char *) "obtained", NULL
};
arg1 = NULL;
@@ -3105,7 +3124,7 @@ SWIGINTERN PyObject *_wrap_Credentials_set_realm(PyObject *SWIGUNUSEDPARM(self),
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "val",(char *)"arg3", NULL
+ (char *) "self",(char *) "val",(char *) "obtained", NULL
};
arg1 = NULL;
@@ -3195,7 +3214,7 @@ SWIGINTERN PyObject *_wrap_Credentials_parse_string(PyObject *SWIGUNUSEDPARM(sel
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
char * kwnames[] = {
- (char *) "self",(char *) "text",(char *)"arg3", NULL
+ (char *) "self",(char *) "text",(char *) "obtained", NULL
};
arg1 = NULL;
@@ -3409,6 +3428,46 @@ fail:
}
+SWIGINTERN PyObject *_wrap_Credentials_set_machine_account(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ cli_credentials *arg1 = (cli_credentials *) 0 ;
+ struct loadparm_context *arg2 = (struct loadparm_context *) 0 ;
+ NTSTATUS result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "lp_ctx", NULL
+ };
+
+ arg1 = NULL;
+ arg2 = loadparm_init(NULL);
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:Credentials_set_machine_account",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (obj0) {
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_cli_credentials, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Credentials_set_machine_account" "', argument " "1"" of type '" "cli_credentials *""'");
+ }
+ arg1 = (cli_credentials *)(argp1);
+ }
+ if (obj1) {
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Credentials_set_machine_account" "', argument " "2"" of type '" "struct loadparm_context *""'");
+ }
+ arg2 = (struct loadparm_context *)(argp2);
+ }
+ result = cli_credentials_set_machine_account(arg1,arg2);
+ resultobj = SWIG_NewPointerObj((NTSTATUS *)memcpy((NTSTATUS *)malloc(sizeof(NTSTATUS)),&result,sizeof(NTSTATUS)), SWIGTYPE_p_NTSTATUS, SWIG_POINTER_OWN | 0 );
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_Credentials_guess(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
cli_credentials *arg1 = (cli_credentials *) 0 ;
@@ -3631,27 +3690,67 @@ SWIGINTERN PyObject *Credentials_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObje
static PyMethodDef SwigMethods[] = {
{ (char *)"new_Credentials", (PyCFunction)_wrap_new_Credentials, METH_NOARGS, NULL},
- { (char *)"Credentials_get_username", (PyCFunction) _wrap_Credentials_get_username, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_set_username", (PyCFunction) _wrap_Credentials_set_username, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_get_password", (PyCFunction) _wrap_Credentials_get_password, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_set_password", (PyCFunction) _wrap_Credentials_set_password, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Credentials_get_username", (PyCFunction) _wrap_Credentials_get_username, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.get_username() -> username\n"
+ "Obtain username.\n"
+ ""},
+ { (char *)"Credentials_set_username", (PyCFunction) _wrap_Credentials_set_username, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_username(name, obtained=CRED_SPECIFIED) -> None\n"
+ "Change username.\n"
+ ""},
+ { (char *)"Credentials_get_password", (PyCFunction) _wrap_Credentials_get_password, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.get_password() -> password\n"
+ "Obtain password.\n"
+ ""},
+ { (char *)"Credentials_set_password", (PyCFunction) _wrap_Credentials_set_password, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_password(password, obtained=CRED_SPECIFIED) -> None\n"
+ "Change password.\n"
+ ""},
{ (char *)"Credentials_get_domain", (PyCFunction) _wrap_Credentials_get_domain, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_set_domain", (PyCFunction) _wrap_Credentials_set_domain, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_get_realm", (PyCFunction) _wrap_Credentials_get_realm, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_set_realm", (PyCFunction) _wrap_Credentials_set_realm, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Credentials_set_domain", (PyCFunction) _wrap_Credentials_set_domain, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_domain(domain, obtained=CRED_SPECIFIED) -> None\n"
+ "Change domain name.\n"
+ ""},
+ { (char *)"Credentials_get_realm", (PyCFunction) _wrap_Credentials_get_realm, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.get_realm() -> realm\n"
+ "Obtain realm name.\n"
+ ""},
+ { (char *)"Credentials_set_realm", (PyCFunction) _wrap_Credentials_set_realm, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_realm(realm, obtained=CRED_SPECIFIED) -> None\n"
+ "Change realm name.\n"
+ ""},
{ (char *)"Credentials_set_kerberos_state", (PyCFunction) _wrap_Credentials_set_kerberos_state, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_parse_string", (PyCFunction) _wrap_Credentials_parse_string, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_get_bind_dn", (PyCFunction) _wrap_Credentials_get_bind_dn, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_set_bind_dn", (PyCFunction) _wrap_Credentials_set_bind_dn, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_set_anonymous", (PyCFunction) _wrap_Credentials_set_anonymous, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Credentials_parse_string", (PyCFunction) _wrap_Credentials_parse_string, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.parse_string(text, obtained=CRED_SPECIFIED) -> None\n"
+ "Parse credentials string.\n"
+ ""},
+ { (char *)"Credentials_get_bind_dn", (PyCFunction) _wrap_Credentials_get_bind_dn, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.get_bind_dn() -> bind dn\n"
+ "Obtain bind DN.\n"
+ ""},
+ { (char *)"Credentials_set_bind_dn", (PyCFunction) _wrap_Credentials_set_bind_dn, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_bind_dn(bind_dn) -> None\n"
+ "Change bind DN.\n"
+ ""},
+ { (char *)"Credentials_set_anonymous", (PyCFunction) _wrap_Credentials_set_anonymous, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_anonymous() -> None\n"
+ "Use anonymous credentials.\n"
+ ""},
{ (char *)"Credentials_get_workstation", (PyCFunction) _wrap_Credentials_get_workstation, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Credentials_set_workstation", (PyCFunction) _wrap_Credentials_set_workstation, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Credentials_set_machine_account", (PyCFunction) _wrap_Credentials_set_machine_account, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Credentials_guess", (PyCFunction) _wrap_Credentials_guess, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Credentials_is_anonymous", (PyCFunction) _wrap_Credentials_is_anonymous, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Credentials_get_nt_hash", (PyCFunction) _wrap_Credentials_get_nt_hash, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Credentials_authentication_requested", (PyCFunction) _wrap_Credentials_authentication_requested, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_wrong_password", (PyCFunction) _wrap_Credentials_wrong_password, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Credentials_set_cmdline_callbacks", (PyCFunction) _wrap_Credentials_set_cmdline_callbacks, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Credentials_wrong_password", (PyCFunction) _wrap_Credentials_wrong_password, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.wrong_password() -> bool\n"
+ "Indicate the returned password was incorrect.\n"
+ ""},
+ { (char *)"Credentials_set_cmdline_callbacks", (PyCFunction) _wrap_Credentials_set_cmdline_callbacks, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_cmdline_callbacks() -> bool\n"
+ "Use command-line to obtain credentials not explicitly set.\n"
+ ""},
{ (char *)"delete_Credentials", (PyCFunction) _wrap_delete_Credentials, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Credentials_swigregister", Credentials_swigregister, METH_VARARGS, NULL},
{ (char *)"Credentials_swiginit", Credentials_swiginit, METH_VARARGS, NULL},
@@ -3661,31 +3760,33 @@ static PyMethodDef SwigMethods[] = {
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
+static swig_type_info _swigt__p_NTSTATUS = {"_p_NTSTATUS", "NTSTATUS *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_TALLOC_CTX = {"_p_TALLOC_CTX", "TALLOC_CTX *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_cli_credentials = {"_p_cli_credentials", "struct cli_credentials *|cli_credentials *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_int = {"_p_int", "int *|int_least32_t *|int32_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_int = {"_p_int", "intptr_t *|int *|int_least32_t *|int_fast32_t *|int32_t *|int_fast16_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_loadparm_context = {"_p_loadparm_context", "struct loadparm_context *|loadparm_context *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_loadparm_service = {"_p_loadparm_service", "struct loadparm_service *|loadparm_service *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_long = {"_p_long", "intptr_t *|int_least64_t *|int_fast32_t *|int_fast64_t *|int64_t *|long *|int_fast16_t *|intmax_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_param_context = {"_p_param_context", "struct param_context *|param *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_param_opt = {"_p_param_opt", "struct param_opt *|param_opt *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_param_section = {"_p_param_section", "struct param_section *|param_section *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *|uint_least8_t *|uint_fast8_t *|uint8_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uint_least32_t *|uint32_t *|unsigned int *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_long = {"_p_unsigned_long", "uintptr_t *|uint_least64_t *|uint_fast32_t *|uint_fast64_t *|uint64_t *|unsigned long *|uint_fast16_t *|uintmax_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uintptr_t *|uint_least32_t *|uint_fast32_t *|uint32_t *|unsigned int *|uint_fast16_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_long_long = {"_p_unsigned_long_long", "uint_least64_t *|uint_fast64_t *|uint64_t *|unsigned long long *|uintmax_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *|uint_least16_t *|uint16_t *", 0, 0, (void*)0, 0};
static swig_type_info *swig_type_initial[] = {
+ &_swigt__p_NTSTATUS,
&_swigt__p_TALLOC_CTX,
&_swigt__p_char,
&_swigt__p_cli_credentials,
&_swigt__p_int,
&_swigt__p_loadparm_context,
&_swigt__p_loadparm_service,
- &_swigt__p_long,
+ &_swigt__p_long_long,
&_swigt__p_param_context,
&_swigt__p_param_opt,
&_swigt__p_param_section,
@@ -3693,17 +3794,18 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_signed_char,
&_swigt__p_unsigned_char,
&_swigt__p_unsigned_int,
- &_swigt__p_unsigned_long,
+ &_swigt__p_unsigned_long_long,
&_swigt__p_unsigned_short,
};
+static swig_cast_info _swigc__p_NTSTATUS[] = { {&_swigt__p_NTSTATUS, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_TALLOC_CTX[] = { {&_swigt__p_TALLOC_CTX, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_cli_credentials[] = { {&_swigt__p_cli_credentials, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_loadparm_context[] = { {&_swigt__p_loadparm_context, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_loadparm_service[] = { {&_swigt__p_loadparm_service, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_long[] = { {&_swigt__p_long, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_param_context[] = { {&_swigt__p_param_context, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_param_opt[] = { {&_swigt__p_param_opt, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_param_section[] = { {&_swigt__p_param_section, 0, 0, 0},{0, 0, 0, 0}};
@@ -3711,17 +3813,18 @@ static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0,
static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_unsigned_long[] = { {&_swigt__p_unsigned_long, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_unsigned_long_long[] = { {&_swigt__p_unsigned_long_long, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info *swig_cast_initial[] = {
+ _swigc__p_NTSTATUS,
_swigc__p_TALLOC_CTX,
_swigc__p_char,
_swigc__p_cli_credentials,
_swigc__p_int,
_swigc__p_loadparm_context,
_swigc__p_loadparm_service,
- _swigc__p_long,
+ _swigc__p_long_long,
_swigc__p_param_context,
_swigc__p_param_opt,
_swigc__p_param_section,
@@ -3729,7 +3832,7 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_signed_char,
_swigc__p_unsigned_char,
_swigc__p_unsigned_int,
- _swigc__p_unsigned_long,
+ _swigc__p_unsigned_long_long,
_swigc__p_unsigned_short,
};
@@ -3799,7 +3902,7 @@ SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
- int found;
+ int found, init;
clientdata = clientdata;
@@ -3809,6 +3912,9 @@ SWIG_InitializeModule(void *clientdata) {
swig_module.type_initial = swig_type_initial;
swig_module.cast_initial = swig_cast_initial;
swig_module.next = &swig_module;
+ init = 1;
+ } else {
+ init = 0;
}
/* Try and load any already created modules */
@@ -3837,6 +3943,12 @@ SWIG_InitializeModule(void *clientdata) {
module_head->next = &swig_module;
}
+ /* When multiple interpeters are used, a module could have already been initialized in
+ a different interpreter, but not yet have a pointer in this interpreter.
+ In this case, we do not want to continue adding types... everything should be
+ set up already */
+ if (init == 0) return;
+
/* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: size %d\n", swig_module.size);
diff --git a/source4/auth/credentials/tests/bindings.py b/source4/auth/credentials/tests/bindings.py
index d0a99502c1..30120b3a60 100644
--- a/source4/auth/credentials/tests/bindings.py
+++ b/source4/auth/credentials/tests/bindings.py
@@ -24,7 +24,7 @@ the functionality, that's already done in other tests.
"""
import unittest
-import credentials
+from samba import credentials
class CredentialsTests(unittest.TestCase):
def setUp(self):
diff --git a/source4/auth/gensec/config.mk b/source4/auth/gensec/config.mk
index 14864f7e4c..f08ff2638a 100644
--- a/source4/auth/gensec/config.mk
+++ b/source4/auth/gensec/config.mk
@@ -1,80 +1,87 @@
#################################
# Start SUBSYSTEM gensec
[LIBRARY::gensec]
-PC_FILE = gensec.pc
-VERSION = 0.0.1
-SO_VERSION = 0
-PRIVATE_PROTO_HEADER = gensec_proto.h
-OBJ_FILES = gensec.o socket.o
PUBLIC_DEPENDENCIES = \
CREDENTIALS LIBSAMBA-UTIL LIBCRYPTO ASN1_UTIL samba-socket LIBPACKET
# End SUBSYSTEM gensec
#################################
-PUBLIC_HEADERS += auth/gensec/gensec.h
+PC_FILES += $(gensecsrcdir)/gensec.pc
+
+gensec_VERSION = 0.0.1
+gensec_SOVERSION = 0
+gensec_OBJ_FILES = $(addprefix $(gensecsrcdir)/, gensec.o socket.o)
+
+PUBLIC_HEADERS += $(gensecsrcdir)/gensec.h
+
+$(eval $(call proto_header_template,$(gensecsrcdir)/gensec_proto.h,$(gensec_OBJ_FILES:.o=.c)))
################################################
# Start MODULE gensec_krb5
[MODULE::gensec_krb5]
SUBSYSTEM = gensec
INIT_FUNCTION = gensec_krb5_init
-OBJ_FILES = gensec_krb5.o
-PRIVATE_DEPENDENCIES = CREDENTIALS KERBEROS auth auth_sam
+PRIVATE_DEPENDENCIES = CREDENTIALS KERBEROS auth_session auth_sam
# End MODULE gensec_krb5
################################################
+gensec_krb5_OBJ_FILES = $(addprefix $(gensecsrcdir)/, gensec_krb5.o)
+
################################################
# Start MODULE gensec_gssapi
[MODULE::gensec_gssapi]
SUBSYSTEM = gensec
INIT_FUNCTION = gensec_gssapi_init
-OBJ_FILES = gensec_gssapi.o
PRIVATE_DEPENDENCIES = HEIMDAL_GSSAPI CREDENTIALS KERBEROS
# End MODULE gensec_gssapi
################################################
+gensec_gssapi_OBJ_FILES = $(addprefix $(gensecsrcdir)/, gensec_gssapi.o)
+
################################################
# Start MODULE cyrus_sasl
[MODULE::cyrus_sasl]
SUBSYSTEM = gensec
INIT_FUNCTION = gensec_sasl_init
-OBJ_FILES = cyrus_sasl.o
PRIVATE_DEPENDENCIES = CREDENTIALS SASL
# End MODULE cyrus_sasl
################################################
+cyrus_sasl_OBJ_FILES = $(addprefix $(gensecsrcdir)/, cyrus_sasl.o)
+
################################################
# Start MODULE gensec_spnego
[MODULE::gensec_spnego]
SUBSYSTEM = gensec
INIT_FUNCTION = gensec_spnego_init
-PRIVATE_PROTO_HEADER = spnego_proto.h
PRIVATE_DEPENDENCIES = ASN1_UTIL CREDENTIALS
-OBJ_FILES = spnego.o spnego_parse.o
# End MODULE gensec_spnego
################################################
+gensec_spnego_OBJ_FILES = $(addprefix $(gensecsrcdir)/, spnego.o spnego_parse.o)
+
+$(eval $(call proto_header_template,$(gensecsrcdir)/spnego_proto.h,$(gensec_spnego_OBJ_FILES:.o=.c)))
+
################################################
# Start MODULE gensec_schannel
[MODULE::gensec_schannel]
SUBSYSTEM = gensec
-PRIVATE_PROTO_HEADER = schannel_proto.h
INIT_FUNCTION = gensec_schannel_init
-OBJ_FILES = schannel.o \
- schannel_sign.o
PRIVATE_DEPENDENCIES = SCHANNELDB NDR_SCHANNEL CREDENTIALS LIBNDR
OUTPUT_TYPE = MERGED_OBJ
# End MODULE gensec_schannel
################################################
+gensec_schannel_OBJ_FILES = $(addprefix $(gensecsrcdir)/, schannel.o schannel_sign.o)
+$(eval $(call proto_header_template,$(gensecsrcdir)/schannel_proto.h,$(gensec_schannel_OBJ_FILES:.o=.c)))
+
################################################
# Start SUBSYSTEM SCHANNELDB
[SUBSYSTEM::SCHANNELDB]
-PRIVATE_PROTO_HEADER = schannel_state.h
-OBJ_FILES = \
- schannel_state.o
PRIVATE_DEPENDENCIES = LDB_WRAP SAMDB
-#
# End SUBSYSTEM SCHANNELDB
################################################
+SCHANNELDB_OBJ_FILES = $(addprefix $(gensecsrcdir)/, schannel_state.o)
+$(eval $(call proto_header_template,$(gensecsrcdir)/schannel_state.h,$(SCHANNELDB_OBJ_FILES:.o=.c)))
+
diff --git a/source4/auth/gensec/gensec.c b/source4/auth/gensec/gensec.c
index 59c19b96ab..0edb34d740 100644
--- a/source4/auth/gensec/gensec.c
+++ b/source4/auth/gensec/gensec.c
@@ -23,7 +23,6 @@
#include "includes.h"
#include "auth/auth.h"
#include "lib/events/events.h"
-#include "build.h"
#include "librpc/rpc/dcerpc.h"
#include "auth/credentials/credentials.h"
#include "auth/gensec/gensec.h"
@@ -482,6 +481,11 @@ static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx,
struct messaging_context *msg,
struct gensec_security **gensec_security)
{
+ if (ev == NULL) {
+ DEBUG(0, ("No event context available!\n"));
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+
(*gensec_security) = talloc(mem_ctx, struct gensec_security);
NT_STATUS_HAVE_NO_MEMORY(*gensec_security);
@@ -493,14 +497,6 @@ static NTSTATUS gensec_start(TALLOC_CTX *mem_ctx,
(*gensec_security)->subcontext = false;
(*gensec_security)->want_features = 0;
-
- if (ev == NULL) {
- ev = event_context_init(*gensec_security);
- if (ev == NULL) {
- talloc_free(*gensec_security);
- return NT_STATUS_NO_MEMORY;
- }
- }
(*gensec_security)->event_ctx = ev;
(*gensec_security)->msg_ctx = msg;
@@ -548,20 +544,11 @@ _PUBLIC_ NTSTATUS gensec_client_start(TALLOC_CTX *mem_ctx,
struct loadparm_context *lp_ctx)
{
NTSTATUS status;
- struct event_context *new_ev = NULL;
-
- if (ev == NULL) {
- new_ev = event_context_init(mem_ctx);
- NT_STATUS_HAVE_NO_MEMORY(new_ev);
- ev = new_ev;
- }
status = gensec_start(mem_ctx, ev, lp_ctx, NULL, gensec_security);
if (!NT_STATUS_IS_OK(status)) {
- talloc_free(new_ev);
return status;
}
- talloc_steal((*gensec_security), new_ev);
(*gensec_security)->gensec_role = GENSEC_CLIENT;
return status;
@@ -1268,6 +1255,12 @@ static int sort_gensec(struct gensec_security_ops **gs1, struct gensec_security_
_PUBLIC_ NTSTATUS gensec_init(struct loadparm_context *lp_ctx)
{
static bool initialized = false;
+ extern NTSTATUS gensec_sasl_init(void);
+ extern NTSTATUS gensec_krb5_init(void);
+ extern NTSTATUS gensec_schannel_init(void);
+ extern NTSTATUS gensec_spnego_init(void);
+ extern NTSTATUS gensec_gssapi_init(void);
+ extern NTSTATUS gensec_ntlmssp_init(void);
init_module_fn static_init[] = { STATIC_gensec_MODULES };
init_module_fn *shared_init;
diff --git a/source4/auth/gensec/gensec_gssapi.c b/source4/auth/gensec/gensec_gssapi.c
index e7dcb4ea68..cc0d40469e 100644
--- a/source4/auth/gensec/gensec_gssapi.c
+++ b/source4/auth/gensec/gensec_gssapi.c
@@ -273,7 +273,9 @@ static NTSTATUS gensec_gssapi_server_start(struct gensec_security *gensec_securi
DEBUG(3, ("No machine account credentials specified\n"));
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
} else {
- ret = cli_credentials_get_server_gss_creds(machine_account, gensec_security->lp_ctx, &gcc);
+ ret = cli_credentials_get_server_gss_creds(machine_account,
+ gensec_security->event_ctx,
+ gensec_security->lp_ctx, &gcc);
if (ret) {
DEBUG(1, ("Aquiring acceptor credentials failed: %s\n",
error_message(ret)));
@@ -359,7 +361,9 @@ static NTSTATUS gensec_gssapi_client_start(struct gensec_security *gensec_securi
return NT_STATUS_INVALID_PARAMETER;
}
- ret = cli_credentials_get_client_gss_creds(creds, gensec_security->lp_ctx, &gcc);
+ ret = cli_credentials_get_client_gss_creds(creds,
+ gensec_security->event_ctx,
+ gensec_security->lp_ctx, &gcc);
switch (ret) {
case 0:
break;
@@ -1323,7 +1327,7 @@ static NTSTATUS gensec_gssapi_session_info(struct gensec_security *gensec_securi
} else if (!lp_parm_bool(gensec_security->lp_ctx, NULL, "gensec", "require_pac", false)) {
DEBUG(1, ("Unable to find PAC, resorting to local user lookup: %s\n",
gssapi_error_string(mem_ctx, maj_stat, min_stat, gensec_gssapi_state->gss_oid)));
- nt_status = sam_get_server_info_principal(mem_ctx, gensec_security->lp_ctx, principal_string,
+ nt_status = sam_get_server_info_principal(mem_ctx, gensec_security->event_ctx, gensec_security->lp_ctx, principal_string,
&server_info);
if (!NT_STATUS_IS_OK(nt_status)) {
@@ -1338,7 +1342,7 @@ static NTSTATUS gensec_gssapi_session_info(struct gensec_security *gensec_securi
}
/* references the server_info into the session_info */
- nt_status = auth_generate_session_info(mem_ctx, gensec_security->lp_ctx, server_info, &session_info);
+ nt_status = auth_generate_session_info(mem_ctx, gensec_security->event_ctx, gensec_security->lp_ctx, server_info, &session_info);
if (!NT_STATUS_IS_OK(nt_status)) {
talloc_free(mem_ctx);
return nt_status;
@@ -1361,12 +1365,12 @@ static NTSTATUS gensec_gssapi_session_info(struct gensec_security *gensec_securi
return NT_STATUS_NO_MEMORY;
}
- cli_credentials_set_event_context(session_info->credentials, gensec_security->event_ctx);
cli_credentials_set_conf(session_info->credentials, gensec_security->lp_ctx);
/* Just so we don't segfault trying to get at a username */
cli_credentials_set_anonymous(session_info->credentials);
ret = cli_credentials_set_client_gss_creds(session_info->credentials,
+ gensec_security->event_ctx,
gensec_security->lp_ctx,
gensec_gssapi_state->delegated_cred_handle,
CRED_SPECIFIED);
diff --git a/source4/auth/gensec/gensec_krb5.c b/source4/auth/gensec/gensec_krb5.c
index ae601b19c2..47df2ccfcc 100644
--- a/source4/auth/gensec/gensec_krb5.c
+++ b/source4/auth/gensec/gensec_krb5.c
@@ -118,7 +118,9 @@ static NTSTATUS gensec_krb5_start(struct gensec_security *gensec_security)
talloc_set_destructor(gensec_krb5_state, gensec_krb5_destroy);
- if (cli_credentials_get_krb5_context(creds, gensec_security->lp_ctx, &gensec_krb5_state->smb_krb5_context)) {
+ if (cli_credentials_get_krb5_context(creds,
+ gensec_security->event_ctx,
+ gensec_security->lp_ctx, &gensec_krb5_state->smb_krb5_context)) {
talloc_free(gensec_krb5_state);
return NT_STATUS_INTERNAL_ERROR;
}
@@ -248,7 +250,9 @@ static NTSTATUS gensec_krb5_client_start(struct gensec_security *gensec_security
principal = gensec_get_target_principal(gensec_security);
- ret = cli_credentials_get_ccache(gensec_get_credentials(gensec_security), gensec_security->lp_ctx, &ccache_container);
+ ret = cli_credentials_get_ccache(gensec_get_credentials(gensec_security),
+ gensec_security->event_ctx,
+ gensec_security->lp_ctx, &ccache_container);
switch (ret) {
case 0:
break;
@@ -446,7 +450,9 @@ static NTSTATUS gensec_krb5_update(struct gensec_security *gensec_security,
}
/* Grab the keytab, however generated */
- ret = cli_credentials_get_keytab(gensec_get_credentials(gensec_security), gensec_security->lp_ctx, &keytab);
+ ret = cli_credentials_get_keytab(gensec_get_credentials(gensec_security),
+ gensec_security->event_ctx,
+ gensec_security->lp_ctx, &keytab);
if (ret) {
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
}
@@ -597,7 +603,7 @@ static NTSTATUS gensec_krb5_session_info(struct gensec_security *gensec_security
DEBUG(5, ("krb5_ticket_get_authorization_data_type failed to find PAC: %s\n",
smb_get_krb5_error_message(context,
ret, mem_ctx)));
- nt_status = sam_get_server_info_principal(mem_ctx, gensec_security->lp_ctx, principal_string,
+ nt_status = sam_get_server_info_principal(mem_ctx, gensec_security->event_ctx, gensec_security->lp_ctx, principal_string,
&server_info);
krb5_free_principal(context, client_principal);
free(principal_string);
@@ -645,7 +651,7 @@ static NTSTATUS gensec_krb5_session_info(struct gensec_security *gensec_security
}
/* references the server_info into the session_info */
- nt_status = auth_generate_session_info(mem_ctx, gensec_security->lp_ctx, server_info, &session_info);
+ nt_status = auth_generate_session_info(mem_ctx, gensec_security->event_ctx, gensec_security->lp_ctx, server_info, &session_info);
if (!NT_STATUS_IS_OK(nt_status)) {
talloc_free(mem_ctx);
diff --git a/source4/auth/gensec/schannel.c b/source4/auth/gensec/schannel.c
index b3117ee9b2..f21202b86f 100644
--- a/source4/auth/gensec/schannel.c
+++ b/source4/auth/gensec/schannel.c
@@ -125,7 +125,8 @@ static NTSTATUS schannel_update(struct gensec_security *gensec_security, TALLOC_
}
/* pull the session key for this client */
- status = schannel_fetch_session_key(out_mem_ctx, gensec_security->lp_ctx, workstation,
+ status = schannel_fetch_session_key(out_mem_ctx, gensec_security->event_ctx,
+ gensec_security->lp_ctx, workstation,
domain, &creds);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(3, ("Could not find session key for attempted schannel connection from %s: %s\n",
@@ -189,7 +190,7 @@ static NTSTATUS schannel_session_info(struct gensec_security *gensec_security,
struct auth_session_info **_session_info)
{
struct schannel_state *state = talloc_get_type(gensec_security->private_data, struct schannel_state);
- return auth_anonymous_session_info(state, gensec_security->lp_ctx, _session_info);
+ return auth_anonymous_session_info(state, gensec_security->event_ctx, gensec_security->lp_ctx, _session_info);
}
static NTSTATUS schannel_start(struct gensec_security *gensec_security)
diff --git a/source4/auth/gensec/schannel_state.c b/source4/auth/gensec/schannel_state.c
index 0c7c509954..0f7c4ca11d 100644
--- a/source4/auth/gensec/schannel_state.c
+++ b/source4/auth/gensec/schannel_state.c
@@ -32,7 +32,8 @@
/**
connect to the schannel ldb
*/
-struct ldb_context *schannel_db_connect(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
+struct ldb_context *schannel_db_connect(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx,
+ struct loadparm_context *lp_ctx)
{
char *path;
struct ldb_context *ldb;
@@ -49,7 +50,7 @@ struct ldb_context *schannel_db_connect(TALLOC_CTX *mem_ctx, struct loadparm_con
existed = file_exist(path);
- ldb = ldb_wrap_connect(mem_ctx, lp_ctx, path,
+ ldb = ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx, path,
system_session(mem_ctx, lp_ctx),
NULL, LDB_FLG_NOSYNC, NULL);
talloc_free(path);
@@ -137,6 +138,7 @@ NTSTATUS schannel_store_session_key_ldb(TALLOC_CTX *mem_ctx,
}
NTSTATUS schannel_store_session_key(TALLOC_CTX *mem_ctx,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
struct creds_CredentialState *creds)
{
@@ -144,7 +146,7 @@ NTSTATUS schannel_store_session_key(TALLOC_CTX *mem_ctx,
NTSTATUS nt_status;
int ret;
- ldb = schannel_db_connect(mem_ctx, lp_ctx);
+ ldb = schannel_db_connect(mem_ctx, ev_ctx, lp_ctx);
if (!ldb) {
return NT_STATUS_ACCESS_DENIED;
}
@@ -268,6 +270,7 @@ NTSTATUS schannel_fetch_session_key_ldb(TALLOC_CTX *mem_ctx,
}
NTSTATUS schannel_fetch_session_key(TALLOC_CTX *mem_ctx,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
const char *computer_name,
const char *domain,
@@ -276,7 +279,7 @@ NTSTATUS schannel_fetch_session_key(TALLOC_CTX *mem_ctx,
NTSTATUS nt_status;
struct ldb_context *ldb;
- ldb = schannel_db_connect(mem_ctx, lp_ctx);
+ ldb = schannel_db_connect(mem_ctx, ev_ctx, lp_ctx);
if (!ldb) {
return NT_STATUS_ACCESS_DENIED;
}
diff --git a/source4/auth/kerberos/config.mk b/source4/auth/kerberos/config.mk
index 7493a6d06d..951e247258 100644
--- a/source4/auth/kerberos/config.mk
+++ b/source4/auth/kerberos/config.mk
@@ -1,14 +1,18 @@
#################################
# Start SUBSYSTEM KERBEROS
[SUBSYSTEM::KERBEROS]
-PRIVATE_PROTO_HEADER = proto.h
-OBJ_FILES = kerberos.o \
- clikrb5.o \
- kerberos_heimdal.o \
- kerberos_pac.o \
- gssapi_parse.o \
- krb5_init_context.o
PUBLIC_DEPENDENCIES = HEIMDAL_KRB5 NDR_KRB5PAC samba-socket LIBCLI_RESOLVE
PRIVATE_DEPENDENCIES = ASN1_UTIL auth_sam_reply LIBPACKET LIBNDR
# End SUBSYSTEM KERBEROS
#################################
+
+KERBEROS_OBJ_FILES = $(addprefix $(authsrcdir)/kerberos/, \
+ kerberos.o \
+ clikrb5.o \
+ kerberos_heimdal.o \
+ kerberos_pac.o \
+ gssapi_parse.o \
+ krb5_init_context.o)
+
+$(eval $(call proto_header_template,$(authsrcdir)/kerberos/proto.h,$(KERBEROS_OBJ_FILES:.o=.c)))
+
diff --git a/source4/auth/auth.c b/source4/auth/ntlm/auth.c
index af3796a70d..0f1ef3ccdb 100644
--- a/source4/auth/auth.c
+++ b/source4/auth/ntlm/auth.c
@@ -21,9 +21,8 @@
#include "includes.h"
#include "lib/util/dlinklist.h"
#include "auth/auth.h"
-#include "auth/auth_proto.h"
+#include "auth/ntlm/auth_proto.h"
#include "lib/events/events.h"
-#include "build.h"
#include "param/param.h"
/***************************************************************************
@@ -516,6 +515,12 @@ const struct auth_critical_sizes *auth_interface_version(void)
_PUBLIC_ NTSTATUS auth_init(void)
{
static bool initialized = false;
+ extern NTSTATUS auth_developer_init(void);
+ extern NTSTATUS auth_winbind_init(void);
+ extern NTSTATUS auth_anonymous_init(void);
+ extern NTSTATUS auth_unix_init(void);
+ extern NTSTATUS auth_sam_init(void);
+ extern NTSTATUS auth_server_init(void);
init_module_fn static_init[] = { STATIC_auth_MODULES };
diff --git a/source4/auth/auth_anonymous.c b/source4/auth/ntlm/auth_anonymous.c
index b93c7c2008..c889071878 100644
--- a/source4/auth/auth_anonymous.c
+++ b/source4/auth/ntlm/auth_anonymous.c
@@ -21,7 +21,7 @@
#include "includes.h"
#include "auth/auth.h"
-#include "auth/auth_proto.h"
+#include "auth/ntlm/auth_proto.h"
#include "param/param.h"
/**
diff --git a/source4/auth/auth_developer.c b/source4/auth/ntlm/auth_developer.c
index a2c9cbc828..3b8c83c349 100644
--- a/source4/auth/auth_developer.c
+++ b/source4/auth/ntlm/auth_developer.c
@@ -21,7 +21,7 @@
#include "includes.h"
#include "auth/auth.h"
-#include "auth/auth_proto.h"
+#include "auth/ntlm/auth_proto.h"
#include "libcli/security/security.h"
#include "librpc/gen_ndr/ndr_samr.h"
diff --git a/source4/auth/ntlm/auth_proto.h b/source4/auth/ntlm/auth_proto.h
new file mode 100644
index 0000000000..572c1a4ca7
--- /dev/null
+++ b/source4/auth/ntlm/auth_proto.h
@@ -0,0 +1,50 @@
+#ifndef __AUTH_NTLM_AUTH_PROTO_H__
+#define __AUTH_NTLM_AUTH_PROTO_H__
+
+#undef _PRINTF_ATTRIBUTE
+#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)
+/* This file was automatically generated by mkproto.pl. DO NOT EDIT */
+
+/* this file contains prototypes for functions that are private
+ * to this subsystem or library. These functions should not be
+ * used outside this particular subsystem! */
+
+
+/* The following definitions come from auth/ntlm/auth.c */
+
+
+/***************************************************************************
+ Set a fixed challenge
+***************************************************************************/
+bool auth_challenge_may_be_modified(struct auth_context *auth_ctx) ;
+const struct auth_operations *auth_backend_byname(const char *name);
+const struct auth_critical_sizes *auth_interface_version(void);
+NTSTATUS server_service_auth_init(void);
+
+/* The following definitions come from auth/ntlm/auth_util.c */
+
+NTSTATUS auth_get_challenge_not_implemented(struct auth_method_context *ctx, TALLOC_CTX *mem_ctx, DATA_BLOB *challenge);
+
+/****************************************************************************
+ Create an auth_usersupplied_data structure after appropriate mapping.
+****************************************************************************/
+NTSTATUS map_user_info(TALLOC_CTX *mem_ctx,
+ const char *default_domain,
+ const struct auth_usersupplied_info *user_info,
+ struct auth_usersupplied_info **user_info_mapped);
+
+/****************************************************************************
+ Create an auth_usersupplied_data structure after appropriate mapping.
+****************************************************************************/
+NTSTATUS encrypt_user_info(TALLOC_CTX *mem_ctx, struct auth_context *auth_context,
+ enum auth_password_state to_state,
+ const struct auth_usersupplied_info *user_info_in,
+ const struct auth_usersupplied_info **user_info_encrypted);
+
+/* The following definitions come from auth/ntlm/auth_simple.c */
+
+#undef _PRINTF_ATTRIBUTE
+#define _PRINTF_ATTRIBUTE(a1, a2)
+
+#endif /* __AUTH_NTLM_AUTH_PROTO_H__ */
+
diff --git a/source4/auth/auth_sam.c b/source4/auth/ntlm/auth_sam.c
index 4b467cee75..2c13cd963d 100644
--- a/source4/auth/auth_sam.c
+++ b/source4/auth/ntlm/auth_sam.c
@@ -25,7 +25,8 @@
#include "lib/ldb/include/ldb.h"
#include "util/util_ldb.h"
#include "auth/auth.h"
-#include "auth/auth_proto.h"
+#include "auth/ntlm/ntlm_check.h"
+#include "auth/ntlm/auth_proto.h"
#include "auth/auth_sam.h"
#include "dsdb/samdb/samdb.h"
#include "libcli/security/security.h"
@@ -289,7 +290,7 @@ static NTSTATUS authsam_check_password_internals(struct auth_method_context *ctx
return NT_STATUS_NO_MEMORY;
}
- sam_ctx = samdb_connect(tmp_ctx, ctx->auth_ctx->lp_ctx, system_session(mem_ctx, ctx->auth_ctx->lp_ctx));
+ sam_ctx = samdb_connect(tmp_ctx, ctx->auth_ctx->event_ctx, ctx->auth_ctx->lp_ctx, system_session(mem_ctx, ctx->auth_ctx->lp_ctx));
if (sam_ctx == NULL) {
talloc_free(tmp_ctx);
return NT_STATUS_INVALID_SYSTEM_SERVICE;
diff --git a/source4/auth/ntlm/auth_server.c b/source4/auth/ntlm/auth_server.c
new file mode 100644
index 0000000000..f154cf0425
--- /dev/null
+++ b/source4/auth/ntlm/auth_server.c
@@ -0,0 +1,225 @@
+/*
+ Unix SMB/CIFS implementation.
+ Authenticate by using a remote server
+ Copyright (C) Andrew Bartlett 2001-2002, 2008
+ Copyright (C) Jelmer Vernooij 2002
+ Copyright (C) Stefan Metzmacher 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 "auth/auth.h"
+#include "auth/ntlm/auth_proto.h"
+#include "auth/credentials/credentials.h"
+#include "libcli/security/security.h"
+#include "librpc/gen_ndr/ndr_samr.h"
+#include "libcli/smb_composite/smb_composite.h"
+#include "param/param.h"
+#include "libcli/resolve/resolve.h"
+
+/* This version of 'security=server' rewirtten from scratch for Samba4
+ * libraries in 2008 */
+
+
+static NTSTATUS server_want_check(struct auth_method_context *ctx,
+ TALLOC_CTX *mem_ctx,
+ const struct auth_usersupplied_info *user_info)
+{
+ return NT_STATUS_OK;
+}
+/**
+ * The challenge from the target server, when operating in security=server
+ **/
+static NTSTATUS server_get_challenge(struct auth_method_context *ctx, TALLOC_CTX *mem_ctx, DATA_BLOB *_blob)
+{
+ struct smb_composite_connect io;
+ struct smbcli_options smb_options;
+ const char **host_list;
+ NTSTATUS status;
+
+ /* Make a connection to the target server, found by 'password server' in smb.conf */
+
+ lp_smbcli_options(ctx->auth_ctx->lp_ctx, &smb_options);
+
+ /* Make a negprot, WITHOUT SPNEGO, so we get a challenge nice an easy */
+ io.in.options.use_spnego = false;
+
+ /* Hope we don't get * (the default), as this won't work... */
+ host_list = lp_passwordserver(ctx->auth_ctx->lp_ctx);
+ if (!host_list) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+ io.in.dest_host = host_list[0];
+ if (strequal(io.in.dest_host, "*")) {
+ return NT_STATUS_INTERNAL_ERROR;
+ }
+ io.in.dest_ports = lp_smb_ports(ctx->auth_ctx->lp_ctx);
+
+ io.in.called_name = strupper_talloc(mem_ctx, io.in.dest_host);
+
+ /* We don't want to get as far as the session setup */
+ io.in.credentials = NULL;
+ io.in.service = NULL;
+
+ io.in.workgroup = ""; /* only used with SPNEGO, disabled above */
+
+ io.in.options = smb_options;
+
+ status = smb_composite_connect(&io, mem_ctx, lp_resolve_context(ctx->auth_ctx->lp_ctx),
+ ctx->auth_ctx->event_ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ *_blob = io.out.tree->session->transport->negotiate.secblob;
+ ctx->private_data = talloc_steal(ctx, io.out.tree->session);
+ }
+ return NT_STATUS_OK;
+}
+
+/**
+ * Return an error based on username
+ *
+ * This function allows the testing of obsure errors, as well as the generation
+ * of NT_STATUS -> DOS error mapping tables.
+ *
+ * This module is of no value to end-users.
+ *
+ * The password is ignored.
+ *
+ * @return An NTSTATUS value based on the username
+ **/
+
+static NTSTATUS server_check_password(struct auth_method_context *ctx,
+ TALLOC_CTX *mem_ctx,
+ const struct auth_usersupplied_info *user_info,
+ struct auth_serversupplied_info **_server_info)
+{
+ NTSTATUS nt_status;
+ struct auth_serversupplied_info *server_info;
+ struct cli_credentials *creds;
+ const char *user;
+ struct smb_composite_sesssetup session_setup;
+
+ struct smbcli_session *session = talloc_get_type(ctx->private_data, struct smbcli_session);
+
+ creds = cli_credentials_init(mem_ctx);
+
+ NT_STATUS_HAVE_NO_MEMORY(creds);
+
+ cli_credentials_set_username(creds, user_info->client.account_name, CRED_SPECIFIED);
+ cli_credentials_set_domain(creds, user_info->client.domain_name, CRED_SPECIFIED);
+
+ switch (user_info->password_state) {
+ case AUTH_PASSWORD_PLAIN:
+ cli_credentials_set_password(creds, user_info->password.plaintext,
+ CRED_SPECIFIED);
+ break;
+ case AUTH_PASSWORD_HASH:
+ cli_credentials_set_nt_hash(creds, user_info->password.hash.nt,
+ CRED_SPECIFIED);
+ break;
+
+ case AUTH_PASSWORD_RESPONSE:
+ cli_credentials_set_ntlm_response(creds, &user_info->password.response.lanman, &user_info->password.response.nt, CRED_SPECIFIED);
+ break;
+ }
+
+ session_setup.in.sesskey = session->transport->negotiate.sesskey;
+ session_setup.in.capabilities = session->transport->negotiate.capabilities;
+
+ session_setup.in.credentials = creds;
+ session_setup.in.workgroup = ""; /* Only used with SPNEGO, which we are not doing */
+
+ /* Check password with remove server - this should be async some day */
+ nt_status = smb_composite_sesssetup(session, &session_setup);
+
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ return nt_status;
+ }
+
+ server_info = talloc(mem_ctx, struct auth_serversupplied_info);
+ NT_STATUS_HAVE_NO_MEMORY(server_info);
+
+ server_info->account_sid = dom_sid_parse_talloc(server_info, SID_NT_ANONYMOUS);
+ NT_STATUS_HAVE_NO_MEMORY(server_info->account_sid);
+
+ /* is this correct? */
+ server_info->primary_group_sid = dom_sid_parse_talloc(server_info, SID_BUILTIN_GUESTS);
+ NT_STATUS_HAVE_NO_MEMORY(server_info->primary_group_sid);
+
+ server_info->n_domain_groups = 0;
+ server_info->domain_groups = NULL;
+
+ /* annoying, but the Anonymous really does have a session key,
+ and it is all zeros! */
+ server_info->user_session_key = data_blob(NULL, 0);
+ server_info->lm_session_key = data_blob(NULL, 0);
+
+ server_info->account_name = talloc_strdup(server_info, user_info->client.account_name);
+ NT_STATUS_HAVE_NO_MEMORY(server_info->account_name);
+
+ server_info->domain_name = talloc_strdup(server_info, user_info->client.domain_name);
+ NT_STATUS_HAVE_NO_MEMORY(server_info->domain_name);
+
+ server_info->full_name = NULL;
+
+ server_info->logon_script = talloc_strdup(server_info, "");
+ NT_STATUS_HAVE_NO_MEMORY(server_info->logon_script);
+
+ server_info->profile_path = talloc_strdup(server_info, "");
+ NT_STATUS_HAVE_NO_MEMORY(server_info->profile_path);
+
+ server_info->home_directory = talloc_strdup(server_info, "");
+ NT_STATUS_HAVE_NO_MEMORY(server_info->home_directory);
+
+ server_info->home_drive = talloc_strdup(server_info, "");
+ NT_STATUS_HAVE_NO_MEMORY(server_info->home_drive);
+
+ server_info->last_logon = 0;
+ server_info->last_logoff = 0;
+ server_info->acct_expiry = 0;
+ server_info->last_password_change = 0;
+ server_info->allow_password_change = 0;
+ server_info->force_password_change = 0;
+
+ server_info->logon_count = 0;
+ server_info->bad_password_count = 0;
+
+ server_info->acct_flags = ACB_NORMAL;
+
+ server_info->authenticated = false;
+
+ *_server_info = server_info;
+
+ return nt_status;
+}
+
+static const struct auth_operations server_auth_ops = {
+ .name = "server",
+ .get_challenge = server_get_challenge,
+ .want_check = server_want_check,
+ .check_password = server_check_password
+};
+
+_PUBLIC_ NTSTATUS auth_server_init(void)
+{
+ NTSTATUS ret;
+
+ ret = auth_register(&server_auth_ops);
+ if (!NT_STATUS_IS_OK(ret)) {
+ DEBUG(0,("Failed to register 'server' auth backend!\n"));
+ return ret;
+ }
+
+ return ret;
+}
diff --git a/source4/auth/auth_simple.c b/source4/auth/ntlm/auth_simple.c
index 50be02a353..e7039c3657 100644
--- a/source4/auth/auth_simple.c
+++ b/source4/auth/ntlm/auth_simple.c
@@ -90,7 +90,7 @@ _PUBLIC_ NTSTATUS authenticate_username_pw(TALLOC_CTX *mem_ctx,
}
if (session_info) {
- nt_status = auth_generate_session_info(tmp_ctx, lp_ctx, server_info, session_info);
+ nt_status = auth_generate_session_info(tmp_ctx, ev, lp_ctx, server_info, session_info);
if (NT_STATUS_IS_OK(nt_status)) {
talloc_steal(mem_ctx, *session_info);
diff --git a/source4/auth/auth_unix.c b/source4/auth/ntlm/auth_unix.c
index a417107025..1717b9d0e1 100644
--- a/source4/auth/auth_unix.c
+++ b/source4/auth/ntlm/auth_unix.c
@@ -21,10 +21,10 @@
#include "includes.h"
#include "auth/auth.h"
-#include "auth/auth_proto.h"
+#include "auth/ntlm/auth_proto.h"
#include "system/passwd.h" /* needed by some systems for struct passwd */
#include "lib/socket/socket.h"
-#include "auth/pam_errors.h"
+#include "auth/ntlm/pam_errors.h"
#include "param/param.h"
/* TODO: look at how to best fill in parms retrieveing a struct passwd info
diff --git a/source4/auth/auth_util.c b/source4/auth/ntlm/auth_util.c
index 1d86b858cf..1d86b858cf 100644
--- a/source4/auth/auth_util.c
+++ b/source4/auth/ntlm/auth_util.c
diff --git a/source4/auth/auth_winbind.c b/source4/auth/ntlm/auth_winbind.c
index 149f549afa..ac63b242e4 100644
--- a/source4/auth/auth_winbind.c
+++ b/source4/auth/ntlm/auth_winbind.c
@@ -23,7 +23,7 @@
#include "includes.h"
#include "auth/auth.h"
-#include "auth/auth_proto.h"
+#include "auth/ntlm/auth_proto.h"
#include "auth/session_proto.h"
#include "nsswitch/winbind_client.h"
#include "librpc/gen_ndr/ndr_netlogon.h"
diff --git a/source4/auth/ntlm/config.mk b/source4/auth/ntlm/config.mk
new file mode 100644
index 0000000000..f31c2b7279
--- /dev/null
+++ b/source4/auth/ntlm/config.mk
@@ -0,0 +1,86 @@
+# NTLM auth server subsystem
+
+[SUBSYSTEM::ntlm_check]
+PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL
+
+ntlm_check_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, ntlm_check.o)
+
+#######################
+# Start MODULE auth_sam
+[MODULE::auth_sam_module]
+# gensec_krb5 and gensec_gssapi depend on it
+INIT_FUNCTION = auth_sam_init
+SUBSYSTEM = auth
+PRIVATE_DEPENDENCIES = \
+ SAMDB auth_sam ntlm_check
+# End MODULE auth_sam
+#######################
+
+auth_sam_module_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth_sam.o)
+
+#######################
+# Start MODULE auth_anonymous
+[MODULE::auth_anonymous]
+INIT_FUNCTION = auth_anonymous_init
+SUBSYSTEM = auth
+# End MODULE auth_anonymous
+#######################
+
+auth_anonymous_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth_anonymous.o)
+
+#######################
+# Start MODULE auth_anonymous
+[MODULE::auth_server]
+INIT_FUNCTION = auth_server_init
+SUBSYSTEM = auth
+PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBCLI_SMB
+OUTPUT_TYPE = SHARED_LIBRARY
+# End MODULE auth_server
+#######################
+
+auth_server_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth_server.o)
+
+#######################
+# Start MODULE auth_winbind
+[MODULE::auth_winbind]
+INIT_FUNCTION = auth_winbind_init
+SUBSYSTEM = auth
+PRIVATE_DEPENDENCIES = NDR_WINBIND MESSAGING LIBWINBIND-CLIENT
+# End MODULE auth_winbind
+#######################
+
+auth_winbind_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth_winbind.o)
+
+#######################
+# Start MODULE auth_developer
+[MODULE::auth_developer]
+INIT_FUNCTION = auth_developer_init
+SUBSYSTEM = auth
+# End MODULE auth_developer
+#######################
+
+auth_developer_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth_developer.o)
+
+[MODULE::auth_unix]
+INIT_FUNCTION = auth_unix_init
+SUBSYSTEM = auth
+PRIVATE_DEPENDENCIES = CRYPT PAM PAM_ERRORS NSS_WRAPPER
+
+auth_unix_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth_unix.o)
+
+[SUBSYSTEM::PAM_ERRORS]
+
+#VERSION = 0.0.1
+#SO_VERSION = 0
+PAM_ERRORS_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, pam_errors.o)
+
+[MODULE::auth]
+INIT_FUNCTION = server_service_auth_init
+SUBSYSTEM = service
+PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBSECURITY SAMDB CREDENTIALS
+
+auth_OBJ_FILES = $(addprefix $(authsrcdir)/ntlm/, auth.o auth_util.o auth_simple.o)
+$(eval $(call proto_header_template,$(authsrcdir)/auth_proto.h,$(auth_OBJ_FILES:.o=.c)))
+
+# PUBLIC_HEADERS += auth/auth.h
+
diff --git a/source4/auth/ntlm_check.c b/source4/auth/ntlm/ntlm_check.c
index 55f2595f44..0dbbce0edc 100644
--- a/source4/auth/ntlm_check.c
+++ b/source4/auth/ntlm/ntlm_check.c
@@ -24,6 +24,7 @@
#include "librpc/gen_ndr/netlogon.h"
#include "libcli/auth/libcli_auth.h"
#include "param/param.h"
+#include "auth/ntlm/ntlm_check.h"
/****************************************************************************
Core of smb password checking routine.
diff --git a/source4/auth/ntlm/ntlm_check.h b/source4/auth/ntlm/ntlm_check.h
new file mode 100644
index 0000000000..eb115b74d6
--- /dev/null
+++ b/source4/auth/ntlm/ntlm_check.h
@@ -0,0 +1,75 @@
+/*
+ Unix SMB/CIFS implementation.
+ Password and authentication handling
+ Copyright (C) Andrew Bartlett <abartlet@samba.org> 2001-2004
+ Copyright (C) Gerald Carter 2003
+ Copyright (C) Luke Kenneth Casson Leighton 1996-2000
+
+ 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/>.
+*/
+
+
+/**
+ * Compare password hashes against those from the SAM
+ *
+ * @param mem_ctx talloc context
+ * @param client_lanman LANMAN password hash, as supplied by the client
+ * @param client_nt NT (MD4) password hash, as supplied by the client
+ * @param username internal Samba username, for log messages
+ * @param client_username username the client used
+ * @param client_domain domain name the client used (may be mapped)
+ * @param stored_lanman LANMAN password hash, as stored on the SAM
+ * @param stored_nt NT (MD4) password hash, as stored on the SAM
+ * @param user_sess_key User session key
+ * @param lm_sess_key LM session key (first 8 bytes of the LM hash)
+ */
+
+NTSTATUS hash_password_check(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
+ const struct samr_Password *client_lanman,
+ const struct samr_Password *client_nt,
+ const char *username,
+ const struct samr_Password *stored_lanman,
+ const struct samr_Password *stored_nt);
+
+/**
+ * Check a challenge-response password against the value of the NT or
+ * LM password hash.
+ *
+ * @param mem_ctx talloc context
+ * @param challenge 8-byte challenge. If all zero, forces plaintext comparison
+ * @param nt_response 'unicode' NT response to the challenge, or unicode password
+ * @param lm_response ASCII or LANMAN response to the challenge, or password in DOS code page
+ * @param username internal Samba username, for log messages
+ * @param client_username username the client used
+ * @param client_domain domain name the client used (may be mapped)
+ * @param stored_lanman LANMAN ASCII password from our passdb or similar
+ * @param stored_nt MD4 unicode password from our passdb or similar
+ * @param user_sess_key User session key
+ * @param lm_sess_key LM session key (first 8 bytes of the LM hash)
+ */
+
+NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
+ struct loadparm_context *lp_ctx,
+ uint32_t logon_parameters,
+ const DATA_BLOB *challenge,
+ const DATA_BLOB *lm_response,
+ const DATA_BLOB *nt_response,
+ const char *username,
+ const char *client_username,
+ const char *client_domain,
+ const struct samr_Password *stored_lanman,
+ const struct samr_Password *stored_nt,
+ DATA_BLOB *user_sess_key,
+ DATA_BLOB *lm_sess_key);
diff --git a/source4/auth/pam_errors.c b/source4/auth/ntlm/pam_errors.c
index 9774ad8727..9774ad8727 100644
--- a/source4/auth/pam_errors.c
+++ b/source4/auth/ntlm/pam_errors.c
diff --git a/source4/auth/ntlm/pam_errors.h b/source4/auth/ntlm/pam_errors.h
new file mode 100644
index 0000000000..959e1f3517
--- /dev/null
+++ b/source4/auth/ntlm/pam_errors.h
@@ -0,0 +1,47 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * PAM error mapping functions
+ * Copyright (C) Andrew Bartlett 2002
+ *
+ * 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 __AUTH_NTLM_PAM_ERRORS_H__
+#define __AUTH_NTLM_PAM_ERRORS_H__
+
+/* The following definitions come from auth/pam_errors.c */
+
+
+/*****************************************************************************
+convert a PAM error to a NT status32 code
+ *****************************************************************************/
+NTSTATUS pam_to_nt_status(int pam_error);
+
+/*****************************************************************************
+convert an NT status32 code to a PAM error
+ *****************************************************************************/
+int nt_status_to_pam(NTSTATUS nt_status);
+
+/*****************************************************************************
+convert a PAM error to a NT status32 code
+ *****************************************************************************/
+NTSTATUS pam_to_nt_status(int pam_error);
+
+/*****************************************************************************
+convert an NT status32 code to a PAM error
+ *****************************************************************************/
+int nt_status_to_pam(NTSTATUS nt_status);
+
+#endif /* __AUTH_NTLM_PAM_ERRORS_H__ */
+
diff --git a/source4/auth/ntlmssp/config.mk b/source4/auth/ntlmssp/config.mk
index 9033384b1f..129f58de83 100644
--- a/source4/auth/ntlmssp/config.mk
+++ b/source4/auth/ntlmssp/config.mk
@@ -1,18 +1,19 @@
[SUBSYSTEM::MSRPC_PARSE]
-PRIVATE_PROTO_HEADER = msrpc_parse.h
-OBJ_FILES = ntlmssp_parse.o
+
+MSRPC_PARSE_OBJ_FILES = $(addprefix $(authsrcdir)/ntlmssp/, ntlmssp_parse.o)
+
+$(eval $(call proto_header_template,$(authsrcdir)/ntlmssp/msrpc_parse.h,$(MSRPC_PARSE_OBJ_FILES:.o=.c)))
################################################
# Start MODULE gensec_ntlmssp
[MODULE::gensec_ntlmssp]
SUBSYSTEM = gensec
INIT_FUNCTION = gensec_ntlmssp_init
-PRIVATE_PROTO_HEADER = proto.h
-OBJ_FILES = ntlmssp.o \
- ntlmssp_sign.o \
- ntlmssp_client.o \
- ntlmssp_server.o
-PRIVATE_DEPENDENCIES = MSRPC_PARSE CREDENTIALS
+PRIVATE_DEPENDENCIES = MSRPC_PARSE CREDENTIALS auth
OUTPUT_TYPE = MERGED_OBJ
# End MODULE gensec_ntlmssp
################################################
+
+gensec_ntlmssp_OBJ_FILES = $(addprefix $(authsrcdir)/ntlmssp/, ntlmssp.o ntlmssp_sign.o ntlmssp_client.o ntlmssp_server.o)
+
+$(eval $(call proto_header_template,$(authsrcdir)/ntlmssp/proto.h,$(gensec_ntlmssp_OBJ_FILES:.o=.c)))
diff --git a/source4/auth/ntlmssp/ntlmssp.c b/source4/auth/ntlmssp/ntlmssp.c
index 64bfebd3d1..0b7f0da9af 100644
--- a/source4/auth/ntlmssp/ntlmssp.c
+++ b/source4/auth/ntlmssp/ntlmssp.c
@@ -29,7 +29,7 @@
#include "auth/gensec/gensec.h"
#include "auth/gensec/gensec_proto.h"
#include "auth/auth.h"
-#include "auth/auth_proto.h"
+#include "auth/ntlm/auth_proto.h"
#include "param/param.h"
/**
diff --git a/source4/auth/ntlmssp/ntlmssp_server.c b/source4/auth/ntlmssp/ntlmssp_server.c
index 12802b7e79..dfc5940d99 100644
--- a/source4/auth/ntlmssp/ntlmssp_server.c
+++ b/source4/auth/ntlmssp/ntlmssp_server.c
@@ -30,7 +30,7 @@
#include "auth/credentials/credentials.h"
#include "auth/gensec/gensec.h"
#include "auth/auth.h"
-#include "auth/auth_proto.h"
+#include "auth/ntlm/auth_proto.h"
#include "param/param.h"
#include "auth/session_proto.h"
@@ -725,7 +725,7 @@ NTSTATUS gensec_ntlmssp_session_info(struct gensec_security *gensec_security,
NTSTATUS nt_status;
struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
- nt_status = auth_generate_session_info(gensec_ntlmssp_state, gensec_security->lp_ctx, gensec_ntlmssp_state->server_info, session_info);
+ nt_status = auth_generate_session_info(gensec_ntlmssp_state, gensec_security->event_ctx, gensec_security->lp_ctx, gensec_ntlmssp_state->server_info, session_info);
NT_STATUS_NOT_OK_RETURN(nt_status);
(*session_info)->session_key = data_blob_talloc(*session_info,
diff --git a/source4/auth/sam.c b/source4/auth/sam.c
index ed44754993..a2090afcdc 100644
--- a/source4/auth/sam.c
+++ b/source4/auth/sam.c
@@ -428,6 +428,7 @@ NTSTATUS sam_get_results_principal(struct ldb_context *sam_ctx,
/* Used in the gensec_gssapi and gensec_krb5 server-side code, where the PAC isn't available */
NTSTATUS sam_get_server_info_principal(TALLOC_CTX *mem_ctx,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
const char *principal,
struct auth_serversupplied_info **server_info)
@@ -445,7 +446,7 @@ NTSTATUS sam_get_server_info_principal(TALLOC_CTX *mem_ctx,
return NT_STATUS_NO_MEMORY;
}
- sam_ctx = samdb_connect(tmp_ctx, lp_ctx, system_session(tmp_ctx, lp_ctx));
+ sam_ctx = samdb_connect(tmp_ctx, event_ctx, lp_ctx, system_session(tmp_ctx, lp_ctx));
if (sam_ctx == NULL) {
talloc_free(tmp_ctx);
return NT_STATUS_INVALID_SYSTEM_SERVICE;
diff --git a/source4/auth/session.c b/source4/auth/session.c
index 112eac95d8..8f5e8d6c56 100644
--- a/source4/auth/session.c
+++ b/source4/auth/session.c
@@ -31,11 +31,12 @@
#include "auth/session_proto.h"
_PUBLIC_ struct auth_session_info *anonymous_session(TALLOC_CTX *mem_ctx,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx)
{
NTSTATUS nt_status;
struct auth_session_info *session_info = NULL;
- nt_status = auth_anonymous_session_info(mem_ctx, lp_ctx, &session_info);
+ nt_status = auth_anonymous_session_info(mem_ctx, event_ctx, lp_ctx, &session_info);
if (!NT_STATUS_IS_OK(nt_status)) {
return NULL;
}
@@ -43,6 +44,7 @@ _PUBLIC_ struct auth_session_info *anonymous_session(TALLOC_CTX *mem_ctx,
}
_PUBLIC_ NTSTATUS auth_anonymous_session_info(TALLOC_CTX *parent_ctx,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct auth_session_info **_session_info)
{
@@ -60,7 +62,7 @@ _PUBLIC_ NTSTATUS auth_anonymous_session_info(TALLOC_CTX *parent_ctx,
}
/* references the server_info into the session_info */
- nt_status = auth_generate_session_info(parent_ctx, lp_ctx, server_info, &session_info);
+ nt_status = auth_generate_session_info(parent_ctx, event_ctx, lp_ctx, server_info, &session_info);
talloc_free(mem_ctx);
NT_STATUS_NOT_OK_RETURN(nt_status);
@@ -151,6 +153,7 @@ _PUBLIC_ NTSTATUS auth_anonymous_server_info(TALLOC_CTX *mem_ctx,
}
_PUBLIC_ NTSTATUS auth_generate_session_info(TALLOC_CTX *mem_ctx,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct auth_serversupplied_info *server_info,
struct auth_session_info **_session_info)
@@ -168,6 +171,7 @@ _PUBLIC_ NTSTATUS auth_generate_session_info(TALLOC_CTX *mem_ctx,
session_info->session_key = server_info->user_session_key;
nt_status = security_token_create(session_info,
+ event_ctx,
lp_ctx,
server_info->account_sid,
server_info->primary_group_sid,
diff --git a/source4/auth/session.h b/source4/auth/session.h
index 87fc47791a..933b14a1b4 100644
--- a/source4/auth/session.h
+++ b/source4/auth/session.h
@@ -1,6 +1,6 @@
/*
Unix SMB/CIFS implementation.
- Auth session handling
+ Process and provide the logged on user's authorization token
Copyright (C) Andrew Bartlett 2001
Copyright (C) Stefan Metzmacher 2005
@@ -30,12 +30,23 @@ struct auth_session_info {
#include "librpc/gen_ndr/netlogon.h"
-struct auth_session_info *system_session_anon(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx);
+/* Create a security token for a session SYSTEM (the most
+ * trusted/prvilaged account), including the local machine account as
+ * the off-host credentials */
struct auth_session_info *system_session(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx) ;
+
+/*
+ * Create a system session, but with anonymous credentials (so we do
+ * not need to open secrets.ldb)
+ */
+struct auth_session_info *system_session_anon(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx);
+
+
NTSTATUS auth_anonymous_server_info(TALLOC_CTX *mem_ctx,
const char *netbios_name,
struct auth_serversupplied_info **_server_info) ;
NTSTATUS auth_generate_session_info(TALLOC_CTX *mem_ctx,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct auth_serversupplied_info *server_info,
struct auth_session_info **_session_info) ;
@@ -46,10 +57,12 @@ NTSTATUS make_server_info_netlogon_validation(TALLOC_CTX *mem_ctx,
union netr_Validation *validation,
struct auth_serversupplied_info **_server_info);
NTSTATUS auth_anonymous_session_info(TALLOC_CTX *parent_ctx,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
struct auth_session_info **_session_info);
struct auth_session_info *anonymous_session(TALLOC_CTX *mem_ctx,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx);
diff --git a/source4/auth/system_session.c b/source4/auth/system_session.c
index e99bbbb1ab..1d227fe468 100644
--- a/source4/auth/system_session.c
+++ b/source4/auth/system_session.c
@@ -147,9 +147,10 @@ static NTSTATUS generate_session_info(TALLOC_CTX *mem_ctx,
-/**
- Create a system session, with machine account credentials
-*/
+/* Create a security token for a session SYSTEM (the most
+ * trusted/prvilaged account), including the local machine account as
+ * the off-host credentials
+ */
_PUBLIC_ struct auth_session_info *system_session(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
{
NTSTATUS nt_status;
diff --git a/source4/auth/tests/bindings.py b/source4/auth/tests/bindings.py
index 4a4b12bf69..b7a5994675 100644
--- a/source4/auth/tests/bindings.py
+++ b/source4/auth/tests/bindings.py
@@ -24,7 +24,7 @@ the functionality, that's already done in other tests.
"""
import unittest
-import auth
+from samba import auth
class AuthTests(unittest.TestCase):
def test_system_session(self):
diff --git a/source4/build/m4/check_ld.m4 b/source4/build/m4/check_ld.m4
index 0d0742e5d2..3a74ffc239 100644
--- a/source4/build/m4/check_ld.m4
+++ b/source4/build/m4/check_ld.m4
@@ -151,36 +151,12 @@ if test $BLDSHARED = true; then
ac_cv_shmod_works=yes
rm -f shlib.${SHLIBEXT} shlib.o
])
- if test $ac_cv_shlib_works = no -o $ac_cv_shmod_works = no; then
- BLDSHARED=false
+ if test $ac_cv_shlib_works = no; then
+ AC_MSG_ERROR(unable to build shared libraries)
+ fi
+ if test $ac_cv_shmod_works = no; then
+ AC_MSG_ERROR(unable to build shared modules)
fi
-fi
-
-if test $BLDSHARED != true; then
- SHLD="shared-libraries-disabled"
- SHLD_FLAGS="shared-libraries-disabled"
- MDLD="shared-modules-disabled"
- MDLD_FLAGS="shared-modules-disabled"
- SHLIBEXT="shared_libraries_disabled"
- SONAMEFLAG="shared-libraries-disabled"
- PICFLAG=""
- AC_MSG_CHECKING([SHLD])
- AC_MSG_RESULT([$SHLD])
- AC_MSG_CHECKING([SHLD_FLAGS])
- AC_MSG_RESULT([$SHLD_FLAGS])
-
- AC_MSG_CHECKING([MDLD])
- AC_MSG_RESULT([$MDLD])
- AC_MSG_CHECKING([MDLD_FLAGS])
- AC_MSG_RESULT([$MDLD_FLAGS])
-
- AC_MSG_CHECKING([SHLIBEXT])
- AC_MSG_RESULT([$SHLIBEXT])
- AC_MSG_CHECKING([SONAMEFLAG])
- AC_MSG_RESULT([$SONAMEFLAG])
-
- AC_MSG_CHECKING([PICFLAG])
- AC_MSG_RESULT([$PICFLAG])
fi
AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
diff --git a/source4/build/m4/public.m4 b/source4/build/m4/public.m4
index eb673446c7..d932f09a69 100644
--- a/source4/build/m4/public.m4
+++ b/source4/build/m4/public.m4
@@ -4,8 +4,6 @@ dnl Copyright (C) 2004 Stefan Metzmacher
dnl Copyright (C) 2004-2005 Jelmer Vernooij
dnl Published under the GPL
dnl
-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)
@@ -14,6 +12,10 @@ dnl SMB_ENABLE(name,default_build)
dnl
dnl SMB_INCLUDE_MK(file)
dnl
+dnl SMB_WRITE_MAKEVARS(file)
+dnl
+dnl SMB_WRITE_PERLVARS(file)
+dnl
dnl #######################################################
dnl ### And now the implementation ###
dnl #######################################################
@@ -22,16 +24,15 @@ 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
+$1_OBJ_FILES = $2
"
SMB_INFO_SUBSYSTEMS="$SMB_INFO_SUBSYSTEMS
###################################
# Start Subsystem $1
@<:@SUBSYSTEM::$1@:>@
-OBJ_FILES = \$($1_OBJ_FILES)
PRIVATE_DEPENDENCIES = $3
CFLAGS = \$($1_CFLAGS)
ENABLE = YES
@@ -40,24 +41,21 @@ ENABLE = YES
"
])
-dnl SMB_LIBRARY(name,obj_files,required_subsystems,version,so_version,cflags,ldflags)
+dnl SMB_LIBRARY(name,obj_files,required_subsystems,cflags,ldflags)
AC_DEFUN([SMB_LIBRARY],
[
MAKE_SETTINGS="$MAKE_SETTINGS
-$1_OBJ_FILES = $2
$1_CFLAGS = $6
$1_LDFLAGS = $7
-$1_ENABLE = YES
+n1_ENABLE = YES
+$1_OBJ_FILES = $2
"
SMB_INFO_LIBRARIES="$SMB_INFO_LIBRARIES
###################################
# Start Library $1
@<:@LIBRARY::$1@:>@
-OBJ_FILES = \$($1_OBJ_FILES)
PRIVATE_DEPENDENCIES = $3
-VERSION = $4
-SO_VERSION = $5
CFLAGS = \$($1_CFLAGS)
LDFLAGS = \$($1_LDFLAGS)
ENABLE = YES
@@ -156,3 +154,70 @@ $1_ENABLE = $2
SMB_INFO_ENABLES="$SMB_INFO_ENABLES
\$enabled{$1} = \"$2\";"
])
+
+dnl SMB_WRITE_MAKEVARS(path)
+AC_DEFUN([SMB_WRITE_MAKEVARS],
+[
+echo "configure: creating $1"
+cat >$1<<CEOF
+# $1 - Autogenerated by configure, DO NOT EDIT!
+AC_FOREACH([AC_Var], m4_defn([_AC_SUBST_VARS]), [
+AC_Var = $AC_Var])
+$MAKE_SETTINGS
+CEOF
+])
+
+dnl SMB_WRITE_PERLVARS(path)
+AC_DEFUN([SMB_WRITE_PERLVARS],
+[
+echo "configure: creating $1"
+cat >$1<<CEOF
+# config.pm - Autogenerate by configure. DO NOT EDIT!
+
+package config;
+require Exporter;
+@ISA = qw(Exporter);
+@EXPORT_OK = qw(%enabled %config);
+use strict;
+
+use vars qw(%enabled %config);
+
+%config = (AC_FOREACH([AC_Var], m4_defn([_AC_SUBST_VARS]), [
+ AC_Var => '$AC_Var',])
+);
+
+$SMB_INFO_ENABLES
+1;
+CEOF
+])
+
+dnl SMB_BUILD_RUN(OUTPUT_FILE)
+AC_DEFUN([SMB_BUILD_RUN],
+[
+AC_OUTPUT_COMMANDS(
+[
+test "x$ac_abs_srcdir" != "x$ac_abs_builddir" && (
+ cd $builddir;
+ # NOTE: We *must* use -R so we don't follow symlinks (at least on BSD
+ # systems).
+ test -d heimdal || cp -R $srcdir/heimdal $builddir/
+ test -d heimdal_build || cp -R $srcdir/heimdal_build $builddir/
+ test -d build || builddir="$builddir" \
+ srcdir="$srcdir" \
+ $PERL ${srcdir}/script/buildtree.pl
+ )
+
+$PERL -I${builddir} -I${builddir}/build \
+ -I${srcdir} -I${srcdir}/build \
+ ${srcdir}/build/smb_build/main.pl --output=$1 main.mk || exit $?
+],
+[
+srcdir="$srcdir"
+builddir="$builddir"
+PERL="$PERL"
+
+export PERL
+export srcdir
+export builddir
+])
+])
diff --git a/source4/script/lex_compile.sh b/source4/build/make/lex_compile.sh
index 9bba7257b1..9bba7257b1 100755
--- a/source4/script/lex_compile.sh
+++ b/source4/build/make/lex_compile.sh
diff --git a/source4/build/make/python.mk b/source4/build/make/python.mk
new file mode 100644
index 0000000000..66e5def8f0
--- /dev/null
+++ b/source4/build/make/python.mk
@@ -0,0 +1,66 @@
+pythonbuilddir = $(builddir)/bin/python
+
+installpython::
+ mkdir -p $(DESTDIR)$(pythondir)
+
+# Install Python
+# Arguments: Module path
+define python_module_template
+
+installpython:: $$(pythonbuilddir)/$(1) ;
+ mkdir -p $$(DESTDIR)$$(pythondir)/$$(dir $(1))
+ cp $$< $$(DESTDIR)$$(pythondir)/$(1)
+
+uninstallpython::
+ rm -f $$(DESTDIR)$$(pythondir)/$(1) ;
+
+pythonmods:: $$(pythonbuilddir)/$(1) ;
+
+endef
+
+define python_py_module_template
+
+$$(pythonbuilddir)/$(1): $(2) ;
+ mkdir -p $$(@D)
+ cp $$< $$@
+
+$(call python_module_template,$(1))
+
+endef
+
+# Python C module
+# Arguments: File name, dependencies, link list
+define python_c_module_template
+
+$$(pythonbuilddir)/$(1): $(2) ;
+ @echo Linking $$@
+ @mkdir -p $$(@D)
+ @$$(MDLD) $$(LDFLAGS) $$(MDLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
+
+$(call python_module_template,$(1))
+endef
+
+# Swig extensions
+swig:: pythonmods
+
+.SUFFIXES: _wrap.c .i .py
+
+%_wrap.c %.py: %.i
+ [ "$(SWIG)" == "no" ] || $(SWIG) -O -Wall -I$(srcdir)/scripting/swig -python -keyword $<
+
+realdistclean::
+ @echo "Removing SWIG output files"
+ # FIXME: Remove _wrap.c files
+
+pythonmods::
+
+clean::
+ @echo "Removing python modules"
+ @rm -rf $(pythonbuilddir)
+
+pydoctor:: pythonmods
+ LD_LIBRARY_PATH=bin/shared PYTHONPATH=$(pythonbuilddir) pydoctor --project-name=Samba --project-url=http://www.samba.org --make-html --docformat=restructuredtext --add-package $(pythonbuilddir)/samba
+
+bin/python/%.py:
+ mkdir -p $(@D)
+ cp $< $@
diff --git a/source4/rules.mk b/source4/build/make/rules.mk
index 5f91f8132e..176e67a691 100644
--- a/source4/rules.mk
+++ b/source4/build/make/rules.mk
@@ -1,3 +1,6 @@
+# Rules file for Samba 4
+# This relies on GNU make.
+#
# Dependencies command
DEPENDS = $(CC) -M -MG -MP -MT $(<:.c=.o) -MT $@ \
$(CFLAGS) $(CPPFLAGS) $< -o $@
@@ -26,22 +29,14 @@ PCHCOMPILE = @$(CC) -Ilib/replace \
# Partial linking
PARTLINK = @$(PROG_LD) -r
+make_utility_dir = $(srcdir)/build/make/
+
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
+pch::
clean:: clean_pch
@echo Removing objects
@@ -51,7 +46,7 @@ clean:: clean_pch
@echo Removing binaries
@-rm -f $(BIN_PROGS) $(SBIN_PROGS) $(BINARIES) $(TORTURE_PROGS)
@echo Removing libraries
- @-rm -f $(STATIC_LIBRARIES) $(SHARED_LIBRARIES)
+ @-rm -f $(STATIC_LIBS) $(SHARED_LIBS)
@-rm -f bin/static/*.a bin/shared/*.$(SHLIBEXT) bin/mergedobj/*.o
@echo Removing modules
@-rm -f bin/modules/*/*.$(SHLIBEXT)
@@ -61,8 +56,6 @@ clean:: clean_pch
@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
@@ -93,6 +86,8 @@ unused_macros:
@mkdir -p $(@D)
@$(STLD) $(STLD_FLAGS) $@ $^
+include build/make/templates.mk
+
###############################################################################
# File types
###############################################################################
@@ -120,17 +115,15 @@ include/includes.d: include/includes.h
@-mkdir -p `dirname $@`
@$(COMPILE) && exit 0 ; \
echo "The following command failed:" 1>&2;\
- $(COMPILE) >/dev/null 2>&1
-
+ echo "$(subst ",\",$(COMPILE))" 1>&2 && exit 1
-# echo "$(COMPILE)" 1>&2;\
.c.ho:
@echo "Compiling $< with host compiler"
@-mkdir -p `dirname $@`
@$(HCOMPILE) && exit 0;\
echo "The following command failed:" 1>&2;\
- echo "$(HCOMPILE)" 1>&2;\
+ echo "$(subst ",\",$(HCOMPILE))" 1>&2;\
$(HCOMPILE) >/dev/null 2>&1
.h.h.gch:
@@ -139,11 +132,18 @@ include/includes.d: include/includes.h
.y.c:
@echo "Building $< with $(YACC)"
- @-$(srcdir)/script/yacc_compile.sh "$(YACC)" "$<" "$@"
+ @-$(make_utility_dir)/yacc_compile.sh "$(YACC)" "$<" "$@"
.l.c:
@echo "Building $< with $(LEX)"
- @-$(srcdir)/script/lex_compile.sh "$(LEX)" "$<" "$@"
+ @-$(make_utility_dir)/lex_compile.sh "$(LEX)" "$<" "$@"
+
+%.a:
+ @echo Linking $@
+ @rm -f $@
+ @mkdir -p $(@D)
+ @$(STLD) $(STLD_FLAGS) $@ $^
+
DOCBOOK_MANPAGE_URL = http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
diff --git a/source4/build/make/templates.mk b/source4/build/make/templates.mk
new file mode 100644
index 0000000000..41a7ccd0a5
--- /dev/null
+++ b/source4/build/make/templates.mk
@@ -0,0 +1,108 @@
+# Templates file for Samba 4
+# This relies on GNU make.
+#
+# © 2008 Jelmer Vernooij <jelmer@samba.org>
+#
+###############################################################################
+# Templates
+###############################################################################
+
+# Partially link
+# Arguments: target object file, source object files
+define partial_link_template
+$(1): $(2) ;
+ @echo Partially linking $$@
+ @mkdir -p $$(@D)
+ $$(PARTLINK) -o $$@ $$^
+endef
+
+# Link a binary
+# Arguments: target file, depends, flags
+define binary_link_template
+$(1): $(2) ;
+ @echo Linking $$@
+ @$$(BNLD) $$(BNLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
+endef
+
+# Link a host-machine binary
+# Arguments: target file, depends, flags
+define host_binary_link_template
+$(1): $(2) ;
+ @echo Linking $$@
+ @$$(HOSTLD) $$(HOSTLD_FLAGS) -L$${builddir}/bin/static -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
+endef
+
+# Create a prototype header
+# Arguments: header file, c files
+define proto_header_template
+
+proto:: $(1) ;
+
+clean:: ;
+ rm -f $(1)
+
+$(1): $(2) ;
+ @echo "Creating $$@"
+ @$$(PERL) $$(srcdir)/script/mkproto.pl --srcdir=$$(srcdir) --builddir=$$(builddir) --public=/dev/null --private=$$@ $$^
+
+endef
+
+# Shared module
+# Arguments: Target, dependencies, objects
+define shared_module_template
+
+$(1): $(2) ;
+ @echo Linking $$@
+ @mkdir -p $$(@D)
+ @$$(MDLD) $$(LDFLAGS) $$(MDLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
+
+endef
+
+# Shared library
+# Arguments: Target, dependencies, link flags, soname
+define shared_library_template
+$(1): $(2)
+ @echo Linking $$@
+ @mkdir -p $$(@D)
+ @$$(SHLD) $$(LDFLAGS) $$(SHLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) \
+ $(3) \
+ $$(if $$(SONAMEFLAG), $$(SONAMEFLAG)$(notdir $(4)))
+
+ifneq ($(notdir $(1)),$(notdir $(4)))
+$(4): $(1)
+ @echo "Creating symbolic link for $$@"
+ @ln -fs $$(<F) $$@
+endif
+
+ifneq ($(notdir $(1)),$(notdir $(5)))
+$(5): $(1)
+ @echo "Creating symbolic link for $$@"
+ @ln -fs $$(<F) $$@
+endif
+endef
+
+# Shared alias
+# Arguments: Target, subsystem name, alias name
+define shared_module_alias_template
+bin/modules/$(2)/$(3).$$(SHLIBEXT): $(1)
+ @ln -fs $$(<F) $$@
+
+PLUGINS += bin/modules/$(2)/$(3).$$(SHLIBEXT)
+
+uninstallplugins::
+ @-rm $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT)
+installplugins::
+ @ln -fs $(notdir $(1)) $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT)
+
+endef
+
+define shared_module_install_template
+installplugins:: bin/modules/$(1)/$(2)
+ @echo Installing $(2) as $$(DESTDIR)$$(modulesdir)/$(1)/$(2)
+ @mkdir -p $$(DESTDIR)$$(modulesdir)/$(1)/
+ @cp bin/modules/$(1)/$(2) $$(DESTDIR)$$(modulesdir)/$(1)/$(2)
+uninstallplugins::
+ @echo Uninstalling $$(DESTDIR)$$(modulesdir)/$(1)/$(2)
+ @-rm $$(DESTDIR)$$(modulesdir)/$(1)/$(2)
+
+endef
diff --git a/source4/script/yacc_compile.sh b/source4/build/make/yacc_compile.sh
index a56a51da0a..a56a51da0a 100755
--- a/source4/script/yacc_compile.sh
+++ b/source4/build/make/yacc_compile.sh
diff --git a/source4/build/smb_build/config_mk.pm b/source4/build/smb_build/config_mk.pm
index d8ec646910..652a52fa60 100644
--- a/source4/build/smb_build/config_mk.pm
+++ b/source4/build/smb_build/config_mk.pm
@@ -20,24 +20,19 @@ my $section_types = {
"LDFLAGS" => "list",
},
"PYTHON" => {
- SWIG_FILE => "string",
+ "LIBRARY_REALNAME" => "string",
"PRIVATE_DEPENDENCIES" => "list",
"PUBLIC_DEPENDENCIES" => "list",
- "OBJ_FILES" => "list",
"ENABLE" => "bool",
"LDFLAGS" => "list",
"CFLAGS" => "list",
},
"SUBSYSTEM" => {
- "OBJ_FILES" => "list",
-
"PRIVATE_DEPENDENCIES" => "list",
"PUBLIC_DEPENDENCIES" => "list",
"ENABLE" => "bool",
- "PRIVATE_PROTO_HEADER" => "string",
-
"CFLAGS" => "list",
"LDFLAGS" => "list",
"STANDARD_VISIBILITY" => "string",
@@ -47,7 +42,6 @@ my $section_types = {
"SUBSYSTEM" => "string",
"INIT_FUNCTION" => "string",
- "OBJ_FILES" => "list",
"PRIVATE_DEPENDENCIES" => "list",
@@ -57,20 +51,15 @@ my $section_types = {
"OUTPUT_TYPE" => "list",
- "PRIVATE_PROTO_HEADER" => "string",
-
"CFLAGS" => "list"
},
"BINARY" => {
- "OBJ_FILES" => "list",
"PRIVATE_DEPENDENCIES" => "list",
"ENABLE" => "bool",
"INSTALLDIR" => "string",
- "PRIVATE_PROTO_HEADER" => "string",
-
"CFLAGS" => "list",
"LDFLAGS" => "list",
"STANDARD_VISIBILITY" => "string",
@@ -78,25 +67,17 @@ my $section_types = {
"USE_HOSTCC" => "bool"
},
"LIBRARY" => {
- "VERSION" => "string",
- "SO_VERSION" => "string",
"LIBRARY_REALNAME" => "string",
- "PC_FILE" => "string",
-
"INIT_FUNCTION_TYPE" => "string",
"INIT_FUNCTION_SENTINEL" => "string",
"OUTPUT_TYPE" => "list",
- "OBJ_FILES" => "list",
-
"PRIVATE_DEPENDENCIES" => "list",
"PUBLIC_DEPENDENCIES" => "list",
"ENABLE" => "bool",
- "PRIVATE_PROTO_HEADER" => "string",
-
"CFLAGS" => "list",
"LDFLAGS" => "list",
"STANDARD_VISIBILITY" => "string"
@@ -107,14 +88,11 @@ use vars qw(@parsed_files);
@parsed_files = ();
-sub _read_config_file
+sub _read_config_file($$$)
{
- use File::Basename;
use Cwd;
- my $srcdir = shift;
- my $builddir = shift;
- my $filename = shift;
+ my ($srcdir, $builddir, $filename) = @_;
my @dirlist;
# We need to change our working directory because config.mk files can
@@ -219,10 +197,13 @@ sub run_config_mk($$$$)
$prev = "";
}
- if ($line =~ /^\[([-a-zA-Z0-9_:]+)\][\t ]*$/)
+ if ($line =~ /^\[([-a-zA-Z0-9_.:]+)\][\t ]*$/)
{
$section = $1;
$infragment = 0;
+
+ $result->{$section}{EXISTS}{KEY} = "EXISTS";
+ $result->{$section}{EXISTS}{VAL} = 1;
next;
}
@@ -233,6 +214,7 @@ sub run_config_mk($$$$)
$subdir =~ s/^\.$//g;
$subdir =~ s/^\.\///g;
$subdir .= "/" if ($subdir ne "");
+ $makefile .= "basedir := $subdir\n";
$makefile .= run_config_mk($input, $srcdir, $builddir, $subdir.$subfile);
next;
}
@@ -251,7 +233,6 @@ sub run_config_mk($$$$)
$infragment = 1;
next;
}
-
# Assignment
if ($line =~ /^([a-zA-Z0-9_]+)[\t ]*=(.*)$/) {
@@ -261,7 +242,7 @@ sub run_config_mk($$$$)
next;
}
- die("$parsing_file:$linenum: Bad line while parsing $parsing_file");
+ die("$parsing_file:$linenum: Bad line");
}
$makefile .= "# }END $parsing_file\n";
@@ -280,6 +261,7 @@ sub run_config_mk($$$$)
$input->{$name}{BASEDIR} = $basedir;
foreach my $key (values %{$result->{$section}}) {
+ next if ($key->{KEY} eq "EXISTS");
$key->{VAL} = smb_build::input::strtrim($key->{VAL});
my $vartype = $sectype->{$key->{KEY}};
if (not defined($vartype)) {
diff --git a/source4/build/smb_build/dot.pl b/source4/build/smb_build/dot.pl
index e50ee50f95..b30c320c6e 100755
--- a/source4/build/smb_build/dot.pl
+++ b/source4/build/smb_build/dot.pl
@@ -26,10 +26,10 @@ sub generate($$$)
foreach my $part (values %{$depend}) {
next if (defined($only) and not contains($only,$part->{NAME}));
foreach my $elem (@{$part->{PUBLIC_DEPENDENCIES}}) {
- $res .= "\t\"$part->{NAME}\" -> \"$elem\"; /* public */\n";
+ $res .= "\t\"$part->{NAME}\" -> \"$elem\" [style=filled]; /* public */\n";
}
foreach my $elem (@{$part->{PRIVATE_DEPENDENCIES}}) {
- $res .= "\t\"$part->{NAME}\" -> \"$elem\"; /* private */\n";
+ $res .= "\t\"$part->{NAME}\" -> \"$elem\" [style=dotted]; /* private */\n";
}
}
diff --git a/source4/build/smb_build/header.pm b/source4/build/smb_build/header.pm
deleted file mode 100644
index c2bdbaf4c8..0000000000
--- a/source4/build/smb_build/header.pm
+++ /dev/null
@@ -1,92 +0,0 @@
-# SMB Build System
-# - create output for build.h
-#
-# Copyright (C) Stefan (metze) Metzmacher 2004
-# Copyright (C) Jelmer Vernooij 2005
-# Released under the GNU GPL
-
-package header;
-use strict;
-
-sub _add_define_section($)
-{
- my $DEFINE = shift;
- my $output = "";
-
- $output .= "
-/* $DEFINE->{COMMENT} */
-#define $DEFINE->{KEY} $DEFINE->{VAL}
-";
-
- return $output;
-}
-
-sub _prepare_build_h($)
-{
- my $depend = shift;
- my @defines = ();
- my $output = "";
-
- foreach my $key (values %$depend) {
- my $DEFINE = ();
- next if ($key->{TYPE} ne "LIBRARY" and
- $key->{TYPE} ne "MODULE" and
- $key->{TYPE} ne "SUBSYSTEM" and
- $key->{TYPE} ne "BINARY");
- next unless defined($key->{INIT_FUNCTIONS});
-
- my $name = $key->{NAME};
- $name =~ s/-/_/g;
- $DEFINE->{COMMENT} = "$key->{TYPE} $key->{NAME} INIT";
- $DEFINE->{KEY} = "STATIC_$name\_MODULES";
- $DEFINE->{VAL} = "\\\n";
- foreach (@{$key->{INIT_FUNCTIONS}}) {
- $DEFINE->{VAL} .= "\t$_, \\\n";
- unless (/{/) {
- my $fn = $key->{INIT_FUNCTION_TYPE};
- my $n = $_;
- if ($fn =~ /\(\*\)/) {
- $fn =~ s/\(\*\)/$n/;
- $output .= "$fn;\n";
- } else {
- $n =~ s/\&//;
- $output .= "$fn $n;\n";
- }
- }
- }
-
- $DEFINE->{VAL} .= "\t$key->{INIT_FUNCTION_SENTINEL} \n";
-
- push(@defines,$DEFINE);
- }
-
- #
- # loop over all BUILD_H define sections
- #
- foreach (@defines) { $output .= _add_define_section($_); }
-
- return $output;
-}
-
-###########################################################
-# This function creates include/build.h from the SMB_BUILD
-# context
-#
-# create_build_h($SMB_BUILD_CTX)
-#
-# $SMB_BUILD_CTX - the global SMB_BUILD context
-#
-# $output - the resulting output buffer
-sub create_smb_build_h($$)
-{
- my ($CTX, $file) = @_;
-
- open(BUILD_H,">$file") || die ("Can't open `$file'\n");
- print BUILD_H "/* autogenerated by build/smb_build/main.pl */\n";
- print BUILD_H _prepare_build_h($CTX);
- close(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 948f2657b4..a76da496d9 100644
--- a/source4/build/smb_build/input.pm
+++ b/source4/build/smb_build/input.pm
@@ -84,14 +84,18 @@ sub check_module($$$)
return if ($mod->{ENABLE} ne "YES");
+
if (exists($INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTION_TYPE})) {
$mod->{INIT_FUNCTION_TYPE} = $INPUT->{$mod->{SUBSYSTEM}}{INIT_FUNCTION_TYPE};
} else {
$mod->{INIT_FUNCTION_TYPE} = "NTSTATUS (*) (void)";
}
+ unless (defined($mod->{INIT_FUNCTION_SENTINEL})) { $mod->{INIT_FUNCTION_SENTINEL} = "NULL"; }
+
if (not defined($mod->{OUTPUT_TYPE})) {
- if ($INPUT->{$mod->{SUBSYSTEM}}->{TYPE} eq "EXT_LIB") {
+ if ((not defined($INPUT->{$mod->{SUBSYSTEM}}->{TYPE})) or
+ $INPUT->{$mod->{SUBSYSTEM}}->{TYPE} eq "EXT_LIB") {
$mod->{OUTPUT_TYPE} = undef;
} else {
$mod->{OUTPUT_TYPE} = $default_ot;
@@ -107,7 +111,7 @@ sub check_module($$$)
}
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});
+ push (@{$INPUT->{$mod->{SUBSYSTEM}}{PRIVATE_DEPENDENCIES}}, $mod->{NAME});
}
}
@@ -119,16 +123,6 @@ sub check_library($$$)
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";
- return;
- }
-
- if (defined($lib->{SO_VERSION}) and not defined($lib->{VERSION})) {
- print "$lib->{NAME}: Please specify VERSION when specifying SO_VERSION\n";
- return;
- }
-
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"; }
@@ -144,25 +138,12 @@ sub check_python($$$)
$python->{INSTALLDIR} = "PYTHONDIR";
unless (defined($python->{CFLAGS})) { $python->{CFLAGS} = []; }
- if (defined($python->{SWIG_FILE})) {
- my $dirname = dirname($python->{SWIG_FILE});
- my $basename = basename($python->{SWIG_FILE}, ".i");
-
- $dirname .= "/" unless $dirname =~ /\/$/;
- $dirname = "" if $dirname eq "./";
-
- $python->{OBJ_FILES} = ["$dirname$basename\_wrap.o"];
- $python->{LIBRARY_REALNAME} = "_$basename.\$(SHLIBEXT)";
- $python->{PYTHON_FILES} = ["$dirname$basename.py"];
- 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};
- $basename =~ s/^python_//g;
+ my $basename = $python->{NAME};
+ $basename =~ s/^python_//g;
+ unless (defined($python->{LIBRARY_REALNAME})) {
$python->{LIBRARY_REALNAME} = "$basename.\$(SHLIBEXT)";
- $python->{INIT_FUNCTION} = "{ (char *)\"$basename\", init$basename }";
}
+ $python->{INIT_FUNCTION} = "{ (char *)\"$basename\", init$basename }";
push (@{$python->{CFLAGS}}, "\$(EXT_LIB_PYTHON_CFLAGS)");
$python->{SUBSYSTEM} = "LIBPYTHON";
@@ -177,6 +158,8 @@ sub check_binary($$)
return if ($bin->{ENABLE} ne "YES");
($bin->{BINARY} = (lc $bin->{NAME})) if not defined($bin->{BINARY});
+ unless (defined($bin->{INIT_FUNCTION_SENTINEL})) { $bin->{INIT_FUNCTION_SENTINEL} = "NULL"; }
+ unless (defined($bin->{INIT_FUNCTION_TYPE})) { $bin->{INIT_FUNCTION_TYPE} = "NTSTATUS (*) (void)"; }
$bin->{OUTPUT_TYPE} = ["BINARY"];
add_libreplace($bin);
@@ -186,16 +169,13 @@ sub add_implicit($$)
{
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)"]
- };
+ $INPUT->{$n}->{TYPE} = "MAKE_RULE";
+ $INPUT->{$n}->{NAME} = $n;
+ $INPUT->{$n}->{OUTPUT_TYPE} = undef;
+ $INPUT->{$n}->{LIBS} = ["\$(".uc($n)."_LIBS)"];
+ $INPUT->{$n}->{LDFLAGS} = ["\$(".uc($n)."_LDFLAGS)"];
+ $INPUT->{$n}->{CFLAGS} = ["\$(".uc($n)."_CFLAGS)"];
+ $INPUT->{$n}->{CPPFLAGS} = ["\$(".uc($n)."_CPPFLAGS)"];
}
sub calc_unique_deps($$$$$$$$)
@@ -204,7 +184,7 @@ sub calc_unique_deps($$$$$$$$)
my ($name, $INPUT, $deps, $udeps, $withlibs, $forward, $pubonly, $busy) = @_;
foreach my $n (@$deps) {
- add_implicit($INPUT, $n) unless (defined($INPUT->{$n}));
+ add_implicit($INPUT, $n) unless (defined($INPUT->{$n}) and defined($INPUT->{$n}->{TYPE}));
my $dep = $INPUT->{$n};
if (grep (/^$n$/, @$busy)) {
next if (@{$dep->{OUTPUT_TYPE}}[0] eq "MERGED_OBJ");
@@ -212,19 +192,19 @@ sub calc_unique_deps($$$$$$$$)
}
next if (grep /^$n$/, @$udeps);
- push (@{$udeps}, $dep->{NAME}) if $forward;
+ push (@{$udeps}, $n) if $forward;
if (defined ($dep->{OUTPUT_TYPE}) &&
($withlibs 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);
- calc_unique_deps($dep->{NAME}, $INPUT, $dep->{PRIVATE_DEPENDENCIES}, $udeps, $withlibs, $forward, $pubonly, $busy) unless $pubonly;
+ push (@$busy, $n);
+ calc_unique_deps($n, $INPUT, $dep->{PUBLIC_DEPENDENCIES}, $udeps, $withlibs, $forward, $pubonly, $busy);
+ calc_unique_deps($n, $INPUT, $dep->{PRIVATE_DEPENDENCIES}, $udeps, $withlibs, $forward, $pubonly, $busy) unless $pubonly;
pop (@$busy);
}
- unshift (@{$udeps}, $dep->{NAME}) unless $forward;
+ unshift (@{$udeps}, $n) unless $forward;
}
}
@@ -249,7 +229,7 @@ sub check($$$$$)
foreach my $part (values %$INPUT) {
$part->{LINK_FLAGS} = [];
- $part->{FULL_OBJ_LIST} = ["\$($part->{NAME}_OBJ_LIST)"];
+ $part->{FULL_OBJ_LIST} = ["\$($part->{NAME}_OBJ_FILES)"];
if ($part->{TYPE} eq "SUBSYSTEM") {
check_subsystem($INPUT, $part, $subsys_ot);
diff --git a/source4/build/smb_build/main.pl b/source4/build/smb_build/main.pl
index c3dc46461b..88289af26d 100644
--- a/source4/build/smb_build/main.pl
+++ b/source4/build/smb_build/main.pl
@@ -6,16 +6,27 @@
# Released under the GNU GPL
use smb_build::makefile;
-use smb_build::header;
use smb_build::input;
use smb_build::config_mk;
use smb_build::output;
use smb_build::summary;
use smb_build::config;
+use Getopt::Long;
use strict;
+my $output_file = "data.mk";
+
+my $result = GetOptions (
+ 'output=s' => \$output_file);
+
+if (not $result) {
+ exit(1);
+}
+
+my $input_file = shift @ARGV;
+
my $INPUT = {};
-my $mkfile = smb_build::config_mk::run_config_mk($INPUT, $config::config{srcdir}, $config::config{builddir}, "main.mk");
+my $mkfile = smb_build::config_mk::run_config_mk($INPUT, $config::config{srcdir}, $config::config{builddir}, $input_file);
my $subsys_output_type = ["MERGED_OBJ"];
@@ -44,45 +55,47 @@ my $mkenv = new smb_build::makefile(\%config::config, $mkfile);
my $shared_libs_used = 0;
foreach my $key (values %$OUTPUT) {
- $mkenv->_prepare_list($key, "OBJ_LIST");
- push(@{$mkenv->{all_objs}}, "\$($key->{NAME}_OBJ_LIST)");
+ next if ($key->{ENABLE} ne "YES");
+ push(@{$mkenv->{all_objs}}, "\$($key->{NAME}_OBJ_FILES)");
}
foreach my $key (values %$OUTPUT) {
next unless defined $key->{OUTPUT_TYPE};
+ $mkenv->StaticLibraryPrimitives($key) if grep(/STATIC_LIBRARY/, @{$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})) {
- $mkenv->output("PC_FILES += $key->{BASEDIR}/$key->{PC_FILE}\n");
- }
$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->SharedModulePrimitives($key) if ($key->{TYPE} eq "MODULE" or
- $key->{TYPE} eq "PYTHON") and
- grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}});
- $mkenv->PythonFiles($key) if defined($key->{PYTHON_FILES});
- $mkenv->ProtoHeader($key) if defined($key->{PRIVATE_PROTO_HEADER});
+ if ($key->{TYPE} eq "MODULE" and @{$key->{OUTPUT_TYPE}}[0] eq "MERGED_OBJ" and defined($key->{INIT_FUNCTION})) {
+ $mkenv->output("$key->{SUBSYSTEM}_INIT_FUNCTIONS += $key->{INIT_FUNCTION},\n");
+ }
$mkenv->CFlags($key);
}
foreach my $key (values %$OUTPUT) {
next unless defined $key->{OUTPUT_TYPE};
+ $mkenv->Integrated($key) if grep(/INTEGRATED/, @{$key->{OUTPUT_TYPE}});
+}
+
+foreach my $key (values %$OUTPUT) {
+ next unless defined $key->{OUTPUT_TYPE};
+ $mkenv->StaticLibrary($key) if grep(/STATIC_LIBRARY/, @{$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->SharedModule($key) if ($key->{TYPE} eq "MODULE" and
+ grep(/SHARED_LIBRARY/, @{$key->{OUTPUT_TYPE}}));
+ $mkenv->PythonModule($key) if ($key->{TYPE} eq "PYTHON");
$mkenv->Binary($key) if grep(/BINARY/, @{$key->{OUTPUT_TYPE}});
+ $mkenv->InitFunctions($key) if defined($key->{INIT_FUNCTIONS});
}
-$mkenv->write("data.mk");
-header::create_smb_build_h($OUTPUT, "include/build.h");
+$mkenv->write($output_file);
summary::show($OUTPUT, \%config::config);
diff --git a/source4/build/smb_build/makefile.pm b/source4/build/smb_build/makefile.pm
index fb3ac561fa..0269cfe8a3 100644
--- a/source4/build/smb_build/makefile.pm
+++ b/source4/build/smb_build/makefile.pm
@@ -23,12 +23,11 @@ sub new($$$)
$self->{output} = "";
- $self->{mkfile} = $mkfile;
-
$self->output("################################################\n");
$self->output("# Autogenerated by build/smb_build/makefile.pm #\n");
$self->output("################################################\n");
$self->output("\n");
+ $self->output($mkfile);
return $self;
}
@@ -73,17 +72,7 @@ sub _prepare_mk_files($)
push (@tmp, $_);
}
- $self->output("
-ifneq (\$(MAKECMDGOALS),clean)
-ifneq (\$(MAKECMDGOALS),distclean)
-ifneq (\$(MAKECMDGOALS),realdistclean)
-");
$self->output("MK_FILES = " . array2oneperline(\@tmp) . "\n");
- $self->output("
-endif
-endif
-endif
-");
}
sub array2oneperline($)
@@ -113,102 +102,54 @@ sub _prepare_list($$$)
$self->output("$ctx->{NAME}_$var =$tmplist\n");
}
-sub SharedModulePrimitives($$)
+sub PythonModule($$)
{
my ($self,$ctx) = @_;
-
- #FIXME
+
+ $self->_prepare_list($ctx, "FULL_OBJ_LIST");
+ $self->_prepare_list($ctx, "DEPEND_LIST");
+ $self->_prepare_list($ctx, "LINK_FLAGS");
+
+ $self->output("\$(eval \$(call python_c_module_template,$ctx->{LIBRARY_REALNAME},\$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST), \$($ctx->{NAME}\_FULL_OBJ_LIST) \$($ctx->{NAME}_LINK_FLAGS)))\n");
}
sub SharedModule($$)
{
my ($self,$ctx) = @_;
- my $init_obj = "";
-
my $sane_subsystem = lc($ctx->{SUBSYSTEM});
$sane_subsystem =~ s/^lib//;
- if ($ctx->{TYPE} eq "PYTHON") {
- $self->output("PYTHON_DSOS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
- } else {
- $self->output("PLUGINS += $ctx->{SHAREDDIR}/$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->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("PLUGINS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n");
+ $self->output("\$(eval \$(call shared_module_install_template,$sane_subsystem,$ctx->{LIBRARY_REALNAME}))\n");
- $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");
- 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};
- $proto_fn =~ s/\(\*\)/$ctx->{INIT_FUNCTION}/;
-
- $self->output(<< "__EOD__"
-bin/$ctx->{NAME}_init_module.c:
- \@echo Creating \$\@
- \@echo \"#include \\\"includes.h\\\"\" > \$\@
- \@echo \"$proto_fn;\" >> \$\@
- \@echo \"_PUBLIC_ $init_fn\" >> \$\@
- \@echo \"{\" >> \$\@
- \@echo \" return $ctx->{INIT_FUNCTION}();\" >> \$\@
- \@echo \"}\" >> \$\@
- \@echo \"\" >> \$\@
-__EOD__
-);
- $init_obj = "bin/$ctx->{NAME}_init_module.o";
+ if (defined($ctx->{INIT_FUNCTION}) and $ctx->{INIT_FUNCTION_TYPE} =~ /\(\*\)/ and not ($ctx->{INIT_FUNCTION} =~ /\(/)) {
+ $self->output("\$($ctx->{NAME}_OBJ_FILES): CFLAGS+=-D$ctx->{INIT_FUNCTION}=init_module\n");
}
- $self->output(<< "__EOD__"
-#
+ $self->output("\$(eval \$(call shared_module_template,$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}, \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST), \$($ctx->{NAME}\_FULL_OBJ_LIST) \$($ctx->{NAME}_LINK_FLAGS)))\n");
-$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST) $init_obj
- \@echo Linking \$\@
- \@mkdir -p $ctx->{SHAREDDIR}
- \@\$(MDLD) \$(LDFLAGS) \$(MDLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
- \$($ctx->{NAME}\_FULL_OBJ_LIST) $init_obj \\
- \$($ctx->{NAME}_LINK_FLAGS)
-__EOD__
-);
if (defined($ctx->{ALIASES})) {
- foreach (@{$ctx->{ALIASES}}) {
- $self->output("\t\@rm -f $ctx->{SHAREDDIR}/$_.\$(SHLIBEXT)\n");
- $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$_.\$(SHLIBEXT)\n");
- }
+ $self->output("\$(eval \$(foreach alias,". join(' ', @{$ctx->{ALIASES}}) . ",\$(call shared_module_alias_template,$ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME},$sane_subsystem,\$(alias))))\n");
}
- $self->output("\n");
}
-sub SharedLibraryPrimitives($$)
+sub StaticLibraryPrimitives($$)
{
my ($self,$ctx) = @_;
+
+ $self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
+ $self->_prepare_list($ctx, "FULL_OBJ_LIST");
+}
- $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}));
+sub SharedLibraryPrimitives($$)
+{
+ my ($self,$ctx) = @_;
if (not grep(/STATIC_LIBRARY/, @{$ctx->{OUTPUT_TYPE}})) {
$self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
@@ -220,58 +161,33 @@ sub SharedLibrary($$)
{
my ($self,$ctx) = @_;
- $self->output("SHARED_LIBS += $ctx->{SHAREDDIR}/$ctx->{LIBRARY_REALNAME}\n") if (defined($ctx->{SO_VERSION}));
+ $self->output("SHARED_LIBS += $ctx->{RESULT_SHARED_LIBRARY}\n");
$self->_prepare_list($ctx, "DEPEND_LIST");
$self->_prepare_list($ctx, "LINK_FLAGS");
- $self->output(<< "__EOD__"
-$ctx->{RESULT_SHARED_LIBRARY}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST)
- \@echo Linking \$\@
- \@mkdir -p \$(\@D)
- \@\$(SHLD) \$(LDFLAGS) \$(SHLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
- \$($ctx->{NAME}\_FULL_OBJ_LIST) \\
- \$($ctx->{NAME}_LINK_FLAGS) \\
- \$(if \$(SONAMEFLAG), \$(SONAMEFLAG)$ctx->{LIBRARY_SONAME})
-__EOD__
-);
- if ($ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) {
- $self->output("\t\@test \$($ctx->{NAME}_VERSION) = \$($ctx->{NAME}_SOVERSION) || ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}\n");
- }
- $self->output("ifdef $ctx->{NAME}_SOVERSION\n");
- $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}\n");
- $self->output("endif\n");
+ $self->output("\$(eval \$(call shared_library_template,$ctx->{RESULT_SHARED_LIBRARY}, \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST), \$($ctx->{NAME}\_FULL_OBJ_LIST) \$($ctx->{NAME}_LINK_FLAGS),$ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME},$ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}))\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 \$(\@D)
- \$(PARTLINK) -o \$@ \$($ctx->{NAME}_OBJ_LIST)
+ $self->output("\$(call partial_link_template, $ctx->{OUTPUT}, \$($ctx->{NAME}_OBJ_FILES))\n");
+}
-__EOD__
-);
+sub InitFunctions($$)
+{
+ my ($self, $ctx) = @_;
+ $self->output("\$($ctx->{NAME}_OBJ_FILES): CFLAGS+=-DSTATIC_$ctx->{NAME}_MODULES=\"\$($ctx->{NAME}_INIT_FUNCTIONS)$ctx->{INIT_FUNCTION_SENTINEL}\"\n");
}
sub StaticLibrary($$)
{
my ($self,$ctx) = @_;
- return unless (defined($ctx->{OBJ_FILES}));
-
- $self->output("STATIC_LIBS += $ctx->{TARGET_STATIC_LIBRARY}\n") if ($ctx->{TYPE} eq "LIBRARY");
-
+ $self->output("STATIC_LIBS += $ctx->{RESULT_STATIC_LIBRARY}\n") if ($ctx->{TYPE} eq "LIBRARY");
$self->output("$ctx->{NAME}_OUTPUT = $ctx->{OUTPUT}\n");
- $self->_prepare_list($ctx, "FULL_OBJ_LIST");
-
$self->output("$ctx->{RESULT_STATIC_LIBRARY}: \$($ctx->{NAME}_FULL_OBJ_LIST)\n");
}
@@ -280,74 +196,31 @@ sub Binary($$)
my ($self,$ctx) = @_;
unless (defined($ctx->{INSTALLDIR})) {
+ $self->output("BINARIES += $ctx->{TARGET_BINARY}\n");
} elsif ($ctx->{INSTALLDIR} eq "SBINDIR") {
- $self->output("SBIN_PROGS += bin/$ctx->{BINARY}\n");
+ $self->output("SBIN_PROGS += $ctx->{RESULT_BINARY}\n");
} elsif ($ctx->{INSTALLDIR} eq "BINDIR") {
- $self->output("BIN_PROGS += bin/$ctx->{BINARY}\n");
+ $self->output("BIN_PROGS += $ctx->{RESULT_BINARY}\n");
}
- $self->output("binaries:: $ctx->{TARGET_BINARY}\n");
-
$self->_prepare_list($ctx, "FULL_OBJ_LIST");
$self->_prepare_list($ctx, "DEPEND_LIST");
$self->_prepare_list($ctx, "LINK_FLAGS");
-$self->output(<< "__EOD__"
-$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) -L\${builddir}/bin/static -o \$\@ \$(INSTALL_LINK_FLAGS) \\
- \$\($ctx->{NAME}_LINK_FLAGS)
-__EOD__
- );
+$self->output("\$(call host_binary_link_template, $ctx->{RESULT_BINARY}, \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST), \$($ctx->{NAME}_LINK_FLAGS))\n");
} else {
- $self->output(<< "__EOD__"
- \@\$(BNLD) \$(BNLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
- \$\($ctx->{NAME}_LINK_FLAGS)
-
-__EOD__
- );
- }
-}
-
-sub PythonFiles($$)
-{
- my ($self,$ctx) = @_;
-
- foreach (@{$ctx->{PYTHON_FILES}}) {
- my $target = "bin/python/".basename($_);
- my $source = output::add_dir_str($ctx->{BASEDIR}, $_);
- $self->output("$target: $source\n\n");
- $self->output("PYTHON_PYS += $target\n");
+$self->output("\$(call binary_link_template, $ctx->{RESULT_BINARY}, \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST), \$($ctx->{NAME}_LINK_FLAGS))\n");
}
}
-sub ProtoHeader($$)
-{
- my ($self,$ctx) = @_;
-
- my $priv = output::add_dir_str($ctx->{BASEDIR}, $ctx->{PRIVATE_PROTO_HEADER});
- $self->output("PROTO_HEADERS += $priv\n");
-
- $self->output("$priv: $ctx->{MK_FILE} \$($ctx->{NAME}_OBJ_LIST:.o=.c) \$(srcdir)/script/mkproto.pl\n");
- $self->output("\t\@echo \"Creating \$@\"\n");
- $self->output("\t\@mkdir -p \$(\@D)\n");
- $self->output("\t\@\$(PERL) \$(srcdir)/script/mkproto.pl --srcdir=\$(srcdir) --builddir=\$(builddir) --public=/dev/null --private=\$@ \$($ctx->{NAME}_OBJ_LIST)\n\n");
-}
-
sub write($$)
{
my ($self, $file) = @_;
- $self->output("ALL_OBJS = " . array2oneperline($self->{all_objs}) . "\n");
-
$self->_prepare_mk_files();
- $self->output($self->{mkfile});
+ $self->output("ALL_OBJS = " . array2oneperline($self->{all_objs}) . "\n");
open(MAKEFILE,">$file") || die ("Can't open $file\n");
print MAKEFILE $self->{output};
@@ -374,7 +247,6 @@ sub CFlags($$)
my $src_ne_build = ($srcdir ne $builddir) ? 1 : 0;
- return unless defined ($key->{OBJ_LIST});
return unless defined ($key->{FINAL_CFLAGS});
return unless (@{$key->{FINAL_CFLAGS}} > 0);
@@ -388,19 +260,19 @@ sub CFlags($$)
my @cflags = ();
foreach my $flag (@sorted_cflags) {
if($src_ne_build) {
- if($flag =~ m#^-I([^/].*$)#) {
- my $dir = $1;
- $dir =~ s#^\$\((?:src|build)dir\)/?##;
+ if($flag =~ m#^-I([^/].*$)#) {
+ my $dir = $1;
+ $dir =~ s#^\$\((?:src|build)dir\)/?##;
push(@cflags, "-I$builddir/$dir", "-I$srcdir/$dir");
- next;
- }
+ next;
+ }
}
push(@cflags, $flag);
}
my $cflags = join(' ', @cflags);
- $self->output("\$(patsubst %.ho,%.d,\$($key->{NAME}_OBJ_LIST:.o=.d)) \$($key->{NAME}_OBJ_LIST): CFLAGS+= $cflags\n");
+ $self->output("\$(patsubst %.ho,%.d,\$($key->{NAME}_OBJ_FILES:.o=.d)) \$($key->{NAME}_OBJ_FILES): CFLAGS+= $cflags\n");
}
1;
diff --git a/source4/build/smb_build/output.pm b/source4/build/smb_build/output.pm
index 4ae4a62cf4..f9f12c3a73 100644
--- a/source4/build/smb_build/output.pm
+++ b/source4/build/smb_build/output.pm
@@ -7,39 +7,6 @@
package output;
use strict;
-use smb_build::config;
-
-sub add_dir_str($$)
-{
- my ($dir,$file) = @_;
- my $dirsep = "/";
-
- $dir =~ s/^\.$//g;
- $dir =~ s/^\.\///g;
-
- $dirsep = "" if ($dir eq "");
-
- my $ret = $file;
- if (substr($ret, 0, 1) ne "\$") {
- $ret = "$dir$dirsep$file";
- $ret =~ s/([^\/\.]+)\/\.\.\///g;
- $ret =~ s/([^\/\.]+)\/\.\.\///g;
- }
-
- return $ret;
-}
-
-sub add_dir_array($$)
-{
- my ($dir,$files) = @_;
- my @ret = ();
-
- foreach (@{$files}) {
- push (@ret, add_dir_str($dir, $_));
- }
-
- return @ret;
-}
sub generate_shared_library($)
{
@@ -80,10 +47,8 @@ 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->{NAME}_SOVERSION)";
- $lib->{LIBRARY_REALNAME} = "$lib->{LIBRARY_REALNAME}.\$($lib->{NAME}_VERSION)";
- }
+ $lib->{LIBRARY_SONAME} = "\$(if \$($lib->{NAME}_SOVERSION),$lib->{LIBRARY_REALNAME}.\$($lib->{NAME}_SOVERSION),$lib->{LIBRARY_REALNAME})";
+ $lib->{LIBRARY_REALNAME} = "\$(if \$($lib->{NAME}_VERSION),$lib->{LIBRARY_REALNAME}.\$($lib->{NAME}_VERSION),$lib->{LIBRARY_REALNAME})";
$lib->{RESULT_SHARED_LIBRARY} = "$lib->{SHAREDDIR}/$lib->{LIBRARY_REALNAME}";
$lib->{OUTPUT_SHARED_LIBRARY} = "-l$link_name";
@@ -97,11 +62,9 @@ sub generate_merged_obj($)
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};
- }
+ $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};
}
sub generate_static_library($)
@@ -116,12 +79,10 @@ sub generate_static_library($)
$lib->{LIBRARY_NAME} = "lib".lc($link_name).".a";
- if (defined($lib->{OBJ_FILES})) {
- $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);
- }
+ $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);
}
sub generate_binary($)
@@ -160,10 +121,6 @@ sub create_output($$)
foreach $part (values %{$depend}) {
next unless(defined($part->{OUTPUT_TYPE}));
- # Combine object lists
- my @list = add_dir_array($part->{BASEDIR}, $part->{OBJ_FILES});
- push(@{$part->{OBJ_LIST}}, @list) if defined($part->{OBJ_FILES});
-
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}});
@@ -197,7 +154,7 @@ sub create_output($$)
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});
+ push(@{$part->{DEPEND_LIST}}, $elem->{TARGET}) if (defined($elem->{TARGET}));
}
}
}
diff --git a/source4/build/tests/unixsock.c b/source4/build/tests/unixsock.c
deleted file mode 100644
index f2765d68f6..0000000000
--- a/source4/build/tests/unixsock.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/* -*- c-file-style: "linux" -*-
- *
- * Try creating a Unix-domain socket, opening it, and reading from it.
- * The POSIX name for these is AF_LOCAL/PF_LOCAL.
- *
- * This is used by the Samba autoconf scripts to detect systems which
- * don't have Unix-domain sockets, such as (probably) VMS, or systems
- * on which they are broken under some conditions, such as RedHat 7.0
- * (unpatched). We can't build WinBind there at the moment.
- *
- * Coding standard says to always use exit() for this, not return, so
- * we do.
- *
- * Martin Pool <mbp@samba.org>, June 2000. */
-
-/* TODO: Look for AF_LOCAL (most standard), AF_UNIX, and AF_FILE. */
-
-#include <stdio.h>
-
-#ifdef HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-
-#ifdef HAVE_SYS_UN_H
-# include <sys/un.h>
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_SYS_WAIT_H
-# include <sys/wait.h>
-#endif
-
-#if HAVE_ERRNO_DECL
-# include <errno.h>
-#else
-extern int errno;
-#endif
-
-static int bind_socket(char const *filename)
-{
- int sock_fd;
- struct sockaddr_un name;
- size_t size;
-
- /* Create the socket. */
- if ((sock_fd = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) {
- perror ("socket(PF_LOCAL, SOCK_STREAM)");
- exit(1);
- }
-
- /* Bind a name to the socket. */
- name.sun_family = AF_LOCAL;
- strncpy(name.sun_path, filename, sizeof (name.sun_path));
-
- /* The size of the address is
- the offset of the start of the filename,
- plus its length,
- plus one for the terminating null byte.
- Alternatively you can just do:
- size = SUN_LEN (&name);
- */
- size = SUN_LEN(&name);
- /* XXX: This probably won't work on unfriendly libcs */
-
- if (bind(sock_fd, (struct sockaddr *) &name, size) < 0) {
- perror ("bind");
- exit(1);
- }
-
- return sock_fd;
-}
-
-
-int main(void)
-{
- int sock_fd;
- int kid;
- char const *filename = "conftest.unixsock.sock";
-
- /* abolish hanging */
- alarm(15); /* secs */
-
- if ((sock_fd = bind_socket(filename)) < 0)
- exit(1);
-
- /* the socket will be deleted when autoconf cleans up these
- files. */
-
- exit(0);
-}
diff --git a/source4/cldap_server/cldap_server.c b/source4/cldap_server/cldap_server.c
index 783e31d1ae..58e9e2d89b 100644
--- a/source4/cldap_server/cldap_server.c
+++ b/source4/cldap_server/cldap_server.c
@@ -187,7 +187,7 @@ static void cldapd_task_init(struct task_server *task)
}
cldapd->task = task;
- cldapd->samctx = samdb_connect(cldapd, task->lp_ctx, anonymous_session(cldapd, task->lp_ctx));
+ cldapd->samctx = samdb_connect(cldapd, task->event_ctx, task->lp_ctx, anonymous_session(cldapd, task->event_ctx, task->lp_ctx));
if (cldapd->samctx == NULL) {
task_server_terminate(task, "cldapd failed to open samdb");
return;
diff --git a/source4/cldap_server/config.mk b/source4/cldap_server/config.mk
index 9dd3758e7a..137a44d0f7 100644
--- a/source4/cldap_server/config.mk
+++ b/source4/cldap_server/config.mk
@@ -4,13 +4,15 @@
# Start SUBSYSTEM CLDAPD
[MODULE::CLDAPD]
INIT_FUNCTION = server_service_cldapd_init
-SUBSYSTEM = service
-PRIVATE_PROTO_HEADER = proto.h
-OBJ_FILES = \
- cldap_server.o \
- netlogon.o \
- rootdse.o
+SUBSYSTEM = smbd
PRIVATE_DEPENDENCIES = \
LIBCLI_CLDAP LIBNETIF process_model
# End SUBSYSTEM CLDAPD
#######################
+
+CLDAPD_OBJ_FILES = $(addprefix $(cldap_serversrcdir)/, \
+ cldap_server.o \
+ netlogon.o \
+ rootdse.o)
+
+$(eval $(call proto_header_template,$(cldap_serversrcdir)/proto.h,$(CLDAPD_OBJ_FILES:.o=.c)))
diff --git a/source4/cldap_server/netlogon.c b/source4/cldap_server/netlogon.c
index 32a71e43af..f263f33d48 100644
--- a/source4/cldap_server/netlogon.c
+++ b/source4/cldap_server/netlogon.c
@@ -4,6 +4,7 @@
CLDAP server - netlogon handling
Copyright (C) Andrew Tridgell 2005
+ Copyright (C) Andrew Bartlett <abartlet@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
@@ -20,7 +21,6 @@
*/
#include "includes.h"
-#include "libcli/ldap/ldap_ndr.h"
#include "lib/ldb/include/ldb.h"
#include "lib/ldb/include/ldb_errors.h"
#include "lib/events/events.h"
@@ -28,29 +28,34 @@
#include "smbd/service_task.h"
#include "cldap_server/cldap_server.h"
#include "librpc/gen_ndr/ndr_misc.h"
+#include "libcli/ldap/ldap_ndr.h"
+#include "libcli/security/security.h"
#include "dsdb/samdb/samdb.h"
#include "auth/auth.h"
#include "ldb_wrap.h"
#include "system/network.h"
#include "lib/socket/netif.h"
#include "param/param.h"
-
/*
fill in the cldap netlogon union for a given version
*/
-static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd,
- TALLOC_CTX *mem_ctx,
- const char *domain,
- const char *domain_guid,
- const char *user,
- const char *src_address,
- uint32_t version,
- struct loadparm_context *lp_ctx,
- union nbt_cldap_netlogon *netlogon)
+NTSTATUS fill_netlogon_samlogon_response(struct ldb_context *sam_ctx,
+ TALLOC_CTX *mem_ctx,
+ const char *domain,
+ const char *netbios_domain,
+ struct dom_sid *domain_sid,
+ const char *domain_guid,
+ const char *user,
+ uint32_t acct_control,
+ const char *src_address,
+ uint32_t version,
+ struct loadparm_context *lp_ctx,
+ struct netlogon_samlogon_response *netlogon)
{
const char *ref_attrs[] = {"nETBIOSName", "dnsRoot", "ncName", NULL};
const char *dom_attrs[] = {"objectGUID", NULL};
- struct ldb_result *ref_res = NULL, *dom_res = NULL;
+ const char *none_attrs[] = {NULL};
+ struct ldb_result *ref_res = NULL, *dom_res = NULL, *user_res = NULL;
int ret;
const char **services = lp_server_services(lp_ctx);
uint32_t server_type;
@@ -65,8 +70,9 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd,
const char *pdc_ip;
struct ldb_dn *partitions_basedn;
struct interface *ifaces;
+ bool user_known;
- partitions_basedn = samdb_partitions_dn(cldapd->samctx, mem_ctx);
+ partitions_basedn = samdb_partitions_dn(sam_ctx, mem_ctx);
/* the domain has an optional trailing . */
if (domain && domain[strlen(domain)-1] == '.') {
@@ -77,7 +83,7 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd,
struct ldb_dn *dom_dn;
/* try and find the domain */
- ret = ldb_search_exp_fmt(cldapd->samctx, mem_ctx, &ref_res,
+ ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &ref_res,
partitions_basedn, LDB_SCOPE_ONELEVEL,
ref_attrs,
"(&(&(objectClass=crossRef)(dnsRoot=%s))(nETBIOSName=*))",
@@ -86,19 +92,58 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd,
if (ret != LDB_SUCCESS) {
DEBUG(2,("Unable to find referece to '%s' in sam: %s\n",
domain,
- ldb_errstring(cldapd->samctx)));
+ ldb_errstring(sam_ctx)));
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ } else if (ref_res->count == 1) {
+ talloc_steal(mem_ctx, dom_res);
+ dom_dn = ldb_msg_find_attr_as_dn(sam_ctx, mem_ctx, ref_res->msgs[0], "ncName");
+ if (!dom_dn) {
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+ ret = ldb_search(sam_ctx, dom_dn,
+ LDB_SCOPE_BASE, "objectClass=domain",
+ dom_attrs, &dom_res);
+ if (ret != LDB_SUCCESS) {
+ DEBUG(2,("Error finding domain '%s'/'%s' in sam: %s\n", domain, ldb_dn_get_linearized(dom_dn), ldb_errstring(sam_ctx)));
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+ talloc_steal(mem_ctx, dom_res);
+ if (dom_res->count != 1) {
+ DEBUG(2,("Error finding domain '%s'/'%s' in sam\n", domain, ldb_dn_get_linearized(dom_dn)));
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+ } else if (ref_res->count > 1) {
+ talloc_free(ref_res);
+ return NT_STATUS_NO_SUCH_DOMAIN;
+ }
+ }
+
+ if (netbios_domain) {
+ struct ldb_dn *dom_dn;
+ /* try and find the domain */
+
+ ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &ref_res,
+ partitions_basedn, LDB_SCOPE_ONELEVEL,
+ ref_attrs,
+ "(&(objectClass=crossRef)(ncName=*)(nETBIOSName=%s))",
+ netbios_domain);
+
+ if (ret != LDB_SUCCESS) {
+ DEBUG(2,("Unable to find referece to '%s' in sam: %s\n",
+ netbios_domain,
+ ldb_errstring(sam_ctx)));
return NT_STATUS_NO_SUCH_DOMAIN;
} else if (ref_res->count == 1) {
talloc_steal(mem_ctx, dom_res);
- dom_dn = ldb_msg_find_attr_as_dn(cldapd->samctx, mem_ctx, ref_res->msgs[0], "ncName");
+ dom_dn = ldb_msg_find_attr_as_dn(sam_ctx, mem_ctx, ref_res->msgs[0], "ncName");
if (!dom_dn) {
return NT_STATUS_NO_SUCH_DOMAIN;
}
- ret = ldb_search(cldapd->samctx, dom_dn,
+ ret = ldb_search(sam_ctx, dom_dn,
LDB_SCOPE_BASE, "objectClass=domain",
dom_attrs, &dom_res);
if (ret != LDB_SUCCESS) {
- DEBUG(2,("Error finding domain '%s'/'%s' in sam: %s\n", domain, ldb_dn_get_linearized(dom_dn), ldb_errstring(cldapd->samctx)));
+ DEBUG(2,("Error finding domain '%s'/'%s' in sam: %s\n", domain, ldb_dn_get_linearized(dom_dn), ldb_errstring(sam_ctx)));
return NT_STATUS_NO_SUCH_DOMAIN;
}
talloc_steal(mem_ctx, dom_res);
@@ -112,23 +157,31 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd,
}
}
- if ((dom_res == NULL || dom_res->count == 0) && domain_guid) {
+ if ((dom_res == NULL || dom_res->count == 0) && (domain_guid || domain_sid)) {
ref_res = NULL;
- ret = ldb_search_exp_fmt(cldapd->samctx, mem_ctx, &dom_res,
- NULL, LDB_SCOPE_SUBTREE,
- dom_attrs,
- "(&(objectClass=domainDNS)(objectGUID=%s))",
- domain_guid);
+ if (domain_guid) {
+ ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &dom_res,
+ NULL, LDB_SCOPE_SUBTREE,
+ dom_attrs,
+ "(&(objectClass=domainDNS)(objectGUID=%s))",
+ domain_guid);
+ } else { /* domain_sid case */
+ ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &dom_res,
+ NULL, LDB_SCOPE_SUBTREE,
+ dom_attrs,
+ "(&(objectClass=domainDNS)(objectSID=%s))",
+ dom_sid_string(mem_ctx, domain_sid));
+ }
if (ret != LDB_SUCCESS) {
- DEBUG(2,("Unable to find referece to GUID '%s' in sam: %s\n",
- domain_guid,
- ldb_errstring(cldapd->samctx)));
+ DEBUG(2,("Unable to find referece to GUID '%s' or SID %s in sam: %s\n",
+ domain_guid, dom_sid_string(mem_ctx, domain_sid),
+ ldb_errstring(sam_ctx)));
return NT_STATUS_NO_SUCH_DOMAIN;
} else if (dom_res->count == 1) {
/* try and find the domain */
- ret = ldb_search_exp_fmt(cldapd->samctx, mem_ctx, &ref_res,
+ ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &ref_res,
partitions_basedn, LDB_SCOPE_ONELEVEL,
ref_attrs,
"(&(objectClass=crossRef)(ncName=%s))",
@@ -137,7 +190,7 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd,
if (ret != LDB_SUCCESS) {
DEBUG(2,("Unable to find referece to '%s' in sam: %s\n",
ldb_dn_get_linearized(dom_res->msgs[0]->dn),
- ldb_errstring(cldapd->samctx)));
+ ldb_errstring(sam_ctx)));
return NT_STATUS_NO_SUCH_DOMAIN;
} else if (ref_res->count != 1) {
@@ -151,6 +204,7 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd,
}
}
+
if ((ref_res == NULL || ref_res->count == 0)) {
DEBUG(2,("Unable to find domain reference with name %s or GUID {%s}\n", domain, domain_guid));
return NT_STATUS_NO_SUCH_DOMAIN;
@@ -161,16 +215,54 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd,
return NT_STATUS_NO_SUCH_DOMAIN;
}
+ /* work around different inputs for not-specified users */
+ if (!user) {
+ user = "";
+ }
+
+ /* Enquire about any valid username with just a CLDAP packet -
+ * if kerberos didn't also do this, the security folks would
+ * scream... */
+ if (user[0]) { \
+ /* Only allow some bits to be enquired: [MS-ATDS] 7.3.3.2 */
+ if (acct_control == (uint32_t)-1) {
+ acct_control = 0;
+ }
+ acct_control = acct_control & (ACB_TEMPDUP | ACB_NORMAL | ACB_DOMTRUST | ACB_WSTRUST | ACB_SVRTRUST);
+
+ /* We must exclude disabled accounts, but otherwise do the bitwise match the client asked for */
+ ret = ldb_search_exp_fmt(sam_ctx, mem_ctx, &user_res,
+ dom_res->msgs[0]->dn, LDB_SCOPE_SUBTREE,
+ none_attrs,
+ "(&(objectClass=user)(samAccountName=%s)"
+ "(!(userAccountControl:" LDB_OID_COMPARATOR_AND ":=%u))"
+ "(userAccountControl:" LDB_OID_COMPARATOR_OR ":=%u))",
+ user, UF_ACCOUNTDISABLE, samdb_acb2uf(acct_control));
+ if (ret != LDB_SUCCESS) {
+ DEBUG(2,("Unable to find referece to user '%s' with ACB 0x%8x under %s: %s\n",
+ user, acct_control, ldb_dn_get_linearized(dom_res->msgs[0]->dn),
+ ldb_errstring(sam_ctx)));
+ return NT_STATUS_NO_SUCH_USER;
+ } else if (user_res->count == 1) {
+ user_known = true;
+ } else {
+ user_known = false;
+ }
+
+ } else {
+ user_known = true;
+ }
+
server_type =
NBT_SERVER_DS | NBT_SERVER_TIMESERV |
NBT_SERVER_CLOSEST | NBT_SERVER_WRITABLE |
NBT_SERVER_GOOD_TIMESERV;
- if (samdb_is_pdc(cldapd->samctx)) {
+ if (samdb_is_pdc(sam_ctx)) {
server_type |= NBT_SERVER_PDC;
}
- if (samdb_is_gc(cldapd->samctx)) {
+ if (samdb_is_gc(sam_ctx)) {
server_type |= NBT_SERVER_GC;
}
@@ -200,68 +292,75 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd,
ZERO_STRUCTP(netlogon);
- switch (version & 0xF) {
- case 0:
- case 1:
- netlogon->logon1.type = (user?19+2:19);
- netlogon->logon1.pdc_name = pdc_name;
- netlogon->logon1.user_name = user;
- netlogon->logon1.domain_name = flatname;
- netlogon->logon1.nt_version = 1;
- netlogon->logon1.lmnt_token = 0xFFFF;
- netlogon->logon1.lm20_token = 0xFFFF;
- break;
- case 2:
- case 3:
- netlogon->logon3.type = (user?19+2:19);
- netlogon->logon3.pdc_name = pdc_name;
- netlogon->logon3.user_name = user;
- netlogon->logon3.domain_name = flatname;
- netlogon->logon3.domain_uuid = domain_uuid;
- netlogon->logon3.forest = realm;
- netlogon->logon3.dns_domain = dns_domain;
- netlogon->logon3.pdc_dns_name = pdc_dns_name;
- netlogon->logon3.pdc_ip = pdc_ip;
- netlogon->logon3.server_type = server_type;
- netlogon->logon3.lmnt_token = 0xFFFF;
- netlogon->logon3.lm20_token = 0xFFFF;
- break;
- case 4:
- case 5:
- case 6:
- case 7:
- netlogon->logon5.type = (user?NETLOGON_RESPONSE_FROM_PDC_USER:NETLOGON_RESPONSE_FROM_PDC2);
- netlogon->logon5.server_type = server_type;
- netlogon->logon5.domain_uuid = domain_uuid;
- netlogon->logon5.forest = realm;
- netlogon->logon5.dns_domain = dns_domain;
- netlogon->logon5.pdc_dns_name = pdc_dns_name;
- netlogon->logon5.domain = flatname;
- netlogon->logon5.pdc_name = lp_netbios_name(lp_ctx);
- netlogon->logon5.user_name = user;
- netlogon->logon5.server_site = server_site;
- netlogon->logon5.client_site = client_site;
- netlogon->logon5.lmnt_token = 0xFFFF;
- netlogon->logon5.lm20_token = 0xFFFF;
- break;
- default:
- netlogon->logon13.type = (user?NETLOGON_RESPONSE_FROM_PDC_USER:NETLOGON_RESPONSE_FROM_PDC2);
- netlogon->logon13.server_type = server_type;
- netlogon->logon13.domain_uuid = domain_uuid;
- netlogon->logon13.forest = realm;
- netlogon->logon13.dns_domain = dns_domain;
- netlogon->logon13.pdc_dns_name = pdc_dns_name;
- netlogon->logon13.domain = flatname;
- netlogon->logon13.pdc_name = lp_netbios_name(lp_ctx);
- netlogon->logon13.user_name = user;
- netlogon->logon13.server_site = server_site;
- netlogon->logon13.client_site = client_site;
- netlogon->logon13.unknown = 10;
- netlogon->logon13.unknown2 = 2;
- netlogon->logon13.pdc_ip = pdc_ip;
- netlogon->logon13.lmnt_token = 0xFFFF;
- netlogon->logon13.lm20_token = 0xFFFF;
- break;
+ /* check if either of these bits is present */
+ if (version & (NETLOGON_NT_VERSION_5EX|NETLOGON_NT_VERSION_5EX_WITH_IP)) {
+ uint32_t extra_flags = 0;
+ netlogon->ntver = NETLOGON_NT_VERSION_5EX;
+
+ /* could check if the user exists */
+ if (user_known) {
+ netlogon->nt5_ex.command = LOGON_SAM_LOGON_RESPONSE_EX;
+ } else {
+ netlogon->nt5_ex.command = LOGON_SAM_LOGON_USER_UNKNOWN_EX;
+ }
+ netlogon->nt5_ex.server_type = server_type;
+ netlogon->nt5_ex.domain_uuid = domain_uuid;
+ netlogon->nt5_ex.forest = realm;
+ netlogon->nt5_ex.dns_domain = dns_domain;
+ netlogon->nt5_ex.pdc_dns_name = pdc_dns_name;
+ netlogon->nt5_ex.domain = flatname;
+ netlogon->nt5_ex.pdc_name = lp_netbios_name(lp_ctx);
+ netlogon->nt5_ex.user_name = user;
+ netlogon->nt5_ex.server_site = server_site;
+ netlogon->nt5_ex.client_site = client_site;
+
+ if (version & NETLOGON_NT_VERSION_5EX_WITH_IP) {
+ /* Clearly this needs to be fixed up for IPv6 */
+ extra_flags = NETLOGON_NT_VERSION_5EX_WITH_IP;
+ netlogon->nt5_ex.sockaddr.sa_family = 2;
+ netlogon->nt5_ex.sockaddr.pdc_ip = pdc_ip;
+ netlogon->nt5_ex.sockaddr.remaining = data_blob_talloc_zero(mem_ctx, 8);
+ }
+ netlogon->nt5_ex.nt_version = NETLOGON_NT_VERSION_1|NETLOGON_NT_VERSION_5EX|extra_flags;
+ netlogon->nt5_ex.lmnt_token = 0xFFFF;
+ netlogon->nt5_ex.lm20_token = 0xFFFF;
+
+ } else if (version & NETLOGON_NT_VERSION_5) {
+ netlogon->ntver = NETLOGON_NT_VERSION_5;
+
+ /* could check if the user exists */
+ if (user_known) {
+ netlogon->nt5.command = LOGON_SAM_LOGON_RESPONSE;
+ } else {
+ netlogon->nt5.command = LOGON_SAM_LOGON_USER_UNKNOWN;
+ }
+ netlogon->nt5.pdc_name = pdc_name;
+ netlogon->nt5.user_name = user;
+ netlogon->nt5.domain_name = flatname;
+ netlogon->nt5.domain_uuid = domain_uuid;
+ netlogon->nt5.forest = realm;
+ netlogon->nt5.dns_domain = dns_domain;
+ netlogon->nt5.pdc_dns_name = pdc_dns_name;
+ netlogon->nt5.pdc_ip = pdc_ip;
+ netlogon->nt5.server_type = server_type;
+ netlogon->nt5.nt_version = NETLOGON_NT_VERSION_1|NETLOGON_NT_VERSION_5;
+ netlogon->nt5.lmnt_token = 0xFFFF;
+ netlogon->nt5.lm20_token = 0xFFFF;
+
+ } else /* (version & NETLOGON_NT_VERSION_1) and all other cases */ {
+ netlogon->ntver = NETLOGON_NT_VERSION_1;
+ /* could check if the user exists */
+ if (user_known) {
+ netlogon->nt4.command = LOGON_SAM_LOGON_RESPONSE;
+ } else {
+ netlogon->nt4.command = LOGON_SAM_LOGON_USER_UNKNOWN;
+ }
+ netlogon->nt4.server = pdc_name;
+ netlogon->nt4.user_name = user;
+ netlogon->nt4.domain = flatname;
+ netlogon->nt4.nt_version = NETLOGON_NT_VERSION_1;
+ netlogon->nt4.lmnt_token = 0xFFFF;
+ netlogon->nt4.lm20_token = 0xFFFF;
}
return NT_STATUS_OK;
@@ -285,7 +384,7 @@ void cldapd_netlogon_request(struct cldap_socket *cldap,
const char *domain_sid = NULL;
int acct_control = -1;
int version = -1;
- union nbt_cldap_netlogon netlogon;
+ struct netlogon_samlogon_response netlogon;
NTSTATUS status = NT_STATUS_INVALID_PARAMETER;
TALLOC_CTX *tmp_ctx = talloc_new(cldap);
@@ -346,9 +445,9 @@ void cldapd_netlogon_request(struct cldap_socket *cldap,
DEBUG(5,("cldap netlogon query domain=%s host=%s user=%s version=%d guid=%s\n",
domain, host, user, version, domain_guid));
- status = cldapd_netlogon_fill(cldapd, tmp_ctx, domain, domain_guid,
- user, src->addr,
- version, cldapd->task->lp_ctx, &netlogon);
+ status = fill_netlogon_samlogon_response(cldapd->samctx, tmp_ctx, domain, NULL, NULL, domain_guid,
+ user, acct_control, src->addr,
+ version, cldapd->task->lp_ctx, &netlogon);
if (!NT_STATUS_IS_OK(status)) {
goto failed;
}
diff --git a/source4/client/cifsdd.c b/source4/client/cifsdd.c
index 8e25dab927..ce48c7bad1 100644
--- a/source4/client/cifsdd.c
+++ b/source4/client/cifsdd.c
@@ -24,6 +24,7 @@
#include "lib/cmdline/popt_common.h"
#include "libcli/resolve/resolve.h"
#include "libcli/raw/libcliraw.h"
+#include "lib/events/events.h"
#include "cifsdd.h"
#include "param/param.h"
@@ -354,6 +355,7 @@ static void print_transfer_stats(void)
}
static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx,
+ struct event_context *ev,
const char * which, const char **ports,
struct smbcli_options *smb_options)
{
@@ -375,13 +377,13 @@ static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx,
if (strcmp(which, "if") == 0) {
path = check_arg_pathname("if");
- handle = dd_open_path(resolve_ctx, path, ports,
+ handle = dd_open_path(resolve_ctx, ev, path, ports,
check_arg_numeric("ibs"), options,
smb_options);
} else if (strcmp(which, "of") == 0) {
options |= DD_WRITE;
path = check_arg_pathname("of");
- handle = dd_open_path(resolve_ctx, path, ports,
+ handle = dd_open_path(resolve_ctx, ev, path, ports,
check_arg_numeric("obs"), options,
smb_options);
} else {
@@ -396,7 +398,7 @@ static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx,
return(handle);
}
-static int copy_files(struct loadparm_context *lp_ctx)
+static int copy_files(struct event_context *ev, struct loadparm_context *lp_ctx)
{
uint8_t * iobuf; /* IO buffer. */
uint64_t iomax; /* Size of the IO buffer. */
@@ -433,12 +435,12 @@ static int copy_files(struct loadparm_context *lp_ctx)
DEBUG(4, ("IO buffer size is %llu, max xmit is %d\n",
(unsigned long long)iomax, options.max_xmit));
- if (!(ifile = open_file(lp_resolve_context(lp_ctx), "if",
+ if (!(ifile = open_file(lp_resolve_context(lp_ctx), ev, "if",
lp_smb_ports(lp_ctx), &options))) {
return(FILESYS_EXIT_CODE);
}
- if (!(ofile = open_file(lp_resolve_context(lp_ctx), "of",
+ if (!(ofile = open_file(lp_resolve_context(lp_ctx), ev, "of",
lp_smb_ports(lp_ctx), &options))) {
return(FILESYS_EXIT_CODE);
}
@@ -528,6 +530,7 @@ int main(int argc, const char ** argv)
{
int i;
const char ** dd_args;
+ struct event_context *ev;
poptContext pctx;
struct poptOption poptions[] = {
@@ -578,6 +581,8 @@ int main(int argc, const char ** argv)
}
}
+ ev = event_context_init(talloc_autofree_context());
+
gensec_init(cmdline_lp_ctx);
dump_args();
@@ -599,7 +604,7 @@ int main(int argc, const char ** argv)
CatchSignal(SIGINT, dd_handle_signal);
CatchSignal(SIGUSR1, dd_handle_signal);
- return(copy_files(cmdline_lp_ctx));
+ return(copy_files(ev, cmdline_lp_ctx));
}
/* vim: set sw=8 sts=8 ts=8 tw=79 : */
diff --git a/source4/client/cifsdd.h b/source4/client/cifsdd.h
index 810c882ea9..21a4ad4882 100644
--- a/source4/client/cifsdd.h
+++ b/source4/client/cifsdd.h
@@ -89,8 +89,10 @@ struct dd_iohandle
#define DD_OPLOCK 0x00000008
struct smbcli_options;
+struct event_context;
struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx,
+ struct event_context *ev,
const char * path,
const char **ports,
uint64_t io_size, int options,
diff --git a/source4/client/cifsddio.c b/source4/client/cifsddio.c
index 7028e85078..4297c30012 100644
--- a/source4/client/cifsddio.c
+++ b/source4/client/cifsddio.c
@@ -221,6 +221,7 @@ static bool smb_write_func(void * handle, uint8_t * buf, uint64_t wanted,
}
static struct smbcli_state * init_smb_session(struct resolve_context *resolve_ctx,
+ struct event_context *ev,
const char * host,
const char **ports,
const char * share,
@@ -233,8 +234,9 @@ static struct smbcli_state * init_smb_session(struct resolve_context *resolve_ct
* each connection, but for now, we just use the same one for both.
*/
ret = smbcli_full_connection(NULL, &cli, host, ports, share,
- NULL /* devtype */, cmdline_credentials, resolve_ctx,
- NULL /* events */, options);
+ NULL /* devtype */,
+ cmdline_credentials, resolve_ctx,
+ ev, options);
if (!NT_STATUS_IS_OK(ret)) {
fprintf(stderr, "%s: connecting to //%s/%s: %s\n",
@@ -293,6 +295,7 @@ static int open_smb_file(struct smbcli_state * cli,
}
static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx,
+ struct event_context *ev,
const char * host,
const char **ports,
const char * share,
@@ -319,7 +322,7 @@ static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx
smbh->h.io_write = smb_write_func;
smbh->h.io_seek = smb_seek_func;
- if ((smbh->cli = init_smb_session(resolve_ctx, host, ports, share,
+ if ((smbh->cli = init_smb_session(resolve_ctx, ev, host, ports, share,
smb_options)) == NULL) {
return(NULL);
}
@@ -336,6 +339,7 @@ static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx
/* ------------------------------------------------------------------------- */
struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx,
+ struct event_context *ev,
const char * path,
const char **ports,
uint64_t io_size,
@@ -355,7 +359,7 @@ struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx,
/* Skip over leading directory separators. */
while (*remain == '/' || *remain == '\\') { remain++; }
- return(open_cifs_handle(resolve_ctx, host, ports,
+ return(open_cifs_handle(resolve_ctx, ev, host, ports,
share, remain,
io_size, options, smb_options));
}
diff --git a/source4/client/client.c b/source4/client/client.c
index 775aa69d37..01197e8a9e 100644
--- a/source4/client/client.c
+++ b/source4/client/client.c
@@ -32,6 +32,7 @@
#include "includes.h"
#include "version.h"
#include "libcli/libcli.h"
+#include "lib/events/events.h"
#include "lib/cmdline/popt_common.h"
#include "librpc/gen_ndr/ndr_srvsvc_c.h"
#include "librpc/gen_ndr/ndr_lsa.h"
@@ -213,15 +214,18 @@ check the space on a device
****************************************************************************/
static int do_dskattr(struct smbclient_context *ctx)
{
- int total, bsize, avail;
+ uint32_t bsize;
+ uint64_t total, avail;
if (NT_STATUS_IS_ERR(smbcli_dskattr(ctx->cli->tree, &bsize, &total, &avail))) {
d_printf("Error in dskattr: %s\n",smbcli_errstr(ctx->cli->tree));
return 1;
}
- d_printf("\n\t\t%d blocks of size %d. %d blocks available\n",
- total, bsize, avail);
+ d_printf("\n\t\t%llu blocks of size %u. %llu blocks available\n",
+ (unsigned long long)total,
+ (unsigned)bsize,
+ (unsigned long long)avail);
return 0;
}
@@ -2545,7 +2549,9 @@ static void display_share_result(struct srvsvc_NetShareCtr1 *ctr1)
/****************************************************************************
try and browse available shares on a host
****************************************************************************/
-static bool browse_host(struct loadparm_context *lp_ctx, const char *query_host)
+static bool browse_host(struct loadparm_context *lp_ctx,
+ struct event_context *ev_ctx,
+ const char *query_host)
{
struct dcerpc_pipe *p;
char *binding;
@@ -2559,7 +2565,7 @@ static bool browse_host(struct loadparm_context *lp_ctx, const char *query_host)
status = dcerpc_pipe_connect(mem_ctx, &p, binding,
&ndr_table_srvsvc,
- cmdline_credentials, NULL,
+ cmdline_credentials, ev_ctx,
lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Failed to connect to %s - %s\n",
@@ -3021,6 +3027,7 @@ static int process_stdin(struct smbclient_context *ctx)
return a connection to a server
*******************************************************/
static bool do_connect(struct smbclient_context *ctx,
+ struct event_context *ev_ctx,
struct resolve_context *resolve_ctx,
const char *specified_server, const char **ports,
const char *specified_share,
@@ -3044,8 +3051,7 @@ static bool do_connect(struct smbclient_context *ctx,
status = smbcli_full_connection(ctx, &ctx->cli, server, ports,
share, NULL, cred, resolve_ctx,
- cli_credentials_get_event_context(cred),
- options);
+ ev_ctx, options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Connection to \\\\%s\\%s failed - %s\n",
server, share, nt_errstr(status));
@@ -3059,9 +3065,12 @@ static bool do_connect(struct smbclient_context *ctx,
/****************************************************************************
handle a -L query
****************************************************************************/
-static int do_host_query(struct loadparm_context *lp_ctx, const char *query_host, const char *workgroup)
+static int do_host_query(struct loadparm_context *lp_ctx,
+ struct event_context *ev_ctx,
+ const char *query_host,
+ const char *workgroup)
{
- browse_host(lp_ctx, query_host);
+ browse_host(lp_ctx, ev_ctx, query_host);
list_servers(workgroup);
return(0);
}
@@ -3070,7 +3079,12 @@ static int do_host_query(struct loadparm_context *lp_ctx, const char *query_host
/****************************************************************************
handle a message operation
****************************************************************************/
-static int do_message_op(const char *netbios_name, const char *desthost, const char **destports, const char *destip, int name_type, struct resolve_context *resolve_ctx, struct smbcli_options *options)
+static int do_message_op(const char *netbios_name, const char *desthost,
+ const char **destports, const char *destip,
+ int name_type,
+ struct event_context *ev_ctx,
+ struct resolve_context *resolve_ctx,
+ struct smbcli_options *options)
{
struct nbt_name called, calling;
const char *server_name;
@@ -3082,7 +3096,9 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
server_name = destip ? destip : desthost;
- if (!(cli=smbcli_state_init(NULL)) || !smbcli_socket_connect(cli, server_name, destports, resolve_ctx, options)) {
+ if (!(cli = smbcli_state_init(NULL)) ||
+ !smbcli_socket_connect(cli, server_name, destports,
+ ev_ctx, resolve_ctx, options)) {
d_printf("Connection to %s failed\n", server_name);
return 1;
}
@@ -3111,11 +3127,6 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
const char *query_host = NULL;
bool message = false;
const char *desthost = NULL;
-#ifdef KANJI
- const char *term_code = KANJI;
-#else
- const char *term_code = "";
-#endif /* KANJI */
poptContext pc;
const char *service = NULL;
int port = 0;
@@ -3123,6 +3134,7 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
int rc = 0;
int name_type = 0x20;
TALLOC_CTX *mem_ctx;
+ struct event_context *ev_ctx;
struct smbclient_context *ctx;
const char *cmdstr = NULL;
struct smbcli_options smb_options;
@@ -3134,7 +3146,6 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
{ "ip-address", 'I', POPT_ARG_STRING, NULL, 'I', "Use this IP to connect to", "IP" },
{ "stderr", 'E', POPT_ARG_NONE, NULL, 'E', "Write messages to stderr instead of stdout" },
{ "list", 'L', POPT_ARG_STRING, NULL, 'L', "Get a list of shares available on a host", "HOST" },
- { "terminal", 't', POPT_ARG_STRING, NULL, 't', "Terminal I/O code {sjis|euc|jis7|jis8|junet|hex}", "CODE" },
{ "directory", 'D', POPT_ARG_STRING, NULL, 'D', "Start from directory", "DIR" },
{ "command", 'c', POPT_ARG_STRING, &cmdstr, 'c', "Execute semicolon separated commands" },
{ "send-buffer", 'b', POPT_ARG_INT, NULL, 'b', "Changes the transmit/send buffer", "BYTES" },
@@ -3176,9 +3187,6 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
case 'L':
query_host = strdup(poptGetOptArg(pc));
break;
- case 't':
- term_code = strdup(poptGetOptArg(pc));
- break;
case 'D':
base_directory = strdup(poptGetOptArg(pc));
break;
@@ -3220,6 +3228,8 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
lp_smbcli_options(cmdline_lp_ctx, &smb_options);
+ ev_ctx = event_context_init(talloc_autofree_context());
+
DEBUG( 3, ( "Client started (version %s).\n", SAMBA_VERSION_STRING ) );
if (query_host && (p=strchr_m(query_host,'#'))) {
@@ -3229,14 +3239,23 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c
}
if (query_host) {
- return do_host_query(cmdline_lp_ctx, query_host, lp_workgroup(cmdline_lp_ctx));
+ rc = do_host_query(cmdline_lp_ctx, ev_ctx, query_host,
+ lp_workgroup(cmdline_lp_ctx));
+ return rc;
}
if (message) {
- return do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), dest_ip, name_type, lp_resolve_context(cmdline_lp_ctx), &smb_options);
+ rc = do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost,
+ lp_smb_ports(cmdline_lp_ctx), dest_ip,
+ name_type, ev_ctx,
+ lp_resolve_context(cmdline_lp_ctx),
+ &smb_options);
+ return rc;
}
- if (!do_connect(ctx, lp_resolve_context(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), service, cmdline_credentials, &smb_options))
+ if (!do_connect(ctx, ev_ctx, lp_resolve_context(cmdline_lp_ctx),
+ desthost, lp_smb_ports(cmdline_lp_ctx), service,
+ cmdline_credentials, &smb_options))
return 1;
if (base_directory)
diff --git a/source4/client/config.mk b/source4/client/config.mk
index 2085faf61e..877544a09a 100644
--- a/source4/client/config.mk
+++ b/source4/client/config.mk
@@ -4,8 +4,6 @@
# Start BINARY smbclient
[BINARY::smbclient]
INSTALLDIR = BINDIR
-OBJ_FILES = \
- client.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-HOSTCONFIG \
SMBREADLINE \
@@ -20,13 +18,12 @@ PRIVATE_DEPENDENCIES = \
# End BINARY smbclient
#################################
+smbclient_OBJ_FILES = $(clientsrcdir)/client.o
+
#################################
# Start BINARY cifsdd
[BINARY::cifsdd]
INSTALLDIR = BINDIR
-OBJ_FILES = \
- cifsdd.o \
- cifsddio.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-HOSTCONFIG \
LIBCLI_SMB \
@@ -36,3 +33,4 @@ PRIVATE_DEPENDENCIES = \
# End BINARY sdd
#################################
+cifsdd_OBJ_FILES = $(addprefix $(clientsrcdir)/, cifsdd.o cifsddio.o)
diff --git a/source4/cluster/config.mk b/source4/cluster/config.mk
index 8b225202fb..e841956a0c 100644
--- a/source4/cluster/config.mk
+++ b/source4/cluster/config.mk
@@ -1,7 +1,7 @@
+ctdbsrcdir = $(clustersrcdir)/ctdb
mkinclude ctdb/config.mk
-####################
[SUBSYSTEM::CLUSTER]
-OBJ_FILES = cluster.o \
- local.o
PRIVATE_DEPENDENCIES = ctdb
+
+CLUSTER_OBJ_FILES = $(addprefix $(clustersrcdir)/, cluster.o local.o)
diff --git a/source4/cluster/ctdb/config.mk b/source4/cluster/ctdb/config.mk
index b8199cafe4..28b18c17ce 100644
--- a/source4/cluster/ctdb/config.mk
+++ b/source4/cluster/ctdb/config.mk
@@ -1,20 +1,24 @@
##################
[SUBSYSTEM::brlock_ctdb]
-OBJ_FILES = brlock_ctdb.o
PUBLIC_DEPENDENCIES = ctdb
+brlock_ctdb_OBJ_FILES = $(ctdbsrcdir)/brlock_ctdb.o
+
##################
[SUBSYSTEM::opendb_ctdb]
-OBJ_FILES = opendb_ctdb.o
PUBLIC_DEPENDENCIES = ctdb
+opendb_ctdb_OBJ_FILES = $(ctdbsrcdir)/opendb_ctdb.o
+
##################
[SUBSYSTEM::ctdb]
-OBJ_FILES = \
+PUBLIC_DEPENDENCIES = TDB_WRAP LIBTALLOC
+
+ctdb_OBJ_FILES = $(addprefix $(ctdbsrcdir)/, \
ctdb_cluster.o \
client/ctdb_client.o \
common/ctdb_io.o \
common/ctdb_ltdb.o \
common/ctdb_message.o \
- common/ctdb_util.o
-PUBLIC_DEPENDENCIES = TDB_WRAP LIBTALLOC
+ common/ctdb_util.o)
+
diff --git a/source4/cluster/ctdb/include/includes.h b/source4/cluster/ctdb/include/includes.h
index 48c3c2ea4c..0ed44cbad0 100644
--- a/source4/cluster/ctdb/include/includes.h
+++ b/source4/cluster/ctdb/include/includes.h
@@ -21,7 +21,7 @@ extern int LogLevel;
#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
#ifndef discard_const
-#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
+#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
#endif
struct timeval timeval_zero(void);
diff --git a/source4/configure.ac b/source4/configure.ac
index 66fb69694e..73d3ffd4d9 100644
--- a/source4/configure.ac
+++ b/source4/configure.ac
@@ -31,7 +31,7 @@ m4_include(pidl/config.m4)
AC_CONFIG_FILES(lib/registry/registry.pc)
AC_CONFIG_FILES(librpc/dcerpc.pc)
AC_CONFIG_FILES(librpc/ndr.pc)
-AC_CONFIG_FILES(torture/torture.pc)
+AC_CONFIG_FILES(lib/torture/torture.pc)
AC_CONFIG_FILES(auth/gensec/gensec.pc)
AC_CONFIG_FILES(param/samba-hostconfig.pc)
AC_CONFIG_FILES(librpc/dcerpc_samr.pc)
@@ -59,7 +59,6 @@ SMB_EXT_LIB_FROM_PKGCONFIG(LIBLDB, ldb >= 0.9.1,
[
SMB_INCLUDE_MK(lib/ldb/ldb_ildap/config.mk)
SMB_INCLUDE_MK(lib/ldb/tools/config.mk)
- SMB_SUBSYSTEM(ldb_map, [], [LIBLDB])
define_ldb_modulesdir=no
],
[
@@ -161,25 +160,7 @@ 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!
-
-package config;
-require Exporter;
-@ISA = qw(Exporter);
-@EXPORT_OK = qw(%enabled %config);
-use strict;
-
-use vars qw(%enabled %config);
-
-%config = (AC_FOREACH([AC_Var], m4_defn([_AC_SUBST_VARS]), [
- AC_Var => '$AC_Var',])
-);
-
-$SMB_INFO_ENABLES
-1;
-CEOF
+SMB_WRITE_PERLVARS(build/smb_build/config.pm)
echo "configure: creating config.mk"
cat >config.mk<<CEOF
@@ -189,32 +170,7 @@ $SMB_INFO_SUBSYSTEMS
$SMB_INFO_LIBRARIES
CEOF
-AC_OUTPUT_COMMANDS(
-[
-test "x$ac_abs_srcdir" != "x$ac_abs_builddir" && (
- cd $builddir;
- # NOTE: We *must* use -R so we don't follow symlinks (at least on BSD
- # systems).
- test -d heimdal || cp -R $srcdir/heimdal $builddir/
- test -d heimdal_build || cp -R $srcdir/heimdal_build $builddir/
- test -d build || builddir="$builddir" \
- srcdir="$srcdir" \
- $PERL ${srcdir}/script/buildtree.pl
- )
-
-$PERL -I${builddir} -I${builddir}/build \
- -I${srcdir} -I${srcdir}/build \
- ${srcdir}/build/smb_build/main.pl || exit $?
-],
-[
-srcdir="$srcdir"
-builddir="$builddir"
-PERL="$PERL"
-
-export PERL
-export srcdir
-export builddir
-])
+SMB_BUILD_RUN(data.mk)
AC_OUTPUT
cmp include/config_tmp.h include/config.h >/dev/null 2>&1
@@ -223,13 +179,7 @@ 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
+SMB_WRITE_MAKEVARS(mkconfig.mk)
if test $USESHARED = true
then
diff --git a/source4/dsdb/common/sidmap.c b/source4/dsdb/common/sidmap.c
index 2144d61dfc..20bba7a0d9 100644
--- a/source4/dsdb/common/sidmap.c
+++ b/source4/dsdb/common/sidmap.c
@@ -49,14 +49,15 @@ struct sidmap_context {
/*
open a sidmap context - use talloc_free to close
*/
-struct sidmap_context *sidmap_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
+struct sidmap_context *sidmap_open(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx,
+ struct loadparm_context *lp_ctx)
{
struct sidmap_context *sidmap;
sidmap = talloc(mem_ctx, struct sidmap_context);
if (sidmap == NULL) {
return NULL;
}
- sidmap->samctx = samdb_connect(sidmap, lp_ctx, system_session(sidmap, lp_ctx));
+ sidmap->samctx = samdb_connect(sidmap, ev_ctx, lp_ctx, system_session(sidmap, lp_ctx));
if (sidmap->samctx == NULL) {
talloc_free(sidmap);
return NULL;
diff --git a/source4/dsdb/config.mk b/source4/dsdb/config.mk
index 1a20add91c..7b700fda22 100644
--- a/source4/dsdb/config.mk
+++ b/source4/dsdb/config.mk
@@ -5,53 +5,57 @@ mkinclude samdb/ldb_modules/config.mk
################################################
# Start SUBSYSTEM SAMDB
[SUBSYSTEM::SAMDB]
-PRIVATE_PROTO_HEADER = samdb/samdb_proto.h
PUBLIC_DEPENDENCIES = HEIMDAL_KRB5
PRIVATE_DEPENDENCIES = LIBNDR NDR_MISC NDR_DRSUAPI NDR_DRSBLOBS NSS_WRAPPER \
auth_system_session LDAP_ENCODE LIBCLI_AUTH LIBNDR \
SAMDB_SCHEMA LDB_WRAP SAMDB_COMMON
-OBJ_FILES = \
+
+
+SAMDB_OBJ_FILES = $(addprefix $(dsdbsrcdir)/, \
samdb/samdb.o \
samdb/samdb_privilege.o \
samdb/cracknames.o \
- repl/replicated_objects.o
-
+ repl/replicated_objects.o)
+$(eval $(call proto_header_template,$(dsdbsrcdir)/samdb/samdb_proto.h,$(SAMDB_OBJ_FILES:.o=.c)))
# PUBLIC_HEADERS += dsdb/samdb/samdb.h
[SUBSYSTEM::SAMDB_COMMON]
-PRIVATE_PROTO_HEADER = common/proto.h
PRIVATE_DEPENDENCIES = LIBLDB
-OBJ_FILES = \
- common/sidmap.o \
- common/flag_mapping.o \
- common/util.o
+
+SAMDB_COMMON_OBJ_FILES = $(addprefix $(dsdbsrcdir)/common/, \
+ sidmap.o \
+ flag_mapping.o \
+ util.o)
+$(eval $(call proto_header_template,$(dsdbsrcdir)/common/proto.h,$(SAMDB_COMMON_OBJ_FILES:.o=.c)))
[SUBSYSTEM::SAMDB_SCHEMA]
-PRIVATE_PROTO_HEADER = schema/proto.h
PRIVATE_DEPENDENCIES = SAMDB_COMMON NDR_DRSUAPI NDR_DRSBLOBS
-OBJ_FILES = \
- schema/schema_init.o \
- schema/schema_syntax.o \
- schema/schema_constructed.o \
+SAMDB_SCHEMA_OBJ_FILES = $(addprefix $(dsdbsrcdir)/schema/, \
+ schema_init.o \
+ schema_syntax.o \
+ schema_constructed.o)
+$(eval $(call proto_header_template,$(dsdbsrcdir)/schema/proto.h,$(SAMDB_SCHEMA_OBJ_FILES:.o=.c)))
# PUBLIC_HEADERS += dsdb/schema/schema.h
#######################
# Start SUBSYSTEM DREPL_SRV
[MODULE::DREPL_SRV]
INIT_FUNCTION = server_service_drepl_init
-SUBSYSTEM = service
-OBJ_FILES = \
- repl/drepl_service.o \
- repl/drepl_periodic.o \
- repl/drepl_partitions.o \
- repl/drepl_out_pull.o \
- repl/drepl_out_helpers.o
-PRIVATE_PROTO_HEADER = repl/drepl_service_proto.h
+SUBSYSTEM = smbd
PRIVATE_DEPENDENCIES = \
SAMDB \
process_model
# End SUBSYSTEM DREPL_SRV
#######################
+
+DREPL_SRV_OBJ_FILES = $(addprefix $(dsdbsrcdir)/repl/, \
+ drepl_service.o \
+ drepl_periodic.o \
+ drepl_partitions.o \
+ drepl_out_pull.o \
+ drepl_out_helpers.o)
+
+$(eval $(call proto_header_template,$(dsdbsrcdir)/repl/drepl_service_proto.h,$(DREPL_SRV_OBJ_FILES:.o=.c)))
diff --git a/source4/dsdb/repl/drepl_service.c b/source4/dsdb/repl/drepl_service.c
index 3375059e99..e485c50a47 100644
--- a/source4/dsdb/repl/drepl_service.c
+++ b/source4/dsdb/repl/drepl_service.c
@@ -51,7 +51,7 @@ static WERROR dreplsrv_connect_samdb(struct dreplsrv_service *service, struct lo
const struct GUID *ntds_guid;
struct drsuapi_DsBindInfo28 *bind_info28;
- service->samdb = samdb_connect(service, lp_ctx, service->system_session_info);
+ service->samdb = samdb_connect(service, service->task->event_ctx, lp_ctx, service->system_session_info);
if (!service->samdb) {
return WERR_DS_SERVICE_UNAVAILABLE;
}
diff --git a/source4/dsdb/samdb/cracknames.c b/source4/dsdb/samdb/cracknames.c
index b9333e451b..da10cbb057 100644
--- a/source4/dsdb/samdb/cracknames.c
+++ b/source4/dsdb/samdb/cracknames.c
@@ -1197,6 +1197,7 @@ NTSTATUS crack_service_principal_name(struct ldb_context *sam_ctx,
}
NTSTATUS crack_name_to_nt4_name(TALLOC_CTX *mem_ctx,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
uint32_t format_offered,
const char *name,
@@ -1214,7 +1215,7 @@ NTSTATUS crack_name_to_nt4_name(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
- ldb = samdb_connect(mem_ctx, lp_ctx, system_session(mem_ctx, lp_ctx));
+ ldb = samdb_connect(mem_ctx, ev_ctx, lp_ctx, system_session(mem_ctx, lp_ctx));
if (ldb == NULL) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
@@ -1259,6 +1260,7 @@ NTSTATUS crack_name_to_nt4_name(TALLOC_CTX *mem_ctx,
}
NTSTATUS crack_auto_name_to_nt4_name(TALLOC_CTX *mem_ctx,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
const char *name,
const char **nt4_domain,
@@ -1283,5 +1285,5 @@ NTSTATUS crack_auto_name_to_nt4_name(TALLOC_CTX *mem_ctx,
format_offered = DRSUAPI_DS_NAME_FORMAT_CANONICAL;
}
- return crack_name_to_nt4_name(mem_ctx, lp_ctx, format_offered, name, nt4_domain, nt4_account);
+ return crack_name_to_nt4_name(mem_ctx, ev_ctx, lp_ctx, format_offered, name, nt4_domain, nt4_account);
}
diff --git a/source4/dsdb/samdb/ldb_modules/config.mk b/source4/dsdb/samdb/ldb_modules/config.mk
index de93b5638d..eae190a85f 100644
--- a/source4/dsdb/samdb/ldb_modules/config.mk
+++ b/source4/dsdb/samdb/ldb_modules/config.mk
@@ -4,12 +4,12 @@
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC LIBNDR NDR_MISC
-INIT_FUNCTION = objectguid_module_module_ops
-OBJ_FILES = \
- objectguid.o
+INIT_FUNCTION = LDB_MODULE(objectguid)
# End MODULE ldb_objectguid
################################################
+ldb_objectguid_OBJ_FILES = dsdb/samdb/ldb_modules/objectguid.o
+
################################################
# Start MODULE ldb_repl_meta_data
[MODULE::ldb_repl_meta_data]
@@ -17,107 +17,113 @@ SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC LIBNDR NDR_MISC NDR_DRSUAPI \
NDR_DRSBLOBS LIBNDR
-INIT_FUNCTION = repl_meta_data_module_module_ops
-OBJ_FILES = \
- repl_meta_data.o
+INIT_FUNCTION = LDB_MODULE(repl_meta_data)
# End MODULE ldb_repl_meta_data
################################################
+ldb_repl_meta_data_OBJ_FILES = \
+ dsdb/samdb/ldb_modules/repl_meta_data.o
+
################################################
# Start MODULE ldb_dsdb_cache
[MODULE::ldb_dsdb_cache]
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC
-INIT_FUNCTION = dsdb_cache_module_module_ops
-OBJ_FILES = \
- dsdb_cache.o
+INIT_FUNCTION = LDB_MODULE(dsdb_cache)
# End MODULE ldb_dsdb_cache
################################################
+ldb_dsdb_cache_OBJ_FILES = \
+ dsdb/samdb/ldb_modules/dsdb_cache.o
+
################################################
# Start MODULE ldb_schema_fsmo
[MODULE::ldb_schema_fsmo]
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC
-INIT_FUNCTION = schema_fsmo_module_module_ops
-OBJ_FILES = \
- schema_fsmo.o
+INIT_FUNCTION = LDB_MODULE(schema_fsmo)
# End MODULE ldb_schema_fsmo
################################################
+ldb_schema_fsmo_OBJ_FILES = \
+ dsdb/samdb/ldb_modules/schema_fsmo.o
+
################################################
# Start MODULE ldb_naming_fsmo
[MODULE::ldb_naming_fsmo]
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC
-INIT_FUNCTION = naming_fsmo_module_module_ops
-OBJ_FILES = \
- naming_fsmo.o
+INIT_FUNCTION = LDB_MODULE(naming_fsmo)
# End MODULE ldb_naming_fsmo
################################################
+ldb_naming_fsmo_OBJ_FILES = \
+ dsdb/samdb/ldb_modules/naming_fsmo.o
+
################################################
# Start MODULE ldb_pdc_fsmo
[MODULE::ldb_pdc_fsmo]
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC
-INIT_FUNCTION = pdc_fsmo_module_module_ops
-OBJ_FILES = \
- pdc_fsmo.o
+INIT_FUNCTION = LDB_MODULE(pdc_fsmo)
# End MODULE ldb_pdc_fsmo
################################################
+ldb_pdc_fsmo_OBJ_FILES = \
+ dsdb/samdb/ldb_modules/pdc_fsmo.o
+
################################################
# Start MODULE ldb_samldb
[MODULE::ldb_samldb]
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC LDAP_ENCODE NDR_MISC SAMDB
-INIT_FUNCTION = samldb_module_module_ops
-OBJ_FILES = \
- samldb.o
+INIT_FUNCTION = LDB_MODULE(samldb)
#
# End MODULE ldb_samldb
################################################
+ldb_samldb_OBJ_FILES = \
+ dsdb/samdb/ldb_modules/samldb.o
+
################################################
# Start MODULE ldb_samba3sam
[MODULE::ldb_samba3sam]
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
-INIT_FUNCTION = &ldb_samba3sam_module_module_ops
-PRIVATE_DEPENDENCIES = LIBTALLOC ldb_map SMBPASSWD NSS_WRAPPER LIBSECURITY \
+INIT_FUNCTION = LDB_MODULE(samba3sam)
+PRIVATE_DEPENDENCIES = LIBTALLOC SMBPASSWD NSS_WRAPPER LIBSECURITY \
NDR_SECURITY
-OBJ_FILES = \
- samba3sam.o
-#
# End MODULE ldb_samldb
################################################
+ldb_samba3sam_OBJ_FILES = \
+ dsdb/samdb/ldb_modules/samba3sam.o
+
################################################
# Start MODULE ldb_simple_ldap_map
[MODULE::ldb_simple_ldap_map]
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
-INIT_FUNCTION = &ldb_simple_ldap_map_module_module_ops
-PRIVATE_DEPENDENCIES = LIBTALLOC ldb_map LIBNDR NDR_MISC
+INIT_FUNCTION = LDB_MODULE(simple_ldap_map)
+PRIVATE_DEPENDENCIES = LIBTALLOC LIBNDR NDR_MISC
ENABLE = YES
ALIASES = entryuuid nsuniqueid
-OBJ_FILES = \
- simple_ldap_map.o
-#
# End MODULE ldb_entryuuid
################################################
+ldb_simple_ldap_map_OBJ_FILES = \
+ dsdb/samdb/ldb_modules/simple_ldap_map.o
+
# ################################################
# # Start MODULE ldb_proxy
# [MODULE::ldb_proxy]
# SUBSYSTEM = LIBLDB
-# INIT_FUNCTION = proxy_module_module_ops
+# INIT_FUNCTION = LDB_MODULE(proxy)
# OBJ_FILES = \
# proxy.o
#
@@ -131,103 +137,98 @@ OBJ_FILES = \
SUBSYSTEM = LIBLDB
PRIVATE_DEPENDENCIES = LIBTALLOC SAMDB
OUTPUT_TYPE = SHARED_LIBRARY
-INIT_FUNCTION = rootdse_module_module_ops
-OBJ_FILES = \
- rootdse.o
-#
+INIT_FUNCTION = LDB_MODULE(rootdse)
# End MODULE ldb_rootdse
################################################
+ldb_rootdse_OBJ_FILES = dsdb/samdb/ldb_modules/rootdse.o
+
################################################
# Start MODULE ldb_password_hash
[MODULE::ldb_password_hash]
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
-INIT_FUNCTION = password_hash_module_module_ops
-OBJ_FILES = password_hash.o
+INIT_FUNCTION = LDB_MODULE(password_hash)
PRIVATE_DEPENDENCIES = HEIMDAL_HDB_KEYS LIBTALLOC HEIMDAL_KRB5 LDAP_ENCODE \
LIBCLI_AUTH NDR_DRSBLOBS KERBEROS SAMDB
-#
# End MODULE ldb_password_hash
################################################
+ldb_password_hash_OBJ_FILES = dsdb/samdb/ldb_modules/password_hash.o
+
################################################
# Start MODULE ldb_local_password
[MODULE::ldb_local_password]
PRIVATE_DEPENDENCIES = LIBTALLOC LIBNDR SAMDB
OUTPUT_TYPE = SHARED_LIBRARY
SUBSYSTEM = LIBLDB
-INIT_FUNCTION = local_password_module_module_ops
-OBJ_FILES = local_password.o
-#
+INIT_FUNCTION = LDB_MODULE(local_password)
# End MODULE ldb_local_password
################################################
+ldb_local_password_OBJ_FILES = dsdb/samdb/ldb_modules/local_password.o
+
################################################
# Start MODULE ldb_kludge_acl
[MODULE::ldb_kludge_acl]
PRIVATE_DEPENDENCIES = LIBTALLOC LIBSECURITY SAMDB
OUTPUT_TYPE = SHARED_LIBRARY
SUBSYSTEM = LIBLDB
-INIT_FUNCTION = &ldb_kludge_acl_module_ops
-OBJ_FILES = \
- kludge_acl.o
-#
+INIT_FUNCTION = LDB_MODULE(kludge_acl)
+
# End MODULE ldb_kludge_acl
################################################
+ldb_kludge_acl_OBJ_FILES = dsdb/samdb/ldb_modules/kludge_acl.o
+
################################################
# Start MODULE ldb_extended_dn
[MODULE::ldb_extended_dn]
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC LIBNDR LIBSECURITY SAMDB
-INIT_FUNCTION = &ldb_extended_dn_module_ops
-OBJ_FILES = \
- extended_dn.o
-#
+INIT_FUNCTION = LDB_MODULE(extended_dn)
# End MODULE ldb_extended_dn
################################################
+ldb_extended_dn_OBJ_FILES = dsdb/samdb/ldb_modules/extended_dn.o
+
################################################
# Start MODULE ldb_show_deleted
[MODULE::ldb_show_deleted]
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC
-INIT_FUNCTION = &ldb_show_deleted_module_ops
-OBJ_FILES = \
- show_deleted.o
-#
+INIT_FUNCTION = LDB_MODULE(show_deleted)
# End MODULE ldb_show_deleted
################################################
+ldb_show_deleted_OBJ_FILES = dsdb/samdb/ldb_modules/show_deleted.o
+
################################################
# Start MODULE ldb_partition
[MODULE::ldb_partition]
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC SAMDB
-INIT_FUNCTION = &ldb_partition_module_ops
-OBJ_FILES = \
- partition.o
-#
+INIT_FUNCTION = LDB_MODULE(partition)
# End MODULE ldb_partition
################################################
+ldb_partition_OBJ_FILES = dsdb/samdb/ldb_modules/partition.o
+
################################################
# Start MODULE ldb_schema
[MODULE::ldb_schema]
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC LIBLDB
-INIT_FUNCTION = &ldb_schema_module_ops
-OBJ_FILES = \
- schema.o schema_syntax.o
-#
+INIT_FUNCTION = LDB_MODULE(schema)
# End MODULE ldb_schema
################################################
+ldb_schema_OBJ_FILES = $(addprefix dsdb/samdb/ldb_modules/, schema.o schema_syntax.o)
+
################################################
# Start MODULE ldb_update_kt
[MODULE::ldb_update_keytab]
@@ -235,111 +236,110 @@ SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC CREDENTIALS
#Also depends on credentials, but that would loop
-INIT_FUNCTION = &ldb_update_kt_module_ops
-OBJ_FILES = \
- update_keytab.o
-#
+INIT_FUNCTION = LDB_MODULE(update_kt)
# End MODULE ldb_update_kt
################################################
+ldb_update_keytab_OBJ_FILES = dsdb/samdb/ldb_modules/update_keytab.o
+
################################################
# Start MODULE ldb_objectclass
[MODULE::ldb_objectclass]
-INIT_FUNCTION = &ldb_objectclass_module_ops
+INIT_FUNCTION = LDB_MODULE(objectclass)
OUTPUT_TYPE = SHARED_LIBRARY
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC LIBSECURITY NDR_SECURITY SAMDB
SUBSYSTEM = LIBLDB
-OBJ_FILES = \
- objectclass.o
# End MODULE ldb_objectclass
################################################
+ldb_objectclass_OBJ_FILES = dsdb/samdb/ldb_modules/objectclass.o
+
################################################
# Start MODULE ldb_subtree_rename
[MODULE::ldb_subtree_rename]
-INIT_FUNCTION = &ldb_subtree_rename_module_ops
+INIT_FUNCTION = LDB_MODULE(subtree_rename)
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC
SUBSYSTEM = LIBLDB
-OBJ_FILES = \
- subtree_rename.o
# End MODULE ldb_subtree_rename
################################################
+ldb_subtree_rename_OBJ_FILES = dsdb/samdb/ldb_modules/subtree_rename.o
+
################################################
# Start MODULE ldb_subtree_rename
[MODULE::ldb_subtree_delete]
-INIT_FUNCTION = &ldb_subtree_delete_module_ops
+INIT_FUNCTION = LDB_MODULE(subtree_delete)
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC
SUBSYSTEM = LIBLDB
-OBJ_FILES = \
- subtree_delete.o
# End MODULE ldb_subtree_rename
################################################
+ldb_subtree_delete_OBJ_FILES = dsdb/samdb/ldb_modules/subtree_delete.o
+
################################################
# Start MODULE ldb_linked_attributes
[MODULE::ldb_linked_attributes]
-INIT_FUNCTION = &ldb_linked_attributes_module_ops
+INIT_FUNCTION = LDB_MODULE(linked_attributes)
CFLAGS = -Ilib/ldb/include
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC SAMDB
SUBSYSTEM = LIBLDB
-OBJ_FILES = \
- linked_attributes.o
# End MODULE ldb_linked_attributes
################################################
+ldb_linked_attributes_OBJ_FILES = dsdb/samdb/ldb_modules/linked_attributes.o
+
################################################
# Start MODULE ldb_ranged_results
[MODULE::ldb_ranged_results]
-INIT_FUNCTION = &ldb_ranged_results_module_ops
+INIT_FUNCTION = LDB_MODULE(ranged_results)
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC
SUBSYSTEM = LIBLDB
-OBJ_FILES = \
- ranged_results.o
# End MODULE ldb_ranged_results
################################################
+ldb_ranged_results_OBJ_FILES = dsdb/samdb/ldb_modules/ranged_results.o
+
################################################
# Start MODULE ldb_anr
[MODULE::ldb_anr]
-INIT_FUNCTION = &ldb_anr_module_ops
+INIT_FUNCTION = LDB_MODULE(anr)
CFLAGS = -Ilib/ldb/include
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL SAMDB
SUBSYSTEM = LIBLDB
-OBJ_FILES = \
- anr.o
# End MODULE ldb_anr
################################################
+ldb_anr_OBJ_FILES = dsdb/samdb/ldb_modules/anr.o
+
################################################
# Start MODULE ldb_normalise
[MODULE::ldb_normalise]
-INIT_FUNCTION = &ldb_normalise_module_ops
+INIT_FUNCTION = LDB_MODULE(normalise)
CFLAGS = -Ilib/ldb/include
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL SAMDB
SUBSYSTEM = LIBLDB
-OBJ_FILES = \
- normalise.o
# End MODULE ldb_normalise
################################################
+ldb_normalise_OBJ_FILES = dsdb/samdb/ldb_modules/normalise.o
+
################################################
# Start MODULE ldb_instancetype
[MODULE::ldb_instancetype]
-INIT_FUNCTION = &ldb_instancetype_module_ops
+INIT_FUNCTION = LDB_MODULE(instancetype)
CFLAGS = -Ilib/ldb/include
OUTPUT_TYPE = SHARED_LIBRARY
-PRIVATE_DEPENDENCIES = LIBTALLOC
+PRIVATE_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL SAMDB
SUBSYSTEM = LIBLDB
-OBJ_FILES = \
- instancetype.o
# End MODULE ldb_instancetype
################################################
+ldb_instancetype_OBJ_FILES = dsdb/samdb/ldb_modules/instancetype.o
+
diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c
index 3235b24ef9..50f333d095 100644
--- a/source4/dsdb/samdb/ldb_modules/rootdse.c
+++ b/source4/dsdb/samdb/ldb_modules/rootdse.c
@@ -26,6 +26,7 @@
#include "lib/ldb/include/ldb_private.h"
#include "system/time.h"
#include "dsdb/samdb/samdb.h"
+#include "version.h"
struct private_data {
int num_controls;
@@ -202,6 +203,13 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
}
}
+ if (schema && do_attribute_explicit(attrs, "vendorVersion")) {
+ if (ldb_msg_add_fmt(msg, "vendorVersion",
+ "%s", SAMBA_VERSION_STRING) != 0) {
+ goto failed;
+ }
+ }
+
/* TODO: lots more dynamic attributes should be added here */
return LDB_SUCCESS;
diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c
index 3b67ca19d3..88590f306b 100644
--- a/source4/dsdb/samdb/ldb_modules/samldb.c
+++ b/source4/dsdb/samdb/ldb_modules/samldb.c
@@ -484,8 +484,7 @@ static int samldb_fill_group_object(struct ldb_module *module, const struct ldb_
return ret;
}
-static int samldb_fill_user_or_computer_object(struct ldb_module *module, const struct ldb_message *msg,
- struct ldb_message **ret_msg)
+static int samldb_fill_user_or_computer_object(struct ldb_module *module, const struct ldb_message *msg, struct ldb_message **ret_msg)
{
int ret;
char *name;
diff --git a/source4/dsdb/samdb/ldb_modules/update_keytab.c b/source4/dsdb/samdb/ldb_modules/update_keytab.c
index 54362dcfd4..b36c2c9b71 100644
--- a/source4/dsdb/samdb/ldb_modules/update_keytab.c
+++ b/source4/dsdb/samdb/ldb_modules/update_keytab.c
@@ -90,7 +90,7 @@ static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delet
}
cli_credentials_set_conf(item->creds, ldb_get_opaque(module->ldb, "loadparm"));
- status = cli_credentials_set_secrets(item->creds, ldb_get_opaque(module->ldb, "loadparm"), module->ldb, NULL, filter);
+ status = cli_credentials_set_secrets(item->creds, ldb_get_opaque(module->ldb, "EventContext"), ldb_get_opaque(module->ldb, "loadparm"), module->ldb, NULL, filter);
talloc_free(filter);
if (NT_STATUS_IS_OK(status)) {
if (delete) {
@@ -158,7 +158,7 @@ static int update_kt_end_trans(struct ldb_module *module)
struct dn_list *p;
for (p=data->changed_dns; p; p = p->next) {
int kret;
- kret = cli_credentials_update_keytab(p->creds, ldb_get_opaque(module->ldb, "loadparm"));
+ kret = cli_credentials_update_keytab(p->creds, ldb_get_opaque(module->ldb, "EventContext"), ldb_get_opaque(module->ldb, "loadparm"));
if (kret != 0) {
talloc_free(data->changed_dns);
data->changed_dns = NULL;
diff --git a/source4/dsdb/samdb/samdb.c b/source4/dsdb/samdb/samdb.c
index a01e442587..9154f5382b 100644
--- a/source4/dsdb/samdb/samdb.c
+++ b/source4/dsdb/samdb/samdb.c
@@ -37,6 +37,7 @@
#include "dsdb/samdb/samdb.h"
#include "dsdb/common/flags.h"
#include "param/param.h"
+#include "lib/events/events.h"
char *samdb_relative_path(struct ldb_context *ldb,
TALLOC_CTX *mem_ctx,
@@ -71,11 +72,12 @@ char *samdb_relative_path(struct ldb_context *ldb,
return an opaque context pointer on success, or NULL on failure
*/
struct ldb_context *samdb_connect(TALLOC_CTX *mem_ctx,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
struct auth_session_info *session_info)
{
struct ldb_context *ldb;
- ldb = ldb_wrap_connect(mem_ctx, lp_ctx,
+ ldb = ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx,
lp_sam_url(lp_ctx), session_info,
NULL, 0, NULL);
if (!ldb) {
@@ -98,6 +100,8 @@ int samdb_copy_template(struct ldb_context *ldb,
struct ldb_context *templates_ldb;
char *templates_ldb_path;
struct ldb_dn *basedn;
+ struct event_context *event_ctx;
+ struct loadparm_context *lp_ctx;
templates_ldb = talloc_get_type(ldb_get_opaque(ldb, "templates_ldb"), struct ldb_context);
@@ -109,8 +113,17 @@ int samdb_copy_template(struct ldb_context *ldb,
*errstring = talloc_asprintf(msg, "samdb_copy_template: ERROR: Failed to contruct path for template db");
return LDB_ERR_OPERATIONS_ERROR;
}
+
+ event_ctx = (struct event_context *)ldb_get_opaque(ldb, "EventContext");
+ lp_ctx = (struct loadparm_context *)ldb_get_opaque(ldb, "loadparm");
+
+ /* FIXME: need to remove this wehn we finally pass the event
+ * context around in ldb */
+ if (event_ctx == NULL) {
+ event_ctx = event_context_init(templates_ldb);
+ }
- templates_ldb = ldb_wrap_connect(ldb, (struct loadparm_context *)ldb_get_opaque(ldb, "loadparm"),
+ templates_ldb = ldb_wrap_connect(ldb, event_ctx, lp_ctx,
templates_ldb_path, NULL,
NULL, 0, NULL);
talloc_free(templates_ldb_path);
@@ -184,6 +197,7 @@ int samdb_copy_template(struct ldb_context *ldb,
Create the SID list for this user.
****************************************************************************/
NTSTATUS security_token_create(TALLOC_CTX *mem_ctx,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
struct dom_sid *user_sid,
struct dom_sid *group_sid,
@@ -242,7 +256,7 @@ NTSTATUS security_token_create(TALLOC_CTX *mem_ctx,
}
/* setup the privilege mask for this token */
- status = samdb_privilege_setup(lp_ctx, ptoken);
+ status = samdb_privilege_setup(ev_ctx, lp_ctx, ptoken);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(ptoken);
return status;
diff --git a/source4/dsdb/samdb/samdb.h b/source4/dsdb/samdb/samdb.h
index 5d8694d2d4..8370857aba 100644
--- a/source4/dsdb/samdb/samdb.h
+++ b/source4/dsdb/samdb/samdb.h
@@ -27,6 +27,7 @@ struct dsdb_control_current_partition;
struct dsdb_extended_replicated_object;
struct dsdb_extended_replicated_objects;
struct loadparm_context;
+struct event_context;
#include "librpc/gen_ndr/security.h"
#include "lib/ldb/include/ldb.h"
@@ -36,6 +37,7 @@ struct loadparm_context;
#include "dsdb/schema/schema.h"
#include "dsdb/samdb/samdb_proto.h"
#include "dsdb/common/proto.h"
+#include "dsdb/common/flags.h"
#define DSDB_CONTROL_CURRENT_PARTITION_OID "1.3.6.1.4.1.7165.4.3.2"
struct dsdb_control_current_partition {
diff --git a/source4/dsdb/samdb/samdb_privilege.c b/source4/dsdb/samdb/samdb_privilege.c
index 5c2de81816..688d1ef9de 100644
--- a/source4/dsdb/samdb/samdb_privilege.c
+++ b/source4/dsdb/samdb/samdb_privilege.c
@@ -73,7 +73,8 @@ static NTSTATUS samdb_privilege_setup_sid(void *samctx, TALLOC_CTX *mem_ctx,
setup the privilege mask for this security token based on our
local SAM
*/
-NTSTATUS samdb_privilege_setup(struct loadparm_context *lp_ctx, struct security_token *token)
+NTSTATUS samdb_privilege_setup(struct event_context *ev_ctx,
+ struct loadparm_context *lp_ctx, struct security_token *token)
{
void *samctx;
TALLOC_CTX *mem_ctx;
@@ -97,7 +98,7 @@ NTSTATUS samdb_privilege_setup(struct loadparm_context *lp_ctx, struct security_
}
mem_ctx = talloc_new(token);
- samctx = samdb_connect(mem_ctx, lp_ctx, system_session(mem_ctx, lp_ctx));
+ samctx = samdb_connect(mem_ctx, ev_ctx, lp_ctx, system_session(mem_ctx, lp_ctx));
if (samctx == NULL) {
talloc_free(mem_ctx);
return NT_STATUS_INTERNAL_DB_CORRUPTION;
diff --git a/source4/dynconfig.mk b/source4/dynconfig.mk
index aa0565cd7a..f365911c6a 100644
--- a/source4/dynconfig.mk
+++ b/source4/dynconfig.mk
@@ -1,5 +1,6 @@
[SUBSYSTEM::DYNCONFIG]
-OBJ_FILES = dynconfig.o
+
+DYNCONFIG_OBJ_FILES = dynconfig.o
# set these to where to find various files
# These can be overridden by command line switches (see smbd(8))
@@ -8,8 +9,11 @@ CONFIGFILE = $(sysconfdir)/smb.conf
PKGCONFIGDIR = $(libdir)/pkgconfig
LMHOSTSFILE = $(sysconfdir)/lmhosts
-PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\" \
- -DBINDIR=\"$(bindir)\" -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" \
+dynconfig.o: dynconfig.c Makefile
+ @echo Compiling $<
+ @$(CC) $(CFLAGS) $(CPPFLAGS) $(PICFLAG) -c $< -o $@ \
+ -DCONFIGFILE=\"$(CONFIGFILE)\" -DBINDIR=\"$(bindir)\" \
+ -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" \
-DLOCKDIR=\"$(lockdir)\" -DPIDDIR=\"$(piddir)\" -DDATADIR=\"$(datadir)\" \
-DLOGFILEBASE=\"$(logfilebase)\" \
-DCONFIGDIR=\"$(sysconfdir)\" -DNCALRPCDIR=\"$(NCALRPCDIR)\" \
@@ -19,7 +23,4 @@ PATH_FLAGS = -DCONFIGFILE=\"$(CONFIGFILE)\" \
-DTORTUREDIR=\"$(TORTUREDIR)\" \
-DSETUPDIR=\"$(SETUPDIR)\" -DWINBINDD_SOCKET_DIR=\"$(winbindd_socket_dir)\"
-dynconfig.o: dynconfig.c Makefile
- @echo Compiling $<
- @$(CC) $(CFLAGS) $(CPPFLAGS) $(PICFLAG) \
- $(PATH_FLAGS) -c $< -o $@
+
diff --git a/source4/headermap.txt b/source4/headermap.txt
index fbfc56e127..91e28b2a1a 100644
--- a/source4/headermap.txt
+++ b/source4/headermap.txt
@@ -44,7 +44,7 @@ rpc_server/common/common.h: dcerpc_server/common.h
libcli/auth/credentials.h: domain_credentials.h
lib/charset/charset.h: charset.h
libcli/ldap/ldap.h: ldap.h
-torture/torture.h: torture.h
+lib/torture/torture.h: torture.h
libcli/libcli.h: client.h
librpc/gen_ndr/nbt.h: gen_ndr/nbt.h
librpc/gen_ndr/svcctl.h: gen_ndr/svcctl.h
@@ -60,7 +60,7 @@ lib/util/asn1.h: samba/asn1.h
libcli/util/error.h: core/error.h
lib/tdb_wrap.h: tdb_wrap.h
lib/ldb_wrap.h: ldb_wrap.h
-torture/ui.h: torture/ui.h
+torture/smbtorture.h: smbtorture.h
librpc/gen_ndr/winbind.h: gen_ndr/winbind.h
param/share.h: share.h
lib/util/util_tdb.h: util_tdb.h
@@ -71,3 +71,4 @@ lib/events/events_internal.h: events/events_internal.h
libcli/ldap/ldap_ndr.h: ldap_ndr.h
lib/events/events.h: events.h
lib/events/events_internal.h: events_internal.h
+auth/session.h: samba/session.h
diff --git a/source4/heimdal_build/asn1_deps.pl b/source4/heimdal_build/asn1_deps.pl
index b80e00d444..a2fbb5e3d0 100755
--- a/source4/heimdal_build/asn1_deps.pl
+++ b/source4/heimdal_build/asn1_deps.pl
@@ -87,11 +87,14 @@ my $depstr = join(' ', @deps);
print '[SUBSYSTEM::HEIMDAL_'.uc($prefix).']'."\n";
print "CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -I$dirname\n";
-print "OBJ_FILES = ";
+print "PUBLIC_DEPENDENCIES = $depstr\n\n";
+
+print "HEIMDAL_".uc($prefix)."_OBJ_FILES = ";
foreach $o_file (@o_files) {
print "\\\n\t$o_file";
}
-print "\nPUBLIC_DEPENDENCIES = $depstr\n\n";
+
+print "\n\n";
print "clean:: \n";
print "\t\@echo \"Deleting ASN1 output files generated from $file\"\n";
diff --git a/source4/heimdal_build/config.mk b/source4/heimdal_build/config.mk
index 24d50acb05..a4f24c9026 100644
--- a/source4/heimdal_build/config.mk
+++ b/source4/heimdal_build/config.mk
@@ -2,334 +2,344 @@
# Start SUBSYSTEM HEIMDAL_KDC
[SUBSYSTEM::HEIMDAL_KDC]
CFLAGS = -Iheimdal_build -Iheimdal/kdc
-OBJ_FILES = \
- ../heimdal/kdc/default_config.o \
- ../heimdal/kdc/kerberos5.o \
- ../heimdal/kdc/krb5tgs.o \
- ../heimdal/kdc/pkinit.o \
- ../heimdal/kdc/log.o \
- ../heimdal/kdc/misc.o \
- ../heimdal/kdc/524.o \
- ../heimdal/kdc/kerberos4.o \
- ../heimdal/kdc/kaserver.o \
- ../heimdal/kdc/digest.o \
- ../heimdal/kdc/process.o \
- ../heimdal/kdc/windc.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
#######################
+
+HEIMDAL_KDC_OBJ_FILES = \
+ $(heimdalsrcdir)/kdc/default_config.o \
+ $(heimdalsrcdir)/kdc/kerberos5.o \
+ $(heimdalsrcdir)/kdc/krb5tgs.o \
+ $(heimdalsrcdir)/kdc/pkinit.o \
+ $(heimdalsrcdir)/kdc/log.o \
+ $(heimdalsrcdir)/kdc/misc.o \
+ $(heimdalsrcdir)/kdc/524.o \
+ $(heimdalsrcdir)/kdc/kerberos4.o \
+ $(heimdalsrcdir)/kdc/kaserver.o \
+ $(heimdalsrcdir)/kdc/digest.o \
+ $(heimdalsrcdir)/kdc/process.o \
+ $(heimdalsrcdir)/kdc/windc.o \
+ $(heimdalsrcdir)/kdc/kx509.o
+
[SUBSYSTEM::HEIMDAL_NTLM]
CFLAGS = -Iheimdal_build -Iheimdal/lib/ntlm
-OBJ_FILES = \
- ../heimdal/lib/ntlm/ntlm.o
PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_HCRYPTO HEIMDAL_KRB5
+HEIMDAL_NTLM_OBJ_FILES = \
+ $(heimdalsrcdir)/lib/ntlm/ntlm.o
+
[SUBSYSTEM::HEIMDAL_HDB_KEYS]
CFLAGS = -Iheimdal_build -Iheimdal/lib/hdb
-OBJ_FILES = \
- ../heimdal/lib/hdb/keys.o
PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_HCRYPTO HEIMDAL_KRB5 \
HEIMDAL_HDB_ASN1
+HEIMDAL_HDB_KEYS_OBJ_FILES = $(heimdalsrcdir)/lib/hdb/keys.o
+
#######################
# Start SUBSYSTEM HEIMDAL_HDB
[SUBSYSTEM::HEIMDAL_HDB]
CFLAGS = -Iheimdal_build -Iheimdal/lib/hdb
-OBJ_FILES = \
- ../heimdal/lib/hdb/db.o \
- ../heimdal/lib/hdb/dbinfo.o \
- ../heimdal/lib/hdb/hdb.o \
- ../heimdal/lib/hdb/ext.o \
- ../heimdal/lib/hdb/keytab.o \
- ../heimdal/lib/hdb/mkey.o \
- ../heimdal/lib/hdb/ndbm.o \
- ../heimdal/lib/hdb/hdb_err.o
PRIVATE_DEPENDENCIES = HDB_LDB HEIMDAL_KRB5 HEIMDAL_HDB_KEYS HEIMDAL_ROKEN HEIMDAL_HCRYPTO HEIMDAL_COM_ERR HEIMDAL_HDB_ASN1
# End SUBSYSTEM HEIMDAL_HDB
#######################
+HEIMDAL_HDB_OBJ_FILES = \
+ $(heimdalsrcdir)/lib/hdb/db.o \
+ $(heimdalsrcdir)/lib/hdb/dbinfo.o \
+ $(heimdalsrcdir)/lib/hdb/hdb.o \
+ $(heimdalsrcdir)/lib/hdb/ext.o \
+ $(heimdalsrcdir)/lib/hdb/keytab.o \
+ $(heimdalsrcdir)/lib/hdb/mkey.o \
+ $(heimdalsrcdir)/lib/hdb/ndbm.o \
+ $(heimdalsrcdir)/lib/hdb/hdb_err.o
+
#######################
# Start SUBSYSTEM HEIMDAL_GSSAPI
[SUBSYSTEM::HEIMDAL_GSSAPI]
CFLAGS = -Iheimdal_build -Iheimdal/lib/gssapi -Iheimdal/lib/gssapi/gssapi -Iheimdal/lib/gssapi/spnego -Iheimdal/lib/gssapi/krb5 -Iheimdal/lib/gssapi/mech
-OBJ_FILES = \
- ../heimdal/lib/gssapi/mech/context.o \
- ../heimdal/lib/gssapi/mech/gss_krb5.o \
- ../heimdal/lib/gssapi/mech/gss_mech_switch.o \
- ../heimdal/lib/gssapi/mech/gss_process_context_token.o \
- ../heimdal/lib/gssapi/mech/gss_buffer_set.o \
- ../heimdal/lib/gssapi/mech/gss_add_cred.o \
- ../heimdal/lib/gssapi/mech/gss_add_oid_set_member.o \
- ../heimdal/lib/gssapi/mech/gss_compare_name.o \
- ../heimdal/lib/gssapi/mech/gss_release_oid_set.o \
- ../heimdal/lib/gssapi/mech/gss_create_empty_oid_set.o \
- ../heimdal/lib/gssapi/mech/gss_decapsulate_token.o \
- ../heimdal/lib/gssapi/mech/gss_inquire_cred_by_oid.o \
- ../heimdal/lib/gssapi/mech/gss_canonicalize_name.o \
- ../heimdal/lib/gssapi/mech/gss_inquire_sec_context_by_oid.o \
- ../heimdal/lib/gssapi/mech/gss_inquire_names_for_mech.o \
- ../heimdal/lib/gssapi/mech/gss_inquire_mechs_for_name.o \
- ../heimdal/lib/gssapi/mech/gss_wrap_size_limit.o \
- ../heimdal/lib/gssapi/mech/gss_names.o \
- ../heimdal/lib/gssapi/mech/gss_verify.o \
- ../heimdal/lib/gssapi/mech/gss_display_name.o \
- ../heimdal/lib/gssapi/mech/gss_duplicate_oid.o \
- ../heimdal/lib/gssapi/mech/gss_display_status.o \
- ../heimdal/lib/gssapi/mech/gss_release_buffer.o \
- ../heimdal/lib/gssapi/mech/gss_release_oid.o \
- ../heimdal/lib/gssapi/mech/gss_test_oid_set_member.o \
- ../heimdal/lib/gssapi/mech/gss_release_cred.o \
- ../heimdal/lib/gssapi/mech/gss_set_sec_context_option.o \
- ../heimdal/lib/gssapi/mech/gss_export_name.o \
- ../heimdal/lib/gssapi/mech/gss_seal.o \
- ../heimdal/lib/gssapi/mech/gss_acquire_cred.o \
- ../heimdal/lib/gssapi/mech/gss_unseal.o \
- ../heimdal/lib/gssapi/mech/gss_verify_mic.o \
- ../heimdal/lib/gssapi/mech/gss_accept_sec_context.o \
- ../heimdal/lib/gssapi/mech/gss_inquire_cred_by_mech.o \
- ../heimdal/lib/gssapi/mech/gss_indicate_mechs.o \
- ../heimdal/lib/gssapi/mech/gss_delete_sec_context.o \
- ../heimdal/lib/gssapi/mech/gss_sign.o \
- ../heimdal/lib/gssapi/mech/gss_utils.o \
- ../heimdal/lib/gssapi/mech/gss_init_sec_context.o \
- ../heimdal/lib/gssapi/mech/gss_oid_equal.o \
- ../heimdal/lib/gssapi/mech/gss_oid_to_str.o \
- ../heimdal/lib/gssapi/mech/gss_context_time.o \
- ../heimdal/lib/gssapi/mech/gss_encapsulate_token.o \
- ../heimdal/lib/gssapi/mech/gss_get_mic.o \
- ../heimdal/lib/gssapi/mech/gss_import_sec_context.o \
- ../heimdal/lib/gssapi/mech/gss_inquire_cred.o \
- ../heimdal/lib/gssapi/mech/gss_wrap.o \
- ../heimdal/lib/gssapi/mech/gss_import_name.o \
- ../heimdal/lib/gssapi/mech/gss_duplicate_name.o \
- ../heimdal/lib/gssapi/mech/gss_unwrap.o \
- ../heimdal/lib/gssapi/mech/gss_export_sec_context.o \
- ../heimdal/lib/gssapi/mech/gss_inquire_context.o \
- ../heimdal/lib/gssapi/mech/gss_release_name.o \
- ../heimdal/lib/gssapi/mech/gss_set_cred_option.o \
- ../heimdal/lib/gssapi/asn1_GSSAPIContextToken.o \
- ../heimdal/lib/gssapi/spnego/init_sec_context.o \
- ../heimdal/lib/gssapi/spnego/external.o \
- ../heimdal/lib/gssapi/spnego/compat.o \
- ../heimdal/lib/gssapi/spnego/context_stubs.o \
- ../heimdal/lib/gssapi/spnego/cred_stubs.o \
- ../heimdal/lib/gssapi/spnego/accept_sec_context.o \
- ../heimdal/lib/gssapi/krb5/copy_ccache.o \
- ../heimdal/lib/gssapi/krb5/delete_sec_context.o \
- ../heimdal/lib/gssapi/krb5/init_sec_context.o \
- ../heimdal/lib/gssapi/krb5/context_time.o \
- ../heimdal/lib/gssapi/krb5/init.o \
- ../heimdal/lib/gssapi/krb5/address_to_krb5addr.o \
- ../heimdal/lib/gssapi/krb5/get_mic.o \
- ../heimdal/lib/gssapi/krb5/inquire_context.o \
- ../heimdal/lib/gssapi/krb5/add_cred.o \
- ../heimdal/lib/gssapi/krb5/inquire_cred.o \
- ../heimdal/lib/gssapi/krb5/inquire_cred_by_oid.o \
- ../heimdal/lib/gssapi/krb5/inquire_cred_by_mech.o \
- ../heimdal/lib/gssapi/krb5/inquire_mechs_for_name.o \
- ../heimdal/lib/gssapi/krb5/inquire_names_for_mech.o \
- ../heimdal/lib/gssapi/krb5/indicate_mechs.o \
- ../heimdal/lib/gssapi/krb5/inquire_sec_context_by_oid.o \
- ../heimdal/lib/gssapi/krb5/export_sec_context.o \
- ../heimdal/lib/gssapi/krb5/import_sec_context.o \
- ../heimdal/lib/gssapi/krb5/duplicate_name.o \
- ../heimdal/lib/gssapi/krb5/import_name.o \
- ../heimdal/lib/gssapi/krb5/compare_name.o \
- ../heimdal/lib/gssapi/krb5/export_name.o \
- ../heimdal/lib/gssapi/krb5/canonicalize_name.o \
- ../heimdal/lib/gssapi/krb5/unwrap.o \
- ../heimdal/lib/gssapi/krb5/wrap.o \
- ../heimdal/lib/gssapi/krb5/release_name.o \
- ../heimdal/lib/gssapi/krb5/cfx.o \
- ../heimdal/lib/gssapi/krb5/8003.o \
- ../heimdal/lib/gssapi/krb5/arcfour.o \
- ../heimdal/lib/gssapi/krb5/encapsulate.o \
- ../heimdal/lib/gssapi/krb5/display_name.o \
- ../heimdal/lib/gssapi/krb5/sequence.o \
- ../heimdal/lib/gssapi/krb5/display_status.o \
- ../heimdal/lib/gssapi/krb5/release_buffer.o \
- ../heimdal/lib/gssapi/krb5/external.o \
- ../heimdal/lib/gssapi/krb5/compat.o \
- ../heimdal/lib/gssapi/krb5/acquire_cred.o \
- ../heimdal/lib/gssapi/krb5/release_cred.o \
- ../heimdal/lib/gssapi/krb5/set_cred_option.o \
- ../heimdal/lib/gssapi/krb5/decapsulate.o \
- ../heimdal/lib/gssapi/krb5/verify_mic.o \
- ../heimdal/lib/gssapi/krb5/accept_sec_context.o \
- ../heimdal/lib/gssapi/krb5/set_sec_context_option.o \
- ../heimdal/lib/gssapi/krb5/process_context_token.o \
- ../heimdal/lib/gssapi/krb5/prf.o
PRIVATE_DEPENDENCIES = HEIMDAL_HCRYPTO HEIMDAL_HEIM_ASN1 HEIMDAL_SPNEGO_ASN1
PUBLIC_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_KRB5
# End SUBSYSTEM HEIMDAL_GSSAPI
#######################
+HEIMDAL_GSSAPI_OBJ_FILES = \
+ $(heimdalsrcdir)/lib/gssapi/mech/context.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_krb5.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_mech_switch.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_process_context_token.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_buffer_set.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_add_cred.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_add_oid_set_member.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_compare_name.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_release_oid_set.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_create_empty_oid_set.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_decapsulate_token.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_inquire_cred_by_oid.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_canonicalize_name.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_inquire_sec_context_by_oid.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_inquire_names_for_mech.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_inquire_mechs_for_name.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_wrap_size_limit.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_names.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_verify.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_display_name.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_duplicate_oid.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_display_status.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_release_buffer.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_release_oid.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_test_oid_set_member.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_release_cred.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_set_sec_context_option.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_export_name.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_seal.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_acquire_cred.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_unseal.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_verify_mic.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_accept_sec_context.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_inquire_cred_by_mech.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_indicate_mechs.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_delete_sec_context.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_sign.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_utils.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_init_sec_context.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_oid_equal.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_oid_to_str.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_context_time.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_encapsulate_token.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_get_mic.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_import_sec_context.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_inquire_cred.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_wrap.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_import_name.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_duplicate_name.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_unwrap.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_export_sec_context.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_inquire_context.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_release_name.o \
+ $(heimdalsrcdir)/lib/gssapi/mech/gss_set_cred_option.o \
+ $(heimdalsrcdir)/lib/gssapi/asn1_GSSAPIContextToken.o \
+ $(heimdalsrcdir)/lib/gssapi/spnego/init_sec_context.o \
+ $(heimdalsrcdir)/lib/gssapi/spnego/external.o \
+ $(heimdalsrcdir)/lib/gssapi/spnego/compat.o \
+ $(heimdalsrcdir)/lib/gssapi/spnego/context_stubs.o \
+ $(heimdalsrcdir)/lib/gssapi/spnego/cred_stubs.o \
+ $(heimdalsrcdir)/lib/gssapi/spnego/accept_sec_context.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/copy_ccache.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/delete_sec_context.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/init_sec_context.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/context_time.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/init.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/address_to_krb5addr.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/get_mic.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/inquire_context.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/add_cred.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/inquire_cred.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/inquire_cred_by_oid.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/inquire_cred_by_mech.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/inquire_mechs_for_name.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/inquire_names_for_mech.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/indicate_mechs.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/inquire_sec_context_by_oid.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/export_sec_context.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/import_sec_context.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/duplicate_name.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/import_name.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/compare_name.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/export_name.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/canonicalize_name.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/unwrap.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/wrap.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/release_name.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/cfx.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/8003.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/arcfour.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/encapsulate.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/display_name.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/sequence.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/display_status.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/release_buffer.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/external.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/compat.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/acquire_cred.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/release_cred.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/set_cred_option.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/decapsulate.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/verify_mic.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/accept_sec_context.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/set_sec_context_option.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/process_context_token.o \
+ $(heimdalsrcdir)/lib/gssapi/krb5/prf.o
+
+
#######################
# Start SUBSYSTEM HEIMDAL_KRB5
[SUBSYSTEM::HEIMDAL_KRB5]
-CFLAGS = -Iheimdal_build -Iheimdal/lib/krb5
+CFLAGS = -Iheimdal_build -Iheimdal/lib/krb5 -Iheimdal/lib/asn1 -Iheimdal/lib/com_err
PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_PKINIT_ASN1 HEIMDAL_WIND
PUBLIC_DEPENDENCIES = HEIMDAL_KRB5_ASN1 HEIMDAL_GLUE HEIMDAL_HX509 HEIMDAL_HCRYPTO
-OBJ_FILES = \
- ../heimdal/lib/krb5/acache.o \
- ../heimdal/lib/krb5/add_et_list.o \
- ../heimdal/lib/krb5/addr_families.o \
- ../heimdal/lib/krb5/appdefault.o \
- ../heimdal/lib/krb5/asn1_glue.o \
- ../heimdal/lib/krb5/auth_context.o \
- ../heimdal/lib/krb5/build_ap_req.o \
- ../heimdal/lib/krb5/build_auth.o \
- ../heimdal/lib/krb5/cache.o \
- ../heimdal/lib/krb5/changepw.o \
- ../heimdal/lib/krb5/codec.o \
- ../heimdal/lib/krb5/config_file.o \
- ../heimdal/lib/krb5/config_file_netinfo.o \
- ../heimdal/lib/krb5/constants.o \
- ../heimdal/lib/krb5/context.o \
- ../heimdal/lib/krb5/convert_creds.o \
- ../heimdal/lib/krb5/copy_host_realm.o \
- ../heimdal/lib/krb5/crc.o \
- ../heimdal/lib/krb5/creds.o \
- ../heimdal/lib/krb5/crypto.o \
- ../heimdal/lib/krb5/data.o \
- ../heimdal/lib/krb5/eai_to_heim_errno.o \
- ../heimdal/lib/krb5/error_string.o \
- ../heimdal/lib/krb5/expand_hostname.o \
- ../heimdal/lib/krb5/fcache.o \
- ../heimdal/lib/krb5/free.o \
- ../heimdal/lib/krb5/free_host_realm.o \
- ../heimdal/lib/krb5/generate_seq_number.o \
- ../heimdal/lib/krb5/generate_subkey.o \
- ../heimdal/lib/krb5/get_cred.o \
- ../heimdal/lib/krb5/get_default_principal.o \
- ../heimdal/lib/krb5/get_default_realm.o \
- ../heimdal/lib/krb5/get_for_creds.o \
- ../heimdal/lib/krb5/get_host_realm.o \
- ../heimdal/lib/krb5/get_in_tkt.o \
- ../heimdal/lib/krb5/get_in_tkt_with_keytab.o \
- ../heimdal/lib/krb5/get_port.o \
- ../heimdal/lib/krb5/init_creds.o \
- ../heimdal/lib/krb5/init_creds_pw.o \
- ../heimdal/lib/krb5/kcm.o \
- ../heimdal/lib/krb5/keyblock.o \
- ../heimdal/lib/krb5/keytab.o \
- ../heimdal/lib/krb5/keytab_any.o \
- ../heimdal/lib/krb5/keytab_file.o \
- ../heimdal/lib/krb5/keytab_memory.o \
- ../heimdal/lib/krb5/keytab_keyfile.o \
- ../heimdal/lib/krb5/keytab_krb4.o \
- ../heimdal/lib/krb5/krbhst.o \
- ../heimdal/lib/krb5/log.o \
- ../heimdal/lib/krb5/mcache.o \
- ../heimdal/lib/krb5/misc.o \
- ../heimdal/lib/krb5/mk_error.o \
- ../heimdal/lib/krb5/mk_priv.o \
- ../heimdal/lib/krb5/mk_rep.o \
- ../heimdal/lib/krb5/mk_req.o \
- ../heimdal/lib/krb5/mk_req_ext.o \
- ../heimdal/lib/krb5/mit_glue.o \
- ../heimdal/lib/krb5/n-fold.o \
- ../heimdal/lib/krb5/padata.o \
- ../heimdal/lib/krb5/pkinit.o \
- ../heimdal/lib/krb5/plugin.o \
- ../heimdal/lib/krb5/principal.o \
- ../heimdal/lib/krb5/pac.o \
- ../heimdal/lib/krb5/prompter_posix.o \
- ../heimdal/lib/krb5/rd_cred.o \
- ../heimdal/lib/krb5/rd_error.o \
- ../heimdal/lib/krb5/rd_priv.o \
- ../heimdal/lib/krb5/rd_rep.o \
- ../heimdal/lib/krb5/rd_req.o \
- ../heimdal/lib/krb5/replay.o \
- ../heimdal/lib/krb5/send_to_kdc.o \
- ../heimdal/lib/krb5/set_default_realm.o \
- ../heimdal/lib/krb5/store.o \
- ../heimdal/lib/krb5/store_emem.o \
- ../heimdal/lib/krb5/store_fd.o \
- ../heimdal/lib/krb5/store_mem.o \
- ../heimdal/lib/krb5/ticket.o \
- ../heimdal/lib/krb5/time.o \
- ../heimdal/lib/krb5/transited.o \
- ../heimdal/lib/krb5/v4_glue.o \
- ../heimdal/lib/krb5/version.o \
- ../heimdal/lib/krb5/warn.o \
- ../heimdal/lib/krb5/krb5_err.o \
- ../heimdal/lib/krb5/heim_err.o \
- ../heimdal/lib/krb5/k524_err.o \
- ../heimdal/lib/krb5/krb_err.o
# End SUBSYSTEM HEIMDAL_KRB5
#######################
+HEIMDAL_KRB5_OBJ_FILES = \
+ $(heimdalsrcdir)/lib/krb5/acache.o \
+ $(heimdalsrcdir)/lib/krb5/add_et_list.o \
+ $(heimdalsrcdir)/lib/krb5/addr_families.o \
+ $(heimdalsrcdir)/lib/krb5/appdefault.o \
+ $(heimdalsrcdir)/lib/krb5/asn1_glue.o \
+ $(heimdalsrcdir)/lib/krb5/auth_context.o \
+ $(heimdalsrcdir)/lib/krb5/build_ap_req.o \
+ $(heimdalsrcdir)/lib/krb5/build_auth.o \
+ $(heimdalsrcdir)/lib/krb5/cache.o \
+ $(heimdalsrcdir)/lib/krb5/changepw.o \
+ $(heimdalsrcdir)/lib/krb5/codec.o \
+ $(heimdalsrcdir)/lib/krb5/config_file.o \
+ $(heimdalsrcdir)/lib/krb5/config_file_netinfo.o \
+ $(heimdalsrcdir)/lib/krb5/constants.o \
+ $(heimdalsrcdir)/lib/krb5/context.o \
+ $(heimdalsrcdir)/lib/krb5/convert_creds.o \
+ $(heimdalsrcdir)/lib/krb5/copy_host_realm.o \
+ $(heimdalsrcdir)/lib/krb5/crc.o \
+ $(heimdalsrcdir)/lib/krb5/creds.o \
+ $(heimdalsrcdir)/lib/krb5/crypto.o \
+ $(heimdalsrcdir)/lib/krb5/data.o \
+ $(heimdalsrcdir)/lib/krb5/eai_to_heim_errno.o \
+ $(heimdalsrcdir)/lib/krb5/error_string.o \
+ $(heimdalsrcdir)/lib/krb5/expand_hostname.o \
+ $(heimdalsrcdir)/lib/krb5/fcache.o \
+ $(heimdalsrcdir)/lib/krb5/free.o \
+ $(heimdalsrcdir)/lib/krb5/free_host_realm.o \
+ $(heimdalsrcdir)/lib/krb5/generate_seq_number.o \
+ $(heimdalsrcdir)/lib/krb5/generate_subkey.o \
+ $(heimdalsrcdir)/lib/krb5/get_cred.o \
+ $(heimdalsrcdir)/lib/krb5/get_default_principal.o \
+ $(heimdalsrcdir)/lib/krb5/get_default_realm.o \
+ $(heimdalsrcdir)/lib/krb5/get_for_creds.o \
+ $(heimdalsrcdir)/lib/krb5/get_host_realm.o \
+ $(heimdalsrcdir)/lib/krb5/get_in_tkt.o \
+ $(heimdalsrcdir)/lib/krb5/get_in_tkt_with_keytab.o \
+ $(heimdalsrcdir)/lib/krb5/get_port.o \
+ $(heimdalsrcdir)/lib/krb5/init_creds.o \
+ $(heimdalsrcdir)/lib/krb5/init_creds_pw.o \
+ $(heimdalsrcdir)/lib/krb5/kcm.o \
+ $(heimdalsrcdir)/lib/krb5/keyblock.o \
+ $(heimdalsrcdir)/lib/krb5/keytab.o \
+ $(heimdalsrcdir)/lib/krb5/keytab_any.o \
+ $(heimdalsrcdir)/lib/krb5/keytab_file.o \
+ $(heimdalsrcdir)/lib/krb5/keytab_memory.o \
+ $(heimdalsrcdir)/lib/krb5/keytab_keyfile.o \
+ $(heimdalsrcdir)/lib/krb5/keytab_krb4.o \
+ $(heimdalsrcdir)/lib/krb5/krbhst.o \
+ $(heimdalsrcdir)/lib/krb5/log.o \
+ $(heimdalsrcdir)/lib/krb5/mcache.o \
+ $(heimdalsrcdir)/lib/krb5/misc.o \
+ $(heimdalsrcdir)/lib/krb5/mk_error.o \
+ $(heimdalsrcdir)/lib/krb5/mk_priv.o \
+ $(heimdalsrcdir)/lib/krb5/mk_rep.o \
+ $(heimdalsrcdir)/lib/krb5/mk_req.o \
+ $(heimdalsrcdir)/lib/krb5/mk_req_ext.o \
+ $(heimdalsrcdir)/lib/krb5/mit_glue.o \
+ $(heimdalsrcdir)/lib/krb5/n-fold.o \
+ $(heimdalsrcdir)/lib/krb5/padata.o \
+ $(heimdalsrcdir)/lib/krb5/pkinit.o \
+ $(heimdalsrcdir)/lib/krb5/plugin.o \
+ $(heimdalsrcdir)/lib/krb5/principal.o \
+ $(heimdalsrcdir)/lib/krb5/pac.o \
+ $(heimdalsrcdir)/lib/krb5/prompter_posix.o \
+ $(heimdalsrcdir)/lib/krb5/rd_cred.o \
+ $(heimdalsrcdir)/lib/krb5/rd_error.o \
+ $(heimdalsrcdir)/lib/krb5/rd_priv.o \
+ $(heimdalsrcdir)/lib/krb5/rd_rep.o \
+ $(heimdalsrcdir)/lib/krb5/rd_req.o \
+ $(heimdalsrcdir)/lib/krb5/replay.o \
+ $(heimdalsrcdir)/lib/krb5/send_to_kdc.o \
+ $(heimdalsrcdir)/lib/krb5/set_default_realm.o \
+ $(heimdalsrcdir)/lib/krb5/store.o \
+ $(heimdalsrcdir)/lib/krb5/store_emem.o \
+ $(heimdalsrcdir)/lib/krb5/store_fd.o \
+ $(heimdalsrcdir)/lib/krb5/store_mem.o \
+ $(heimdalsrcdir)/lib/krb5/ticket.o \
+ $(heimdalsrcdir)/lib/krb5/time.o \
+ $(heimdalsrcdir)/lib/krb5/transited.o \
+ $(heimdalsrcdir)/lib/krb5/v4_glue.o \
+ $(heimdalsrcdir)/lib/krb5/version.o \
+ $(heimdalsrcdir)/lib/krb5/warn.o \
+ $(heimdalsrcdir)/lib/krb5/krb5_err.o \
+ $(heimdalsrcdir)/lib/krb5/heim_err.o \
+ $(heimdalsrcdir)/lib/krb5/k524_err.o \
+ $(heimdalsrcdir)/lib/krb5/krb_err.o
+
#######################
# Start SUBSYSTEM HEIMDAL_HEIM_ASN1
[SUBSYSTEM::HEIMDAL_HEIM_ASN1]
CFLAGS = -Iheimdal_build -Iheimdal/lib/asn1
-OBJ_FILES = \
- ../heimdal/lib/asn1/der_get.o \
- ../heimdal/lib/asn1/der_put.o \
- ../heimdal/lib/asn1/der_free.o \
- ../heimdal/lib/asn1/der_format.o \
- ../heimdal/lib/asn1/der_length.o \
- ../heimdal/lib/asn1/der_copy.o \
- ../heimdal/lib/asn1/der_cmp.o \
- ../heimdal/lib/asn1/extra.o \
- ../heimdal/lib/asn1/timegm.o \
- ../heimdal/lib/asn1/asn1_err.o
PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_COM_ERR
# End SUBSYSTEM HEIMDAL_KRB5
#######################
+HEIMDAL_HEIM_ASN1_OBJ_FILES = \
+ $(heimdalsrcdir)/lib/asn1/der_get.o \
+ $(heimdalsrcdir)/lib/asn1/der_put.o \
+ $(heimdalsrcdir)/lib/asn1/der_free.o \
+ $(heimdalsrcdir)/lib/asn1/der_format.o \
+ $(heimdalsrcdir)/lib/asn1/der_length.o \
+ $(heimdalsrcdir)/lib/asn1/der_copy.o \
+ $(heimdalsrcdir)/lib/asn1/der_cmp.o \
+ $(heimdalsrcdir)/lib/asn1/extra.o \
+ $(heimdalsrcdir)/lib/asn1/timegm.o \
+ $(heimdalsrcdir)/lib/asn1/asn1_err.o
+
#######################
# Start SUBSYSTEM HEIMDAL_HCRYPTO_IMATH
[SUBSYSTEM::HEIMDAL_HCRYPTO_IMATH]
CFLAGS = -Iheimdal_build -Iheimdal/lib/hcrypto/imath
PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN
-OBJ_FILES = \
- ../heimdal/lib/hcrypto/imath/imath.o \
- ../heimdal/lib/hcrypto/imath/iprime.o
# End SUBSYSTEM HEIMDAL_HCRYPTO_IMATH
#######################
+HEIMDAL_HCRYPTO_IMATH_OBJ_FILES = \
+ $(heimdalsrcdir)/lib/hcrypto/imath/imath.o \
+ $(heimdalsrcdir)/lib/hcrypto/imath/iprime.o
+
[SUBSYSTEM::HEIMDAL_HCRYPTO]
CFLAGS = -Iheimdal_build -Iheimdal/lib/hcrypto -Iheimdal/lib
PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_HEIM_ASN1 HEIMDAL_HCRYPTO_IMATH HEIMDAL_RFC2459_ASN1
-OBJ_FILES = \
- ../heimdal/lib/hcrypto/aes.o \
- ../heimdal/lib/hcrypto/bn.o \
- ../heimdal/lib/hcrypto/dh.o \
- ../heimdal/lib/hcrypto/dh-imath.o \
- ../heimdal/lib/hcrypto/des.o \
- ../heimdal/lib/hcrypto/dsa.o \
- ../heimdal/lib/hcrypto/engine.o \
- ../heimdal/lib/hcrypto/md2.o \
- ../heimdal/lib/hcrypto/md4.o \
- ../heimdal/lib/hcrypto/md5.o \
- ../heimdal/lib/hcrypto/rsa.o \
- ../heimdal/lib/hcrypto/rsa-imath.o \
- ../heimdal/lib/hcrypto/rc2.o \
- ../heimdal/lib/hcrypto/rc4.o \
- ../heimdal/lib/hcrypto/rijndael-alg-fst.o \
- ../heimdal/lib/hcrypto/rnd_keys.o \
- ../heimdal/lib/hcrypto/sha.o \
- ../heimdal/lib/hcrypto/sha256.o \
- ../heimdal/lib/hcrypto/ui.o \
- ../heimdal/lib/hcrypto/evp.o \
- ../heimdal/lib/hcrypto/pkcs5.o \
- ../heimdal/lib/hcrypto/pkcs12.o \
- ../heimdal/lib/hcrypto/rand.o \
- ../heimdal/lib/hcrypto/rand-egd.o \
- ../heimdal/lib/hcrypto/rand-unix.o \
- ../heimdal/lib/hcrypto/rand-fortuna.o \
- ../heimdal/lib/hcrypto/rand-timer.o \
- ../heimdal/lib/hcrypto/hmac.o \
- ../heimdal/lib/hcrypto/camellia.o \
- ../heimdal/lib/hcrypto/camellia-ntt.o
# End SUBSYSTEM HEIMDAL_HCRYPTO
#######################
+HEIMDAL_HCRYPTO_OBJ_FILES = \
+ $(heimdalsrcdir)/lib/hcrypto/aes.o \
+ $(heimdalsrcdir)/lib/hcrypto/bn.o \
+ $(heimdalsrcdir)/lib/hcrypto/dh.o \
+ $(heimdalsrcdir)/lib/hcrypto/dh-imath.o \
+ $(heimdalsrcdir)/lib/hcrypto/des.o \
+ $(heimdalsrcdir)/lib/hcrypto/dsa.o \
+ $(heimdalsrcdir)/lib/hcrypto/engine.o \
+ $(heimdalsrcdir)/lib/hcrypto/md2.o \
+ $(heimdalsrcdir)/lib/hcrypto/md4.o \
+ $(heimdalsrcdir)/lib/hcrypto/md5.o \
+ $(heimdalsrcdir)/lib/hcrypto/rsa.o \
+ $(heimdalsrcdir)/lib/hcrypto/rsa-imath.o \
+ $(heimdalsrcdir)/lib/hcrypto/rc2.o \
+ $(heimdalsrcdir)/lib/hcrypto/rc4.o \
+ $(heimdalsrcdir)/lib/hcrypto/rijndael-alg-fst.o \
+ $(heimdalsrcdir)/lib/hcrypto/rnd_keys.o \
+ $(heimdalsrcdir)/lib/hcrypto/sha.o \
+ $(heimdalsrcdir)/lib/hcrypto/sha256.o \
+ $(heimdalsrcdir)/lib/hcrypto/ui.o \
+ $(heimdalsrcdir)/lib/hcrypto/evp.o \
+ $(heimdalsrcdir)/lib/hcrypto/pkcs5.o \
+ $(heimdalsrcdir)/lib/hcrypto/pkcs12.o \
+ $(heimdalsrcdir)/lib/hcrypto/rand.o \
+ $(heimdalsrcdir)/lib/hcrypto/rand-egd.o \
+ $(heimdalsrcdir)/lib/hcrypto/rand-unix.o \
+ $(heimdalsrcdir)/lib/hcrypto/rand-fortuna.o \
+ $(heimdalsrcdir)/lib/hcrypto/rand-timer.o \
+ $(heimdalsrcdir)/lib/hcrypto/hmac.o \
+ $(heimdalsrcdir)/lib/hcrypto/camellia.o \
+ $(heimdalsrcdir)/lib/hcrypto/camellia-ntt.o
+
#######################
# Start SUBSYSTEM HEIMDAL_HX509
[SUBSYSTEM::HEIMDAL_HX509]
@@ -342,103 +352,78 @@ PRIVATE_DEPENDENCIES = \
HEIMDAL_PKCS9_ASN1 HEIMDAL_PKCS12_ASN1 \
HEIMDAL_PKINIT_ASN1 HEIMDAL_PKCS10_ASN1 \
HEIMDAL_WIND
-OBJ_FILES = \
- ../heimdal/lib/hx509/ca.o \
- ../heimdal/lib/hx509/cert.o \
- ../heimdal/lib/hx509/cms.o \
- ../heimdal/lib/hx509/collector.o \
- ../heimdal/lib/hx509/crypto.o \
- ../heimdal/lib/hx509/error.o \
- ../heimdal/lib/hx509/env.o \
- ../heimdal/lib/hx509/file.o \
- ../heimdal/lib/hx509/keyset.o \
- ../heimdal/lib/hx509/ks_dir.o \
- ../heimdal/lib/hx509/ks_file.o \
- ../heimdal/lib/hx509/ks_keychain.o \
- ../heimdal/lib/hx509/ks_mem.o \
- ../heimdal/lib/hx509/ks_null.o \
- ../heimdal/lib/hx509/ks_p11.o \
- ../heimdal/lib/hx509/ks_p12.o \
- ../heimdal/lib/hx509/lock.o \
- ../heimdal/lib/hx509/name.o \
- ../heimdal/lib/hx509/peer.o \
- ../heimdal/lib/hx509/print.o \
- ../heimdal/lib/hx509/req.o \
- ../heimdal/lib/hx509/revoke.o \
- ../heimdal/lib/hx509/hx509_err.o
# End SUBSYSTEM HEIMDAL_HX509
#######################
+HEIMDAL_HX509_OBJ_FILES = \
+ $(heimdalsrcdir)/lib/hx509/ca.o \
+ $(heimdalsrcdir)/lib/hx509/cert.o \
+ $(heimdalsrcdir)/lib/hx509/cms.o \
+ $(heimdalsrcdir)/lib/hx509/collector.o \
+ $(heimdalsrcdir)/lib/hx509/crypto.o \
+ $(heimdalsrcdir)/lib/hx509/error.o \
+ $(heimdalsrcdir)/lib/hx509/env.o \
+ $(heimdalsrcdir)/lib/hx509/file.o \
+ $(heimdalsrcdir)/lib/hx509/keyset.o \
+ $(heimdalsrcdir)/lib/hx509/ks_dir.o \
+ $(heimdalsrcdir)/lib/hx509/ks_file.o \
+ $(heimdalsrcdir)/lib/hx509/ks_keychain.o \
+ $(heimdalsrcdir)/lib/hx509/ks_mem.o \
+ $(heimdalsrcdir)/lib/hx509/ks_null.o \
+ $(heimdalsrcdir)/lib/hx509/ks_p11.o \
+ $(heimdalsrcdir)/lib/hx509/ks_p12.o \
+ $(heimdalsrcdir)/lib/hx509/lock.o \
+ $(heimdalsrcdir)/lib/hx509/name.o \
+ $(heimdalsrcdir)/lib/hx509/peer.o \
+ $(heimdalsrcdir)/lib/hx509/print.o \
+ $(heimdalsrcdir)/lib/hx509/req.o \
+ $(heimdalsrcdir)/lib/hx509/revoke.o \
+ $(heimdalsrcdir)/lib/hx509/hx509_err.o
+
#######################
# Start SUBSYSTEM HEIMDAL_WIND
[SUBSYSTEM::HEIMDAL_WIND]
CFLAGS = -Iheimdal_build -Iheimdal/lib/wind
PRIVATE_DEPENDENCIES = \
HEIMDAL_ROKEN HEIMDAL_COM_ERR
-OBJ_FILES = \
- ../heimdal/lib/wind/wind_err.o \
- ../heimdal/lib/wind/stringprep.o \
- ../heimdal/lib/wind/errorlist.o \
- ../heimdal/lib/wind/errorlist_table.o \
- ../heimdal/lib/wind/normalize.o \
- ../heimdal/lib/wind/normalize_table.o \
- ../heimdal/lib/wind/combining.o \
- ../heimdal/lib/wind/combining_table.o \
- ../heimdal/lib/wind/utf8.o \
- ../heimdal/lib/wind/bidi.o \
- ../heimdal/lib/wind/bidi_table.o \
- ../heimdal/lib/wind/ldap.o \
- ../heimdal/lib/wind/map.o \
- ../heimdal/lib/wind/map_table.o
+
+HEIMDAL_WIND_OBJ_FILES = \
+ $(heimdalsrcdir)/lib/wind/wind_err.o \
+ $(heimdalsrcdir)/lib/wind/stringprep.o \
+ $(heimdalsrcdir)/lib/wind/errorlist.o \
+ $(heimdalsrcdir)/lib/wind/errorlist_table.o \
+ $(heimdalsrcdir)/lib/wind/normalize.o \
+ $(heimdalsrcdir)/lib/wind/normalize_table.o \
+ $(heimdalsrcdir)/lib/wind/combining.o \
+ $(heimdalsrcdir)/lib/wind/combining_table.o \
+ $(heimdalsrcdir)/lib/wind/utf8.o \
+ $(heimdalsrcdir)/lib/wind/bidi.o \
+ $(heimdalsrcdir)/lib/wind/bidi_table.o \
+ $(heimdalsrcdir)/lib/wind/ldap.o \
+ $(heimdalsrcdir)/lib/wind/map.o \
+ $(heimdalsrcdir)/lib/wind/map_table.o
# End SUBSYSTEM HEIMDAL_WIND
#######################
[SUBSYSTEM::HEIMDAL_ROKEN_GETPROGNAME]
CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -Ilib/socket_wrapper
-OBJ_FILES = ../heimdal/lib/roken/getprogname.o
+
+HEIMDAL_ROKEN_GETPROGNAME_OBJ_FILES = $(heimdalsrcdir)/lib/roken/getprogname.o
[SUBSYSTEM::HEIMDAL_ROKEN_CLOSEFROM]
CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -Ilib/socket_wrapper
-OBJ_FILES = ../heimdal/lib/roken/closefrom.o
+
+HEIMDAL_ROKEN_CLOSEFROM_OBJ_FILES = $(heimdalsrcdir)/lib/roken/closefrom.o
[SUBSYSTEM::HEIMDAL_ROKEN_GETPROGNAME_H]
CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -Ilib/socket_wrapper
-OBJ_FILES = ../heimdal/lib/roken/getprogname.ho
+
+HEIMDAL_ROKEN_GETPROGNAME_H_OBJ_FILES = $(heimdalsrcdir)/lib/roken/getprogname.ho
#######################
# Start SUBSYSTEM HEIMDAL_ROKEN
[SUBSYSTEM::HEIMDAL_ROKEN]
CFLAGS = -Iheimdal_build -Iheimdal/lib/roken -Ilib/socket_wrapper
-OBJ_FILES = \
- ../heimdal/lib/roken/base64.o \
- ../heimdal/lib/roken/hex.o \
- ../heimdal/lib/roken/bswap.o \
- ../heimdal/lib/roken/dumpdata.o \
- ../heimdal/lib/roken/emalloc.o \
- ../heimdal/lib/roken/ecalloc.o \
- ../heimdal/lib/roken/get_window_size.o \
- ../heimdal/lib/roken/h_errno.o \
- ../heimdal/lib/roken/issuid.o \
- ../heimdal/lib/roken/net_read.o \
- ../heimdal/lib/roken/net_write.o \
- ../heimdal/lib/roken/socket.o \
- ../heimdal/lib/roken/parse_time.o \
- ../heimdal/lib/roken/parse_units.o \
- ../heimdal/lib/roken/resolve.o \
- ../heimdal/lib/roken/roken_gethostby.o \
- ../heimdal/lib/roken/signal.o \
- ../heimdal/lib/roken/vis.o \
- ../heimdal/lib/roken/strlwr.o \
- ../heimdal/lib/roken/strsep_copy.o \
- ../heimdal/lib/roken/strsep.o \
- ../heimdal/lib/roken/strupr.o \
- ../heimdal/lib/roken/strpool.o \
- ../heimdal/lib/roken/estrdup.o \
- ../heimdal/lib/roken/erealloc.o \
- ../heimdal/lib/roken/simple_exec.o \
- ../heimdal/lib/roken/strcollect.o \
- ../heimdal/lib/roken/rtbl.o \
- replace.o
PUBLIC_DEPENDENCIES = \
HEIMDAL_ROKEN_GETPROGNAME \
HEIMDAL_ROKEN_CLOSEFROM \
@@ -447,64 +432,99 @@ PUBLIC_DEPENDENCIES = \
# End SUBSYSTEM HEIMDAL_ROKEN
#######################
+HEIMDAL_ROKEN_OBJ_FILES = \
+ $(heimdalsrcdir)/lib/roken/base64.o \
+ $(heimdalsrcdir)/lib/roken/hex.o \
+ $(heimdalsrcdir)/lib/roken/bswap.o \
+ $(heimdalsrcdir)/lib/roken/dumpdata.o \
+ $(heimdalsrcdir)/lib/roken/emalloc.o \
+ $(heimdalsrcdir)/lib/roken/ecalloc.o \
+ $(heimdalsrcdir)/lib/roken/get_window_size.o \
+ $(heimdalsrcdir)/lib/roken/h_errno.o \
+ $(heimdalsrcdir)/lib/roken/issuid.o \
+ $(heimdalsrcdir)/lib/roken/net_read.o \
+ $(heimdalsrcdir)/lib/roken/net_write.o \
+ $(heimdalsrcdir)/lib/roken/socket.o \
+ $(heimdalsrcdir)/lib/roken/parse_time.o \
+ $(heimdalsrcdir)/lib/roken/parse_units.o \
+ $(heimdalsrcdir)/lib/roken/resolve.o \
+ $(heimdalsrcdir)/lib/roken/roken_gethostby.o \
+ $(heimdalsrcdir)/lib/roken/signal.o \
+ $(heimdalsrcdir)/lib/roken/vis.o \
+ $(heimdalsrcdir)/lib/roken/strlwr.o \
+ $(heimdalsrcdir)/lib/roken/strsep_copy.o \
+ $(heimdalsrcdir)/lib/roken/strsep.o \
+ $(heimdalsrcdir)/lib/roken/strupr.o \
+ $(heimdalsrcdir)/lib/roken/strpool.o \
+ $(heimdalsrcdir)/lib/roken/estrdup.o \
+ $(heimdalsrcdir)/lib/roken/erealloc.o \
+ $(heimdalsrcdir)/lib/roken/simple_exec.o \
+ $(heimdalsrcdir)/lib/roken/strcollect.o \
+ $(heimdalsrcdir)/lib/roken/rtbl.o \
+ ./heimdal_build/replace.o
+
#######################
# Start SUBSYSTEM HEIMDAL_GLUE
[SUBSYSTEM::HEIMDAL_GLUE]
CFLAGS = -Iheimdal_build -Iheimdal/lib/krb5 -Iheimdal/lib/asn1 -Iheimdal/lib/com_err
-OBJ_FILES = glue.o
PUBLIC_DEPENDENCIES = LIBNETIF LIBSAMBA-HOSTCONFIG
# End SUBSYSTEM HEIMDAL_GLUE
#######################
+HEIMDAL_GLUE_OBJ_FILES = heimdal_build/glue.o
+
#######################
# Start SUBSYSTEM HEIMDAL_COM_ERR
[SUBSYSTEM::HEIMDAL_COM_ERR]
CFLAGS = -Iheimdal_build -Iheimdal/lib/com_err
-OBJ_FILES = \
- ../heimdal/lib/com_err/com_err.o \
- ../heimdal/lib/com_err/error.o
PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN
# End SUBSYSTEM HEIMDAL_COM_ERR
#######################
+HEIMDAL_COM_ERR_OBJ_FILES = \
+ $(heimdalsrcdir)/lib/com_err/com_err.o \
+ $(heimdalsrcdir)/lib/com_err/error.o
+
#######################
# Start SUBSYSTEM HEIMDAL_ASN1_COMPILE_LEX
[SUBSYSTEM::HEIMDAL_ASN1_COMPILE_LEX]
CFLAGS = -Iheimdal_build -Iheimdal/lib/asn1 -Iheimdal/lib/roken -Ilib/socket_wrapper
-OBJ_FILES = ../heimdal/lib/asn1/lex.ho
# End SUBSYSTEM HEIMDAL_ASN1_COMPILE_LEX
#######################
+HEIMDAL_ASN1_COMPILE_LEX_OBJ_FILES = $(heimdalsrcdir)/lib/asn1/lex.ho
+
#######################
# Start BINARY asn1_compile
[BINARY::asn1_compile]
CFLAGS = -Iheimdal_build -Iheimdal/lib/roken
USE_HOSTCC = YES
-OBJ_FILES = \
- ../heimdal/lib/asn1/main.ho \
- ../heimdal/lib/asn1/gen.ho \
- ../heimdal/lib/asn1/gen_copy.ho \
- ../heimdal/lib/asn1/gen_decode.ho \
- ../heimdal/lib/asn1/gen_encode.ho \
- ../heimdal/lib/asn1/gen_free.ho \
- ../heimdal/lib/asn1/gen_glue.ho \
- ../heimdal/lib/asn1/gen_length.ho \
- ../heimdal/lib/asn1/gen_seq.ho \
- ../heimdal/lib/asn1/hash.ho \
- ../heimdal/lib/asn1/parse.ho \
- ../heimdal/lib/roken/emalloc.ho \
- ../heimdal/lib/roken/getarg.ho \
- ../heimdal/lib/roken/setprogname.ho \
- ../heimdal/lib/roken/strupr.ho \
- ../heimdal/lib/roken/get_window_size.ho \
- ../heimdal/lib/roken/estrdup.ho \
- ../heimdal/lib/roken/ecalloc.ho \
- ../heimdal/lib/asn1/symbol.ho \
- ../heimdal/lib/vers/print_version.ho \
- ../lib/socket_wrapper/socket_wrapper.ho \
- replace.ho
PRIVATE_DEPENDENCIES = HEIMDAL_ASN1_COMPILE_LEX HEIMDAL_ROKEN_GETPROGNAME_H LIBREPLACE_NETWORK
+asn1_compile_OBJ_FILES = \
+ $(heimdalsrcdir)/lib/asn1/main.ho \
+ $(heimdalsrcdir)/lib/asn1/gen.ho \
+ $(heimdalsrcdir)/lib/asn1/gen_copy.ho \
+ $(heimdalsrcdir)/lib/asn1/gen_decode.ho \
+ $(heimdalsrcdir)/lib/asn1/gen_encode.ho \
+ $(heimdalsrcdir)/lib/asn1/gen_free.ho \
+ $(heimdalsrcdir)/lib/asn1/gen_glue.ho \
+ $(heimdalsrcdir)/lib/asn1/gen_length.ho \
+ $(heimdalsrcdir)/lib/asn1/gen_seq.ho \
+ $(heimdalsrcdir)/lib/asn1/hash.ho \
+ $(heimdalsrcdir)/lib/asn1/parse.ho \
+ $(heimdalsrcdir)/lib/roken/emalloc.ho \
+ $(heimdalsrcdir)/lib/roken/getarg.ho \
+ $(heimdalsrcdir)/lib/roken/setprogname.ho \
+ $(heimdalsrcdir)/lib/roken/strupr.ho \
+ $(heimdalsrcdir)/lib/roken/get_window_size.ho \
+ $(heimdalsrcdir)/lib/roken/estrdup.ho \
+ $(heimdalsrcdir)/lib/roken/ecalloc.ho \
+ $(heimdalsrcdir)/lib/asn1/symbol.ho \
+ $(heimdalsrcdir)/lib/vers/print_version.ho \
+ ./lib/socket_wrapper/socket_wrapper.ho \
+ ./heimdal_build/replace.ho
+
# End BINARY asn1_compile
#######################
@@ -512,28 +532,31 @@ PRIVATE_DEPENDENCIES = HEIMDAL_ASN1_COMPILE_LEX HEIMDAL_ROKEN_GETPROGNAME_H LIBR
# Start SUBSYSTEM HEIMDAL_COM_ERR_COMPILE_LEX
[SUBSYSTEM::HEIMDAL_COM_ERR_COMPILE_LEX]
CFLAGS = -Iheimdal_build -Iheimdal/lib/com_err -Iheimdal/lib/roken -Ilib/socket_wrapper
-OBJ_FILES = ../heimdal/lib/com_err/lex.ho
# End SUBSYSTEM HEIMDAL_COM_ERR_COMPILE_LEX
#######################
+HEIMDAL_COM_ERR_COMPILE_LEX_OBJ_FILES = $(heimdalsrcdir)/lib/com_err/lex.ho
+
#######################
# Start BINARY compile_et
[BINARY::compile_et]
CFLAGS = -Iheimdal_build -Iheimdal/lib/roken
USE_HOSTCC = YES
-OBJ_FILES = ../heimdal/lib/vers/print_version.ho \
- ../heimdal/lib/com_err/parse.ho \
- ../heimdal/lib/com_err/compile_et.ho \
- ../heimdal/lib/roken/getarg.ho \
- ../heimdal/lib/roken/get_window_size.ho \
- ../heimdal/lib/roken/strupr.ho \
- ../heimdal/lib/roken/setprogname.ho \
- ../lib/socket_wrapper/socket_wrapper.ho \
- replace.ho
PRIVATE_DEPENDENCIES = HEIMDAL_COM_ERR_COMPILE_LEX HEIMDAL_ROKEN_GETPROGNAME_H LIBREPLACE_NETWORK
# End BINARY compile_et
#######################
+compile_et_OBJ_FILES = $(heimdalsrcdir)/lib/vers/print_version.ho \
+ $(heimdalsrcdir)/lib/com_err/parse.ho \
+ $(heimdalsrcdir)/lib/com_err/compile_et.ho \
+ $(heimdalsrcdir)/lib/roken/getarg.ho \
+ $(heimdalsrcdir)/lib/roken/get_window_size.ho \
+ $(heimdalsrcdir)/lib/roken/strupr.ho \
+ $(heimdalsrcdir)/lib/roken/setprogname.ho \
+ ./lib/socket_wrapper/socket_wrapper.ho \
+ ./heimdal_build/replace.ho
+
+
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|
@@ -550,7 +573,7 @@ mkinclude perl_path_wrapper.sh asn1_deps.pl heimdal/lib/asn1/kx509.asn1 kx509_as
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!
+# Ensure to update ./static_deps.mk when you add a new entry here!
#
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|
@@ -569,31 +592,25 @@ clean::
# Start SUBSYSTEM HEIMDAL
[SUBSYSTEM::HEIMDAL]
CFLAGS = -Iheimdal_build
-OBJ_FILES = ../heimdal/lib/vers/print_version.o
PUBLIC_DEPENDENCIES = \
HEIMDAL_GSSAPI HEIMDAL_KRB5
# End SUBSYSTEM HEIMDAL
#######################
-#######################
-# Start SUBSYSTEM KERBEROS_LIB
-[SUBSYSTEM::KERBEROS_LIB]
-#PUBLIC_DEPENDENCIES = EXT_KRB5
-PUBLIC_DEPENDENCIES = HEIMDAL
-# End SUBSYSTEM KERBEROS_LIB
-#######################
+HEIMDAL_OBJ_FILES = $(heimdalsrcdir)/lib/vers/print_version.o
#######################
# Start BINARY compile_et
[BINARY::samba4kinit]
CFLAGS = -Iheimdal_build -Iheimdal/lib/roken
-OBJ_FILES = ../heimdal/kuser/kinit.o \
- ../heimdal/lib/vers/print_version.o \
- ../heimdal/lib/roken/setprogname.o \
- ../heimdal/lib/roken/getarg.o
PRIVATE_DEPENDENCIES = HEIMDAL_KRB5 HEIMDAL_NTLM
# End BINARY compile_et
#######################
-dist:: heimdal/lib/asn1/lex.c heimdal/lib/com_err/lex.c \
- heimdal/lib/asn1/parse.c heimdal/lib/com_err/parse.c
+samba4kinit_OBJ_FILES = $(heimdalsrcdir)/kuser/kinit.o \
+ $(heimdalsrcdir)/lib/vers/print_version.o \
+ $(heimdalsrcdir)/lib/roken/setprogname.o \
+ $(heimdalsrcdir)/lib/roken/getarg.o
+
+dist:: $(heimdalsrcdir)/lib/asn1/lex.c $(heimdalsrcdir)/lib/com_err/lex.c \
+ $(heimdalsrcdir)/lib/asn1/parse.c $(heimdalsrcdir)/lib/com_err/parse.c
diff --git a/source4/kdc/config.mk b/source4/kdc/config.mk
index 479cb36296..b3b8b216f0 100644
--- a/source4/kdc/config.mk
+++ b/source4/kdc/config.mk
@@ -4,26 +4,23 @@
# Start SUBSYSTEM KDC
[MODULE::KDC]
INIT_FUNCTION = server_service_kdc_init
-SUBSYSTEM = service
-OBJ_FILES = \
- kdc.o \
- kpasswdd.o
+SUBSYSTEM = smbd
PRIVATE_DEPENDENCIES = \
- LIBLDB KERBEROS_LIB HEIMDAL_KDC HEIMDAL_HDB SAMDB
+ LIBLDB HEIMDAL HEIMDAL_KDC HEIMDAL_HDB SAMDB
# End SUBSYSTEM KDC
#######################
+KDC_OBJ_FILES = $(addprefix $(kdcsrcdir)/, kdc.o kpasswdd.o)
+
#######################
# Start SUBSYSTEM KDC
[SUBSYSTEM::HDB_LDB]
CFLAGS = -Iheimdal/kdc -Iheimdal/lib/hdb
-PRIVATE_PROTO_HEADER = pac_glue.h
-OBJ_FILES = \
- hdb-ldb.o \
- pac-glue.o
PRIVATE_DEPENDENCIES = \
- LIBLDB auth_sam auth_sam_reply KERBEROS CREDENTIALS \
+ LIBLDB auth_sam auth_sam_reply HEIMDAL CREDENTIALS \
HEIMDAL_HDB_ASN1
# End SUBSYSTEM KDC
#######################
+HDB_LDB_OBJ_FILES = $(addprefix $(kdcsrcdir)/, hdb-ldb.o pac-glue.o)
+$(eval $(call proto_header_template,$(kdcsrcdir)/pac_glue.h,$(HDB_LDB_OBJ_FILES:.o=.c)))
diff --git a/source4/kdc/hdb-ldb.c b/source4/kdc/hdb-ldb.c
index d983b77b40..9c7b1f6457 100644
--- a/source4/kdc/hdb-ldb.c
+++ b/source4/kdc/hdb-ldb.c
@@ -50,6 +50,7 @@
#include "librpc/gen_ndr/ndr_drsblobs.h"
#include "libcli/auth/libcli_auth.h"
#include "param/param.h"
+#include "events/events.h"
enum hdb_ldb_ent_type
{ HDB_LDB_ENT_TYPE_CLIENT, HDB_LDB_ENT_TYPE_SERVER,
@@ -1106,6 +1107,7 @@ static krb5_error_code LDB_destroy(krb5_context context, HDB *db)
* code */
NTSTATUS kdc_hdb_ldb_create(TALLOC_CTX *mem_ctx,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
krb5_context context, struct HDB **db, const char *arg)
{
@@ -1137,7 +1139,7 @@ NTSTATUS kdc_hdb_ldb_create(TALLOC_CTX *mem_ctx,
CRED_DONT_USE_KERBEROS);
/* Setup the link to LDB */
- (*db)->hdb_db = samdb_connect(*db, lp_ctx, session_info);
+ (*db)->hdb_db = samdb_connect(*db, ev_ctx, lp_ctx, session_info);
if ((*db)->hdb_db == NULL) {
DEBUG(1, ("hdb_ldb_create: Cannot open samdb for KDC backend!"));
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
@@ -1168,7 +1170,7 @@ krb5_error_code hdb_ldb_create(krb5_context context, struct HDB **db, const char
{
NTSTATUS nt_status;
/* The global kdc_mem_ctx and kdc_lp_ctx, Disgusting, ugly hack, but it means one less private hook */
- nt_status = kdc_hdb_ldb_create(kdc_mem_ctx, kdc_lp_ctx,
+ nt_status = kdc_hdb_ldb_create(kdc_mem_ctx, event_context_find(kdc_mem_ctx), kdc_lp_ctx,
context, db, arg);
if (NT_STATUS_IS_OK(nt_status)) {
diff --git a/source4/kdc/kdc.c b/source4/kdc/kdc.c
index 72b5bb14a9..84d9d45f57 100644
--- a/source4/kdc/kdc.c
+++ b/source4/kdc/kdc.c
@@ -624,7 +624,7 @@ static void kdc_task_init(struct task_server *task)
}
kdc->config->num_db = 1;
- status = kdc_hdb_ldb_create(kdc, task->lp_ctx,
+ status = kdc_hdb_ldb_create(kdc, task->event_ctx, task->lp_ctx,
kdc->smb_krb5_context->krb5_context,
&kdc->config->db[0], NULL);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source4/kdc/kpasswdd.c b/source4/kdc/kpasswdd.c
index f468fea6c4..1d49a8a4bd 100644
--- a/source4/kdc/kpasswdd.c
+++ b/source4/kdc/kpasswdd.c
@@ -180,7 +180,7 @@ static bool kpasswdd_change_password(struct kdc_server *kdc,
struct samr_DomInfo1 *dominfo;
struct ldb_context *samdb;
- samdb = samdb_connect(mem_ctx, kdc->task->lp_ctx, system_session(mem_ctx, kdc->task->lp_ctx));
+ samdb = samdb_connect(mem_ctx, kdc->task->event_ctx, kdc->task->lp_ctx, system_session(mem_ctx, kdc->task->lp_ctx));
if (!samdb) {
return kpasswdd_make_error_reply(kdc, mem_ctx,
KRB5_KPASSWD_HARDERROR,
@@ -310,7 +310,7 @@ static bool kpasswd_process_request(struct kdc_server *kdc,
krb5_free_principal(context, principal);
- samdb = samdb_connect(mem_ctx, kdc->task->lp_ctx, session_info);
+ samdb = samdb_connect(mem_ctx, kdc->task->event_ctx, kdc->task->lp_ctx, session_info);
if (!samdb) {
return kpasswdd_make_error_reply(kdc, mem_ctx,
KRB5_KPASSWD_HARDERROR,
@@ -474,7 +474,7 @@ bool kpasswdd_process(struct kdc_server *kdc,
* we already have, rather than a new context */
cli_credentials_set_krb5_context(server_credentials, kdc->smb_krb5_context);
cli_credentials_set_conf(server_credentials, kdc->task->lp_ctx);
- nt_status = cli_credentials_set_stored_principal(server_credentials, kdc->task->lp_ctx, "kadmin/changepw");
+ nt_status = cli_credentials_set_stored_principal(server_credentials, kdc->task->event_ctx, kdc->task->lp_ctx, "kadmin/changepw");
if (!NT_STATUS_IS_OK(nt_status)) {
ret = kpasswdd_make_unauth_error_reply(kdc, mem_ctx,
KRB5_KPASSWD_HARDERROR,
diff --git a/source4/ldap_server/config.mk b/source4/ldap_server/config.mk
index 5f8c530db9..65f5b17f9a 100644
--- a/source4/ldap_server/config.mk
+++ b/source4/ldap_server/config.mk
@@ -4,13 +4,7 @@
# Start SUBSYSTEM LDAP
[MODULE::LDAP]
INIT_FUNCTION = server_service_ldap_init
-SUBSYSTEM = service
-PRIVATE_PROTO_HEADER = proto.h
-OBJ_FILES = \
- ldap_server.o \
- ldap_backend.o \
- ldap_bind.o \
- ldap_extended.o
+SUBSYSTEM = smbd
PRIVATE_DEPENDENCIES = CREDENTIALS \
LIBCLI_LDAP SAMDB \
process_model \
@@ -18,3 +12,11 @@ PRIVATE_DEPENDENCIES = CREDENTIALS \
LIBSAMBA-HOSTCONFIG
# End SUBSYSTEM SMB
#######################
+
+LDAP_OBJ_FILES = $(addprefix $(ldap_serversrcdir)/, \
+ ldap_server.o \
+ ldap_backend.o \
+ ldap_bind.o \
+ ldap_extended.o)
+
+$(eval $(call proto_header_template,$(ldap_serversrcdir)/proto.h,$(LDAP_OBJ_FILES:.o=.c)))
diff --git a/source4/ldap_server/ldap_backend.c b/source4/ldap_server/ldap_backend.c
index 9b43d7bd74..9047773529 100644
--- a/source4/ldap_server/ldap_backend.c
+++ b/source4/ldap_server/ldap_backend.c
@@ -27,6 +27,7 @@
#include "auth/credentials/credentials.h"
#include "auth/gensec/gensec.h"
#include "param/param.h"
+#include "smbd/service_stream.h"
#define VALID_DN_SYNTAX(dn,i) do {\
if (!(dn)) {\
@@ -56,6 +57,7 @@ static int map_ldb_error(struct ldb_context *ldb, int err, const char **errstrin
NTSTATUS ldapsrv_backend_Init(struct ldapsrv_connection *conn)
{
conn->ldb = ldb_wrap_connect(conn,
+ conn->connection->event.ctx,
conn->lp_ctx,
lp_sam_url(conn->lp_ctx),
conn->session_info,
diff --git a/source4/ldap_server/ldap_bind.c b/source4/ldap_server/ldap_bind.c
index f2c974ae3f..f37ef31c0a 100644
--- a/source4/ldap_server/ldap_bind.c
+++ b/source4/ldap_server/ldap_bind.c
@@ -44,7 +44,7 @@ static NTSTATUS ldapsrv_BindSimple(struct ldapsrv_call *call)
DEBUG(10, ("BindSimple dn: %s\n",req->dn));
- status = crack_auto_name_to_nt4_name(call, call->conn->lp_ctx, req->dn, &nt4_domain, &nt4_account);
+ status = crack_auto_name_to_nt4_name(call, call->conn->connection->event.ctx, call->conn->lp_ctx, req->dn, &nt4_domain, &nt4_account);
if (NT_STATUS_IS_OK(status)) {
status = authenticate_username_pw(call,
call->conn->connection->event.ctx,
diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c
index 11cb63e07b..197f84692c 100644
--- a/source4/ldap_server/ldap_server.c
+++ b/source4/ldap_server/ldap_server.c
@@ -409,7 +409,7 @@ static void ldapsrv_accept(struct stream_connection *c)
conn->server_credentials = server_credentials;
/* Connections start out anonymous */
- if (!NT_STATUS_IS_OK(auth_anonymous_session_info(conn, conn->lp_ctx, &conn->session_info))) {
+ if (!NT_STATUS_IS_OK(auth_anonymous_session_info(conn, c->event.ctx, conn->lp_ctx, &conn->session_info))) {
ldapsrv_terminate_connection(conn, "failed to setup anonymous session info");
return;
}
@@ -478,7 +478,8 @@ static NTSTATUS add_socket(struct event_context *event_context,
}
/* Load LDAP database */
- ldb = samdb_connect(ldap_service, lp_ctx, system_session(ldap_service, lp_ctx));
+ ldb = samdb_connect(ldap_service, ldap_service->task->event_ctx,
+ lp_ctx, system_session(ldap_service, lp_ctx));
if (!ldb) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
diff --git a/source4/lib/appweb/config.mk b/source4/lib/appweb/config.mk
index df0f81dccb..4d27b69fb5 100644
--- a/source4/lib/appweb/config.mk
+++ b/source4/lib/appweb/config.mk
@@ -1,31 +1,25 @@
#######################
# Start SUBSYSTEM MPR
[SUBSYSTEM::MPR]
-OBJ_FILES = \
- mpr/miniMpr.o \
- mpr/var.o
# End SUBSYSTEM MPR
#######################
+MPR_OBJ_FILES = $(addprefix $(appwebsrcdir)/mpr/, miniMpr.o var.o)
#######################
# Start SUBSYSTEM EJS
[SUBSYSTEM::EJS]
-OBJ_FILES = \
- ejs/ejsLib.o \
- ejs/ejsLex.o \
- ejs/ejsParser.o \
- ejs/ejsProcs.o
PUBLIC_DEPENDENCIES = MPR
# End SUBSYSTEM EJS
#######################
+EJS_OBJ_FILES = $(addprefix $(appwebsrcdir)/ejs/, ejsLib.o ejsLex.o ejsParser.o ejsProcs.o)
+
#######################
# Start SUBSYSTEM ESP
[SUBSYSTEM::ESP]
-OBJ_FILES = \
- esp/esp.o \
- esp/espProcs.o
PUBLIC_DEPENDENCIES = EJS
# End SUBSYSTEM ESP
#######################
+
+ESP_OBJ_FILES = $(addprefix $(appwebsrcdir)/esp/, esp.o espProcs.o)
diff --git a/source4/lib/appweb/mpr/miniMpr.c b/source4/lib/appweb/mpr/miniMpr.c
index 52b23608aa..381815eb23 100644
--- a/source4/lib/appweb/mpr/miniMpr.c
+++ b/source4/lib/appweb/mpr/miniMpr.c
@@ -31,6 +31,7 @@
#include "miniMpr.h"
#include "param/param.h"
+#include "lib/events/events.h"
/************************************ Code ************************************/
#if !BLD_APPWEB
@@ -50,6 +51,11 @@ void *mprMemCtx(void)
return mpr_ctx;
}
+struct event_context *mprEventCtx(void)
+{
+ return event_context_find(mprMemCtx());
+}
+
/* return the loadparm context being used for all ejs variables */
struct loadparm_context *mprLpCtx(void)
{
diff --git a/source4/lib/appweb/mpr/miniMpr.h b/source4/lib/appweb/mpr/miniMpr.h
index 15ce30c8df..2b8ff0af6a 100644
--- a/source4/lib/appweb/mpr/miniMpr.h
+++ b/source4/lib/appweb/mpr/miniMpr.h
@@ -274,6 +274,8 @@ extern void mprSetCtx(void *ctx);
extern void *mprMemCtx(void);
struct loadparm_context;
extern struct loadparm_context *mprLpCtx(void);
+struct event_context;
+extern struct event_context *mprEventCtx(void);
/* This function needs to be provided by anyone using ejs */
void ejs_exception(const char *reason);
diff --git a/source4/lib/basic.mk b/source4/lib/basic.mk
index d6e90928b0..b86df5dc9f 100644
--- a/source4/lib/basic.mk
+++ b/source4/lib/basic.mk
@@ -1,44 +1,25 @@
-# LIB BASIC subsystem
-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
-
[SUBSYSTEM::LIBCOMPRESSION]
-OBJ_FILES = compression/mszip.o
+
+LIBCOMPRESSION_OBJ_FILES = $(libcompressionsrcdir)/mszip.o
[SUBSYSTEM::GENCACHE]
-OBJ_FILES = gencache/gencache.o
PRIVATE_DEPENDENCIES = TDB_WRAP
+GENCACHE_OBJ_FILES = $(libgencachesrcdir)/gencache.o
-# PUBLIC_HEADERS += lib/gencache/gencache.h
+# PUBLIC_HEADERS += $(libgencachesrcdir)/gencache.h
[SUBSYSTEM::LDB_WRAP]
-OBJ_FILES = ldb_wrap.o
PUBLIC_DEPENDENCIES = LIBLDB
PRIVATE_DEPENDENCIES = LDBSAMBA UTIL_LDB
-
-PUBLIC_HEADERS += lib/ldb_wrap.h
+LDB_WRAP_OBJ_FILES = $(libsrcdir)/ldb_wrap.o
+PUBLIC_HEADERS += $(libsrcdir)/ldb_wrap.h
[SUBSYSTEM::TDB_WRAP]
-OBJ_FILES = tdb_wrap.o
PUBLIC_DEPENDENCIES = LIBTDB
+TDB_WRAP_OBJ_FILES = $(libsrcdir)/tdb_wrap.o
+PUBLIC_HEADERS += $(libsrcdir)/tdb_wrap.h
-PUBLIC_HEADERS += lib/tdb_wrap.h
+SMBREADLINE_OBJ_LIST = $(SMBREADLINE_OBJ_FILES)
diff --git a/source4/lib/charset/config.mk b/source4/lib/charset/config.mk
index 2766784c52..12c2f5f321 100644
--- a/source4/lib/charset/config.mk
+++ b/source4/lib/charset/config.mk
@@ -1,15 +1,13 @@
################################################
# Start SUBSYSTEM CHARSET
[SUBSYSTEM::CHARSET]
-OBJ_FILES = \
- iconv.o \
- charcnv.o \
- util_unistr.o
-PRIVATE_PROTO_HEADER = charset_proto.h
PUBLIC_DEPENDENCIES = ICONV
PRIVATE_DEPENDENCIES = DYNCONFIG
# End SUBSYSTEM CHARSET
################################################
+CHARSET_OBJ_FILES = $(addprefix $(libcharsetsrcdir)/, iconv.o charcnv.o util_unistr.o)
-PUBLIC_HEADERS += lib/charset/charset.h
+PUBLIC_HEADERS += $(libcharsetsrcdir)/charset.h
+
+$(eval $(call proto_header_template,$(libcharsetsrcdir)/charset_proto.h,$(CHARSET_OBJ_FILES:.o=.c)))
diff --git a/source4/lib/cmdline/config.mk b/source4/lib/cmdline/config.mk
index 87014d4d53..4434ff3701 100644
--- a/source4/lib/cmdline/config.mk
+++ b/source4/lib/cmdline/config.mk
@@ -1,16 +1,21 @@
[SUBSYSTEM::LIBCMDLINE_CREDENTIALS]
-PRIVATE_PROTO_HEADER = credentials.h
-OBJ_FILES = credentials.o
PUBLIC_DEPENDENCIES = CREDENTIALS LIBPOPT
+LIBCMDLINE_CREDENTIALS_OBJ_FILES = $(libcmdlinesrcdir)/credentials.o
+
+$(eval $(call proto_header_template,$(libcmdlinesrcdir)/credentials.h,$(LIBCMDLINE_CREDENTIALS_OBJ_FILES:.o=.c)))
+
[SUBSYSTEM::POPT_SAMBA]
-OBJ_FILES = popt_common.o
PUBLIC_DEPENDENCIES = LIBPOPT
-PUBLIC_HEADERS += lib/cmdline/popt_common.h
+POPT_SAMBA_OBJ_FILES = $(libcmdlinesrcdir)/popt_common.o
+
+PUBLIC_HEADERS += $(libcmdlinesrcdir)/popt_common.h
[SUBSYSTEM::POPT_CREDENTIALS]
-PRIVATE_PROTO_HEADER = popt_credentials.h
-OBJ_FILES = popt_credentials.o
PUBLIC_DEPENDENCIES = CREDENTIALS LIBCMDLINE_CREDENTIALS LIBPOPT
PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL
+
+POPT_CREDENTIALS_OBJ_FILES = $(libcmdlinesrcdir)/popt_credentials.o
+
+$(eval $(call proto_header_template,$(libcmdlinesrcdir)/popt_credentials.h,$(POPT_CREDENTIALS_OBJ_FILES:.o=.c)))
diff --git a/source4/lib/crypto/config.mk b/source4/lib/crypto/config.mk
index f7a8d20604..b9a7f7cb9e 100644
--- a/source4/lib/crypto/config.mk
+++ b/source4/lib/crypto/config.mk
@@ -1,26 +1,19 @@
##############################
# Start SUBSYSTEM LIBCRYPTO
[SUBSYSTEM::LIBCRYPTO]
-OBJ_FILES = \
- crc32.o \
- md5.o \
- hmacmd5.o \
- md4.o \
- arcfour.o \
- sha1.o \
- hmacsha1.o
# End SUBSYSTEM LIBCRYPTO
##############################
+LIBCRYPTO_OBJ_FILES = $(addprefix $(libcryptosrcdir)/, \
+ crc32.o md5.o hmacmd5.o md4.o \
+ arcfour.o sha1.o hmacsha1.o)
+
+
[MODULE::TORTURE_LIBCRYPTO]
-OBJ_FILES = \
- md4test.o \
- md5test.o \
- hmacmd5test.o \
- sha1test.o \
- hmacsha1test.o
-SUBSYSTEM = torture
+SUBSYSTEM = smbtorture
PRIVATE_DEPENDENCIES = LIBCRYPTO
-PRIVATE_PROTO_HEADER = test_proto.h
+TORTURE_LIBCRYPTO_OBJ_FILES = $(addprefix $(libcryptosrcdir)/, \
+ md4test.o md5test.o hmacmd5test.o sha1test.o hmacsha1test.o)
+$(eval $(call proto_header_template,$(libcryptosrcdir)/test_proto.h,$(TORTURE_LIBCRYPTO_OBJ_FILES:.o=.c)))
diff --git a/source4/lib/crypto/sha1test.c b/source4/lib/crypto/sha1test.c
index 0e943bd74d..7777764277 100644
--- a/source4/lib/crypto/sha1test.c
+++ b/source4/lib/crypto/sha1test.c
@@ -17,7 +17,7 @@
*/
#include "includes.h"
-#include "torture/ui.h"
+#include "torture/torture.h"
#include "lib/crypto/crypto.h"
diff --git a/source4/lib/dbwrap/config.mk b/source4/lib/dbwrap/config.mk
index 01ce4ddd8e..34e2629b16 100644
--- a/source4/lib/dbwrap/config.mk
+++ b/source4/lib/dbwrap/config.mk
@@ -1,6 +1,6 @@
[SUBSYSTEM::LIBDBWRAP]
-OBJ_FILES = dbwrap.o \
- dbwrap_tdb.o \
- dbwrap_ctdb.o
PUBLIC_DEPENDENCIES = \
LIBTDB ctdb
+
+LIBDBWRAP_OBJ_FILES = $(addprefix $(libdbwrapsrcdir)/, dbwrap.o dbwrap_tdb.o dbwrap_ctdb.o)
+
diff --git a/source4/lib/events/Makefile.in b/source4/lib/events/Makefile.in
new file mode 100644
index 0000000000..0a0df9bef9
--- /dev/null
+++ b/source4/lib/events/Makefile.in
@@ -0,0 +1,66 @@
+#!gmake
+#
+# Makefile for tdb directory
+#
+
+CC = @CC@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+includedir = @includedir@
+libdir = @libdir@
+VPATH = @srcdir@:@tallocdir@:@libreplacedir@
+srcdir = @srcdir@
+builddir = @builddir@
+CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/include -Iinclude -I.
+LDFLAGS = @LDFLAGS@
+EXEEXT = @EXEEXT@
+SHLD = @SHLD@
+SHLD_FLAGS = @SHLD_FLAGS@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PICFLAG = @PICFLAG@
+SHLIBEXT = @SHLIBEXT@
+SWIG = swig
+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@
+eventsdir = @eventsdir@
+tallocdir = @tallocdir@
+
+TALLOC_LIBS = @TALLOC_LIBS@
+TALLOC_CFLAGS = @TALLOC_CFLAGS@
+TALLOC_OBJ = @TALLOC_OBJ@
+
+CFLAGS = $(CPPFLAGS) $(TALLOC_CFLAGS) @CFLAGS@
+
+EVENTS_OBJ = @EVENTS_OBJ@ $(TALLOC_OBJ) @LIBREPLACEOBJ@
+
+default: all
+
+include $(eventsdir)/events.mk
+include $(eventsdir)/rules.mk
+
+all:: showflags dirs $(PROGS) $(LIBEVENTS_SOLIB) libevents.a $(PYTHON_BUILD_TARGET)
+
+install:: all
+$(LIBEVENTS_SOLIB): $(EVENTS_OBJ)
+ $(SHLD) $(SHLD_FLAGS) -o $@ $(EVENTS_OBJ) $(TALLOC_LIBS) @SONAMEFLAG@$(LIBEVENTS_SONAME)
+
+check: test
+
+test:: $(PYTHON_CHECK_TARGET)
+installcheck:: test install
+
+clean::
+ rm -f *.o *.a */*.o
+ rm -f $(TALLOC_OBJ)
+
+distclean:: clean
+ rm -f config.log config.status include/config.h config.cache
+ rm -f Makefile
+
+realdistclean:: distclean
+ rm -f configure include/config.h.in
diff --git a/source4/lib/events/autogen.sh b/source4/lib/events/autogen.sh
new file mode 100755
index 0000000000..b13a4b685d
--- /dev/null
+++ b/source4/lib/events/autogen.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+rm -rf autom4te.cache
+rm -f configure config.h.in
+
+IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace"
+IPATHS="$IPATHS -I lib/talloc -I talloc -I ../talloc"
+autoconf $IPATHS || exit 1
+autoheader $IPATHS || exit 1
+
+rm -rf autom4te.cache
+
+swig -O -Wall -python -keyword events.i # Ignore errors for now
+
+echo "Now run ./configure and then make."
+exit 0
+
diff --git a/source4/lib/events/config.mk b/source4/lib/events/config.mk
index 225a23c634..9d579807c8 100644
--- a/source4/lib/events/config.mk
+++ b/source4/lib/events/config.mk
@@ -1,43 +1,62 @@
+################################################
+# Start SUBSYSTEM LIBEVENTS
+[LIBRARY::LIBEVENTS]
+PUBLIC_DEPENDENCIES = LIBTALLOC
+OUTPUT_TYPE = STATIC_LIBRARY
+CFLAGS = -Ilib/events
+#
+# End SUBSYSTEM LIBEVENTS
+################################################
+
##############################
[MODULE::EVENTS_AIO]
-OBJ_FILES = events_aio.o
PRIVATE_DEPENDENCIES = LIBAIO_LINUX
SUBSYSTEM = LIBEVENTS
INIT_FUNCTION = s4_events_aio_init
##############################
+EVENTS_AIO_OBJ_FILES = $(libeventssrcdir)/events_aio.o
+
##############################
[MODULE::EVENTS_EPOLL]
-OBJ_FILES = events_epoll.o
SUBSYSTEM = LIBEVENTS
INIT_FUNCTION = s4_events_epoll_init
##############################
+EVENTS_EPOLL_OBJ_FILES = $(libeventssrcdir)/events_epoll.o
+
##############################
[MODULE::EVENTS_SELECT]
-OBJ_FILES = events_select.o
SUBSYSTEM = LIBEVENTS
INIT_FUNCTION = s4_events_select_init
##############################
+EVENTS_SELECT_OBJ_FILES = $(libeventssrcdir)/events_select.o
+
##############################
[MODULE::EVENTS_STANDARD]
-OBJ_FILES = events_standard.o
SUBSYSTEM = LIBEVENTS
INIT_FUNCTION = s4_events_standard_init
##############################
+EVENTS_STANDARD_OBJ_FILES = $(libeventssrcdir)/events_standard.o
##############################
# Start SUBSYSTEM LIBEVENTS
[SUBSYSTEM::LIBEVENTS]
-OBJ_FILES = events.o events_timed.o events_signal.o
-PUBLIC_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL
# End SUBSYSTEM LIBEVENTS
##############################
-PUBLIC_HEADERS += $(addprefix lib/events/, events.h events_internal.h)
+LIBEVENTS_OBJ_FILES = $(addprefix $(libeventssrcdir)/, events.o events_timed.o events_signal.o)
+
+PUBLIC_HEADERS += $(addprefix $(libeventssrcdir)/, events.h events_internal.h)
[PYTHON::swig_events]
-SWIG_FILE = events.i
-PRIVATE_DEPENDENCIES = LIBEVENTS
+LIBRARY_REALNAME = samba/_events.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = LIBEVENTS LIBSAMBA-HOSTCONFIG
+
+swig_events_OBJ_FILES = $(libeventssrcdir)/events_wrap.o
+
+$(eval $(call python_py_module_template,samba/events.py,$(libeventssrcdir)/events.py))
+
+$(swig_events_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
diff --git a/source4/lib/events/configure.ac b/source4/lib/events/configure.ac
new file mode 100644
index 0000000000..4eb3575aac
--- /dev/null
+++ b/source4/lib/events/configure.ac
@@ -0,0 +1,35 @@
+AC_PREREQ(2.50)
+AC_DEFUN([SMB_MODULE_DEFAULT], [echo -n ""])
+AC_DEFUN([SMB_LIBRARY_ENABLE], [echo -n ""])
+AC_DEFUN([SMB_ENABLE], [echo -n ""])
+AC_INIT(events, 1.0.0)
+AC_CONFIG_SRCDIR([events.c])
+AC_CONFIG_HEADER(config.h)
+AC_LIBREPLACE_ALL_CHECKS
+AC_LIBREPLACE_NETWORK_CHECKS
+
+m4_include(libtalloc.m4)
+
+AC_LD_EXPORT_DYNAMIC
+AC_LD_SONAMEFLAG
+AC_LD_PICFLAG
+AC_LD_SHLIBEXT
+AC_LIBREPLACE_SHLD
+AC_LIBREPLACE_SHLD_FLAGS
+AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
+m4_include(libevents.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 events.pc)
diff --git a/source4/lib/events/events.c b/source4/lib/events/events.c
index 555a5092cc..ccc62b4c83 100644
--- a/source4/lib/events/events.c
+++ b/source4/lib/events/events.c
@@ -52,15 +52,16 @@
forever.
*/
-
+#if _SAMBA_BUILD_
#include "includes.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
#include "lib/util/dlinklist.h"
#include "param/param.h"
-#if _SAMBA_BUILD_
-#include "build.h"
+#else
+#include "replace.h"
+#include "events_util.h"
#endif
+#include "events.h"
+#include "events_internal.h"
struct event_ops_list {
struct event_ops_list *next, *prev;
@@ -102,6 +103,10 @@ void event_set_default_backend(const char *backend)
static void event_backend_init(void)
{
#if _SAMBA_BUILD_
+ NTSTATUS s4_events_standard_init(void);
+ NTSTATUS s4_events_select_init(void);
+ NTSTATUS s4_events_epoll_init(void);
+ NTSTATUS s4_events_aio_init(void);
init_module_fn static_init[] = { STATIC_LIBEVENTS_MODULES };
if (event_backends) return;
run_init_functions(static_init);
@@ -203,6 +208,8 @@ struct event_context *event_context_init_byname(TALLOC_CTX *mem_ctx, const char
*/
struct event_context *event_context_init(TALLOC_CTX *mem_ctx)
{
+ DEBUG(0, ("New event context requested. Parent: [%s:%p]\n",
+ mem_ctx?talloc_get_name(mem_ctx):"NULL", mem_ctx));
return event_context_init_byname(mem_ctx, NULL);
}
@@ -282,7 +289,7 @@ struct signal_event *event_add_signal(struct event_context *ev, TALLOC_CTX *mem_
/*
do a single event loop using the events defined in ev
*/
-_PUBLIC_ int event_loop_once(struct event_context *ev)
+int event_loop_once(struct event_context *ev)
{
return ev->ops->loop_once(ev);
}
diff --git a/source4/lib/events/events.i b/source4/lib/events/events.i
index 263605b176..7de8aec79d 100644
--- a/source4/lib/events/events.i
+++ b/source4/lib/events/events.i
@@ -21,14 +21,17 @@
%import "../talloc/talloc.i";
%{
-#include "lib/events/events.h"
+#include "events.h"
typedef struct event_context event;
%}
typedef struct event_context {
%extend {
+ %feature("docstring") event "S.__init__()";
event(TALLOC_CTX *mem_ctx) { return event_context_init(mem_ctx); }
+ %feature("docstring") loop_once "S.loop_once() -> int";
int loop_once(void);
+ %feature("docstring") loop_wait "S.loop_wait() -> int";
int loop_wait(void);
}
} event;
@@ -44,6 +47,8 @@ typedef struct event_context {
struct event_context *event_context_init_byname(TALLOC_CTX *mem_ctx, const char *name);
+%feature("docstring") event_backend_list "event_backend_list() -> list";
const char **event_backend_list(TALLOC_CTX *mem_ctx);
+%feature("docstring") event_set_default_backend "event_set_default_backend(name) -> None";
%rename(set_default_backend) event_set_default_backend;
void event_set_default_backend(const char *backend);
diff --git a/source4/lib/events/events.mk b/source4/lib/events/events.mk
new file mode 100644
index 0000000000..64d3fcb9fd
--- /dev/null
+++ b/source4/lib/events/events.mk
@@ -0,0 +1,59 @@
+dirs::
+ @mkdir -p lib
+
+LIBEVENTS_SONAME = libevents.$(SHLIBEXT).0
+LIBEVENTS_SOLIB = libevents.$(SHLIBEXT).$(PACKAGE_VERSION)
+
+LIBEVENTS = libevents.a
+
+clean::
+ rm -f $(LIBEVENTS_SONAME) $(LIBEVENTS_SOLIB) libevents.a libevents.$(SHLIBEXT)
+ rm -f events.pc
+
+build-python:: _libevents.$(SHLIBEXT)
+
+events_wrap.o: $(eventsdir)/events_wrap.c
+ $(CC) $(PICFLAG) -c $(eventsdir)/events_wrap.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags`
+
+_libevents.$(SHLIBEXT): libevents.$(SHLIBEXT) events_wrap.o
+ $(SHLD) $(SHLD_FLAGS) -o $@ events_wrap.o -L. -levents `$(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 $(eventsdir)/events.py $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"`
+ cp _libevents.$(SHLIBEXT) $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='$(prefix)')"`
+
+check-python:: build-python
+ $(LIB_PATH_VAR)=. PYTHONPATH=".:$(eventsdir)" $(PYTHON) $(eventsdir)/python/tests/simple.py
+
+install-swig::
+ mkdir -p $(DESTDIR)`$(SWIG) -swiglib`
+ cp events.i $(DESTDIR)`$(SWIG) -swiglib`
+
+clean::
+ rm -f _libevents.$(SHLIBEXT)
+
+installdirs::
+ mkdir -p $(DESTDIR)$(includedir)
+ mkdir -p $(DESTDIR)$(libdir)
+ mkdir -p $(DESTDIR)$(libdir)/pkgconfig
+
+installheaders:: installdirs
+ cp $(srcdir)/events.h $(DESTDIR)$(includedir)
+
+installlibs:: all installdirs
+ cp events.pc $(DESTDIR)$(libdir)/pkgconfig
+ cp libevents.a $(LIBEVENTS_SOLIB) $(DESTDIR)$(libdir)
+
+libevents.a: $(EVENTS_OBJ)
+ ar -rv libevents.a $(EVENTS_OBJ)
+
+libevents.$(SHLIBEXT): $(LIBEVENTS_SOLIB)
+ ln -fs $< $@
+
+$(LIBEVENTS_SONAME): $(LIBEVENTS_SOLIB)
+ ln -fs $< $@
diff --git a/source4/lib/events/events.pc.in b/source4/lib/events/events.pc.in
new file mode 100644
index 0000000000..4a4c012d73
--- /dev/null
+++ b/source4/lib/events/events.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: events
+Description: An event system library
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -levents
+Cflags: -I${includedir}
+URL: http://samba.org/
diff --git a/source4/lib/events/events.py b/source4/lib/events/events.py
index d8f70f6319..264e0b7cdf 100644
--- a/source4/lib/events/events.py
+++ b/source4/lib/events/events.py
@@ -1,5 +1,5 @@
# This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.33
+# Version 1.3.35
#
# Don't modify this file, modify the SWIG interface instead.
@@ -61,7 +61,16 @@ class event(object):
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
def __init__(self, *args, **kwargs):
+ """S.__init__()"""
_events.event_swiginit(self,_events.new_event(*args, **kwargs))
+ def loop_once(*args, **kwargs):
+ """S.loop_once() -> int"""
+ return _events.event_loop_once(*args, **kwargs)
+
+ def loop_wait(*args, **kwargs):
+ """S.loop_wait() -> int"""
+ return _events.event_loop_wait(*args, **kwargs)
+
__swig_destroy__ = _events.delete_event
event.loop_once = new_instancemethod(_events.event_loop_once,None,event)
event.loop_wait = new_instancemethod(_events.event_loop_wait,None,event)
@@ -69,7 +78,13 @@ event_swigregister = _events.event_swigregister
event_swigregister(event)
event_context_init_byname = _events.event_context_init_byname
-event_backend_list = _events.event_backend_list
-set_default_backend = _events.set_default_backend
+
+def event_backend_list(*args):
+ """event_backend_list() -> list"""
+ return _events.event_backend_list(*args)
+
+def set_default_backend(*args, **kwargs):
+ """event_set_default_backend(name) -> None"""
+ return _events.set_default_backend(*args, **kwargs)
diff --git a/source4/lib/events/events_epoll.c b/source4/lib/events/events_epoll.c
index 109027eb1a..07e66154fc 100644
--- a/source4/lib/events/events_epoll.c
+++ b/source4/lib/events/events_epoll.c
@@ -20,12 +20,17 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#if _SAMBA_BUILD_
#include "includes.h"
+#include "lib/util/dlinklist.h"
+#else
+#include "replace.h"
+#include "events_util.h"
+#endif
#include "system/filesys.h"
#include "system/network.h"
-#include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
+#include "events.h"
+#include "events_internal.h"
#include <sys/epoll.h>
struct epoll_event_context {
@@ -56,9 +61,11 @@ struct epoll_event_context {
called when a epoll call fails, and we should fallback
to using select
*/
-_NORETURN_ static void epoll_panic(struct epoll_event_context *epoll_ev, const char *reason)
+static void epoll_panic(struct epoll_event_context *epoll_ev, const char *reason)
{
+#if _SAMBA_BUILD_
DEBUG(0,("%s (%s) - calling abort()\n", reason, strerror(errno)));
+#endif
abort();
}
diff --git a/source4/lib/events/events_select.c b/source4/lib/events/events_select.c
index f4b7e4e5eb..16fff71e4a 100644
--- a/source4/lib/events/events_select.c
+++ b/source4/lib/events/events_select.c
@@ -23,12 +23,17 @@
*/
+#if _SAMBA_BUILD_
#include "includes.h"
+#include "lib/util/dlinklist.h"
+#else
+#include "replace.h"
+#include "events_util.h"
+#endif
#include "system/filesys.h"
#include "system/select.h"
-#include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
+#include "events.h"
+#include "events_internal.h"
struct select_event_context {
/* a pointer back to the generic event_context */
@@ -216,7 +221,9 @@ static int select_event_loop_select(struct select_event_context *select_ev, stru
made readable and that should have removed
the event, so this must be a bug. This is a
fatal error. */
+#if _SAMBA_BUILD_
DEBUG(0,("ERROR: EBADF on select_event_loop_once\n"));
+#endif
select_ev->exit_code = EBADF;
return -1;
}
diff --git a/source4/lib/events/events_signal.c b/source4/lib/events/events_signal.c
index c0771cbe01..7128612fb0 100644
--- a/source4/lib/events/events_signal.c
+++ b/source4/lib/events/events_signal.c
@@ -19,13 +19,18 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#if _SAMBA_BUILD_
#include "includes.h"
+#include "lib/util/dlinklist.h"
+#else
+#include <signal.h>
+#include "replace.h"
+#include "events_util.h"
+#endif
#include "system/filesys.h"
#include "system/select.h"
-#include "system/wait.h"
-#include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
+#include "events.h"
+#include "events_internal.h"
#define NUM_SIGNALS 64
diff --git a/source4/lib/events/events_standard.c b/source4/lib/events/events_standard.c
index 7b945b154d..4e41c42206 100644
--- a/source4/lib/events/events_standard.c
+++ b/source4/lib/events/events_standard.c
@@ -27,13 +27,18 @@
at runtime we fallback to select()
*/
+#if _SAMBA_BUILD_
#include "includes.h"
+#include "lib/util/dlinklist.h"
+#else
+#include "replace.h"
+#include "events_util.h"
+#endif
#include "system/filesys.h"
#include "system/network.h"
#include "system/select.h" /* needed for HAVE_EVENTS_EPOLL */
-#include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
+#include "events.h"
+#include "events_internal.h"
struct std_event_context {
/* a pointer back to the generic event_context */
diff --git a/source4/lib/events/events_timed.c b/source4/lib/events/events_timed.c
index 389c2cbbb7..79e4cde795 100644
--- a/source4/lib/events/events_timed.c
+++ b/source4/lib/events/events_timed.c
@@ -20,12 +20,17 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#if _SAMBA_BUILD_
#include "includes.h"
+#include "lib/util/dlinklist.h"
+#else
+#include "replace.h"
+#include "events_util.h"
+#endif
#include "system/filesys.h"
#include "system/select.h"
-#include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
+#include "events.h"
+#include "events_internal.h"
/*
destroy a timed event
diff --git a/source4/lib/events/events_util.c b/source4/lib/events/events_util.c
new file mode 100644
index 0000000000..74e11473f3
--- /dev/null
+++ b/source4/lib/events/events_util.c
@@ -0,0 +1,129 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Copyright (C) Andrew Tridgell 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/>.
+*/
+
+#include "replace.h"
+#include "talloc.h"
+
+/**
+ return the number of elements in a string list
+*/
+static size_t str_list_length(const char **list)
+{
+ size_t ret;
+ for (ret=0;list && list[ret];ret++) /* noop */ ;
+ return ret;
+}
+
+/**
+ add an entry to a string list
+*/
+const char **str_list_add(const char **list, const char *s)
+{
+ size_t len = str_list_length(list);
+ const char **ret;
+
+ ret = talloc_realloc(NULL, list, const char *, len+2);
+ if (ret == NULL) return NULL;
+
+ ret[len] = talloc_strdup(ret, s);
+ if (ret[len] == NULL) return NULL;
+
+ ret[len+1] = NULL;
+
+ return ret;
+}
+
+/**
+ compare two timeval structures.
+ Return -1 if tv1 < tv2
+ Return 0 if tv1 == tv2
+ Return 1 if tv1 > tv2
+*/
+static int timeval_compare(const struct timeval *tv1, const struct timeval *tv2)
+{
+ if (tv1->tv_sec > tv2->tv_sec) return 1;
+ if (tv1->tv_sec < tv2->tv_sec) return -1;
+ if (tv1->tv_usec > tv2->tv_usec) return 1;
+ if (tv1->tv_usec < tv2->tv_usec) return -1;
+ return 0;
+}
+
+/**
+ return a zero timeval
+*/
+struct timeval timeval_zero(void)
+{
+ struct timeval tv;
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ return tv;
+}
+
+/**
+ return true if a timeval is zero
+*/
+bool timeval_is_zero(const struct timeval *tv)
+{
+ return tv->tv_sec == 0 && tv->tv_usec == 0;
+}
+
+/**
+ return a timeval for the current time
+*/
+struct timeval timeval_current(void)
+{
+ struct timeval tv;
+ GetTimeOfDay(&tv);
+ return tv;
+}
+
+/**
+ return a timeval struct with the given elements
+*/
+struct timeval timeval_set(uint32_t secs, uint32_t usecs)
+{
+ struct timeval tv;
+ tv.tv_sec = secs;
+ tv.tv_usec = usecs;
+ return tv;
+}
+
+/**
+ return the difference between two timevals as a timeval
+ if tv1 comes after tv2, then return a zero timeval
+ (this is *tv2 - *tv1)
+*/
+struct timeval timeval_until(const struct timeval *tv1,
+ const struct timeval *tv2)
+{
+ struct timeval t;
+ if (timeval_compare(tv1, tv2) >= 0) {
+ return timeval_zero();
+ }
+ t.tv_sec = tv2->tv_sec - tv1->tv_sec;
+ if (tv1->tv_usec > tv2->tv_usec) {
+ t.tv_sec--;
+ t.tv_usec = 1000000 - (tv1->tv_usec - tv2->tv_usec);
+ } else {
+ t.tv_usec = tv2->tv_usec - tv1->tv_usec;
+ }
+ return t;
+}
+
diff --git a/source4/lib/events/events_util.h b/source4/lib/events/events_util.h
new file mode 100644
index 0000000000..401df891a5
--- /dev/null
+++ b/source4/lib/events/events_util.h
@@ -0,0 +1,123 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Copyright (C) Andrew Tridgell 1998-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/>.
+*/
+
+/* To use these macros you must have a structure containing a next and
+ prev pointer */
+
+#ifndef _DLINKLIST_H
+#define _DLINKLIST_H
+
+
+/* hook into the front of the list */
+#define DLIST_ADD(list, p) \
+do { \
+ if (!(list)) { \
+ (list) = (p); \
+ (p)->next = (p)->prev = NULL; \
+ } else { \
+ (list)->prev = (p); \
+ (p)->next = (list); \
+ (p)->prev = NULL; \
+ (list) = (p); \
+ }\
+} while (0)
+
+/* remove an element from a list - element doesn't have to be in list. */
+#define DLIST_REMOVE(list, p) \
+do { \
+ if ((p) == (list)) { \
+ (list) = (p)->next; \
+ if (list) (list)->prev = NULL; \
+ } else { \
+ if ((p)->prev) (p)->prev->next = (p)->next; \
+ if ((p)->next) (p)->next->prev = (p)->prev; \
+ } \
+ if ((p) != (list)) (p)->next = (p)->prev = NULL; \
+} while (0)
+
+/* promote an element to the top of the list */
+#define DLIST_PROMOTE(list, p) \
+do { \
+ DLIST_REMOVE(list, p); \
+ DLIST_ADD(list, p); \
+} while (0)
+
+/* hook into the end of the list - needs a tmp pointer */
+#define DLIST_ADD_END(list, p, type) \
+do { \
+ if (!(list)) { \
+ (list) = (p); \
+ (p)->next = (p)->prev = NULL; \
+ } else { \
+ type tmp; \
+ for (tmp = (list); tmp->next; tmp = tmp->next) ; \
+ tmp->next = (p); \
+ (p)->next = NULL; \
+ (p)->prev = tmp; \
+ } \
+} while (0)
+
+/* insert 'p' after the given element 'el' in a list. If el is NULL then
+ this is the same as a DLIST_ADD() */
+#define DLIST_ADD_AFTER(list, p, el) \
+do { \
+ if (!(list) || !(el)) { \
+ DLIST_ADD(list, p); \
+ } else { \
+ p->prev = el; \
+ p->next = el->next; \
+ el->next = p; \
+ if (p->next) p->next->prev = p; \
+ }\
+} while (0)
+
+/* demote an element to the end of the list, needs a tmp pointer */
+#define DLIST_DEMOTE(list, p, tmp) \
+do { \
+ DLIST_REMOVE(list, p); \
+ DLIST_ADD_END(list, p, tmp); \
+} while (0)
+
+/* concatenate two lists - putting all elements of the 2nd list at the
+ end of the first list */
+#define DLIST_CONCATENATE(list1, list2, type) \
+do { \
+ if (!(list1)) { \
+ (list1) = (list2); \
+ } else { \
+ type tmp; \
+ for (tmp = (list1); tmp->next; tmp = tmp->next) ; \
+ tmp->next = (list2); \
+ if (list2) { \
+ (list2)->prev = tmp; \
+ } \
+ } \
+} while (0)
+
+#endif /* _DLINKLIST_H */
+
+const char **str_list_add(const char **list, const char *s);
+struct timeval timeval_zero(void);
+bool timeval_is_zero(const struct timeval *tv);
+struct timeval timeval_current(void);
+struct timeval timeval_set(uint32_t secs, uint32_t usecs);
+struct timeval timeval_until(const struct timeval *tv1,
+ const struct timeval *tv2);
+
diff --git a/source4/lib/events/events_wrap.c b/source4/lib/events/events_wrap.c
index b220d320cf..ccaeab7ad6 100644
--- a/source4/lib/events/events_wrap.c
+++ b/source4/lib/events/events_wrap.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.33
+ * Version 1.3.35
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
@@ -126,7 +126,7 @@
/* This should only be incremented when either the layout of swig_type_info changes,
or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "3"
+#define SWIG_RUNTIME_VERSION "4"
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
#ifdef SWIG_TYPE_TABLE
@@ -161,6 +161,7 @@
/* Flags for pointer conversions */
#define SWIG_POINTER_DISOWN 0x1
+#define SWIG_CAST_NEW_MEMORY 0x2
/* Flags for new pointer objects */
#define SWIG_POINTER_OWN 0x1
@@ -301,10 +302,10 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) {
extern "C" {
#endif
-typedef void *(*swig_converter_func)(void *);
+typedef void *(*swig_converter_func)(void *, int *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);
-/* Structure to store inforomation on one type */
+/* Structure to store information on one type */
typedef struct swig_type_info {
const char *name; /* mangled name of this type */
const char *str; /* human readable name of this type */
@@ -431,8 +432,8 @@ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
Cast a pointer up an inheritance hierarchy
*/
SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
- return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
+SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
}
/*
@@ -856,7 +857,7 @@ SWIG_Python_AddErrorMsg(const char* mesg)
Py_DECREF(old_str);
Py_DECREF(value);
} else {
- PyErr_Format(PyExc_RuntimeError, mesg);
+ PyErr_SetString(PyExc_RuntimeError, mesg);
}
}
@@ -1416,7 +1417,7 @@ PySwigObject_dealloc(PyObject *v)
{
PySwigObject *sobj = (PySwigObject *) v;
PyObject *next = sobj->next;
- if (sobj->own) {
+ if (sobj->own == SWIG_POINTER_OWN) {
swig_type_info *ty = sobj->ty;
PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
PyObject *destroy = data ? data->destroy : 0;
@@ -1434,12 +1435,13 @@ PySwigObject_dealloc(PyObject *v)
res = ((*meth)(mself, v));
}
Py_XDECREF(res);
- } else {
- const char *name = SWIG_TypePrettyName(ty);
+ }
#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
- printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
-#endif
+ else {
+ const char *name = SWIG_TypePrettyName(ty);
+ printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
}
+#endif
}
Py_XDECREF(next);
PyObject_DEL(v);
@@ -1944,7 +1946,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
SWIGRUNTIME int
SWIG_Python_AcquirePtr(PyObject *obj, int own) {
- if (own) {
+ if (own == SWIG_POINTER_OWN) {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
if (sobj) {
int oldown = sobj->own;
@@ -1965,6 +1967,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
return SWIG_OK;
} else {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+ if (own)
+ *own = 0;
while (sobj) {
void *vptr = sobj->ptr;
if (ty) {
@@ -1978,7 +1982,15 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
if (!tc) {
sobj = (PySwigObject *)sobj->next;
} else {
- if (ptr) *ptr = SWIG_TypeCast(tc,vptr);
+ if (ptr) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
+ assert(own);
+ if (own)
+ *own = *own | SWIG_CAST_NEW_MEMORY;
+ }
+ }
break;
}
}
@@ -1988,7 +2000,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
}
}
if (sobj) {
- if (own) *own = sobj->own;
+ if (own)
+ *own = *own | sobj->own;
if (flags & SWIG_POINTER_DISOWN) {
sobj->own = 0;
}
@@ -2053,8 +2066,13 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
}
if (ty) {
swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
- if (!tc) return SWIG_ERROR;
- *ptr = SWIG_TypeCast(tc,vptr);
+ if (tc) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ assert(!newmemory); /* newmemory handling not yet implemented */
+ } else {
+ return SWIG_ERROR;
+ }
} else {
*ptr = vptr;
}
@@ -2493,7 +2511,7 @@ static swig_module_info swig_module = {swig_types, 4, 0, 0, 0, 0};
#define SWIG_name "_events"
-#define SWIGVERSION 0x010333
+#define SWIGVERSION 0x010335
#define SWIG_VERSION SWIGVERSION
@@ -2501,7 +2519,7 @@ static swig_module_info swig_module = {swig_types, 4, 0, 0, 0, 0};
#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
-#include "lib/events/events.h"
+#include "events.h"
typedef struct event_context event;
SWIGINTERN event *new_event(TALLOC_CTX *mem_ctx){ return event_context_init(mem_ctx); }
@@ -2755,15 +2773,15 @@ fail:
static PyMethodDef SwigMethods[] = {
- { (char *)"new_event", (PyCFunction)_wrap_new_event, METH_NOARGS, NULL},
- { (char *)"event_loop_once", (PyCFunction)_wrap_event_loop_once, METH_O, NULL},
- { (char *)"event_loop_wait", (PyCFunction)_wrap_event_loop_wait, METH_O, NULL},
+ { (char *)"new_event", (PyCFunction)_wrap_new_event, METH_NOARGS, (char *)"S.__init__()"},
+ { (char *)"event_loop_once", (PyCFunction)_wrap_event_loop_once, METH_O, (char *)"S.loop_once() -> int"},
+ { (char *)"event_loop_wait", (PyCFunction)_wrap_event_loop_wait, METH_O, (char *)"S.loop_wait() -> int"},
{ (char *)"delete_event", (PyCFunction)_wrap_delete_event, METH_O, NULL},
{ (char *)"event_swigregister", event_swigregister, METH_VARARGS, NULL},
{ (char *)"event_swiginit", event_swiginit, METH_VARARGS, NULL},
{ (char *)"event_context_init_byname", (PyCFunction) _wrap_event_context_init_byname, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"event_backend_list", (PyCFunction)_wrap_event_backend_list, METH_NOARGS, NULL},
- { (char *)"set_default_backend", (PyCFunction) _wrap_set_default_backend, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"event_backend_list", (PyCFunction)_wrap_event_backend_list, METH_NOARGS, (char *)"event_backend_list() -> list"},
+ { (char *)"set_default_backend", (PyCFunction) _wrap_set_default_backend, METH_VARARGS | METH_KEYWORDS, (char *)"event_set_default_backend(name) -> None"},
{ NULL, NULL, 0, NULL }
};
@@ -2860,7 +2878,7 @@ SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
- int found;
+ int found, init;
clientdata = clientdata;
@@ -2870,6 +2888,9 @@ SWIG_InitializeModule(void *clientdata) {
swig_module.type_initial = swig_type_initial;
swig_module.cast_initial = swig_cast_initial;
swig_module.next = &swig_module;
+ init = 1;
+ } else {
+ init = 0;
}
/* Try and load any already created modules */
@@ -2898,6 +2919,12 @@ SWIG_InitializeModule(void *clientdata) {
module_head->next = &swig_module;
}
+ /* When multiple interpeters are used, a module could have already been initialized in
+ a different interpreter, but not yet have a pointer in this interpreter.
+ In this case, we do not want to continue adding types... everything should be
+ set up already */
+ if (init == 0) return;
+
/* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: size %d\n", swig_module.size);
diff --git a/source4/lib/events/libevents.m4 b/source4/lib/events/libevents.m4
index 99a47dcc54..483ab861fb 100644
--- a/source4/lib/events/libevents.m4
+++ b/source4/lib/events/libevents.m4
@@ -1,11 +1,28 @@
-EVENTS_OBJ="lib/events/events.o lib/events/events_select.o lib/events/events_signal.o lib/events/events_timed.o lib/events/events_standard.o"
+dnl find the events sources. This is meant to work both for
+dnl standalone builds, and builds of packages using libevents
+eventsdir=""
+eventspaths="$srcdir $srcdir/lib/events $srcdir/events $srcdir/../events"
+for d in $eventspaths; do
+ if test -f "$d/events.c"; then
+ eventsdir="$d"
+ AC_SUBST(eventsdir)
+ break;
+ fi
+done
+if test x"$eventsdir" = "x"; then
+ AC_MSG_ERROR([cannot find libevents source in $eventspaths])
+fi
+
+EVENTS_OBJ="events.o events_select.o events_signal.o events_timed.o events_standard.o events_util.o"
+AC_SUBST(LIBREPLACEOBJ)
AC_CHECK_HEADERS(sys/epoll.h)
AC_CHECK_FUNCS(epoll_create)
if test x"$ac_cv_header_sys_epoll_h" = x"yes" -a x"$ac_cv_func_epoll_create" = x"yes"; then
- EVENTS_OBJ="$EVENTS_OBJ lib/events/events_epoll.o"
+ EVENTS_OBJ="$EVENTS_OBJ events_epoll.o"
AC_DEFINE(HAVE_EVENTS_EPOLL, 1, [Whether epoll available])
fi
AC_SUBST(EVENTS_OBJ)
+
diff --git a/source4/lib/events/tests.py b/source4/lib/events/tests.py
index b14f7e6250..006426207e 100644
--- a/source4/lib/events/tests.py
+++ b/source4/lib/events/tests.py
@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-import events
+from samba import events
import unittest
# Just test the bindings are there and that calling them doesn't crash
diff --git a/source4/lib/ldb-samba/config.mk b/source4/lib/ldb-samba/config.mk
index fa3ac46021..84007f3833 100644
--- a/source4/lib/ldb-samba/config.mk
+++ b/source4/lib/ldb-samba/config.mk
@@ -2,11 +2,10 @@
# Start SUBSYSTEM LDBSAMBA
[SUBSYSTEM::LDBSAMBA]
PUBLIC_DEPENDENCIES = LIBLDB
-PRIVATE_PROTO_HEADER = ldif_handlers.h
PRIVATE_DEPENDENCIES = LIBSECURITY SAMDB_SCHEMA LIBNDR NDR_MISC
-OBJ_FILES = \
- ldif_handlers.o
# End SUBSYSTEM LDBSAMBA
################################################
+LDBSAMBA_OBJ_FILES = $(ldb_sambasrcdir)/ldif_handlers.o
+$(eval $(call proto_header_template,$(ldb_sambasrcdir)/ldif_handlers.h,$(LDBSAMBA_OBJ_FILES:.o=.c)))
diff --git a/source4/lib/ldb/common/ldb_modules.c b/source4/lib/ldb/common/ldb_modules.c
index 34e0afbf93..ddbe0f23a6 100644
--- a/source4/lib/ldb/common/ldb_modules.c
+++ b/source4/lib/ldb/common/ldb_modules.c
@@ -35,7 +35,6 @@
#if (_SAMBA_BUILD_ >= 4)
#include "includes.h"
-#include "build.h"
#endif
#define LDB_MODULE_PREFIX "modules:"
@@ -126,14 +125,16 @@ static struct ops_list_entry {
struct ops_list_entry *next;
} *registered_modules = NULL;
+#define LDB_MODULE(name) (&ldb_ ## name ## _module_ops)
+
#ifndef STATIC_LIBLDB_MODULES
#define STATIC_LIBLDB_MODULES \
- &ldb_operational_module_ops, \
- &ldb_rdn_name_module_ops, \
- &ldb_paged_results_module_ops, \
- &ldb_server_sort_module_ops, \
- &ldb_asq_module_ops, \
+ LDB_MODULE(operational), \
+ LDB_MODULE(rdn_name), \
+ LDB_MODULE(paged_results), \
+ LDB_MODULE(server_sort), \
+ LDB_MODULE(asq), \
NULL
#endif
diff --git a/source4/lib/ldb/config.mk b/source4/lib/ldb/config.mk
index 81fd1e9b95..e8852980f6 100644
--- a/source4/lib/ldb/config.mk
+++ b/source4/lib/ldb/config.mk
@@ -3,10 +3,10 @@
[MODULE::ldb_asq]
PRIVATE_DEPENDENCIES = LIBTALLOC
CFLAGS = -Ilib/ldb/include
-INIT_FUNCTION = &ldb_asq_module_ops
+INIT_FUNCTION = LDB_MODULE(asq)
SUBSYSTEM = LIBLDB
-OBJ_FILES = \
- modules/asq.o
+
+ldb_asq_OBJ_FILES = lib/ldb/modules/asq.o
# End MODULE ldb_asq
################################################
@@ -15,72 +15,64 @@ OBJ_FILES = \
[MODULE::ldb_server_sort]
PRIVATE_DEPENDENCIES = LIBTALLOC
CFLAGS = -Ilib/ldb/include
-INIT_FUNCTION = &ldb_server_sort_module_ops
+INIT_FUNCTION = LDB_MODULE(server_sort)
SUBSYSTEM = LIBLDB
-OBJ_FILES = \
- modules/sort.o
+
# End MODULE ldb_sort
################################################
+ldb_server_sort_OBJ_FILES = lib/ldb/modules/sort.o
################################################
# Start MODULE ldb_paged_results
[MODULE::ldb_paged_results]
-INIT_FUNCTION = &ldb_paged_results_module_ops
+INIT_FUNCTION = LDB_MODULE(paged_results)
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC
SUBSYSTEM = LIBLDB
-OBJ_FILES = \
- modules/paged_results.o
# End MODULE ldb_paged_results
################################################
+ldb_paged_results_OBJ_FILES = lib/ldb/modules/paged_results.o
+
################################################
# Start MODULE ldb_paged_results
[MODULE::ldb_paged_searches]
-INIT_FUNCTION = &ldb_paged_searches_module_ops
+INIT_FUNCTION = LDB_MODULE(paged_searches)
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC
SUBSYSTEM = LIBLDB
-OBJ_FILES = \
- modules/paged_searches.o
# End MODULE ldb_paged_results
################################################
+ldb_paged_searches_OBJ_FILES = lib/ldb/modules/paged_searches.o
+
################################################
# Start MODULE ldb_operational
[MODULE::ldb_operational]
SUBSYSTEM = LIBLDB
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC
-INIT_FUNCTION = &ldb_operational_module_ops
-OBJ_FILES = \
- modules/operational.o
+INIT_FUNCTION = LDB_MODULE(operational)
# End MODULE ldb_operational
################################################
+ldb_operational_OBJ_FILES = lib/ldb/modules/operational.o
+
################################################
# Start MODULE ldb_rdn_name
[MODULE::ldb_rdn_name]
SUBSYSTEM = LIBLDB
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC
-INIT_FUNCTION = &ldb_rdn_name_module_ops
-OBJ_FILES = \
- modules/rdn_name.o
+INIT_FUNCTION = LDB_MODULE(rdn_name)
# End MODULE ldb_rdn_name
################################################
-################################################
-# Start MODULE ldb_map
-[SUBSYSTEM::ldb_map]
-PRIVATE_DEPENDENCIES = LIBTALLOC
-CFLAGS = -Ilib/ldb/include -Ilib/ldb/ldb_map
-OBJ_FILES = \
- ldb_map/ldb_map_inbound.o \
- ldb_map/ldb_map_outbound.o \
- ldb_map/ldb_map.o
-# End MODULE ldb_map
-################################################
+ldb_rdn_name_OBJ_FILES = lib/ldb/modules/rdn_name.o
+
+ldb_map_OBJ_FILES = $(addprefix lib/ldb/ldb_map/, ldb_map_inbound.o ldb_map_outbound.o ldb_map.o)
+
+$(ldb_map_OBJ_FILES): CFLAGS+=-Ilib/ldb/ldb_map
################################################
# Start MODULE ldb_skel
@@ -88,69 +80,56 @@ OBJ_FILES = \
SUBSYSTEM = LIBLDB
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC
-INIT_FUNCTION = &ldb_skel_module_ops
-OBJ_FILES = modules/skel.o
+INIT_FUNCTION = LDB_MODULE(skel)
# End MODULE ldb_skel
################################################
+ldb_skel_OBJ_FILES = lib/ldb/modules/skel.o
+
################################################
# Start MODULE ldb_sqlite3
[MODULE::ldb_sqlite3]
SUBSYSTEM = LIBLDB
CFLAGS = -Ilib/ldb/include
PRIVATE_DEPENDENCIES = LIBTALLOC SQLITE3 LIBTALLOC
-OBJ_FILES = \
- ldb_sqlite3/ldb_sqlite3.o
# End MODULE ldb_sqlite3
################################################
+ldb_sqlite3_OBJ_FILES = lib/ldb/ldb_sqlite3/ldb_sqlite3.o
+
################################################
# Start MODULE ldb_tdb
[MODULE::ldb_tdb]
SUBSYSTEM = LIBLDB
CFLAGS = -Ilib/ldb/include -Ilib/ldb/ldb_tdb
-OBJ_FILES = \
- ldb_tdb/ldb_tdb.o \
- ldb_tdb/ldb_search.o \
- ldb_tdb/ldb_pack.o \
- ldb_tdb/ldb_index.o \
- ldb_tdb/ldb_cache.o \
- ldb_tdb/ldb_tdb_wrap.o
PRIVATE_DEPENDENCIES = \
LIBTDB LIBTALLOC
# End MODULE ldb_tdb
################################################
+ldb_tdb_OBJ_FILES = $(addprefix lib/ldb/ldb_tdb/, ldb_tdb.o ldb_search.o ldb_pack.o ldb_index.o ldb_cache.o ldb_tdb_wrap.o)
+
+
################################################
# Start SUBSYSTEM ldb
[LIBRARY::LIBLDB]
-VERSION = 0.0.1
-SO_VERSION = 0
CFLAGS = -Ilib/ldb/include
-PC_FILE = ldb.pc
INIT_FUNCTION_TYPE = extern const struct ldb_module_ops
-OBJ_FILES = \
- common/ldb.o \
- common/ldb_ldif.o \
- common/ldb_parse.o \
- common/ldb_msg.o \
- common/ldb_utf8.o \
- common/ldb_debug.o \
- common/ldb_modules.o \
- common/ldb_match.o \
- common/ldb_attributes.o \
- common/attrib_handlers.o \
- common/ldb_dn.o \
- common/ldb_controls.o \
- common/qsort.o
PUBLIC_DEPENDENCIES = \
LIBTALLOC
PRIVATE_DEPENDENCIES = \
SOCKET_WRAPPER
+
+PC_FILES += $(ldbdir)/ldb.pc
#
# End SUBSYSTEM ldb
################################################
+LIBLDB_VERSION = 0.0.1
+LIBLDB_SOVERSION = 0
+
+LIBLDB_OBJ_FILES = $(addprefix lib/ldb/common/, ldb.o ldb_ldif.o ldb_parse.o ldb_msg.o ldb_utf8.o ldb_debug.o ldb_modules.o ldb_match.o ldb_attributes.o attrib_handlers.o ldb_dn.o ldb_controls.o qsort.o) $(ldb_map_OBJ_FILES)
+
PUBLIC_HEADERS += $(ldbdir)/include/ldb.h $(ldbdir)/include/ldb_errors.h
MANPAGES += $(ldbdir)/man/ldb.3
@@ -158,39 +137,38 @@ MANPAGES += $(ldbdir)/man/ldb.3
################################################
# Start BINARY ldbtest
[BINARY::ldbtest]
-OBJ_FILES= \
- tools/ldbtest.o
PRIVATE_DEPENDENCIES = \
LIBLDB_CMDLINE
# End BINARY ldbtest
################################################
+ldbtest_OBJ_FILES = lib/ldb/tools/ldbtest.o
+
################################################
# Start BINARY oLschema2ldif
[BINARY::oLschema2ldif]
INSTALLDIR = BINDIR
-OBJ_FILES= \
- tools/convert.o \
- tools/oLschema2ldif.o
PRIVATE_DEPENDENCIES = \
LIBLDB_CMDLINE
# End BINARY oLschema2ldif
################################################
+
+oLschema2ldif_OBJ_FILES = $(addprefix lib/ldb/tools/, convert.o oLschema2ldif.o)
+
MANPAGES += $(ldbdir)/man/oLschema2ldif.1
################################################
# Start BINARY ad2oLschema
[BINARY::ad2oLschema]
INSTALLDIR = BINDIR
-OBJ_FILES= \
- tools/convert.o \
- tools/ad2oLschema.o
PRIVATE_DEPENDENCIES = \
LIBLDB_CMDLINE
# End BINARY ad2oLschema
################################################
+ad2oLschema_OBJ_FILES = $(addprefix lib/ldb/tools/, convert.o ad2oLschema.o)
+
MANPAGES += $(ldbdir)/man/ad2oLschema.1
mkinclude tools/config.mk
diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h
index 0ffba9d99b..ea8533bc38 100644
--- a/source4/lib/ldb/include/ldb_private.h
+++ b/source4/lib/ldb/include/ldb_private.h
@@ -188,8 +188,14 @@ extern const struct ldb_module_ops ldb_asq_module_ops;
extern const struct ldb_module_ops ldb_server_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_paged_searches_module_ops;
extern const struct ldb_module_ops ldb_tdb_module_ops;
+extern const struct ldb_module_ops ldb_skel_module_ops;
+extern const struct ldb_module_ops ldb_subtree_rename_module_ops;
+extern const struct ldb_module_ops ldb_subtree_delete_module_ops;
extern const struct ldb_module_ops ldb_sqlite3_module_ops;
+extern const struct ldb_module_ops ldb_wins_ldb_module_ops;
+extern const struct ldb_module_ops ldb_ranged_results_module_ops;
extern const struct ldb_backend_ops ldb_tdb_backend_ops;
extern const struct ldb_backend_ops ldb_sqlite3_backend_ops;
diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i
index e01a1107d2..061d13a2dd 100644
--- a/source4/lib/ldb/ldb.i
+++ b/source4/lib/ldb/ldb.i
@@ -25,7 +25,11 @@
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-%module ldb
+%define DOCSTRING
+"An interface to LDB, a LDAP-like API that can either to talk an embedded database (TDB-based) or a standards-compliant LDAP server."
+%enddef
+
+%module(docstring=DOCSTRING) ldb
%{
@@ -40,7 +44,7 @@ typedef struct ldb_message ldb_msg;
typedef struct ldb_context ldb;
typedef struct ldb_dn ldb_dn;
typedef struct ldb_ldif ldb_ldif;
-typedef struct ldb_message_element ldb_msg_element;
+typedef struct ldb_message_element ldb_message_element;
typedef int ldb_error;
typedef int ldb_int_error;
@@ -194,8 +198,11 @@ PyObject *ldb_val_to_py_object(struct ldb_context *ldb_ctx,
%rename(__cmp__) ldb_dn::compare;
%rename(__len__) ldb_dn::get_comp_num;
%rename(Dn) ldb_dn;
+%feature("docstring") ldb_dn "A LDB distinguished name.";
typedef struct ldb_dn {
%extend {
+ %feature("docstring") ldb_dn "S.__init__(ldb, string)\n" \
+ "Create a new DN.";
ldb_dn(ldb *ldb_ctx, const char *str)
{
ldb_dn *ret = ldb_dn_new(ldb_ctx, ldb_ctx, str);
@@ -210,25 +217,49 @@ fail:
return ret;
}
~ldb_dn() { talloc_free($self); }
+ %feature("docstring") validate "S.validate() -> bool\n" \
+ "Validate DN is correct.";
bool validate();
const char *get_casefold();
const char *get_linearized();
+ %feature("docstring") parent "S.parent() -> dn\n" \
+ "Get the parent for this DN.";
ldb_dn *parent() { return ldb_dn_get_parent(NULL, $self); }
int compare(ldb_dn *other);
bool is_valid();
+ %feature("docstring") is_special "S.is_special() -> bool\n" \
+ "Check whether this is a special LDB DN.";
bool is_special();
+ %feature("docstring") is_null "S.is_null() -> bool\n" \
+ "Check whether this is a null DN.";
bool is_null();
bool check_special(const char *name);
int get_comp_num();
+ %feature("docstring") add_child "S.add_child(dn) -> None\n" \
+ "Add a child DN to this DN.";
bool add_child(ldb_dn *child);
+ %feature("docstring") add_base "S.add_base(dn) -> None\n" \
+ "Add a base DN to this DN.";
bool add_base(ldb_dn *base);
+ %feature("docstring") canonical_str "S.canonical_str() -> string\n" \
+ "Canonical version of this DN (like a posix path).";
const char *canonical_str() {
return ldb_dn_canonical_string($self, $self);
}
+ %feature("docstring") canonical_ex_str "S.canonical_ex_str() -> string\n" \
+ "Canonical version of this DN (like a posix path, with terminating newline).";
const char *canonical_ex_str() {
return ldb_dn_canonical_ex_string($self, $self);
}
#ifdef SWIGPYTHON
+ char *__repr__(void)
+ {
+ char *dn = ldb_dn_get_linearized($self), *ret;
+ asprintf(&ret, "Dn('%s')", dn);
+ talloc_free(dn);
+ return ret;
+ }
+
ldb_dn *__add__(ldb_dn *other)
{
ldb_dn *ret = ldb_dn_copy(NULL, $self);
@@ -251,6 +282,14 @@ fail:
#ifdef SWIGPYTHON
%{
+struct ldb_context *ldb_context_from_py_object(PyObject *py_obj)
+{
+ struct ldb_context *ldb_ctx;
+ if (SWIG_ConvertPtr(py_obj, (void *)&ldb_ctx, SWIGTYPE_p_ldb_context, 0 | 0 ) < 0)
+ return NULL;
+ return ldb_ctx;
+}
+
int ldb_dn_from_pyobject(TALLOC_CTX *mem_ctx, PyObject *object,
struct ldb_context *ldb_ctx, ldb_dn **dn)
{
@@ -273,7 +312,7 @@ int ldb_dn_from_pyobject(TALLOC_CTX *mem_ctx, PyObject *object,
return ret;
}
-ldb_msg_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
+ldb_message_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
PyObject *set_obj, int flags,
const char *attr_name)
{
@@ -304,7 +343,7 @@ ldb_msg_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
}
PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx,
- ldb_msg_element *me)
+ ldb_message_element *me)
{
int i;
PyObject *result;
@@ -324,11 +363,16 @@ PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx,
#endif
/* ldb_message_element */
-%rename(__cmp__) ldb_message_element::compare;
-%rename(MessageElement) ldb_msg_element;
+%rename(MessageElement) ldb_message_element;
+%feature("docstring") ldb_message_element "Message element.";
typedef struct ldb_message_element {
%extend {
#ifdef SWIGPYTHON
+ int __cmp__(ldb_message_element *other)
+ {
+ return ldb_msg_element_compare($self, other);
+ }
+
PyObject *__iter__(void)
{
return PyObject_GetIter(ldb_msg_element_to_set(NULL, $self));
@@ -339,7 +383,7 @@ typedef struct ldb_message_element {
return ldb_msg_element_to_set(NULL, $self);
}
- ldb_msg_element(PyObject *set_obj, int flags=0, const char *name = NULL)
+ ldb_message_element(PyObject *set_obj, int flags=0, const char *name = NULL)
{
return ldb_msg_element_from_pyobject(NULL, set_obj, flags, name);
}
@@ -358,8 +402,7 @@ typedef struct ldb_message_element {
return ldb_val_to_py_object(NULL, $self, &$self->values[i]);
}
- ~ldb_msg_element() { talloc_free($self); }
- int compare(ldb_msg_element *);
+ ~ldb_message_element() { talloc_free($self); }
}
%pythoncode {
def __getitem__(self, i):
@@ -368,6 +411,9 @@ typedef struct ldb_message_element {
raise KeyError("no such value")
return ret
+ def __repr__(self):
+ return "MessageElement([%s])" % (",".join(repr(x) for x in self.__set__()))
+
def __eq__(self, other):
if (len(self) == 1 and self.get(0) == other):
return True
@@ -379,30 +425,34 @@ typedef struct ldb_message_element {
return False
return True
}
-} ldb_msg_element;
+} ldb_message_element;
/* ldb_message */
+%feature("docstring") ldb_message "Message.";
%rename(Message) ldb_message;
#ifdef SWIGPYTHON
%rename(__delitem__) ldb_message::remove_attr;
-%typemap(out) ldb_msg_element * {
+%typemap(out) ldb_message_element * {
if ($1 == NULL)
PyErr_SetString(PyExc_KeyError, "no such element");
else
$result = SWIG_NewPointerObj($1, SWIGTYPE_p_ldb_message_element, 0);
}
-%rename(__getitem__) ldb_message::find_element;
-//%typemap(out) ldb_msg_element *;
-
%inline {
PyObject *ldb_msg_list_elements(ldb_msg *msg)
{
- int i;
- PyObject *obj = PyList_New(msg->num_elements);
- for (i = 0; i < msg->num_elements; i++)
- PyList_SetItem(obj, i, PyString_FromString(msg->elements[i].name));
+ int i, j = 0;
+ PyObject *obj = PyList_New(msg->num_elements+(msg->dn != NULL?1:0));
+ if (msg->dn != NULL) {
+ PyList_SetItem(obj, j, PyString_FromString("dn"));
+ j++;
+ }
+ for (i = 0; i < msg->num_elements; i++) {
+ PyList_SetItem(obj, j, PyString_FromString(msg->elements[i].name));
+ j++;
+ }
return obj;
}
}
@@ -419,10 +469,10 @@ typedef struct ldb_message {
return ret;
}
~ldb_msg() { talloc_free($self); }
- ldb_msg_element *find_element(const char *name);
+ ldb_message_element *find_element(const char *name);
#ifdef SWIGPYTHON
- void __setitem__(const char *attr_name, ldb_msg_element *val)
+ void __setitem__(const char *attr_name, ldb_message_element *val)
{
struct ldb_message_element *el;
@@ -458,6 +508,28 @@ typedef struct ldb_message {
}
#endif
void remove_attr(const char *name);
+%pythoncode {
+ def get(self, key, default=None):
+ if key == "dn":
+ return self.dn
+ return self.find_element(key)
+
+ def __getitem__(self, key):
+ ret = self.get(key, None)
+ if ret is None:
+ raise KeyError("No such element")
+ return ret
+
+ def iteritems(self):
+ for k in self.keys():
+ yield k, self[k]
+
+ def items(self):
+ return list(self.iteritems())
+
+ def __repr__(self):
+ return "Message(%s)" % repr(dict(self.iteritems()))
+}
}
} ldb_msg;
@@ -554,6 +626,7 @@ PyObject *PyExc_LdbError;
}
%rename(Ldb) ldb_context;
+%feature("docstring") ldb_context "Connection to a LDB database.";
%typemap(in,noblock=1) struct ldb_dn * {
if (ldb_dn_from_pyobject(NULL, $input, arg1, &$1) != 0) {
@@ -567,7 +640,7 @@ PyObject *PyExc_LdbError;
%typemap(in,numinputs=1) ldb_msg *add_msg {
Py_ssize_t dict_pos, msg_pos;
- ldb_msg_element *msgel;
+ ldb_message_element *msgel;
PyObject *key, *value;
if (PyDict_Check($input)) {
@@ -614,6 +687,8 @@ typedef struct ldb_context {
%extend {
ldb(void) { return ldb_init(NULL); }
+ %feature("docstring") connect "S.connect(url,flags=0,options=None) -> None\n" \
+ "Connect to a LDB URL.";
ldb_error connect(const char *url, unsigned int flags = 0,
const char *options[] = NULL);
@@ -661,11 +736,19 @@ typedef struct ldb_context {
return ret;
}
+ %feature("docstring") delete "S.delete(dn) -> None\n" \
+ "Remove an entry.";
ldb_error delete(ldb_dn *dn);
+ %feature("docstring") rename "S.rename(old_dn, new_dn) -> None\n" \
+ "Rename an entry.";
ldb_error rename(ldb_dn *olddn, ldb_dn *newdn);
struct ldb_control **parse_control_strings(TALLOC_CTX *mem_ctx,
const char * const*control_strings);
+ %feature("docstring") add "S.add(message) -> None\n" \
+ "Add an entry.";
ldb_error add(ldb_msg *add_msg);
+ %feature("docstring") modify "S.modify(message) -> None\n" \
+ "Modify an entry.";
ldb_error modify(ldb_msg *message);
ldb_dn *get_config_basedn();
ldb_dn *get_root_basedn();
@@ -701,20 +784,39 @@ typedef struct ldb_context {
}
const char *errstring();
+ %feature("docstring") set_create_perms "S.set_create_perms(mode) -> None\n" \
+ "Set mode to use when creating new LDB files.";
void set_create_perms(unsigned int perms);
+ %feature("docstring") set_modules_dir "S.set_modules_dir(path) -> None\n" \
+ "Set path LDB should search for modules";
void set_modules_dir(const char *path);
+ %feature("docstring") set_debug "S.set_debug(callback) -> None\n" \
+ "Set callback for LDB debug messages.\n" \
+ "The callback should accept a debug level and debug text.";
ldb_error set_debug(void (*debug)(void *context, enum ldb_debug_level level,
const char *fmt, va_list ap),
void *context);
+ %feature("docstring") set_opaque "S.set_opaque(name, value) -> None\n" \
+ "Set an opaque value on this LDB connection. \n"
+ ":note: Passing incorrect values may cause crashes.";
ldb_error set_opaque(const char *name, void *value);
+ %feature("docstring") get_opaque "S.get_opaque(name) -> value\n" \
+ "Get an opaque value set on this LDB connection. \n"
+ ":note: The returned value may not be useful in Python.";
void *get_opaque(const char *name);
+ %feature("docstring") transaction_start "S.transaction_start() -> None\n" \
+ "Start a new transaction.";
ldb_error transaction_start();
+ %feature("docstring") transaction_commit "S.transaction_commit() -> None\n" \
+ "Commit currently active transaction.";
ldb_error transaction_commit();
+ %feature("docstring") transaction_cancel "S.transaction_cancel() -> None\n" \
+ "Cancel currently active transaction.";
ldb_error transaction_cancel();
void schema_attribute_remove(const char *name);
ldb_error schema_attribute_add(const char *attribute, unsigned flags, const char *syntax);
- ldb_error setup_wellknown_attributes(void);
-
+ ldb_error setup_wellknown_attributes(void);
+
#ifdef SWIGPYTHON
%typemap(in,numinputs=0,noblock=1) struct ldb_result **result_as_bool (struct ldb_result *tmp) { $1 = &tmp; }
%typemap(argout,noblock=1) struct ldb_result **result_as_bool { $result = ((*$1)->count > 0)?Py_True:Py_False; }
@@ -725,6 +827,9 @@ typedef struct ldb_context {
result_as_bool);
}
+ %feature("docstring") parse_ldif "S.parse_ldif(ldif) -> iter(messages)\n" \
+ "Parse a string formatted using LDIF.";
+
PyObject *parse_ldif(const char *s)
{
PyObject *list = PyList_New(0);
@@ -735,16 +840,37 @@ typedef struct ldb_context {
return PyObject_GetIter(list);
}
+ char *__repr__(void)
+ {
+ char *ret;
+ asprintf(&ret, "<ldb connection at 0x%x>", ret);
+ return ret;
+ }
#endif
}
%pythoncode {
def __init__(self, url=None, flags=0, options=None):
+ """Create a new LDB object.
+
+ Will also connect to the specified URL if one was given.
+ """
_ldb.Ldb_swiginit(self,_ldb.new_Ldb())
if url is not None:
self.connect(url, flags, options)
def search(self, base=None, scope=SCOPE_DEFAULT, expression=None,
attrs=None, controls=None):
+ """Search in a database.
+
+ :param base: Optional base DN to search
+ :param scope: Search scope (SCOPE_BASE, SCOPE_ONELEVEL or SCOPE_SUBTREE)
+ :param expression: Optional search expression
+ :param attrs: Attributes to return (defaults to all)
+ :param controls: Optional list of controls
+ :return: Iterator over Message objects
+ """
+ if not (attrs is None or isinstance(attrs, list)):
+ raise TypeError("attributes not a list")
parsed_controls = None
if controls is not None:
parsed_controls = self.parse_control_strings(controls)
@@ -762,10 +888,15 @@ typedef struct ldb_context {
%nodefault Dn;
%rename(valid_attr_name) ldb_valid_attr_name;
+%feature("docstring") ldb_valid_attr_name "S.valid_attr_name(name) -> bool\n"
+ "Check whether the supplied name is a valid attribute name.";
int ldb_valid_attr_name(const char *s);
typedef unsigned long time_t;
+%feature("docstring") timestring "S.timestring(int) -> string\n"
+ "Generate a LDAP time string from a UNIX timestamp";
+
%inline %{
static char *timestring(time_t t)
{
@@ -777,6 +908,8 @@ static char *timestring(time_t t)
%}
%rename(string_to_time) ldb_string_to_time;
+%feature("docstring") ldb_string_to_time "S.string_to_time(string) -> int\n"
+ "Parse a LDAP time string into a UNIX timestamp.";
time_t ldb_string_to_time(const char *s);
%typemap(in,noblock=1) const struct ldb_module_ops * {
@@ -785,5 +918,11 @@ time_t ldb_string_to_time(const char *s);
$1->name = (char *)PyObject_GetAttrString($input, (char *)"name");
}
+%feature("docstring") ldb_register_module "S.register_module(module) -> None\n"
+ "Register a LDB module.";
%rename(register_module) ldb_register_module;
ldb_int_error ldb_register_module(const struct ldb_module_ops *);
+
+%pythoncode {
+__docformat__ = "restructuredText"
+}
diff --git a/source4/lib/ldb/ldb.mk b/source4/lib/ldb/ldb.mk
index cc920178bc..df11e9d2ab 100644
--- a/source4/lib/ldb/ldb.mk
+++ b/source4/lib/ldb/ldb.mk
@@ -71,7 +71,7 @@ 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)
+ $(SHLD) $(SHLD_FLAGS) -o _ldb.$(SHLIBEXT) ldb_wrap.o $(LIB_FLAGS) `$(PYTHON_CONFIG) --ldflags`
install-python:: build-python
mkdir -p $(DESTDIR)`$(PYTHON) -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(0, prefix='$(prefix)')"` \
diff --git a/source4/lib/ldb/ldb.py b/source4/lib/ldb/ldb.py
index 0bcfd36779..ae2c187367 100644
--- a/source4/lib/ldb/ldb.py
+++ b/source4/lib/ldb/ldb.py
@@ -1,8 +1,12 @@
# This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.33
+# Version 1.3.35
#
# Don't modify this file, modify the SWIG interface instead.
+"""
+An interface to LDB, a LDAP-like API that can either to talk an embedded database (TDB-based) or a standards-compliant LDAP server.
+"""
+
import _ldb
import new
new_instancemethod = new.instancemethod
@@ -67,11 +71,71 @@ CHANGETYPE_DELETE = _ldb.CHANGETYPE_DELETE
CHANGETYPE_MODIFY = _ldb.CHANGETYPE_MODIFY
ldb_val_to_py_object = _ldb.ldb_val_to_py_object
class Dn(object):
+ """A LDB distinguished name."""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
- __repr__ = _swig_repr
def __init__(self, *args, **kwargs):
+ """
+ S.__init__(ldb, string)
+ Create a new DN.
+ """
_ldb.Dn_swiginit(self,_ldb.new_Dn(*args, **kwargs))
__swig_destroy__ = _ldb.delete_Dn
+ def validate(*args, **kwargs):
+ """
+ S.validate() -> bool
+ Validate DN is correct.
+ """
+ return _ldb.Dn_validate(*args, **kwargs)
+
+ def parent(*args, **kwargs):
+ """
+ S.parent() -> dn
+ Get the parent for this DN.
+ """
+ return _ldb.Dn_parent(*args, **kwargs)
+
+ def is_special(*args, **kwargs):
+ """
+ S.is_special() -> bool
+ Check whether this is a special LDB DN.
+ """
+ return _ldb.Dn_is_special(*args, **kwargs)
+
+ def is_null(*args, **kwargs):
+ """
+ S.is_null() -> bool
+ Check whether this is a null DN.
+ """
+ return _ldb.Dn_is_null(*args, **kwargs)
+
+ def add_child(*args, **kwargs):
+ """
+ S.add_child(dn) -> None
+ Add a child DN to this DN.
+ """
+ return _ldb.Dn_add_child(*args, **kwargs)
+
+ def add_base(*args, **kwargs):
+ """
+ S.add_base(dn) -> None
+ Add a base DN to this DN.
+ """
+ return _ldb.Dn_add_base(*args, **kwargs)
+
+ def canonical_str(*args, **kwargs):
+ """
+ S.canonical_str() -> string
+ Canonical version of this DN (like a posix path).
+ """
+ return _ldb.Dn_canonical_str(*args, **kwargs)
+
+ def canonical_ex_str(*args, **kwargs):
+ """
+ S.canonical_ex_str() -> string
+ Canonical version of this DN (like a posix path, with terminating newline).
+ """
+ return _ldb.Dn_canonical_ex_str(*args, **kwargs)
+
def __eq__(self, other):
if isinstance(other, self.__class__):
return self.__cmp__(other) == 0
@@ -93,21 +157,28 @@ Dn.add_child = new_instancemethod(_ldb.Dn_add_child,None,Dn)
Dn.add_base = new_instancemethod(_ldb.Dn_add_base,None,Dn)
Dn.canonical_str = new_instancemethod(_ldb.Dn_canonical_str,None,Dn)
Dn.canonical_ex_str = new_instancemethod(_ldb.Dn_canonical_ex_str,None,Dn)
+Dn.__repr__ = new_instancemethod(_ldb.Dn___repr__,None,Dn)
Dn.__add__ = new_instancemethod(_ldb.Dn___add__,None,Dn)
Dn_swigregister = _ldb.Dn_swigregister
Dn_swigregister(Dn)
-class ldb_msg_element(object):
+class MessageElement(object):
+ """Message element."""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
- def __init__(self): raise AttributeError, "No constructor defined"
__repr__ = _swig_repr
- __swig_destroy__ = _ldb.delete_ldb_msg_element
+ def __init__(self, *args, **kwargs):
+ """Message element."""
+ _ldb.MessageElement_swiginit(self,_ldb.new_MessageElement(*args, **kwargs))
+ __swig_destroy__ = _ldb.delete_MessageElement
def __getitem__(self, i):
ret = self.get(i)
if ret is None:
raise KeyError("no such value")
return ret
+ def __repr__(self):
+ return "MessageElement([%s])" % (",".join(repr(x) for x in self.__set__()))
+
def __eq__(self, other):
if (len(self) == 1 and self.get(0) == other):
return True
@@ -119,27 +190,45 @@ class ldb_msg_element(object):
return False
return True
-ldb_msg_element.__iter__ = new_instancemethod(_ldb.ldb_msg_element___iter__,None,ldb_msg_element)
-ldb_msg_element.__set__ = new_instancemethod(_ldb.ldb_msg_element___set__,None,ldb_msg_element)
-ldb_msg_element.__len__ = new_instancemethod(_ldb.ldb_msg_element___len__,None,ldb_msg_element)
-ldb_msg_element.get = new_instancemethod(_ldb.ldb_msg_element_get,None,ldb_msg_element)
-ldb_msg_element.__cmp__ = new_instancemethod(_ldb.ldb_msg_element___cmp__,None,ldb_msg_element)
-ldb_msg_element_swigregister = _ldb.ldb_msg_element_swigregister
-ldb_msg_element_swigregister(ldb_msg_element)
-
-def MessageElement(*args, **kwargs):
- val = _ldb.new_MessageElement(*args, **kwargs)
- return val
+MessageElement.__cmp__ = new_instancemethod(_ldb.MessageElement___cmp__,None,MessageElement)
+MessageElement.__iter__ = new_instancemethod(_ldb.MessageElement___iter__,None,MessageElement)
+MessageElement.__set__ = new_instancemethod(_ldb.MessageElement___set__,None,MessageElement)
+MessageElement.__len__ = new_instancemethod(_ldb.MessageElement___len__,None,MessageElement)
+MessageElement.get = new_instancemethod(_ldb.MessageElement_get,None,MessageElement)
+MessageElement_swigregister = _ldb.MessageElement_swigregister
+MessageElement_swigregister(MessageElement)
ldb_msg_list_elements = _ldb.ldb_msg_list_elements
class Message(object):
+ """Message."""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
dn = _swig_property(_ldb.Message_dn_get, _ldb.Message_dn_set)
def __init__(self, *args, **kwargs):
_ldb.Message_swiginit(self,_ldb.new_Message(*args, **kwargs))
__swig_destroy__ = _ldb.delete_Message
-Message.__getitem__ = new_instancemethod(_ldb.Message___getitem__,None,Message)
+ def get(self, key, default=None):
+ if key == "dn":
+ return self.dn
+ return self.find_element(key)
+
+ def __getitem__(self, key):
+ ret = self.get(key, None)
+ if ret is None:
+ raise KeyError("No such element")
+ return ret
+
+ def iteritems(self):
+ for k in self.keys():
+ yield k, self[k]
+
+ def items(self):
+ return list(self.iteritems())
+
+ def __repr__(self):
+ return "Message(%s)" % repr(dict(self.iteritems()))
+
+Message.find_element = new_instancemethod(_ldb.Message_find_element,None,Message)
Message.__setitem__ = new_instancemethod(_ldb.Message___setitem__,None,Message)
Message.__len__ = new_instancemethod(_ldb.Message___len__,None,Message)
Message.keys = new_instancemethod(_ldb.Message_keys,None,Message)
@@ -190,18 +279,134 @@ LDB_ERR_OBJECT_CLASS_MODS_PROHIBITED = _ldb.LDB_ERR_OBJECT_CLASS_MODS_PROHIBITED
LDB_ERR_AFFECTS_MULTIPLE_DSAS = _ldb.LDB_ERR_AFFECTS_MULTIPLE_DSAS
LDB_ERR_OTHER = _ldb.LDB_ERR_OTHER
class Ldb(object):
+ """Connection to a LDB database."""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
- __repr__ = _swig_repr
def __init__(self, *args, **kwargs):
_ldb.Ldb_swiginit(self,_ldb.new_Ldb(*args, **kwargs))
+ def connect(*args, **kwargs):
+ """
+ S.connect(url,flags=0,options=None) -> None
+ Connect to a LDB URL.
+ """
+ return _ldb.Ldb_connect(*args, **kwargs)
+
__swig_destroy__ = _ldb.delete_Ldb
+ def delete(*args, **kwargs):
+ """
+ S.delete(dn) -> None
+ Remove an entry.
+ """
+ return _ldb.Ldb_delete(*args, **kwargs)
+
+ def rename(*args, **kwargs):
+ """
+ S.rename(old_dn, new_dn) -> None
+ Rename an entry.
+ """
+ return _ldb.Ldb_rename(*args, **kwargs)
+
+ def add(*args, **kwargs):
+ """
+ S.add(message) -> None
+ Add an entry.
+ """
+ return _ldb.Ldb_add(*args, **kwargs)
+
+ def modify(*args, **kwargs):
+ """
+ S.modify(message) -> None
+ Modify an entry.
+ """
+ return _ldb.Ldb_modify(*args, **kwargs)
+
+ def set_create_perms(*args, **kwargs):
+ """
+ S.set_create_perms(mode) -> None
+ Set mode to use when creating new LDB files.
+ """
+ return _ldb.Ldb_set_create_perms(*args, **kwargs)
+
+ def set_modules_dir(*args, **kwargs):
+ """
+ S.set_modules_dir(path) -> None
+ Set path LDB should search for modules
+ """
+ return _ldb.Ldb_set_modules_dir(*args, **kwargs)
+
+ def set_debug(*args, **kwargs):
+ """
+ S.set_debug(callback) -> None
+ Set callback for LDB debug messages.
+ The callback should accept a debug level and debug text.
+ """
+ return _ldb.Ldb_set_debug(*args, **kwargs)
+
+ def set_opaque(*args, **kwargs):
+ """
+ S.set_opaque(name, value) -> None
+ Set an opaque value on this LDB connection.
+ :note: Passing incorrect values may cause crashes.
+ """
+ return _ldb.Ldb_set_opaque(*args, **kwargs)
+
+ def get_opaque(*args, **kwargs):
+ """
+ S.get_opaque(name) -> value
+ Get an opaque value set on this LDB connection.
+ :note: The returned value may not be useful in Python.
+ """
+ return _ldb.Ldb_get_opaque(*args, **kwargs)
+
+ def transaction_start(*args, **kwargs):
+ """
+ S.transaction_start() -> None
+ Start a new transaction.
+ """
+ return _ldb.Ldb_transaction_start(*args, **kwargs)
+
+ def transaction_commit(*args, **kwargs):
+ """
+ S.transaction_commit() -> None
+ Commit currently active transaction.
+ """
+ return _ldb.Ldb_transaction_commit(*args, **kwargs)
+
+ def transaction_cancel(*args, **kwargs):
+ """
+ S.transaction_cancel() -> None
+ Cancel currently active transaction.
+ """
+ return _ldb.Ldb_transaction_cancel(*args, **kwargs)
+
+ def parse_ldif(*args, **kwargs):
+ """
+ S.parse_ldif(ldif) -> iter(messages)
+ Parse a string formatted using LDIF.
+ """
+ return _ldb.Ldb_parse_ldif(*args, **kwargs)
+
def __init__(self, url=None, flags=0, options=None):
+ """Create a new LDB object.
+
+ Will also connect to the specified URL if one was given.
+ """
_ldb.Ldb_swiginit(self,_ldb.new_Ldb())
if url is not None:
self.connect(url, flags, options)
def search(self, base=None, scope=SCOPE_DEFAULT, expression=None,
attrs=None, controls=None):
+ """Search in a database.
+
+ :param base: Optional base DN to search
+ :param scope: Search scope (SCOPE_BASE, SCOPE_ONELEVEL or SCOPE_SUBTREE)
+ :param expression: Optional search expression
+ :param attrs: Attributes to return (defaults to all)
+ :param controls: Optional list of controls
+ :return: Iterator over Message objects
+ """
+ if not (attrs is None or isinstance(attrs, list)):
+ raise TypeError("attributes not a list")
parsed_controls = None
if controls is not None:
parsed_controls = self.parse_control_strings(controls)
@@ -234,12 +439,39 @@ Ldb.schema_attribute_add = new_instancemethod(_ldb.Ldb_schema_attribute_add,None
Ldb.setup_wellknown_attributes = new_instancemethod(_ldb.Ldb_setup_wellknown_attributes,None,Ldb)
Ldb.__contains__ = new_instancemethod(_ldb.Ldb___contains__,None,Ldb)
Ldb.parse_ldif = new_instancemethod(_ldb.Ldb_parse_ldif,None,Ldb)
+Ldb.__repr__ = new_instancemethod(_ldb.Ldb___repr__,None,Ldb)
Ldb_swigregister = _ldb.Ldb_swigregister
Ldb_swigregister(Ldb)
-valid_attr_name = _ldb.valid_attr_name
-timestring = _ldb.timestring
-string_to_time = _ldb.string_to_time
-register_module = _ldb.register_module
+
+def valid_attr_name(*args, **kwargs):
+ """
+ S.valid_attr_name(name) -> bool
+ Check whether the supplied name is a valid attribute name.
+ """
+ return _ldb.valid_attr_name(*args, **kwargs)
+
+def timestring(*args, **kwargs):
+ """
+ S.timestring(int) -> string
+ Generate a LDAP time string from a UNIX timestamp
+ """
+ return _ldb.timestring(*args, **kwargs)
+
+def string_to_time(*args, **kwargs):
+ """
+ S.string_to_time(string) -> int
+ Parse a LDAP time string into a UNIX timestamp.
+ """
+ return _ldb.string_to_time(*args, **kwargs)
+
+def register_module(*args, **kwargs):
+ """
+ S.register_module(module) -> None
+ Register a LDB module.
+ """
+ return _ldb.register_module(*args, **kwargs)
+__docformat__ = "restructuredText"
+
diff --git a/source4/lib/ldb/ldb_ildap/config.mk b/source4/lib/ldb/ldb_ildap/config.mk
index 3062dc886f..1b534645b6 100644
--- a/source4/lib/ldb/ldb_ildap/config.mk
+++ b/source4/lib/ldb/ldb_ildap/config.mk
@@ -6,9 +6,8 @@ CFLAGS = -Ilib/ldb/include
OUTPUT_TYPE = SHARED_LIBRARY
PRIVATE_DEPENDENCIES = LIBTALLOC LIBCLI_LDAP CREDENTIALS
ALIASES = ldapi ldaps ldap
-OBJ_FILES = \
- ldb_ildap.o
# End MODULE ldb_ildap
################################################
+ldb_ildap_OBJ_FILES = lib/ldb/ldb_ildap/ldb_ildap.o
diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
index 79958a86eb..6b50b2f5eb 100644
--- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c
+++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
@@ -737,6 +737,7 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
struct ildb_private *ildb;
NTSTATUS status;
struct cli_credentials *creds;
+ struct event_context *event_ctx;
module = talloc(ldb, struct ldb_module);
if (!module) {
@@ -756,8 +757,19 @@ static int ildb_connect(struct ldb_context *ldb, const char *url,
}
module->private_data = ildb;
ildb->module = module;
- ildb->ldap = ldap4_new_connection(ildb, ldb_get_opaque(ldb, "loadparm"),
- ldb_get_opaque(ldb, "EventContext"));
+
+ event_ctx = ldb_get_opaque(ldb, "EventContext");
+
+ /* FIXME: We must make the event context an explicit parameter, but we
+ * need to build the events library separately first. Hack a new event
+ * context so that CMD line utilities work until we have libevents for
+ * standalone builds ready */
+ if (event_ctx == NULL) {
+ event_ctx = event_context_init(NULL);
+ }
+
+ ildb->ldap = ldap4_new_connection(ildb, ldb_get_opaque(ldb, "loadparm"),
+ event_ctx);
if (!ildb->ldap) {
ldb_oom(ldb);
goto failed;
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c
index d8776f48e2..1b6d9feed6 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_index.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_index.c
@@ -545,7 +545,7 @@ static int ltdb_index_dn_one(struct ldb_module *module,
/* the attribute is indexed. Pull the list of DNs that match the
search criterion */
- val.data = (uint8_t *)((intptr_t)ldb_dn_get_casefold(parent_dn));
+ val.data = (uint8_t *)((uintptr_t)ldb_dn_get_casefold(parent_dn));
val.length = strlen((char *)val.data);
key = ltdb_index_key(ldb, LTDB_IDXONE, &val);
if (!key) {
@@ -1140,7 +1140,7 @@ int ltdb_index_one(struct ldb_module *module, const struct ldb_message *msg, int
return LDB_ERR_OPERATIONS_ERROR;
}
- val.data = (uint8_t *)((intptr_t)ldb_dn_get_casefold(pdn));
+ val.data = (uint8_t *)((uintptr_t)ldb_dn_get_casefold(pdn));
if (val.data == NULL) {
talloc_free(pdn);
return LDB_ERR_OPERATIONS_ERROR;
diff --git a/source4/lib/ldb/ldb_wrap.c b/source4/lib/ldb/ldb_wrap.c
index 082c6d9cad..744033cbf6 100644
--- a/source4/lib/ldb/ldb_wrap.c
+++ b/source4/lib/ldb/ldb_wrap.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.33
+ * Version 1.3.35
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
@@ -126,7 +126,7 @@
/* This should only be incremented when either the layout of swig_type_info changes,
or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "3"
+#define SWIG_RUNTIME_VERSION "4"
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
#ifdef SWIG_TYPE_TABLE
@@ -161,6 +161,7 @@
/* Flags for pointer conversions */
#define SWIG_POINTER_DISOWN 0x1
+#define SWIG_CAST_NEW_MEMORY 0x2
/* Flags for new pointer objects */
#define SWIG_POINTER_OWN 0x1
@@ -301,10 +302,10 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) {
extern "C" {
#endif
-typedef void *(*swig_converter_func)(void *);
+typedef void *(*swig_converter_func)(void *, int *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);
-/* Structure to store inforomation on one type */
+/* Structure to store information on one type */
typedef struct swig_type_info {
const char *name; /* mangled name of this type */
const char *str; /* human readable name of this type */
@@ -431,8 +432,8 @@ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
Cast a pointer up an inheritance hierarchy
*/
SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
- return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
+SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
}
/*
@@ -856,7 +857,7 @@ SWIG_Python_AddErrorMsg(const char* mesg)
Py_DECREF(old_str);
Py_DECREF(value);
} else {
- PyErr_Format(PyExc_RuntimeError, mesg);
+ PyErr_SetString(PyExc_RuntimeError, mesg);
}
}
@@ -1416,7 +1417,7 @@ PySwigObject_dealloc(PyObject *v)
{
PySwigObject *sobj = (PySwigObject *) v;
PyObject *next = sobj->next;
- if (sobj->own) {
+ if (sobj->own == SWIG_POINTER_OWN) {
swig_type_info *ty = sobj->ty;
PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
PyObject *destroy = data ? data->destroy : 0;
@@ -1434,12 +1435,13 @@ PySwigObject_dealloc(PyObject *v)
res = ((*meth)(mself, v));
}
Py_XDECREF(res);
- } else {
- const char *name = SWIG_TypePrettyName(ty);
+ }
#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
- printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
-#endif
+ else {
+ const char *name = SWIG_TypePrettyName(ty);
+ printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
}
+#endif
}
Py_XDECREF(next);
PyObject_DEL(v);
@@ -1944,7 +1946,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
SWIGRUNTIME int
SWIG_Python_AcquirePtr(PyObject *obj, int own) {
- if (own) {
+ if (own == SWIG_POINTER_OWN) {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
if (sobj) {
int oldown = sobj->own;
@@ -1965,6 +1967,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
return SWIG_OK;
} else {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+ if (own)
+ *own = 0;
while (sobj) {
void *vptr = sobj->ptr;
if (ty) {
@@ -1978,7 +1982,15 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
if (!tc) {
sobj = (PySwigObject *)sobj->next;
} else {
- if (ptr) *ptr = SWIG_TypeCast(tc,vptr);
+ if (ptr) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
+ assert(own);
+ if (own)
+ *own = *own | SWIG_CAST_NEW_MEMORY;
+ }
+ }
break;
}
}
@@ -1988,7 +2000,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
}
}
if (sobj) {
- if (own) *own = sobj->own;
+ if (own)
+ *own = *own | sobj->own;
if (flags & SWIG_POINTER_DISOWN) {
sobj->own = 0;
}
@@ -2053,8 +2066,13 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
}
if (ty) {
swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
- if (!tc) return SWIG_ERROR;
- *ptr = SWIG_TypeCast(tc,vptr);
+ if (tc) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ assert(!newmemory); /* newmemory handling not yet implemented */
+ } else {
+ return SWIG_ERROR;
+ }
} else {
*ptr = vptr;
}
@@ -2471,7 +2489,7 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
#define SWIGTYPE_p_ldb_module_ops swig_types[9]
#define SWIGTYPE_p_ldb_result swig_types[10]
#define SWIGTYPE_p_ldb_val swig_types[11]
-#define SWIGTYPE_p_long swig_types[12]
+#define SWIGTYPE_p_long_long swig_types[12]
#define SWIGTYPE_p_p_char swig_types[13]
#define SWIGTYPE_p_p_ldb_control swig_types[14]
#define SWIGTYPE_p_p_ldb_result swig_types[15]
@@ -2480,10 +2498,11 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
#define SWIGTYPE_p_unsigned_char swig_types[18]
#define SWIGTYPE_p_unsigned_int swig_types[19]
#define SWIGTYPE_p_unsigned_long swig_types[20]
-#define SWIGTYPE_p_unsigned_short swig_types[21]
-#define SWIGTYPE_p_void swig_types[22]
-static swig_type_info *swig_types[24];
-static swig_module_info swig_module = {swig_types, 23, 0, 0, 0, 0};
+#define SWIGTYPE_p_unsigned_long_long swig_types[21]
+#define SWIGTYPE_p_unsigned_short swig_types[22]
+#define SWIGTYPE_p_void swig_types[23]
+static swig_type_info *swig_types[25];
+static swig_module_info swig_module = {swig_types, 24, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
@@ -2515,7 +2534,7 @@ static swig_module_info swig_module = {swig_types, 23, 0, 0, 0, 0};
#define SWIG_name "_ldb"
-#define SWIGVERSION 0x010333
+#define SWIGVERSION 0x010335
#define SWIG_VERSION SWIGVERSION
@@ -2535,7 +2554,7 @@ typedef struct ldb_message ldb_msg;
typedef struct ldb_context ldb;
typedef struct ldb_dn ldb_dn;
typedef struct ldb_ldif ldb_ldif;
-typedef struct ldb_message_element ldb_msg_element;
+typedef struct ldb_message_element ldb_message_element;
typedef int ldb_error;
typedef int ldb_int_error;
@@ -2700,12 +2719,26 @@ SWIGINTERN char const *ldb_dn_canonical_str(ldb_dn *self){
SWIGINTERN char const *ldb_dn_canonical_ex_str(ldb_dn *self){
return ldb_dn_canonical_ex_string(self, self);
}
+SWIGINTERN char *ldb_dn___repr__(ldb_dn *self){
+ char *dn = ldb_dn_get_linearized(self), *ret;
+ asprintf(&ret, "Dn('%s')", dn);
+ talloc_free(dn);
+ return ret;
+ }
SWIGINTERN ldb_dn *ldb_dn___add__(ldb_dn *self,ldb_dn *other){
ldb_dn *ret = ldb_dn_copy(NULL, self);
ldb_dn_add_child(ret, other);
return ret;
}
+struct ldb_context *ldb_context_from_py_object(PyObject *py_obj)
+{
+ struct ldb_context *ldb_ctx;
+ if (SWIG_ConvertPtr(py_obj, (void *)&ldb_ctx, SWIGTYPE_p_ldb_context, 0 | 0 ) < 0)
+ return NULL;
+ return ldb_ctx;
+}
+
int ldb_dn_from_pyobject(TALLOC_CTX *mem_ctx, PyObject *object,
struct ldb_context *ldb_ctx, ldb_dn **dn)
{
@@ -2728,7 +2761,7 @@ int ldb_dn_from_pyobject(TALLOC_CTX *mem_ctx, PyObject *object,
return ret;
}
-ldb_msg_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
+ldb_message_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
PyObject *set_obj, int flags,
const char *attr_name)
{
@@ -2759,7 +2792,7 @@ ldb_msg_element *ldb_msg_element_from_pyobject(TALLOC_CTX *mem_ctx,
}
PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx,
- ldb_msg_element *me)
+ ldb_message_element *me)
{
int i;
PyObject *result;
@@ -2776,10 +2809,13 @@ PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx,
}
-SWIGINTERN PyObject *ldb_msg_element___iter__(ldb_msg_element *self){
+SWIGINTERN int ldb_message_element___cmp__(ldb_message_element *self,ldb_message_element *other){
+ return ldb_msg_element_compare(self, other);
+ }
+SWIGINTERN PyObject *ldb_message_element___iter__(ldb_message_element *self){
return PyObject_GetIter(ldb_msg_element_to_set(NULL, self));
}
-SWIGINTERN PyObject *ldb_msg_element___set__(ldb_msg_element *self){
+SWIGINTERN PyObject *ldb_message_element___set__(ldb_message_element *self){
return ldb_msg_element_to_set(NULL, self);
}
@@ -2927,26 +2963,32 @@ SWIG_AsVal_int (PyObject * obj, int *val)
return res;
}
-SWIGINTERN ldb_msg_element *new_ldb_msg_element(PyObject *set_obj,int flags,char const *name){
+SWIGINTERN ldb_message_element *new_ldb_message_element(PyObject *set_obj,int flags,char const *name){
return ldb_msg_element_from_pyobject(NULL, set_obj, flags, name);
}
-SWIGINTERN int ldb_msg_element___len__(ldb_msg_element *self){
+SWIGINTERN int ldb_message_element___len__(ldb_message_element *self){
return self->num_values;
}
-SWIGINTERN PyObject *ldb_msg_element_get(ldb_msg_element *self,int i){
+SWIGINTERN PyObject *ldb_message_element_get(ldb_message_element *self,int i){
if (i < 0 || i >= self->num_values)
return Py_None;
return ldb_val_to_py_object(NULL, self, &self->values[i]);
}
-SWIGINTERN void delete_ldb_msg_element(ldb_msg_element *self){ talloc_free(self); }
+SWIGINTERN void delete_ldb_message_element(ldb_message_element *self){ talloc_free(self); }
PyObject *ldb_msg_list_elements(ldb_msg *msg)
{
- int i;
- PyObject *obj = PyList_New(msg->num_elements);
- for (i = 0; i < msg->num_elements; i++)
- PyList_SetItem(obj, i, PyString_FromString(msg->elements[i].name));
+ int i, j = 0;
+ PyObject *obj = PyList_New(msg->num_elements+(msg->dn != NULL?1:0));
+ if (msg->dn != NULL) {
+ PyList_SetItem(obj, j, PyString_FromString("dn"));
+ j++;
+ }
+ for (i = 0; i < msg->num_elements; i++) {
+ PyList_SetItem(obj, j, PyString_FromString(msg->elements[i].name));
+ j++;
+ }
return obj;
}
@@ -2956,7 +2998,7 @@ SWIGINTERN ldb_msg *new_ldb_msg(ldb_dn *dn){
return ret;
}
SWIGINTERN void delete_ldb_msg(ldb_msg *self){ talloc_free(self); }
-SWIGINTERN void ldb_msg___setitem____SWIG_0(ldb_msg *self,char const *attr_name,ldb_msg_element *val){
+SWIGINTERN void ldb_msg___setitem____SWIG_0(ldb_msg *self,char const *attr_name,ldb_message_element *val){
struct ldb_message_element *el;
ldb_msg_remove_attr(self, attr_name);
@@ -3161,6 +3203,11 @@ SWIGINTERN PyObject *ldb_parse_ldif(ldb *self,char const *s){
}
return PyObject_GetIter(list);
}
+SWIGINTERN char *ldb___repr__(ldb *self){
+ char *ret;
+ asprintf(&ret, "<ldb connection at 0x%x>", ret);
+ return ret;
+ }
static char *timestring(time_t t)
{
@@ -3651,6 +3698,29 @@ fail:
}
+SWIGINTERN PyObject *_wrap_Dn___repr__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ ldb_dn *arg1 = (ldb_dn *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_dn, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Dn___repr__" "', argument " "1"" of type '" "ldb_dn *""'");
+ }
+ arg1 = (ldb_dn *)(argp1);
+ result = (char *)ldb_dn___repr__(arg1);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_Dn___add__(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
ldb_dn *arg1 = (ldb_dn *) 0 ;
@@ -3696,9 +3766,43 @@ SWIGINTERN PyObject *Dn_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args)
return SWIG_Python_InitShadowInstance(args);
}
-SWIGINTERN PyObject *_wrap_ldb_msg_element___iter__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_MessageElement___cmp__(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
- ldb_msg_element *arg1 = (ldb_msg_element *) 0 ;
+ ldb_message_element *arg1 = (ldb_message_element *) 0 ;
+ ldb_message_element *arg2 = (ldb_message_element *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "other", NULL
+ };
+
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:MessageElement___cmp__",kwnames,&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_message_element, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MessageElement___cmp__" "', argument " "1"" of type '" "ldb_message_element *""'");
+ }
+ arg1 = (ldb_message_element *)(argp1);
+ res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_message_element, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "MessageElement___cmp__" "', argument " "2"" of type '" "ldb_message_element *""'");
+ }
+ arg2 = (ldb_message_element *)(argp2);
+ result = (int)ldb_message_element___cmp__(arg1,arg2);
+ resultobj = SWIG_From_int((int)(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_MessageElement___iter__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ ldb_message_element *arg1 = (ldb_message_element *) 0 ;
PyObject *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
@@ -3708,10 +3812,10 @@ SWIGINTERN PyObject *_wrap_ldb_msg_element___iter__(PyObject *SWIGUNUSEDPARM(sel
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_message_element, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_msg_element___iter__" "', argument " "1"" of type '" "ldb_msg_element *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MessageElement___iter__" "', argument " "1"" of type '" "ldb_message_element *""'");
}
- arg1 = (ldb_msg_element *)(argp1);
- result = (PyObject *)ldb_msg_element___iter__(arg1);
+ arg1 = (ldb_message_element *)(argp1);
+ result = (PyObject *)ldb_message_element___iter__(arg1);
resultobj = result;
return resultobj;
fail:
@@ -3719,9 +3823,9 @@ fail:
}
-SWIGINTERN PyObject *_wrap_ldb_msg_element___set__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_MessageElement___set__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- ldb_msg_element *arg1 = (ldb_msg_element *) 0 ;
+ ldb_message_element *arg1 = (ldb_message_element *) 0 ;
PyObject *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
@@ -3731,10 +3835,10 @@ SWIGINTERN PyObject *_wrap_ldb_msg_element___set__(PyObject *SWIGUNUSEDPARM(self
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_message_element, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_msg_element___set__" "', argument " "1"" of type '" "ldb_msg_element *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MessageElement___set__" "', argument " "1"" of type '" "ldb_message_element *""'");
}
- arg1 = (ldb_msg_element *)(argp1);
- result = (PyObject *)ldb_msg_element___set__(arg1);
+ arg1 = (ldb_message_element *)(argp1);
+ result = (PyObject *)ldb_message_element___set__(arg1);
resultobj = result;
return resultobj;
fail:
@@ -3747,7 +3851,7 @@ SWIGINTERN PyObject *_wrap_new_MessageElement(PyObject *SWIGUNUSEDPARM(self), Py
PyObject *arg1 = (PyObject *) 0 ;
int arg2 = (int) 0 ;
char *arg3 = (char *) NULL ;
- ldb_msg_element *result = 0 ;
+ ldb_message_element *result = 0 ;
int val2 ;
int ecode2 = 0 ;
int res3 ;
@@ -3776,8 +3880,8 @@ SWIGINTERN PyObject *_wrap_new_MessageElement(PyObject *SWIGUNUSEDPARM(self), Py
}
arg3 = (char *)(buf3);
}
- result = (ldb_msg_element *)new_ldb_msg_element(arg1,arg2,(char const *)arg3);
- resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_message_element, SWIG_POINTER_OWN | 0 );
+ result = (ldb_message_element *)new_ldb_message_element(arg1,arg2,(char const *)arg3);
+ resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_ldb_message_element, SWIG_POINTER_NEW | 0 );
if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
return resultobj;
fail:
@@ -3786,9 +3890,9 @@ fail:
}
-SWIGINTERN PyObject *_wrap_ldb_msg_element___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_MessageElement___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- ldb_msg_element *arg1 = (ldb_msg_element *) 0 ;
+ ldb_message_element *arg1 = (ldb_message_element *) 0 ;
int result;
void *argp1 = 0 ;
int res1 = 0 ;
@@ -3798,10 +3902,10 @@ SWIGINTERN PyObject *_wrap_ldb_msg_element___len__(PyObject *SWIGUNUSEDPARM(self
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_message_element, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_msg_element___len__" "', argument " "1"" of type '" "ldb_msg_element *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MessageElement___len__" "', argument " "1"" of type '" "ldb_message_element *""'");
}
- arg1 = (ldb_msg_element *)(argp1);
- result = (int)ldb_msg_element___len__(arg1);
+ arg1 = (ldb_message_element *)(argp1);
+ result = (int)ldb_message_element___len__(arg1);
resultobj = SWIG_From_int((int)(result));
return resultobj;
fail:
@@ -3809,9 +3913,9 @@ fail:
}
-SWIGINTERN PyObject *_wrap_ldb_msg_element_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_MessageElement_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
- ldb_msg_element *arg1 = (ldb_msg_element *) 0 ;
+ ldb_message_element *arg1 = (ldb_message_element *) 0 ;
int arg2 ;
PyObject *result = 0 ;
void *argp1 = 0 ;
@@ -3824,18 +3928,18 @@ SWIGINTERN PyObject *_wrap_ldb_msg_element_get(PyObject *SWIGUNUSEDPARM(self), P
(char *) "self",(char *) "i", NULL
};
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_msg_element_get",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:MessageElement_get",kwnames,&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_message_element, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_msg_element_get" "', argument " "1"" of type '" "ldb_msg_element *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MessageElement_get" "', argument " "1"" of type '" "ldb_message_element *""'");
}
- arg1 = (ldb_msg_element *)(argp1);
+ arg1 = (ldb_message_element *)(argp1);
ecode2 = SWIG_AsVal_int(obj1, &val2);
if (!SWIG_IsOK(ecode2)) {
- SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ldb_msg_element_get" "', argument " "2"" of type '" "int""'");
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MessageElement_get" "', argument " "2"" of type '" "int""'");
}
arg2 = (int)(val2);
- result = (PyObject *)ldb_msg_element_get(arg1,arg2);
+ result = (PyObject *)ldb_message_element_get(arg1,arg2);
resultobj = result;
return resultobj;
fail:
@@ -3843,9 +3947,9 @@ fail:
}
-SWIGINTERN PyObject *_wrap_delete_ldb_msg_element(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_delete_MessageElement(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
- ldb_msg_element *arg1 = (ldb_msg_element *) 0 ;
+ ldb_message_element *arg1 = (ldb_message_element *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject *swig_obj[1] ;
@@ -3854,10 +3958,10 @@ SWIGINTERN PyObject *_wrap_delete_ldb_msg_element(PyObject *SWIGUNUSEDPARM(self)
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_message_element, SWIG_POINTER_DISOWN | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ldb_msg_element" "', argument " "1"" of type '" "ldb_msg_element *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_MessageElement" "', argument " "1"" of type '" "ldb_message_element *""'");
}
- arg1 = (ldb_msg_element *)(argp1);
- delete_ldb_msg_element(arg1);
+ arg1 = (ldb_message_element *)(argp1);
+ delete_ldb_message_element(arg1);
resultobj = SWIG_Py_Void();
return resultobj;
@@ -3866,47 +3970,17 @@ fail:
}
-SWIGINTERN PyObject *_wrap_ldb_msg_element___cmp__(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- ldb_msg_element *arg1 = (ldb_msg_element *) 0 ;
- ldb_msg_element *arg2 = (ldb_msg_element *) 0 ;
- int result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp2 = 0 ;
- int res2 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *)"arg2", NULL
- };
-
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:ldb_msg_element___cmp__",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_message_element, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ldb_msg_element___cmp__" "', argument " "1"" of type '" "ldb_msg_element *""'");
- }
- arg1 = (ldb_msg_element *)(argp1);
- res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_message_element, 0 | 0 );
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ldb_msg_element___cmp__" "', argument " "2"" of type '" "ldb_msg_element *""'");
- }
- arg2 = (ldb_msg_element *)(argp2);
- result = (int)ldb_msg_element_compare(arg1,arg2);
- resultobj = SWIG_From_int((int)(result));
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *ldb_msg_element_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *MessageElement_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
SWIG_TypeNewClientData(SWIGTYPE_p_ldb_message_element, SWIG_NewClientData(obj));
return SWIG_Py_Void();
}
+SWIGINTERN PyObject *MessageElement_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ return SWIG_Python_InitShadowInstance(args);
+}
+
SWIGINTERN PyObject *_wrap_ldb_msg_list_elements(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
ldb_msg *arg1 = (ldb_msg *) 0 ;
@@ -4047,11 +4121,11 @@ fail:
}
-SWIGINTERN PyObject *_wrap_Message___getitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Message_find_element(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
ldb_msg *arg1 = (ldb_msg *) 0 ;
char *arg2 = (char *) 0 ;
- ldb_msg_element *result = 0 ;
+ ldb_message_element *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
int res2 ;
@@ -4063,21 +4137,21 @@ SWIGINTERN PyObject *_wrap_Message___getitem__(PyObject *SWIGUNUSEDPARM(self), P
(char *) "self",(char *) "name", NULL
};
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Message___getitem__",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Message_find_element",kwnames,&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_message, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Message___getitem__" "', argument " "1"" of type '" "ldb_msg *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Message_find_element" "', argument " "1"" of type '" "ldb_msg *""'");
}
arg1 = (ldb_msg *)(argp1);
res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Message___getitem__" "', argument " "2"" of type '" "char const *""'");
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Message_find_element" "', argument " "2"" of type '" "char const *""'");
}
arg2 = (char *)(buf2);
if (arg1 == NULL)
SWIG_exception(SWIG_ValueError,
"Message can not be None");
- result = (ldb_msg_element *)ldb_msg_find_element(arg1,(char const *)arg2);
+ result = (ldb_message_element *)ldb_msg_find_element(arg1,(char const *)arg2);
{
if (result == NULL)
PyErr_SetString(PyExc_KeyError, "no such element");
@@ -4096,7 +4170,7 @@ SWIGINTERN PyObject *_wrap_Message___setitem____SWIG_0(PyObject *SWIGUNUSEDPARM(
PyObject *resultobj = 0;
ldb_msg *arg1 = (ldb_msg *) 0 ;
char *arg2 = (char *) 0 ;
- ldb_msg_element *arg3 = (ldb_msg_element *) 0 ;
+ ldb_message_element *arg3 = (ldb_message_element *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
int res2 ;
@@ -4118,9 +4192,9 @@ SWIGINTERN PyObject *_wrap_Message___setitem____SWIG_0(PyObject *SWIGUNUSEDPARM(
arg2 = (char *)(buf2);
res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_ldb_message_element, 0 | 0 );
if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Message___setitem__" "', argument " "3"" of type '" "ldb_msg_element *""'");
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Message___setitem__" "', argument " "3"" of type '" "ldb_message_element *""'");
}
- arg3 = (ldb_msg_element *)(argp3);
+ arg3 = (ldb_message_element *)(argp3);
if (arg1 == NULL)
SWIG_exception(SWIG_ValueError,
"Message can not be None");
@@ -4193,7 +4267,10 @@ check_1:
}
fail:
- SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'Message___setitem__'.\n Possible C/C++ prototypes are:\n"" __setitem__(ldb_msg *,char const *,ldb_msg_element *)\n"" __setitem__(ldb_msg *,char const *,PyObject *)\n");
+ SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'Message___setitem__'.\n"
+ " Possible C/C++ prototypes are:\n"
+ " __setitem__(ldb_msg *,char const *,ldb_message_element *)\n"
+ " __setitem__(ldb_msg *,char const *,PyObject *)\n");
return NULL;
}
@@ -4717,7 +4794,7 @@ SWIGINTERN PyObject *_wrap_Ldb_add(PyObject *SWIGUNUSEDPARM(self), PyObject *arg
arg1 = (ldb *)(argp1);
{
Py_ssize_t dict_pos, msg_pos;
- ldb_msg_element *msgel;
+ ldb_message_element *msgel;
PyObject *key, *value;
if (PyDict_Check(obj1)) {
@@ -5508,6 +5585,32 @@ fail:
}
+SWIGINTERN PyObject *_wrap_Ldb___repr__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ ldb *arg1 = (ldb *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject *swig_obj[1] ;
+
+ if (!args) SWIG_fail;
+ swig_obj[0] = args;
+ res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb___repr__" "', argument " "1"" of type '" "ldb *""'");
+ }
+ arg1 = (ldb *)(argp1);
+ if (arg1 == NULL)
+ SWIG_exception(SWIG_ValueError,
+ "ldb context must be non-NULL");
+ result = (char *)ldb___repr__(arg1);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *Ldb_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
@@ -5627,39 +5730,68 @@ fail:
static PyMethodDef SwigMethods[] = {
{ (char *)"ldb_val_to_py_object", (PyCFunction) _wrap_ldb_val_to_py_object, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"new_Dn", (PyCFunction) _wrap_new_Dn, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"new_Dn", (PyCFunction) _wrap_new_Dn, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.__init__(ldb, string)\n"
+ "Create a new DN.\n"
+ ""},
{ (char *)"delete_Dn", (PyCFunction)_wrap_delete_Dn, METH_O, NULL},
- { (char *)"Dn_validate", (PyCFunction)_wrap_Dn_validate, METH_O, NULL},
+ { (char *)"Dn_validate", (PyCFunction)_wrap_Dn_validate, METH_O, (char *)"\n"
+ "S.validate() -> bool\n"
+ "Validate DN is correct.\n"
+ ""},
{ (char *)"Dn_get_casefold", (PyCFunction)_wrap_Dn_get_casefold, METH_O, NULL},
{ (char *)"Dn___str__", (PyCFunction)_wrap_Dn___str__, METH_O, NULL},
- { (char *)"Dn_parent", (PyCFunction)_wrap_Dn_parent, METH_O, NULL},
+ { (char *)"Dn_parent", (PyCFunction)_wrap_Dn_parent, METH_O, (char *)"\n"
+ "S.parent() -> dn\n"
+ "Get the parent for this DN.\n"
+ ""},
{ (char *)"Dn___cmp__", (PyCFunction) _wrap_Dn___cmp__, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Dn_is_valid", (PyCFunction)_wrap_Dn_is_valid, METH_O, NULL},
- { (char *)"Dn_is_special", (PyCFunction)_wrap_Dn_is_special, METH_O, NULL},
- { (char *)"Dn_is_null", (PyCFunction)_wrap_Dn_is_null, METH_O, NULL},
+ { (char *)"Dn_is_special", (PyCFunction)_wrap_Dn_is_special, METH_O, (char *)"\n"
+ "S.is_special() -> bool\n"
+ "Check whether this is a special LDB DN.\n"
+ ""},
+ { (char *)"Dn_is_null", (PyCFunction)_wrap_Dn_is_null, METH_O, (char *)"\n"
+ "S.is_null() -> bool\n"
+ "Check whether this is a null DN.\n"
+ ""},
{ (char *)"Dn_check_special", (PyCFunction) _wrap_Dn_check_special, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Dn___len__", (PyCFunction)_wrap_Dn___len__, METH_O, NULL},
- { (char *)"Dn_add_child", (PyCFunction) _wrap_Dn_add_child, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Dn_add_base", (PyCFunction) _wrap_Dn_add_base, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Dn_canonical_str", (PyCFunction)_wrap_Dn_canonical_str, METH_O, NULL},
- { (char *)"Dn_canonical_ex_str", (PyCFunction)_wrap_Dn_canonical_ex_str, METH_O, NULL},
+ { (char *)"Dn_add_child", (PyCFunction) _wrap_Dn_add_child, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.add_child(dn) -> None\n"
+ "Add a child DN to this DN.\n"
+ ""},
+ { (char *)"Dn_add_base", (PyCFunction) _wrap_Dn_add_base, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.add_base(dn) -> None\n"
+ "Add a base DN to this DN.\n"
+ ""},
+ { (char *)"Dn_canonical_str", (PyCFunction)_wrap_Dn_canonical_str, METH_O, (char *)"\n"
+ "S.canonical_str() -> string\n"
+ "Canonical version of this DN (like a posix path).\n"
+ ""},
+ { (char *)"Dn_canonical_ex_str", (PyCFunction)_wrap_Dn_canonical_ex_str, METH_O, (char *)"\n"
+ "S.canonical_ex_str() -> string\n"
+ "Canonical version of this DN (like a posix path, with terminating newline).\n"
+ ""},
+ { (char *)"Dn___repr__", (PyCFunction)_wrap_Dn___repr__, METH_O, NULL},
{ (char *)"Dn___add__", (PyCFunction) _wrap_Dn___add__, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Dn_swigregister", Dn_swigregister, METH_VARARGS, NULL},
{ (char *)"Dn_swiginit", Dn_swiginit, METH_VARARGS, NULL},
- { (char *)"ldb_msg_element___iter__", (PyCFunction)_wrap_ldb_msg_element___iter__, METH_O, NULL},
- { (char *)"ldb_msg_element___set__", (PyCFunction)_wrap_ldb_msg_element___set__, METH_O, NULL},
- { (char *)"new_MessageElement", (PyCFunction) _wrap_new_MessageElement, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"ldb_msg_element___len__", (PyCFunction)_wrap_ldb_msg_element___len__, METH_O, NULL},
- { (char *)"ldb_msg_element_get", (PyCFunction) _wrap_ldb_msg_element_get, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"delete_ldb_msg_element", (PyCFunction)_wrap_delete_ldb_msg_element, METH_O, NULL},
- { (char *)"ldb_msg_element___cmp__", (PyCFunction) _wrap_ldb_msg_element___cmp__, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"ldb_msg_element_swigregister", ldb_msg_element_swigregister, METH_VARARGS, NULL},
+ { (char *)"MessageElement___cmp__", (PyCFunction) _wrap_MessageElement___cmp__, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"MessageElement___iter__", (PyCFunction)_wrap_MessageElement___iter__, METH_O, NULL},
+ { (char *)"MessageElement___set__", (PyCFunction)_wrap_MessageElement___set__, METH_O, NULL},
+ { (char *)"new_MessageElement", (PyCFunction) _wrap_new_MessageElement, METH_VARARGS | METH_KEYWORDS, (char *)"Message element."},
+ { (char *)"MessageElement___len__", (PyCFunction)_wrap_MessageElement___len__, METH_O, NULL},
+ { (char *)"MessageElement_get", (PyCFunction) _wrap_MessageElement_get, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"delete_MessageElement", (PyCFunction)_wrap_delete_MessageElement, METH_O, NULL},
+ { (char *)"MessageElement_swigregister", MessageElement_swigregister, METH_VARARGS, NULL},
+ { (char *)"MessageElement_swiginit", MessageElement_swiginit, METH_VARARGS, NULL},
{ (char *)"ldb_msg_list_elements", (PyCFunction) _wrap_ldb_msg_list_elements, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Message_dn_set", _wrap_Message_dn_set, METH_VARARGS, NULL},
{ (char *)"Message_dn_get", (PyCFunction)_wrap_Message_dn_get, METH_O, NULL},
{ (char *)"new_Message", (PyCFunction) _wrap_new_Message, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"delete_Message", (PyCFunction)_wrap_delete_Message, METH_O, NULL},
- { (char *)"Message___getitem__", (PyCFunction) _wrap_Message___getitem__, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Message_find_element", (PyCFunction) _wrap_Message_find_element, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Message___setitem__", _wrap_Message___setitem__, METH_VARARGS, NULL},
{ (char *)"Message___len__", (PyCFunction)_wrap_Message___len__, METH_O, NULL},
{ (char *)"Message_keys", (PyCFunction)_wrap_Message_keys, METH_O, NULL},
@@ -5669,39 +5801,97 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"Message_swiginit", Message_swiginit, METH_VARARGS, NULL},
{ (char *)"ldb_ldif_to_pyobject", (PyCFunction) _wrap_ldb_ldif_to_pyobject, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"new_Ldb", (PyCFunction)_wrap_new_Ldb, METH_NOARGS, NULL},
- { (char *)"Ldb_connect", (PyCFunction) _wrap_Ldb_connect, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Ldb_connect", (PyCFunction) _wrap_Ldb_connect, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.connect(url,flags=0,options=None) -> None\n"
+ "Connect to a LDB URL.\n"
+ ""},
{ (char *)"delete_Ldb", (PyCFunction)_wrap_delete_Ldb, METH_O, NULL},
{ (char *)"Ldb_search_ex", (PyCFunction) _wrap_Ldb_search_ex, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_delete", (PyCFunction) _wrap_Ldb_delete, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_rename", (PyCFunction) _wrap_Ldb_rename, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Ldb_delete", (PyCFunction) _wrap_Ldb_delete, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.delete(dn) -> None\n"
+ "Remove an entry.\n"
+ ""},
+ { (char *)"Ldb_rename", (PyCFunction) _wrap_Ldb_rename, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.rename(old_dn, new_dn) -> None\n"
+ "Rename an entry.\n"
+ ""},
{ (char *)"Ldb_parse_control_strings", (PyCFunction) _wrap_Ldb_parse_control_strings, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_add", (PyCFunction) _wrap_Ldb_add, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_modify", (PyCFunction) _wrap_Ldb_modify, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Ldb_add", (PyCFunction) _wrap_Ldb_add, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.add(message) -> None\n"
+ "Add an entry.\n"
+ ""},
+ { (char *)"Ldb_modify", (PyCFunction) _wrap_Ldb_modify, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.modify(message) -> None\n"
+ "Modify an entry.\n"
+ ""},
{ (char *)"Ldb_get_config_basedn", (PyCFunction)_wrap_Ldb_get_config_basedn, METH_O, NULL},
{ (char *)"Ldb_get_root_basedn", (PyCFunction)_wrap_Ldb_get_root_basedn, METH_O, NULL},
{ (char *)"Ldb_get_schema_basedn", (PyCFunction)_wrap_Ldb_get_schema_basedn, METH_O, NULL},
{ (char *)"Ldb_get_default_basedn", (PyCFunction)_wrap_Ldb_get_default_basedn, METH_O, NULL},
{ (char *)"Ldb_schema_format_value", (PyCFunction) _wrap_Ldb_schema_format_value, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Ldb_errstring", (PyCFunction)_wrap_Ldb_errstring, METH_O, NULL},
- { (char *)"Ldb_set_create_perms", (PyCFunction) _wrap_Ldb_set_create_perms, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_set_modules_dir", (PyCFunction) _wrap_Ldb_set_modules_dir, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_set_debug", (PyCFunction) _wrap_Ldb_set_debug, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_set_opaque", (PyCFunction) _wrap_Ldb_set_opaque, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_get_opaque", (PyCFunction) _wrap_Ldb_get_opaque, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_transaction_start", (PyCFunction)_wrap_Ldb_transaction_start, METH_O, NULL},
- { (char *)"Ldb_transaction_commit", (PyCFunction)_wrap_Ldb_transaction_commit, METH_O, NULL},
- { (char *)"Ldb_transaction_cancel", (PyCFunction)_wrap_Ldb_transaction_cancel, METH_O, NULL},
+ { (char *)"Ldb_set_create_perms", (PyCFunction) _wrap_Ldb_set_create_perms, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_create_perms(mode) -> None\n"
+ "Set mode to use when creating new LDB files.\n"
+ ""},
+ { (char *)"Ldb_set_modules_dir", (PyCFunction) _wrap_Ldb_set_modules_dir, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_modules_dir(path) -> None\n"
+ "Set path LDB should search for modules\n"
+ ""},
+ { (char *)"Ldb_set_debug", (PyCFunction) _wrap_Ldb_set_debug, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_debug(callback) -> None\n"
+ "Set callback for LDB debug messages.\n"
+ "The callback should accept a debug level and debug text.\n"
+ ""},
+ { (char *)"Ldb_set_opaque", (PyCFunction) _wrap_Ldb_set_opaque, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_opaque(name, value) -> None\n"
+ "Set an opaque value on this LDB connection. \n"
+ ":note: Passing incorrect values may cause crashes.\n"
+ ""},
+ { (char *)"Ldb_get_opaque", (PyCFunction) _wrap_Ldb_get_opaque, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.get_opaque(name) -> value\n"
+ "Get an opaque value set on this LDB connection. \n"
+ ":note: The returned value may not be useful in Python.\n"
+ ""},
+ { (char *)"Ldb_transaction_start", (PyCFunction)_wrap_Ldb_transaction_start, METH_O, (char *)"\n"
+ "S.transaction_start() -> None\n"
+ "Start a new transaction.\n"
+ ""},
+ { (char *)"Ldb_transaction_commit", (PyCFunction)_wrap_Ldb_transaction_commit, METH_O, (char *)"\n"
+ "S.transaction_commit() -> None\n"
+ "Commit currently active transaction.\n"
+ ""},
+ { (char *)"Ldb_transaction_cancel", (PyCFunction)_wrap_Ldb_transaction_cancel, METH_O, (char *)"\n"
+ "S.transaction_cancel() -> None\n"
+ "Cancel currently active transaction.\n"
+ ""},
{ (char *)"Ldb_schema_attribute_remove", (PyCFunction) _wrap_Ldb_schema_attribute_remove, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Ldb_schema_attribute_add", (PyCFunction) _wrap_Ldb_schema_attribute_add, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Ldb_setup_wellknown_attributes", (PyCFunction)_wrap_Ldb_setup_wellknown_attributes, METH_O, NULL},
{ (char *)"Ldb___contains__", (PyCFunction) _wrap_Ldb___contains__, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_parse_ldif", (PyCFunction) _wrap_Ldb_parse_ldif, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Ldb_parse_ldif", (PyCFunction) _wrap_Ldb_parse_ldif, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.parse_ldif(ldif) -> iter(messages)\n"
+ "Parse a string formatted using LDIF.\n"
+ ""},
+ { (char *)"Ldb___repr__", (PyCFunction)_wrap_Ldb___repr__, METH_O, NULL},
{ (char *)"Ldb_swigregister", Ldb_swigregister, METH_VARARGS, NULL},
{ (char *)"Ldb_swiginit", Ldb_swiginit, METH_VARARGS, NULL},
- { (char *)"valid_attr_name", (PyCFunction) _wrap_valid_attr_name, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"timestring", (PyCFunction) _wrap_timestring, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"string_to_time", (PyCFunction) _wrap_string_to_time, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"register_module", (PyCFunction) _wrap_register_module, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"valid_attr_name", (PyCFunction) _wrap_valid_attr_name, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.valid_attr_name(name) -> bool\n"
+ "Check whether the supplied name is a valid attribute name.\n"
+ ""},
+ { (char *)"timestring", (PyCFunction) _wrap_timestring, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.timestring(int) -> string\n"
+ "Generate a LDAP time string from a UNIX timestamp\n"
+ ""},
+ { (char *)"string_to_time", (PyCFunction) _wrap_string_to_time, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.string_to_time(string) -> int\n"
+ "Parse a LDAP time string into a UNIX timestamp.\n"
+ ""},
+ { (char *)"register_module", (PyCFunction) _wrap_register_module, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.register_module(module) -> None\n"
+ "Register a LDB module.\n"
+ ""},
{ NULL, NULL, 0, NULL }
};
@@ -5711,24 +5901,25 @@ static PyMethodDef SwigMethods[] = {
static swig_type_info _swigt__p_TALLOC_CTX = {"_p_TALLOC_CTX", "TALLOC_CTX *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_f_p_void_enum_ldb_debug_level_p_q_const__char_va_list__void = {"_p_f_p_void_enum_ldb_debug_level_p_q_const__char_va_list__void", "void (*)(void *,enum ldb_debug_level,char const *,va_list)", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_int = {"_p_int", "int *|int_least32_t *|int32_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_int = {"_p_int", "intptr_t *|int *|int_least32_t *|int_fast32_t *|int32_t *|int_fast16_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_context = {"_p_ldb_context", "struct ldb_context *|ldb *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_dn = {"_p_ldb_dn", "struct ldb_dn *|ldb_dn *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_ldif = {"_p_ldb_ldif", "struct ldb_ldif *|ldb_ldif *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_message = {"_p_ldb_message", "ldb_msg *|struct ldb_message *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_ldb_message_element = {"_p_ldb_message_element", "struct ldb_message_element *|ldb_msg_element *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_ldb_message_element = {"_p_ldb_message_element", "struct ldb_message_element *|ldb_message_element *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_module_ops = {"_p_ldb_module_ops", "struct ldb_module_ops *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_result = {"_p_ldb_result", "struct ldb_result *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_val = {"_p_ldb_val", "struct ldb_val *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_long = {"_p_long", "intptr_t *|int_least64_t *|int_fast32_t *|int_fast64_t *|int64_t *|long *|int_fast16_t *|intmax_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_p_char = {"_p_p_char", "char **", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_p_ldb_control = {"_p_p_ldb_control", "struct ldb_control **", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_p_ldb_result = {"_p_p_ldb_result", "struct ldb_result **", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *|uint_least8_t *|uint_fast8_t *|uint8_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uint_least32_t *|uint32_t *|unsigned int *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_long = {"_p_unsigned_long", "uintptr_t *|uint_least64_t *|uint_fast32_t *|uint_fast64_t *|uint64_t *|unsigned long *|time_t *|uint_fast16_t *|uintmax_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uintptr_t *|uint_least32_t *|uint_fast32_t *|uint32_t *|unsigned int *|uint_fast16_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_long = {"_p_unsigned_long", "unsigned long *|time_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_unsigned_long_long = {"_p_unsigned_long_long", "uint_least64_t *|uint_fast64_t *|uint64_t *|unsigned long long *|uintmax_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *|uint_least16_t *|uint16_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_void = {"_p_void", "void *", 0, 0, (void*)0, 0};
@@ -5745,7 +5936,7 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_ldb_module_ops,
&_swigt__p_ldb_result,
&_swigt__p_ldb_val,
- &_swigt__p_long,
+ &_swigt__p_long_long,
&_swigt__p_p_char,
&_swigt__p_p_ldb_control,
&_swigt__p_p_ldb_result,
@@ -5754,6 +5945,7 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_unsigned_char,
&_swigt__p_unsigned_int,
&_swigt__p_unsigned_long,
+ &_swigt__p_unsigned_long_long,
&_swigt__p_unsigned_short,
&_swigt__p_void,
};
@@ -5770,7 +5962,7 @@ static swig_cast_info _swigc__p_ldb_message_element[] = { {&_swigt__p_ldb_messa
static swig_cast_info _swigc__p_ldb_module_ops[] = { {&_swigt__p_ldb_module_ops, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_ldb_result[] = { {&_swigt__p_ldb_result, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_ldb_val[] = { {&_swigt__p_ldb_val, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_long[] = { {&_swigt__p_long, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_p_char[] = { {&_swigt__p_p_char, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_p_ldb_control[] = { {&_swigt__p_p_ldb_control, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_p_ldb_result[] = { {&_swigt__p_p_ldb_result, 0, 0, 0},{0, 0, 0, 0}};
@@ -5779,6 +5971,7 @@ static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0
static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_unsigned_long[] = { {&_swigt__p_unsigned_long, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_unsigned_long_long[] = { {&_swigt__p_unsigned_long_long, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_void[] = { {&_swigt__p_void, 0, 0, 0},{0, 0, 0, 0}};
@@ -5795,7 +5988,7 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_ldb_module_ops,
_swigc__p_ldb_result,
_swigc__p_ldb_val,
- _swigc__p_long,
+ _swigc__p_long_long,
_swigc__p_p_char,
_swigc__p_p_ldb_control,
_swigc__p_p_ldb_result,
@@ -5804,6 +5997,7 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_unsigned_char,
_swigc__p_unsigned_int,
_swigc__p_unsigned_long,
+ _swigc__p_unsigned_long_long,
_swigc__p_unsigned_short,
_swigc__p_void,
};
@@ -5874,7 +6068,7 @@ SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
- int found;
+ int found, init;
clientdata = clientdata;
@@ -5884,6 +6078,9 @@ SWIG_InitializeModule(void *clientdata) {
swig_module.type_initial = swig_type_initial;
swig_module.cast_initial = swig_cast_initial;
swig_module.next = &swig_module;
+ init = 1;
+ } else {
+ init = 0;
}
/* Try and load any already created modules */
@@ -5912,6 +6109,12 @@ SWIG_InitializeModule(void *clientdata) {
module_head->next = &swig_module;
}
+ /* When multiple interpeters are used, a module could have already been initialized in
+ a different interpreter, but not yet have a pointer in this interpreter.
+ In this case, we do not want to continue adding types... everything should be
+ set up already */
+ if (init == 0) return;
+
/* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: size %d\n", swig_module.size);
diff --git a/source4/lib/ldb/python.mk b/source4/lib/ldb/python.mk
index bbd4c1c5eb..89aba8f276 100644
--- a/source4/lib/ldb/python.mk
+++ b/source4/lib/ldb/python.mk
@@ -1,4 +1,10 @@
[PYTHON::swig_ldb]
+LIBRARY_REALNAME = _ldb.$(SHLIBEXT)
PUBLIC_DEPENDENCIES = LIBLDB
CFLAGS = -Ilib/ldb/include
-SWIG_FILE = ldb.i
+
+swig_ldb_OBJ_FILES = lib/ldb/ldb_wrap.o
+
+$(eval $(call python_py_module_template,ldb.py,lib/ldb/ldb.py))
+
+$(swig_ldb_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py
index 5f3f727b5d..1ae3fde744 100755
--- a/source4/lib/ldb/tests/python/api.py
+++ b/source4/lib/ldb/tests/python/api.py
@@ -36,6 +36,10 @@ class SimpleLdb(unittest.TestCase):
x = ldb.Ldb()
x.connect("foo.tdb")
+ def test_repr(self):
+ x = ldb.Ldb()
+ self.assertTrue(repr(x).startswith("<ldb connection"))
+
def test_set_create_perms(self):
x = ldb.Ldb()
x.set_create_perms(0600)
@@ -60,6 +64,10 @@ class SimpleLdb(unittest.TestCase):
l = ldb.Ldb("foo.tdb")
self.assertEquals(len(l.search("", ldb.SCOPE_SUBTREE, "(dc=*)", ["dc"])), 0)
+ def test_search_attr_string(self):
+ l = ldb.Ldb("foo.tdb")
+ self.assertRaises(TypeError, l.search, attrs="dc")
+
def test_opaque(self):
l = ldb.Ldb("foo.tdb")
l.set_opaque("my_opaque", l)
@@ -257,6 +265,10 @@ class DnTests(unittest.TestCase):
x = ldb.Dn(self.ldb, "dc=foo,bar=bloe")
self.assertEquals(x.__str__(), "dc=foo,bar=bloe")
+ def test_repr(self):
+ x = ldb.Dn(self.ldb, "dc=foo,bla=blie")
+ self.assertEquals(x.__repr__(), "Dn('dc=foo,bla=blie')")
+
def test_get_casefold(self):
x = ldb.Dn(self.ldb, "dc=foo,bar=bloe")
self.assertEquals(x.get_casefold(), "DC=FOO,BAR=bloe")
@@ -347,6 +359,16 @@ class LdbMsgTests(unittest.TestCase):
self.msg = ldb.Message(ldb.Dn(ldb.Ldb(), "dc=foo"))
self.assertEquals("dc=foo", str(self.msg.dn))
+ def test_iter_items(self):
+ self.assertEquals(0, len(self.msg.items()))
+ self.msg.dn = ldb.Dn(ldb.Ldb("foo.tdb"), "dc=foo")
+ self.assertEquals(1, len(self.msg.items()))
+
+ def test_repr(self):
+ self.msg.dn = ldb.Dn(ldb.Ldb("foo.tdb"), "dc=foo")
+ self.msg["dc"] = "foo"
+ self.assertEquals("Message({'dn': Dn('dc=foo'), 'dc': MessageElement(['foo'])})", repr(self.msg))
+
def test_len(self):
self.assertEquals(0, len(self.msg))
@@ -374,14 +396,26 @@ class LdbMsgTests(unittest.TestCase):
self.assertEquals(["bar"], list(self.msg["foo"]))
def test_keys(self):
+ self.msg.dn = ldb.Dn(ldb.Ldb("foo.tdb"), "@BASEINFO")
self.msg["foo"] = ["bla"]
self.msg["bar"] = ["bla"]
- self.assertEquals(["foo", "bar"], self.msg.keys())
+ self.assertEquals(["dn", "foo", "bar"], self.msg.keys())
def test_dn(self):
self.msg.dn = ldb.Dn(ldb.Ldb("foo.tdb"), "@BASEINFO")
self.assertEquals("@BASEINFO", self.msg.dn.__str__())
+ def test_get_dn(self):
+ self.msg.dn = ldb.Dn(ldb.Ldb("foo.tdb"), "@BASEINFO")
+ self.assertEquals("@BASEINFO", self.msg.get("dn").__str__())
+
+ def test_get_other(self):
+ self.msg["foo"] = ["bar"]
+ self.assertEquals("bar", self.msg.get("foo")[0])
+
+ def test_get_unknown(self):
+ self.assertRaises(KeyError, self.msg.get, "lalalala")
+
class MessageElementTests(unittest.TestCase):
def test_cmp_element(self):
@@ -395,6 +429,12 @@ class MessageElementTests(unittest.TestCase):
x = ldb.MessageElement(["foo"])
self.assertEquals(["foo"], list(x))
+ def test_repr(self):
+ x = ldb.MessageElement(["foo"])
+ self.assertEquals("MessageElement(['foo'])", repr(x))
+ x = ldb.MessageElement(["foo", "bla"])
+ self.assertEquals("MessageElement(['foo','bla'])", repr(x))
+
def test_get_item(self):
x = ldb.MessageElement(["foo", "bar"])
self.assertEquals("foo", x[0])
diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py
index ead5796b7b..c76222c207 100755
--- a/source4/lib/ldb/tests/python/ldap.py
+++ b/source4/lib/ldb/tests/python/ldap.py
@@ -6,16 +6,18 @@ import getopt
import optparse
import sys
+sys.path.append("bin/python")
+
import samba.getopt as options
-from auth import system_session
+from samba.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_OTHER)
from samba import Ldb
from subunit import SubunitTestRunner
-import param
+from samba import param
import unittest
parser = optparse.OptionParser("ldap [options] <host>")
diff --git a/source4/lib/ldb/tools/ad2oLschema.c b/source4/lib/ldb/tools/ad2oLschema.c
index 67b16dd06e..0a89656fa2 100644
--- a/source4/lib/ldb/tools/ad2oLschema.c
+++ b/source4/lib/ldb/tools/ad2oLschema.c
@@ -429,7 +429,7 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_
/* We might have been asked to remap this oid,
* due to a conflict, or lack of
* implementation */
- for (j=0; syntax_oid && oid_map[j].old_oid; j++) {
+ for (j=0; syntax_oid && oid_map && oid_map[j].old_oid; j++) {
if (strcasecmp(syntax_oid, oid_map[j].old_oid) == 0) {
syntax_oid = oid_map[j].new_oid;
break;
@@ -494,7 +494,7 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum convert_
}
/* We might have been asked to remap this oid, due to a conflict */
- for (j=0; oid_map[j].old_oid; j++) {
+ for (j=0; oid_map && oid_map[j].old_oid; j++) {
if (strcasecmp(oid, oid_map[j].old_oid) == 0) {
oid = oid_map[j].new_oid;
break;
diff --git a/source4/lib/ldb/tools/config.mk b/source4/lib/ldb/tools/config.mk
index 02ad84ae25..6729636434 100644
--- a/source4/lib/ldb/tools/config.mk
+++ b/source4/lib/ldb/tools/config.mk
@@ -2,89 +2,89 @@
# Start SUBSYSTEM LIBLDB_CMDLINE
[SUBSYSTEM::LIBLDB_CMDLINE]
CFLAGS = -Ilib/ldb -Ilib/ldb/include
-OBJ_FILES= \
- cmdline.o
PUBLIC_DEPENDENCIES = LIBLDB LIBPOPT
PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL POPT_SAMBA POPT_CREDENTIALS gensec
# End SUBSYSTEM LIBLDB_CMDLINE
################################################
+LIBLDB_CMDLINE_OBJ_FILES = lib/ldb/tools/cmdline.o
+
################################################
# Start BINARY ldbadd
[BINARY::ldbadd]
INSTALLDIR = BINDIR
-OBJ_FILES = \
- ldbadd.o
PRIVATE_DEPENDENCIES = \
LIBLDB_CMDLINE LIBCLI_RESOLVE
# End BINARY ldbadd
################################################
+
+ldbadd_OBJ_FILES = lib/ldb/tools/ldbadd.o
+
MANPAGES += $(ldbdir)/man/ldbadd.1
################################################
# Start BINARY ldbdel
[BINARY::ldbdel]
INSTALLDIR = BINDIR
-OBJ_FILES= \
- ldbdel.o
PRIVATE_DEPENDENCIES = \
LIBLDB_CMDLINE
# End BINARY ldbdel
################################################
+ldbdel_OBJ_FILES = lib/ldb/tools/ldbdel.o
+
MANPAGES += $(ldbdir)/man/ldbdel.1
################################################
# Start BINARY ldbmodify
[BINARY::ldbmodify]
INSTALLDIR = BINDIR
-OBJ_FILES= \
- ldbmodify.o
PRIVATE_DEPENDENCIES = \
LIBLDB_CMDLINE
# End BINARY ldbmodify
################################################
+ldbmodify_OBJ_FILES = lib/ldb/tools/ldbmodify.o
MANPAGES += $(ldbdir)/man/ldbmodify.1
################################################
# Start BINARY ldbsearch
[BINARY::ldbsearch]
INSTALLDIR = BINDIR
-OBJ_FILES= \
- ldbsearch.o
PRIVATE_DEPENDENCIES = \
LIBLDB_CMDLINE
# End BINARY ldbsearch
################################################
+ldbsearch_OBJ_FILES = lib/ldb/tools/ldbsearch.o
+
MANPAGES += $(ldbdir)/man/ldbsearch.1
################################################
# Start BINARY ldbedit
[BINARY::ldbedit]
INSTALLDIR = BINDIR
-OBJ_FILES= \
- ldbedit.o
PRIVATE_DEPENDENCIES = \
LIBLDB_CMDLINE
# End BINARY ldbedit
################################################
+ldbedit_OBJ_FILES = lib/ldb/tools/ldbedit.o
+
MANPAGES += $(ldbdir)/man/ldbedit.1
################################################
# Start BINARY ldbrename
[BINARY::ldbrename]
INSTALLDIR = BINDIR
-OBJ_FILES= \
- ldbrename.o
PRIVATE_DEPENDENCIES = \
LIBLDB_CMDLINE
# End BINARY ldbrename
################################################
+ldbrename_OBJ_FILES = lib/ldb/tools/ldbrename.o
+
MANPAGES += $(ldbdir)/man/ldbrename.1
diff --git a/source4/lib/ldb_wrap.c b/source4/lib/ldb_wrap.c
index 71ba37b479..f47d0d5d39 100644
--- a/source4/lib/ldb_wrap.c
+++ b/source4/lib/ldb_wrap.c
@@ -44,7 +44,7 @@ static void ldb_wrap_debug(void *context, enum ldb_debug_level level,
static void ldb_wrap_debug(void *context, enum ldb_debug_level level,
const char *fmt, va_list ap)
{
- int samba_level;
+ int samba_level = -1;
char *s = NULL;
switch (level) {
case LDB_DEBUG_FATAL:
@@ -94,6 +94,7 @@ static int ldb_wrap_destructor(struct ldb_context *ldb)
TODO: We need an error_string parameter
*/
struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
struct loadparm_context *lp_ctx,
const char *url,
struct auth_session_info *session_info,
@@ -103,7 +104,6 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
{
struct ldb_context *ldb;
int ret;
- struct event_context *ev;
char *real_url = NULL;
size_t *startup_blocks;
@@ -115,10 +115,9 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
ldb_set_modules_dir(ldb,
talloc_asprintf(ldb, "%s/ldb", lp_modulesdir(lp_ctx)));
- /* we want to use the existing event context if possible. This
- relies on the fact that in smbd, everything is a child of
- the main event_context */
- ev = event_context_find(ldb);
+ if (ev == NULL) {
+ return NULL;
+ }
if (ldb_set_opaque(ldb, "EventContext", ev)) {
talloc_free(ldb);
diff --git a/source4/lib/ldb_wrap.h b/source4/lib/ldb_wrap.h
index d3ff04b880..e626b6ef8a 100644
--- a/source4/lib/ldb_wrap.h
+++ b/source4/lib/ldb_wrap.h
@@ -27,10 +27,12 @@ struct ldb_message;
struct ldb_dn;
struct cli_credentials;
struct loadparm_context;
+struct event_context;
char *wrap_casefold(void *context, void *mem_ctx, const char *s);
struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
struct loadparm_context *lp_ctx,
const char *url,
struct auth_session_info *session_info,
diff --git a/source4/lib/messaging/config.mk b/source4/lib/messaging/config.mk
index 3fec9c0c90..eaf7e3581e 100644
--- a/source4/lib/messaging/config.mk
+++ b/source4/lib/messaging/config.mk
@@ -2,8 +2,6 @@
################################################
# Start SUBSYSTEM MESSAGING
[SUBSYSTEM::MESSAGING]
-OBJ_FILES = \
- messaging.o
PUBLIC_DEPENDENCIES = \
LIBSAMBA-UTIL \
TDB_WRAP \
@@ -14,3 +12,5 @@ PUBLIC_DEPENDENCIES = \
LIBNDR
# End SUBSYSTEM MESSAGING
################################################
+
+MESSAGING_OBJ_FILES = $(libmessagingsrcdir)/messaging.o
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index 29d6e00247..e7b654894f 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -544,6 +544,10 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
NTSTATUS status;
struct socket_address *path;
+ if (ev == NULL) {
+ return NULL;
+ }
+
msg = talloc_zero(mem_ctx, struct messaging_context);
if (msg == NULL) {
return NULL;
@@ -556,10 +560,6 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
return NULL;
}
- if (ev == NULL) {
- ev = event_context_init(msg);
- }
-
/* create the messaging directory if needed */
mkdir(dir, 0700);
@@ -1085,8 +1085,14 @@ void irpc_remove_name(struct messaging_context *msg_ctx, const char *name)
return;
}
rec = tdb_fetch_bystring(t->tdb, name);
+ if (rec.dptr == NULL) {
+ tdb_unlock_bystring(t->tdb, name);
+ talloc_free(t);
+ return;
+ }
count = rec.dsize / sizeof(struct server_id);
if (count == 0) {
+ free(rec.dptr);
tdb_unlock_bystring(t->tdb, name);
talloc_free(t);
return;
diff --git a/source4/lib/messaging/tests/messaging.c b/source4/lib/messaging/tests/messaging.c
index 45b573518c..f66b3a5b43 100644
--- a/source4/lib/messaging/tests/messaging.c
+++ b/source4/lib/messaging/tests/messaging.c
@@ -134,7 +134,6 @@ static bool test_ping_speed(struct torture_context *tctx)
talloc_free(msg_client_ctx);
talloc_free(msg_server_ctx);
- talloc_free(ev);
return true;
}
diff --git a/source4/lib/nss_wrapper/config.mk b/source4/lib/nss_wrapper/config.mk
index 03c10acc7a..015fbe511c 100644
--- a/source4/lib/nss_wrapper/config.mk
+++ b/source4/lib/nss_wrapper/config.mk
@@ -1,6 +1,7 @@
##############################
# Start SUBSYSTEM NSS_WRAPPER
[SUBSYSTEM::NSS_WRAPPER]
-OBJ_FILES = nss_wrapper.o
# End SUBSYSTEM NSS_WRAPPER
##############################
+
+NSS_WRAPPER_OBJ_FILES = $(nsswrappersrcdir)/nss_wrapper.o
diff --git a/source4/lib/policy/adm.h b/source4/lib/policy/adm.h
deleted file mode 100644
index c541ced6ff..0000000000
--- a/source4/lib/policy/adm.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Copyright (C) 2006 Wilco Baan Hofman <wilco@baanhofman.nl>
- Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef __ADM_H__
-#define __ADM_H__
-
-struct adm_file {
- struct adm_class *classes;
-};
-
-struct adm_class {
- struct adm_category *categories;
-};
-
-struct adm_category {
- struct adm_category *subcategories;
- struct adm_policy *policies;
-};
-
-struct adm_policy {
- struct adm_part *parts;
-};
-
-struct adm_part {
- int dummy;
-};
-
-struct adm_file *adm_read_file(const char *);
-
-#endif /* __ADM_H__ */
diff --git a/source4/lib/policy/config.mk b/source4/lib/policy/config.mk
deleted file mode 100644
index 6763884b48..0000000000
--- a/source4/lib/policy/config.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-[SUBSYSTEM::LIBPOLICY]
-CFLAGS = -Iheimdal/lib/roken
-OBJ_FILES = lex.o parse_adm.o
-PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG LIBTALLOC CHARSET
-
-lib/policy/lex.l: lib/policy/parse_adm.h
-
-lib/policy/parse_adm.h: lib/policy/parse_adm.c
-
-[BINARY::dumpadm]
-OBJ_FILES = dumpadm.o
-PRIVATE_DEPENDENCIES = LIBPOLICY LIBPOPT LIBSAMBA-HOSTCONFIG LIBTALLOC LIBSAMBA-UTIL CHARSET
diff --git a/source4/lib/policy/dumpadm.c b/source4/lib/policy/dumpadm.c
deleted file mode 100644
index 2ed5abf111..0000000000
--- a/source4/lib/policy/dumpadm.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Copyright (C) 2006 Wilco Baan Hofman <wilco@baanhofman.nl>
- Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include "includes.h"
-#include "lib/popt/popt.h"
-#include "lib/policy/adm.h"
-
-int main(int argc, char **argv)
-{
- bool ret = true;
- poptContext pc;
- struct poptOption long_options[] = {
- POPT_AUTOHELP
- { 0, 0, 0, 0 }
- };
-
- pc = poptGetContext(argv[0], argc, (const char **)argv, long_options, 0);
-
- poptSetOtherOptionHelp(pc, "<ADM-FILE> ...");
-
- while ((poptGetNextOpt(pc) != -1))
-
- if(!poptPeekArg(pc)) {
- poptPrintUsage(pc, stderr, 0);
- exit(1);
- }
-
- while (poptPeekArg(pc)) {
- const char *name = poptGetArg(pc);
-
- adm_read_file(name);
- }
-
- poptFreeContext(pc);
-
- return ret;
-}
diff --git a/source4/lib/policy/lex.c b/source4/lib/policy/lex.c
deleted file mode 100644
index 6d524445c9..0000000000
--- a/source4/lib/policy/lex.c
+++ /dev/null
@@ -1,2085 +0,0 @@
-#include "config.h"
-
-#line 3 "lex.yy.c"
-
-#define YY_INT_ALIGNED short int
-
-/* A lexical scanner generated by flex */
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 33
-#if YY_FLEX_SUBMINOR_VERSION > 0
-#define FLEX_BETA
-#endif
-
-/* First, we deal with platform-specific or compiler-specific issues. */
-
-/* begin standard C headers. */
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/* end standard C headers. */
-
-/* flex integer type definitions */
-
-#ifndef FLEXINT_H
-#define FLEXINT_H
-
-/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-
-#if __STDC_VERSION__ >= 199901L
-
-/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
- * if you want the limit (max/min) macros for int types.
- */
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS 1
-#endif
-
-#include <inttypes.h>
-typedef int8_t flex_int8_t;
-typedef uint8_t flex_uint8_t;
-typedef int16_t flex_int16_t;
-typedef uint16_t flex_uint16_t;
-typedef int32_t flex_int32_t;
-typedef uint32_t flex_uint32_t;
-#else
-typedef signed char flex_int8_t;
-typedef short int flex_int16_t;
-typedef int flex_int32_t;
-typedef unsigned char flex_uint8_t;
-typedef unsigned short int flex_uint16_t;
-typedef unsigned int flex_uint32_t;
-#endif /* ! C99 */
-
-/* Limits of integral types. */
-#ifndef INT8_MIN
-#define INT8_MIN (-128)
-#endif
-#ifndef INT16_MIN
-#define INT16_MIN (-32767-1)
-#endif
-#ifndef INT32_MIN
-#define INT32_MIN (-2147483647-1)
-#endif
-#ifndef INT8_MAX
-#define INT8_MAX (127)
-#endif
-#ifndef INT16_MAX
-#define INT16_MAX (32767)
-#endif
-#ifndef INT32_MAX
-#define INT32_MAX (2147483647)
-#endif
-#ifndef UINT8_MAX
-#define UINT8_MAX (255U)
-#endif
-#ifndef UINT16_MAX
-#define UINT16_MAX (65535U)
-#endif
-#ifndef UINT32_MAX
-#define UINT32_MAX (4294967295U)
-#endif
-
-#endif /* ! FLEXINT_H */
-
-#ifdef __cplusplus
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-#if __STDC__
-
-#define YY_USE_CONST
-
-#endif /* __STDC__ */
-#endif /* ! __cplusplus */
-
-#ifdef YY_USE_CONST
-#define yyconst const
-#else
-#define yyconst
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN (yy_start) = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state. The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START (((yy_start) - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart(yyin )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#ifndef YY_BUF_SIZE
-#define YY_BUF_SIZE 16384
-#endif
-
-/* The state buf must be large enough to hold one state per character in the main buffer.
- */
-#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
-
-#ifndef YY_TYPEDEF_YY_BUFFER_STATE
-#define YY_TYPEDEF_YY_BUFFER_STATE
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-#endif
-
-extern int yyleng;
-
-extern FILE *yyin, *yyout;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
- #define YY_LESS_LINENO(n)
-
-/* Return all but the first "n" matched characters back to the input stream. */
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- *yy_cp = (yy_hold_char); \
- YY_RESTORE_YY_MORE_OFFSET \
- (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up yytext again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, (yytext_ptr) )
-
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef unsigned int yy_size_t;
-#endif
-
-#ifndef YY_STRUCT_YY_BUFFER_STATE
-#define YY_STRUCT_YY_BUFFER_STATE
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- yy_size_t yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- int yy_n_chars;
-
- /* Whether we "own" the buffer - i.e., we know we created it,
- * and can realloc() it to grow it, and should free() it to
- * delete it.
- */
- int yy_is_our_buffer;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether we're considered to be at the beginning of a line.
- * If so, '^' rules will be active on the next match, otherwise
- * not.
- */
- int yy_at_bol;
-
- int yy_bs_lineno; /**< The line count. */
- int yy_bs_column; /**< The column count. */
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via yyrestart()), so that the user can continue scanning by
- * just pointing yyin at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
-
- };
-#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-
-/* Stack of input buffers. */
-static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
-static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
-static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- *
- * Returns the top of the stack, or NULL.
- */
-#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
- ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
- : NULL)
-
-/* Same as previous macro, but useful when we know that the buffer stack is not
- * NULL or when we need an lvalue. For internal use only.
- */
-#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
-
-/* yy_hold_char holds the character lost when yytext is formed. */
-static char yy_hold_char;
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-int yyleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 0; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow yywrap()'s to do buffer switches
- * instead of setting up a fresh yyin. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void yyrestart (FILE *input_file );
-void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
-YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
-void yy_delete_buffer (YY_BUFFER_STATE b );
-void yy_flush_buffer (YY_BUFFER_STATE b );
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
-void yypop_buffer_state (void );
-
-static void yyensure_buffer_stack (void );
-static void yy_load_buffer_state (void );
-static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
-
-#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
-
-YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
-YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
-
-void *yyalloc (yy_size_t );
-void *yyrealloc (void *,yy_size_t );
-void yyfree (void * );
-
-#define yy_new_buffer yy_create_buffer
-
-#define yy_set_interactive(is_interactive) \
- { \
- if ( ! YY_CURRENT_BUFFER ){ \
- yyensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- yy_create_buffer(yyin,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
- }
-
-#define yy_set_bol(at_bol) \
- { \
- if ( ! YY_CURRENT_BUFFER ){\
- yyensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- yy_create_buffer(yyin,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
- }
-
-#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
-
-/* Begin user sect3 */
-
-typedef unsigned char YY_CHAR;
-
-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
-
-typedef int yy_state_type;
-
-extern int yylineno;
-
-int yylineno = 1;
-
-extern char *yytext;
-#define yytext_ptr yytext
-
-static yy_state_type yy_get_previous_state (void );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
-static int yy_get_next_buffer (void );
-static void yy_fatal_error (yyconst char msg[] );
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up yytext.
- */
-#define YY_DO_BEFORE_ACTION \
- (yytext_ptr) = yy_bp; \
- yyleng = (size_t) (yy_cp - yy_bp); \
- (yy_hold_char) = *yy_cp; \
- *yy_cp = '\0'; \
- (yy_c_buf_p) = yy_cp;
-
-#define YY_NUM_RULES 38
-#define YY_END_OF_BUFFER 39
-/* This struct is not used in this scanner,
- but its presence is necessary. */
-struct yy_trans_info
- {
- flex_int32_t yy_verify;
- flex_int32_t yy_nxt;
- };
-static yyconst flex_int16_t yy_accept[185] =
- { 0,
- 0, 0, 39, 38, 34, 35, 38, 38, 31, 38,
- 29, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 38, 34, 0, 0,
- 31, 0, 36, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 0, 33, 37,
- 32, 32, 32, 32, 32, 32, 32, 32, 9, 32,
- 32, 32, 32, 15, 14, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 0, 33, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 32, 32, 32, 16,
-
- 32, 18, 32, 32, 21, 32, 23, 24, 32, 0,
- 32, 32, 32, 4, 32, 32, 32, 32, 32, 32,
- 32, 32, 32, 32, 32, 32, 25, 0, 32, 32,
- 32, 32, 5, 32, 32, 32, 32, 32, 32, 32,
- 19, 32, 32, 32, 32, 0, 32, 32, 32, 6,
- 32, 32, 10, 32, 12, 13, 17, 32, 32, 32,
- 32, 27, 0, 32, 2, 3, 32, 8, 11, 20,
- 32, 32, 28, 0, 32, 32, 22, 26, 30, 1,
- 32, 32, 7, 0
- } ;
-
-static yyconst flex_int32_t yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 4, 5, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 6, 1, 1, 7, 7, 7,
- 7, 7, 7, 7, 7, 7, 7, 1, 8, 1,
- 9, 1, 1, 1, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
- 26, 27, 28, 29, 30, 31, 32, 33, 34, 19,
- 35, 36, 37, 1, 6, 1, 19, 19, 19, 19,
-
- 19, 19, 38, 19, 39, 19, 19, 19, 19, 40,
- 19, 19, 19, 41, 42, 43, 19, 19, 19, 19,
- 19, 19, 36, 1, 36, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-static yyconst flex_int32_t yy_meta[44] =
- { 0,
- 1, 1, 2, 1, 1, 3, 3, 1, 1, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 1, 5, 1, 4, 4, 4,
- 4, 4, 4
- } ;
-
-static yyconst flex_int16_t yy_base[190] =
- { 0,
- 0, 0, 213, 214, 210, 214, 207, 0, 203, 206,
- 214, 196, 0, 34, 31, 33, 178, 192, 39, 37,
- 38, 191, 29, 190, 175, 192, 159, 198, 0, 196,
- 191, 194, 214, 0, 167, 166, 180, 183, 48, 168,
- 173, 177, 164, 174, 153, 38, 163, 163, 162, 156,
- 161, 155, 162, 154, 145, 163, 155, 132, 0, 214,
- 156, 159, 160, 143, 160, 155, 143, 138, 0, 145,
- 143, 141, 146, 0, 0, 148, 147, 131, 141, 128,
- 134, 131, 126, 127, 123, 111, 0, 127, 134, 129,
- 120, 117, 117, 132, 115, 133, 121, 131, 122, 0,
-
- 112, 0, 126, 119, 0, 112, 0, 0, 121, 95,
- 110, 108, 120, 0, 109, 115, 104, 113, 108, 107,
- 102, 100, 104, 87, 93, 92, 29, 78, 96, 89,
- 91, 85, 0, 81, 79, 88, 82, 95, 94, 95,
- 0, 92, 76, 94, 45, 65, 84, 67, 67, 0,
- 76, 69, 0, 68, 0, 0, 0, 83, 81, 72,
- 78, 0, 50, 63, 0, 0, 69, 0, 0, 0,
- 76, 74, 0, 50, 44, 52, 0, 0, 214, 0,
- 37, 35, 0, 214, 71, 76, 79, 57, 82
- } ;
-
-static yyconst flex_int16_t yy_def[190] =
- { 0,
- 184, 1, 184, 184, 184, 184, 184, 185, 184, 186,
- 184, 187, 187, 187, 187, 187, 187, 187, 187, 187,
- 187, 187, 187, 187, 187, 187, 184, 184, 188, 185,
- 184, 186, 184, 187, 187, 187, 187, 187, 187, 187,
- 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
- 187, 187, 187, 187, 187, 187, 187, 184, 189, 184,
- 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
- 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
- 187, 187, 187, 187, 187, 184, 189, 187, 187, 187,
- 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
-
- 187, 187, 187, 187, 187, 187, 187, 187, 187, 184,
- 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
- 187, 187, 187, 187, 187, 187, 187, 184, 187, 187,
- 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
- 187, 187, 187, 187, 187, 184, 187, 187, 187, 187,
- 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
- 187, 187, 184, 187, 187, 187, 187, 187, 187, 187,
- 187, 187, 187, 184, 187, 187, 187, 187, 184, 187,
- 187, 187, 187, 0, 184, 184, 184, 184, 184
- } ;
-
-static yyconst flex_int16_t yy_nxt[258] =
- { 0,
- 4, 5, 6, 7, 8, 4, 9, 10, 11, 12,
- 13, 14, 15, 16, 13, 13, 13, 17, 13, 18,
- 13, 19, 20, 13, 21, 13, 22, 23, 24, 25,
- 26, 13, 13, 13, 27, 13, 4, 13, 13, 13,
- 13, 13, 13, 36, 39, 41, 48, 50, 46, 73,
- 37, 144, 145, 53, 38, 42, 47, 40, 54, 161,
- 59, 51, 65, 183, 182, 43, 49, 162, 66, 181,
- 74, 30, 180, 30, 30, 30, 32, 32, 32, 32,
- 32, 34, 34, 34, 87, 87, 179, 178, 177, 176,
- 175, 174, 173, 172, 171, 170, 169, 168, 167, 166,
-
- 165, 164, 163, 160, 159, 158, 157, 156, 155, 154,
- 153, 152, 151, 150, 149, 148, 147, 146, 143, 142,
- 141, 140, 139, 138, 137, 136, 135, 134, 133, 132,
- 131, 130, 129, 128, 127, 126, 125, 124, 123, 122,
- 121, 120, 119, 118, 117, 116, 115, 114, 113, 112,
- 111, 110, 109, 108, 107, 106, 105, 104, 103, 102,
- 101, 100, 99, 98, 97, 96, 95, 94, 93, 92,
- 91, 90, 89, 88, 86, 85, 84, 83, 82, 81,
- 80, 79, 78, 77, 76, 75, 72, 71, 70, 69,
- 68, 67, 64, 63, 62, 61, 33, 31, 60, 28,
-
- 58, 57, 56, 55, 52, 45, 44, 35, 33, 31,
- 29, 28, 184, 3, 184, 184, 184, 184, 184, 184,
- 184, 184, 184, 184, 184, 184, 184, 184, 184, 184,
- 184, 184, 184, 184, 184, 184, 184, 184, 184, 184,
- 184, 184, 184, 184, 184, 184, 184, 184, 184, 184,
- 184, 184, 184, 184, 184, 184, 184
- } ;
-
-static yyconst flex_int16_t yy_chk[258] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 14, 15, 16, 20, 21, 19, 46,
- 14, 127, 127, 23, 14, 16, 19, 15, 23, 145,
- 188, 21, 39, 182, 181, 16, 20, 145, 39, 176,
- 46, 185, 175, 185, 185, 185, 186, 186, 186, 186,
- 186, 187, 187, 187, 189, 189, 174, 172, 171, 167,
- 164, 163, 161, 160, 159, 158, 154, 152, 151, 149,
-
- 148, 147, 146, 144, 143, 142, 140, 139, 138, 137,
- 136, 135, 134, 132, 131, 130, 129, 128, 126, 125,
- 124, 123, 122, 121, 120, 119, 118, 117, 116, 115,
- 113, 112, 111, 110, 109, 106, 104, 103, 101, 99,
- 98, 97, 96, 95, 94, 93, 92, 91, 90, 89,
- 88, 86, 85, 84, 83, 82, 81, 80, 79, 78,
- 77, 76, 73, 72, 71, 70, 68, 67, 66, 65,
- 64, 63, 62, 61, 58, 57, 56, 55, 54, 53,
- 52, 51, 50, 49, 48, 47, 45, 44, 43, 42,
- 41, 40, 38, 37, 36, 35, 32, 31, 30, 28,
-
- 27, 26, 25, 24, 22, 18, 17, 12, 10, 9,
- 7, 5, 3, 184, 184, 184, 184, 184, 184, 184,
- 184, 184, 184, 184, 184, 184, 184, 184, 184, 184,
- 184, 184, 184, 184, 184, 184, 184, 184, 184, 184,
- 184, 184, 184, 184, 184, 184, 184, 184, 184, 184,
- 184, 184, 184, 184, 184, 184, 184
- } ;
-
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-extern int yy_flex_debug;
-int yy_flex_debug = 0;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-char *yytext;
-#line 1 "lex.l"
-/*
- Unix SMB/CIFS implementation.
- Copyright (C) 2006 Wilco Baan Hofman <wilco@baanhofman.nl>
- Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#line 23 "lex.l"
-#include "includes.h"
-#include "lib/policy/parse_adm.h"
-#include "param/param.h"
-void error_message (const char *format, ...);
-int yyparse (void);
-
-static int lineno = 1;
-static bool utf16 = false;
-
-#define YY_INPUT(buf,result,max_size) \
-{ \
- if (utf16) { \
- uint16_t v; \
- if (fread(&v, 2, 1, yyin) < 1) \
- result = YY_NULL; \
- else \
- result = push_codepoint(lp_iconv_convenience(global_loadparm), buf, v); \
- } else { \
- int c = getc(yyin); \
- result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
- } \
-}
-
-#line 610 "lex.yy.c"
-
-#define INITIAL 0
-
-#ifndef YY_NO_UNISTD_H
-/* Special case for "unistd.h", since it is non-ANSI. We include it way
- * down here because we want the user's section 1 to have been scanned first.
- * The user has a chance to override it with an option.
- */
-#include <unistd.h>
-#endif
-
-#ifndef YY_EXTRA_TYPE
-#define YY_EXTRA_TYPE void *
-#endif
-
-static int yy_init_globals (void );
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int yywrap (void );
-#else
-extern int yywrap (void );
-#endif
-#endif
-
- static void yyunput (int c,char *buf_ptr );
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int );
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * );
-#endif
-
-#ifndef YY_NO_INPUT
-
-#ifdef __cplusplus
-static int yyinput (void );
-#else
-static int input (void );
-#endif
-
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 8192
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
- { \
- int c = '*'; \
- size_t n; \
- for ( n = 0; n < max_size && \
- (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
- buf[n] = (char) c; \
- if ( c == '\n' ) \
- buf[n++] = (char) c; \
- if ( c == EOF && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- result = n; \
- } \
- else \
- { \
- errno=0; \
- while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
- { \
- if( errno != EINTR) \
- { \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- break; \
- } \
- errno=0; \
- clearerr(yyin); \
- } \
- }\
-\
-
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* end tables serialization structures and prototypes */
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL_IS_OURS 1
-
-extern int yylex (void);
-
-#define YY_DECL int yylex (void)
-#endif /* !YY_DECL */
-
-/* Code executed at the beginning of each rule, after yytext and yyleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK break;
-#endif
-
-#define YY_RULE_SETUP \
- YY_USER_ACTION
-
-/** The main scanner function which does all the work.
- */
-YY_DECL
-{
- register yy_state_type yy_current_state;
- register char *yy_cp, *yy_bp;
- register int yy_act;
-
-#line 47 "lex.l"
-
-
-#line 766 "lex.yy.c"
-
- if ( !(yy_init) )
- {
- (yy_init) = 1;
-
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! (yy_start) )
- (yy_start) = 1; /* first start state */
-
- if ( ! yyin )
- yyin = stdin;
-
- if ( ! yyout )
- yyout = stdout;
-
- if ( ! YY_CURRENT_BUFFER ) {
- yyensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- yy_create_buffer(yyin,YY_BUF_SIZE );
- }
-
- yy_load_buffer_state( );
- }
-
- while ( 1 ) /* loops until end-of-file is reached */
- {
- yy_cp = (yy_c_buf_p);
-
- /* Support of yytext. */
- *yy_cp = (yy_hold_char);
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = (yy_start);
-yy_match:
- do
- {
- register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 185 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- ++yy_cp;
- }
- while ( yy_base[yy_current_state] != 214 );
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
- if ( yy_act == 0 )
- { /* have to back up */
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- yy_act = yy_accept[yy_current_state];
- }
-
- YY_DO_BEFORE_ACTION;
-
-do_action: /* This label is used only to access EOF actions. */
-
- switch ( yy_act )
- { /* beginning of action switch */
- case 0: /* must back up */
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = (yy_hold_char);
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- goto yy_find_action;
-
-case 1:
-YY_RULE_SETUP
-#line 49 "lex.l"
-{ return ACTIONLIST; }
- YY_BREAK
-case 2:
-YY_RULE_SETUP
-#line 50 "lex.l"
-{ return CATEGORY; }
- YY_BREAK
-case 3:
-YY_RULE_SETUP
-#line 51 "lex.l"
-{ return CHECKBOX; }
- YY_BREAK
-case 4:
-YY_RULE_SETUP
-#line 52 "lex.l"
-{ return CLASS; }
- YY_BREAK
-case 5:
-YY_RULE_SETUP
-#line 53 "lex.l"
-{ return DEL; }
- YY_BREAK
-case 6:
-YY_RULE_SETUP
-#line 54 "lex.l"
-{ return DEFAULT; }
- YY_BREAK
-case 7:
-YY_RULE_SETUP
-#line 55 "lex.l"
-{ return DROPDOWNLIST; }
- YY_BREAK
-case 8:
-YY_RULE_SETUP
-#line 56 "lex.l"
-{ return EDITTEXT; }
- YY_BREAK
-case 9:
-YY_RULE_SETUP
-#line 57 "lex.l"
-{ return END; }
- YY_BREAK
-case 10:
-YY_RULE_SETUP
-#line 58 "lex.l"
-{ return EXPLAIN; }
- YY_BREAK
-case 11:
-YY_RULE_SETUP
-#line 59 "lex.l"
-{ return ITEMLIST; }
- YY_BREAK
-case 12:
-YY_RULE_SETUP
-#line 60 "lex.l"
-{ return KEYNAME; }
- YY_BREAK
-case 13:
-YY_RULE_SETUP
-#line 61 "lex.l"
-{ return CLASS_MACHINE; }
- YY_BREAK
-case 14:
-YY_RULE_SETUP
-#line 62 "lex.l"
-{ return MINIMUM; }
- YY_BREAK
-case 15:
-YY_RULE_SETUP
-#line 63 "lex.l"
-{ return MAXIMUM; }
- YY_BREAK
-case 16:
-YY_RULE_SETUP
-#line 64 "lex.l"
-{ return NAME; }
- YY_BREAK
-case 17:
-YY_RULE_SETUP
-#line 65 "lex.l"
-{ return NUMERIC; }
- YY_BREAK
-case 18:
-YY_RULE_SETUP
-#line 66 "lex.l"
-{ return PART; }
- YY_BREAK
-case 19:
-YY_RULE_SETUP
-#line 67 "lex.l"
-{ return POLICY; }
- YY_BREAK
-case 20:
-YY_RULE_SETUP
-#line 68 "lex.l"
-{ return REQUIRED; }
- YY_BREAK
-case 21:
-YY_RULE_SETUP
-#line 69 "lex.l"
-{ return SPIN; }
- YY_BREAK
-case 22:
-YY_RULE_SETUP
-#line 70 "lex.l"
-{ return SUPPORTED; }
- YY_BREAK
-case 23:
-YY_RULE_SETUP
-#line 71 "lex.l"
-{ return TEXT; }
- YY_BREAK
-case 24:
-YY_RULE_SETUP
-#line 72 "lex.l"
-{ return CLASS_USER; }
- YY_BREAK
-case 25:
-YY_RULE_SETUP
-#line 73 "lex.l"
-{ return VALUE; }
- YY_BREAK
-case 26:
-YY_RULE_SETUP
-#line 74 "lex.l"
-{ return VALUENAME; }
- YY_BREAK
-case 27:
-YY_RULE_SETUP
-#line 75 "lex.l"
-{ return VALUEON; }
- YY_BREAK
-case 28:
-YY_RULE_SETUP
-#line 76 "lex.l"
-{ return VALUEOFF; }
- YY_BREAK
-case 29:
-YY_RULE_SETUP
-#line 77 "lex.l"
-{ return EQUALS; }
- YY_BREAK
-case 30:
-YY_RULE_SETUP
-#line 78 "lex.l"
-{ return STRINGSSECTION; }
- YY_BREAK
-case 31:
-YY_RULE_SETUP
-#line 80 "lex.l"
-{
- char *e, *y = yytext;
- yylval.integer = strtol((const char *)yytext, &e, 0);
- if(e == y)
- error_message("malformed constant (%s)", yytext);
- else
- return INTEGER;
- }
- YY_BREAK
-case 32:
-YY_RULE_SETUP
-#line 89 "lex.l"
-{
- yylval.text = strdup ((const char *)yytext);
- return LITERAL;
- }
- YY_BREAK
-case 33:
-YY_RULE_SETUP
-#line 94 "lex.l"
-{
- yylval.text = strdup ((const char *)yytext);
- return LOOKUPLITERAL;
- }
- YY_BREAK
-case 34:
-YY_RULE_SETUP
-#line 98 "lex.l"
-
- YY_BREAK
-case 35:
-/* rule 35 can match eol */
-YY_RULE_SETUP
-#line 99 "lex.l"
-{ lineno++; }
- YY_BREAK
-case 36:
-/* rule 36 can match eol */
-YY_RULE_SETUP
-#line 100 "lex.l"
-{ lineno++; }
- YY_BREAK
-case 37:
-/* rule 37 can match eol */
-YY_RULE_SETUP
-#line 101 "lex.l"
-{ lineno++; yylval.text = strdup((const char *)yytext); return LITERAL; }
- YY_BREAK
-case 38:
-YY_RULE_SETUP
-#line 102 "lex.l"
-ECHO;
- YY_BREAK
-#line 1055 "lex.yy.c"
-case YY_STATE_EOF(INITIAL):
- yyterminate();
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = (yy_hold_char);
- YY_RESTORE_YY_MORE_OFFSET
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed yyin at a new source and called
- * yylex(). If so, then we have to assure
- * consistency between YY_CURRENT_BUFFER and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++(yy_c_buf_p);
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = (yy_c_buf_p);
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_END_OF_FILE:
- {
- (yy_did_buffer_switch_on_eof) = 0;
-
- if ( yywrap( ) )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * yytext, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) =
- (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- (yy_c_buf_p) =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
-} /* end of yylex */
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-static int yy_get_next_buffer (void)
-{
- register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
- register char *source = (yytext_ptr);
- register int number_to_move, i;
- int ret_val;
-
- if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
- {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
-
- else
- {
- int num_to_read =
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
-
- int yy_c_buf_p_offset =
- (int) ((yy_c_buf_p) - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer )
- {
- int new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 )
- b->yy_buf_size += b->yy_buf_size / 8;
- else
- b->yy_buf_size *= 2;
-
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
- }
- else
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
- number_to_move - 1;
-
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- (yy_n_chars), (size_t) num_to_read );
-
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- if ( (yy_n_chars) == 0 )
- {
- if ( number_to_move == YY_MORE_ADJ )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- yyrestart(yyin );
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- (yy_n_chars) += number_to_move;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
-
- (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
-
- return ret_val;
-}
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
- static yy_state_type yy_get_previous_state (void)
-{
- register yy_state_type yy_current_state;
- register char *yy_cp;
-
- yy_current_state = (yy_start);
-
- for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
- {
- register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 185 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- }
-
- return yy_current_state;
-}
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
- static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
-{
- register int yy_is_jam;
- register char *yy_cp = (yy_c_buf_p);
-
- register YY_CHAR yy_c = 1;
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 185 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 184);
-
- return yy_is_jam ? 0 : yy_current_state;
-}
-
- static void yyunput (int c, register char * yy_bp )
-{
- register char *yy_cp;
-
- yy_cp = (yy_c_buf_p);
-
- /* undo effects of setting up yytext */
- *yy_cp = (yy_hold_char);
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- /* +2 for EOB chars. */
- register int number_to_move = (yy_n_chars) + 2;
- register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
- register char *source =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
-
- while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += (int) (dest - source);
- yy_bp += (int) (dest - source);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
-
- if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- *--yy_cp = (char) c;
-
- (yytext_ptr) = yy_bp;
- (yy_hold_char) = *yy_cp;
- (yy_c_buf_p) = yy_cp;
-}
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
- static int yyinput (void)
-#else
- static int input (void)
-#endif
-
-{
- int c;
-
- *(yy_c_buf_p) = (yy_hold_char);
-
- if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- /* This was really a NUL. */
- *(yy_c_buf_p) = '\0';
-
- else
- { /* need more input */
- int offset = (yy_c_buf_p) - (yytext_ptr);
- ++(yy_c_buf_p);
-
- switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_LAST_MATCH:
- /* This happens because yy_g_n_b()
- * sees that we've accumulated a
- * token and flags that we need to
- * try matching the token before
- * proceeding. But for input(),
- * there's no matching to consider.
- * So convert the EOB_ACT_LAST_MATCH
- * to EOB_ACT_END_OF_FILE.
- */
-
- /* Reset buffer status. */
- yyrestart(yyin );
-
- /*FALLTHROUGH*/
-
- case EOB_ACT_END_OF_FILE:
- {
- if ( yywrap( ) )
- return EOF;
-
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) = (yytext_ptr) + offset;
- break;
- }
- }
- }
-
- c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
- *(yy_c_buf_p) = '\0'; /* preserve yytext */
- (yy_hold_char) = *++(yy_c_buf_p);
-
- return c;
-}
-#endif /* ifndef YY_NO_INPUT */
-
-/** Immediately switch to a different input stream.
- * @param input_file A readable stream.
- *
- * @note This function does not reset the start condition to @c INITIAL .
- */
- void yyrestart (FILE * input_file )
-{
-
- if ( ! YY_CURRENT_BUFFER ){
- yyensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- yy_create_buffer(yyin,YY_BUF_SIZE );
- }
-
- yy_init_buffer(YY_CURRENT_BUFFER,input_file );
- yy_load_buffer_state( );
-}
-
-/** Switch to a different input buffer.
- * @param new_buffer The new input buffer.
- *
- */
- void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
-{
-
- /* TODO. We should be able to replace this entire function body
- * with
- * yypop_buffer_state();
- * yypush_buffer_state(new_buffer);
- */
- yyensure_buffer_stack ();
- if ( YY_CURRENT_BUFFER == new_buffer )
- return;
-
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
- yy_load_buffer_state( );
-
- /* We don't actually know whether we did this switch during
- * EOF (yywrap()) processing, but the only time this flag
- * is looked at is after yywrap() is called, so it's safe
- * to go ahead and always set it.
- */
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-static void yy_load_buffer_state (void)
-{
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
- yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
- (yy_hold_char) = *(yy_c_buf_p);
-}
-
-/** Allocate and initialize an input buffer state.
- * @param file A readable stream.
- * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
- *
- * @return the allocated buffer state.
- */
- YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
-{
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_buf_size = size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_is_our_buffer = 1;
-
- yy_init_buffer(b,file );
-
- return b;
-}
-
-/** Destroy the buffer.
- * @param b a buffer created with yy_create_buffer()
- *
- */
- void yy_delete_buffer (YY_BUFFER_STATE b )
-{
-
- if ( ! b )
- return;
-
- if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
- YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
-
- if ( b->yy_is_our_buffer )
- yyfree((void *) b->yy_ch_buf );
-
- yyfree((void *) b );
-}
-
-#ifndef __cplusplus
-extern int isatty (int );
-#endif /* __cplusplus */
-
-/* Initializes or reinitializes a buffer.
- * This function is sometimes called more than once on the same buffer,
- * such as during a yyrestart() or at EOF.
- */
- static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
-
-{
- int oerrno = errno;
-
- yy_flush_buffer(b );
-
- b->yy_input_file = file;
- b->yy_fill_buffer = 1;
-
- /* If b is the current buffer, then yy_init_buffer was _probably_
- * called from yyrestart() or through yy_get_next_buffer.
- * In that case, we don't want to reset the lineno or column.
- */
- if (b != YY_CURRENT_BUFFER){
- b->yy_bs_lineno = 1;
- b->yy_bs_column = 0;
- }
-
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-
- errno = oerrno;
-}
-
-/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
- * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
- *
- */
- void yy_flush_buffer (YY_BUFFER_STATE b )
-{
- if ( ! b )
- return;
-
- b->yy_n_chars = 0;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[0];
-
- b->yy_at_bol = 1;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- if ( b == YY_CURRENT_BUFFER )
- yy_load_buffer_state( );
-}
-
-/** Pushes the new state onto the stack. The new state becomes
- * the current state. This function will allocate the stack
- * if necessary.
- * @param new_buffer The new state.
- *
- */
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
-{
- if (new_buffer == NULL)
- return;
-
- yyensure_buffer_stack();
-
- /* This block is copied from yy_switch_to_buffer. */
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- /* Only push if top exists. Otherwise, replace top. */
- if (YY_CURRENT_BUFFER)
- (yy_buffer_stack_top)++;
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
-
- /* copied from yy_switch_to_buffer. */
- yy_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-/** Removes and deletes the top of the stack, if present.
- * The next element becomes the new top.
- *
- */
-void yypop_buffer_state (void)
-{
- if (!YY_CURRENT_BUFFER)
- return;
-
- yy_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- if ((yy_buffer_stack_top) > 0)
- --(yy_buffer_stack_top);
-
- if (YY_CURRENT_BUFFER) {
- yy_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
- }
-}
-
-/* Allocates the stack if it does not exist.
- * Guarantees space for at least one push.
- */
-static void yyensure_buffer_stack (void)
-{
- int num_to_alloc;
-
- if (!(yy_buffer_stack)) {
-
- /* First allocation is just for 2 elements, since we don't know if this
- * scanner will even need a stack. We use 2 instead of 1 to avoid an
- * immediate realloc on the next call.
- */
- num_to_alloc = 1;
- (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
- (num_to_alloc * sizeof(struct yy_buffer_state*)
- );
-
- memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-
- (yy_buffer_stack_max) = num_to_alloc;
- (yy_buffer_stack_top) = 0;
- return;
- }
-
- if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
-
- /* Increase the buffer to prepare for a possible push. */
- int grow_size = 8 /* arbitrary grow size */;
-
- num_to_alloc = (yy_buffer_stack_max) + grow_size;
- (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
- ((yy_buffer_stack),
- num_to_alloc * sizeof(struct yy_buffer_state*)
- );
-
- /* zero only the new slots.*/
- memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
- (yy_buffer_stack_max) = num_to_alloc;
- }
-}
-
-/** Setup the input buffer state to scan directly from a user-specified character buffer.
- * @param base the character buffer
- * @param size the size in bytes of the character buffer
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
-{
- YY_BUFFER_STATE b;
-
- if ( size < 2 ||
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
- base[size-1] != YY_END_OF_BUFFER_CHAR )
- /* They forgot to leave room for the EOB's. */
- return 0;
-
- b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
-
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
- b->yy_buf_pos = b->yy_ch_buf = base;
- b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
- b->yy_n_chars = b->yy_buf_size;
- b->yy_is_interactive = 0;
- b->yy_at_bol = 1;
- b->yy_fill_buffer = 0;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- yy_switch_to_buffer(b );
-
- return b;
-}
-
-/** Setup the input buffer state to scan a string. The next call to yylex() will
- * scan from a @e copy of @a str.
- * @param yystr a NUL-terminated string to scan
- *
- * @return the newly allocated buffer state object.
- * @note If you want to scan bytes that may contain NUL values, then use
- * yy_scan_bytes() instead.
- */
-YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
-{
-
- return yy_scan_bytes(yystr,strlen(yystr) );
-}
-
-/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
- * scan from a @e copy of @a bytes.
- * @param bytes the byte buffer to scan
- * @param len the number of bytes in the buffer pointed to by @a bytes.
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
-{
- YY_BUFFER_STATE b;
- char *buf;
- yy_size_t n;
- int i;
-
- /* Get memory for full buffer, including space for trailing EOB's. */
- n = _yybytes_len + 2;
- buf = (char *) yyalloc(n );
- if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
-
- for ( i = 0; i < _yybytes_len; ++i )
- buf[i] = yybytes[i];
-
- buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
-
- b = yy_scan_buffer(buf,n );
- if ( ! b )
- YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
-
- /* It's okay to grow etc. this buffer, and we should throw it
- * away when we're done.
- */
- b->yy_is_our_buffer = 1;
-
- return b;
-}
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-static void yy_fatal_error (yyconst char* msg )
-{
- (void) fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
-}
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- yytext[yyleng] = (yy_hold_char); \
- (yy_c_buf_p) = yytext + yyless_macro_arg; \
- (yy_hold_char) = *(yy_c_buf_p); \
- *(yy_c_buf_p) = '\0'; \
- yyleng = yyless_macro_arg; \
- } \
- while ( 0 )
-
-/* Accessor methods (get/set functions) to struct members. */
-
-/** Get the current line number.
- *
- */
-int yyget_lineno (void)
-{
-
- return yylineno;
-}
-
-/** Get the input stream.
- *
- */
-FILE *yyget_in (void)
-{
- return yyin;
-}
-
-/** Get the output stream.
- *
- */
-FILE *yyget_out (void)
-{
- return yyout;
-}
-
-/** Get the length of the current token.
- *
- */
-int yyget_leng (void)
-{
- return yyleng;
-}
-
-/** Get the current token.
- *
- */
-
-char *yyget_text (void)
-{
- return yytext;
-}
-
-/** Set the current line number.
- * @param line_number
- *
- */
-void yyset_lineno (int line_number )
-{
-
- yylineno = line_number;
-}
-
-/** Set the input stream. This does not discard the current
- * input buffer.
- * @param in_str A readable stream.
- *
- * @see yy_switch_to_buffer
- */
-void yyset_in (FILE * in_str )
-{
- yyin = in_str ;
-}
-
-void yyset_out (FILE * out_str )
-{
- yyout = out_str ;
-}
-
-int yyget_debug (void)
-{
- return yy_flex_debug;
-}
-
-void yyset_debug (int bdebug )
-{
- yy_flex_debug = bdebug ;
-}
-
-static int yy_init_globals (void)
-{
- /* Initialization is the same as for the non-reentrant scanner.
- * This function is called from yylex_destroy(), so don't allocate here.
- */
-
- (yy_buffer_stack) = 0;
- (yy_buffer_stack_top) = 0;
- (yy_buffer_stack_max) = 0;
- (yy_c_buf_p) = (char *) 0;
- (yy_init) = 0;
- (yy_start) = 0;
-
-/* Defined in main.c */
-#ifdef YY_STDINIT
- yyin = stdin;
- yyout = stdout;
-#else
- yyin = (FILE *) 0;
- yyout = (FILE *) 0;
-#endif
-
- /* For future reference: Set errno on error, since we are called by
- * yylex_init()
- */
- return 0;
-}
-
-/* yylex_destroy is for both reentrant and non-reentrant scanners. */
-int yylex_destroy (void)
-{
-
- /* Pop the buffer stack, destroying each element. */
- while(YY_CURRENT_BUFFER){
- yy_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- yypop_buffer_state();
- }
-
- /* Destroy the stack itself. */
- yyfree((yy_buffer_stack) );
- (yy_buffer_stack) = NULL;
-
- /* Reset the globals. This is important in a non-reentrant scanner so the next time
- * yylex() is called, initialization will occur. */
- yy_init_globals( );
-
- return 0;
-}
-
-/*
- * Internal utility routines.
- */
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
-{
- register int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
-}
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s )
-{
- register int n;
- for ( n = 0; s[n]; ++n )
- ;
-
- return n;
-}
-#endif
-
-void *yyalloc (yy_size_t size )
-{
- return (void *) malloc( size );
-}
-
-void *yyrealloc (void * ptr, yy_size_t size )
-{
- /* The cast to (char *) in the following accommodates both
- * implementations that use char* generic pointers, and those
- * that use void* generic pointers. It works with the latter
- * because both ANSI C and C++ allow castless assignment from
- * any pointer type to void*, and deal with argument conversions
- * as though doing an assignment.
- */
- return (void *) realloc( (char *) ptr, size );
-}
-
-void yyfree (void * ptr )
-{
- free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
-}
-
-#define YYTABLES_NAME "yytables"
-
-#line 102 "lex.l"
-
-
-
-#ifndef yywrap /* XXX */
-int
-yywrap ()
-{
- return 1;
-}
-#endif
-
-
-void
-error_message (const char *format, ...)
-{
- va_list args;
-
- va_start (args, format);
- fprintf (stderr, "%d:", lineno);
- vfprintf (stderr, format, args);
- va_end (args);
-}
-
-struct adm_file *adm_read_file(const char *file)
-{
- uint8_t c[2];
- yyin = fopen(file, "r");
- if (yyin == NULL)
- return NULL;
-
- c[0] = getc(yyin);
- c[1] = getc(yyin);
- if (c[0] == 0xff && c[1] == 0xfe) {
- utf16 = true;
- } else {
- rewind(yyin);
- }
-
- yyparse();
-
- return NULL; /* FIXME */
-}
-
diff --git a/source4/lib/policy/lex.l b/source4/lib/policy/lex.l
deleted file mode 100644
index dc1f0aa34e..0000000000
--- a/source4/lib/policy/lex.l
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Copyright (C) 2006 Wilco Baan Hofman <wilco@baanhofman.nl>
- Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-
-%{
-#include "includes.h"
-#include "lib/policy/parse_adm.h"
-void error_message (const char *format, ...);
-int yyparse (void);
-
-static int lineno = 1;
-static bool utf16 = false;
-
-#define YY_INPUT(buf,result,max_size) \
-{ \
- if (utf16) { \
- uint16_t v; \
- if (fread(&v, 2, 1, yyin) < 1) \
- result = YY_NULL; \
- else \
- result = push_codepoint(buf, v); \
- } else { \
- int c = getc(yyin); \
- result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
- } \
-}
-
-%}
-
-%%
-
-ACTIONLIST { return ACTIONLIST; }
-CATEGORY { return CATEGORY; }
-CHECKBOX { return CHECKBOX; }
-CLASS { return CLASS; }
-DELETE { return DEL; }
-DEFAULT { return DEFAULT; }
-DROPDOWNLIST { return DROPDOWNLIST; }
-EDITTEXT { return EDITTEXT; }
-END { return END; }
-EXPLAIN { return EXPLAIN; }
-ITEMLIST { return ITEMLIST; }
-KEYNAME { return KEYNAME; }
-MACHINE { return CLASS_MACHINE; }
-MIN { return MINIMUM; }
-MAX { return MAXIMUM; }
-NAME { return NAME; }
-NUMERIC { return NUMERIC; }
-PART { return PART; }
-POLICY { return POLICY; }
-REQUIRED { return REQUIRED; }
-SPIN { return SPIN; }
-SUPPORTED { return SUPPORTED; }
-TEXT { return TEXT; }
-USER { return CLASS_USER; }
-VALUE { return VALUE; }
-VALUENAME { return VALUENAME; }
-VALUEON { return VALUEON; }
-VALUEOFF { return VALUEOFF; }
-= { return EQUALS; }
-\[strings\] { return STRINGSSECTION; }
-
-[0-9]+ {
- char *e, *y = yytext;
- yylval.integer = strtol((const char *)yytext, &e, 0);
- if(e == y)
- error_message("malformed constant (%s)", yytext);
- else
- return INTEGER;
- }
-
-[A-Za-z\\{}][{}\-\\A-Za-z0-9_]* {
- yylval.text = strdup ((const char *)yytext);
- return LITERAL;
- }
-
-"!!"[A-Za-z][-A-Za-z0-9_]* {
- yylval.text = strdup ((const char *)yytext);
- return LOOKUPLITERAL;
- }
-[ \t]+
-\n { lineno++; }
-;[^\n]*\n { lineno++; }
-\"([^\n]+)\n { lineno++; yylval.text = strdup((const char *)yytext); return LITERAL; }
-%%
-
-#ifndef yywrap /* XXX */
-int
-yywrap ()
-{
- return 1;
-}
-#endif
-
-
-void
-error_message (const char *format, ...)
-{
- va_list args;
-
- va_start (args, format);
- fprintf (stderr, "%d:", lineno);
- vfprintf (stderr, format, args);
- va_end (args);
-}
-
-struct adm_file *adm_read_file(const char *file)
-{
- uint8_t c[2];
- yyin = fopen(file, "r");
- if (yyin == NULL)
- return NULL;
-
- c[0] = getc(yyin);
- c[1] = getc(yyin);
- if (c[0] == 0xff && c[1] == 0xfe) {
- utf16 = true;
- } else {
- rewind(yyin);
- }
-
- yyparse();
-
- return NULL; /* FIXME */
-}
diff --git a/source4/lib/policy/parse_adm.c b/source4/lib/policy/parse_adm.c
deleted file mode 100644
index c68e2db814..0000000000
--- a/source4/lib/policy/parse_adm.c
+++ /dev/null
@@ -1,1726 +0,0 @@
-/* A Bison parser, made by GNU Bison 2.3. */
-
-/* Skeleton implementation for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
-
- 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 2, 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-/* C LALR(1) parser skeleton written by Richard Stallman, by
- simplifying the original so-called "semantic" parser. */
-
-/* All symbols defined below should begin with yy or YY, to avoid
- infringing on user name space. This should be done even for local
- variables, as they might otherwise be expanded by user macros.
- There are some unavoidable exceptions within include files to
- define necessary library symbols; they are noted "INFRINGES ON
- USER NAME SPACE" below. */
-
-/* Identify Bison output. */
-#define YYBISON 1
-
-/* Bison version. */
-#define YYBISON_VERSION "2.3"
-
-/* Skeleton name. */
-#define YYSKELETON_NAME "yacc.c"
-
-/* Pure parsers. */
-#define YYPURE 0
-
-/* Using locations. */
-#define YYLSP_NEEDED 0
-
-
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- CATEGORY = 258,
- CLASS = 259,
- CLASS_USER = 260,
- CLASS_MACHINE = 261,
- POLICY = 262,
- KEYNAME = 263,
- EXPLAIN = 264,
- VALUENAME = 265,
- VALUEON = 266,
- VALUEOFF = 267,
- PART = 268,
- ITEMLIST = 269,
- NAME = 270,
- VALUE = 271,
- NUMERIC = 272,
- EDITTEXT = 273,
- TEXT = 274,
- DROPDOWNLIST = 275,
- CHECKBOX = 276,
- MINIMUM = 277,
- MAXIMUM = 278,
- DEFAULT = 279,
- END = 280,
- ACTIONLIST = 281,
- DEL = 282,
- SUPPORTED = 283,
- LITERAL = 284,
- INTEGER = 285,
- LOOKUPLITERAL = 286,
- CLIENTEXT = 287,
- REQUIRED = 288,
- NOSORT = 289,
- SPIN = 290,
- EQUALS = 291,
- STRINGSSECTION = 292
- };
-#endif
-/* Tokens. */
-#define CATEGORY 258
-#define CLASS 259
-#define CLASS_USER 260
-#define CLASS_MACHINE 261
-#define POLICY 262
-#define KEYNAME 263
-#define EXPLAIN 264
-#define VALUENAME 265
-#define VALUEON 266
-#define VALUEOFF 267
-#define PART 268
-#define ITEMLIST 269
-#define NAME 270
-#define VALUE 271
-#define NUMERIC 272
-#define EDITTEXT 273
-#define TEXT 274
-#define DROPDOWNLIST 275
-#define CHECKBOX 276
-#define MINIMUM 277
-#define MAXIMUM 278
-#define DEFAULT 279
-#define END 280
-#define ACTIONLIST 281
-#define DEL 282
-#define SUPPORTED 283
-#define LITERAL 284
-#define INTEGER 285
-#define LOOKUPLITERAL 286
-#define CLIENTEXT 287
-#define REQUIRED 288
-#define NOSORT 289
-#define SPIN 290
-#define EQUALS 291
-#define STRINGSSECTION 292
-
-
-
-
-/* Copy the first part of user declarations. */
-#line 24 "lib/policy/parse_adm.y"
-
-#include "config.h"
-void error_message (const char *format, ...);
-int yyparse (void);
-void yyerror (const char *s);
-extern int yylex (void);
-
-
-
-/* Enabling traces. */
-#ifndef YYDEBUG
-# define YYDEBUG 0
-#endif
-
-/* Enabling verbose error messages. */
-#ifdef YYERROR_VERBOSE
-# undef YYERROR_VERBOSE
-# define YYERROR_VERBOSE 1
-#else
-# define YYERROR_VERBOSE 0
-#endif
-
-/* Enabling the token table. */
-#ifndef YYTOKEN_TABLE
-# define YYTOKEN_TABLE 0
-#endif
-
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE
-#line 33 "lib/policy/parse_adm.y"
-{
- char *text;
- int integer;
-}
-/* Line 187 of yacc.c. */
-#line 184 "lib/policy/parse_adm.y"
- YYSTYPE;
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
-#endif
-
-
-
-/* Copy the second part of user declarations. */
-
-
-/* Line 216 of yacc.c. */
-#line 197 "lib/policy/parse_adm.y"
-
-#ifdef short
-# undef short
-#endif
-
-#ifdef YYTYPE_UINT8
-typedef YYTYPE_UINT8 yytype_uint8;
-#else
-typedef unsigned char yytype_uint8;
-#endif
-
-#ifdef YYTYPE_INT8
-typedef YYTYPE_INT8 yytype_int8;
-#elif (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-typedef signed char yytype_int8;
-#else
-typedef short int yytype_int8;
-#endif
-
-#ifdef YYTYPE_UINT16
-typedef YYTYPE_UINT16 yytype_uint16;
-#else
-typedef unsigned short int yytype_uint16;
-#endif
-
-#ifdef YYTYPE_INT16
-typedef YYTYPE_INT16 yytype_int16;
-#else
-typedef short int yytype_int16;
-#endif
-
-#ifndef YYSIZE_T
-# ifdef __SIZE_TYPE__
-# define YYSIZE_T __SIZE_TYPE__
-# elif defined size_t
-# define YYSIZE_T size_t
-# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# else
-# define YYSIZE_T unsigned int
-# endif
-#endif
-
-#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
-
-#ifndef YY_
-# if YYENABLE_NLS
-# if ENABLE_NLS
-# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
-# define YY_(msgid) dgettext ("bison-runtime", msgid)
-# endif
-# endif
-# ifndef YY_
-# define YY_(msgid) msgid
-# endif
-#endif
-
-/* Suppress unused-variable warnings by "using" E. */
-#if ! defined lint || defined __GNUC__
-# define YYUSE(e) ((void) (e))
-#else
-# define YYUSE(e) /* empty */
-#endif
-
-/* Identity function, used to suppress warnings about constant conditions. */
-#ifndef lint
-# define YYID(n) (n)
-#else
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static int
-YYID (int i)
-#else
-static int
-YYID (i)
- int i;
-#endif
-{
- return i;
-}
-#endif
-
-#if ! defined yyoverflow || YYERROR_VERBOSE
-
-/* The parser invokes alloca or malloc; define the necessary symbols. */
-
-# ifdef YYSTACK_USE_ALLOCA
-# if YYSTACK_USE_ALLOCA
-# ifdef __GNUC__
-# define YYSTACK_ALLOC __builtin_alloca
-# elif defined __BUILTIN_VA_ARG_INCR
-# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
-# elif defined _AIX
-# define YYSTACK_ALLOC __alloca
-# elif defined _MSC_VER
-# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
-# define alloca _alloca
-# else
-# define YYSTACK_ALLOC alloca
-# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef _STDLIB_H
-# define _STDLIB_H 1
-# endif
-# endif
-# endif
-# endif
-# endif
-
-# ifdef YYSTACK_ALLOC
- /* Pacify GCC's `empty if-body' warning. */
-# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
-# ifndef YYSTACK_ALLOC_MAXIMUM
- /* The OS might guarantee only one guard page at the bottom of the stack,
- and a page size can be as small as 4096 bytes. So we cannot safely
- invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
- to allow for a few compiler-allocated temporary stack slots. */
-# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
-# endif
-# else
-# define YYSTACK_ALLOC YYMALLOC
-# define YYSTACK_FREE YYFREE
-# ifndef YYSTACK_ALLOC_MAXIMUM
-# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
-# endif
-# if (defined __cplusplus && ! defined _STDLIB_H \
- && ! ((defined YYMALLOC || defined malloc) \
- && (defined YYFREE || defined free)))
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# ifndef _STDLIB_H
-# define _STDLIB_H 1
-# endif
-# endif
-# ifndef YYMALLOC
-# define YYMALLOC malloc
-# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# ifndef YYFREE
-# define YYFREE free
-# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-void free (void *); /* INFRINGES ON USER NAME SPACE */
-# endif
-# endif
-# endif
-#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
-
-
-#if (! defined yyoverflow \
- && (! defined __cplusplus \
- || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
-
-/* A type that is properly aligned for any stack member. */
-union yyalloc
-{
- yytype_int16 yyss;
- YYSTYPE yyvs;
- };
-
-/* The size of the maximum gap between one aligned stack and the next. */
-# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
-
-/* The size of an array large to enough to hold all stacks, each with
- N elements. */
-# define YYSTACK_BYTES(N) \
- ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
- + YYSTACK_GAP_MAXIMUM)
-
-/* Copy COUNT objects from FROM to TO. The source and destination do
- not overlap. */
-# ifndef YYCOPY
-# if defined __GNUC__ && 1 < __GNUC__
-# define YYCOPY(To, From, Count) \
- __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
-# else
-# define YYCOPY(To, From, Count) \
- do \
- { \
- YYSIZE_T yyi; \
- for (yyi = 0; yyi < (Count); yyi++) \
- (To)[yyi] = (From)[yyi]; \
- } \
- while (YYID (0))
-# endif
-# endif
-
-/* Relocate STACK from its old location to the new one. The
- local variables YYSIZE and YYSTACKSIZE give the old and new number of
- elements in the stack, and YYPTR gives the new location of the
- stack. Advance YYPTR to a properly aligned location for the next
- stack. */
-# define YYSTACK_RELOCATE(Stack) \
- do \
- { \
- YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack, Stack, yysize); \
- Stack = &yyptr->Stack; \
- yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
- yyptr += yynewbytes / sizeof (*yyptr); \
- } \
- while (YYID (0))
-
-#endif
-
-/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 8
-/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 112
-
-/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 38
-/* YYNNTS -- Number of nonterminals. */
-#define YYNNTS 38
-/* YYNRULES -- Number of rules. */
-#define YYNRULES 78
-/* YYNRULES -- Number of states. */
-#define YYNSTATES 119
-
-/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
-#define YYUNDEFTOK 2
-#define YYMAXUTOK 292
-
-#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
-
-/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
-static const yytype_uint8 yytranslate[] =
-{
- 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
- 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
- 35, 36, 37
-};
-
-#if YYDEBUG
-/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
- YYRHS. */
-static const yytype_uint8 yyprhs[] =
-{
- 0, 0, 3, 6, 7, 10, 14, 16, 18, 19,
- 22, 24, 26, 32, 34, 36, 38, 40, 43, 44,
- 50, 52, 54, 56, 58, 60, 62, 64, 66, 68,
- 70, 73, 74, 76, 78, 80, 82, 84, 91, 94,
- 96, 98, 100, 102, 104, 106, 108, 110, 112, 114,
- 117, 118, 121, 124, 127, 130, 132, 135, 138, 141,
- 144, 147, 152, 155, 158, 160, 162, 164, 166, 167,
- 170, 173, 178, 181, 184, 185, 189, 192, 193
-};
-
-/* YYRHS -- A `-1'-separated list of the rules' RHS. */
-static const yytype_int8 yyrhs[] =
-{
- 39, 0, -1, 40, 75, -1, -1, 41, 40, -1,
- 4, 42, 43, -1, 5, -1, 6, -1, -1, 45,
- 43, -1, 29, -1, 31, -1, 3, 44, 47, 25,
- 3, -1, 59, -1, 45, -1, 48, -1, 64, -1,
- 46, 47, -1, -1, 7, 44, 50, 25, 7, -1,
- 59, -1, 64, -1, 63, -1, 61, -1, 62, -1,
- 56, -1, 57, -1, 58, -1, 70, -1, 52, -1,
- 49, 50, -1, -1, 17, -1, 18, -1, 19, -1,
- 20, -1, 21, -1, 13, 44, 51, 55, 25, 13,
- -1, 35, 30, -1, 64, -1, 63, -1, 61, -1,
- 62, -1, 56, -1, 57, -1, 58, -1, 65, -1,
- 33, -1, 53, -1, 54, 55, -1, -1, 22, 30,
- -1, 23, 30, -1, 24, 30, -1, 9, 44, -1,
- 27, -1, 17, 30, -1, 11, 60, -1, 12, 60,
- -1, 10, 44, -1, 8, 44, -1, 14, 69, 25,
- 14, -1, 15, 44, -1, 16, 60, -1, 66, -1,
- 67, -1, 24, -1, 71, -1, -1, 68, 69, -1,
- 28, 44, -1, 26, 72, 25, 26, -1, 63, 72,
- -1, 67, 72, -1, -1, 29, 36, 29, -1, 73,
- 74, -1, -1, 37, 74, -1
-};
-
-/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
-static const yytype_uint8 yyrline[] =
-{
- 0, 71, 71, 73, 73, 75, 76, 76, 78, 78,
- 80, 80, 82, 84, 84, 84, 84, 85, 85, 87,
- 88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
- 89, 89, 91, 91, 91, 91, 91, 93, 95, 97,
- 97, 97, 97, 97, 97, 97, 97, 97, 97, 98,
- 98, 100, 101, 102, 104, 105, 105, 107, 108, 110,
- 111, 113, 114, 115, 117, 117, 117, 117, 118, 118,
- 120, 122, 123, 123, 123, 125, 126, 126, 127
-};
-#endif
-
-#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
-/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
- First, the terminals, then, starting at YYNTOKENS, nonterminals. */
-static const char *const yytname[] =
-{
- "$end", "error", "$undefined", "CATEGORY", "CLASS", "CLASS_USER",
- "CLASS_MACHINE", "POLICY", "KEYNAME", "EXPLAIN", "VALUENAME", "VALUEON",
- "VALUEOFF", "PART", "ITEMLIST", "NAME", "VALUE", "NUMERIC", "EDITTEXT",
- "TEXT", "DROPDOWNLIST", "CHECKBOX", "MINIMUM", "MAXIMUM", "DEFAULT",
- "END", "ACTIONLIST", "DEL", "SUPPORTED", "LITERAL", "INTEGER",
- "LOOKUPLITERAL", "CLIENTEXT", "REQUIRED", "NOSORT", "SPIN", "EQUALS",
- "STRINGSSECTION", "$accept", "admfile", "classes", "class", "classvalue",
- "categories", "string", "category", "categoryitem", "categoryitems",
- "policy", "policyitem", "policyitems", "valuetype", "part", "spin",
- "partitem", "partitems", "min", "max", "defaultvalue", "explain",
- "value", "valueon", "valueoff", "valuename", "keyname", "itemlist",
- "itemname", "itemvalue", "item", "items", "supported", "actionlist",
- "actions", "variable", "variables", "strings", 0
-};
-#endif
-
-# ifdef YYPRINT
-/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
- token YYLEX-NUM. */
-static const yytype_uint16 yytoknum[] =
-{
- 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
- 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
- 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
- 285, 286, 287, 288, 289, 290, 291, 292
-};
-# endif
-
-/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
-static const yytype_uint8 yyr1[] =
-{
- 0, 38, 39, 40, 40, 41, 42, 42, 43, 43,
- 44, 44, 45, 46, 46, 46, 46, 47, 47, 48,
- 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 50, 50, 51, 51, 51, 51, 51, 52, 53, 54,
- 54, 54, 54, 54, 54, 54, 54, 54, 54, 55,
- 55, 56, 57, 58, 59, 60, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 68, 68, 68, 69, 69,
- 70, 71, 72, 72, 72, 73, 74, 74, 75
-};
-
-/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
-static const yytype_uint8 yyr2[] =
-{
- 0, 2, 2, 0, 2, 3, 1, 1, 0, 2,
- 1, 1, 5, 1, 1, 1, 1, 2, 0, 5,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 0, 1, 1, 1, 1, 1, 6, 2, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
- 0, 2, 2, 2, 2, 1, 2, 2, 2, 2,
- 2, 4, 2, 2, 1, 1, 1, 1, 0, 2,
- 2, 4, 2, 2, 0, 3, 2, 0, 2
-};
-
-/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
- STATE-NUM when YYTABLE doesn't specify something else to do. Zero
- means the default is an error. */
-static const yytype_uint8 yydefact[] =
-{
- 3, 0, 0, 0, 3, 6, 7, 8, 1, 77,
- 2, 4, 0, 5, 8, 0, 77, 78, 10, 11,
- 18, 9, 0, 76, 0, 0, 0, 14, 18, 0,
- 15, 13, 16, 75, 31, 60, 54, 17, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 31, 0, 29,
- 25, 26, 27, 20, 23, 24, 22, 21, 28, 12,
- 59, 0, 55, 57, 58, 0, 51, 52, 53, 70,
- 30, 0, 56, 32, 33, 34, 35, 36, 50, 19,
- 68, 47, 0, 48, 50, 0, 43, 44, 45, 41,
- 42, 40, 39, 46, 0, 0, 66, 74, 64, 65,
- 68, 0, 67, 38, 49, 0, 62, 63, 74, 74,
- 0, 69, 0, 37, 72, 73, 0, 61, 71
-};
-
-/* YYDEFGOTO[NTERM-NUM]. */
-static const yytype_int8 yydefgoto[] =
-{
- -1, 2, 3, 4, 7, 13, 20, 14, 28, 29,
- 30, 47, 48, 78, 49, 83, 84, 85, 50, 51,
- 52, 31, 63, 54, 55, 108, 32, 93, 98, 109,
- 100, 101, 58, 102, 110, 16, 17, 10
-};
-
-/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
- STATE-NUM. */
-#define YYPACT_NINF -61
-static const yytype_int8 yypact[] =
-{
- 30, 46, 36, 12, 30, -61, -61, 70, -61, 10,
- -61, -61, -22, -61, 70, 45, 10, -61, -61, -61,
- 55, -61, 53, -61, -22, -22, -22, -61, 55, 58,
- -61, -61, -61, -61, 19, -61, -61, -61, 81, -22,
- 6, 6, -22, 56, 57, 60, -22, 19, 63, -61,
- -61, -61, -61, -61, -61, -61, -61, -61, -61, -61,
- -61, 61, -61, -61, -61, 59, -61, -61, -61, -61,
- -61, 78, -61, -61, -61, -61, -61, -61, 2, -61,
- 29, -61, 62, -61, 2, 64, -61, -61, -61, -61,
- -61, -61, -61, -61, -22, 6, -61, -5, -61, -61,
- 29, 68, -61, -61, -61, 82, -61, -61, -5, -5,
- 69, -61, 83, -61, -61, -61, 72, -61, -61
-};
-
-/* YYPGOTO[NTERM-NUM]. */
-static const yytype_int8 yypgoto[] =
-{
- -61, -61, 92, -61, -61, 85, -24, 18, -61, 73,
- -61, -61, 65, -61, -61, -61, -61, 16, -19, -18,
- -17, -26, -38, -10, -9, -30, -28, -61, -61, -60,
- -61, 3, -61, -61, -37, -61, 86, -61
-};
-
-/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
- positive, shift that token. If negative, reduce the rule which
- number is the opposite. If zero, do what YYDEFACT says.
- If YYTABLE_NINF, syntax error. */
-#define YYTABLE_NINF -1
-static const yytype_uint8 yytable[] =
-{
- 34, 35, 36, 64, 56, 39, 57, 18, 53, 19,
- 25, 95, 39, 40, 41, 60, 80, 56, 65, 57,
- 99, 53, 69, 61, 43, 44, 45, 25, 26, 39,
- 40, 41, 42, 62, 1, 81, 8, 82, 27, 15,
- 99, 43, 44, 45, 94, 95, 27, 46, 91, 9,
- 92, 5, 6, 96, 91, 97, 92, 107, 12, 86,
- 87, 88, 24, 25, 26, 86, 87, 88, 89, 90,
- 106, 114, 115, 12, 89, 90, 73, 74, 75, 76,
- 77, 22, 33, 38, 59, 79, 66, 67, 71, 105,
- 68, 72, 103, 112, 116, 113, 11, 117, 118, 21,
- 104, 37, 23, 111, 0, 0, 0, 0, 0, 0,
- 0, 0, 70
-};
-
-static const yytype_int8 yycheck[] =
-{
- 24, 25, 26, 41, 34, 10, 34, 29, 34, 31,
- 8, 16, 10, 11, 12, 39, 14, 47, 42, 47,
- 80, 47, 46, 17, 22, 23, 24, 8, 9, 10,
- 11, 12, 13, 27, 4, 33, 0, 35, 20, 29,
- 100, 22, 23, 24, 15, 16, 28, 28, 78, 37,
- 78, 5, 6, 24, 84, 26, 84, 95, 3, 78,
- 78, 78, 7, 8, 9, 84, 84, 84, 78, 78,
- 94, 108, 109, 3, 84, 84, 17, 18, 19, 20,
- 21, 36, 29, 25, 3, 7, 30, 30, 25, 25,
- 30, 30, 30, 25, 25, 13, 4, 14, 26, 14,
- 84, 28, 16, 100, -1, -1, -1, -1, -1, -1,
- -1, -1, 47
-};
-
-/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
- symbol of state STATE-NUM. */
-static const yytype_uint8 yystos[] =
-{
- 0, 4, 39, 40, 41, 5, 6, 42, 0, 37,
- 75, 40, 3, 43, 45, 29, 73, 74, 29, 31,
- 44, 43, 36, 74, 7, 8, 9, 45, 46, 47,
- 48, 59, 64, 29, 44, 44, 44, 47, 25, 10,
- 11, 12, 13, 22, 23, 24, 28, 49, 50, 52,
- 56, 57, 58, 59, 61, 62, 63, 64, 70, 3,
- 44, 17, 27, 60, 60, 44, 30, 30, 30, 44,
- 50, 25, 30, 17, 18, 19, 20, 21, 51, 7,
- 14, 33, 35, 53, 54, 55, 56, 57, 58, 61,
- 62, 63, 64, 65, 15, 16, 24, 26, 66, 67,
- 68, 69, 71, 30, 55, 25, 44, 60, 63, 67,
- 72, 69, 25, 13, 72, 72, 25, 14, 26
-};
-
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY (-2)
-#define YYEOF 0
-
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrorlab
-
-
-/* Like YYERROR except do call yyerror. This remains here temporarily
- to ease the transition to the new meaning of YYERROR, for GCC.
- Once GCC version 2 has supplanted version 1, this can go. */
-
-#define YYFAIL goto yyerrlab
-
-#define YYRECOVERING() (!!yyerrstatus)
-
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY && yylen == 1) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- yytoken = YYTRANSLATE (yychar); \
- YYPOPSTACK (1); \
- goto yybackup; \
- } \
- else \
- { \
- yyerror (YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (YYID (0))
-
-
-#define YYTERROR 1
-#define YYERRCODE 256
-
-
-/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
- If N is 0, then set CURRENT to the empty location which ends
- the previous symbol: RHS[0] (always defined). */
-
-#define YYRHSLOC(Rhs, K) ((Rhs)[K])
-#ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(Current, Rhs, N) \
- do \
- if (YYID (N)) \
- { \
- (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
- (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
- (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
- (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
- } \
- else \
- { \
- (Current).first_line = (Current).last_line = \
- YYRHSLOC (Rhs, 0).last_line; \
- (Current).first_column = (Current).last_column = \
- YYRHSLOC (Rhs, 0).last_column; \
- } \
- while (YYID (0))
-#endif
-
-
-/* YY_LOCATION_PRINT -- Print the location on the stream.
- This macro was not mandated originally: define only if we know
- we won't break user code: when these are the locations we know. */
-
-#ifndef YY_LOCATION_PRINT
-# if YYLTYPE_IS_TRIVIAL
-# define YY_LOCATION_PRINT(File, Loc) \
- fprintf (File, "%d.%d-%d.%d", \
- (Loc).first_line, (Loc).first_column, \
- (Loc).last_line, (Loc).last_column)
-# else
-# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
-# endif
-#endif
-
-
-/* YYLEX -- calling `yylex' with the right arguments. */
-
-#ifdef YYLEX_PARAM
-# define YYLEX yylex (YYLEX_PARAM)
-#else
-# define YYLEX yylex ()
-#endif
-
-/* Enable debugging if requested. */
-#if YYDEBUG
-
-# ifndef YYFPRINTF
-# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
-# define YYFPRINTF fprintf
-# endif
-
-# define YYDPRINTF(Args) \
-do { \
- if (yydebug) \
- YYFPRINTF Args; \
-} while (YYID (0))
-
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
-do { \
- if (yydebug) \
- { \
- YYFPRINTF (stderr, "%s ", Title); \
- yy_symbol_print (stderr, \
- Type, Value); \
- YYFPRINTF (stderr, "\n"); \
- } \
-} while (YYID (0))
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-/*ARGSUSED*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-#else
-static void
-yy_symbol_value_print (yyoutput, yytype, yyvaluep)
- FILE *yyoutput;
- int yytype;
- YYSTYPE const * const yyvaluep;
-#endif
-{
- if (!yyvaluep)
- return;
-# ifdef YYPRINT
- if (yytype < YYNTOKENS)
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# else
- YYUSE (yyoutput);
-# endif
- switch (yytype)
- {
- default:
- break;
- }
-}
-
-
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
-#else
-static void
-yy_symbol_print (yyoutput, yytype, yyvaluep)
- FILE *yyoutput;
- int yytype;
- YYSTYPE const * const yyvaluep;
-#endif
-{
- if (yytype < YYNTOKENS)
- YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
- else
- YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
-
- yy_symbol_value_print (yyoutput, yytype, yyvaluep);
- YYFPRINTF (yyoutput, ")");
-}
-
-/*------------------------------------------------------------------.
-| yy_stack_print -- Print the state stack from its BOTTOM up to its |
-| TOP (included). |
-`------------------------------------------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
-#else
-static void
-yy_stack_print (bottom, top)
- yytype_int16 *bottom;
- yytype_int16 *top;
-#endif
-{
- YYFPRINTF (stderr, "Stack now");
- for (; bottom <= top; ++bottom)
- YYFPRINTF (stderr, " %d", *bottom);
- YYFPRINTF (stderr, "\n");
-}
-
-# define YY_STACK_PRINT(Bottom, Top) \
-do { \
- if (yydebug) \
- yy_stack_print ((Bottom), (Top)); \
-} while (YYID (0))
-
-
-/*------------------------------------------------.
-| Report that the YYRULE is going to be reduced. |
-`------------------------------------------------*/
-
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
-#else
-static void
-yy_reduce_print (yyvsp, yyrule)
- YYSTYPE *yyvsp;
- int yyrule;
-#endif
-{
- int yynrhs = yyr2[yyrule];
- int yyi;
- unsigned long int yylno = yyrline[yyrule];
- YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
- yyrule - 1, yylno);
- /* The symbols being reduced. */
- for (yyi = 0; yyi < yynrhs; yyi++)
- {
- fprintf (stderr, " $%d = ", yyi + 1);
- yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
- &(yyvsp[(yyi + 1) - (yynrhs)])
- );
- fprintf (stderr, "\n");
- }
-}
-
-# define YY_REDUCE_PRINT(Rule) \
-do { \
- if (yydebug) \
- yy_reduce_print (yyvsp, Rule); \
-} while (YYID (0))
-
-/* Nonzero means print parse trace. It is left uninitialized so that
- multiple parsers can coexist. */
-int yydebug;
-#else /* !YYDEBUG */
-# define YYDPRINTF(Args)
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
-# define YY_STACK_PRINT(Bottom, Top)
-# define YY_REDUCE_PRINT(Rule)
-#endif /* !YYDEBUG */
-
-
-/* YYINITDEPTH -- initial size of the parser's stacks. */
-#ifndef YYINITDEPTH
-# define YYINITDEPTH 200
-#endif
-
-/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
- if the built-in stack extension method is used).
-
- Do not make this value too large; the results are undefined if
- YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
- evaluated with infinite-precision integer arithmetic. */
-
-#ifndef YYMAXDEPTH
-# define YYMAXDEPTH 10000
-#endif
-
-
-
-#if YYERROR_VERBOSE
-
-# ifndef yystrlen
-# if defined __GLIBC__ && defined _STRING_H
-# define yystrlen strlen
-# else
-/* Return the length of YYSTR. */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static YYSIZE_T
-yystrlen (const char *yystr)
-#else
-static YYSIZE_T
-yystrlen (yystr)
- const char *yystr;
-#endif
-{
- YYSIZE_T yylen;
- for (yylen = 0; yystr[yylen]; yylen++)
- continue;
- return yylen;
-}
-# endif
-# endif
-
-# ifndef yystpcpy
-# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
-# define yystpcpy stpcpy
-# else
-/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
- YYDEST. */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static char *
-yystpcpy (char *yydest, const char *yysrc)
-#else
-static char *
-yystpcpy (yydest, yysrc)
- char *yydest;
- const char *yysrc;
-#endif
-{
- char *yyd = yydest;
- const char *yys = yysrc;
-
- while ((*yyd++ = *yys++) != '\0')
- continue;
-
- return yyd - 1;
-}
-# endif
-# endif
-
-# ifndef yytnamerr
-/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
- quotes and backslashes, so that it's suitable for yyerror. The
- heuristic is that double-quoting is unnecessary unless the string
- contains an apostrophe, a comma, or backslash (other than
- backslash-backslash). YYSTR is taken from yytname. If YYRES is
- null, do not copy; instead, return the length of what the result
- would have been. */
-static YYSIZE_T
-yytnamerr (char *yyres, const char *yystr)
-{
- if (*yystr == '"')
- {
- YYSIZE_T yyn = 0;
- char const *yyp = yystr;
-
- for (;;)
- switch (*++yyp)
- {
- case '\'':
- case ',':
- goto do_not_strip_quotes;
-
- case '\\':
- if (*++yyp != '\\')
- goto do_not_strip_quotes;
- /* Fall through. */
- default:
- if (yyres)
- yyres[yyn] = *yyp;
- yyn++;
- break;
-
- case '"':
- if (yyres)
- yyres[yyn] = '\0';
- return yyn;
- }
- do_not_strip_quotes: ;
- }
-
- if (! yyres)
- return yystrlen (yystr);
-
- return yystpcpy (yyres, yystr) - yyres;
-}
-# endif
-
-/* Copy into YYRESULT an error message about the unexpected token
- YYCHAR while in state YYSTATE. Return the number of bytes copied,
- including the terminating null byte. If YYRESULT is null, do not
- copy anything; just return the number of bytes that would be
- copied. As a special case, return 0 if an ordinary "syntax error"
- message will do. Return YYSIZE_MAXIMUM if overflow occurs during
- size calculation. */
-static YYSIZE_T
-yysyntax_error (char *yyresult, int yystate, int yychar)
-{
- int yyn = yypact[yystate];
-
- if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
- return 0;
- else
- {
- int yytype = YYTRANSLATE (yychar);
- YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
- YYSIZE_T yysize = yysize0;
- YYSIZE_T yysize1;
- int yysize_overflow = 0;
- enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
- char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
- int yyx;
-
-# if 0
- /* This is so xgettext sees the translatable formats that are
- constructed on the fly. */
- YY_("syntax error, unexpected %s");
- YY_("syntax error, unexpected %s, expecting %s");
- YY_("syntax error, unexpected %s, expecting %s or %s");
- YY_("syntax error, unexpected %s, expecting %s or %s or %s");
- YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
-# endif
- char *yyfmt;
- char const *yyf;
- static char const yyunexpected[] = "syntax error, unexpected %s";
- static char const yyexpecting[] = ", expecting %s";
- static char const yyor[] = " or %s";
- char yyformat[sizeof yyunexpected
- + sizeof yyexpecting - 1
- + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
- * (sizeof yyor - 1))];
- char const *yyprefix = yyexpecting;
-
- /* Start YYX at -YYN if negative to avoid negative indexes in
- YYCHECK. */
- int yyxbegin = yyn < 0 ? -yyn : 0;
-
- /* Stay within bounds of both yycheck and yytname. */
- int yychecklim = YYLAST - yyn + 1;
- int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
- int yycount = 1;
-
- yyarg[0] = yytname[yytype];
- yyfmt = yystpcpy (yyformat, yyunexpected);
-
- for (yyx = yyxbegin; yyx < yyxend; ++yyx)
- if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
- {
- if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
- {
- yycount = 1;
- yysize = yysize0;
- yyformat[sizeof yyunexpected - 1] = '\0';
- break;
- }
- yyarg[yycount++] = yytname[yyx];
- yysize1 = yysize + yytnamerr (0, yytname[yyx]);
- yysize_overflow |= (yysize1 < yysize);
- yysize = yysize1;
- yyfmt = yystpcpy (yyfmt, yyprefix);
- yyprefix = yyor;
- }
-
- yyf = YY_(yyformat);
- yysize1 = yysize + yystrlen (yyf);
- yysize_overflow |= (yysize1 < yysize);
- yysize = yysize1;
-
- if (yysize_overflow)
- return YYSIZE_MAXIMUM;
-
- if (yyresult)
- {
- /* Avoid sprintf, as that infringes on the user's name space.
- Don't have undefined behavior even if the translation
- produced a string with the wrong number of "%s"s. */
- char *yyp = yyresult;
- int yyi = 0;
- while ((*yyp = *yyf) != '\0')
- {
- if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
- {
- yyp += yytnamerr (yyp, yyarg[yyi++]);
- yyf += 2;
- }
- else
- {
- yyp++;
- yyf++;
- }
- }
- }
- return yysize;
- }
-}
-#endif /* YYERROR_VERBOSE */
-
-
-/*-----------------------------------------------.
-| Release the memory associated to this symbol. |
-`-----------------------------------------------*/
-
-/*ARGSUSED*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-static void
-yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
-#else
-static void
-yydestruct (yymsg, yytype, yyvaluep)
- const char *yymsg;
- int yytype;
- YYSTYPE *yyvaluep;
-#endif
-{
- YYUSE (yyvaluep);
-
- if (!yymsg)
- yymsg = "Deleting";
- YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
-
- switch (yytype)
- {
-
- default:
- break;
- }
-}
-
-
-/* Prevent warnings from -Wmissing-prototypes. */
-
-#ifdef YYPARSE_PARAM
-#if defined __STDC__ || defined __cplusplus
-int yyparse (void *YYPARSE_PARAM);
-#else
-int yyparse ();
-#endif
-#else /* ! YYPARSE_PARAM */
-#if defined __STDC__ || defined __cplusplus
-int yyparse (void);
-#else
-int yyparse ();
-#endif
-#endif /* ! YYPARSE_PARAM */
-
-
-
-/* The look-ahead symbol. */
-int yychar;
-
-/* The semantic value of the look-ahead symbol. */
-YYSTYPE yylval;
-
-/* Number of syntax errors so far. */
-int yynerrs;
-
-
-
-/*----------.
-| yyparse. |
-`----------*/
-
-#ifdef YYPARSE_PARAM
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-int
-yyparse (void *YYPARSE_PARAM)
-#else
-int
-yyparse (YYPARSE_PARAM)
- void *YYPARSE_PARAM;
-#endif
-#else /* ! YYPARSE_PARAM */
-#if (defined __STDC__ || defined __C99__FUNC__ \
- || defined __cplusplus || defined _MSC_VER)
-int
-yyparse (void)
-#else
-int
-yyparse ()
-
-#endif
-#endif
-{
-
- int yystate;
- int yyn;
- int yyresult;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
- /* Look-ahead token as an internal (translated) token number. */
- int yytoken = 0;
-#if YYERROR_VERBOSE
- /* Buffer for error messages, and its allocated size. */
- char yymsgbuf[128];
- char *yymsg = yymsgbuf;
- YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
-#endif
-
- /* Three stacks and their tools:
- `yyss': related to states,
- `yyvs': related to semantic values,
- `yyls': related to locations.
-
- Refer to the stacks thru separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
-
- /* The state stack. */
- yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyss = yyssa;
- yytype_int16 *yyssp;
-
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs = yyvsa;
- YYSTYPE *yyvsp;
-
-
-
-#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
-
- YYSIZE_T yystacksize = YYINITDEPTH;
-
- /* The variables used to return semantic value and location from the
- action routines. */
- YYSTYPE yyval;
-
-
- /* The number of symbols on the RHS of the reduced rule.
- Keep to zero when no symbol should be popped. */
- int yylen = 0;
-
- YYDPRINTF ((stderr, "Starting parse\n"));
-
- yystate = 0;
- yyerrstatus = 0;
- yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
-
- /* Initialize stack pointers.
- Waste one element of value and location stack
- so that they stay on the same level as the state stack.
- The wasted elements are never initialized. */
-
- yyssp = yyss;
- yyvsp = yyvs;
-
- goto yysetstate;
-
-/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
-`------------------------------------------------------------*/
- yynewstate:
- /* In all cases, when you get here, the value and location stacks
- have just been pushed. So pushing a state here evens the stacks. */
- yyssp++;
-
- yysetstate:
- *yyssp = yystate;
-
- if (yyss + yystacksize - 1 <= yyssp)
- {
- /* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
-
-#ifdef yyoverflow
- {
- /* Give user a chance to reallocate the stack. Use copies of
- these so that the &'s don't force the real ones into
- memory. */
- YYSTYPE *yyvs1 = yyvs;
- yytype_int16 *yyss1 = yyss;
-
-
- /* Each stack pointer address is followed by the size of the
- data in use in that stack, in bytes. This used to be a
- conditional around just the two extra args, but that might
- be undefined if yyoverflow is a macro. */
- yyoverflow (YY_("memory exhausted"),
- &yyss1, yysize * sizeof (*yyssp),
- &yyvs1, yysize * sizeof (*yyvsp),
-
- &yystacksize);
-
- yyss = yyss1;
- yyvs = yyvs1;
- }
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyexhaustedlab;
-# else
- /* Extend the stack our own way. */
- if (YYMAXDEPTH <= yystacksize)
- goto yyexhaustedlab;
- yystacksize *= 2;
- if (YYMAXDEPTH < yystacksize)
- yystacksize = YYMAXDEPTH;
-
- {
- yytype_int16 *yyss1 = yyss;
- union yyalloc *yyptr =
- (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
- if (! yyptr)
- goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss);
- YYSTACK_RELOCATE (yyvs);
-
-# undef YYSTACK_RELOCATE
- if (yyss1 != yyssa)
- YYSTACK_FREE (yyss1);
- }
-# endif
-#endif /* no yyoverflow */
-
- yyssp = yyss + yysize - 1;
- yyvsp = yyvs + yysize - 1;
-
-
- YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
-
- if (yyss + yystacksize - 1 <= yyssp)
- YYABORT;
- }
-
- YYDPRINTF ((stderr, "Entering state %d\n", yystate));
-
- goto yybackup;
-
-/*-----------.
-| yybackup. |
-`-----------*/
-yybackup:
-
- /* Do appropriate processing given the current state. Read a
- look-ahead token if we need one and don't already have one. */
-
- /* First try to decide what to do without reference to look-ahead token. */
- yyn = yypact[yystate];
- if (yyn == YYPACT_NINF)
- goto yydefault;
-
- /* Not known => get a look-ahead token if don't already have one. */
-
- /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
- if (yychar == YYEMPTY)
- {
- YYDPRINTF ((stderr, "Reading a token: "));
- yychar = YYLEX;
- }
-
- if (yychar <= YYEOF)
- {
- yychar = yytoken = YYEOF;
- YYDPRINTF ((stderr, "Now at end of input.\n"));
- }
- else
- {
- yytoken = YYTRANSLATE (yychar);
- YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
- }
-
- /* If the proper action on seeing token YYTOKEN is to reduce or to
- detect an error, take that action. */
- yyn += yytoken;
- if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
- goto yydefault;
- yyn = yytable[yyn];
- if (yyn <= 0)
- {
- if (yyn == 0 || yyn == YYTABLE_NINF)
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
- }
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- /* Count tokens shifted since error; after three, turn off error
- status. */
- if (yyerrstatus)
- yyerrstatus--;
-
- /* Shift the look-ahead token. */
- YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
-
- /* Discard the shifted token unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
-
- yystate = yyn;
- *++yyvsp = yylval;
-
- goto yynewstate;
-
-
-/*-----------------------------------------------------------.
-| yydefault -- do the default action for the current state. |
-`-----------------------------------------------------------*/
-yydefault:
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
- goto yyreduce;
-
-
-/*-----------------------------.
-| yyreduce -- Do a reduction. |
-`-----------------------------*/
-yyreduce:
- /* yyn is the number of a rule to reduce with. */
- yylen = yyr2[yyn];
-
- /* If YYLEN is nonzero, implement the default value of the action:
- `$$ = $1'.
-
- Otherwise, the following line sets YYVAL to garbage.
- This behavior is undocumented and Bison
- users should not rely upon it. Assigning to YYVAL
- unconditionally makes the parser a bit smaller, and it avoids a
- GCC warning that YYVAL may be used uninitialized. */
- yyval = yyvsp[1-yylen];
-
-
- YY_REDUCE_PRINT (yyn);
- switch (yyn)
- {
-
-/* Line 1267 of yacc.c. */
-#line 1502 "lib/policy/parse_adm.y"
- default: break;
- }
- YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
-
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
-
- *++yyvsp = yyval;
-
-
- /* Now `shift' the result of the reduction. Determine what state
- that goes to, based on the state we popped back to and the rule
- number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
-
- goto yynewstate;
-
-
-/*------------------------------------.
-| yyerrlab -- here on detecting error |
-`------------------------------------*/
-yyerrlab:
- /* If not already recovering from an error, report this error. */
- if (!yyerrstatus)
- {
- ++yynerrs;
-#if ! YYERROR_VERBOSE
- yyerror (YY_("syntax error"));
-#else
- {
- YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
- if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
- {
- YYSIZE_T yyalloc = 2 * yysize;
- if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
- yyalloc = YYSTACK_ALLOC_MAXIMUM;
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
- yymsg = (char *) YYSTACK_ALLOC (yyalloc);
- if (yymsg)
- yymsg_alloc = yyalloc;
- else
- {
- yymsg = yymsgbuf;
- yymsg_alloc = sizeof yymsgbuf;
- }
- }
-
- if (0 < yysize && yysize <= yymsg_alloc)
- {
- (void) yysyntax_error (yymsg, yystate, yychar);
- yyerror (yymsg);
- }
- else
- {
- yyerror (YY_("syntax error"));
- if (yysize != 0)
- goto yyexhaustedlab;
- }
- }
-#endif
- }
-
-
-
- if (yyerrstatus == 3)
- {
- /* If just tried and failed to reuse look-ahead token after an
- error, discard it. */
-
- if (yychar <= YYEOF)
- {
- /* Return failure if at end of input. */
- if (yychar == YYEOF)
- YYABORT;
- }
- else
- {
- yydestruct ("Error: discarding",
- yytoken, &yylval);
- yychar = YYEMPTY;
- }
- }
-
- /* Else will try to reuse look-ahead token after shifting the error
- token. */
- goto yyerrlab1;
-
-
-/*---------------------------------------------------.
-| yyerrorlab -- error raised explicitly by YYERROR. |
-`---------------------------------------------------*/
-yyerrorlab:
-
- /* Pacify compilers like GCC when the user code never invokes
- YYERROR and the label yyerrorlab therefore never appears in user
- code. */
- if (/*CONSTCOND*/ 0)
- goto yyerrorlab;
-
- /* Do not reclaim the symbols of the rule which action triggered
- this YYERROR. */
- YYPOPSTACK (yylen);
- yylen = 0;
- YY_STACK_PRINT (yyss, yyssp);
- yystate = *yyssp;
- goto yyerrlab1;
-
-
-/*-------------------------------------------------------------.
-| yyerrlab1 -- common code for both syntax error and YYERROR. |
-`-------------------------------------------------------------*/
-yyerrlab1:
- yyerrstatus = 3; /* Each real token shifted decrements this. */
-
- for (;;)
- {
- yyn = yypact[yystate];
- if (yyn != YYPACT_NINF)
- {
- yyn += YYTERROR;
- if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
- {
- yyn = yytable[yyn];
- if (0 < yyn)
- break;
- }
- }
-
- /* Pop the current state because it cannot handle the error token. */
- if (yyssp == yyss)
- YYABORT;
-
-
- yydestruct ("Error: popping",
- yystos[yystate], yyvsp);
- YYPOPSTACK (1);
- yystate = *yyssp;
- YY_STACK_PRINT (yyss, yyssp);
- }
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- *++yyvsp = yylval;
-
-
- /* Shift the error token. */
- YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
-
- yystate = yyn;
- goto yynewstate;
-
-
-/*-------------------------------------.
-| yyacceptlab -- YYACCEPT comes here. |
-`-------------------------------------*/
-yyacceptlab:
- yyresult = 0;
- goto yyreturn;
-
-/*-----------------------------------.
-| yyabortlab -- YYABORT comes here. |
-`-----------------------------------*/
-yyabortlab:
- yyresult = 1;
- goto yyreturn;
-
-#ifndef yyoverflow
-/*-------------------------------------------------.
-| yyexhaustedlab -- memory exhaustion comes here. |
-`-------------------------------------------------*/
-yyexhaustedlab:
- yyerror (YY_("memory exhausted"));
- yyresult = 2;
- /* Fall through. */
-#endif
-
-yyreturn:
- if (yychar != YYEOF && yychar != YYEMPTY)
- yydestruct ("Cleanup: discarding lookahead",
- yytoken, &yylval);
- /* Do not reclaim the symbols of the rule which action triggered
- this YYABORT or YYACCEPT. */
- YYPOPSTACK (yylen);
- YY_STACK_PRINT (yyss, yyssp);
- while (yyssp != yyss)
- {
- yydestruct ("Cleanup: popping",
- yystos[*yyssp], yyvsp);
- YYPOPSTACK (1);
- }
-#ifndef yyoverflow
- if (yyss != yyssa)
- YYSTACK_FREE (yyss);
-#endif
-#if YYERROR_VERBOSE
- if (yymsg != yymsgbuf)
- YYSTACK_FREE (yymsg);
-#endif
- /* Make sure YYID is used. */
- return YYID (yyresult);
-}
-
-
-#line 129 "lib/policy/parse_adm.y"
-
-
-void
-yyerror (const char *s)
-{
- error_message ("%s\n", s);
-}
-
-
-
-
diff --git a/source4/lib/policy/parse_adm.h b/source4/lib/policy/parse_adm.h
deleted file mode 100644
index 372e4b9680..0000000000
--- a/source4/lib/policy/parse_adm.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/* A Bison parser, made by GNU Bison 2.3. */
-
-/* Skeleton interface for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
-
- 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 2, 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, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
-
-/* As a special exception, you may create a larger work that contains
- part or all of the Bison parser skeleton and distribute that work
- under terms of your choice, so long as that work isn't itself a
- parser generator using the skeleton or a modified version thereof
- as a parser skeleton. Alternatively, if you modify or redistribute
- the parser skeleton itself, you may (at your option) remove this
- special exception, which will cause the skeleton and the resulting
- Bison output files to be licensed under the GNU General Public
- License without this special exception.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- CATEGORY = 258,
- CLASS = 259,
- CLASS_USER = 260,
- CLASS_MACHINE = 261,
- POLICY = 262,
- KEYNAME = 263,
- EXPLAIN = 264,
- VALUENAME = 265,
- VALUEON = 266,
- VALUEOFF = 267,
- PART = 268,
- ITEMLIST = 269,
- NAME = 270,
- VALUE = 271,
- NUMERIC = 272,
- EDITTEXT = 273,
- TEXT = 274,
- DROPDOWNLIST = 275,
- CHECKBOX = 276,
- MINIMUM = 277,
- MAXIMUM = 278,
- DEFAULT = 279,
- END = 280,
- ACTIONLIST = 281,
- DEL = 282,
- SUPPORTED = 283,
- LITERAL = 284,
- INTEGER = 285,
- LOOKUPLITERAL = 286,
- CLIENTEXT = 287,
- REQUIRED = 288,
- NOSORT = 289,
- SPIN = 290,
- EQUALS = 291,
- STRINGSSECTION = 292
- };
-#endif
-/* Tokens. */
-#define CATEGORY 258
-#define CLASS 259
-#define CLASS_USER 260
-#define CLASS_MACHINE 261
-#define POLICY 262
-#define KEYNAME 263
-#define EXPLAIN 264
-#define VALUENAME 265
-#define VALUEON 266
-#define VALUEOFF 267
-#define PART 268
-#define ITEMLIST 269
-#define NAME 270
-#define VALUE 271
-#define NUMERIC 272
-#define EDITTEXT 273
-#define TEXT 274
-#define DROPDOWNLIST 275
-#define CHECKBOX 276
-#define MINIMUM 277
-#define MAXIMUM 278
-#define DEFAULT 279
-#define END 280
-#define ACTIONLIST 281
-#define DEL 282
-#define SUPPORTED 283
-#define LITERAL 284
-#define INTEGER 285
-#define LOOKUPLITERAL 286
-#define CLIENTEXT 287
-#define REQUIRED 288
-#define NOSORT 289
-#define SPIN 290
-#define EQUALS 291
-#define STRINGSSECTION 292
-
-
-
-
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE
-#line 33 "lib/policy/parse_adm.y"
-{
- char *text;
- int integer;
-}
-/* Line 1489 of yacc.c. */
-#line 128 "lib/policy/parse_adm.y"
- YYSTYPE;
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
-#endif
-
-extern YYSTYPE yylval;
-
diff --git a/source4/lib/policy/parse_adm.y b/source4/lib/policy/parse_adm.y
deleted file mode 100644
index 23c5e7730e..0000000000
--- a/source4/lib/policy/parse_adm.y
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Copyright (C) 2006 Wilco Baan Hofman <wilco@baanhofman.nl>
- Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- For more information on the .ADM file format:
- http://msdn2.microsoft.com/en-us/library/aa372405.aspx
-*/
-
-%{
-#include "config.h"
-void error_message (const char *format, ...);
-int yyparse (void);
-void yyerror (const char *s);
-extern int yylex (void);
-
-%}
-
-%union {
- char *text;
- int integer;
-}
-
-%token CATEGORY
-%token CLASS
-%token CLASS_USER
-%token CLASS_MACHINE
-%token POLICY
-%token KEYNAME
-%token EXPLAIN
-%token VALUENAME
-%token VALUEON VALUEOFF
-%token PART
-%token ITEMLIST
-%token NAME
-%token VALUE
-%token NUMERIC EDITTEXT TEXT DROPDOWNLIST CHECKBOX
-%token MINIMUM MAXIMUM DEFAULT
-%token END
-%token ACTIONLIST
-%token DEL
-%token SUPPORTED
-%token <text> LITERAL
-%token <integer> INTEGER
-%token <text> LOOKUPLITERAL
-%token CLIENTEXT
-%token REQUIRED
-%token NOSORT
-%token SPIN
-%token EQUALS
-%token STRINGSSECTION
-
-%start admfile
-
-%%
-
-admfile: classes strings;
-
-classes: /* empty */ | class classes;
-
-class: CLASS classvalue categories;
-classvalue: CLASS_USER|CLASS_MACHINE;
-
-categories: /* empty */ | category categories;
-
-string: LITERAL | LOOKUPLITERAL;
-
-category: CATEGORY string categoryitems END CATEGORY;
-
-categoryitem: explain | category | policy | keyname;
-categoryitems: categoryitem categoryitems | /* empty */ ;
-
-policy: POLICY string policyitems END POLICY;
-policyitem: explain | keyname | valuename | valueon | valueoff | min | max | defaultvalue | supported | part;
-policyitems: policyitem policyitems | /* empty */;
-
-valuetype: NUMERIC | EDITTEXT | TEXT | DROPDOWNLIST | CHECKBOX;
-
-part: PART string valuetype partitems END PART;
-
-spin: SPIN INTEGER;
-
-partitem: keyname | valuename | valueon | valueoff | min | max | defaultvalue | itemlist | REQUIRED | spin;
-partitems: partitem partitems | /* empty */;
-
-min: MINIMUM INTEGER;
-max: MAXIMUM INTEGER;
-defaultvalue: DEFAULT INTEGER;
-
-explain: EXPLAIN string;
-value: DEL | NUMERIC INTEGER;
-
-valueon: VALUEON value;
-valueoff: VALUEOFF value;
-
-valuename: VALUENAME string;
-keyname: KEYNAME string;
-
-itemlist: ITEMLIST items END ITEMLIST;
-itemname: NAME string;
-itemvalue: VALUE value;
-
-item: itemname | itemvalue | DEFAULT | actionlist;
-items: /* empty */ | item items;
-
-supported: SUPPORTED string;
-
-actionlist: ACTIONLIST actions END ACTIONLIST;
-actions: valuename actions | itemvalue actions | /* empty */;
-
-variable: LITERAL EQUALS LITERAL;
-variables: variable variables | /* empty */;
-strings: STRINGSSECTION variables;
-
-%%
-
-void
-yyerror (const char *s)
-{
- error_message ("%s\n", s);
-}
-
-
-
diff --git a/source4/lib/popt/config.mk b/source4/lib/popt/config.mk
index ad218517b3..86d440ac78 100644
--- a/source4/lib/popt/config.mk
+++ b/source4/lib/popt/config.mk
@@ -1,7 +1,5 @@
[SUBSYSTEM::LIBPOPT]
-OBJ_FILES = findme.o \
- popt.o \
- poptconfig.o \
- popthelp.o \
- poptparse.o
CFLAGS = -Ilib/popt
+
+LIBPOPT_OBJ_FILES = $(addprefix lib/popt/, findme.o popt.o poptconfig.o popthelp.o poptparse.o)
+
diff --git a/source4/lib/registry/config.mk b/source4/lib/registry/config.mk
index 77b4ece552..44adc53524 100644
--- a/source4/lib/registry/config.mk
+++ b/source4/lib/registry/config.mk
@@ -1,112 +1,115 @@
[SUBSYSTEM::TDR_REGF]
PUBLIC_DEPENDENCIES = TDR
-OBJ_FILES = tdr_regf.o
+
+TDR_REGF_OBJ_FILES = $(libregistrysrcdir)/tdr_regf.o
# Special support for external builddirs
-lib/registry/regf.c: lib/registry/tdr_regf.c
-$(srcdir)/lib/registry/regf.c: lib/registry/tdr_regf.c
-lib/registry/tdr_regf.h: lib/registry/tdr_regf.c
-lib/registry/tdr_regf.c: $(srcdir)/lib/registry/regf.idl
+$(libregistrysrcdir)/regf.c: $(libregistrysrcdir)/tdr_regf.c
+$(srcdir)/$(libregistrysrcdir)/regf.c: $(libregistrysrcdir)/tdr_regf.c
+$(libregistrysrcdir)/tdr_regf.h: $(libregistrysrcdir)/tdr_regf.c
+$(libregistrysrcdir)/tdr_regf.c: $(srcdir)/$(libregistrysrcdir)/regf.idl
@CPP="$(CPP)" srcdir="$(srcdir)" $(PERL) $(srcdir)/pidl/pidl $(PIDL_ARGS) \
--header --outputdir=lib/registry \
- --tdr-parser -- $(srcdir)/lib/registry/regf.idl
+ --tdr-parser -- $(srcdir)/$(libregistrysrcdir)/regf.idl
clean::
- @-rm -f lib/registry/regf.h lib/registry/tdr_regf*
+ @-rm -f $(libregistrysrcdir)/regf.h $(libregistrysrcdir)/tdr_regf*
################################################
# Start SUBSYSTEM registry
[LIBRARY::registry]
-VERSION = 0.0.1
-PC_FILE = registry.pc
-SO_VERSION = 0
-OBJ_FILES = \
- interface.o \
- util.o \
- samba.o \
- patchfile_dotreg.o \
- patchfile_preg.o \
- patchfile.o \
- regf.o \
- hive.o \
- local.o \
- ldb.o \
- dir.o \
- rpc.o
PUBLIC_DEPENDENCIES = \
LIBSAMBA-UTIL CHARSET TDR_REGF LIBLDB \
RPC_NDR_WINREG LDB_WRAP
# End MODULE registry_ldb
################################################
-PUBLIC_HEADERS += lib/registry/registry.h
+PC_FILES += $(libregistrysrcdir)/registry.pc
+
+registry_VERSION = 0.0.1
+registry_SOVERSION = 0
+
+registry_OBJ_FILES = $(addprefix $(libregistrysrcdir)/, interface.o util.o samba.o \
+ patchfile_dotreg.o patchfile_preg.o patchfile.o regf.o \
+ hive.o local.o ldb.o dir.o rpc.o)
+
+PUBLIC_HEADERS += $(libregistrysrcdir)/registry.h
[SUBSYSTEM::registry_common]
PUBLIC_DEPENDENCIES = registry
-OBJ_FILES = tools/common.o
-PRIVATE_PROTO_HEADER = tools/common.h
+
+registry_common_OBJ_FILES = $(libregistrysrcdir)/tools/common.o
+
+$(eval $(call proto_header_template,$(libregistrysrcdir)/tools/common.h,$(registry_common_OBJ_FILES:.o=.c)))
################################################
# Start BINARY regdiff
[BINARY::regdiff]
INSTALLDIR = BINDIR
-OBJ_FILES = tools/regdiff.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-HOSTCONFIG registry LIBPOPT POPT_SAMBA POPT_CREDENTIALS
# End BINARY regdiff
################################################
-MANPAGES += lib/registry/man/regdiff.1
+regdiff_OBJ_FILES = $(libregistrysrcdir)/tools/regdiff.o
+
+MANPAGES += $(libregistrysrcdir)/man/regdiff.1
################################################
# Start BINARY regpatch
[BINARY::regpatch]
INSTALLDIR = BINDIR
-OBJ_FILES = tools/regpatch.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-HOSTCONFIG registry LIBPOPT POPT_SAMBA POPT_CREDENTIALS \
registry_common
# End BINARY regpatch
################################################
-MANPAGES += lib/registry/man/regpatch.1
+regpatch_OBJ_FILES = $(libregistrysrcdir)/tools/regpatch.o
+
+MANPAGES += $(libregistrysrcdir)/man/regpatch.1
################################################
# Start BINARY regshell
[BINARY::regshell]
INSTALLDIR = BINDIR
-OBJ_FILES = tools/regshell.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-HOSTCONFIG LIBPOPT registry POPT_SAMBA POPT_CREDENTIALS \
SMBREADLINE registry_common
# End BINARY regshell
################################################
-MANPAGES += lib/registry/man/regshell.1
+regshell_OBJ_FILES = $(libregistrysrcdir)/tools/regshell.o
+
+MANPAGES += $(libregistrysrcdir)/man/regshell.1
################################################
# Start BINARY regtree
[BINARY::regtree]
INSTALLDIR = BINDIR
-OBJ_FILES = tools/regtree.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-HOSTCONFIG LIBPOPT registry POPT_SAMBA POPT_CREDENTIALS \
registry_common
# End BINARY regtree
################################################
-MANPAGES += lib/registry/man/regtree.1
+regtree_OBJ_FILES = $(libregistrysrcdir)/tools/regtree.o
+
+MANPAGES += $(libregistrysrcdir)/man/regtree.1
[SUBSYSTEM::torture_registry]
PRIVATE_DEPENDENCIES = registry
-PRIVATE_PROTO_HEADER = tests/proto.h
-OBJ_FILES = \
- tests/generic.o \
- tests/hive.o \
- tests/diff.o \
- tests/registry.o
+
+torture_registry_OBJ_FILES = $(addprefix $(libregistrysrcdir)/tests/, generic.o hive.o diff.o registry.o)
+
+$(eval $(call proto_header_template,$(libregistrysrcdir)/tests/proto.h,$(torture_registry_OBJ_FILES:.o=.c)))
[PYTHON::swig_registry]
+LIBRARY_REALNAME = samba/_registry.$(SHLIBEXT)
PUBLIC_DEPENDENCIES = registry
-SWIG_FILE = registry.i
+swig_registry_OBJ_FILES = $(libregistrysrcdir)/registry_wrap.o
+
+$(eval $(call python_py_module_template,samba/registry.py,lib/registry/registry.py))
+
+$(swig_registry_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
diff --git a/source4/lib/registry/hive.c b/source4/lib/registry/hive.c
index 2a9b1a59ce..5105040f30 100644
--- a/source4/lib/registry/hive.c
+++ b/source4/lib/registry/hive.c
@@ -28,6 +28,7 @@
_PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
struct auth_session_info *session_info,
struct cli_credentials *credentials,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
struct hive_key **root)
{
@@ -57,7 +58,7 @@ _PUBLIC_ WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
} else if (!strncmp(peek, "TDB file", 8)) {
close(fd);
return reg_open_ldb_file(parent_ctx, location, session_info,
- credentials, lp_ctx, root);
+ credentials, ev_ctx, lp_ctx, root);
}
return WERR_BADFILE;
@@ -143,6 +144,24 @@ WERROR hive_get_value_by_index(TALLOC_CTX *mem_ctx,
return key->ops->enum_value(mem_ctx, key, idx, name, type, data);
}
+WERROR hive_get_sec_desc(TALLOC_CTX *mem_ctx,
+ struct hive_key *key,
+ struct security_descriptor **security)
+{
+ if (key->ops->get_sec_desc == NULL)
+ return WERR_NOT_SUPPORTED;
+
+ return key->ops->get_sec_desc(mem_ctx, key, security);
+}
+
+WERROR hive_set_sec_desc(struct hive_key *key,
+ const struct security_descriptor *security)
+{
+ if (key->ops->set_sec_desc == NULL)
+ return WERR_NOT_SUPPORTED;
+
+ return key->ops->set_sec_desc(key, security);
+}
WERROR hive_key_del_value(struct hive_key *key, const char *name)
{
diff --git a/source4/lib/registry/interface.c b/source4/lib/registry/interface.c
index a18fd2c28c..c9b3b06447 100644
--- a/source4/lib/registry/interface.c
+++ b/source4/lib/registry/interface.c
@@ -21,7 +21,6 @@
#include "lib/util/dlinklist.h"
#include "lib/registry/registry.h"
#include "system/filesys.h"
-#include "build.h"
/**
@@ -249,10 +248,10 @@ _PUBLIC_ WERROR reg_get_sec_desc(TALLOC_CTX *ctx,
return WERR_INVALID_PARAM;
/* A 'real' set function has preference */
- if (key->context->ops->get_security == NULL)
+ if (key->context->ops->get_sec_desc == NULL)
return WERR_NOT_SUPPORTED;
- return key->context->ops->get_security(ctx, key, secdesc);
+ return key->context->ops->get_sec_desc(ctx, key, secdesc);
}
/**
@@ -283,27 +282,14 @@ _PUBLIC_ WERROR reg_key_flush(struct registry_key *key)
return key->context->ops->flush_key(key);
}
-_PUBLIC_ WERROR reg_get_security(TALLOC_CTX *mem_ctx,
- const struct registry_key *key,
- struct security_descriptor **security)
-{
- if (key == NULL)
- return WERR_INVALID_PARAM;
-
- if (key->context->ops->get_security == NULL)
- return WERR_NOT_SUPPORTED;
-
- return key->context->ops->get_security(mem_ctx, key, security);
-}
-
-_PUBLIC_ WERROR reg_set_security(struct registry_key *key,
- struct security_descriptor *security)
+_PUBLIC_ WERROR reg_set_sec_desc(struct registry_key *key,
+ const struct security_descriptor *security)
{
if (key == NULL)
return WERR_INVALID_PARAM;
- if (key->context->ops->set_security == NULL)
+ if (key->context->ops->set_sec_desc == NULL)
return WERR_NOT_SUPPORTED;
- return key->context->ops->set_security(key, security);
+ return key->context->ops->set_sec_desc(key, security);
}
diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c
index a764ca6235..a8a9ed597e 100644
--- a/source4/lib/registry/ldb.c
+++ b/source4/lib/registry/ldb.c
@@ -357,6 +357,7 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h,
WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
struct auth_session_info *session_info,
struct cli_credentials *credentials,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
struct hive_key **k)
{
@@ -367,7 +368,7 @@ WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
if (location == NULL)
return WERR_INVALID_PARAM;
- wrap = ldb_wrap_connect(parent_ctx, lp_ctx,
+ wrap = ldb_wrap_connect(parent_ctx, ev_ctx, lp_ctx,
location, session_info, credentials, 0, NULL);
if (wrap == NULL) {
diff --git a/source4/lib/registry/local.c b/source4/lib/registry/local.c
index 5bf2d86588..4af95e2dd6 100644
--- a/source4/lib/registry/local.c
+++ b/source4/lib/registry/local.c
@@ -22,7 +22,6 @@
#include "lib/util/dlinklist.h"
#include "lib/registry/registry.h"
#include "system/filesys.h"
-#include "build.h"
struct reg_key_path {
uint32_t predefined_key;
@@ -37,9 +36,6 @@ struct registry_local {
struct hive_key *key;
struct mountpoint *prev, *next;
} *mountpoints;
-
- struct auth_session_info *session_info;
- struct cli_credentials *credentials;
};
struct local_key {
@@ -278,7 +274,21 @@ static WERROR local_get_key_info(TALLOC_CTX *mem_ctx,
last_change_time, max_subkeynamelen,
max_valnamelen, max_valbufsize);
}
+static WERROR local_get_sec_desc(TALLOC_CTX *mem_ctx,
+ const struct registry_key *key,
+ struct security_descriptor **security)
+{
+ const struct local_key *local = (const struct local_key *)key;
+
+ return hive_get_sec_desc(mem_ctx, local->hive_key, security);
+}
+static WERROR local_set_sec_desc(struct registry_key *key,
+ const struct security_descriptor *security)
+{
+ const struct local_key *local = (const struct local_key *)key;
+ return hive_set_sec_desc(local->hive_key, security);
+}
const static struct registry_operations local_ops = {
.name = "local",
.open_key = local_open_key,
@@ -292,11 +302,11 @@ const static struct registry_operations local_ops = {
.delete_value = local_delete_value,
.flush_key = local_flush_key,
.get_key_info = local_get_key_info,
+ .get_sec_desc = local_get_sec_desc,
+ .set_sec_desc = local_set_sec_desc,
};
-WERROR reg_open_local(TALLOC_CTX *mem_ctx, struct registry_context **ctx,
- struct auth_session_info *session_info,
- struct cli_credentials *credentials)
+WERROR reg_open_local(TALLOC_CTX *mem_ctx, struct registry_context **ctx)
{
struct registry_local *ret = talloc_zero(mem_ctx,
struct registry_local);
@@ -304,8 +314,6 @@ WERROR reg_open_local(TALLOC_CTX *mem_ctx, struct registry_context **ctx,
W_ERROR_HAVE_NO_MEMORY(ret);
ret->ops = &local_ops;
- ret->session_info = session_info;
- ret->credentials = credentials;
*ctx = (struct registry_context *)ret;
diff --git a/source4/lib/registry/patchfile.c b/source4/lib/registry/patchfile.c
index 15e3a158f2..0ede3106f0 100644
--- a/source4/lib/registry/patchfile.c
+++ b/source4/lib/registry/patchfile.c
@@ -45,7 +45,7 @@ WERROR reg_generate_diff_key(struct registry_key *oldkey,
void *callback_data)
{
int i;
- struct registry_key *t1, *t2;
+ struct registry_key *t1 = NULL, *t2 = NULL;
char *tmppath;
const char *keyname1;
WERROR error, error1, error2;
@@ -295,7 +295,7 @@ _PUBLIC_ WERROR reg_diff_load(const char *filename,
/* Reset position in file */
lseek(fd, 0, SEEK_SET);
-#if 0
+#if 0 /* These backends are not supported yet. */
if (strncmp(hdr, "CREG", 4) == 0) {
/* Must be a W9x CREG Config.pol file */
return reg_creg_diff_load(diff, fd);
@@ -320,12 +320,33 @@ static WERROR reg_diff_apply_add_key(void *_ctx, const char *key_name)
{
struct registry_context *ctx = (struct registry_context *)_ctx;
struct registry_key *tmp;
+ char *buf, *buf_ptr;
WERROR error;
+ /* Recursively create the path */
+ buf = talloc_strdup(ctx, key_name);
+ buf_ptr = buf;
+
+ while (*buf_ptr++ != '\0' ) {
+ if (*buf_ptr == '\\') {
+ *buf_ptr = '\0';
+ error = reg_key_add_abs(ctx, ctx, buf, 0, NULL, &tmp);
+
+ if (!W_ERROR_EQUAL(error, WERR_ALREADY_EXISTS) &&
+ !W_ERROR_IS_OK(error)) {
+ DEBUG(0, ("Error adding new key '%s': %s\n",
+ key_name, win_errstr(error)));
+ return error;
+ }
+ *buf_ptr++ = '\\';
+ }
+ }
+
+ /* Add the key */
error = reg_key_add_abs(ctx, ctx, key_name, 0, NULL, &tmp);
if (!W_ERROR_EQUAL(error, WERR_ALREADY_EXISTS) &&
- !W_ERROR_IS_OK(error)) {
+ !W_ERROR_IS_OK(error)) {
DEBUG(0, ("Error adding new key '%s': %s\n",
key_name, win_errstr(error)));
return error;
diff --git a/source4/lib/registry/patchfile_dotreg.c b/source4/lib/registry/patchfile_dotreg.c
index 59f4044713..1bc9c60753 100644
--- a/source4/lib/registry/patchfile_dotreg.c
+++ b/source4/lib/registry/patchfile_dotreg.c
@@ -3,7 +3,7 @@
Reading .REG files
Copyright (C) Jelmer Vernooij 2004-2007
- Copyright (C) Wilco Baan Hofman 2006
+ Copyright (C) Wilco Baan Hofman 2006-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
@@ -20,7 +20,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* FIXME Newer .REG files, created by Windows XP and above use unicode UTF-16 */
+/* FIXME Newer .REG files, created by Windows XP and above use unicode UCS-2 */
#include "includes.h"
#include "lib/registry/registry.h"
@@ -112,8 +112,8 @@ _PUBLIC_ WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
data->iconv_convenience = iconv_convenience;
if (filename) {
- data->fd = open(filename, O_CREAT, 0755);
- if (data->fd == -1) {
+ data->fd = open(filename, O_CREAT|O_WRONLY, 0755);
+ if (data->fd < 0) {
DEBUG(0, ("Unable to open %s\n", filename));
return WERR_BADFILE;
}
@@ -121,7 +121,7 @@ _PUBLIC_ WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
data->fd = STDOUT_FILENO;
}
- fdprintf(data->fd, "%s\n", HEADER_STRING);
+ fdprintf(data->fd, "%s\n\n", HEADER_STRING);
*callbacks = talloc(ctx, struct reg_diff_callbacks);
diff --git a/source4/lib/registry/patchfile_preg.c b/source4/lib/registry/patchfile_preg.c
index 0fa367bfcb..bb46495c19 100644
--- a/source4/lib/registry/patchfile_preg.c
+++ b/source4/lib/registry/patchfile_preg.c
@@ -2,7 +2,7 @@
Unix SMB/CIFS implementation.
Reading Registry.pol PReg registry files
- Copyright (C) Wilco Baan Hofman 2006
+ Copyright (C) Wilco Baan Hofman 2006-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
@@ -23,9 +23,12 @@
#include "lib/registry/registry.h"
#include "system/filesys.h"
#include "param/param.h"
+#include "librpc/gen_ndr/winreg.h"
struct preg_data {
int fd;
+ TALLOC_CTX *ctx;
+ struct smb_iconv_convenience *ic;
};
static WERROR preg_read_utf16(struct smb_iconv_convenience *ic, int fd, char *c)
@@ -38,14 +41,22 @@ static WERROR preg_read_utf16(struct smb_iconv_convenience *ic, int fd, char *c)
push_codepoint(ic, c, v);
return WERR_OK;
}
-
-/* FIXME These functions need to be implemented */
-static WERROR reg_preg_diff_add_key(void *_data, const char *key_name)
+static WERROR preg_write_utf16(struct smb_iconv_convenience *ic, int fd, const char *string)
{
+ codepoint_t v;
+ uint16_t i;
+ size_t size;
+
+ for (i = 0; i < strlen(string); i+=size) {
+ v = next_codepoint(ic, &string[i], &size);
+ if (write(fd, &v, 2) < 2) {
+ return WERR_GENERAL_FAILURE;
+ }
+ }
return WERR_OK;
}
-
-static WERROR reg_preg_diff_del_key(void *_data, const char *key_name)
+/* PReg does not support adding keys. */
+static WERROR reg_preg_diff_add_key(void *_data, const char *key_name)
{
return WERR_OK;
}
@@ -54,24 +65,73 @@ static WERROR reg_preg_diff_set_value(void *_data, const char *key_name,
const char *value_name,
uint32_t value_type, DATA_BLOB value_data)
{
+ struct preg_data *data = _data;
+ uint32_t buf;
+
+ preg_write_utf16(data->ic, data->fd, "[");
+ preg_write_utf16(data->ic, data->fd, key_name);
+ preg_write_utf16(data->ic, data->fd, ";");
+ preg_write_utf16(data->ic, data->fd, value_name);
+ preg_write_utf16(data->ic, data->fd, ";");
+ SIVAL(&buf, 0, value_type);
+ write(data->fd, &buf, sizeof(uint32_t));
+ preg_write_utf16(data->ic, data->fd, ";");
+ SIVAL(&buf, 0, value_data.length);
+ write(data->fd, &buf, sizeof(uint32_t));
+ preg_write_utf16(data->ic, data->fd, ";");
+ write(data->fd, value_data.data, value_data.length);
+ preg_write_utf16(data->ic, data->fd, "]");
+
return WERR_OK;
}
+static WERROR reg_preg_diff_del_key(void *_data, const char *key_name)
+{
+ struct preg_data *data = _data;
+ char *parent_name;
+ DATA_BLOB blob;
+
+ parent_name = talloc_strndup(data->ctx, key_name, strrchr(key_name, '\\')-key_name);
+ blob.data = (void *)talloc_strndup(data->ctx, key_name+(strrchr(key_name, '\\')-key_name)+1,
+ strlen(key_name)-(strrchr(key_name, '\\')-key_name));
+ blob.length = strlen((char *)blob.data)+1;
+
+
+ /* FIXME: These values should be accumulated to be written at done(). */
+ return reg_preg_diff_set_value(data, parent_name, "**DeleteKeys", REG_SZ, blob);
+}
+
static WERROR reg_preg_diff_del_value(void *_data, const char *key_name,
const char *value_name)
{
- return WERR_OK;
+ struct preg_data *data = _data;
+ char *val;
+ DATA_BLOB blob;
+
+ val = talloc_asprintf(data->ctx, "**Del.%s", value_name);
+
+ blob.data = (void *)talloc(data->ctx, uint32_t);
+ *(uint32_t *)blob.data = 0;
+ blob.length = 4;
+ return reg_preg_diff_set_value(data, key_name, val, REG_DWORD, blob);
}
static WERROR reg_preg_diff_del_all_values(void *_data, const char *key_name)
{
- return WERR_OK;
+ struct preg_data *data = _data;
+ DATA_BLOB blob;
+
+ blob.data = (void *)talloc(data->ctx, uint32_t);
+ *(uint32_t *)blob.data = 0;
+ blob.length = 4;
+
+ return reg_preg_diff_set_value(data, key_name, "**DelVals.", REG_DWORD, blob);
}
static WERROR reg_preg_diff_done(void *_data)
{
struct preg_data *data = (struct preg_data *)_data;
-
+
close(data->fd);
talloc_free(data);
return WERR_OK;
@@ -81,6 +141,7 @@ static WERROR reg_preg_diff_done(void *_data)
* Save registry diff
*/
_PUBLIC_ WERROR reg_preg_diff_save(TALLOC_CTX *ctx, const char *filename,
+ struct smb_iconv_convenience *ic,
struct reg_diff_callbacks **callbacks,
void **callback_data)
{
@@ -95,18 +156,22 @@ _PUBLIC_ WERROR reg_preg_diff_save(TALLOC_CTX *ctx, const char *filename,
*callback_data = data;
if (filename) {
- data->fd = open(filename, O_CREAT, 0755);
- if (data->fd == -1) {
+ data->fd = open(filename, O_CREAT|O_WRONLY, 0755);
+ if (data->fd < 0) {
DEBUG(0, ("Unable to open %s\n", filename));
return WERR_BADFILE;
}
} else {
data->fd = STDOUT_FILENO;
}
- snprintf(preg_header.hdr, 4, "PReg");
+
+ strncpy(preg_header.hdr, "PReg", 4);
SIVAL(&preg_header, 4, 1);
write(data->fd, (uint8_t *)&preg_header,8);
+ data->ctx = ctx;
+ data->ic = ic;
+
*callbacks = talloc(ctx, struct reg_diff_callbacks);
(*callbacks)->add_key = reg_preg_diff_add_key;
@@ -149,6 +214,8 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
ret = WERR_GENERAL_FAILURE;
goto cleanup;
}
+ preg_header.version = IVAL(&preg_header.version, 0);
+
if (strncmp(preg_header.hdr, "PReg", 4) != 0) {
DEBUG(0, ("This file is not a valid preg registry file\n"));
ret = WERR_GENERAL_FAILURE;
@@ -177,7 +244,8 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
*buf_ptr != ';' && buf_ptr-buf < buf_size) {
buf_ptr++;
}
- key = talloc_asprintf(mem_ctx, "\\%s", buf);
+ buf[buf_ptr-buf] = '\0';
+ key = talloc_strdup(mem_ctx, buf);
/* Get the name */
buf_ptr = buf;
@@ -185,6 +253,7 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
*buf_ptr != ';' && buf_ptr-buf < buf_size) {
buf_ptr++;
}
+ buf[buf_ptr-buf] = '\0';
value_name = talloc_strdup(mem_ctx, buf);
/* Get the type */
@@ -193,6 +262,8 @@ _PUBLIC_ WERROR reg_preg_diff_load(int fd,
ret = WERR_GENERAL_FAILURE;
goto cleanup;
}
+ value_type = IVAL(&value_type, 0);
+
/* Read past delimiter */
buf_ptr = buf;
if (!(W_ERROR_IS_OK(preg_read_utf16(iconv_convenience, fd, buf_ptr)) &&
diff --git a/source4/lib/registry/regf.c b/source4/lib/registry/regf.c
index 46ccca922b..57a895aa00 100644
--- a/source4/lib/registry/regf.c
+++ b/source4/lib/registry/regf.c
@@ -25,6 +25,8 @@
#include "librpc/gen_ndr/winreg.h"
#include "param/param.h"
#include "lib/registry/registry.h"
+#include "libcli/security/security.h"
+
static struct hive_operations reg_backend_regf;
@@ -1915,9 +1917,12 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx,
{
struct regf_data *regf;
struct regf_hdr *regf_hdr;
- int i;
struct nk_block nk;
+ struct sk_block sk;
WERROR error;
+ DATA_BLOB data;
+ struct security_descriptor *sd;
+ uint32_t sk_offset;
regf = (struct regf_data *)talloc_zero(NULL, struct regf_data);
@@ -1945,20 +1950,17 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx,
regf_hdr->version.minor = minor_version;
regf_hdr->last_block = 0x1000; /* Block size */
regf_hdr->description = talloc_strdup(regf_hdr,
- "registry created by Samba 4");
+ "Registry created by Samba 4");
W_ERROR_HAVE_NO_MEMORY(regf_hdr->description);
regf_hdr->chksum = 0;
regf->header = regf_hdr;
- i = 0;
/* Create all hbin blocks */
regf->hbins = talloc_array(regf, struct hbin_block *, 1);
W_ERROR_HAVE_NO_MEMORY(regf->hbins);
regf->hbins[0] = NULL;
- regf_hdr->data_offset = -1; /* FIXME */
-
nk.header = "nk";
nk.type = REG_SUB_KEY;
unix_to_nt_time(&nk.last_change, time(NULL));
@@ -1971,27 +1973,67 @@ WERROR reg_create_regf_file(TALLOC_CTX *parent_ctx,
nk.num_values = 0;
nk.values_offset = -1;
memset(nk.unk3, 0, 5);
- nk.clsname_offset = -1; /* FIXME: fill in */
+ nk.clsname_offset = -1;
nk.clsname_length = 0;
- nk.key_name = "";
+ nk.sk_offset = 0x80;
+ nk.key_name = "SambaRootKey";
+
+ /*
+ * It should be noted that changing the key_name to something shorter
+ * creates a shorter nk block, which makes the position of the sk block
+ * change. All Windows registries I've seen have the sk at 0x80.
+ * I therefore recommend that our regf files share that offset -- Wilco
+ */
+
+ /* Create a security descriptor. */
+ sd = security_descriptor_dacl_create(regf,
+ 0,
+ NULL, NULL,
+ SID_NT_AUTHENTICATED_USERS,
+ SEC_ACE_TYPE_ACCESS_ALLOWED,
+ SEC_GENERIC_ALL,
+ SEC_ACE_FLAG_OBJECT_INHERIT,
+ NULL);
+
+ /* Push the security descriptor to a blob */
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_push_struct_blob(&data, regf, NULL,
+ sd, (ndr_push_flags_fn_t)ndr_push_security_descriptor))) {
+ DEBUG(0, ("Unable to push security descriptor\n"));
+ return WERR_GENERAL_FAILURE;
+ }
- nk.sk_offset = -1; /* FIXME: fill in */
+ ZERO_STRUCT(sk);
+ sk.header = "sk";
+ sk.prev_offset = 0x80;
+ sk.next_offset = 0x80;
+ sk.ref_cnt = 1;
+ sk.rec_size = data.length;
+ sk.sec_desc = data.data;
/* Store the new nk key */
regf->header->data_offset = hbin_store_tdr(regf,
(tdr_push_fn_t)tdr_push_nk_block,
&nk);
+ /* Store the sk block */
+ sk_offset = hbin_store_tdr(regf,
+ (tdr_push_fn_t) tdr_push_sk_block,
+ &sk);
+ if (sk_offset != 0x80) {
+ DEBUG(0, ("Error storing sk block, should be at 0x80, stored at 0x%x\n", nk.sk_offset));
+ return WERR_GENERAL_FAILURE;
+ }
+
*key = (struct hive_key *)regf_get_key(parent_ctx, regf,
regf->header->data_offset);
- /* We can drop our own reference now that *key will have created one */
- talloc_free(regf);
-
error = regf_save_hbin(regf);
if (!W_ERROR_IS_OK(error)) {
return error;
}
+
+ /* We can drop our own reference now that *key will have created one */
+ talloc_free(regf);
return WERR_OK;
}
diff --git a/source4/lib/registry/registry.h b/source4/lib/registry/registry.h
index a86294bf46..e134e3e532 100644
--- a/source4/lib/registry/registry.h
+++ b/source4/lib/registry/registry.h
@@ -149,10 +149,12 @@ struct hive_operations {
struct cli_credentials;
struct auth_session_info;
+struct event_context;
WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
struct auth_session_info *session_info,
struct cli_credentials *credentials,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
struct hive_key **root);
WERROR hive_key_get_info(TALLOC_CTX *mem_ctx, const struct hive_key *key,
@@ -184,6 +186,12 @@ WERROR hive_get_value_by_index(TALLOC_CTX *mem_ctx,
struct hive_key *key, uint32_t idx,
const char **name,
uint32_t *type, DATA_BLOB *data);
+WERROR hive_get_sec_desc(TALLOC_CTX *mem_ctx,
+ struct hive_key *key,
+ struct security_descriptor **security);
+
+WERROR hive_set_sec_desc(struct hive_key *key,
+ const struct security_descriptor *security);
WERROR hive_key_del_value(struct hive_key *key, const char *name);
@@ -199,6 +207,7 @@ WERROR reg_open_regf_file(TALLOC_CTX *parent_ctx,
WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
struct auth_session_info *session_info,
struct cli_credentials *credentials,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
struct hive_key **k);
@@ -311,11 +320,11 @@ struct registry_operations {
uint32_t *type,
DATA_BLOB *data);
- WERROR (*get_security) (TALLOC_CTX *mem_ctx,
+ WERROR (*get_sec_desc) (TALLOC_CTX *mem_ctx,
const struct registry_key *key,
struct security_descriptor **security);
- WERROR (*set_security) (struct registry_key *key,
+ WERROR (*set_sec_desc) (struct registry_key *key,
const struct security_descriptor *security);
WERROR (*load_key) (struct registry_key *key,
@@ -355,12 +364,11 @@ struct loadparm_context;
* Open the locally defined registry.
*/
WERROR reg_open_local(TALLOC_CTX *mem_ctx,
- struct registry_context **ctx,
- struct auth_session_info *session_info,
- struct cli_credentials *credentials);
+ struct registry_context **ctx);
WERROR reg_open_samba(TALLOC_CTX *mem_ctx,
struct registry_context **ctx,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
struct auth_session_info *session_info,
struct cli_credentials *credentials);
@@ -461,12 +469,8 @@ struct registry_key *reg_import_hive_key(struct registry_context *ctx,
struct hive_key *hive,
uint32_t predef_key,
const char **elements);
-WERROR reg_get_security(TALLOC_CTX *mem_ctx,
- const struct registry_key *key,
- struct security_descriptor **security);
-
-WERROR reg_set_security(struct registry_key *key,
- struct security_descriptor *security);
+WERROR reg_set_sec_desc(struct registry_key *key,
+ const struct security_descriptor *security);
struct reg_diff_callbacks {
WERROR (*add_key) (void *callback_data, const char *key_name);
@@ -490,11 +494,19 @@ WERROR reg_dotreg_diff_save(TALLOC_CTX *ctx, const char *filename,
struct smb_iconv_convenience *iconv_convenience,
struct reg_diff_callbacks **callbacks,
void **callback_data);
+WERROR reg_preg_diff_save(TALLOC_CTX *ctx, const char *filename,
+ struct smb_iconv_convenience *ic,
+ struct reg_diff_callbacks **callbacks,
+ void **callback_data);
WERROR reg_generate_diff_key(struct registry_key *oldkey,
struct registry_key *newkey,
const char *path,
const struct reg_diff_callbacks *callbacks,
void *callback_data);
+WERROR reg_diff_load(const char *filename,
+ struct smb_iconv_convenience *iconv_convenience,
+ const struct reg_diff_callbacks *callbacks,
+ void *callback_data);
diff --git a/source4/lib/registry/registry.i b/source4/lib/registry/registry.i
index 8ab402d57d..7dd02b344c 100644
--- a/source4/lib/registry/registry.i
+++ b/source4/lib/registry/registry.i
@@ -26,6 +26,7 @@
#include "includes.h"
#include "registry.h"
#include "param/param.h"
+#include "events/events.h"
typedef struct registry_context reg;
typedef struct hive_key hive_key;
@@ -41,6 +42,7 @@ typedef struct hive_key hive_key;
%import "../../auth/credentials/credentials.i"
%import "../../libcli/util/errors.i"
%import "../../param/param.i"
+%import "../events/events.i"
/* Utility functions */
@@ -57,9 +59,7 @@ const char *str_regtype(int type);
}
%rename(Registry) reg_open_local;
-WERROR reg_open_local(TALLOC_CTX *parent_ctx, struct registry_context **ctx,
- struct auth_session_info *session_info,
- struct cli_credentials *credentials);
+WERROR reg_open_local(TALLOC_CTX *parent_ctx, struct registry_context **ctx);
%typemap(in,noblock=1) const char ** {
/* Check if is a list */
@@ -93,11 +93,20 @@ WERROR reg_open_local(TALLOC_CTX *parent_ctx, struct registry_context **ctx,
typedef struct registry_context {
%extend {
+ %feature("docstring") get_predefined_key_by_name "S.get_predefined_key_by_name(name) -> key\n"
+ "Find a predefined key by name";
WERROR get_predefined_key_by_name(const char *name,
struct registry_key **key);
+ %feature("docstring") key_del_abs "S.key_del_abs(name) -> None\n"
+ "Delete a key by absolute path.";
WERROR key_del_abs(const char *path);
+ %feature("docstring") get_predefined_key "S.get_predefined_key(hkey_id) -> key\n"
+ "Find a predefined key by id";
WERROR get_predefined_key(uint32_t hkey_id, struct registry_key **key);
+ %feature("docstring") diff_apply "S.diff_apply(filename) -> None\n"
+ "Apply the diff from the specified file";
+
WERROR diff_apply(const char *filename);
WERROR generate_diff(struct registry_context *ctx2, const struct reg_diff_callbacks *callbacks,
void *callback_data);
@@ -106,6 +115,8 @@ typedef struct registry_context {
const char **elements=NULL);
struct registry_key *import_hive_key(struct hive_key *hive, uint32_t predef_key, const char **elements);
+ %feature("docstring") mount_hive "S.mount_hive(key, predef_name) -> None\n"
+ "Mount the specified key at the specified path.";
WERROR mount_hive(struct hive_key *key, const char *predef_name)
{
int i;
@@ -130,24 +141,30 @@ typedef struct registry_context {
$result = SWIG_NewPointerObj(*$1, SWIGTYPE_p_hive_key, 0);
}
+%feature("docstring") reg_open_hive "S.__init__(location, session_info=None, credentials=None, loadparm_context=None)";
%rename(hive_key) reg_open_hive;
WERROR reg_open_hive(TALLOC_CTX *parent_ctx, const char *location,
struct auth_session_info *session_info,
struct cli_credentials *credentials,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
struct hive_key **root);
+%feature("docstring") reg_open_ldb_file "open_ldb(location, session_info=None, credentials=None, loadparm_context=None) -> key";
%rename(open_ldb) reg_open_ldb_file;
WERROR reg_open_ldb_file(TALLOC_CTX *parent_ctx, const char *location,
struct auth_session_info *session_info,
struct cli_credentials *credentials,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
struct hive_key **k);
+%feature("docstring") reg_create_directory "create_dir(location) -> key";
%rename(create_dir) reg_create_directory;
WERROR reg_create_directory(TALLOC_CTX *parent_ctx,
const char *location, struct hive_key **key);
+%feature("docstring") reg_open_directory "open_dir(location) -> key";
%rename(open_dir) reg_open_directory;
WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
const char *location, struct hive_key **key);
@@ -156,17 +173,27 @@ WERROR reg_open_directory(TALLOC_CTX *parent_ctx,
typedef struct hive_key {
%extend {
+ %feature("docstring") del "S.del(name) -> None\n"
+ "Delete a subkey";
WERROR del(const char *name);
+ %feature("docstring") flush "S.flush() -> None\n"
+ "Flush this key to disk";
WERROR flush(void);
+ %feature("docstring") del_value "S.del_value(name) -> None\n"
+ "Delete a value";
WERROR del_value(const char *name);
+ %feature("docstring") set_value "S.set_value(name, type, data) -> None\n"
+ "Set a value";
WERROR set_value(const char *name, uint32_t type, const DATA_BLOB data);
}
} hive_key;
%rename(open_samba) reg_open_samba;
+%feature("docstring") reg_open_samba "open_samba() -> reg";
WERROR reg_open_samba(TALLOC_CTX *mem_ctx,
struct registry_context **ctx,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
struct auth_session_info *session_info,
struct cli_credentials *credentials);
diff --git a/source4/lib/registry/registry.py b/source4/lib/registry/registry.py
index bf8ac60498..4c6e735414 100644
--- a/source4/lib/registry/registry.py
+++ b/source4/lib/registry/registry.py
@@ -1,5 +1,5 @@
# This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.33
+# Version 1.3.35
#
# Don't modify this file, modify the SWIG interface instead.
@@ -59,12 +59,48 @@ def _swig_setattr_nondynamic_method(set):
import credentials
import param
+import events
reg_get_predef_name = _registry.reg_get_predef_name
str_regtype = _registry.str_regtype
Registry = _registry.Registry
class reg(object):
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
__repr__ = _swig_repr
+ def get_predefined_key_by_name(*args, **kwargs):
+ """
+ S.get_predefined_key_by_name(name) -> key
+ Find a predefined key by name
+ """
+ return _registry.reg_get_predefined_key_by_name(*args, **kwargs)
+
+ def key_del_abs(*args, **kwargs):
+ """
+ S.key_del_abs(name) -> None
+ Delete a key by absolute path.
+ """
+ return _registry.reg_key_del_abs(*args, **kwargs)
+
+ def get_predefined_key(*args, **kwargs):
+ """
+ S.get_predefined_key(hkey_id) -> key
+ Find a predefined key by id
+ """
+ return _registry.reg_get_predefined_key(*args, **kwargs)
+
+ def diff_apply(*args, **kwargs):
+ """
+ S.diff_apply(filename) -> None
+ Apply the diff from the specified file
+ """
+ return _registry.reg_diff_apply(*args, **kwargs)
+
+ def mount_hive(*args):
+ """
+ S.mount_hive(key, predef_name) -> None
+ Mount the specified key at the specified path.
+ """
+ return _registry.reg_mount_hive(*args)
+
def __init__(self, *args, **kwargs):
_registry.reg_swiginit(self,_registry.new_reg(*args, **kwargs))
__swig_destroy__ = _registry.delete_reg
@@ -78,11 +114,26 @@ reg.mount_hive = new_instancemethod(_registry.reg_mount_hive,None,reg)
reg_swigregister = _registry.reg_swigregister
reg_swigregister(reg)
-hive_key = _registry.hive_key
-open_ldb = _registry.open_ldb
-create_dir = _registry.create_dir
-open_dir = _registry.open_dir
-open_samba = _registry.open_samba
+
+def hive_key(*args, **kwargs):
+ """S.__init__(location, session_info=None, credentials=None, loadparm_context=None)"""
+ return _registry.hive_key(*args, **kwargs)
+
+def open_ldb(*args, **kwargs):
+ """open_ldb(location, session_info=None, credentials=None, loadparm_context=None) -> key"""
+ return _registry.open_ldb(*args, **kwargs)
+
+def create_dir(*args, **kwargs):
+ """create_dir(location) -> key"""
+ return _registry.create_dir(*args, **kwargs)
+
+def open_dir(*args, **kwargs):
+ """open_dir(location) -> key"""
+ return _registry.open_dir(*args, **kwargs)
+
+def open_samba(*args, **kwargs):
+ """open_samba() -> reg"""
+ return _registry.open_samba(*args, **kwargs)
HKEY_CLASSES_ROOT = _registry.HKEY_CLASSES_ROOT
HKEY_CURRENT_USER = _registry.HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE = _registry.HKEY_LOCAL_MACHINE
diff --git a/source4/lib/registry/registry_wrap.c b/source4/lib/registry/registry_wrap.c
index da09ecbe08..b066e42b41 100644
--- a/source4/lib/registry/registry_wrap.c
+++ b/source4/lib/registry/registry_wrap.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.33
+ * Version 1.3.35
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
@@ -126,7 +126,7 @@
/* This should only be incremented when either the layout of swig_type_info changes,
or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "3"
+#define SWIG_RUNTIME_VERSION "4"
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
#ifdef SWIG_TYPE_TABLE
@@ -161,6 +161,7 @@
/* Flags for pointer conversions */
#define SWIG_POINTER_DISOWN 0x1
+#define SWIG_CAST_NEW_MEMORY 0x2
/* Flags for new pointer objects */
#define SWIG_POINTER_OWN 0x1
@@ -301,10 +302,10 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) {
extern "C" {
#endif
-typedef void *(*swig_converter_func)(void *);
+typedef void *(*swig_converter_func)(void *, int *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);
-/* Structure to store inforomation on one type */
+/* Structure to store information on one type */
typedef struct swig_type_info {
const char *name; /* mangled name of this type */
const char *str; /* human readable name of this type */
@@ -431,8 +432,8 @@ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
Cast a pointer up an inheritance hierarchy
*/
SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
- return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
+SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
}
/*
@@ -856,7 +857,7 @@ SWIG_Python_AddErrorMsg(const char* mesg)
Py_DECREF(old_str);
Py_DECREF(value);
} else {
- PyErr_Format(PyExc_RuntimeError, mesg);
+ PyErr_SetString(PyExc_RuntimeError, mesg);
}
}
@@ -1416,7 +1417,7 @@ PySwigObject_dealloc(PyObject *v)
{
PySwigObject *sobj = (PySwigObject *) v;
PyObject *next = sobj->next;
- if (sobj->own) {
+ if (sobj->own == SWIG_POINTER_OWN) {
swig_type_info *ty = sobj->ty;
PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
PyObject *destroy = data ? data->destroy : 0;
@@ -1434,12 +1435,13 @@ PySwigObject_dealloc(PyObject *v)
res = ((*meth)(mself, v));
}
Py_XDECREF(res);
- } else {
- const char *name = SWIG_TypePrettyName(ty);
+ }
#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
- printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
-#endif
+ else {
+ const char *name = SWIG_TypePrettyName(ty);
+ printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
}
+#endif
}
Py_XDECREF(next);
PyObject_DEL(v);
@@ -1944,7 +1946,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
SWIGRUNTIME int
SWIG_Python_AcquirePtr(PyObject *obj, int own) {
- if (own) {
+ if (own == SWIG_POINTER_OWN) {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
if (sobj) {
int oldown = sobj->own;
@@ -1965,6 +1967,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
return SWIG_OK;
} else {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+ if (own)
+ *own = 0;
while (sobj) {
void *vptr = sobj->ptr;
if (ty) {
@@ -1978,7 +1982,15 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
if (!tc) {
sobj = (PySwigObject *)sobj->next;
} else {
- if (ptr) *ptr = SWIG_TypeCast(tc,vptr);
+ if (ptr) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
+ assert(own);
+ if (own)
+ *own = *own | SWIG_CAST_NEW_MEMORY;
+ }
+ }
break;
}
}
@@ -1988,7 +2000,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
}
}
if (sobj) {
- if (own) *own = sobj->own;
+ if (own)
+ *own = *own | sobj->own;
if (flags & SWIG_POINTER_DISOWN) {
sobj->own = 0;
}
@@ -2053,8 +2066,13 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
}
if (ty) {
swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
- if (!tc) return SWIG_ERROR;
- *ptr = SWIG_TypeCast(tc,vptr);
+ if (tc) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ assert(!newmemory); /* newmemory handling not yet implemented */
+ } else {
+ return SWIG_ERROR;
+ }
} else {
*ptr = vptr;
}
@@ -2460,29 +2478,30 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
#define SWIGTYPE_p_auth_session_info swig_types[1]
#define SWIGTYPE_p_char swig_types[2]
#define SWIGTYPE_p_cli_credentials swig_types[3]
-#define SWIGTYPE_p_hive_key swig_types[4]
-#define SWIGTYPE_p_int swig_types[5]
-#define SWIGTYPE_p_loadparm_context swig_types[6]
-#define SWIGTYPE_p_loadparm_service swig_types[7]
-#define SWIGTYPE_p_long_long swig_types[8]
-#define SWIGTYPE_p_p_char swig_types[9]
-#define SWIGTYPE_p_p_hive_key swig_types[10]
-#define SWIGTYPE_p_p_registry_context swig_types[11]
-#define SWIGTYPE_p_p_registry_key swig_types[12]
-#define SWIGTYPE_p_param_context swig_types[13]
-#define SWIGTYPE_p_param_opt swig_types[14]
-#define SWIGTYPE_p_param_section swig_types[15]
-#define SWIGTYPE_p_reg_diff_callbacks swig_types[16]
-#define SWIGTYPE_p_registry_context swig_types[17]
-#define SWIGTYPE_p_registry_key swig_types[18]
-#define SWIGTYPE_p_short swig_types[19]
-#define SWIGTYPE_p_signed_char swig_types[20]
-#define SWIGTYPE_p_unsigned_char swig_types[21]
-#define SWIGTYPE_p_unsigned_int swig_types[22]
-#define SWIGTYPE_p_unsigned_long_long swig_types[23]
-#define SWIGTYPE_p_unsigned_short swig_types[24]
-static swig_type_info *swig_types[26];
-static swig_module_info swig_module = {swig_types, 25, 0, 0, 0, 0};
+#define SWIGTYPE_p_event_context swig_types[4]
+#define SWIGTYPE_p_hive_key swig_types[5]
+#define SWIGTYPE_p_int swig_types[6]
+#define SWIGTYPE_p_loadparm_context swig_types[7]
+#define SWIGTYPE_p_loadparm_service swig_types[8]
+#define SWIGTYPE_p_long_long swig_types[9]
+#define SWIGTYPE_p_p_char swig_types[10]
+#define SWIGTYPE_p_p_hive_key swig_types[11]
+#define SWIGTYPE_p_p_registry_context swig_types[12]
+#define SWIGTYPE_p_p_registry_key swig_types[13]
+#define SWIGTYPE_p_param_context swig_types[14]
+#define SWIGTYPE_p_param_opt swig_types[15]
+#define SWIGTYPE_p_param_section swig_types[16]
+#define SWIGTYPE_p_reg_diff_callbacks swig_types[17]
+#define SWIGTYPE_p_registry_context swig_types[18]
+#define SWIGTYPE_p_registry_key swig_types[19]
+#define SWIGTYPE_p_short swig_types[20]
+#define SWIGTYPE_p_signed_char swig_types[21]
+#define SWIGTYPE_p_unsigned_char swig_types[22]
+#define SWIGTYPE_p_unsigned_int swig_types[23]
+#define SWIGTYPE_p_unsigned_long_long swig_types[24]
+#define SWIGTYPE_p_unsigned_short swig_types[25]
+static swig_type_info *swig_types[27];
+static swig_module_info swig_module = {swig_types, 26, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
@@ -2514,7 +2533,7 @@ static swig_module_info swig_module = {swig_types, 25, 0, 0, 0, 0};
#define SWIG_name "_registry"
-#define SWIGVERSION 0x010333
+#define SWIGVERSION 0x010335
#define SWIG_VERSION SWIGVERSION
@@ -2529,6 +2548,7 @@ static swig_module_info swig_module = {swig_types, 25, 0, 0, 0, 0};
#include "includes.h"
#include "registry.h"
#include "param/param.h"
+#include "events/events.h"
typedef struct registry_context reg;
typedef struct hive_key hive_key;
@@ -2910,44 +2930,17 @@ fail:
}
-SWIGINTERN PyObject *_wrap_Registry(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Registry(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
struct registry_context **arg2 = (struct registry_context **) 0 ;
- struct auth_session_info *arg3 = (struct auth_session_info *) 0 ;
- struct cli_credentials *arg4 = (struct cli_credentials *) 0 ;
WERROR result;
struct registry_context *tmp2 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- void *argp4 = 0 ;
- int res4 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "session_info",(char *) "credentials", NULL
- };
- arg3 = NULL;
- arg4 = NULL;
arg1 = NULL;
arg2 = &tmp2;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:Registry",kwnames,&obj0,&obj1)) SWIG_fail;
- if (obj0) {
- res3 = SWIG_ConvertPtr(obj0, &argp3,SWIGTYPE_p_auth_session_info, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Registry" "', argument " "3"" of type '" "struct auth_session_info *""'");
- }
- arg3 = (struct auth_session_info *)(argp3);
- }
- if (obj1) {
- res4 = SWIG_ConvertPtr(obj1, &argp4,SWIGTYPE_p_cli_credentials, 0 | 0 );
- if (!SWIG_IsOK(res4)) {
- SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Registry" "', argument " "4"" of type '" "struct cli_credentials *""'");
- }
- arg4 = (struct cli_credentials *)(argp4);
- }
- result = reg_open_local(arg1,arg2,arg3,arg4);
+ if (!SWIG_Python_UnpackTuple(args,"Registry",0,0,0)) SWIG_fail;
+ result = reg_open_local(arg1,arg2);
if (!W_ERROR_IS_OK(result)) {
PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
PyErr_SetObject(PyExc_RuntimeError, obj);
@@ -3410,7 +3403,10 @@ check_1:
}
fail:
- SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'reg_mount_hive'.\n Possible C/C++ prototypes are:\n"" mount_hive(reg *,struct hive_key *,uint32_t,char const **)\n"" mount_hive(reg *,struct hive_key *,char const *)\n");
+ SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'reg_mount_hive'.\n"
+ " Possible C/C++ prototypes are:\n"
+ " mount_hive(reg *,struct hive_key *,uint32_t,char const **)\n"
+ " mount_hive(reg *,struct hive_key *,char const *)\n");
return NULL;
}
@@ -3420,7 +3416,7 @@ SWIGINTERN PyObject *_wrap_new_reg(PyObject *SWIGUNUSEDPARM(self), PyObject *arg
reg *result = 0 ;
if (!SWIG_Python_UnpackTuple(args,"new_reg",0,0,0)) SWIG_fail;
- result = (reg *)(reg *) calloc(1, sizeof(reg));
+ result = (reg *)calloc(1, sizeof(reg));
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_registry_context, SWIG_POINTER_NEW | 0 );
return resultobj;
fail:
@@ -3468,8 +3464,9 @@ SWIGINTERN PyObject *_wrap_hive_key(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
char *arg2 = (char *) 0 ;
struct auth_session_info *arg3 = (struct auth_session_info *) 0 ;
struct cli_credentials *arg4 = (struct cli_credentials *) 0 ;
- struct loadparm_context *arg5 = (struct loadparm_context *) 0 ;
- struct hive_key **arg6 = (struct hive_key **) 0 ;
+ struct event_context *arg5 = (struct event_context *) 0 ;
+ struct loadparm_context *arg6 = (struct loadparm_context *) 0 ;
+ struct hive_key **arg7 = (struct hive_key **) 0 ;
WERROR result;
int res2 ;
char *buf2 = 0 ;
@@ -3480,21 +3477,25 @@ SWIGINTERN PyObject *_wrap_hive_key(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
int res4 = 0 ;
void *argp5 = 0 ;
int res5 = 0 ;
- struct hive_key *tmp6 ;
+ void *argp6 = 0 ;
+ int res6 = 0 ;
+ struct hive_key *tmp7 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
char * kwnames[] = {
- (char *) "location",(char *) "session_info",(char *) "credentials",(char *) "lp_ctx", NULL
+ (char *) "location",(char *) "session_info",(char *) "credentials",(char *) "ev_ctx",(char *) "lp_ctx", NULL
};
arg3 = NULL;
arg4 = NULL;
- arg5 = loadparm_init(NULL);
+ arg5 = event_context_init(NULL);
+ arg6 = loadparm_init(NULL);
arg1 = NULL;
- arg6 = &tmp6;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OOO:hive_key",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+ arg7 = &tmp7;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OOOO:hive_key",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
res2 = SWIG_AsCharPtrAndSize(obj0, &buf2, NULL, &alloc2);
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "hive_key" "', argument " "2"" of type '" "char const *""'");
@@ -3515,13 +3516,20 @@ SWIGINTERN PyObject *_wrap_hive_key(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
arg4 = (struct cli_credentials *)(argp4);
}
if (obj3) {
- res5 = SWIG_ConvertPtr(obj3, &argp5,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ res5 = SWIG_ConvertPtr(obj3, &argp5,SWIGTYPE_p_event_context, 0 | 0 );
if (!SWIG_IsOK(res5)) {
- SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "hive_key" "', argument " "5"" of type '" "struct loadparm_context *""'");
+ SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "hive_key" "', argument " "5"" of type '" "struct event_context *""'");
+ }
+ arg5 = (struct event_context *)(argp5);
+ }
+ if (obj4) {
+ res6 = SWIG_ConvertPtr(obj4, &argp6,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res6)) {
+ SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "hive_key" "', argument " "6"" of type '" "struct loadparm_context *""'");
}
- arg5 = (struct loadparm_context *)(argp5);
+ arg6 = (struct loadparm_context *)(argp6);
}
- result = reg_open_hive(arg1,(char const *)arg2,arg3,arg4,arg5,arg6);
+ result = reg_open_hive(arg1,(char const *)arg2,arg3,arg4,arg5,arg6,arg7);
if (!W_ERROR_IS_OK(result)) {
PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
PyErr_SetObject(PyExc_RuntimeError, obj);
@@ -3530,7 +3538,7 @@ SWIGINTERN PyObject *_wrap_hive_key(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
resultobj = Py_None;
}
Py_XDECREF(resultobj);
- resultobj = SWIG_NewPointerObj(*arg6, SWIGTYPE_p_hive_key, 0);
+ resultobj = SWIG_NewPointerObj(*arg7, SWIGTYPE_p_hive_key, 0);
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
return resultobj;
fail:
@@ -3545,8 +3553,9 @@ SWIGINTERN PyObject *_wrap_open_ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
char *arg2 = (char *) 0 ;
struct auth_session_info *arg3 = (struct auth_session_info *) 0 ;
struct cli_credentials *arg4 = (struct cli_credentials *) 0 ;
- struct loadparm_context *arg5 = (struct loadparm_context *) 0 ;
- struct hive_key **arg6 = (struct hive_key **) 0 ;
+ struct event_context *arg5 = (struct event_context *) 0 ;
+ struct loadparm_context *arg6 = (struct loadparm_context *) 0 ;
+ struct hive_key **arg7 = (struct hive_key **) 0 ;
WERROR result;
int res2 ;
char *buf2 = 0 ;
@@ -3557,21 +3566,25 @@ SWIGINTERN PyObject *_wrap_open_ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
int res4 = 0 ;
void *argp5 = 0 ;
int res5 = 0 ;
- struct hive_key *tmp6 ;
+ void *argp6 = 0 ;
+ int res6 = 0 ;
+ struct hive_key *tmp7 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
PyObject * obj3 = 0 ;
+ PyObject * obj4 = 0 ;
char * kwnames[] = {
- (char *) "location",(char *) "session_info",(char *) "credentials",(char *) "lp_ctx", NULL
+ (char *) "location",(char *) "session_info",(char *) "credentials",(char *) "ev_ctx",(char *) "lp_ctx", NULL
};
arg3 = NULL;
arg4 = NULL;
- arg5 = loadparm_init(NULL);
+ arg5 = event_context_init(NULL);
+ arg6 = loadparm_init(NULL);
arg1 = NULL;
- arg6 = &tmp6;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OOO:open_ldb",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+ arg7 = &tmp7;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"O|OOOO:open_ldb",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
res2 = SWIG_AsCharPtrAndSize(obj0, &buf2, NULL, &alloc2);
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "open_ldb" "', argument " "2"" of type '" "char const *""'");
@@ -3592,13 +3605,20 @@ SWIGINTERN PyObject *_wrap_open_ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
arg4 = (struct cli_credentials *)(argp4);
}
if (obj3) {
- res5 = SWIG_ConvertPtr(obj3, &argp5,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ res5 = SWIG_ConvertPtr(obj3, &argp5,SWIGTYPE_p_event_context, 0 | 0 );
if (!SWIG_IsOK(res5)) {
- SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "open_ldb" "', argument " "5"" of type '" "struct loadparm_context *""'");
+ SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "open_ldb" "', argument " "5"" of type '" "struct event_context *""'");
+ }
+ arg5 = (struct event_context *)(argp5);
+ }
+ if (obj4) {
+ res6 = SWIG_ConvertPtr(obj4, &argp6,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res6)) {
+ SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "open_ldb" "', argument " "6"" of type '" "struct loadparm_context *""'");
}
- arg5 = (struct loadparm_context *)(argp5);
+ arg6 = (struct loadparm_context *)(argp6);
}
- result = reg_open_ldb_file(arg1,(char const *)arg2,arg3,arg4,arg5,arg6);
+ result = reg_open_ldb_file(arg1,(char const *)arg2,arg3,arg4,arg5,arg6,arg7);
if (!W_ERROR_IS_OK(result)) {
PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
PyErr_SetObject(PyExc_RuntimeError, obj);
@@ -3607,7 +3627,7 @@ SWIGINTERN PyObject *_wrap_open_ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
resultobj = Py_None;
}
Py_XDECREF(resultobj);
- resultobj = SWIG_NewPointerObj(*arg6, SWIGTYPE_p_hive_key, 0);
+ resultobj = SWIG_NewPointerObj(*arg7, SWIGTYPE_p_hive_key, 0);
if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
return resultobj;
fail:
@@ -3702,9 +3722,10 @@ SWIGINTERN PyObject *_wrap_open_samba(PyObject *SWIGUNUSEDPARM(self), PyObject *
PyObject *resultobj = 0;
TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
struct registry_context **arg2 = (struct registry_context **) 0 ;
- struct loadparm_context *arg3 = (struct loadparm_context *) 0 ;
- struct auth_session_info *arg4 = (struct auth_session_info *) 0 ;
- struct cli_credentials *arg5 = (struct cli_credentials *) 0 ;
+ struct event_context *arg3 = (struct event_context *) 0 ;
+ struct loadparm_context *arg4 = (struct loadparm_context *) 0 ;
+ struct auth_session_info *arg5 = (struct auth_session_info *) 0 ;
+ struct cli_credentials *arg6 = (struct cli_credentials *) 0 ;
WERROR result;
struct registry_context *tmp2 ;
void *argp3 = 0 ;
@@ -3713,41 +3734,52 @@ SWIGINTERN PyObject *_wrap_open_samba(PyObject *SWIGUNUSEDPARM(self), PyObject *
int res4 = 0 ;
void *argp5 = 0 ;
int res5 = 0 ;
+ void *argp6 = 0 ;
+ int res6 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
+ PyObject * obj3 = 0 ;
char * kwnames[] = {
- (char *) "lp_ctx",(char *) "session_info",(char *) "credentials", NULL
+ (char *) "ev_ctx",(char *) "lp_ctx",(char *) "session_info",(char *) "credentials", NULL
};
- arg3 = loadparm_init(NULL);
- arg4 = NULL;
+ arg3 = event_context_init(NULL);
+ arg4 = loadparm_init(NULL);
arg5 = NULL;
+ arg6 = NULL;
arg1 = NULL;
arg2 = &tmp2;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:open_samba",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOOO:open_samba",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
if (obj0) {
- res3 = SWIG_ConvertPtr(obj0, &argp3,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ res3 = SWIG_ConvertPtr(obj0, &argp3,SWIGTYPE_p_event_context, 0 | 0 );
if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "open_samba" "', argument " "3"" of type '" "struct loadparm_context *""'");
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "open_samba" "', argument " "3"" of type '" "struct event_context *""'");
}
- arg3 = (struct loadparm_context *)(argp3);
+ arg3 = (struct event_context *)(argp3);
}
if (obj1) {
- res4 = SWIG_ConvertPtr(obj1, &argp4,SWIGTYPE_p_auth_session_info, 0 | 0 );
+ res4 = SWIG_ConvertPtr(obj1, &argp4,SWIGTYPE_p_loadparm_context, 0 | 0 );
if (!SWIG_IsOK(res4)) {
- SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "open_samba" "', argument " "4"" of type '" "struct auth_session_info *""'");
+ SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "open_samba" "', argument " "4"" of type '" "struct loadparm_context *""'");
}
- arg4 = (struct auth_session_info *)(argp4);
+ arg4 = (struct loadparm_context *)(argp4);
}
if (obj2) {
- res5 = SWIG_ConvertPtr(obj2, &argp5,SWIGTYPE_p_cli_credentials, 0 | 0 );
+ res5 = SWIG_ConvertPtr(obj2, &argp5,SWIGTYPE_p_auth_session_info, 0 | 0 );
if (!SWIG_IsOK(res5)) {
- SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "open_samba" "', argument " "5"" of type '" "struct cli_credentials *""'");
+ SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "open_samba" "', argument " "5"" of type '" "struct auth_session_info *""'");
}
- arg5 = (struct cli_credentials *)(argp5);
+ arg5 = (struct auth_session_info *)(argp5);
}
- result = reg_open_samba(arg1,arg2,arg3,arg4,arg5);
+ if (obj3) {
+ res6 = SWIG_ConvertPtr(obj3, &argp6,SWIGTYPE_p_cli_credentials, 0 | 0 );
+ if (!SWIG_IsOK(res6)) {
+ SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "open_samba" "', argument " "6"" of type '" "struct cli_credentials *""'");
+ }
+ arg6 = (struct cli_credentials *)(argp6);
+ }
+ result = reg_open_samba(arg1,arg2,arg3,arg4,arg5,arg6);
if (!W_ERROR_IS_OK(result)) {
PyObject *obj = Py_BuildValue((char *)"(i,s)", W_ERROR_V(result), win_errstr(result));
PyErr_SetObject(PyExc_RuntimeError, obj);
@@ -3765,11 +3797,23 @@ fail:
static PyMethodDef SwigMethods[] = {
{ (char *)"reg_get_predef_name", (PyCFunction) _wrap_reg_get_predef_name, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"str_regtype", (PyCFunction) _wrap_str_regtype, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Registry", (PyCFunction) _wrap_Registry, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"reg_get_predefined_key_by_name", (PyCFunction) _wrap_reg_get_predefined_key_by_name, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"reg_key_del_abs", (PyCFunction) _wrap_reg_key_del_abs, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"reg_get_predefined_key", (PyCFunction) _wrap_reg_get_predefined_key, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"reg_diff_apply", (PyCFunction) _wrap_reg_diff_apply, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Registry", (PyCFunction)_wrap_Registry, METH_NOARGS, NULL},
+ { (char *)"reg_get_predefined_key_by_name", (PyCFunction) _wrap_reg_get_predefined_key_by_name, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.get_predefined_key_by_name(name) -> key\n"
+ "Find a predefined key by name\n"
+ ""},
+ { (char *)"reg_key_del_abs", (PyCFunction) _wrap_reg_key_del_abs, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.key_del_abs(name) -> None\n"
+ "Delete a key by absolute path.\n"
+ ""},
+ { (char *)"reg_get_predefined_key", (PyCFunction) _wrap_reg_get_predefined_key, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.get_predefined_key(hkey_id) -> key\n"
+ "Find a predefined key by id\n"
+ ""},
+ { (char *)"reg_diff_apply", (PyCFunction) _wrap_reg_diff_apply, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.diff_apply(filename) -> None\n"
+ "Apply the diff from the specified file\n"
+ ""},
{ (char *)"reg_generate_diff", (PyCFunction) _wrap_reg_generate_diff, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"reg_import_hive_key", (PyCFunction) _wrap_reg_import_hive_key, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"reg_mount_hive", _wrap_reg_mount_hive, METH_VARARGS, NULL},
@@ -3777,11 +3821,11 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"delete_reg", (PyCFunction)_wrap_delete_reg, METH_O, NULL},
{ (char *)"reg_swigregister", reg_swigregister, METH_VARARGS, NULL},
{ (char *)"reg_swiginit", reg_swiginit, METH_VARARGS, NULL},
- { (char *)"hive_key", (PyCFunction) _wrap_hive_key, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"open_ldb", (PyCFunction) _wrap_open_ldb, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"create_dir", (PyCFunction) _wrap_create_dir, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"open_dir", (PyCFunction) _wrap_open_dir, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"open_samba", (PyCFunction) _wrap_open_samba, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"hive_key", (PyCFunction) _wrap_hive_key, METH_VARARGS | METH_KEYWORDS, (char *)"S.__init__(location, session_info=None, credentials=None, loadparm_context=None)"},
+ { (char *)"open_ldb", (PyCFunction) _wrap_open_ldb, METH_VARARGS | METH_KEYWORDS, (char *)"open_ldb(location, session_info=None, credentials=None, loadparm_context=None) -> key"},
+ { (char *)"create_dir", (PyCFunction) _wrap_create_dir, METH_VARARGS | METH_KEYWORDS, (char *)"create_dir(location) -> key"},
+ { (char *)"open_dir", (PyCFunction) _wrap_open_dir, METH_VARARGS | METH_KEYWORDS, (char *)"open_dir(location) -> key"},
+ { (char *)"open_samba", (PyCFunction) _wrap_open_samba, METH_VARARGS | METH_KEYWORDS, (char *)"open_samba() -> reg"},
{ NULL, NULL, 0, NULL }
};
@@ -3792,6 +3836,7 @@ static swig_type_info _swigt__p_TALLOC_CTX = {"_p_TALLOC_CTX", "TALLOC_CTX *", 0
static swig_type_info _swigt__p_auth_session_info = {"_p_auth_session_info", "struct auth_session_info *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_cli_credentials = {"_p_cli_credentials", "struct cli_credentials *|cli_credentials *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_event_context = {"_p_event_context", "struct event_context *|event *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_hive_key = {"_p_hive_key", "struct hive_key *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_int = {"_p_int", "intptr_t *|int *|int_least32_t *|int_fast32_t *|int32_t *|int_fast16_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_loadparm_context = {"_p_loadparm_context", "struct loadparm_context *|loadparm_context *", 0, 0, (void*)0, 0};
@@ -3819,6 +3864,7 @@ static swig_type_info *swig_type_initial[] = {
&_swigt__p_auth_session_info,
&_swigt__p_char,
&_swigt__p_cli_credentials,
+ &_swigt__p_event_context,
&_swigt__p_hive_key,
&_swigt__p_int,
&_swigt__p_loadparm_context,
@@ -3846,6 +3892,7 @@ static swig_cast_info _swigc__p_TALLOC_CTX[] = { {&_swigt__p_TALLOC_CTX, 0, 0,
static swig_cast_info _swigc__p_auth_session_info[] = { {&_swigt__p_auth_session_info, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_cli_credentials[] = { {&_swigt__p_cli_credentials, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_event_context[] = { {&_swigt__p_event_context, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_hive_key[] = { {&_swigt__p_hive_key, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_loadparm_context[] = { {&_swigt__p_loadparm_context, 0, 0, 0},{0, 0, 0, 0}};
@@ -3873,6 +3920,7 @@ static swig_cast_info *swig_cast_initial[] = {
_swigc__p_auth_session_info,
_swigc__p_char,
_swigc__p_cli_credentials,
+ _swigc__p_event_context,
_swigc__p_hive_key,
_swigc__p_int,
_swigc__p_loadparm_context,
@@ -3962,7 +4010,7 @@ SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
- int found;
+ int found, init;
clientdata = clientdata;
@@ -3972,6 +4020,9 @@ SWIG_InitializeModule(void *clientdata) {
swig_module.type_initial = swig_type_initial;
swig_module.cast_initial = swig_cast_initial;
swig_module.next = &swig_module;
+ init = 1;
+ } else {
+ init = 0;
}
/* Try and load any already created modules */
@@ -4000,6 +4051,12 @@ SWIG_InitializeModule(void *clientdata) {
module_head->next = &swig_module;
}
+ /* When multiple interpeters are used, a module could have already been initialized in
+ a different interpreter, but not yet have a pointer in this interpreter.
+ In this case, we do not want to continue adding types... everything should be
+ set up already */
+ if (init == 0) return;
+
/* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: size %d\n", swig_module.size);
diff --git a/source4/lib/registry/samba.c b/source4/lib/registry/samba.c
index 599385e73c..84a8112f17 100644
--- a/source4/lib/registry/samba.c
+++ b/source4/lib/registry/samba.c
@@ -26,6 +26,7 @@
*/
static WERROR mount_samba_hive(struct registry_context *ctx,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct auth_session_info *auth_info,
struct cli_credentials *creds,
@@ -40,11 +41,11 @@ static WERROR mount_samba_hive(struct registry_context *ctx,
lp_private_dir(lp_ctx),
name);
- error = reg_open_hive(ctx, location, auth_info, creds, lp_ctx, &hive);
+ error = reg_open_hive(ctx, location, auth_info, creds, event_ctx, lp_ctx, &hive);
if (W_ERROR_EQUAL(error, WERR_BADFILE))
error = reg_open_ldb_file(ctx, location, auth_info,
- creds, lp_ctx, &hive);
+ creds, event_ctx, lp_ctx, &hive);
if (!W_ERROR_IS_OK(error))
return error;
@@ -55,29 +56,30 @@ static WERROR mount_samba_hive(struct registry_context *ctx,
_PUBLIC_ WERROR reg_open_samba(TALLOC_CTX *mem_ctx,
struct registry_context **ctx,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
struct auth_session_info *session_info,
struct cli_credentials *credentials)
{
WERROR result;
- result = reg_open_local(mem_ctx, ctx, session_info, credentials);
+ result = reg_open_local(mem_ctx, ctx);
if (!W_ERROR_IS_OK(result)) {
return result;
}
- mount_samba_hive(*ctx, lp_ctx, session_info, credentials,
+ mount_samba_hive(*ctx, ev_ctx, lp_ctx, session_info, credentials,
"hklm", HKEY_LOCAL_MACHINE);
- mount_samba_hive(*ctx, lp_ctx, session_info, credentials,
+ mount_samba_hive(*ctx, ev_ctx, lp_ctx, session_info, credentials,
"hkcr", HKEY_CLASSES_ROOT);
/* FIXME: Should be mounted from NTUSER.DAT in the home directory of the
* current user */
- mount_samba_hive(*ctx, lp_ctx, session_info, credentials,
+ mount_samba_hive(*ctx, ev_ctx, lp_ctx, session_info, credentials,
"hkcu", HKEY_CURRENT_USER);
- mount_samba_hive(*ctx, lp_ctx, session_info, credentials,
+ mount_samba_hive(*ctx, ev_ctx, lp_ctx, session_info, credentials,
"hku", HKEY_USERS);
/* FIXME: Different hive backend for HKEY_CLASSES_ROOT: merged view of HKEY_LOCAL_MACHINE\Software\Classes
diff --git a/source4/lib/registry/tests/bindings.py b/source4/lib/registry/tests/bindings.py
index 314cf778a1..1fb5c70b70 100644
--- a/source4/lib/registry/tests/bindings.py
+++ b/source4/lib/registry/tests/bindings.py
@@ -19,7 +19,7 @@
import os
import unittest
-import registry
+from samba import registry
import samba.tests
class HelperTests(unittest.TestCase):
diff --git a/source4/lib/registry/tests/diff.c b/source4/lib/registry/tests/diff.c
index 690f71fcf7..44ea090527 100644
--- a/source4/lib/registry/tests/diff.c
+++ b/source4/lib/registry/tests/diff.c
@@ -4,6 +4,7 @@
local testing of registry diff functionality
Copyright (C) Jelmer Vernooij 2007
+ Copyright (C) Wilco Baan Hofman 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
@@ -23,28 +24,73 @@
#include "lib/registry/registry.h"
#include "torture/torture.h"
#include "librpc/gen_ndr/winreg.h"
+#include "param/param.h"
-static bool test_generate_diff(struct torture_context *test)
+struct diff_tcase_data {
+ struct registry_context *r1_ctx;
+ struct registry_context *r2_ctx;
+ struct reg_diff_callbacks *callbacks;
+ void *callback_data;
+ char *tempdir;
+ char *filename;
+};
+
+static bool test_generate_diff(struct torture_context *tctx, void *tcase_data)
{
- /* WERROR reg_generate_diff(struct registry_context *ctx1,
- struct registry_context *ctx2,
- const struct reg_diff_callbacks *callbacks,
- void *callback_data)
- */
+ WERROR error;
+ struct diff_tcase_data *td = tcase_data;
+
+ error = reg_generate_diff(td->r1_ctx, td->r2_ctx,
+ td->callbacks,
+ td->callback_data);
+ torture_assert_werr_ok(tctx, error, "reg_generate_diff");
+
return true;
}
-
-static bool test_diff_load(struct torture_context *test)
+#if 0
+static bool test_diff_load(struct torture_context *tctx, void *tcase_data)
{
- /* WERROR reg_diff_load(const char *filename, const struct reg_diff_callbacks *callbacks, void *callback_data) */
+ struct diff_tcase_data *td = tcase_data;
+ struct smb_iconv_convenience *ic;
+ struct reg_diff_callbacks *callbacks;
+ void *data;
+ WERROR error;
+
+ ic = lp_iconv_convenience(tctx->lp_ctx);
+
+ error = reg_diff_load(td->filename, iconv_convenience, callbacks, data);
+ torture_assert_werr_ok(tctx, error, "reg_diff_load");
return true;
}
-
-static bool test_diff_apply(struct torture_context *test)
+#endif
+static bool test_diff_apply(struct torture_context *tctx, void *tcase_data)
{
- /* _PUBLIC_ WERROR reg_diff_apply (const char *filename, struct registry_context *ctx) */
+ struct diff_tcase_data *td = tcase_data;
+ struct registry_key *key;
+ WERROR error;
+
+ error = reg_diff_apply(td->r1_ctx, td->filename);
+ torture_assert_werr_ok(tctx, error, "reg_diff_apply");
+
+ error = td->r1_ctx->ops->get_predefined_key(td->r1_ctx, HKEY_LOCAL_MACHINE, &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKEY_LOCAL_MACHINE failed");
+
+ /* If this generates an error it could be that the apply doesn't work,
+ * but also that the reg_generate_diff didn't work. */
+ error = td->r1_ctx->ops->open_key(td->r1_ctx, key, "Software", &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKLM\\Software failed");
+ error = td->r1_ctx->ops->open_key(td->r1_ctx, key, "Microsoft", &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKLM\\Software\\Microsoft failed");
+ error = td->r1_ctx->ops->open_key(td->r1_ctx, key, "Windows", &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKLM\\..\\Microsoft\\Windows failed");
+ error = td->r1_ctx->ops->open_key(td->r1_ctx, key, "CurrentVersion", &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKLM\\..\\Windows\\CurrentVersion failed");
+ error = td->r1_ctx->ops->open_key(td->r1_ctx, key, "Policies", &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKLM\\..\\CurrentVersion\\Policies failed");
+ error = td->r1_ctx->ops->open_key(td->r1_ctx, key, "Explorer", &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKLM\\..\\Policies\\Explorer failed");
return true;
}
@@ -58,7 +104,7 @@ static WERROR test_add_key(void *callback_data, const char *key_name)
return WERR_OK;
}
-static bool test_generate_diff_key_add(struct torture_context *test)
+static bool test_generate_diff_key_add(struct torture_context *tctx, void *tcase_data)
{
struct reg_diff_callbacks cb;
struct registry_key rk;
@@ -69,15 +115,15 @@ static bool test_generate_diff_key_add(struct torture_context *test)
cb.add_key = test_add_key;
- if (W_ERROR_IS_OK(reg_generate_diff_key(&rk, NULL, "bla", &cb, test)))
+ if (W_ERROR_IS_OK(reg_generate_diff_key(&rk, NULL, "bla", &cb, tctx)))
return false;
- torture_assert_str_equal(test, added_key, "bla", "key added");
+ torture_assert_str_equal(tctx, added_key, "bla", "key added");
return true;
}
-static bool test_generate_diff_key_null(struct torture_context *test)
+static bool test_generate_diff_key_null(struct torture_context *tctx, void *tcase_data)
{
struct reg_diff_callbacks cb;
@@ -89,18 +135,162 @@ static bool test_generate_diff_key_null(struct torture_context *test)
return true;
}
+static void tcase_add_tests (struct torture_tcase *tcase)
+{
+ torture_tcase_add_simple_test(tcase, "test_generate_diff_key_add",
+ test_generate_diff_key_add);
+ torture_tcase_add_simple_test(tcase, "test_generate_diff_key_null",
+ test_generate_diff_key_null);
+ torture_tcase_add_simple_test(tcase, "test_generate_diff",
+ test_generate_diff);
+ torture_tcase_add_simple_test(tcase, "test_diff_apply",
+ test_diff_apply);
+/* torture_tcase_add_simple_test(tcase, "test_diff_load",
+ test_diff_load);
+*/
+}
+
+static bool diff_setup_tcase(struct torture_context *tctx, void **data)
+{
+ struct registry_context *r1_ctx, *r2_ctx;
+ WERROR error;
+ NTSTATUS status;
+ struct hive_key *r1_hklm, *r1_hkcu;
+ struct hive_key *r2_hklm, *r2_hkcu;
+ const char *filename;
+ struct diff_tcase_data *td;
+ struct registry_key *key, *newkey;
+ DATA_BLOB blob;
+
+ td = talloc(tctx, struct diff_tcase_data);
+
+ /* Create two registry contexts */
+ error = reg_open_local(tctx, &r1_ctx);
+ torture_assert_werr_ok(tctx, error, "Opening registry 1 for patch tests failed");
+
+ error = reg_open_local(tctx, &r2_ctx);
+ torture_assert_werr_ok(tctx, error, "Opening registry 2 for patch tests failed");
+
+ /* Create temp directory */
+ status = torture_temp_dir(tctx, "patchfile", &td->tempdir);
+ torture_assert_ntstatus_ok(tctx, status, "Creating temp dir failed");
+
+ /* Create and mount HKLM and HKCU hives for registry 1 */
+ filename = talloc_asprintf(tctx, "%s/r1_local_machine.ldb", td->tempdir);
+ error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->ev, tctx->lp_ctx, &r1_hklm);
+ torture_assert_werr_ok(tctx, error, "Opening local machine file failed");
+
+ error = reg_mount_hive(r1_ctx, r1_hklm, HKEY_LOCAL_MACHINE, NULL);
+ torture_assert_werr_ok(tctx, error, "Mounting hive failed");
+
+ filename = talloc_asprintf(tctx, "%s/r1_current_user.ldb", td->tempdir);
+ error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->ev, tctx->lp_ctx, &r1_hkcu);
+ torture_assert_werr_ok(tctx, error, "Opening current user file failed");
+
+ error = reg_mount_hive(r1_ctx, r1_hkcu, HKEY_CURRENT_USER, NULL);
+ torture_assert_werr_ok(tctx, error, "Mounting hive failed");
+
+ /* Create and mount HKLM and HKCU hives for registry 2 */
+ filename = talloc_asprintf(tctx, "%s/r2_local_machine.ldb", td->tempdir);
+ error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->ev, tctx->lp_ctx, &r2_hklm);
+ torture_assert_werr_ok(tctx, error, "Opening local machine file failed");
+
+ error = reg_mount_hive(r2_ctx, r2_hklm, HKEY_LOCAL_MACHINE, NULL);
+ torture_assert_werr_ok(tctx, error, "Mounting hive failed");
+
+ filename = talloc_asprintf(tctx, "%s/r2_current_user.ldb", td->tempdir);
+ error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->ev, tctx->lp_ctx, &r2_hkcu);
+ torture_assert_werr_ok(tctx, error, "Opening current user file failed");
+
+ error = reg_mount_hive(r2_ctx, r2_hkcu, HKEY_CURRENT_USER, NULL);
+ torture_assert_werr_ok(tctx, error, "Mounting hive failed");
+
+ error = r1_ctx->ops->get_predefined_key(r1_ctx, HKEY_CURRENT_USER, &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKEY_CURRENT_USER failed");
+ error = r1_ctx->ops->create_key(r1_ctx, key, "Network", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Opening HKCU\\Network failed");
+ error = r1_ctx->ops->create_key(r1_ctx, newkey, "L", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Opening HKCU\\Network\\L failed");
+
+ error = r2_ctx->ops->get_predefined_key(r2_ctx, HKEY_LOCAL_MACHINE, &key);
+ torture_assert_werr_ok(tctx, error, "Opening HKEY_LOCAL_MACHINE failed");
+ error = r2_ctx->ops->create_key(r2_ctx, key, "Software", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Creating HKLM\\Sofware failed");
+ error = r2_ctx->ops->create_key(r2_ctx, newkey, "Microsoft", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Creating HKLM\\Software\\Microsoft failed");
+ error = r2_ctx->ops->create_key(r2_ctx, newkey, "Windows", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Creating HKLM\\Software\\Microsoft\\Windows failed");
+ error = r2_ctx->ops->create_key(r2_ctx, newkey, "CurrentVersion", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Creating HKLM\\..\\Windows\\CurrentVersion failed");
+ error = r2_ctx->ops->create_key(r2_ctx, newkey, "Policies", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Creating HKLM\\..\\CurrentVersion\\Policies failed");
+ error = r2_ctx->ops->create_key(r2_ctx, newkey, "Explorer", NULL, NULL, &newkey);
+ torture_assert_werr_ok(tctx, error, "Creating HKLM\\..\\Policies\\Explorer failed");
+
+
+ blob.data = (void *)talloc(r2_ctx, uint32_t);
+ SIVAL(blob.data, 0, 0x03ffffff);
+ blob.length = sizeof(uint32_t);
+
+ r1_ctx->ops->set_value(newkey, "NoDrives", REG_DWORD, blob);
+
+ /* Set test case data */
+ td->r1_ctx = r1_ctx;
+ td->r2_ctx = r2_ctx;
+
+ *data = td;
+
+ return true;
+}
+
+static bool diff_setup_preg_tcase (struct torture_context *tctx, void **data)
+{
+ struct diff_tcase_data *td;
+ struct smb_iconv_convenience *ic;
+ WERROR error;
+
+ diff_setup_tcase(tctx, data);
+ td = *data;
+
+ ic = lp_iconv_convenience(tctx->lp_ctx);
+
+ td->filename = talloc_asprintf(tctx, "%s/test.pol", td->tempdir);
+ error = reg_preg_diff_save(tctx, td->filename, ic, &td->callbacks, &td->callback_data);
+ torture_assert_werr_ok(tctx, error, "reg_preg_diff_save");
+
+ return true;
+}
+
+static bool diff_setup_dotreg_tcase (struct torture_context *tctx, void **data)
+{
+ struct diff_tcase_data *td;
+ struct smb_iconv_convenience *ic;
+ WERROR error;
+
+ diff_setup_tcase(tctx, data);
+ td = *data;
+
+ ic = lp_iconv_convenience(tctx->lp_ctx);
+
+ td->filename = talloc_asprintf(tctx, "%s/test.reg", td->tempdir);
+ error = reg_dotreg_diff_save(tctx, td->filename, ic, &td->callbacks, &td->callback_data);
+ torture_assert_werr_ok(tctx, error, "reg_dotreg_diff_save");
+
+ return true;
+}
+
struct torture_suite *torture_registry_diff(TALLOC_CTX *mem_ctx)
{
+ struct torture_tcase *tcase;
struct torture_suite *suite = torture_suite_create(mem_ctx, "DIFF");
- torture_suite_add_simple_test(suite, "test_generate_diff_key_add",
- test_generate_diff_key_add);
- torture_suite_add_simple_test(suite, "test_generate_diff_key_null",
- test_generate_diff_key_null);
- torture_suite_add_simple_test(suite, "test_diff_apply",
- test_diff_apply);
- torture_suite_add_simple_test(suite, "test_generate_diff",
- test_generate_diff);
- torture_suite_add_simple_test(suite, "test_diff_load",
- test_diff_load);
+
+ tcase = torture_suite_add_tcase(suite, "PReg");
+ torture_tcase_set_fixture(tcase, diff_setup_preg_tcase, NULL);
+ tcase_add_tests(tcase);
+
+ tcase = torture_suite_add_tcase(suite, "dotreg");
+ torture_tcase_set_fixture(tcase, diff_setup_dotreg_tcase, NULL);
+ tcase_add_tests(tcase);
+
return suite;
}
diff --git a/source4/lib/registry/tests/hive.c b/source4/lib/registry/tests/hive.c
index 70b0241b04..edc97c2468 100644
--- a/source4/lib/registry/tests/hive.c
+++ b/source4/lib/registry/tests/hive.c
@@ -26,6 +26,7 @@
#include "librpc/gen_ndr/winreg.h"
#include "system/filesys.h"
#include "param/param.h"
+#include "libcli/security/security.h"
static bool test_del_nonexistant_key(struct torture_context *tctx,
const void *test_data)
@@ -68,14 +69,15 @@ static bool test_keyinfo_nums(struct torture_context *tctx, void *test_data)
struct hive_key *root = (struct hive_key *)test_data;
WERROR error;
struct hive_key *subkey;
- uint32_t data = 42;
+ char data[4];
+ SIVAL(data, 0, 42);
error = hive_key_add_name(tctx, root, "Nested Keyll", NULL,
NULL, &subkey);
torture_assert_werr_ok(tctx, error, "hive_key_add_name");
error = hive_key_set_value(root, "Answer", REG_DWORD,
- data_blob_talloc(tctx, &data, sizeof(data)));
+ data_blob_talloc(tctx, data, sizeof(data)));
torture_assert_werr_ok(tctx, error, "hive_key_set_value");
/* This is a new backend. There should be no subkeys and no
@@ -119,7 +121,8 @@ static bool test_del_recursive(struct torture_context *tctx,
struct hive_key *subkey2;
const struct hive_key *root = (const struct hive_key *)test_data;
TALLOC_CTX *mem_ctx = tctx;
- uint32_t data = 42;
+ char data[4];
+ SIVAL(data, 0, 42);
/* Create a new key under the root */
error = hive_key_add_name(mem_ctx, root, "Parent Key", NULL,
@@ -133,7 +136,7 @@ static bool test_del_recursive(struct torture_context *tctx,
/* Create a new value under "Child Key" */
error = hive_key_set_value(subkey2, "Answer Recursive", REG_DWORD,
- data_blob_talloc(mem_ctx, &data, sizeof(data)));
+ data_blob_talloc(mem_ctx, data, sizeof(data)));
torture_assert_werr_ok(tctx, error, "hive_key_set_value");
/* Deleting "Parent Key" will also delete "Child Key" and the value. */
@@ -179,14 +182,15 @@ static bool test_set_value(struct torture_context *tctx,
struct hive_key *subkey;
const struct hive_key *root = (const struct hive_key *)test_data;
TALLOC_CTX *mem_ctx = tctx;
- uint32_t data = 42;
+ char data[4];
+ SIVAL(data, 0, 42);
error = hive_key_add_name(mem_ctx, root, "YA Nested Key", NULL,
NULL, &subkey);
torture_assert_werr_ok(tctx, error, "hive_key_add_name");
error = hive_key_set_value(subkey, "Answer", REG_DWORD,
- data_blob_talloc(mem_ctx, &data, sizeof(data)));
+ data_blob_talloc(mem_ctx, data, sizeof(data)));
torture_assert_werr_ok(tctx, error, "hive_key_set_value");
return true;
@@ -198,10 +202,12 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data)
struct hive_key *subkey;
const struct hive_key *root = (const struct hive_key *)test_data;
TALLOC_CTX *mem_ctx = tctx;
- uint32_t data = 42;
+ char data[4];
uint32_t type;
DATA_BLOB value;
+ SIVAL(data, 0, 42);
+
error = hive_key_add_name(mem_ctx, root, "EYA Nested Key", NULL,
NULL, &subkey);
torture_assert_werr_ok(tctx, error, "hive_key_add_name");
@@ -211,7 +217,7 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data)
"getting missing value");
error = hive_key_set_value(subkey, "Answer", REG_DWORD,
- data_blob_talloc(mem_ctx, &data, sizeof(data)));
+ data_blob_talloc(mem_ctx, data, sizeof(data)));
torture_assert_werr_ok(tctx, error, "hive_key_set_value");
error = hive_get_value(mem_ctx, subkey, "Answer", &type, &value);
@@ -220,7 +226,7 @@ static bool test_get_value(struct torture_context *tctx, const void *test_data)
torture_assert_int_equal(tctx, value.length, 4, "value length");
torture_assert_int_equal(tctx, type, REG_DWORD, "value type");
- torture_assert_int_equal(tctx, data, IVAL(value.data, 0),
+ torture_assert_mem_equal(tctx, &data, value.data, sizeof(uint32_t),
"value data");
return true;
@@ -232,16 +238,18 @@ static bool test_del_value(struct torture_context *tctx, const void *test_data)
struct hive_key *subkey;
const struct hive_key *root = (const struct hive_key *)test_data;
TALLOC_CTX *mem_ctx = tctx;
- uint32_t data = 42;
+ char data[4];
uint32_t type;
DATA_BLOB value;
+ SIVAL(data, 0, 42);
+
error = hive_key_add_name(mem_ctx, root, "EEYA Nested Key", NULL,
NULL, &subkey);
torture_assert_werr_ok(tctx, error, "hive_key_add_name");
error = hive_key_set_value(subkey, "Answer", REG_DWORD,
- data_blob_talloc(mem_ctx, &data, sizeof(data)));
+ data_blob_talloc(mem_ctx, data, sizeof(data)));
torture_assert_werr_ok(tctx, error, "hive_key_set_value");
error = hive_key_del_value(subkey, "Answer");
@@ -264,17 +272,19 @@ static bool test_list_values(struct torture_context *tctx,
struct hive_key *subkey;
const struct hive_key *root = (const struct hive_key *)test_data;
TALLOC_CTX *mem_ctx = tctx;
- uint32_t data = 42;
+ char data[4];
uint32_t type;
DATA_BLOB value;
const char *name;
+ int data_val = 42;
+ SIVAL(data, 0, data_val);
error = hive_key_add_name(mem_ctx, root, "AYAYA Nested Key", NULL,
NULL, &subkey);
torture_assert_werr_ok(tctx, error, "hive_key_add_name");
error = hive_key_set_value(subkey, "Answer", REG_DWORD,
- data_blob_talloc(mem_ctx, &data, sizeof(data)));
+ data_blob_talloc(mem_ctx, data, sizeof(data)));
torture_assert_werr_ok(tctx, error, "hive_key_set_value");
error = hive_get_value_by_index(mem_ctx, subkey, 0, &name,
@@ -287,7 +297,7 @@ static bool test_list_values(struct torture_context *tctx,
torture_assert_int_equal(tctx, type, REG_DWORD, "value type");
- torture_assert_int_equal(tctx, data, IVAL(value.data, 0), "value data");
+ torture_assert_int_equal(tctx, data_val, IVAL(value.data, 0), "value data");
error = hive_get_value_by_index(mem_ctx, subkey, 1, &name,
&type, &value);
@@ -297,6 +307,56 @@ static bool test_list_values(struct torture_context *tctx,
return true;
}
+static bool test_hive_security(struct torture_context *tctx, const void *_data)
+{
+ struct hive_key *subkey = NULL;
+ const struct hive_key *root = _data;
+ WERROR error;
+ struct security_descriptor *osd, *nsd;
+
+ osd = security_descriptor_dacl_create(tctx,
+ 0,
+ NULL, NULL,
+ SID_NT_AUTHENTICATED_USERS,
+ SEC_ACE_TYPE_ACCESS_ALLOWED,
+ SEC_GENERIC_ALL,
+ SEC_ACE_FLAG_OBJECT_INHERIT,
+ NULL);
+
+
+ error = hive_key_add_name(tctx, root, "SecurityKey", NULL,
+ osd, &subkey);
+ torture_assert_werr_ok(tctx, error, "hive_key_add_name");
+
+ error = hive_get_sec_desc(tctx, subkey, &nsd);
+ torture_assert_werr_ok (tctx, error, "getting security descriptor");
+
+ torture_assert(tctx, security_descriptor_equal(osd, nsd),
+ "security descriptor changed!");
+
+ /* Create a fresh security descriptor */
+ talloc_free(osd);
+ osd = security_descriptor_dacl_create(tctx,
+ 0,
+ NULL, NULL,
+ SID_NT_AUTHENTICATED_USERS,
+ SEC_ACE_TYPE_ACCESS_ALLOWED,
+ SEC_GENERIC_ALL,
+ SEC_ACE_FLAG_OBJECT_INHERIT,
+ NULL);
+
+ error = hive_set_sec_desc(subkey, osd);
+ torture_assert_werr_ok(tctx, error, "setting security descriptor");
+
+ error = hive_get_sec_desc(tctx, subkey, &nsd);
+ torture_assert_werr_ok (tctx, error, "getting security descriptor");
+
+ torture_assert(tctx, security_descriptor_equal(osd, nsd),
+ "security descriptor changed!");
+
+ return true;
+}
+
static void tcase_add_tests(struct torture_tcase *tcase)
{
torture_tcase_add_simple_test_const(tcase, "del_nonexistant_key",
@@ -324,6 +384,8 @@ static void tcase_add_tests(struct torture_tcase *tcase)
test_del_key);
torture_tcase_add_simple_test_const(tcase, "del_value",
test_del_value);
+ torture_tcase_add_simple_test_const(tcase, "check hive security",
+ test_hive_security);
}
static bool hive_setup_dir(struct torture_context *tctx, void **data)
@@ -363,7 +425,7 @@ static bool hive_setup_ldb(struct torture_context *tctx, void **data)
rmdir(dirname);
- error = reg_open_ldb_file(tctx, dirname, NULL, NULL, tctx->lp_ctx, &key);
+ error = reg_open_ldb_file(tctx, dirname, NULL, NULL, tctx->ev, tctx->lp_ctx, &key);
if (!W_ERROR_IS_OK(error)) {
fprintf(stderr, "Unable to initialize ldb hive\n");
return false;
@@ -381,7 +443,7 @@ static bool hive_setup_regf(struct torture_context *tctx, void **data)
char *dirname;
NTSTATUS status;
- status = torture_temp_dir(tctx, "hive-dir", &dirname);
+ status = torture_temp_dir(tctx, "hive-regf", &dirname);
if (!NT_STATUS_IS_OK(status))
return false;
diff --git a/source4/lib/registry/tests/registry.c b/source4/lib/registry/tests/registry.c
index e5e34c11e0..7274bf009d 100644
--- a/source4/lib/registry/tests/registry.c
+++ b/source4/lib/registry/tests/registry.c
@@ -281,7 +281,8 @@ static bool test_query_key_nums(struct torture_context *tctx, void *_data)
struct registry_key *root, *subkey1, *subkey2;
WERROR error;
uint32_t num_subkeys, num_values;
- uint32_t data = 42;
+ char data[4];
+ SIVAL(data, 0, 42);
if (!create_test_key(tctx, rctx, "Berlin", &root, &subkey1))
return false;
@@ -353,13 +354,15 @@ static bool test_set_value(struct torture_context *tctx, void *_data)
struct registry_context *rctx = (struct registry_context *)_data;
struct registry_key *subkey = NULL, *root;
WERROR error;
- uint32_t data = 42;
+ char data[4];
+
+ SIVAL(data, 0, 42);
if (!create_test_key(tctx, rctx, "Dusseldorf", &root, &subkey))
return false;
error = reg_val_set(subkey, "Answer", REG_DWORD,
- data_blob_talloc(tctx, &data, sizeof(data)));
+ data_blob_talloc(tctx, data, sizeof(data)));
torture_assert_werr_ok (tctx, error, "setting value");
return true;
@@ -387,11 +390,11 @@ static bool test_security(struct torture_context *tctx, void *_data)
SEC_ACE_FLAG_OBJECT_INHERIT,
NULL);
- error = reg_set_security(subkey, osd);
- torture_assert_werr_ok(tctx, error, "setting security");
+ error = reg_set_sec_desc(subkey, osd);
+ torture_assert_werr_ok(tctx, error, "setting security descriptor");
- error = reg_get_security(tctx, subkey, &nsd);
- torture_assert_werr_ok (tctx, error, "setting security");
+ error = reg_get_sec_desc(tctx, subkey, &nsd);
+ torture_assert_werr_ok (tctx, error, "getting security descriptor");
torture_assert(tctx, security_descriptor_equal(osd, nsd),
"security descriptor changed!");
@@ -408,8 +411,9 @@ static bool test_get_value(struct torture_context *tctx, void *_data)
struct registry_key *subkey = NULL, *root;
WERROR error;
DATA_BLOB data;
- uint32_t value = 42;
+ char value[4];
uint32_t type;
+ SIVAL(value, 0, 42);
if (!create_test_key(tctx, rctx, "Duisburg", &root, &subkey))
return false;
@@ -420,16 +424,16 @@ static bool test_get_value(struct torture_context *tctx, void *_data)
"getting missing value");
error = reg_val_set(subkey, __FUNCTION__, REG_DWORD,
- data_blob_talloc(tctx, &value, 4));
+ data_blob_talloc(tctx, value, sizeof(value)));
torture_assert_werr_ok(tctx, error, "setting value");
error = reg_key_get_value_by_name(tctx, subkey, __FUNCTION__, &type,
&data);
torture_assert_werr_ok(tctx, error, "getting value");
- torture_assert_int_equal(tctx, 4, data.length, "value length ok");
- torture_assert(tctx, memcmp(data.data, &value, 4) == 0,
- "value content ok");
+ torture_assert_int_equal(tctx, sizeof(value), data.length, "value length ok");
+ torture_assert_mem_equal(tctx, data.data, value, sizeof(value),
+ "value content ok");
torture_assert_int_equal(tctx, REG_DWORD, type, "value type");
return true;
@@ -444,8 +448,9 @@ static bool test_del_value(struct torture_context *tctx, void *_data)
struct registry_key *subkey = NULL, *root;
WERROR error;
DATA_BLOB data;
- uint32_t value = 42;
uint32_t type;
+ char value[4];
+ SIVAL(value, 0, 42);
if (!create_test_key(tctx, rctx, "Warschau", &root, &subkey))
return false;
@@ -456,7 +461,7 @@ static bool test_del_value(struct torture_context *tctx, void *_data)
"getting missing value");
error = reg_val_set(subkey, __FUNCTION__, REG_DWORD,
- data_blob_talloc(tctx, &value, 4));
+ data_blob_talloc(tctx, value, sizeof(value)));
torture_assert_werr_ok (tctx, error, "setting value");
error = reg_del_value(subkey, __FUNCTION__);
@@ -479,15 +484,16 @@ static bool test_list_values(struct torture_context *tctx, void *_data)
struct registry_key *subkey = NULL, *root;
WERROR error;
DATA_BLOB data;
- uint32_t value = 42;
uint32_t type;
const char *name;
+ char value[4];
+ SIVAL(value, 0, 42);
if (!create_test_key(tctx, rctx, "Bonn", &root, &subkey))
return false;
error = reg_val_set(subkey, "bar", REG_DWORD,
- data_blob_talloc(tctx, &value, 4));
+ data_blob_talloc(tctx, value, sizeof(value)));
torture_assert_werr_ok (tctx, error, "setting value");
error = reg_key_get_value_by_index(tctx, subkey, 0, &name,
@@ -495,8 +501,8 @@ static bool test_list_values(struct torture_context *tctx, void *_data)
torture_assert_werr_ok(tctx, error, "getting value");
torture_assert_str_equal(tctx, name, "bar", "value name");
- torture_assert_int_equal(tctx, 4, data.length, "value length");
- torture_assert(tctx, memcmp(data.data, &value, 4) == 0,
+ torture_assert_int_equal(tctx, sizeof(value), data.length, "value length");
+ torture_assert_mem_equal(tctx, data.data, value, sizeof(value),
"value content");
torture_assert_int_equal(tctx, REG_DWORD, type, "value type");
@@ -517,14 +523,14 @@ static bool setup_local_registry(struct torture_context *tctx, void **data)
struct hive_key *hive_key;
const char *filename;
- error = reg_open_local(tctx, &rctx, NULL, NULL);
+ error = reg_open_local(tctx, &rctx);
torture_assert_werr_ok(tctx, error, "Opening local registry failed");
status = torture_temp_dir(tctx, "registry-local", &tempdir);
torture_assert_ntstatus_ok(tctx, status, "Creating temp dir failed");
filename = talloc_asprintf(tctx, "%s/classes_root.ldb", tempdir);
- error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->lp_ctx, &hive_key);
+ error = reg_open_ldb_file(tctx, filename, NULL, NULL, tctx->ev, tctx->lp_ctx, &hive_key);
torture_assert_werr_ok(tctx, error, "Opening classes_root file failed");
error = reg_mount_hive(rctx, hive_key, HKEY_CLASSES_ROOT, NULL);
diff --git a/source4/lib/registry/tools/common.c b/source4/lib/registry/tools/common.c
index cec0f8b906..3ea780de60 100644
--- a/source4/lib/registry/tools/common.c
+++ b/source4/lib/registry/tools/common.c
@@ -42,6 +42,7 @@ struct registry_context *reg_common_open_remote(const char *remote,
}
struct registry_key *reg_common_open_file(const char *path,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
struct cli_credentials *creds)
{
@@ -49,7 +50,7 @@ struct registry_key *reg_common_open_file(const char *path,
struct registry_context *h = NULL;
WERROR error;
- error = reg_open_hive(NULL, path, NULL, creds, lp_ctx, &hive_root);
+ error = reg_open_hive(NULL, path, NULL, creds, ev_ctx, lp_ctx, &hive_root);
if(!W_ERROR_IS_OK(error)) {
fprintf(stderr, "Unable to open '%s': %s \n",
@@ -57,7 +58,7 @@ struct registry_key *reg_common_open_file(const char *path,
return NULL;
}
- error = reg_open_local(NULL, &h, NULL, creds);
+ error = reg_open_local(NULL, &h);
if (!W_ERROR_IS_OK(error)) {
fprintf(stderr, "Unable to initialize local registry: %s\n",
win_errstr(error));
@@ -67,12 +68,14 @@ struct registry_key *reg_common_open_file(const char *path,
return reg_import_hive_key(h, hive_root, -1, NULL);
}
-struct registry_context *reg_common_open_local(struct cli_credentials *creds, struct loadparm_context *lp_ctx)
+struct registry_context *reg_common_open_local(struct cli_credentials *creds,
+ struct event_context *ev_ctx,
+ struct loadparm_context *lp_ctx)
{
WERROR error;
struct registry_context *h = NULL;
- error = reg_open_samba(NULL, &h, lp_ctx, NULL, creds);
+ error = reg_open_samba(NULL, &h, ev_ctx, lp_ctx, NULL, creds);
if(!W_ERROR_IS_OK(error)) {
fprintf(stderr, "Unable to open local registry:%s \n",
diff --git a/source4/lib/registry/tools/regdiff.c b/source4/lib/registry/tools/regdiff.c
index c94380efd2..9b49799bed 100644
--- a/source4/lib/registry/tools/regdiff.c
+++ b/source4/lib/registry/tools/regdiff.c
@@ -29,6 +29,7 @@
enum reg_backend { REG_UNKNOWN, REG_LOCAL, REG_REMOTE, REG_NULL };
static struct registry_context *open_backend(poptContext pc,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
enum reg_backend backend,
const char *remote_host)
@@ -41,14 +42,14 @@ static struct registry_context *open_backend(poptContext pc,
poptPrintUsage(pc, stderr, 0);
return NULL;
case REG_LOCAL:
- error = reg_open_samba(NULL, &ctx, lp_ctx, NULL, cmdline_credentials);
+ error = reg_open_samba(NULL, &ctx, ev_ctx, lp_ctx, NULL, cmdline_credentials);
break;
case REG_REMOTE:
error = reg_open_remote(&ctx, NULL, cmdline_credentials, lp_ctx,
remote_host, NULL);
break;
case REG_NULL:
- error = reg_open_local(NULL, &ctx, NULL, cmdline_credentials);
+ error = reg_open_local(NULL, &ctx);
break;
}
@@ -82,6 +83,7 @@ int main(int argc, const char **argv)
};
TALLOC_CTX *ctx;
void *callback_data;
+ struct event_context *ev_ctx;
struct reg_diff_callbacks *callbacks;
ctx = talloc_init("regdiff");
@@ -116,11 +118,13 @@ int main(int argc, const char **argv)
}
- h1 = open_backend(pc, cmdline_lp_ctx, backend1, remote1);
+ ev_ctx = event_context_init(NULL);
+
+ h1 = open_backend(pc, ev_ctx, cmdline_lp_ctx, backend1, remote1);
if (h1 == NULL)
return 1;
- h2 = open_backend(pc, cmdline_lp_ctx, backend2, remote2);
+ h2 = open_backend(pc, ev_ctx, cmdline_lp_ctx, backend2, remote2);
if (h2 == NULL)
return 1;
diff --git a/source4/lib/registry/tools/regpatch.c b/source4/lib/registry/tools/regpatch.c
index 98443e6456..9285459d85 100644
--- a/source4/lib/registry/tools/regpatch.c
+++ b/source4/lib/registry/tools/regpatch.c
@@ -24,6 +24,7 @@
#include "lib/cmdline/popt_common.h"
#include "lib/registry/tools/common.h"
#include "param/param.h"
+#include "events/events.h"
int main(int argc, char **argv)
{
@@ -33,6 +34,7 @@ int main(int argc, char **argv)
struct registry_context *h;
const char *file = NULL;
const char *remote = NULL;
+ struct event_context *ev;
struct poptOption long_options[] = {
POPT_AUTOHELP
{"remote", 'R', POPT_ARG_STRING, &remote, 0, "connect to specified remote server", NULL},
@@ -47,10 +49,12 @@ int main(int argc, char **argv)
while((opt = poptGetNextOpt(pc)) != -1) {
}
+ ev = event_context_init(NULL);
+
if (remote) {
h = reg_common_open_remote (remote, cmdline_lp_ctx, cmdline_credentials);
} else {
- h = reg_common_open_local (cmdline_credentials, cmdline_lp_ctx);
+ h = reg_common_open_local (cmdline_credentials, ev, cmdline_lp_ctx);
}
if (h == NULL)
diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c
index 58f64cb049..80eafcc4a2 100644
--- a/source4/lib/registry/tools/regshell.c
+++ b/source4/lib/registry/tools/regshell.c
@@ -498,6 +498,7 @@ int main(int argc, char **argv)
poptContext pc;
const char *remote = NULL;
struct regshell_context *ctx;
+ struct event_context *ev_ctx;
bool ret = true;
struct poptOption long_options[] = {
POPT_AUTOHELP
@@ -516,17 +517,19 @@ int main(int argc, char **argv)
ctx = talloc_zero(NULL, struct regshell_context);
+ ev_ctx = event_context_init(ctx);
+
if (remote != NULL) {
ctx->registry = reg_common_open_remote(remote, cmdline_lp_ctx,
cmdline_credentials);
} else if (file != NULL) {
- ctx->current = reg_common_open_file(file, cmdline_lp_ctx, cmdline_credentials);
+ ctx->current = reg_common_open_file(file, ev_ctx, cmdline_lp_ctx, cmdline_credentials);
if (ctx->current == NULL)
return 1;
ctx->registry = ctx->current->context;
ctx->path = talloc_strdup(ctx, "");
} else {
- ctx->registry = reg_common_open_local(cmdline_credentials, cmdline_lp_ctx);
+ ctx->registry = reg_common_open_local(cmdline_credentials, ev_ctx, cmdline_lp_ctx);
}
if (ctx->registry == NULL)
diff --git a/source4/lib/registry/tools/regtree.c b/source4/lib/registry/tools/regtree.c
index 424d3515e0..440399f764 100644
--- a/source4/lib/registry/tools/regtree.c
+++ b/source4/lib/registry/tools/regtree.c
@@ -109,6 +109,7 @@ int main(int argc, char **argv)
poptContext pc;
struct registry_context *h = NULL;
struct registry_key *start_key = NULL;
+ struct event_context *ev_ctx;
WERROR error;
bool fullpath = false, no_values = false;
struct poptOption long_options[] = {
@@ -128,12 +129,14 @@ int main(int argc, char **argv)
while((opt = poptGetNextOpt(pc)) != -1) {
}
+ ev_ctx = event_context_init(NULL);
+
if (remote != NULL) {
h = reg_common_open_remote(remote, cmdline_lp_ctx, cmdline_credentials);
} else if (file != NULL) {
- start_key = reg_common_open_file(file, cmdline_lp_ctx, cmdline_credentials);
+ start_key = reg_common_open_file(file, ev_ctx, cmdline_lp_ctx, cmdline_credentials);
} else {
- h = reg_common_open_local(cmdline_credentials, cmdline_lp_ctx);
+ h = reg_common_open_local(cmdline_credentials, ev_ctx, cmdline_lp_ctx);
}
if (h == NULL && start_key == NULL)
diff --git a/source4/lib/replace/README b/source4/lib/replace/README
index 43f7b08572..4d94317c4b 100644
--- a/source4/lib/replace/README
+++ b/source4/lib/replace/README
@@ -62,6 +62,8 @@ getnameinfo
gai_strerror
getifaddrs
freeifaddrs
+utime
+utimes
Types:
bool
diff --git a/source4/lib/replace/configure.ac b/source4/lib/replace/configure.ac
index 02dc08bf72..81997e09b7 100644
--- a/source4/lib/replace/configure.ac
+++ b/source4/lib/replace/configure.ac
@@ -6,6 +6,7 @@ AC_CONFIG_HEADER(config.h)
CFLAGS="$CFLAGS -I$srcdir"
AC_LIBREPLACE_ALL_CHECKS
+AC_LIBREPLACE_NETWORK_CHECKS
if test "$ac_cv_prog_gcc" = yes; then
CFLAGS="$CFLAGS -Wall"
diff --git a/source4/lib/replace/getaddrinfo.m4 b/source4/lib/replace/getaddrinfo.m4
deleted file mode 100644
index bc6e69ea56..0000000000
--- a/source4/lib/replace/getaddrinfo.m4
+++ /dev/null
@@ -1,32 +0,0 @@
-dnl test for getaddrinfo/getnameinfo
-AC_CACHE_CHECK([for getaddrinfo],libreplace_cv_HAVE_GETADDRINFO,[
-AC_TRY_LINK([
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
-#include <sys/socket.h>
-#include <netdb.h>],
-[
-struct sockaddr sa;
-struct addrinfo *ai = NULL;
-int ret = getaddrinfo(NULL, NULL, NULL, &ai);
-if (ret != 0) {
- const char *es = gai_strerror(ret);
-}
-freeaddrinfo(ai);
-ret = getnameinfo(&sa, sizeof(sa),
- NULL, 0,
- NULL, 0, 0);
-
-],
-libreplace_cv_HAVE_GETADDRINFO=yes,libreplace_cv_HAVE_GETADDRINFO=no)])
-if test x"$libreplace_cv_HAVE_GETADDRINFO" = x"yes"; then
- AC_DEFINE(HAVE_GETADDRINFO,1,[Whether the system has getaddrinfo])
- AC_DEFINE(HAVE_GETNAMEINFO,1,[Whether the system has getnameinfo])
- AC_DEFINE(HAVE_FREEADDRINFO,1,[Whether the system has freeaddrinfo])
- AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether the system has gai_strerror])
-else
- LIBREPLACEOBJ="${LIBREPLACEOBJ} getaddrinfo.o"
-fi
diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4
deleted file mode 100644
index 927bc677db..0000000000
--- a/source4/lib/replace/getifaddrs.m4
+++ /dev/null
@@ -1,128 +0,0 @@
-AC_CHECK_HEADERS([ifaddrs.h])
-
-dnl Used when getifaddrs is not available
-AC_CHECK_MEMBERS([struct sockaddr.sa_len],
- [AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has a sa_len member])],
- [],
- [#include <sys/socket.h>])
-
-dnl test for getifaddrs and freeifaddrs
-AC_CACHE_CHECK([for getifaddrs and freeifaddrs],libreplace_cv_HAVE_GETIFADDRS,[
-AC_TRY_COMPILE([
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <ifaddrs.h>
-#include <netdb.h>],
-[
-struct ifaddrs *ifp = NULL;
-int ret = getifaddrs (&ifp);
-freeifaddrs(ifp);
-],
-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])
-fi
-
-##################
-# look for a method of finding the list of network interfaces
-#
-# This tests need LIBS="${LIBREPLACE_NETWORK_LIBS}"
-#
-old_LIBS=$LIBS
-LIBS="${LIBREPLACE_NETWORK_LIBS}"
-SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS -I$libreplacedir"
-iface=no;
-##################
-# look for a method of finding the list of network interfaces
-iface=no;
-AC_CACHE_CHECK([for iface getifaddrs],libreplace_cv_HAVE_IFACE_GETIFADDRS,[
-AC_TRY_RUN([
-#define HAVE_IFACE_GETIFADDRS 1
-#define NO_CONFIG_H 1
-#define AUTOCONF_TEST 1
-#define SOCKET_WRAPPER_NOT_REPLACE
-#include "$libreplacedir/replace.c"
-#include "$libreplacedir/inet_ntop.c"
-#include "$libreplacedir/snprintf.c"
-#include "$libreplacedir/getifaddrs.c"
-#define getifaddrs_test main
-#include "$libreplacedir/test/getifaddrs.c"],
- 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"
-fi
-
-
-if test $iface = no; then
-AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[
-AC_TRY_RUN([
-#define HAVE_IFACE_AIX 1
-#define NO_CONFIG_H 1
-#define AUTOCONF_TEST 1
-#undef _XOPEN_SOURCE_EXTENDED
-#define SOCKET_WRAPPER_NOT_REPLACE
-#include "$libreplacedir/replace.c"
-#include "$libreplacedir/inet_ntop.c"
-#include "$libreplacedir/snprintf.c"
-#include "$libreplacedir/getifaddrs.c"
-#define getifaddrs_test main
-#include "$libreplacedir/test/getifaddrs.c"],
- 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],libreplace_cv_HAVE_IFACE_IFCONF,[
-AC_TRY_RUN([
-#define HAVE_IFACE_IFCONF 1
-#define NO_CONFIG_H 1
-#define AUTOCONF_TEST 1
-#define SOCKET_WRAPPER_NOT_REPLACE
-#include "$libreplacedir/replace.c"
-#include "$libreplacedir/inet_ntop.c"
-#include "$libreplacedir/snprintf.c"
-#include "$libreplacedir/getifaddrs.c"
-#define getifaddrs_test main
-#include "$libreplacedir/test/getifaddrs.c"],
- 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],libreplace_cv_HAVE_IFACE_IFREQ,[
-AC_TRY_RUN([
-#define HAVE_IFACE_IFREQ 1
-#define NO_CONFIG_H 1
-#define AUTOCONF_TEST 1
-#define SOCKET_WRAPPER_NOT_REPLACE
-#include "$libreplacedir/replace.c"
-#include "$libreplacedir/inet_ntop.c"
-#include "$libreplacedir/snprintf.c"
-#include "$libreplacedir/getifaddrs.c"
-#define getifaddrs_test main
-#include "$libreplacedir/test/getifaddrs.c"],
- 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
-
-LIBS=$old_LIBS
-CPPFLAGS="$SAVE_CPPFLAGS"
-
diff --git a/source4/lib/replace/inet_aton.m4 b/source4/lib/replace/inet_aton.m4
deleted file mode 100644
index 853688ef6b..0000000000
--- a/source4/lib/replace/inet_aton.m4
+++ /dev/null
@@ -1 +0,0 @@
-AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_aton.o"])
diff --git a/source4/lib/replace/inet_ntoa.m4 b/source4/lib/replace/inet_ntoa.m4
deleted file mode 100644
index 5aaa9350c5..0000000000
--- a/source4/lib/replace/inet_ntoa.m4
+++ /dev/null
@@ -1,19 +0,0 @@
-AC_CHECK_FUNCS(inet_ntoa,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntoa.o"])
-
-AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[
-AC_TRY_RUN([
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-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);}],
- 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
diff --git a/source4/lib/replace/inet_ntop.m4 b/source4/lib/replace/inet_ntop.m4
deleted file mode 100644
index 6f39056f1d..0000000000
--- a/source4/lib/replace/inet_ntop.m4
+++ /dev/null
@@ -1 +0,0 @@
-AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_ntop.o"])
diff --git a/source4/lib/replace/inet_pton.m4 b/source4/lib/replace/inet_pton.m4
deleted file mode 100644
index 51de9275d0..0000000000
--- a/source4/lib/replace/inet_pton.m4
+++ /dev/null
@@ -1 +0,0 @@
-AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} inet_pton.o"])
diff --git a/source4/lib/replace/libreplace.m4 b/source4/lib/replace/libreplace.m4
index 8e17258918..6a85ff5a82 100644
--- a/source4/lib/replace/libreplace.m4
+++ b/source4/lib/replace/libreplace.m4
@@ -96,65 +96,9 @@ fi
AC_CHECK_HEADERS(sys/syslog.h syslog.h)
AC_CHECK_HEADERS(sys/time.h time.h)
AC_CHECK_HEADERS(stdarg.h vararg.h)
-AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h)
-AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
-AC_CHECK_HEADERS(sys/sockio.h sys/un.h)
AC_CHECK_HEADERS(sys/mount.h mntent.h)
AC_CHECK_HEADERS(stropts.h)
-dnl we need to check that net/if.h really can be used, to cope with hpux
-dnl where including it always fails
-AC_CACHE_CHECK([for usable net/if.h],libreplace_cv_USABLE_NET_IF_H,[
- AC_COMPILE_IFELSE([AC_LANG_SOURCE([
- AC_INCLUDES_DEFAULT
- #if HAVE_SYS_SOCKET_H
- # include <sys/socket.h>
- #endif
- #include <net/if.h>
- int main(void) {return 0;}])],
- [libreplace_cv_USABLE_NET_IF_H=yes],
- [libreplace_cv_USABLE_NET_IF_H=no]
- )
-])
-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_HAVE_TYPE([socklen_t],[#include <sys/socket.h>])
-AC_HAVE_TYPE([sa_family_t],[#include <sys/socket.h>])
-AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])
-AC_HAVE_TYPE([struct sockaddr], [#include <sys/socket.h>])
-AC_HAVE_TYPE([struct sockaddr_storage], [
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-])
-AC_HAVE_TYPE([struct sockaddr_in6], [
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-])
-
-if test x"$ac_cv_type_struct_sockaddr_storage" = x"yes"; then
-AC_CHECK_MEMBER(struct sockaddr_storage.ss_family,
- AC_DEFINE(HAVE_SS_FAMILY, 1, [Defined if struct sockaddr_storage has ss_family field]),,
- [
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
- ])
-
-if test x"$ac_cv_member_struct_sockaddr_storage_ss_family" != x"yes"; then
-AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family,
- AC_DEFINE(HAVE___SS_FAMILY, 1, [Defined if struct sockaddr_storage has __ss_family field]),,
- [
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
- ])
-fi
-fi
-
AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup)
@@ -326,15 +270,7 @@ m4_include(getpass.m4)
m4_include(strptime.m4)
m4_include(win32.m4)
m4_include(timegm.m4)
-m4_include(socket.m4)
-m4_include(inet_ntop.m4)
-m4_include(inet_pton.m4)
-m4_include(inet_aton.m4)
-m4_include(inet_ntoa.m4)
-m4_include(getaddrinfo.m4)
m4_include(repdir.m4)
-m4_include(getifaddrs.m4)
-m4_include(socketpair.m4)
AC_CHECK_FUNCS([syslog printf memset memcpy],,[AC_MSG_ERROR([Required function not found])])
@@ -361,5 +297,6 @@ CFLAGS="$CFLAGS -I$libreplacedir"
m4_include(libreplace_cc.m4)
m4_include(libreplace_ld.m4)
+m4_include(libreplace_network.m4)
m4_include(libreplace_macros.m4)
m4_include(autoconf-2.60.m4)
diff --git a/source4/lib/replace/libreplace_cc.m4 b/source4/lib/replace/libreplace_cc.m4
index bf5056838d..0ce0958a96 100644
--- a/source4/lib/replace/libreplace_cc.m4
+++ b/source4/lib/replace/libreplace_cc.m4
@@ -132,7 +132,8 @@ AC_CHECK_SIZEOF(off_t)
AC_CHECK_SIZEOF(size_t)
AC_CHECK_SIZEOF(ssize_t)
-AC_CHECK_TYPE(intptr_t, unsigned long long)
+AC_CHECK_TYPE(intptr_t, long long)
+AC_CHECK_TYPE(uintptr_t, unsigned long long)
AC_CHECK_TYPE(ptrdiff_t, unsigned long long)
if test x"$ac_cv_type_long_long" != x"yes";then
diff --git a/source4/lib/replace/libreplace_ld.m4 b/source4/lib/replace/libreplace_ld.m4
index f0d10c1e3e..9995d69bbc 100644
--- a/source4/lib/replace/libreplace_ld.m4
+++ b/source4/lib/replace/libreplace_ld.m4
@@ -270,6 +270,9 @@ AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG],
*darwin*)
LD_SHLIB_ALLOW_UNDEF_FLAG="-undefined dynamic_lookup"
;;
+ *aix*)
+ LD_SHLIB_ALLOW_UNDEF_FLAG="--Wl,-bnoentry"
+ ;;
esac
AC_SUBST(LD_SHLIB_ALLOW_UNDEF_FLAG)
diff --git a/source4/lib/replace/libreplace_network.m4 b/source4/lib/replace/libreplace_network.m4
new file mode 100644
index 0000000000..4edb55c03a
--- /dev/null
+++ b/source4/lib/replace/libreplace_network.m4
@@ -0,0 +1,377 @@
+AC_DEFUN_ONCE(AC_LIBREPLACE_NETWORK_CHECKS,
+[
+echo "LIBREPLACE_NETWORK_CHECKS: START"
+
+AC_DEFINE(LIBREPLACE_NETWORK_CHECKS, 1, [LIBREPLACE_NETWORK_CHECKS were used])
+LIBREPLACE_NETWORK_OBJS=""
+LIBREPLACE_NETWORK_LIBS=""
+
+AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h)
+AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
+AC_CHECK_HEADERS(sys/sockio.h sys/un.h)
+
+dnl we need to check that net/if.h really can be used, to cope with hpux
+dnl where including it always fails
+AC_CACHE_CHECK([for usable net/if.h],libreplace_cv_USABLE_NET_IF_H,[
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+ AC_INCLUDES_DEFAULT
+ #if HAVE_SYS_SOCKET_H
+ # include <sys/socket.h>
+ #endif
+ #include <net/if.h>
+ int main(void) {return 0;}])],
+ [libreplace_cv_USABLE_NET_IF_H=yes],
+ [libreplace_cv_USABLE_NET_IF_H=no]
+ )
+])
+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_HAVE_TYPE([socklen_t],[#include <sys/socket.h>])
+AC_HAVE_TYPE([sa_family_t],[#include <sys/socket.h>])
+AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])
+AC_HAVE_TYPE([struct sockaddr], [#include <sys/socket.h>])
+AC_HAVE_TYPE([struct sockaddr_storage], [
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+])
+AC_HAVE_TYPE([struct sockaddr_in6], [
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+])
+
+if test x"$ac_cv_type_struct_sockaddr_storage" = x"yes"; then
+AC_CHECK_MEMBER(struct sockaddr_storage.ss_family,
+ AC_DEFINE(HAVE_SS_FAMILY, 1, [Defined if struct sockaddr_storage has ss_family field]),,
+ [
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+ ])
+
+if test x"$ac_cv_member_struct_sockaddr_storage_ss_family" != x"yes"; then
+AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family,
+ AC_DEFINE(HAVE___SS_FAMILY, 1, [Defined if struct sockaddr_storage has __ss_family field]),,
+ [
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+ ])
+fi
+fi
+
+AC_CACHE_CHECK([for sin_len in sock],libreplace_cv_HAVE_SOCK_SIN_LEN,[
+ AC_TRY_COMPILE(
+ [
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+ ],[
+struct sockaddr_in sock; sock.sin_len = sizeof(sock);
+ ],[
+ libreplace_cv_HAVE_SOCK_SIN_LEN=yes
+ ],[
+ libreplace_cv_HAVE_SOCK_SIN_LEN=no
+ ])
+])
+if test x"$libreplace_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
+ AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
+fi
+
+############################################
+# check for unix domain sockets
+AC_CACHE_CHECK([for unix domain sockets],libreplace_cv_HAVE_UNIXSOCKET,[
+ AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+ ],[
+struct sockaddr_un sunaddr;
+sunaddr.sun_family = AF_UNIX;
+ ],[
+ libreplace_cv_HAVE_UNIXSOCKET=yes
+ ],[
+ libreplace_cv_HAVE_UNIXSOCKET=no
+ ])
+])
+if test x"$libreplace_cv_HAVE_UNIXSOCKET" = x"yes"; then
+ AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support])
+fi
+
+dnl The following test is roughl taken from the cvs sources.
+dnl
+dnl If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
+dnl The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
+dnl libsocket.so which has a bad implementation of gethostbyname (it
+dnl only looks in /etc/hosts), so we only look for -lsocket if we need
+dnl it.
+AC_CHECK_FUNCS(connect)
+if test x"$ac_cv_func_connect" = x"no"; then
+ AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, connect)
+ AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, connect)
+ AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, connect)
+ AC_CHECK_LIB_EXT(inet, LIBREPLACE_NETWORK_LIBS, connect)
+ dnl We can't just call AC_CHECK_FUNCS(connect) here,
+ dnl because the value has been cached.
+ if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" ||
+ test x"$ac_cv_lib_ext_nsl_connect" = x"yes" ||
+ test x"$ac_cv_lib_ext_socket_connect" = x"yes" ||
+ test x"$ac_cv_lib_ext_inet_connect" = x"yes"
+ then
+ AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
+ fi
+fi
+
+AC_CHECK_FUNCS(gethostbyname)
+if test x"$ac_cv_func_gethostbyname" = x"no"; then
+ AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, gethostbyname)
+ AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, gethostbyname)
+ AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, gethostbyname)
+ dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here,
+ dnl because the value has been cached.
+ if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" = x"yes" ||
+ test x"$ac_cv_lib_ext_nsl_gethostbyname" = x"yes" ||
+ test x"$ac_cv_lib_ext_socket_gethostbyname" = x"yes"
+ then
+ AC_DEFINE(HAVE_GETHOSTBYNAME,1,
+ [Whether the system has gethostbyname()])
+ fi
+fi
+
+dnl HP-UX has if_nametoindex in -lipv6
+AC_CHECK_FUNCS(if_nametoindex)
+if test x"$ac_cv_func_if_nametoindex" = x"no"; then
+ AC_CHECK_LIB_EXT(ipv6, LIBREPLACE_NETWORK_LIBS, if_nametoindex)
+ dnl We can't just call AC_CHECK_FUNCS(if_nametoindex) here,
+ dnl because the value has been cached.
+ if test x"$ac_cv_lib_ext_ipv6_if_nametoindex" = x"yes"
+ then
+ AC_DEFINE(HAVE_IF_NAMETOINDEX, 1,
+ [Whether the system has if_nametoindex()])
+ fi
+fi
+
+# The following tests need LIBS="${LIBREPLACE_NETWORK_LIBS}"
+old_LIBS=$LIBS
+LIBS="${LIBREPLACE_NETWORK_LIBS}"
+SAVE_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS -I$libreplacedir"
+
+AC_CHECK_FUNCS(socketpair,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} socketpair.o"])
+
+AC_CACHE_CHECK([for broken inet_ntoa],libreplace_cv_REPLACE_INET_NTOA,[
+AC_TRY_RUN([
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+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);}],
+ libreplace_cv_REPLACE_INET_NTOA=yes,libreplace_cv_REPLACE_INET_NTOA=no,libreplace_cv_REPLACE_INET_NTOA=cross)])
+
+AC_CHECK_FUNCS(inet_ntoa,[],[libreplace_cv_REPLACE_INET_NTOA=yes])
+if test x"$libreplace_cv_REPLACE_INET_NTOA" = x"yes"; then
+ AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
+ LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_ntoa.o"
+fi
+
+AC_CHECK_FUNCS(inet_aton,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_aton.o"])
+
+AC_CHECK_FUNCS(inet_ntop,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_ntop.o"])
+
+AC_CHECK_FUNCS(inet_pton,[],[LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} inet_pton.o"])
+
+dnl test for getaddrinfo/getnameinfo
+AC_CACHE_CHECK([for getaddrinfo],libreplace_cv_HAVE_GETADDRINFO,[
+AC_TRY_LINK([
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+#include <sys/socket.h>
+#include <netdb.h>],
+[
+struct sockaddr sa;
+struct addrinfo *ai = NULL;
+int ret = getaddrinfo(NULL, NULL, NULL, &ai);
+if (ret != 0) {
+ const char *es = gai_strerror(ret);
+}
+freeaddrinfo(ai);
+ret = getnameinfo(&sa, sizeof(sa),
+ NULL, 0,
+ NULL, 0, 0);
+
+],
+libreplace_cv_HAVE_GETADDRINFO=yes,libreplace_cv_HAVE_GETADDRINFO=no)])
+if test x"$libreplace_cv_HAVE_GETADDRINFO" = x"yes"; then
+ AC_DEFINE(HAVE_GETADDRINFO,1,[Whether the system has getaddrinfo])
+ AC_DEFINE(HAVE_GETNAMEINFO,1,[Whether the system has getnameinfo])
+ AC_DEFINE(HAVE_FREEADDRINFO,1,[Whether the system has freeaddrinfo])
+ AC_DEFINE(HAVE_GAI_STRERROR,1,[Whether the system has gai_strerror])
+else
+ LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} getaddrinfo.o"
+fi
+
+AC_CHECK_HEADERS([ifaddrs.h])
+
+dnl Used when getifaddrs is not available
+AC_CHECK_MEMBERS([struct sockaddr.sa_len],
+ [AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has a sa_len member])],
+ [],
+ [#include <sys/socket.h>])
+
+dnl test for getifaddrs and freeifaddrs
+AC_CACHE_CHECK([for getifaddrs and freeifaddrs],libreplace_cv_HAVE_GETIFADDRS,[
+AC_TRY_COMPILE([
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <ifaddrs.h>
+#include <netdb.h>],
+[
+struct ifaddrs *ifp = NULL;
+int ret = getifaddrs (&ifp);
+freeifaddrs(ifp);
+],
+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])
+fi
+
+##################
+# look for a method of finding the list of network interfaces
+iface=no;
+AC_CACHE_CHECK([for iface getifaddrs],libreplace_cv_HAVE_IFACE_GETIFADDRS,[
+AC_TRY_RUN([
+#define HAVE_IFACE_GETIFADDRS 1
+#define NO_CONFIG_H 1
+#define AUTOCONF_TEST 1
+#define SOCKET_WRAPPER_NOT_REPLACE
+#include "$libreplacedir/replace.c"
+#include "$libreplacedir/inet_ntop.c"
+#include "$libreplacedir/snprintf.c"
+#include "$libreplacedir/getifaddrs.c"
+#define getifaddrs_test main
+#include "$libreplacedir/test/getifaddrs.c"],
+ 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
+ LIBREPLACE_NETWORK_OBJS="${LIBREPLACE_NETWORK_OBJS} getifaddrs.o"
+fi
+
+
+if test $iface = no; then
+AC_CACHE_CHECK([for iface AIX],libreplace_cv_HAVE_IFACE_AIX,[
+AC_TRY_RUN([
+#define HAVE_IFACE_AIX 1
+#define NO_CONFIG_H 1
+#define AUTOCONF_TEST 1
+#undef _XOPEN_SOURCE_EXTENDED
+#define SOCKET_WRAPPER_NOT_REPLACE
+#include "$libreplacedir/replace.c"
+#include "$libreplacedir/inet_ntop.c"
+#include "$libreplacedir/snprintf.c"
+#include "$libreplacedir/getifaddrs.c"
+#define getifaddrs_test main
+#include "$libreplacedir/test/getifaddrs.c"],
+ 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],libreplace_cv_HAVE_IFACE_IFCONF,[
+AC_TRY_RUN([
+#define HAVE_IFACE_IFCONF 1
+#define NO_CONFIG_H 1
+#define AUTOCONF_TEST 1
+#define SOCKET_WRAPPER_NOT_REPLACE
+#include "$libreplacedir/replace.c"
+#include "$libreplacedir/inet_ntop.c"
+#include "$libreplacedir/snprintf.c"
+#include "$libreplacedir/getifaddrs.c"
+#define getifaddrs_test main
+#include "$libreplacedir/test/getifaddrs.c"],
+ 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],libreplace_cv_HAVE_IFACE_IFREQ,[
+AC_TRY_RUN([
+#define HAVE_IFACE_IFREQ 1
+#define NO_CONFIG_H 1
+#define AUTOCONF_TEST 1
+#define SOCKET_WRAPPER_NOT_REPLACE
+#include "$libreplacedir/replace.c"
+#include "$libreplacedir/inet_ntop.c"
+#include "$libreplacedir/snprintf.c"
+#include "$libreplacedir/getifaddrs.c"
+#define getifaddrs_test main
+#include "$libreplacedir/test/getifaddrs.c"],
+ 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
+
+dnl test for ipv6
+AC_CACHE_CHECK([for ipv6 support],libreplace_cv_HAVE_IPV6,[
+ AC_TRY_LINK([
+#include <stdlib.h> /* for NULL */
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netdb.h>
+ ],
+ [
+struct sockaddr_storage sa_store;
+struct addrinfo *ai = NULL;
+struct in6_addr in6addr;
+int idx = if_nametoindex("iface1");
+int s = socket(AF_INET6, SOCK_STREAM, 0);
+int ret = getaddrinfo(NULL, NULL, NULL, &ai);
+if (ret != 0) {
+ const char *es = gai_strerror(ret);
+}
+freeaddrinfo(ai);
+ ],[
+ libreplace_cv_HAVE_IPV6=yes
+ ],[
+ libreplace_cv_HAVE_IPV6=no
+ ])
+])
+if test x"$libreplace_cv_HAVE_IPV6" = x"yes"; then
+ AC_DEFINE(HAVE_IPV6,1,[Whether the system has IPv6 support])
+fi
+
+LIBS=$old_LIBS
+CPPFLAGS="$SAVE_CPPFLAGS"
+
+LIBREPLACEOBJ="${LIBREPLACEOBJ} ${LIBREPLACE_NETWORK_OBJS}"
+
+echo "LIBREPLACE_NETWORK_CHECKS: END"
+]) dnl end AC_LIBREPLACE_NETWORK_CHECKS
diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c
index 6930f9b079..2c3f14c2df 100644
--- a/source4/lib/replace/replace.c
+++ b/source4/lib/replace/replace.c
@@ -458,7 +458,7 @@ char *rep_strcasestr(const char *haystack, const char *needle)
for (s=haystack;*s;s++) {
if (toupper(*needle) == toupper(*s) &&
strncasecmp(s, needle, nlen) == 0) {
- return (char *)((intptr_t)s);
+ return (char *)((uintptr_t)s);
}
}
return NULL;
@@ -584,3 +584,30 @@ int rep_unsetenv(const char *name)
return 0;
}
#endif
+
+#ifndef HAVE_UTIME
+int rep_utime(const char *filename, const struct utimbuf *buf)
+{
+ errno = ENOSYS;
+ return -1;
+}
+#endif
+
+#ifndef HAVE_UTIMES
+int rep_utimes(const char *filename, const struct timeval tv[2])
+{
+ struct utimbuf u;
+
+ u.actime = tv[0].tv_sec;
+ if (tv[0].tv_usec > 500000) {
+ u.actime += 1;
+ }
+
+ u.modtime = tv[1].tv_sec;
+ if (tv[1].tv_usec > 500000) {
+ u.modtime += 1;
+ }
+
+ return utime(filename, &u);
+}
+#endif
diff --git a/source4/lib/replace/replace.h b/source4/lib/replace/replace.h
index 5fe79394eb..c69ea6cdac 100644
--- a/source4/lib/replace/replace.h
+++ b/source4/lib/replace/replace.h
@@ -101,6 +101,16 @@ void *rep_memmove(void *dest,const void *src,int size);
/* prototype is in "system/time.h" */
#endif
+#ifndef HAVE_UTIME
+#define utime rep_utime
+/* prototype is in "system/time.h" */
+#endif
+
+#ifndef HAVE_UTIMES
+#define utimes rep_utimes
+/* prototype is in "system/time.h" */
+#endif
+
#ifndef HAVE_STRLCPY
#define strlcpy rep_strlcpy
size_t rep_strlcpy(char *d, const char *s, size_t bufsize);
@@ -499,7 +509,7 @@ typedef int bool;
Also, please call this via the discard_const_p() macro interface, as that
makes the return type safe.
*/
-#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
+#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
/** Type-safe version of discard_const */
#define discard_const_p(type, ptr) ((type *)discard_const(ptr))
diff --git a/source4/lib/replace/samba.m4 b/source4/lib/replace/samba.m4
index 7984ef31db..07c4d38887 100644
--- a/source4/lib/replace/samba.m4
+++ b/source4/lib/replace/samba.m4
@@ -1,4 +1,5 @@
AC_LIBREPLACE_BROKEN_CHECKS
+AC_LIBREPLACE_NETWORK_CHECKS
SMB_EXT_LIB(LIBREPLACE_EXT, [${LIBDL}])
SMB_ENABLE(LIBREPLACE_EXT)
diff --git a/source4/lib/replace/socket.m4 b/source4/lib/replace/socket.m4
deleted file mode 100644
index 984f81f15f..0000000000
--- a/source4/lib/replace/socket.m4
+++ /dev/null
@@ -1,39 +0,0 @@
-dnl The following test is roughl taken from the cvs sources.
-dnl
-dnl If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
-dnl The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
-dnl libsocket.so which has a bad implementation of gethostbyname (it
-dnl only looks in /etc/hosts), so we only look for -lsocket if we need
-dnl it.
-AC_CHECK_FUNCS(connect)
-if test x"$ac_cv_func_connect" = x"no"; then
- AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, connect)
- AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, connect)
- AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, connect)
- AC_CHECK_LIB_EXT(inet, LIBREPLACE_NETWORK_LIBS, connect)
- dnl We can't just call AC_CHECK_FUNCS(connect) here,
- dnl because the value has been cached.
- if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" ||
- test x"$ac_cv_lib_ext_nsl_connect" = x"yes" ||
- test x"$ac_cv_lib_ext_socket_connect" = x"yes" ||
- test x"$ac_cv_lib_ext_inet_connect" = x"yes"
- then
- AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
- fi
-fi
-
-AC_CHECK_FUNCS(gethostbyname)
-if test x"$ac_cv_func_gethostbyname" = x"no"; then
- AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, gethostbyname)
- AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, gethostbyname)
- AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, gethostbyname)
- dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here,
- dnl because the value has been cached.
- if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" = x"yes" ||
- test x"$ac_cv_lib_ext_nsl_gethostbyname" = x"yes" ||
- test x"$ac_cv_lib_ext_socket_gethostbyname" = x"yes"
- then
- AC_DEFINE(HAVE_GETHOSTBYNAME,1,
- [Whether the system has gethostbyname()])
- fi
-fi
diff --git a/source4/lib/replace/socketpair.m4 b/source4/lib/replace/socketpair.m4
deleted file mode 100644
index 7088334cda..0000000000
--- a/source4/lib/replace/socketpair.m4
+++ /dev/null
@@ -1 +0,0 @@
-AC_CHECK_FUNCS(socketpair,[],[LIBREPLACEOBJ="${LIBREPLACEOBJ} socketpair.o"])
diff --git a/source4/lib/replace/system/config.m4 b/source4/lib/replace/system/config.m4
index 66c2bd652a..5c9b53d5c5 100644
--- a/source4/lib/replace/system/config.m4
+++ b/source4/lib/replace/system/config.m4
@@ -9,6 +9,7 @@ AC_CHECK_HEADERS(sys/select.h)
# time
AC_CHECK_HEADERS(sys/time.h utime.h)
AC_HEADER_TIME
+AC_CHECK_FUNCS(utime utimes)
# wait
AC_HEADER_SYS_WAIT
diff --git a/source4/lib/replace/system/network.h b/source4/lib/replace/system/network.h
index a5fb813aa1..077892a54e 100644
--- a/source4/lib/replace/system/network.h
+++ b/source4/lib/replace/system/network.h
@@ -27,6 +27,10 @@
*/
+#ifndef LIBREPLACE_NETWORK_CHECKS
+#error "AC_LIBREPLACE_NETWORK_CHECKS missing in configure"
+#endif
+
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
diff --git a/source4/lib/replace/system/time.h b/source4/lib/replace/system/time.h
index 036812ab8f..4abf295d1a 100644
--- a/source4/lib/replace/system/time.h
+++ b/source4/lib/replace/system/time.h
@@ -39,6 +39,11 @@
#ifdef HAVE_UTIME_H
#include <utime.h>
+#else
+struct utimbuf {
+ time_t actime; /* access time */
+ time_t modtime; /* modification time */
+};
#endif
#ifndef HAVE_MKTIME
@@ -51,4 +56,14 @@ time_t rep_mktime(struct tm *t);
time_t rep_timegm(struct tm *tm);
#endif
+#ifndef HAVE_UTIME
+/* define is in "replace.h" */
+int rep_utime(const char *filename, const struct utimbuf *buf);
+#endif
+
+#ifndef HAVE_UTIMES
+/* define is in "replace.h" */
+int rep_utimes(const char *filename, const struct timeval tv[2]);
+#endif
+
#endif
diff --git a/source4/lib/replace/test/testsuite.c b/source4/lib/replace/test/testsuite.c
index b538360365..1e8290906e 100644
--- a/source4/lib/replace/test/testsuite.c
+++ b/source4/lib/replace/test/testsuite.c
@@ -872,6 +872,149 @@ static int test_getifaddrs(void)
return true;
}
+static int test_utime(void)
+{
+ struct utimbuf u;
+ struct stat st1, st2, st3;
+ int fd;
+
+ printf("test: utime\n");
+ unlink(TESTFILE);
+
+ fd = open(TESTFILE, O_RDWR|O_CREAT, 0600);
+ if (fd == -1) {
+ printf("failure: utime [\n"
+ "creating '%s' failed - %s\n]\n",
+ TESTFILE, strerror(errno));
+ return false;
+ }
+
+ if (fstat(fd, &st1) != 0) {
+ printf("failure: utime [\n"
+ "fstat (1) failed - %s\n]\n",
+ strerror(errno));
+ return false;
+ }
+
+ u.actime = st1.st_atime + 300;
+ u.modtime = st1.st_mtime - 300;
+ if (utime(TESTFILE, &u) != 0) {
+ printf("failure: utime [\n"
+ "utime(&u) failed - %s\n]\n",
+ strerror(errno));
+ return false;
+ }
+
+ if (fstat(fd, &st2) != 0) {
+ printf("failure: utime [\n"
+ "fstat (2) failed - %s\n]\n",
+ strerror(errno));
+ return false;
+ }
+
+ if (utime(TESTFILE, NULL) != 0) {
+ printf("failure: utime [\n"
+ "utime(NULL) failed - %s\n]\n",
+ strerror(errno));
+ return false;
+ }
+
+ if (fstat(fd, &st3) != 0) {
+ printf("failure: utime [\n"
+ "fstat (3) failed - %s\n]\n",
+ strerror(errno));
+ return false;
+ }
+
+#define CMP_VAL(a,c,b) do { \
+ if (a c b) { \
+ printf("failure: utime [\n" \
+ "%s: %s(%d) %s %s(%d)\n]\n", \
+ __location__, \
+ #a, (int)a, #c, #b, (int)b); \
+ return false; \
+ } \
+} while(0)
+#define EQUAL_VAL(a,b) CMP_VAL(a,!=,b)
+#define GREATER_VAL(a,b) CMP_VAL(a,<=,b)
+#define LESSER_VAL(a,b) CMP_VAL(a,>=,b)
+
+ EQUAL_VAL(st2.st_atime, st1.st_atime + 300);
+ EQUAL_VAL(st2.st_mtime, st1.st_mtime - 300);
+ LESSER_VAL(st3.st_atime, st2.st_atime);
+ GREATER_VAL(st3.st_mtime, st2.st_mtime);
+
+#undef CMP_VAL
+#undef EQUAL_VAL
+#undef GREATER_VAL
+#undef LESSER_VAL
+
+ unlink(TESTFILE);
+ printf("success: utime\n");
+ return true;
+}
+
+static int test_utimes(void)
+{
+ struct timeval tv[2];
+ struct stat st1, st2;
+ int fd;
+
+ printf("test: utimes\n");
+ unlink(TESTFILE);
+
+ fd = open(TESTFILE, O_RDWR|O_CREAT, 0600);
+ if (fd == -1) {
+ printf("failure: utimes [\n"
+ "creating '%s' failed - %s\n]\n",
+ TESTFILE, strerror(errno));
+ return false;
+ }
+
+ if (fstat(fd, &st1) != 0) {
+ printf("failure: utimes [\n"
+ "fstat (1) failed - %s\n]\n",
+ strerror(errno));
+ return false;
+ }
+
+ ZERO_STRUCT(tv);
+ tv[0].tv_sec = st1.st_atime + 300;
+ tv[1].tv_sec = st1.st_mtime - 300;
+ if (utimes(TESTFILE, tv) != 0) {
+ printf("failure: utimes [\n"
+ "utimes(tv) failed - %s\n]\n",
+ strerror(errno));
+ return false;
+ }
+
+ if (fstat(fd, &st2) != 0) {
+ printf("failure: utimes [\n"
+ "fstat (2) failed - %s\n]\n",
+ strerror(errno));
+ return false;
+ }
+
+#define EQUAL_VAL(a,b) do { \
+ if (a != b) { \
+ printf("failure: utimes [\n" \
+ "%s: %s(%d) != %s(%d)\n]\n", \
+ __location__, \
+ #a, (int)a, #b, (int)b); \
+ return false; \
+ } \
+} while(0)
+
+ EQUAL_VAL(st2.st_atime, st1.st_atime + 300);
+ EQUAL_VAL(st2.st_mtime, st1.st_mtime - 300);
+
+#undef EQUAL_VAL
+
+ unlink(TESTFILE);
+ printf("success: utimes\n");
+ return true;
+}
+
struct torture_context;
bool torture_local_replace(struct torture_context *ctx)
{
@@ -920,6 +1063,8 @@ bool torture_local_replace(struct torture_context *ctx)
ret &= test_socketpair();
ret &= test_strptime();
ret &= test_getifaddrs();
+ ret &= test_utime();
+ ret &= test_utimes();
return ret;
}
diff --git a/source4/lib/samba3/config.mk b/source4/lib/samba3/config.mk
index 2d129c5f8c..e089149393 100644
--- a/source4/lib/samba3/config.mk
+++ b/source4/lib/samba3/config.mk
@@ -1,8 +1,10 @@
################################################
# Start SUBSYSTEM LIBSAMBA3
[SUBSYSTEM::SMBPASSWD]
-PRIVATE_PROTO_HEADER = samba3_smbpasswd_proto.h
-OBJ_FILES = smbpasswd.o
PRIVATE_DEPENDENCIES = CHARSET LIBSAMBA-UTIL
# End SUBSYSTEM LIBSAMBA3
################################################
+
+SMBPASSWD_OBJ_FILES = $(libsrcdir)/samba3/smbpasswd.o
+
+$(eval $(call proto_header_template,$(libsrcdir)/samba3/samba3_smbpasswd_proto.h,$(SMBPASSWD_OBJ_FILES:.o=.c)))
diff --git a/source4/lib/socket/config.m4 b/source4/lib/socket/config.m4
index b40002b321..9c0072dd8b 100644
--- a/source4/lib/socket/config.m4
+++ b/source4/lib/socket/config.m4
@@ -1,57 +1,19 @@
AC_CHECK_FUNCS(writev)
AC_CHECK_FUNCS(readv)
-
-AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
-AC_TRY_COMPILE([#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>],
-[struct sockaddr_in sock; sock.sin_len = sizeof(sock);],
-samba_cv_HAVE_SOCK_SIN_LEN=yes,samba_cv_HAVE_SOCK_SIN_LEN=no)])
-if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
- AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
-fi
+AC_CHECK_FUNCS(gethostbyname2)
############################################
# check for unix domain sockets
-AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
- AC_TRY_COMPILE([
-#include <sys/types.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <sys/socket.h>
-#include <sys/un.h>],
-[
- struct sockaddr_un sunaddr;
- sunaddr.sun_family = AF_UNIX;
-],
- samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
+# done by AC_LIBREPLACE_NETWORK_CHECKS
SMB_ENABLE(socket_unix, NO)
-if test x"$samba_cv_unixsocket" = x"yes"; then
- SMB_ENABLE(socket_unix, YES)
- AC_DEFINE(HAVE_UNIXSOCKET,1,[If we need to build with unixscoket support])
+if test x"$libreplace_cv_HAVE_UNIXSOCKET" = x"yes"; then
+ SMB_ENABLE(socket_unix, YES)
fi
-AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
-AC_TRY_RUN([#include "${srcdir-.}/build/tests/unixsock.c"],
- samba_cv_HAVE_WORKING_AF_LOCAL=yes,
- samba_cv_HAVE_WORKING_AF_LOCAL=no,
- samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
-if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
-then
- AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
-fi
-
-dnl test for ipv6 using the gethostbyname2() function. That should be sufficient
-dnl for now
-AC_CHECK_FUNCS(gethostbyname2, have_ipv6=true, have_ipv6=false)
+############################################
+# check for ipv6
+# done by AC_LIBREPLACE_NETWORK_CHECKS
SMB_ENABLE(socket_ipv6, NO)
-if $have_ipv6 = true; then
+if test x"$libreplace_cv_HAVE_IPV6" = x"yes"; then
SMB_ENABLE(socket_ipv6, YES)
- AC_DEFINE(HAVE_IPV6,1,[Whether the system has ipv6 support])
fi
-dnl don't build ipv6 by default, unless the above test enables it, or
-dnl the configure uses --with-static-modules=socket_ipv6
-
-
-
-
diff --git a/source4/lib/socket/config.mk b/source4/lib/socket/config.mk
index 777882f6e0..18aa806e41 100644
--- a/source4/lib/socket/config.mk
+++ b/source4/lib/socket/config.mk
@@ -1,45 +1,43 @@
##############################
# Start SUBSYSTEM LIBNETIF
[SUBSYSTEM::LIBNETIF]
-PRIVATE_PROTO_HEADER = netif_proto.h
-OBJ_FILES = \
- interface.o \
- netif.o
PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBREPLACE_NETWORK
# End SUBSYSTEM LIBNETIF
##############################
+LIBNETIF_OBJ_FILES = $(addprefix $(libsocketsrcdir)/, interface.o netif.o)
+
+$(eval $(call proto_header_template,$(libsocketsrcdir)/netif_proto.h,$(LIBNETIF_OBJ_FILES:.o=.c)))
+
################################################
# Start MODULE socket_ip
[MODULE::socket_ip]
SUBSYSTEM = samba-socket
OUTPUT_TYPE = MERGED_OBJ
-OBJ_FILES = \
- socket_ip.o
PRIVATE_DEPENDENCIES = LIBSAMBA-ERRORS LIBREPLACE_NETWORK
# End MODULE socket_ip
################################################
+socket_ip_OBJ_FILES = $(libsocketsrcdir)/socket_ip.o
+
################################################
# Start MODULE socket_unix
[MODULE::socket_unix]
SUBSYSTEM = samba-socket
OUTPUT_TYPE = MERGED_OBJ
-OBJ_FILES = \
- socket_unix.o
PRIVATE_DEPENDENCIES = LIBREPLACE_NETWORK
# End MODULE socket_unix
################################################
+socket_unix_OBJ_FILES = $(libsocketsrcdir)/socket_unix.o
+
################################################
# Start SUBSYSTEM SOCKET
[SUBSYSTEM::samba-socket]
-OBJ_FILES = \
- socket.o \
- access.o \
- connect_multi.o \
- connect.o
PUBLIC_DEPENDENCIES = LIBTALLOC
PRIVATE_DEPENDENCIES = SOCKET_WRAPPER LIBCLI_COMPOSITE LIBCLI_RESOLVE
# End SUBSYSTEM SOCKET
################################################
+
+samba-socket_OBJ_FILES = $(addprefix $(libsocketsrcdir)/, socket.o access.o connect_multi.o connect.o)
+
diff --git a/source4/lib/socket/testsuite.c b/source4/lib/socket/testsuite.c
index 6d4d81a884..2c25d8f491 100644
--- a/source4/lib/socket/testsuite.c
+++ b/source4/lib/socket/testsuite.c
@@ -86,7 +86,7 @@ static bool test_udp(struct torture_context *tctx)
torture_assert_int_equal(tctx, nread, size, "Unexpected recvfrom size");
- torture_assert(tctx, memcmp(blob2.data, blob.data, size) == 0,
+ torture_assert_mem_equal(tctx, blob2.data, blob.data, size,
"Bad data in recvfrom");
generate_random_buffer(blob.data, blob.length);
@@ -104,7 +104,7 @@ static bool test_udp(struct torture_context *tctx)
torture_assert_int_equal(tctx, from_addr->port, srv_addr->port,
"Unexpected recvfrom port");
- torture_assert(tctx, memcmp(blob2.data, blob.data, size) == 0,
+ torture_assert_mem_equal(tctx, blob2.data, blob.data, size,
"Bad data in recvfrom");
talloc_free(sock1);
@@ -124,7 +124,7 @@ static bool test_tcp(struct torture_context *tctx)
DATA_BLOB blob, blob2;
size_t sent, nread;
TALLOC_CTX *mem_ctx = tctx;
- struct event_context *ev = event_context_init(mem_ctx);
+ struct event_context *ev = tctx->ev;
struct interface *ifaces;
status = socket_create("ip", SOCKET_TYPE_STREAM, &sock1, 0);
@@ -181,7 +181,7 @@ static bool test_tcp(struct torture_context *tctx)
torture_assert_int_equal(tctx, nread, size, "Unexpected recvfrom size");
- torture_assert(tctx, memcmp(blob2.data, blob.data, size) == 0,
+ torture_assert_mem_equal(tctx, blob2.data, blob.data, size,
"Bad data in recv");
return true;
}
diff --git a/source4/lib/socket_wrapper/config.mk b/source4/lib/socket_wrapper/config.mk
index 902692d9be..60cfb3209a 100644
--- a/source4/lib/socket_wrapper/config.mk
+++ b/source4/lib/socket_wrapper/config.mk
@@ -1,7 +1,8 @@
##############################
# Start SUBSYSTEM SOCKET_WRAPPER
[SUBSYSTEM::SOCKET_WRAPPER]
-OBJ_FILES = socket_wrapper.o
PRIVATE_DEPENDENCIES = LIBREPLACE_NETWORK
# End SUBSYSTEM SOCKET_WRAPPER
##############################
+
+SOCKET_WRAPPER_OBJ_FILES = $(socketwrappersrcdir)/socket_wrapper.o
diff --git a/source4/lib/stream/config.mk b/source4/lib/stream/config.mk
index 39e7bc739d..56d117e7bd 100644
--- a/source4/lib/stream/config.mk
+++ b/source4/lib/stream/config.mk
@@ -1,8 +1,4 @@
-
-################################################
-# Start SUBSYSTEM LIBPACKET
[SUBSYSTEM::LIBPACKET]
-OBJ_FILES = packet.o
PRIVATE_DEPENDENCIES = LIBTLS
-# End SUBSYSTEM LIBPACKET
-################################################
+
+LIBPACKET_OBJ_FILES = $(libstreamsrcdir)/packet.o
diff --git a/source4/lib/talloc/config.mk b/source4/lib/talloc/config.mk
index 42f8b38815..84848ae77a 100644
--- a/source4/lib/talloc/config.mk
+++ b/source4/lib/talloc/config.mk
@@ -1,4 +1,7 @@
[LIBRARY::LIBTALLOC]
OUTPUT_TYPE = STATIC_LIBRARY
-OBJ_FILES = talloc.o
CFLAGS = -Ilib/talloc
+
+LIBTALLOC_OBJ_FILES = lib/talloc/talloc.o
+
+MANPAGES += $(tallocdir)/talloc.3
diff --git a/source4/lib/talloc/testsuite.c b/source4/lib/talloc/testsuite.c
index fedbda95aa..3f06eee566 100644
--- a/source4/lib/talloc/testsuite.c
+++ b/source4/lib/talloc/testsuite.c
@@ -48,7 +48,8 @@ static double timeval_elapsed(struct timeval *tv)
}
#define torture_assert_str_equal(test, arg1, arg2, desc) \
- if (strcmp(arg1, arg2)) { \
+ if (arg1 == NULL && arg2 == NULL) { \
+ } else if (strcmp(arg1, arg2)) { \
printf("failure: %s [\n%s: Expected %s, got %s: %s\n]\n", \
test, __location__, arg1, arg2, desc); \
return false; \
diff --git a/source4/lib/tdb/common/traverse.c b/source4/lib/tdb/common/traverse.c
index 07b0c23858..69c81e6e98 100644
--- a/source4/lib/tdb/common/traverse.c
+++ b/source4/lib/tdb/common/traverse.c
@@ -204,18 +204,23 @@ int tdb_traverse_read(struct tdb_context *tdb,
{
struct tdb_traverse_lock tl = { NULL, 0, 0, F_RDLCK };
int ret;
+ bool in_transaction = (tdb->transaction != NULL);
/* we need to get a read lock on the transaction lock here to
cope with the lock ordering semantics of solaris10 */
- if (tdb_transaction_lock(tdb, F_RDLCK)) {
- return -1;
+ if (!in_transaction) {
+ if (tdb_transaction_lock(tdb, F_RDLCK)) {
+ return -1;
+ }
}
tdb->traverse_read++;
ret = tdb_traverse_internal(tdb, fn, private_data, &tl);
tdb->traverse_read--;
- tdb_transaction_unlock(tdb);
+ if (!in_transaction) {
+ tdb_transaction_unlock(tdb);
+ }
return ret;
}
@@ -232,20 +237,25 @@ int tdb_traverse(struct tdb_context *tdb,
{
struct tdb_traverse_lock tl = { NULL, 0, 0, F_WRLCK };
int ret;
+ bool in_transaction = (tdb->transaction != NULL);
if (tdb->read_only || tdb->traverse_read) {
return tdb_traverse_read(tdb, fn, private_data);
}
- if (tdb_transaction_lock(tdb, F_WRLCK)) {
- return -1;
+ if (!in_transaction) {
+ if (tdb_transaction_lock(tdb, F_WRLCK)) {
+ return -1;
+ }
}
tdb->traverse_write++;
ret = tdb_traverse_internal(tdb, fn, private_data, &tl);
tdb->traverse_write--;
- tdb_transaction_unlock(tdb);
+ if (!in_transaction) {
+ tdb_transaction_unlock(tdb);
+ }
return ret;
}
diff --git a/source4/lib/tdb/config.mk b/source4/lib/tdb/config.mk
index 76342dc8fa..b9a8f80dda 100644
--- a/source4/lib/tdb/config.mk
+++ b/source4/lib/tdb/config.mk
@@ -2,55 +2,56 @@
# Start SUBSYSTEM LIBTDB
[LIBRARY::LIBTDB]
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 \
- common/error.o common/transaction.o
CFLAGS = -Ilib/tdb/include
#
# End SUBSYSTEM ldb
################################################
+LIBTDB_OBJ_FILES = $(addprefix lib/tdb/common/, \
+ tdb.o dump.o io.o lock.o \
+ open.o traverse.o freelist.o \
+ error.o transaction.o)
+
################################################
# Start BINARY tdbtool
[BINARY::tdbtool]
INSTALLDIR = BINDIR
-OBJ_FILES= \
- tools/tdbtool.o
PRIVATE_DEPENDENCIES = \
LIBTDB
# End BINARY tdbtool
################################################
+tdbtool_OBJ_FILES = lib/tdb/tools/tdbtool.o
+
################################################
# Start BINARY tdbtorture
[BINARY::tdbtorture]
INSTALLDIR = BINDIR
-OBJ_FILES= \
- tools/tdbtorture.o
PRIVATE_DEPENDENCIES = \
LIBTDB
# End BINARY tdbtorture
################################################
+tdbtorture_OBJ_FILES = lib/tdb/tools/tdbtorture.o
+
################################################
# Start BINARY tdbdump
[BINARY::tdbdump]
INSTALLDIR = BINDIR
-OBJ_FILES= \
- tools/tdbdump.o
PRIVATE_DEPENDENCIES = \
LIBTDB
# End BINARY tdbdump
################################################
+tdbdump_OBJ_FILES = lib/tdb/tools/tdbdump.o
+
################################################
# Start BINARY tdbbackup
[BINARY::tdbbackup]
INSTALLDIR = BINDIR
-OBJ_FILES= \
- tools/tdbbackup.o
PRIVATE_DEPENDENCIES = \
LIBTDB
# End BINARY tdbbackup
################################################
+
+tdbbackup_OBJ_FILES = lib/tdb/tools/tdbbackup.o
diff --git a/source4/lib/tdb/configure.ac b/source4/lib/tdb/configure.ac
index 9b16a82c33..eaf70d30b4 100644
--- a/source4/lib/tdb/configure.ac
+++ b/source4/lib/tdb/configure.ac
@@ -2,7 +2,7 @@ AC_PREREQ(2.50)
AC_DEFUN([SMB_MODULE_DEFAULT], [echo -n ""])
AC_DEFUN([SMB_LIBRARY_ENABLE], [echo -n ""])
AC_DEFUN([SMB_ENABLE], [echo -n ""])
-AC_INIT(tdb, 1.1.1)
+AC_INIT(tdb, 1.1.2)
AC_CONFIG_SRCDIR([common/tdb.c])
AC_CONFIG_HEADER(include/config.h)
AC_LIBREPLACE_ALL_CHECKS
diff --git a/source4/lib/tdb/python.mk b/source4/lib/tdb/python.mk
index 23b01c120c..83336e7b41 100644
--- a/source4/lib/tdb/python.mk
+++ b/source4/lib/tdb/python.mk
@@ -1,3 +1,10 @@
[PYTHON::swig_tdb]
-SWIG_FILE = tdb.i
+LIBRARY_REALNAME = _tdb.$(SHLIBEXT)
PUBLIC_DEPENDENCIES = LIBTDB DYNCONFIG
+
+swig_tdb_OBJ_FILES = lib/tdb/tdb_wrap.o
+
+$(eval $(call python_py_module_template,tdb.py,lib/tdb/tdb.py))
+
+$(swig_tdb_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
+
diff --git a/source4/lib/tdb/python/tests/simple.py b/source4/lib/tdb/python/tests/simple.py
index 94407b6398..7147718c91 100644
--- a/source4/lib/tdb/python/tests/simple.py
+++ b/source4/lib/tdb/python/tests/simple.py
@@ -3,8 +3,8 @@
# Note that this tests the interface of the Python bindings
# It does not test tdb itself.
#
-# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU LGPL
+# Copyright (C) 2007-2008 Jelmer Vernooij <jelmer@samba.org>
+# Published under the GNU LGPLv3 or later
import tdb
from unittest import TestCase
@@ -25,6 +25,9 @@ class SimpleTdbTests(TestCase):
def tearDown(self):
del self.tdb
+ def test_repr(self):
+ self.assertTrue(repr(self.tdb).startswith("Tdb('"))
+
def test_lockall(self):
self.tdb.lock_all()
diff --git a/source4/lib/tdb/tdb.i b/source4/lib/tdb/tdb.i
index c82d2d0a6d..5f23568170 100644
--- a/source4/lib/tdb/tdb.i
+++ b/source4/lib/tdb/tdb.i
@@ -24,7 +24,11 @@
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-%module tdb
+%define DOCSTRING
+"TDB is a simple key-value database similar to GDBM that supports multiple writers."
+%enddef
+
+%module(docstring=DOCSTRING) tdb
%{
@@ -138,7 +142,8 @@ enum TDB_ERROR {
$1 = TDB_REPLACE;
}
-%rename(Tdb) tdb;
+%rename(Tdb) tdb_context;
+%feature("docstring") tdb_context "A TDB file.";
%typemap(out,noblock=1) tdb * {
/* Throw an IOError exception from errno if tdb_open() returns NULL */
if ($1 == NULL) {
@@ -150,40 +155,74 @@ enum TDB_ERROR {
typedef struct tdb_context {
%extend {
+ %feature("docstring") tdb "S.__init__(name,hash_size=0,tdb_flags=TDB_DEFAULT,flags=O_RDWR,mode=0600)\n"
+ "Open a TDB file.";
tdb(const char *name, int hash_size, int tdb_flags, int flags, mode_t mode) {
return tdb_open(name, hash_size, tdb_flags, flags, mode);
}
enum TDB_ERROR error();
~tdb() { tdb_close($self); }
+ %feature("docstring") close "S.close() -> None\n"
+ "Close the TDB file.";
int close();
int append(TDB_DATA key, TDB_DATA new_dbuf);
+ %feature("docstring") errorstr "S.errorstr() -> errorstring\n"
+ "Obtain last error message.";
const char *errorstr();
%rename(get) fetch;
+ %feature("docstring") fetch "S.fetch(key) -> value\n"
+ "Fetch a value.";
TDB_DATA fetch(TDB_DATA key);
+ %feature("docstring") delete "S.delete(key) -> None\n"
+ "Delete an entry.";
int delete(TDB_DATA key);
+ %feature("docstring") store "S.store(key, value, flag=TDB_REPLACE) -> None\n"
+ "Store an entry.";
int store(TDB_DATA key, TDB_DATA dbuf, int flag);
int exists(TDB_DATA key);
+ %feature("docstring") firstkey "S.firstkey() -> data\n"
+ "Return the first key in this database.";
TDB_DATA firstkey();
+ %feature("docstring") nextkey "S.nextkey(prev) -> data\n"
+ "Return the next key in this database.";
TDB_DATA nextkey(TDB_DATA key);
+ %feature("docstring") lockall "S.lockall() -> bool";
int lockall();
+ %feature("docstring") unlockall "S.unlockall() -> bool";
int unlockall();
+ %feature("docstring") unlockall "S.lockall_read() -> bool";
int lockall_read();
+ %feature("docstring") unlockall "S.unlockall_read() -> bool";
int unlockall_read();
+ %feature("docstring") reopen "S.reopen() -> bool\n"
+ "Reopen this file.";
int reopen();
+ %feature("docstring") transaction_start "S.transaction_start() -> None\n"
+ "Start a new transaction.";
int transaction_start();
+ %feature("docstring") transaction_commit "S.transaction_commit() -> None\n"
+ "Commit the currently active transaction.";
int transaction_commit();
+ %feature("docstring") transaction_cancel "S.transaction_cancel() -> None\n"
+ "Cancel the currently active transaction.";
int transaction_cancel();
int transaction_recover();
+ %feature("docstring") hash_size "S.hash_size() -> int";
int hash_size();
+ %feature("docstring") map_size "S.map_size() -> int";
size_t map_size();
+ %feature("docstring") get_flags "S.get_flags() -> int";
int get_flags();
+ %feature("docstring") set_max_dead "S.set_max_dead(int) -> None";
void set_max_dead(int max_dead);
+ %feature("docstring") name "S.name() -> path\n" \
+ "Return filename of this TDB file.";
const char *name();
}
%pythoncode {
- def __str__(self):
- return self.name()
+ def __repr__(self):
+ return "Tdb('%s')" % self.name()
# Random access to keys, values
def __getitem__(self, key):
diff --git a/source4/lib/tdb/tdb.mk b/source4/lib/tdb/tdb.mk
index 0e53927366..fa8db6d34c 100644
--- a/source4/lib/tdb/tdb.mk
+++ b/source4/lib/tdb/tdb.mk
@@ -39,7 +39,7 @@ 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`
+ $(SHLD) $(SHLD_FLAGS) -o $@ tdb_wrap.o -L. -ltdb `$(PYTHON_CONFIG) --ldflags`
install:: installdirs installbin installheaders installlibs \
$(PYTHON_INSTALL_TARGET)
@@ -50,7 +50,7 @@ install-python:: build-python
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
+check-python:: build-python $(TDB_SONAME)
$(LIB_PATH_VAR)=. PYTHONPATH=".:$(tdbdir)" $(PYTHON) $(tdbdir)/python/tests/simple.py
install-swig::
diff --git a/source4/lib/tdb/tdb.py b/source4/lib/tdb/tdb.py
index 0effa3ff98..a8c1d06e0d 100644
--- a/source4/lib/tdb/tdb.py
+++ b/source4/lib/tdb/tdb.py
@@ -1,8 +1,12 @@
# This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.33
+# Version 1.3.35
#
# Don't modify this file, modify the SWIG interface instead.
+"""
+TDB is a simple key-value database similar to GDBM that supports multiple writers.
+"""
+
import _tdb
import new
new_instancemethod = new.instancemethod
@@ -78,13 +82,127 @@ TDB_ERR_LOCK_TIMEOUT = _tdb.TDB_ERR_LOCK_TIMEOUT
TDB_ERR_NOEXIST = _tdb.TDB_ERR_NOEXIST
TDB_ERR_EINVAL = _tdb.TDB_ERR_EINVAL
TDB_ERR_RDONLY = _tdb.TDB_ERR_RDONLY
-class tdb(object):
+class Tdb(object):
+ """A TDB file."""
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
- def __init__(self): raise AttributeError, "No constructor defined"
__repr__ = _swig_repr
- __swig_destroy__ = _tdb.delete_tdb
- def __str__(self):
- return self.name()
+ def __init__(self, *args, **kwargs):
+ """
+ S.__init__(name,hash_size=0,tdb_flags=TDB_DEFAULT,flags=O_RDWR,mode=0600)
+ Open a TDB file.
+ """
+ _tdb.Tdb_swiginit(self,_tdb.new_Tdb(*args, **kwargs))
+ __swig_destroy__ = _tdb.delete_Tdb
+ def close(*args, **kwargs):
+ """
+ S.close() -> None
+ Close the TDB file.
+ """
+ return _tdb.Tdb_close(*args, **kwargs)
+
+ def errorstr(*args, **kwargs):
+ """
+ S.errorstr() -> errorstring
+ Obtain last error message.
+ """
+ return _tdb.Tdb_errorstr(*args, **kwargs)
+
+ def get(*args, **kwargs):
+ """
+ S.fetch(key) -> value
+ Fetch a value.
+ """
+ return _tdb.Tdb_get(*args, **kwargs)
+
+ def delete(*args, **kwargs):
+ """
+ S.delete(key) -> None
+ Delete an entry.
+ """
+ return _tdb.Tdb_delete(*args, **kwargs)
+
+ def store(*args, **kwargs):
+ """
+ S.store(key, value, flag=TDB_REPLACE) -> None
+ Store an entry.
+ """
+ return _tdb.Tdb_store(*args, **kwargs)
+
+ def firstkey(*args, **kwargs):
+ """
+ S.firstkey() -> data
+ Return the first key in this database.
+ """
+ return _tdb.Tdb_firstkey(*args, **kwargs)
+
+ def nextkey(*args, **kwargs):
+ """
+ S.nextkey(prev) -> data
+ Return the next key in this database.
+ """
+ return _tdb.Tdb_nextkey(*args, **kwargs)
+
+ def lock_all(*args, **kwargs):
+ """S.lockall() -> bool"""
+ return _tdb.Tdb_lock_all(*args, **kwargs)
+
+ def unlock_all(*args, **kwargs):
+ """S.unlockall() -> bool"""
+ return _tdb.Tdb_unlock_all(*args, **kwargs)
+
+ def reopen(*args, **kwargs):
+ """
+ S.reopen() -> bool
+ Reopen this file.
+ """
+ return _tdb.Tdb_reopen(*args, **kwargs)
+
+ def transaction_start(*args, **kwargs):
+ """
+ S.transaction_start() -> None
+ Start a new transaction.
+ """
+ return _tdb.Tdb_transaction_start(*args, **kwargs)
+
+ def transaction_commit(*args, **kwargs):
+ """
+ S.transaction_commit() -> None
+ Commit the currently active transaction.
+ """
+ return _tdb.Tdb_transaction_commit(*args, **kwargs)
+
+ def transaction_cancel(*args, **kwargs):
+ """
+ S.transaction_cancel() -> None
+ Cancel the currently active transaction.
+ """
+ return _tdb.Tdb_transaction_cancel(*args, **kwargs)
+
+ def hash_size(*args, **kwargs):
+ """S.hash_size() -> int"""
+ return _tdb.Tdb_hash_size(*args, **kwargs)
+
+ def map_size(*args, **kwargs):
+ """S.map_size() -> int"""
+ return _tdb.Tdb_map_size(*args, **kwargs)
+
+ def get_flags(*args, **kwargs):
+ """S.get_flags() -> int"""
+ return _tdb.Tdb_get_flags(*args, **kwargs)
+
+ def set_max_dead(*args, **kwargs):
+ """S.set_max_dead(int) -> None"""
+ return _tdb.Tdb_set_max_dead(*args, **kwargs)
+
+ def name(*args, **kwargs):
+ """
+ S.name() -> path
+ Return filename of this TDB file.
+ """
+ return _tdb.Tdb_name(*args, **kwargs)
+
+ def __repr__(self):
+ return "Tdb('%s')" % self.name()
def __getitem__(self, key):
@@ -178,36 +296,32 @@ class tdb(object):
-tdb.error = new_instancemethod(_tdb.tdb_error,None,tdb)
-tdb.close = new_instancemethod(_tdb.tdb_close,None,tdb)
-tdb.append = new_instancemethod(_tdb.tdb_append,None,tdb)
-tdb.errorstr = new_instancemethod(_tdb.tdb_errorstr,None,tdb)
-tdb.get = new_instancemethod(_tdb.tdb_get,None,tdb)
-tdb.delete = new_instancemethod(_tdb.tdb_delete,None,tdb)
-tdb.store = new_instancemethod(_tdb.tdb_store,None,tdb)
-tdb.exists = new_instancemethod(_tdb.tdb_exists,None,tdb)
-tdb.firstkey = new_instancemethod(_tdb.tdb_firstkey,None,tdb)
-tdb.nextkey = new_instancemethod(_tdb.tdb_nextkey,None,tdb)
-tdb.lock_all = new_instancemethod(_tdb.tdb_lock_all,None,tdb)
-tdb.unlock_all = new_instancemethod(_tdb.tdb_unlock_all,None,tdb)
-tdb.read_lock_all = new_instancemethod(_tdb.tdb_read_lock_all,None,tdb)
-tdb.read_unlock_all = new_instancemethod(_tdb.tdb_read_unlock_all,None,tdb)
-tdb.reopen = new_instancemethod(_tdb.tdb_reopen,None,tdb)
-tdb.transaction_start = new_instancemethod(_tdb.tdb_transaction_start,None,tdb)
-tdb.transaction_commit = new_instancemethod(_tdb.tdb_transaction_commit,None,tdb)
-tdb.transaction_cancel = new_instancemethod(_tdb.tdb_transaction_cancel,None,tdb)
-tdb.transaction_recover = new_instancemethod(_tdb.tdb_transaction_recover,None,tdb)
-tdb.hash_size = new_instancemethod(_tdb.tdb_hash_size,None,tdb)
-tdb.map_size = new_instancemethod(_tdb.tdb_map_size,None,tdb)
-tdb.get_flags = new_instancemethod(_tdb.tdb_get_flags,None,tdb)
-tdb.set_max_dead = new_instancemethod(_tdb.tdb_set_max_dead,None,tdb)
-tdb.name = new_instancemethod(_tdb.tdb_name,None,tdb)
-tdb_swigregister = _tdb.tdb_swigregister
-tdb_swigregister(tdb)
-
-def Tdb(*args, **kwargs):
- val = _tdb.new_Tdb(*args, **kwargs)
- return val
+Tdb.error = new_instancemethod(_tdb.Tdb_error,None,Tdb)
+Tdb.close = new_instancemethod(_tdb.Tdb_close,None,Tdb)
+Tdb.append = new_instancemethod(_tdb.Tdb_append,None,Tdb)
+Tdb.errorstr = new_instancemethod(_tdb.Tdb_errorstr,None,Tdb)
+Tdb.get = new_instancemethod(_tdb.Tdb_get,None,Tdb)
+Tdb.delete = new_instancemethod(_tdb.Tdb_delete,None,Tdb)
+Tdb.store = new_instancemethod(_tdb.Tdb_store,None,Tdb)
+Tdb.exists = new_instancemethod(_tdb.Tdb_exists,None,Tdb)
+Tdb.firstkey = new_instancemethod(_tdb.Tdb_firstkey,None,Tdb)
+Tdb.nextkey = new_instancemethod(_tdb.Tdb_nextkey,None,Tdb)
+Tdb.lock_all = new_instancemethod(_tdb.Tdb_lock_all,None,Tdb)
+Tdb.unlock_all = new_instancemethod(_tdb.Tdb_unlock_all,None,Tdb)
+Tdb.read_lock_all = new_instancemethod(_tdb.Tdb_read_lock_all,None,Tdb)
+Tdb.read_unlock_all = new_instancemethod(_tdb.Tdb_read_unlock_all,None,Tdb)
+Tdb.reopen = new_instancemethod(_tdb.Tdb_reopen,None,Tdb)
+Tdb.transaction_start = new_instancemethod(_tdb.Tdb_transaction_start,None,Tdb)
+Tdb.transaction_commit = new_instancemethod(_tdb.Tdb_transaction_commit,None,Tdb)
+Tdb.transaction_cancel = new_instancemethod(_tdb.Tdb_transaction_cancel,None,Tdb)
+Tdb.transaction_recover = new_instancemethod(_tdb.Tdb_transaction_recover,None,Tdb)
+Tdb.hash_size = new_instancemethod(_tdb.Tdb_hash_size,None,Tdb)
+Tdb.map_size = new_instancemethod(_tdb.Tdb_map_size,None,Tdb)
+Tdb.get_flags = new_instancemethod(_tdb.Tdb_get_flags,None,Tdb)
+Tdb.set_max_dead = new_instancemethod(_tdb.Tdb_set_max_dead,None,Tdb)
+Tdb.name = new_instancemethod(_tdb.Tdb_name,None,Tdb)
+Tdb_swigregister = _tdb.Tdb_swigregister
+Tdb_swigregister(Tdb)
diff --git a/source4/lib/tdb/tdb_wrap.c b/source4/lib/tdb/tdb_wrap.c
index 6a5b7feffc..27da552d33 100644
--- a/source4/lib/tdb/tdb_wrap.c
+++ b/source4/lib/tdb/tdb_wrap.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.33
+ * Version 1.3.35
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
@@ -126,7 +126,7 @@
/* This should only be incremented when either the layout of swig_type_info changes,
or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "3"
+#define SWIG_RUNTIME_VERSION "4"
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
#ifdef SWIG_TYPE_TABLE
@@ -161,6 +161,7 @@
/* Flags for pointer conversions */
#define SWIG_POINTER_DISOWN 0x1
+#define SWIG_CAST_NEW_MEMORY 0x2
/* Flags for new pointer objects */
#define SWIG_POINTER_OWN 0x1
@@ -301,10 +302,10 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) {
extern "C" {
#endif
-typedef void *(*swig_converter_func)(void *);
+typedef void *(*swig_converter_func)(void *, int *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);
-/* Structure to store inforomation on one type */
+/* Structure to store information on one type */
typedef struct swig_type_info {
const char *name; /* mangled name of this type */
const char *str; /* human readable name of this type */
@@ -431,8 +432,8 @@ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
Cast a pointer up an inheritance hierarchy
*/
SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
- return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
+SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
}
/*
@@ -856,7 +857,7 @@ SWIG_Python_AddErrorMsg(const char* mesg)
Py_DECREF(old_str);
Py_DECREF(value);
} else {
- PyErr_Format(PyExc_RuntimeError, mesg);
+ PyErr_SetString(PyExc_RuntimeError, mesg);
}
}
@@ -1416,7 +1417,7 @@ PySwigObject_dealloc(PyObject *v)
{
PySwigObject *sobj = (PySwigObject *) v;
PyObject *next = sobj->next;
- if (sobj->own) {
+ if (sobj->own == SWIG_POINTER_OWN) {
swig_type_info *ty = sobj->ty;
PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
PyObject *destroy = data ? data->destroy : 0;
@@ -1434,12 +1435,13 @@ PySwigObject_dealloc(PyObject *v)
res = ((*meth)(mself, v));
}
Py_XDECREF(res);
- } else {
- const char *name = SWIG_TypePrettyName(ty);
+ }
#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
- printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
-#endif
+ else {
+ const char *name = SWIG_TypePrettyName(ty);
+ printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
}
+#endif
}
Py_XDECREF(next);
PyObject_DEL(v);
@@ -1944,7 +1946,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
SWIGRUNTIME int
SWIG_Python_AcquirePtr(PyObject *obj, int own) {
- if (own) {
+ if (own == SWIG_POINTER_OWN) {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
if (sobj) {
int oldown = sobj->own;
@@ -1965,6 +1967,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
return SWIG_OK;
} else {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+ if (own)
+ *own = 0;
while (sobj) {
void *vptr = sobj->ptr;
if (ty) {
@@ -1978,7 +1982,15 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
if (!tc) {
sobj = (PySwigObject *)sobj->next;
} else {
- if (ptr) *ptr = SWIG_TypeCast(tc,vptr);
+ if (ptr) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
+ assert(own);
+ if (own)
+ *own = *own | SWIG_CAST_NEW_MEMORY;
+ }
+ }
break;
}
}
@@ -1988,7 +2000,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
}
}
if (sobj) {
- if (own) *own = sobj->own;
+ if (own)
+ *own = *own | sobj->own;
if (flags & SWIG_POINTER_DISOWN) {
sobj->own = 0;
}
@@ -2053,8 +2066,13 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
}
if (ty) {
swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
- if (!tc) return SWIG_ERROR;
- *ptr = SWIG_TypeCast(tc,vptr);
+ if (tc) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ assert(!newmemory); /* newmemory handling not yet implemented */
+ } else {
+ return SWIG_ERROR;
+ }
} else {
*ptr = vptr;
}
@@ -2500,7 +2518,7 @@ static swig_module_info swig_module = {swig_types, 11, 0, 0, 0, 0};
#define SWIG_name "_tdb"
-#define SWIGVERSION 0x010333
+#define SWIGVERSION 0x010335
#define SWIG_VERSION SWIGVERSION
@@ -2874,7 +2892,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_error(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_error(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
enum TDB_ERROR result;
@@ -2886,7 +2904,7 @@ SWIGINTERN PyObject *_wrap_tdb_error(PyObject *SWIGUNUSEDPARM(self), PyObject *a
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_error" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_error" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (enum TDB_ERROR)tdb_error(arg1);
@@ -2897,7 +2915,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_delete_tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_delete_Tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
void *argp1 = 0 ;
@@ -2908,7 +2926,7 @@ SWIGINTERN PyObject *_wrap_delete_tdb(PyObject *SWIGUNUSEDPARM(self), PyObject *
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, SWIG_POINTER_DISOWN | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_tdb" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Tdb" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
delete_tdb(arg1);
@@ -2920,7 +2938,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_close(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_close(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -2932,7 +2950,7 @@ SWIGINTERN PyObject *_wrap_tdb_close(PyObject *SWIGUNUSEDPARM(self), PyObject *a
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_close" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_close" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_close(arg1);
@@ -2943,7 +2961,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
TDB_DATA arg2 ;
@@ -2958,10 +2976,10 @@ SWIGINTERN PyObject *_wrap_tdb_append(PyObject *SWIGUNUSEDPARM(self), PyObject *
(char *) "self",(char *) "key",(char *) "new_dbuf", NULL
};
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:tdb_append",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:Tdb_append",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_append" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_append" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
if (obj1 == Py_None) {
@@ -2992,7 +3010,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_errorstr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_errorstr(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
char *result = 0 ;
@@ -3004,7 +3022,7 @@ SWIGINTERN PyObject *_wrap_tdb_errorstr(PyObject *SWIGUNUSEDPARM(self), PyObject
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_errorstr" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_errorstr" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (char *)tdb_errorstr(arg1);
@@ -3015,7 +3033,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
TDB_DATA arg2 ;
@@ -3028,10 +3046,10 @@ SWIGINTERN PyObject *_wrap_tdb_get(PyObject *SWIGUNUSEDPARM(self), PyObject *arg
(char *) "self",(char *) "key", NULL
};
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:tdb_get",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_get",kwnames,&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_get" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_get" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
if (obj1 == Py_None) {
@@ -3057,7 +3075,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
TDB_DATA arg2 ;
@@ -3070,10 +3088,10 @@ SWIGINTERN PyObject *_wrap_tdb_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *
(char *) "self",(char *) "key", NULL
};
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:tdb_delete",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_delete",kwnames,&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_delete" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_delete" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
if (obj1 == Py_None) {
@@ -3094,7 +3112,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
TDB_DATA arg2 ;
@@ -3114,10 +3132,10 @@ SWIGINTERN PyObject *_wrap_tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *a
};
arg4 = TDB_REPLACE;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:tdb_store",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO|O:Tdb_store",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_store" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_store" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
if (obj1 == Py_None) {
@@ -3143,7 +3161,7 @@ SWIGINTERN PyObject *_wrap_tdb_store(PyObject *SWIGUNUSEDPARM(self), PyObject *a
if (obj3) {
ecode4 = SWIG_AsVal_int(obj3, &val4);
if (!SWIG_IsOK(ecode4)) {
- SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "tdb_store" "', argument " "4"" of type '" "int""'");
+ SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Tdb_store" "', argument " "4"" of type '" "int""'");
}
arg4 = (int)(val4);
}
@@ -3155,7 +3173,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_exists(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_exists(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
TDB_DATA arg2 ;
@@ -3168,10 +3186,10 @@ SWIGINTERN PyObject *_wrap_tdb_exists(PyObject *SWIGUNUSEDPARM(self), PyObject *
(char *) "self",(char *) "key", NULL
};
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:tdb_exists",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_exists",kwnames,&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_exists" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_exists" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
if (obj1 == Py_None) {
@@ -3192,7 +3210,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_firstkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_firstkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
TDB_DATA result;
@@ -3204,7 +3222,7 @@ SWIGINTERN PyObject *_wrap_tdb_firstkey(PyObject *SWIGUNUSEDPARM(self), PyObject
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_firstkey" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_firstkey" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = tdb_firstkey(arg1);
@@ -3220,7 +3238,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_nextkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_nextkey(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
TDB_DATA arg2 ;
@@ -3233,10 +3251,10 @@ SWIGINTERN PyObject *_wrap_tdb_nextkey(PyObject *SWIGUNUSEDPARM(self), PyObject
(char *) "self",(char *) "key", NULL
};
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:tdb_nextkey",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_nextkey",kwnames,&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_nextkey" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_nextkey" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
if (obj1 == Py_None) {
@@ -3262,7 +3280,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3274,7 +3292,7 @@ SWIGINTERN PyObject *_wrap_tdb_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_lock_all" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_lock_all" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_lockall(arg1);
@@ -3285,7 +3303,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3297,7 +3315,7 @@ SWIGINTERN PyObject *_wrap_tdb_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObje
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_unlock_all" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_unlock_all" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_unlockall(arg1);
@@ -3308,7 +3326,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_read_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_read_lock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3320,7 +3338,7 @@ SWIGINTERN PyObject *_wrap_tdb_read_lock_all(PyObject *SWIGUNUSEDPARM(self), PyO
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_read_lock_all" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_read_lock_all" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_lockall_read(arg1);
@@ -3331,7 +3349,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_read_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_read_unlock_all(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3343,7 +3361,7 @@ SWIGINTERN PyObject *_wrap_tdb_read_unlock_all(PyObject *SWIGUNUSEDPARM(self), P
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_read_unlock_all" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_read_unlock_all" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_unlockall_read(arg1);
@@ -3354,7 +3372,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_reopen(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_reopen(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3366,7 +3384,7 @@ SWIGINTERN PyObject *_wrap_tdb_reopen(PyObject *SWIGUNUSEDPARM(self), PyObject *
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_reopen" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_reopen" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_reopen(arg1);
@@ -3377,7 +3395,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_transaction_start(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_transaction_start(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3389,7 +3407,7 @@ SWIGINTERN PyObject *_wrap_tdb_transaction_start(PyObject *SWIGUNUSEDPARM(self),
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_transaction_start" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_start" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_transaction_start(arg1);
@@ -3400,7 +3418,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_transaction_commit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_transaction_commit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3412,7 +3430,7 @@ SWIGINTERN PyObject *_wrap_tdb_transaction_commit(PyObject *SWIGUNUSEDPARM(self)
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_transaction_commit" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_commit" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_transaction_commit(arg1);
@@ -3423,7 +3441,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_transaction_cancel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_transaction_cancel(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3435,7 +3453,7 @@ SWIGINTERN PyObject *_wrap_tdb_transaction_cancel(PyObject *SWIGUNUSEDPARM(self)
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_transaction_cancel" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_cancel" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_transaction_cancel(arg1);
@@ -3446,7 +3464,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_transaction_recover(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_transaction_recover(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3458,7 +3476,7 @@ SWIGINTERN PyObject *_wrap_tdb_transaction_recover(PyObject *SWIGUNUSEDPARM(self
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_transaction_recover" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_transaction_recover" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_transaction_recover(arg1);
@@ -3469,7 +3487,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_hash_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_hash_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3481,7 +3499,7 @@ SWIGINTERN PyObject *_wrap_tdb_hash_size(PyObject *SWIGUNUSEDPARM(self), PyObjec
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_hash_size" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_hash_size" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_hash_size(arg1);
@@ -3492,7 +3510,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_map_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_map_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
size_t result;
@@ -3504,7 +3522,7 @@ SWIGINTERN PyObject *_wrap_tdb_map_size(PyObject *SWIGUNUSEDPARM(self), PyObject
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_map_size" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_map_size" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = tdb_map_size(arg1);
@@ -3515,7 +3533,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_get_flags(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_get_flags(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int result;
@@ -3527,7 +3545,7 @@ SWIGINTERN PyObject *_wrap_tdb_get_flags(PyObject *SWIGUNUSEDPARM(self), PyObjec
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_get_flags" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_get_flags" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (int)tdb_get_flags(arg1);
@@ -3538,7 +3556,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_set_max_dead(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+SWIGINTERN PyObject *_wrap_Tdb_set_max_dead(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
int arg2 ;
@@ -3552,15 +3570,15 @@ SWIGINTERN PyObject *_wrap_tdb_set_max_dead(PyObject *SWIGUNUSEDPARM(self), PyOb
(char *) "self",(char *) "max_dead", NULL
};
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:tdb_set_max_dead",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Tdb_set_max_dead",kwnames,&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_set_max_dead" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_set_max_dead" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
ecode2 = SWIG_AsVal_int(obj1, &val2);
if (!SWIG_IsOK(ecode2)) {
- SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "tdb_set_max_dead" "', argument " "2"" of type '" "int""'");
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Tdb_set_max_dead" "', argument " "2"" of type '" "int""'");
}
arg2 = (int)(val2);
tdb_set_max_dead(arg1,arg2);
@@ -3571,7 +3589,7 @@ fail:
}
-SWIGINTERN PyObject *_wrap_tdb_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_Tdb_name(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
tdb *arg1 = (tdb *) 0 ;
char *result = 0 ;
@@ -3583,7 +3601,7 @@ SWIGINTERN PyObject *_wrap_tdb_name(PyObject *SWIGUNUSEDPARM(self), PyObject *ar
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_tdb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "tdb_name" "', argument " "1"" of type '" "tdb *""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Tdb_name" "', argument " "1"" of type '" "tdb *""'");
}
arg1 = (tdb *)(argp1);
result = (char *)tdb_name(arg1);
@@ -3594,41 +3612,85 @@ fail:
}
-SWIGINTERN PyObject *tdb_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *Tdb_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
SWIG_TypeNewClientData(SWIGTYPE_p_tdb_context, SWIG_NewClientData(obj));
return SWIG_Py_Void();
}
+SWIGINTERN PyObject *Tdb_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ return SWIG_Python_InitShadowInstance(args);
+}
+
static PyMethodDef SwigMethods[] = {
- { (char *)"new_Tdb", (PyCFunction) _wrap_new_Tdb, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"tdb_error", (PyCFunction)_wrap_tdb_error, METH_O, NULL},
- { (char *)"delete_tdb", (PyCFunction)_wrap_delete_tdb, METH_O, NULL},
- { (char *)"tdb_close", (PyCFunction)_wrap_tdb_close, METH_O, NULL},
- { (char *)"tdb_append", (PyCFunction) _wrap_tdb_append, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"tdb_errorstr", (PyCFunction)_wrap_tdb_errorstr, METH_O, NULL},
- { (char *)"tdb_get", (PyCFunction) _wrap_tdb_get, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"tdb_delete", (PyCFunction) _wrap_tdb_delete, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"tdb_store", (PyCFunction) _wrap_tdb_store, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"tdb_exists", (PyCFunction) _wrap_tdb_exists, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"tdb_firstkey", (PyCFunction)_wrap_tdb_firstkey, METH_O, NULL},
- { (char *)"tdb_nextkey", (PyCFunction) _wrap_tdb_nextkey, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"tdb_lock_all", (PyCFunction)_wrap_tdb_lock_all, METH_O, NULL},
- { (char *)"tdb_unlock_all", (PyCFunction)_wrap_tdb_unlock_all, METH_O, NULL},
- { (char *)"tdb_read_lock_all", (PyCFunction)_wrap_tdb_read_lock_all, METH_O, NULL},
- { (char *)"tdb_read_unlock_all", (PyCFunction)_wrap_tdb_read_unlock_all, METH_O, NULL},
- { (char *)"tdb_reopen", (PyCFunction)_wrap_tdb_reopen, METH_O, NULL},
- { (char *)"tdb_transaction_start", (PyCFunction)_wrap_tdb_transaction_start, METH_O, NULL},
- { (char *)"tdb_transaction_commit", (PyCFunction)_wrap_tdb_transaction_commit, METH_O, NULL},
- { (char *)"tdb_transaction_cancel", (PyCFunction)_wrap_tdb_transaction_cancel, METH_O, NULL},
- { (char *)"tdb_transaction_recover", (PyCFunction)_wrap_tdb_transaction_recover, METH_O, NULL},
- { (char *)"tdb_hash_size", (PyCFunction)_wrap_tdb_hash_size, METH_O, NULL},
- { (char *)"tdb_map_size", (PyCFunction)_wrap_tdb_map_size, METH_O, NULL},
- { (char *)"tdb_get_flags", (PyCFunction)_wrap_tdb_get_flags, METH_O, NULL},
- { (char *)"tdb_set_max_dead", (PyCFunction) _wrap_tdb_set_max_dead, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"tdb_name", (PyCFunction)_wrap_tdb_name, METH_O, NULL},
- { (char *)"tdb_swigregister", tdb_swigregister, METH_VARARGS, NULL},
+ { (char *)"new_Tdb", (PyCFunction) _wrap_new_Tdb, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.__init__(name,hash_size=0,tdb_flags=TDB_DEFAULT,flags=O_RDWR,mode=0600)\n"
+ "Open a TDB file.\n"
+ ""},
+ { (char *)"Tdb_error", (PyCFunction)_wrap_Tdb_error, METH_O, NULL},
+ { (char *)"delete_Tdb", (PyCFunction)_wrap_delete_Tdb, METH_O, NULL},
+ { (char *)"Tdb_close", (PyCFunction)_wrap_Tdb_close, METH_O, (char *)"\n"
+ "S.close() -> None\n"
+ "Close the TDB file.\n"
+ ""},
+ { (char *)"Tdb_append", (PyCFunction) _wrap_Tdb_append, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Tdb_errorstr", (PyCFunction)_wrap_Tdb_errorstr, METH_O, (char *)"\n"
+ "S.errorstr() -> errorstring\n"
+ "Obtain last error message.\n"
+ ""},
+ { (char *)"Tdb_get", (PyCFunction) _wrap_Tdb_get, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.fetch(key) -> value\n"
+ "Fetch a value.\n"
+ ""},
+ { (char *)"Tdb_delete", (PyCFunction) _wrap_Tdb_delete, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.delete(key) -> None\n"
+ "Delete an entry.\n"
+ ""},
+ { (char *)"Tdb_store", (PyCFunction) _wrap_Tdb_store, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.store(key, value, flag=TDB_REPLACE) -> None\n"
+ "Store an entry.\n"
+ ""},
+ { (char *)"Tdb_exists", (PyCFunction) _wrap_Tdb_exists, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"Tdb_firstkey", (PyCFunction)_wrap_Tdb_firstkey, METH_O, (char *)"\n"
+ "S.firstkey() -> data\n"
+ "Return the first key in this database.\n"
+ ""},
+ { (char *)"Tdb_nextkey", (PyCFunction) _wrap_Tdb_nextkey, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.nextkey(prev) -> data\n"
+ "Return the next key in this database.\n"
+ ""},
+ { (char *)"Tdb_lock_all", (PyCFunction)_wrap_Tdb_lock_all, METH_O, (char *)"S.lockall() -> bool"},
+ { (char *)"Tdb_unlock_all", (PyCFunction)_wrap_Tdb_unlock_all, METH_O, (char *)"S.unlockall() -> bool"},
+ { (char *)"Tdb_read_lock_all", (PyCFunction)_wrap_Tdb_read_lock_all, METH_O, NULL},
+ { (char *)"Tdb_read_unlock_all", (PyCFunction)_wrap_Tdb_read_unlock_all, METH_O, NULL},
+ { (char *)"Tdb_reopen", (PyCFunction)_wrap_Tdb_reopen, METH_O, (char *)"\n"
+ "S.reopen() -> bool\n"
+ "Reopen this file.\n"
+ ""},
+ { (char *)"Tdb_transaction_start", (PyCFunction)_wrap_Tdb_transaction_start, METH_O, (char *)"\n"
+ "S.transaction_start() -> None\n"
+ "Start a new transaction.\n"
+ ""},
+ { (char *)"Tdb_transaction_commit", (PyCFunction)_wrap_Tdb_transaction_commit, METH_O, (char *)"\n"
+ "S.transaction_commit() -> None\n"
+ "Commit the currently active transaction.\n"
+ ""},
+ { (char *)"Tdb_transaction_cancel", (PyCFunction)_wrap_Tdb_transaction_cancel, METH_O, (char *)"\n"
+ "S.transaction_cancel() -> None\n"
+ "Cancel the currently active transaction.\n"
+ ""},
+ { (char *)"Tdb_transaction_recover", (PyCFunction)_wrap_Tdb_transaction_recover, METH_O, NULL},
+ { (char *)"Tdb_hash_size", (PyCFunction)_wrap_Tdb_hash_size, METH_O, (char *)"S.hash_size() -> int"},
+ { (char *)"Tdb_map_size", (PyCFunction)_wrap_Tdb_map_size, METH_O, (char *)"S.map_size() -> int"},
+ { (char *)"Tdb_get_flags", (PyCFunction)_wrap_Tdb_get_flags, METH_O, (char *)"S.get_flags() -> int"},
+ { (char *)"Tdb_set_max_dead", (PyCFunction) _wrap_Tdb_set_max_dead, METH_VARARGS | METH_KEYWORDS, (char *)"S.set_max_dead(int) -> None"},
+ { (char *)"Tdb_name", (PyCFunction)_wrap_Tdb_name, METH_O, (char *)"\n"
+ "S.name() -> path\n"
+ "Return filename of this TDB file.\n"
+ ""},
+ { (char *)"Tdb_swigregister", Tdb_swigregister, METH_VARARGS, NULL},
+ { (char *)"Tdb_swiginit", Tdb_swiginit, METH_VARARGS, NULL},
{ NULL, NULL, 0, NULL }
};
@@ -3753,7 +3815,7 @@ SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
- int found;
+ int found, init;
clientdata = clientdata;
@@ -3763,6 +3825,9 @@ SWIG_InitializeModule(void *clientdata) {
swig_module.type_initial = swig_type_initial;
swig_module.cast_initial = swig_cast_initial;
swig_module.next = &swig_module;
+ init = 1;
+ } else {
+ init = 0;
}
/* Try and load any already created modules */
@@ -3791,6 +3856,12 @@ SWIG_InitializeModule(void *clientdata) {
module_head->next = &swig_module;
}
+ /* When multiple interpeters are used, a module could have already been initialized in
+ a different interpreter, but not yet have a pointer in this interpreter.
+ In this case, we do not want to continue adding types... everything should be
+ set up already */
+ if (init == 0) return;
+
/* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: size %d\n", swig_module.size);
diff --git a/source4/lib/tdr/config.mk b/source4/lib/tdr/config.mk
index eb3cde9bdf..07506ec647 100644
--- a/source4/lib/tdr/config.mk
+++ b/source4/lib/tdr/config.mk
@@ -1,7 +1,9 @@
[SUBSYSTEM::TDR]
CFLAGS = -Ilib/tdr
-PRIVATE_PROTO_HEADER = tdr_proto.h
PUBLIC_DEPENDENCIES = LIBTALLOC LIBSAMBA-UTIL
-OBJ_FILES = tdr.o
-PUBLIC_HEADERS += lib/tdr/tdr.h
+TDR_OBJ_FILES = $(libtdrsrcdir)/tdr.o
+
+$(eval $(call proto_header_template,$(libtdrsrcdir)/tdr_proto.h,$(TDR_OBJ_FILES:.o=.c)))
+
+PUBLIC_HEADERS += $(libtdrsrcdir)/tdr.h
diff --git a/source4/lib/tls/config.mk b/source4/lib/tls/config.mk
index 8e8330f709..e01f79ce10 100644
--- a/source4/lib/tls/config.mk
+++ b/source4/lib/tls/config.mk
@@ -1,11 +1,5 @@
-################################################
-# Start SUBSYSTEM LIBTLS
[SUBSYSTEM::LIBTLS]
-OBJ_FILES = \
- tls.o \
- tlscert.o
PUBLIC_DEPENDENCIES = \
LIBTALLOC GNUTLS LIBSAMBA-HOSTCONFIG samba-socket
-#
-# End SUBSYSTEM LIBTLS
-################################################
+
+LIBTLS_OBJ_FILES = $(addprefix $(libtlssrcdir)/, tls.o tlscert.o)
diff --git a/source4/lib/torture/config.mk b/source4/lib/torture/config.mk
new file mode 100644
index 0000000000..49e7b1a171
--- /dev/null
+++ b/source4/lib/torture/config.mk
@@ -0,0 +1,14 @@
+# TORTURE subsystem
+[LIBRARY::torture]
+PUBLIC_DEPENDENCIES = \
+ LIBSAMBA-HOSTCONFIG \
+ LIBSAMBA-UTIL \
+ LIBTALLOC
+
+torture_VERSION = 0.0.1
+torture_SOVERSION = 0
+
+PC_FILES += $(libtorturesrcdir)/torture.pc
+torture_OBJ_FILES = $(addprefix $(libtorturesrcdir)/, torture.o)
+
+PUBLIC_HEADERS += $(libtorturesrcdir)/torture.h
diff --git a/source4/torture/ui.c b/source4/lib/torture/torture.c
index a7025aac95..33959ded16 100644
--- a/source4/torture/ui.c
+++ b/source4/lib/torture/torture.c
@@ -19,22 +19,19 @@
*/
#include "includes.h"
-#include "torture/ui.h"
#include "torture/torture.h"
#include "lib/util/dlinklist.h"
#include "param/param.h"
#include "system/filesys.h"
-#include "auth/credentials/credentials.h"
-#include "lib/cmdline/popt_common.h"
-struct torture_context *torture_context_init(TALLOC_CTX *mem_ctx,
+struct torture_context *torture_context_init(struct event_context *event_ctx,
const struct torture_ui_ops *ui_ops)
{
- struct torture_context *torture = talloc_zero(mem_ctx,
+ struct torture_context *torture = talloc_zero(event_ctx,
struct torture_context);
torture->ui_ops = ui_ops;
torture->returncode = true;
- torture->ev = cli_credentials_get_event_context(cmdline_credentials);
+ torture->ev = event_ctx;
if (ui_ops->init)
ui_ops->init(torture);
@@ -578,6 +575,3 @@ struct torture_test *torture_tcase_add_simple_test(struct torture_tcase *tcase,
return test;
}
-
-
-
diff --git a/source4/torture/ui.h b/source4/lib/torture/torture.h
index 6645d9b012..15b04c2397 100644
--- a/source4/torture/ui.h
+++ b/source4/lib/torture/torture.h
@@ -253,6 +253,15 @@ void torture_result(struct torture_context *test,
} \
} while(0)
+#define torture_assert_mem_equal(torture_ctx,got,expected,len,cmt)\
+ do { const void *__got = (got), *__expected = (expected); \
+ if (memcmp(__got, __expected, len) != 0) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" of len %d did not match"#expected": %s", len, cmt); \
+ return false; \
+ } \
+ } while(0)
+
#define torture_assert_file_contains_text(torture_ctx,filename,expected,cmt)\
do { \
char *__got; \
@@ -381,7 +390,7 @@ bool torture_suite_init_tcase(struct torture_suite *suite,
struct torture_tcase *tcase,
const char *name);
-struct torture_context *torture_context_init(TALLOC_CTX *mem_ctx,
+struct torture_context *torture_context_init(struct event_context *event_ctx,
const struct torture_ui_ops *ui_ops);
#endif /* __TORTURE_UI_H__ */
diff --git a/source4/torture/torture.pc.in b/source4/lib/torture/torture.pc.in
index 6582816cb5..6582816cb5 100644
--- a/source4/torture/torture.pc.in
+++ b/source4/lib/torture/torture.pc.in
diff --git a/source4/lib/util/config.mk b/source4/lib/util/config.mk
index 0bf0692193..925713a53c 100644
--- a/source4/lib/util/config.mk
+++ b/source4/lib/util/config.mk
@@ -1,7 +1,11 @@
[SUBSYSTEM::LIBSAMBA-UTIL]
-#VERSION = 0.0.1
-#SO_VERSION = 0
-OBJ_FILES = xfile.o \
+PUBLIC_DEPENDENCIES = \
+ LIBTALLOC LIBCRYPTO \
+ SOCKET_WRAPPER LIBREPLACE_NETWORK \
+ CHARSET EXECINFO
+
+LIBSAMBA-UTIL_OBJ_FILES = $(addprefix $(libutilsrcdir)/, \
+ xfile.o \
debug.o \
fault.o \
signal.o \
@@ -19,13 +23,9 @@ OBJ_FILES = xfile.o \
mutex.o \
idtree.o \
become_daemon.o \
- params.o
-PUBLIC_DEPENDENCIES = \
- LIBTALLOC LIBCRYPTO \
- SOCKET_WRAPPER LIBREPLACE_NETWORK \
- CHARSET EXECINFO
+ params.o)
-PUBLIC_HEADERS += $(addprefix lib/util/, util.h \
+PUBLIC_HEADERS += $(addprefix $(libutilsrcdir)/, util.h \
attr.h \
byteorder.h \
data_blob.h \
@@ -37,32 +37,35 @@ PUBLIC_HEADERS += $(addprefix lib/util/, util.h \
xfile.h)
[SUBSYSTEM::ASN1_UTIL]
-PRIVATE_PROTO_HEADER = asn1_proto.h
-OBJ_FILES = asn1.o
-# PUBLIC_HEADERS += lib/util/asn1.h
+ASN1_UTIL_OBJ_FILES = $(libutilsrcdir)/asn1.o
+
+$(eval $(call proto_header_template,$(libutilsrcdir)/asn1_proto.h,$(ASN1_UTIL_OBJ_FILES:.o=.c)))
[SUBSYSTEM::UNIX_PRIVS]
-PRIVATE_PROTO_HEADER = unix_privs.h
-OBJ_FILES = unix_privs.o
+
+UNIX_PRIVS_OBJ_FILES = $(libutilsrcdir)/unix_privs.o
+
+$(eval $(call proto_header_template,$(libutilsrcdir)/unix_privs.h,$(UNIX_PRIVS_OBJ_FILES:.o=.c)))
################################################
# Start SUBSYSTEM WRAP_XATTR
[SUBSYSTEM::WRAP_XATTR]
-OBJ_FILES = \
- wrap_xattr.o
PUBLIC_DEPENDENCIES = XATTR
#
# End SUBSYSTEM WRAP_XATTR
################################################
+WRAP_XATTR_OBJ_FILES = $(libutilsrcdir)/wrap_xattr.o
+
[SUBSYSTEM::UTIL_TDB]
-PRIVATE_PROTO_HEADER = util_tdb.h
-OBJ_FILES = \
- util_tdb.o
PUBLIC_DEPENDENCIES = LIBTDB
+UTIL_TDB_OBJ_FILES = $(libutilsrcdir)/util_tdb.o
+
+$(eval $(call proto_header_template,$(libutilsrcdir)/util_tdb.h,$(UTIL_TDB_OBJ_FILES:.o=.c)))
+
[SUBSYSTEM::UTIL_LDB]
-OBJ_FILES = \
- util_ldb.o
PUBLIC_DEPENDENCIES = LIBLDB
+
+UTIL_LDB_OBJ_FILES = $(libutilsrcdir)/util_ldb.o
diff --git a/source4/lib/util/tests/file.c b/source4/lib/util/tests/file.c
index fe87293671..3377e833dc 100644
--- a/source4/lib/util/tests/file.c
+++ b/source4/lib/util/tests/file.c
@@ -45,9 +45,9 @@ static bool test_file_load_save(struct torture_context *tctx)
data = file_load(TEST_FILENAME, &len, mem_ctx);
torture_assert(tctx, data, "loading file");
- torture_assert(tctx, len == strlen(TEST_DATA), "Length");
+ torture_assert_int_equal(tctx, len, strlen(TEST_DATA), "Length");
- torture_assert(tctx, memcmp(data, TEST_DATA, len) == 0, "Contents");
+ torture_assert_mem_equal(tctx, data, TEST_DATA, len, "Contents");
unlink(TEST_FILENAME);
return true;
diff --git a/source4/lib/util/tests/str.c b/source4/lib/util/tests/str.c
index a219ef0891..3bd6a02fdc 100644
--- a/source4/lib/util/tests/str.c
+++ b/source4/lib/util/tests/str.c
@@ -20,7 +20,7 @@
*/
#include "includes.h"
-#include "torture/ui.h"
+#include "torture/torture.h"
static bool test_string_sub_simple(struct torture_context *tctx)
{
diff --git a/source4/lib/util/time.c b/source4/lib/util/time.c
index a181885806..978d73cc0a 100644
--- a/source4/lib/util/time.c
+++ b/source4/lib/util/time.c
@@ -376,7 +376,7 @@ _PUBLIC_ NTTIME pull_nttime(uint8_t *base, uint16_t offset)
/**
return (tv1 - tv2) in microseconds
*/
-_PUBLIC_ int64_t usec_time_diff(struct timeval *tv1, struct timeval *tv2)
+_PUBLIC_ int64_t usec_time_diff(const struct timeval *tv1, const struct timeval *tv2)
{
int64_t sec_diff = tv1->tv_sec - tv2->tv_sec;
return (sec_diff * 1000000) + (int64_t)(tv1->tv_usec - tv2->tv_usec);
diff --git a/source4/lib/util/time.h b/source4/lib/util/time.h
index 1ab976ca78..e4008c5782 100644
--- a/source4/lib/util/time.h
+++ b/source4/lib/util/time.h
@@ -127,7 +127,7 @@ _PUBLIC_ NTTIME nttime_from_string(const char *s);
/**
return (tv1 - tv2) in microseconds
*/
-_PUBLIC_ int64_t usec_time_diff(struct timeval *tv1, struct timeval *tv2);
+_PUBLIC_ int64_t usec_time_diff(const struct timeval *tv1, const struct timeval *tv2);
/**
return a zero timeval
diff --git a/source4/lib/util/util.h b/source4/lib/util/util.h
index 3bf6b98d2f..ffe83c14b2 100644
--- a/source4/lib/util/util.h
+++ b/source4/lib/util/util.h
@@ -64,7 +64,7 @@ extern const char *panic_action;
makes the return type safe.
*/
#ifndef discard_const
-#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
+#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
#endif
/** Type-safe version of discard_const */
diff --git a/source4/libcli/auth/config.mk b/source4/libcli/auth/config.mk
index f786c71469..498c2af258 100644
--- a/source4/libcli/auth/config.mk
+++ b/source4/libcli/auth/config.mk
@@ -1,16 +1,17 @@
#################################
# Start SUBSYSTEM LIBCLI_AUTH
[SUBSYSTEM::LIBCLI_AUTH]
-PRIVATE_PROTO_HEADER = proto.h
-OBJ_FILES = credentials.o \
- session.o \
- smbencrypt.o \
- smbdes.o
PUBLIC_DEPENDENCIES = \
MSRPC_PARSE \
LIBSAMBA-HOSTCONFIG
# End SUBSYSTEM LIBCLI_AUTH
#################################
+LIBCLI_AUTH_OBJ_FILES = $(addprefix $(libclisrcdir)/auth/, \
+ credentials.o \
+ session.o \
+ smbencrypt.o \
+ smbdes.o)
-PUBLIC_HEADERS += libcli/auth/credentials.h
+PUBLIC_HEADERS += $(libclisrcdir)/auth/credentials.h
+$(eval $(call proto_header_template,$(libclisrcdir)/auth/proto.h,$(LIBCLI_AUTH_OBJ_FILES:.o=.c)))
diff --git a/source4/libcli/cldap/cldap.c b/source4/libcli/cldap/cldap.c
index d10eeb8ffd..860bd358d5 100644
--- a/source4/libcli/cldap/cldap.c
+++ b/source4/libcli/cldap/cldap.c
@@ -250,11 +250,7 @@ struct cldap_socket *cldap_socket_init(TALLOC_CTX *mem_ctx,
cldap = talloc(mem_ctx, struct cldap_socket);
if (cldap == NULL) goto failed;
- if (event_ctx == NULL) {
- cldap->event_ctx = event_context_init(cldap);
- } else {
- cldap->event_ctx = talloc_reference(cldap, event_ctx);
- }
+ cldap->event_ctx = talloc_reference(cldap, event_ctx);
if (cldap->event_ctx == NULL) goto failed;
cldap->idr = idr_init(cldap);
@@ -599,10 +595,12 @@ NTSTATUS cldap_netlogon_recv(struct cldap_request *req,
struct cldap_netlogon *io)
{
NTSTATUS status;
- enum ndr_err_code ndr_err;
struct cldap_search search;
+ struct cldap_socket *cldap;
DATA_BLOB *data;
+ cldap = req->cldap;
+
status = cldap_search_recv(req, mem_ctx, &search);
if (!NT_STATUS_IS_OK(status)) {
return status;
@@ -619,18 +617,15 @@ NTSTATUS cldap_netlogon_recv(struct cldap_request *req,
}
data = search.out.response->attributes[0].values;
- ndr_err = ndr_pull_union_blob_all(data, mem_ctx,
- req->cldap->iconv_convenience,
- &io->out.netlogon,
- io->in.version & 0xF,
- (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- DEBUG(2,("cldap failed to parse netlogon response of type 0x%02x\n",
- SVAL(data->data, 0)));
- dump_data(10, data->data, data->length);
- return ndr_map_error2ntstatus(ndr_err);
+ status = pull_netlogon_samlogon_response(data, mem_ctx, req->cldap->iconv_convenience,
+ &io->out.netlogon);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ if (io->in.map_response) {
+ map_netlogon_samlogon_response(&io->out.netlogon);
}
-
return NT_STATUS_OK;
}
@@ -705,25 +700,20 @@ NTSTATUS cldap_netlogon_reply(struct cldap_socket *cldap,
uint32_t message_id,
struct socket_address *src,
uint32_t version,
- union nbt_cldap_netlogon *netlogon)
+ struct netlogon_samlogon_response *netlogon)
{
NTSTATUS status;
- enum ndr_err_code ndr_err;
struct cldap_reply reply;
struct ldap_SearchResEntry response;
struct ldap_Result result;
TALLOC_CTX *tmp_ctx = talloc_new(cldap);
DATA_BLOB blob;
- ndr_err = ndr_push_union_blob(&blob, tmp_ctx,
- cldap->iconv_convenience,
- netlogon, version & 0xF,
- (ndr_push_flags_fn_t)ndr_push_nbt_cldap_netlogon);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- talloc_free(tmp_ctx);
- return ndr_map_error2ntstatus(ndr_err);
+ status = push_netlogon_samlogon_response(&blob, tmp_ctx, cldap->iconv_convenience,
+ netlogon);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
-
reply.messageid = message_id;
reply.dest = src;
reply.response = &response;
diff --git a/source4/libcli/cldap/cldap.h b/source4/libcli/cldap/cldap.h
index eb0191d0f4..7c2daf0ca2 100644
--- a/source4/libcli/cldap/cldap.h
+++ b/source4/libcli/cldap/cldap.h
@@ -20,7 +20,7 @@
*/
#include "lib/util/asn1.h"
-#include "librpc/gen_ndr/nbt.h"
+#include "libcli/netlogon.h"
struct ldap_message;
@@ -161,9 +161,10 @@ struct cldap_netlogon {
const char *domain_sid;
int acct_control;
uint32_t version;
+ bool map_response;
} in;
struct {
- union nbt_cldap_netlogon netlogon;
+ struct netlogon_samlogon_response netlogon;
} out;
};
@@ -178,4 +179,4 @@ NTSTATUS cldap_netlogon_reply(struct cldap_socket *cldap,
uint32_t message_id,
struct socket_address *src,
uint32_t version,
- union nbt_cldap_netlogon *netlogon);
+ struct netlogon_samlogon_response *netlogon);
diff --git a/source4/libcli/cliconnect.c b/source4/libcli/cliconnect.c
index 4858a96110..c20a7fd935 100644
--- a/source4/libcli/cliconnect.c
+++ b/source4/libcli/cliconnect.c
@@ -33,13 +33,14 @@
*/
bool smbcli_socket_connect(struct smbcli_state *cli, const char *server,
const char **ports,
+ struct event_context *ev_ctx,
struct resolve_context *resolve_ctx,
struct smbcli_options *options)
{
struct smbcli_socket *sock;
- sock = smbcli_sock_connect_byname(server, ports, NULL, resolve_ctx,
- NULL);
+ sock = smbcli_sock_connect_byname(server, ports, NULL,
+ resolve_ctx, ev_ctx);
if (sock == NULL) return false;
diff --git a/source4/libcli/clifile.c b/source4/libcli/clifile.c
index e59b7f9af3..2cf174060b 100644
--- a/source4/libcli/clifile.c
+++ b/source4/libcli/clifile.c
@@ -650,7 +650,8 @@ NTSTATUS smbcli_chkpath(struct smbcli_tree *tree, const char *path)
/****************************************************************************
Query disk space.
****************************************************************************/
-NTSTATUS smbcli_dskattr(struct smbcli_tree *tree, int *bsize, int *total, int *avail)
+NTSTATUS smbcli_dskattr(struct smbcli_tree *tree, uint32_t *bsize,
+ uint64_t *total, uint64_t *avail)
{
union smb_fsinfo fsinfo_parms;
TALLOC_CTX *mem_ctx;
@@ -658,12 +659,12 @@ NTSTATUS smbcli_dskattr(struct smbcli_tree *tree, int *bsize, int *total, int *a
mem_ctx = talloc_init("smbcli_dskattr");
- fsinfo_parms.dskattr.level = RAW_QFS_DSKATTR;
+ fsinfo_parms.dskattr.level = RAW_QFS_SIZE_INFO;
status = smb_raw_fsinfo(tree, mem_ctx, &fsinfo_parms);
if (NT_STATUS_IS_OK(status)) {
- *bsize = fsinfo_parms.dskattr.out.block_size;
- *total = fsinfo_parms.dskattr.out.units_total;
- *avail = fsinfo_parms.dskattr.out.units_free;
+ *bsize = fsinfo_parms.size_info.out.bytes_per_sector * fsinfo_parms.size_info.out.sectors_per_unit;
+ *total = fsinfo_parms.size_info.out.total_alloc_units;
+ *avail = fsinfo_parms.size_info.out.avail_alloc_units;
}
talloc_free(mem_ctx);
diff --git a/source4/libcli/composite/composite.c b/source4/libcli/composite/composite.c
index 26169e7838..3e3f224f47 100644
--- a/source4/libcli/composite/composite.c
+++ b/source4/libcli/composite/composite.c
@@ -42,7 +42,11 @@ _PUBLIC_ struct composite_context *composite_create(TALLOC_CTX *mem_ctx,
c = talloc_zero(mem_ctx, struct composite_context);
if (!c) return NULL;
c->state = COMPOSITE_STATE_IN_PROGRESS;
- c->event_ctx = ev;
+ c->event_ctx = talloc_reference(c, ev);
+ if (!c->event_ctx) {
+ talloc_free(c);
+ return NULL;
+ }
return c;
}
@@ -65,6 +69,17 @@ _PUBLIC_ NTSTATUS composite_wait(struct composite_context *c)
return c->status;
}
+/*
+ block until a composite function has completed, then return the status.
+ Free the composite context before returning
+*/
+_PUBLIC_ NTSTATUS composite_wait_free(struct composite_context *c)
+{
+ NTSTATUS status = composite_wait(c);
+ talloc_free(c);
+ return status;
+}
+
/*
callback from composite_done() and composite_error()
@@ -90,6 +105,12 @@ static void composite_trigger(struct event_context *ev, struct timed_event *te,
_PUBLIC_ void composite_error(struct composite_context *ctx, NTSTATUS status)
{
+ /* you are allowed to pass NT_STATUS_OK to composite_error(), in which
+ case it is equivalent to composite_done() */
+ if (NT_STATUS_IS_OK(status)) {
+ composite_done(ctx);
+ return;
+ }
if (!ctx->used_wait && !ctx->async.fn) {
event_add_timed(ctx->event_ctx, ctx, timeval_zero(), composite_trigger, ctx);
}
@@ -183,7 +204,7 @@ _PUBLIC_ void composite_continue_smb2(struct composite_context *ctx,
{
if (composite_nomem(new_req, ctx)) return;
new_req->async.fn = continuation;
- new_req->async.private = private_data;
+ new_req->async.private_data = private_data;
}
_PUBLIC_ void composite_continue_nbt(struct composite_context *ctx,
diff --git a/source4/libcli/composite/composite.h b/source4/libcli/composite/composite.h
index f1bed20361..28cd6a88dc 100644
--- a/source4/libcli/composite/composite.h
+++ b/source4/libcli/composite/composite.h
@@ -101,6 +101,7 @@ bool composite_is_ok(struct composite_context *ctx);
void composite_done(struct composite_context *ctx);
void composite_error(struct composite_context *ctx, NTSTATUS status);
NTSTATUS composite_wait(struct composite_context *c);
+NTSTATUS composite_wait_free(struct composite_context *c);
#endif /* __COMPOSITE_H__ */
diff --git a/source4/libcli/config.mk b/source4/libcli/config.mk
index 0c00fa2740..b24f3eb4af 100644
--- a/source4/libcli/config.mk
+++ b/source4/libcli/config.mk
@@ -4,150 +4,174 @@ mkinclude security/config.mk
mkinclude wbclient/config.mk
[SUBSYSTEM::LIBSAMBA-ERRORS]
-OBJ_FILES = util/doserr.o \
- util/errormap.o \
- util/nterr.o \
+LIBSAMBA-ERRORS_OBJ_FILES = $(addprefix $(libclisrcdir)/util/, doserr.o errormap.o nterr.o)
-PUBLIC_HEADERS += $(addprefix libcli/, util/error.h util/ntstatus.h util/doserr.h util/werror.h)
+PUBLIC_HEADERS += $(addprefix $(libclisrcdir)/, util/error.h util/ntstatus.h util/doserr.h util/werror.h)
[SUBSYSTEM::LIBCLI_LSA]
-PRIVATE_PROTO_HEADER = util/clilsa.h
-OBJ_FILES = util/clilsa.o
PUBLIC_DEPENDENCIES = RPC_NDR_LSA
PRIVATE_DEPENDENCIES = LIBSECURITY
+LIBCLI_LSA_OBJ_FILES = $(libclisrcdir)/util/clilsa.o
+
+$(eval $(call proto_header_template,$(libclisrcdir)/util/clilsa.h,$(LIBCLI_LSA_OBJ_FILES:.o=.c)))
+
[SUBSYSTEM::LIBCLI_COMPOSITE]
-PRIVATE_PROTO_HEADER = composite/proto.h
-OBJ_FILES = \
- composite/composite.o
PUBLIC_DEPENDENCIES = LIBEVENTS
+LIBCLI_COMPOSITE_OBJ_FILES = $(libclisrcdir)/composite/composite.o
+$(eval $(call proto_header_template,$(libclisrcdir)/composite/proto.h,$(LIBCLI_COMPOSITE_OBJ_FILES:.o=.c)))
+
[SUBSYSTEM::LIBCLI_SMB_COMPOSITE]
-PRIVATE_PROTO_HEADER = smb_composite/proto.h
-OBJ_FILES = \
- smb_composite/loadfile.o \
- smb_composite/savefile.o \
- smb_composite/connect.o \
- smb_composite/sesssetup.o \
- smb_composite/fetchfile.o \
- smb_composite/appendacl.o \
- smb_composite/fsinfo.o
PUBLIC_DEPENDENCIES = LIBCLI_COMPOSITE CREDENTIALS gensec LIBCLI_RESOLVE
+LIBCLI_SMB_COMPOSITE_OBJ_FILES = $(addprefix $(libclisrcdir)/smb_composite/, \
+ loadfile.o \
+ savefile.o \
+ connect.o \
+ sesssetup.o \
+ fetchfile.o \
+ appendacl.o \
+ fsinfo.o \
+ smb2.o)
+
+$(eval $(call proto_header_template,$(libclisrcdir)/smb_composite/proto.h,$(LIBCLI_SMB_COMPOSITE_OBJ_FILES:.o=.c)))
+
[SUBSYSTEM::NDR_NBT_BUF]
-PRIVATE_PROTO_HEADER = nbt/nbtname.h
-OBJ_FILES = nbt/nbtname.o
+
+NDR_NBT_BUF_OBJ_FILES = $(libclisrcdir)/nbt/nbtname.o
+
+$(eval $(call proto_header_template,$(libclisrcdir)/nbt/nbtname.h,$(NDR_NBT_BUF_OBJ_FILES:.o=.c)))
[SUBSYSTEM::LIBCLI_NBT]
-#VERSION = 0.0.1
-#SO_VERSION = 0
-PRIVATE_PROTO_HEADER = nbt/nbt_proto.h
-OBJ_FILES = \
- nbt/nbtsocket.o \
- nbt/namequery.o \
- nbt/nameregister.o \
- nbt/namerefresh.o \
- nbt/namerelease.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_NBT LIBCLI_COMPOSITE LIBEVENTS \
NDR_SECURITY samba-socket LIBSAMBA-UTIL
+LIBCLI_NBT_OBJ_FILES = $(addprefix $(libclisrcdir)/nbt/, \
+ nbtsocket.o \
+ namequery.o \
+ nameregister.o \
+ namerefresh.o \
+ namerelease.o)
+
+$(eval $(call proto_header_template,$(libclisrcdir)/nbt/nbt_proto.h,$(LIBCLI_NBT_OBJ_FILES:.o=.c)))
+
+[SUBSYSTEM::LIBCLI_NDR_NETLOGON]
+PUBLIC_DEPENDENCIES = LIBNDR \
+ NDR_SECURITY
+
+LIBCLI_NDR_NETLOGON_OBJ_FILES = $(addprefix libcli/, \
+ ndr_netlogon.o)
+
+$(eval $(call proto_header_template,$(libclisrcdir)/ndr_netlogon_proto.h,$(LIBCLI_NDR_NETLOGON_OBJ_FILES:.o=.c)))
+
+[SUBSYSTEM::LIBCLI_NETLOGON]
+PUBLIC_DEPENDENCIES = LIBSAMBA-UTIL LIBCLI_NDR_NETLOGON
+
+LIBCLI_NETLOGON_OBJ_FILES = $(addprefix libcli/, \
+ netlogon.o)
+
+$(eval $(call proto_header_template,$(libclisrcdir)/netlogon_proto.h,$(LIBCLI_NETLOGON_OBJ_FILES:.o=.c)))
+
[PYTHON::python_libcli_nbt]
-SWIG_FILE = swig/libcli_nbt.i
+LIBRARY_REALNAME = samba/_libcli_nbt.$(SHLIBEXT)
PUBLIC_DEPENDENCIES = LIBCLI_NBT DYNCONFIG LIBSAMBA-HOSTCONFIG
+python_libcli_nbt_OBJ_FILES = $(libclisrcdir)/swig/libcli_nbt_wrap.o
+
+$(eval $(call python_py_module_template,samba/nbt.py,$(libclisrcdir)/swig/libcli_nbt.py))
+
+$(python_libcli_nbt_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
+
[PYTHON::python_libcli_smb]
-SWIG_FILE = swig/libcli_smb.i
+LIBRARY_REALNAME = samba/_libcli_smb.$(SHLIBEXT)
PUBLIC_DEPENDENCIES = LIBCLI_SMB DYNCONFIG LIBSAMBA-HOSTCONFIG
+python_libcli_smb_OBJ_FILES = $(libclisrcdir)/swig/libcli_smb_wrap.o
+
+$(eval $(call python_py_module_template,samba/smb.py,$(libclisrcdir)/swig/libcli_smb.py))
+
+$(python_libcli_smb_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
+
+
[SUBSYSTEM::LIBCLI_DGRAM]
-OBJ_FILES = \
- dgram/dgramsocket.o \
- dgram/mailslot.o \
- dgram/netlogon.o \
- dgram/ntlogon.o \
- dgram/browse.o
-PUBLIC_DEPENDENCIES = LIBCLI_NBT LIBNDR LIBCLI_RESOLVE
+PUBLIC_DEPENDENCIES = LIBCLI_NBT LIBNDR LIBCLI_RESOLVE LIBCLI_NETLOGON
+
+LIBCLI_DGRAM_OBJ_FILES = $(addprefix $(libclisrcdir)/dgram/, \
+ dgramsocket.o \
+ mailslot.o \
+ netlogon.o \
+ browse.o)
[SUBSYSTEM::LIBCLI_CLDAP]
-OBJ_FILES = cldap/cldap.o
PUBLIC_DEPENDENCIES = LIBCLI_LDAP
-PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBLDB
+PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBLDB LIBCLI_NETLOGON
-# PUBLIC_HEADERS += libcli/cldap/cldap.h
+LIBCLI_CLDAP_OBJ_FILES = $(libclisrcdir)/cldap/cldap.o
+# PUBLIC_HEADERS += $(libclisrcdir)/cldap/cldap.h
[SUBSYSTEM::LIBCLI_WREPL]
-PRIVATE_PROTO_HEADER = wrepl/winsrepl_proto.h
-OBJ_FILES = \
- wrepl/winsrepl.o
PUBLIC_DEPENDENCIES = NDR_WINSREPL samba-socket LIBCLI_RESOLVE LIBEVENTS \
LIBPACKET LIBNDR
+LIBCLI_WREPL_OBJ_FILES = $(libclisrcdir)/wrepl/winsrepl.o
+
+$(eval $(call proto_header_template,$(libclisrcdir)/wrepl/winsrepl_proto.h,$(LIBCLI_WREPL_OBJ_FILES:.o=.c)))
+
[SUBSYSTEM::LIBCLI_RESOLVE]
-PRIVATE_PROTO_HEADER = resolve/proto.h
-OBJ_FILES = \
- resolve/resolve.o
PUBLIC_DEPENDENCIES = NDR_NBT
+LIBCLI_RESOLVE_OBJ_FILES = $(libclisrcdir)/resolve/resolve.o
+
+$(eval $(call proto_header_template,$(libclisrcdir)/resolve/proto.h,$(LIBCLI_RESOLVE_OBJ_FILES:.o=.c)))
+
[SUBSYSTEM::LP_RESOLVE]
-PRIVATE_PROTO_HEADER = resolve/lp_proto.h
-OBJ_FILES = \
- resolve/bcast.o \
- resolve/nbtlist.o \
- resolve/wins.o \
- resolve/host.o \
- resolve/resolve_lp.o
PRIVATE_DEPENDENCIES = LIBCLI_NBT LIBSAMBA-HOSTCONFIG LIBNETIF
+LP_RESOLVE_OBJ_FILES = $(addprefix $(libclisrcdir)/resolve/, \
+ bcast.o nbtlist.o wins.o \
+ host.o resolve_lp.o)
+
+$(eval $(call proto_header_template,$(libclisrcdir)/resolve/lp_proto.h,$(LP_RESOLVE_OBJ_FILES:.o=.c)))
+
[SUBSYSTEM::LIBCLI_FINDDCS]
-PRIVATE_PROTO_HEADER = finddcs.h
-OBJ_FILES = \
- finddcs.o
PUBLIC_DEPENDENCIES = LIBCLI_NBT MESSAGING
+LIBCLI_FINDDCS_OBJ_FILES = $(libclisrcdir)/finddcs.o
+
+$(eval $(call proto_header_template,$(libclisrcdir)/finddcs.h,$(LIBCLI_FINDDCS_OBJ_FILES:.o=.c)))
+
[SUBSYSTEM::LIBCLI_SMB]
-PRIVATE_PROTO_HEADER = libcli_proto.h
-OBJ_FILES = clireadwrite.o \
+PUBLIC_DEPENDENCIES = LIBCLI_RAW LIBSAMBA-ERRORS LIBCLI_AUTH \
+ LIBCLI_SMB_COMPOSITE LIBCLI_NBT LIBSECURITY LIBCLI_RESOLVE \
+ LIBCLI_DGRAM LIBCLI_SMB2 LIBCLI_FINDDCS samba-socket
+
+LIBCLI_SMB_OBJ_FILES = $(addprefix $(libclisrcdir)/, \
+ clireadwrite.o \
cliconnect.o \
clifile.o \
clilist.o \
clitrans2.o \
climessage.o \
- clideltree.o
-PUBLIC_DEPENDENCIES = LIBCLI_RAW LIBSAMBA-ERRORS LIBCLI_AUTH \
- LIBCLI_SMB_COMPOSITE LIBCLI_NBT LIBSECURITY LIBCLI_RESOLVE \
- LIBCLI_DGRAM LIBCLI_SMB2 LIBCLI_FINDDCS samba-socket
+ clideltree.o)
+$(eval $(call proto_header_template,$(libclisrcdir)/libcli_proto.h,$(LIBCLI_SMB_OBJ_FILES:.o=.c)))
-# PUBLIC_HEADERS += libcli/libcli.h
+# PUBLIC_HEADERS += $(libclisrcdir)/libcli.h
[SUBSYSTEM::LIBCLI_RAW]
-PRIVATE_PROTO_HEADER = raw/raw_proto.h
PRIVATE_DEPENDENCIES = LIBCLI_COMPOSITE LP_RESOLVE gensec LIBCLI_RESOLVE LIBSECURITY LIBNDR
#LDFLAGS = $(LIBCLI_SMB_COMPOSITE_OUTPUT)
PUBLIC_DEPENDENCIES = samba-socket LIBPACKET gensec LIBCRYPTO CREDENTIALS
-OBJ_FILES = raw/rawfile.o \
- raw/smb_signing.o \
- raw/clisocket.o \
- raw/clitransport.o \
- raw/clisession.o \
- raw/clitree.o \
- raw/clierror.o \
- raw/rawrequest.o \
- raw/rawreadwrite.o \
- raw/rawsearch.o \
- raw/rawsetfileinfo.o \
- raw/raweas.o \
- raw/rawtrans.o \
- raw/clioplock.o \
- raw/rawnegotiate.o \
- raw/rawfsinfo.o \
- raw/rawfileinfo.o \
- raw/rawnotify.o \
- raw/rawioctl.o \
- raw/rawacl.o \
- raw/rawdate.o \
- raw/rawlpq.o \
- raw/rawshadow.o
+
+LIBCLI_RAW_OBJ_FILES = $(addprefix $(libclisrcdir)/raw/, rawfile.o smb_signing.o clisocket.o \
+ clitransport.o clisession.o clitree.o clierror.o rawrequest.o \
+ rawreadwrite.o rawsearch.o rawsetfileinfo.o raweas.o rawtrans.o \
+ clioplock.o rawnegotiate.o rawfsinfo.o rawfileinfo.o rawnotify.o \
+ rawioctl.o rawacl.o rawdate.o rawlpq.o rawshadow.o)
+
+
+$(eval $(call proto_header_template,$(libclisrcdir)/raw/raw_proto.h,$(LIBCLI_RAW_OBJ_FILES:.o=.c)))
mkinclude smb2/config.mk
diff --git a/source4/libcli/dgram/dgramsocket.c b/source4/libcli/dgram/dgramsocket.c
index 130d8ae870..06b7bd5771 100644
--- a/source4/libcli/dgram/dgramsocket.c
+++ b/source4/libcli/dgram/dgramsocket.c
@@ -167,11 +167,7 @@ struct nbt_dgram_socket *nbt_dgram_socket_init(TALLOC_CTX *mem_ctx,
dgmsock = talloc(mem_ctx, struct nbt_dgram_socket);
if (dgmsock == NULL) goto failed;
- if (event_ctx == NULL) {
- dgmsock->event_ctx = event_context_init(dgmsock);
- } else {
- dgmsock->event_ctx = talloc_reference(dgmsock, event_ctx);
- }
+ dgmsock->event_ctx = talloc_reference(dgmsock, event_ctx);
if (dgmsock->event_ctx == NULL) goto failed;
status = socket_create("ip", SOCKET_TYPE_DGRAM, &dgmsock->sock, 0);
diff --git a/source4/libcli/dgram/libdgram.h b/source4/libcli/dgram/libdgram.h
index 707cca8cc5..e1209e7a54 100644
--- a/source4/libcli/dgram/libdgram.h
+++ b/source4/libcli/dgram/libdgram.h
@@ -19,7 +19,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "librpc/gen_ndr/nbt.h"
+#include "libcli/netlogon.h"
/*
a datagram name request
@@ -121,33 +121,23 @@ NTSTATUS dgram_mailslot_send(struct nbt_dgram_socket *dgmsock,
NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock,
struct nbt_name *dest_name,
struct socket_address *dest,
+ const char *mailslot_name,
struct nbt_name *src_name,
struct nbt_netlogon_packet *request);
NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock,
struct nbt_dgram_packet *request,
const char *my_netbios_name,
const char *mailslot_name,
- struct nbt_netlogon_packet *reply);
-NTSTATUS dgram_mailslot_netlogon_parse(struct dgram_mailslot_handler *dgmslot,
- TALLOC_CTX *mem_ctx,
- struct nbt_dgram_packet *dgram,
- struct nbt_netlogon_packet *netlogon);
-
-NTSTATUS dgram_mailslot_ntlogon_send(struct nbt_dgram_socket *dgmsock,
- enum dgram_msg_type msg_type,
- struct nbt_name *dest_name,
- struct socket_address *dest,
- struct nbt_name *src_name,
- struct nbt_ntlogon_packet *request);
-NTSTATUS dgram_mailslot_ntlogon_reply(struct nbt_dgram_socket *dgmsock,
- struct nbt_dgram_packet *request,
- const char *my_netbios_name,
- const char *mailslot_name,
- struct nbt_ntlogon_packet *reply);
-NTSTATUS dgram_mailslot_ntlogon_parse(struct dgram_mailslot_handler *dgmslot,
- TALLOC_CTX *mem_ctx,
- struct nbt_dgram_packet *dgram,
- struct nbt_ntlogon_packet *ntlogon);
+ struct nbt_netlogon_response *reply);
+NTSTATUS dgram_mailslot_netlogon_parse_request(struct dgram_mailslot_handler *dgmslot,
+ TALLOC_CTX *mem_ctx,
+ struct nbt_dgram_packet *dgram,
+ struct nbt_netlogon_packet *netlogon);
+
+NTSTATUS dgram_mailslot_netlogon_parse_response(struct dgram_mailslot_handler *dgmslot,
+ TALLOC_CTX *mem_ctx,
+ struct nbt_dgram_packet *dgram,
+ struct nbt_netlogon_response *netlogon);
NTSTATUS dgram_mailslot_browse_send(struct nbt_dgram_socket *dgmsock,
struct nbt_name *dest_name,
diff --git a/source4/libcli/dgram/netlogon.c b/source4/libcli/dgram/netlogon.c
index 5c7dedc7bb..b37d4a2ee6 100644
--- a/source4/libcli/dgram/netlogon.c
+++ b/source4/libcli/dgram/netlogon.c
@@ -32,6 +32,7 @@
NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock,
struct nbt_name *dest_name,
struct socket_address *dest,
+ const char *mailslot,
struct nbt_name *src_name,
struct nbt_netlogon_packet *request)
{
@@ -51,7 +52,7 @@ NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock,
status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE,
- NBT_MAILSLOT_NETLOGON,
+ mailslot,
dest_name, dest,
src_name, &blob);
talloc_free(tmp_ctx);
@@ -66,22 +67,18 @@ NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock,
struct nbt_dgram_packet *request,
const char *my_netbios_name,
const char *mailslot_name,
- struct nbt_netlogon_packet *reply)
+ struct nbt_netlogon_response *reply)
{
NTSTATUS status;
- enum ndr_err_code ndr_err;
DATA_BLOB blob;
TALLOC_CTX *tmp_ctx = talloc_new(dgmsock);
struct nbt_name myname;
struct socket_address *dest;
- ndr_err = ndr_push_struct_blob(&blob, tmp_ctx,
- dgmsock->iconv_convenience,
- reply,
- (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_packet);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- talloc_free(tmp_ctx);
- return ndr_map_error2ntstatus(ndr_err);
+ status = push_nbt_netlogon_response(&blob, tmp_ctx, dgmsock->iconv_convenience,
+ reply);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
make_nbt_name_client(&myname, my_netbios_name);
@@ -106,10 +103,10 @@ NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock,
/*
parse a netlogon response. The packet must be a valid mailslot packet
*/
-NTSTATUS dgram_mailslot_netlogon_parse(struct dgram_mailslot_handler *dgmslot,
- TALLOC_CTX *mem_ctx,
- struct nbt_dgram_packet *dgram,
- struct nbt_netlogon_packet *netlogon)
+NTSTATUS dgram_mailslot_netlogon_parse_request(struct dgram_mailslot_handler *dgmslot,
+ TALLOC_CTX *mem_ctx,
+ struct nbt_dgram_packet *dgram,
+ struct nbt_netlogon_packet *netlogon)
{
DATA_BLOB data = dgram_mailslot_data(dgram);
enum ndr_err_code ndr_err;
@@ -127,3 +124,23 @@ NTSTATUS dgram_mailslot_netlogon_parse(struct dgram_mailslot_handler *dgmslot,
}
return NT_STATUS_OK;
}
+
+/*
+ parse a netlogon response. The packet must be a valid mailslot packet
+*/
+NTSTATUS dgram_mailslot_netlogon_parse_response(struct dgram_mailslot_handler *dgmslot,
+ TALLOC_CTX *mem_ctx,
+ struct nbt_dgram_packet *dgram,
+ struct nbt_netlogon_response *netlogon)
+{
+ NTSTATUS status;
+ DATA_BLOB data = dgram_mailslot_data(dgram);
+
+ status = pull_nbt_netlogon_response(&data, mem_ctx, dgmslot->dgmsock->iconv_convenience, netlogon);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ return NT_STATUS_OK;
+}
+
diff --git a/source4/libcli/dgram/ntlogon.c b/source4/libcli/dgram/ntlogon.c
deleted file mode 100644
index 7b26ed7c00..0000000000
--- a/source4/libcli/dgram/ntlogon.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
-
- handling for ntlogon dgram requests
-
- Copyright (C) Andrew Tridgell 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 "libcli/dgram/libdgram.h"
-#include "lib/socket/socket.h"
-#include "libcli/resolve/resolve.h"
-#include "librpc/gen_ndr/ndr_nbt.h"
-#include "param/param.h"
-
-/*
- send a ntlogon mailslot request
-*/
-NTSTATUS dgram_mailslot_ntlogon_send(struct nbt_dgram_socket *dgmsock,
- enum dgram_msg_type msg_type,
- struct nbt_name *dest_name,
- struct socket_address *dest,
- struct nbt_name *src_name,
- struct nbt_ntlogon_packet *request)
-{
- NTSTATUS status;
- enum ndr_err_code ndr_err;
- DATA_BLOB blob;
- TALLOC_CTX *tmp_ctx = talloc_new(dgmsock);
-
- ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, dgmsock->iconv_convenience,
- request,
- (ndr_push_flags_fn_t)ndr_push_nbt_ntlogon_packet);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- talloc_free(tmp_ctx);
- return ndr_map_error2ntstatus(ndr_err);
- }
-
-
- status = dgram_mailslot_send(dgmsock, msg_type,
- NBT_MAILSLOT_NTLOGON,
- dest_name, dest,
- src_name, &blob);
- talloc_free(tmp_ctx);
- return status;
-}
-
-
-/*
- send a ntlogon mailslot reply
-*/
-NTSTATUS dgram_mailslot_ntlogon_reply(struct nbt_dgram_socket *dgmsock,
- struct nbt_dgram_packet *request,
- const char *my_netbios_name,
- const char *mailslot_name,
- struct nbt_ntlogon_packet *reply)
-{
- NTSTATUS status;
- enum ndr_err_code ndr_err;
- DATA_BLOB blob;
- TALLOC_CTX *tmp_ctx = talloc_new(dgmsock);
- struct nbt_name myname;
- struct socket_address *dest;
-
- ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, dgmsock->iconv_convenience, reply,
- (ndr_push_flags_fn_t)ndr_push_nbt_ntlogon_packet);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- talloc_free(tmp_ctx);
- return ndr_map_error2ntstatus(ndr_err);
- }
-
- make_nbt_name_client(&myname, my_netbios_name);
-
- dest = socket_address_from_strings(tmp_ctx,
- dgmsock->sock->backend_name,
- request->src_addr, request->src_port);
- if (!dest) {
- talloc_free(tmp_ctx);
- return NT_STATUS_NO_MEMORY;
- }
-
- status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE,
- mailslot_name,
- &request->data.msg.source_name,
- dest,
- &myname, &blob);
- talloc_free(tmp_ctx);
- return status;
-}
-
-
-/*
- parse a ntlogon response. The packet must be a valid mailslot packet
-*/
-NTSTATUS dgram_mailslot_ntlogon_parse(struct dgram_mailslot_handler *dgmslot,
- TALLOC_CTX *mem_ctx,
- struct nbt_dgram_packet *dgram,
- struct nbt_ntlogon_packet *ntlogon)
-{
- DATA_BLOB data = dgram_mailslot_data(dgram);
- enum ndr_err_code ndr_err;
-
- ndr_err = ndr_pull_struct_blob(&data, mem_ctx, dgmslot->dgmsock->iconv_convenience, ntlogon,
- (ndr_pull_flags_fn_t)ndr_pull_nbt_ntlogon_packet);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- NTSTATUS status = ndr_map_error2ntstatus(ndr_err);
- DEBUG(0,("Failed to parse ntlogon packet of length %d: %s\n",
- (int)data.length, nt_errstr(status)));
- if (DEBUGLVL(10)) {
- file_save("ntlogon.dat", data.data, data.length);
- }
- return status;
- }
- return NT_STATUS_OK;
-}
diff --git a/source4/libcli/ldap/config.mk b/source4/libcli/ldap/config.mk
index 0c5236c138..02678eed7a 100644
--- a/source4/libcli/ldap/config.mk
+++ b/source4/libcli/ldap/config.mk
@@ -1,17 +1,18 @@
[SUBSYSTEM::LIBCLI_LDAP]
-PRIVATE_PROTO_HEADER = ldap_proto.h
-OBJ_FILES = ldap.o \
- ldap_client.o \
- ldap_bind.o \
- ldap_msg.o \
- ldap_ildap.o \
- ldap_controls.o
PUBLIC_DEPENDENCIES = LIBSAMBA-ERRORS LIBEVENTS LIBPACKET
PRIVATE_DEPENDENCIES = LIBCLI_COMPOSITE samba-socket NDR_SAMR LIBTLS ASN1_UTIL \
LDAP_ENCODE LIBNDR LP_RESOLVE gensec
-PUBLIC_HEADERS += libcli/ldap/ldap.h libcli/ldap/ldap_ndr.h
+LIBCLI_LDAP_OBJ_FILES = $(addprefix $(libclisrcdir)/ldap/, \
+ ldap.o ldap_client.o ldap_bind.o \
+ ldap_msg.o ldap_ildap.o ldap_controls.o)
+
+
+PUBLIC_HEADERS += $(libclisrcdir)/ldap/ldap.h $(libclisrcdir)/ldap/ldap_ndr.h
+
+$(eval $(call proto_header_template,$(libclisrcdir)/ldap/ldap_proto.h,$(LIBCLI_LDAP_OBJ_FILES:.o=.c)))
[SUBSYSTEM::LDAP_ENCODE]
-OBJ_FILES = ldap_ndr.o
# FIXME PRIVATE_DEPENDENCIES = LIBLDB
+
+LDAP_ENCODE_OBJ_FILES = $(libclisrcdir)/ldap/ldap_ndr.o
diff --git a/source4/libcli/ldap/ldap_bind.c b/source4/libcli/ldap/ldap_bind.c
index 2c04edf950..e1569e7296 100644
--- a/source4/libcli/ldap/ldap_bind.c
+++ b/source4/libcli/ldap/ldap_bind.c
@@ -200,7 +200,7 @@ static struct ldap_message *new_ldap_sasl_bind_msg(struct ldap_connection *conn,
/*
perform a sasl bind using the given credentials
*/
-_PUBLIC_ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn,
+_PUBLIC_ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn,
struct cli_credentials *creds,
struct loadparm_context *lp_ctx)
{
@@ -223,7 +223,8 @@ _PUBLIC_ NTSTATUS ldap_bind_sasl(struct ldap_connection *conn,
gensec_init(lp_ctx);
- status = gensec_client_start(conn, &conn->gensec, NULL, lp_ctx);
+ status = gensec_client_start(conn, &conn->gensec,
+ conn->event.event_ctx, lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Failed to start GENSEC engine (%s)\n", nt_errstr(status)));
goto failed;
diff --git a/source4/libcli/ldap/ldap_client.c b/source4/libcli/ldap/ldap_client.c
index 296a7b11f2..bca867b033 100644
--- a/source4/libcli/ldap/ldap_client.c
+++ b/source4/libcli/ldap/ldap_client.c
@@ -48,17 +48,13 @@ _PUBLIC_ struct ldap_connection *ldap4_new_connection(TALLOC_CTX *mem_ctx,
{
struct ldap_connection *conn;
- conn = talloc_zero(mem_ctx, struct ldap_connection);
- if (conn == NULL) {
+ if (ev == NULL) {
return NULL;
}
- if (ev == NULL) {
- ev = event_context_init(conn);
- if (ev == NULL) {
- talloc_free(conn);
- return NULL;
- }
+ conn = talloc_zero(mem_ctx, struct ldap_connection);
+ if (conn == NULL) {
+ return NULL;
}
conn->next_messageid = 1;
diff --git a/source4/libcli/ldap/ldap_ndr.h b/source4/libcli/ldap/ldap_ndr.h
index dfbb723c36..ee1f702c78 100644
--- a/source4/libcli/ldap/ldap_ndr.h
+++ b/source4/libcli/ldap/ldap_ndr.h
@@ -1,6 +1,8 @@
#ifndef __LIBCLI_LDAP_LDAP_NDR_H__
#define __LIBCLI_LDAP_LDAP_NDR_H__
+#include "librpc/gen_ndr/ndr_misc.h"
+
char *ldap_encode_ndr_uint32(TALLOC_CTX *mem_ctx, uint32_t value);
char *ldap_encode_ndr_dom_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
char *ldap_encode_ndr_GUID(TALLOC_CTX *mem_ctx, struct GUID *guid);
diff --git a/source4/libcli/nbt/libnbt.h b/source4/libcli/nbt/libnbt.h
index 14cec3a024..0b01365510 100644
--- a/source4/libcli/nbt/libnbt.h
+++ b/source4/libcli/nbt/libnbt.h
@@ -330,7 +330,7 @@ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
NDR_SCALAR_PROTO(wrepl_nbt_name, const struct nbt_name *)
-NDR_SCALAR_PROTO(nbt_string, const char *);
+NDR_SCALAR_PROTO(nbt_string, const char *)
NDR_BUFFER_PROTO(nbt_name, struct nbt_name)
NTSTATUS nbt_rcode_to_ntstatus(uint8_t rcode);
diff --git a/source4/libcli/nbt/nbtsocket.c b/source4/libcli/nbt/nbtsocket.c
index 747127980a..5d4611e2d9 100644
--- a/source4/libcli/nbt/nbtsocket.c
+++ b/source4/libcli/nbt/nbtsocket.c
@@ -318,11 +318,7 @@ _PUBLIC_ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
nbtsock = talloc(mem_ctx, struct nbt_name_socket);
if (nbtsock == NULL) goto failed;
- if (event_ctx == NULL) {
- nbtsock->event_ctx = event_context_init(nbtsock);
- } else {
- nbtsock->event_ctx = talloc_reference(nbtsock, event_ctx);
- }
+ nbtsock->event_ctx = talloc_reference(nbtsock, event_ctx);
if (nbtsock->event_ctx == NULL) goto failed;
status = socket_create("ip", SOCKET_TYPE_DGRAM, &nbtsock->sock, 0);
diff --git a/source4/libcli/ndr_netlogon.c b/source4/libcli/ndr_netlogon.c
new file mode 100644
index 0000000000..504b3b02a7
--- /dev/null
+++ b/source4/libcli/ndr_netlogon.c
@@ -0,0 +1,209 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ CLDAP server structures
+
+ Copyright (C) Andrew Bartlett <abartlet@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/>.
+*/
+
+/* parser auto-generated by pidl, then hand-modified by abartlet */
+
+#include "includes.h"
+#include "libcli/netlogon.h"
+/* Manually modified to handle the dom_sid being optional based on if it is present or all zero */
+enum ndr_err_code ndr_push_NETLOGON_SAM_LOGON_REQUEST(struct ndr_push *ndr, int ndr_flags, const struct NETLOGON_SAM_LOGON_REQUEST *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->request_count));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->computer_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->user_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->mailslot_name));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_samr_AcctFlags(ndr, NDR_SCALARS, r->acct_control));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_size_dom_sid0(&r->sid, ndr->flags)));
+ if (ndr_size_dom_sid0(&r->sid, ndr->flags)) {
+ struct ndr_push *_ndr_sid;
+ uint32_t _flags_save_DATA_BLOB = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4);
+ NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->_pad));
+ ndr->flags = _flags_save_DATA_BLOB;
+ NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_sid, 0, ndr_size_dom_sid0(&r->sid, ndr->flags)));
+ NDR_CHECK(ndr_push_dom_sid0(_ndr_sid, NDR_SCALARS|NDR_BUFFERS, &r->sid));
+ NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_sid, 0, ndr_size_dom_sid0(&r->sid, ndr->flags)));
+ }
+ NDR_CHECK(ndr_push_netlogon_nt_version_flags(ndr, NDR_SCALARS, r->nt_version));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+/* Manually modified to handle the dom_sid being optional based on if it is present (size is non-zero) or not */
+enum ndr_err_code ndr_pull_NETLOGON_SAM_LOGON_REQUEST(struct ndr_pull *ndr, int ndr_flags, struct NETLOGON_SAM_LOGON_REQUEST *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->request_count));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->computer_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->user_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->mailslot_name));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_pull_samr_AcctFlags(ndr, NDR_SCALARS, &r->acct_control));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sid_size));
+ if (r->sid_size) {
+ uint32_t _flags_save_DATA_BLOB = ndr->flags;
+ struct ndr_pull *_ndr_sid;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_ALIGN4);
+ NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->_pad));
+ ndr->flags = _flags_save_DATA_BLOB;
+ NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_sid, 0, r->sid_size));
+ NDR_CHECK(ndr_pull_dom_sid0(_ndr_sid, NDR_SCALARS|NDR_BUFFERS, &r->sid));
+ NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_sid, 0, r->sid_size));
+ } else {
+ ZERO_STRUCT(r->sid);
+ }
+ NDR_CHECK(ndr_pull_netlogon_nt_version_flags(ndr, NDR_SCALARS, &r->nt_version));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+/* Manually modified to only push some parts of the structure if certain flags are set */
+enum ndr_err_code ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags(struct ndr_push *ndr, int ndr_flags, const struct NETLOGON_SAM_LOGON_RESPONSE_EX *r)
+{
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_netlogon_command(ndr, NDR_SCALARS, r->command));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->sbz));
+ NDR_CHECK(ndr_push_nbt_server_type(ndr, NDR_SCALARS, r->server_type));
+ NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->domain_uuid));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->forest));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->dns_domain));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_dns_name));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->domain));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->pdc_name));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->user_name));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->server_site));
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->client_site));
+ if (r->nt_version & NETLOGON_NT_VERSION_5EX_WITH_IP) {
+ NDR_CHECK(ndr_push_uint8(ndr, NDR_SCALARS, ndr_size_nbt_sockaddr(&r->sockaddr, ndr->flags)));
+ {
+ struct ndr_push *_ndr_sockaddr;
+ NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_sockaddr, 0, ndr_size_nbt_sockaddr(&r->sockaddr, ndr->flags)));
+ NDR_CHECK(ndr_push_nbt_sockaddr(_ndr_sockaddr, NDR_SCALARS|NDR_BUFFERS, &r->sockaddr));
+ NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_sockaddr, 0, ndr_size_nbt_sockaddr(&r->sockaddr, ndr->flags)));
+ }
+ }
+ if (r->nt_version & NETLOGON_NT_VERSION_WITH_CLOSEST_SITE) {
+ NDR_CHECK(ndr_push_nbt_string(ndr, NDR_SCALARS, r->next_closest_site));
+ }
+ NDR_CHECK(ndr_push_netlogon_nt_version_flags(ndr, NDR_SCALARS, r->nt_version));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lmnt_token));
+ NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ NDR_CHECK(ndr_push_GUID(ndr, NDR_BUFFERS, &r->domain_uuid));
+ }
+ ndr->flags = _flags_save_STRUCT;
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+/* Manually modified to only pull some parts of the structure if certain flags provided */
+enum ndr_err_code ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags(struct ndr_pull *ndr, int ndr_flags, struct NETLOGON_SAM_LOGON_RESPONSE_EX *r,
+ uint32_t nt_version_flags)
+{
+ {
+ uint32_t _flags_save_STRUCT = ndr->flags;
+ ZERO_STRUCTP(r);
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_netlogon_command(ndr, NDR_SCALARS, &r->command));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->sbz));
+ NDR_CHECK(ndr_pull_nbt_server_type(ndr, NDR_SCALARS, &r->server_type));
+ NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &r->domain_uuid));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->forest));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->dns_domain));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_dns_name));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->domain));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->pdc_name));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->user_name));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->server_site));
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->client_site));
+ if (nt_version_flags & NETLOGON_NT_VERSION_5EX_WITH_IP) {
+ NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &r->sockaddr_size));
+ {
+ struct ndr_pull *_ndr_sockaddr;
+ NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_sockaddr, 0, r->sockaddr_size));
+ NDR_CHECK(ndr_pull_nbt_sockaddr(_ndr_sockaddr, NDR_SCALARS|NDR_BUFFERS, &r->sockaddr));
+ NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_sockaddr, 0, r->sockaddr_size));
+ }
+ }
+ if (nt_version_flags & NETLOGON_NT_VERSION_WITH_CLOSEST_SITE) {
+ NDR_CHECK(ndr_pull_nbt_string(ndr, NDR_SCALARS, &r->next_closest_site));
+ }
+ NDR_CHECK(ndr_pull_netlogon_nt_version_flags(ndr, NDR_SCALARS, &r->nt_version));
+ if (r->nt_version != nt_version_flags) {
+ return NDR_ERR_VALIDATE;
+ }
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lmnt_token));
+ NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &r->lm20_token));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ NDR_CHECK(ndr_pull_GUID(ndr, NDR_BUFFERS, &r->domain_uuid));
+ }
+ ndr->flags = _flags_save_STRUCT;
+ }
+ return NDR_ERR_SUCCESS;
+}
diff --git a/source4/libcli/netlogon.c b/source4/libcli/netlogon.c
new file mode 100644
index 0000000000..052d7cbc1e
--- /dev/null
+++ b/source4/libcli/netlogon.c
@@ -0,0 +1,239 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ CLDAP server structures
+
+ Copyright (C) Andrew Bartlett <abartlet@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 "libcli/netlogon.h"
+
+NTSTATUS push_netlogon_samlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx,
+ struct smb_iconv_convenience *iconv_convenience,
+ struct netlogon_samlogon_response *response)
+{
+ enum ndr_err_code ndr_err;
+ if (response->ntver == NETLOGON_NT_VERSION_1) {
+ ndr_err = ndr_push_struct_blob(data, mem_ctx,
+ iconv_convenience,
+ &response->nt4,
+ (ndr_push_flags_fn_t)ndr_push_NETLOGON_SAM_LOGON_RESPONSE_NT40);
+ } else if (response->ntver & NETLOGON_NT_VERSION_5EX) {
+ ndr_err = ndr_push_struct_blob(data, mem_ctx,
+ iconv_convenience,
+ &response->nt5_ex,
+ (ndr_push_flags_fn_t)ndr_push_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags);
+ } else if (response->ntver & NETLOGON_NT_VERSION_5) {
+ ndr_err = ndr_push_struct_blob(data, mem_ctx,
+ iconv_convenience,
+ &response->nt5,
+ (ndr_push_flags_fn_t)ndr_push_NETLOGON_SAM_LOGON_RESPONSE);
+ } else {
+ DEBUG(0, ("Asked to push unknown netlogon response type 0x%02x\n", response->ntver));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ DEBUG(2,("failed to push netlogon response of type 0x%02x\n",
+ response->ntver));
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+ return NT_STATUS_OK;
+}
+
+NTSTATUS pull_netlogon_samlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx,
+ struct smb_iconv_convenience *iconv_convenience,
+ struct netlogon_samlogon_response *response)
+{
+ uint32_t ntver;
+ enum ndr_err_code ndr_err;
+
+ if (data->length < 8) {
+ return NT_STATUS_BUFFER_TOO_SMALL;
+ }
+
+ /* lmnttoken */
+ if (SVAL(data->data, data->length - 4) != 0xffff) {
+ return NT_STATUS_INVALID_NETWORK_RESPONSE;
+ }
+ /* lm20token */
+ if (SVAL(data->data, data->length - 2) != 0xffff) {
+ return NT_STATUS_INVALID_NETWORK_RESPONSE;
+ }
+
+ ntver = IVAL(data->data, data->length - 8);
+
+ if (ntver == NETLOGON_NT_VERSION_1) {
+ ndr_err = ndr_pull_struct_blob_all(data, mem_ctx,
+ iconv_convenience,
+ &response->nt4,
+ (ndr_pull_flags_fn_t)ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_NT40);
+ response->ntver = NETLOGON_NT_VERSION_1;
+ } else if (ntver & NETLOGON_NT_VERSION_5EX) {
+ struct ndr_pull *ndr;
+ ndr = ndr_pull_init_blob(data, mem_ctx, iconv_convenience);
+ if (!ndr) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ ndr_err = ndr_pull_NETLOGON_SAM_LOGON_RESPONSE_EX_with_flags(ndr, NDR_SCALARS|NDR_BUFFERS, &response->nt5_ex, ntver);
+ if (ndr->offset < ndr->data_size) {
+ ndr_err = ndr_pull_error(ndr, NDR_ERR_UNREAD_BYTES,
+ "not all bytes consumed ofs[%u] size[%u]",
+ ndr->offset, ndr->data_size);
+ }
+ response->ntver = NETLOGON_NT_VERSION_5EX;
+
+ } else if (ntver & NETLOGON_NT_VERSION_5) {
+ ndr_err = ndr_pull_struct_blob_all(data, mem_ctx,
+ iconv_convenience,
+ &response->nt5,
+ (ndr_pull_flags_fn_t)ndr_pull_NETLOGON_SAM_LOGON_RESPONSE);
+ response->ntver = NETLOGON_NT_VERSION_5;
+ } else {
+ DEBUG(2,("failed to parse netlogon response of type 0x%02x - unknown response type\n",
+ ntver));
+ dump_data(10, data->data, data->length);
+ return NT_STATUS_INVALID_NETWORK_RESPONSE;
+ }
+
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ DEBUG(2,("failed to parse netlogon response of type 0x%02x\n",
+ ntver));
+ dump_data(10, data->data, data->length);
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+ return NT_STATUS_OK;
+}
+
+void map_netlogon_samlogon_response(struct netlogon_samlogon_response *response)
+{
+ struct NETLOGON_SAM_LOGON_RESPONSE_EX response_5_ex;
+ switch (response->ntver) {
+ case NETLOGON_NT_VERSION_5EX:
+ break;
+ case NETLOGON_NT_VERSION_5:
+ ZERO_STRUCT(response_5_ex);
+ response_5_ex.command = response->nt5.command;
+ response_5_ex.pdc_name = response->nt5.pdc_name;
+ response_5_ex.user_name = response->nt5.user_name;
+ response_5_ex.domain = response->nt5.domain_name;
+ response_5_ex.domain_uuid = response->nt5.domain_uuid;
+ response_5_ex.forest = response->nt5.forest;
+ response_5_ex.dns_domain = response->nt5.dns_domain;
+ response_5_ex.pdc_dns_name = response->nt5.pdc_dns_name;
+ response_5_ex.sockaddr.pdc_ip = response->nt5.pdc_ip;
+ response_5_ex.server_type = response->nt5.server_type;
+ response_5_ex.nt_version = response->nt5.nt_version;
+ response_5_ex.lmnt_token = response->nt5.lmnt_token;
+ response_5_ex.lm20_token = response->nt5.lm20_token;
+ response->ntver = NETLOGON_NT_VERSION_5EX;
+ response->nt5_ex = response_5_ex;
+ break;
+
+ case NETLOGON_NT_VERSION_1:
+ ZERO_STRUCT(response_5_ex);
+ response_5_ex.command = response->nt4.command;
+ response_5_ex.pdc_name = response->nt4.server;
+ response_5_ex.user_name = response->nt4.user_name;
+ response_5_ex.domain = response->nt4.domain;
+ response_5_ex.nt_version = response->nt4.nt_version;
+ response_5_ex.lmnt_token = response->nt4.lmnt_token;
+ response_5_ex.lm20_token = response->nt4.lm20_token;
+ response->ntver = NETLOGON_NT_VERSION_5EX;
+ response->nt5_ex = response_5_ex;
+ break;
+ }
+ return;
+}
+
+NTSTATUS push_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx,
+ struct smb_iconv_convenience *iconv_convenience,
+ struct nbt_netlogon_response *response)
+{
+ NTSTATUS status = NT_STATUS_INVALID_NETWORK_RESPONSE;
+ enum ndr_err_code ndr_err;
+ switch (response->response_type) {
+ case NETLOGON_GET_PDC:
+ ndr_err = ndr_push_struct_blob(data, mem_ctx, iconv_convenience, &response->get_pdc,
+ (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_response_from_pdc);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ status = ndr_map_error2ntstatus(ndr_err);
+ DEBUG(0,("Failed to parse netlogon packet of length %d: %s\n",
+ (int)data->length, nt_errstr(status)));
+ if (DEBUGLVL(10)) {
+ file_save("netlogon.dat", data->data, data->length);
+ }
+ return status;
+ }
+ status = NT_STATUS_OK;
+ break;
+ case NETLOGON_SAMLOGON:
+ status = push_netlogon_samlogon_response(data, mem_ctx, iconv_convenience, &response->samlogon);
+ break;
+ }
+ return status;
+}
+
+
+NTSTATUS pull_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx,
+ struct smb_iconv_convenience *iconv_convenience,
+ struct nbt_netlogon_response *response)
+{
+ NTSTATUS status = NT_STATUS_INVALID_NETWORK_RESPONSE;
+ enum netlogon_command command;
+ enum ndr_err_code ndr_err;
+ if (data->length < 4) {
+ return NT_STATUS_INVALID_NETWORK_RESPONSE;
+ }
+
+ command = SVAL(data->data, 0);
+
+ switch (command) {
+ case NETLOGON_RESPONSE_FROM_PDC:
+ ndr_err = ndr_pull_struct_blob_all(data, mem_ctx, iconv_convenience, &response->get_pdc,
+ (ndr_pull_flags_fn_t)ndr_pull_nbt_netlogon_response_from_pdc);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ status = ndr_map_error2ntstatus(ndr_err);
+ DEBUG(0,("Failed to parse netlogon packet of length %d: %s\n",
+ (int)data->length, nt_errstr(status)));
+ if (DEBUGLVL(10)) {
+ file_save("netlogon.dat", data->data, data->length);
+ }
+ return status;
+ }
+ status = NT_STATUS_OK;
+ response->response_type = NETLOGON_GET_PDC;
+ break;
+ case LOGON_SAM_LOGON_RESPONSE:
+ case LOGON_SAM_LOGON_PAUSE_RESPONSE:
+ case LOGON_SAM_LOGON_USER_UNKNOWN:
+ case LOGON_SAM_LOGON_RESPONSE_EX:
+ case LOGON_SAM_LOGON_PAUSE_RESPONSE_EX:
+ case LOGON_SAM_LOGON_USER_UNKNOWN_EX:
+ status = pull_netlogon_samlogon_response(data, mem_ctx, iconv_convenience, &response->samlogon);
+ response->response_type = NETLOGON_SAMLOGON;
+ break;
+
+ /* These levels are queries, not responses */
+ case LOGON_PRIMARY_QUERY:
+ case NETLOGON_ANNOUNCE_UAS:
+ case LOGON_SAM_LOGON_REQUEST:
+ status = NT_STATUS_INVALID_NETWORK_RESPONSE;
+ }
+
+ return status;
+
+}
diff --git a/source4/libcli/netlogon.h b/source4/libcli/netlogon.h
new file mode 100644
index 0000000000..177ed3a514
--- /dev/null
+++ b/source4/libcli/netlogon.h
@@ -0,0 +1,54 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ CLDAP server structures
+
+ Copyright (C) Andrew Bartlett <abartlet@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 __LIBCLI_NETLOGON_H__
+#define __LIBCLI_NETLOGON_H__
+
+#include "librpc/gen_ndr/ndr_nbt.h"
+
+#include "librpc/gen_ndr/ndr_misc.h"
+#include "librpc/gen_ndr/ndr_security.h"
+#include "librpc/gen_ndr/ndr_svcctl.h"
+#include "librpc/gen_ndr/ndr_samr.h"
+
+struct netlogon_samlogon_response
+{
+ uint32_t ntver;
+ union {
+ struct NETLOGON_SAM_LOGON_RESPONSE_NT40 nt4;
+ struct NETLOGON_SAM_LOGON_RESPONSE nt5;
+ struct NETLOGON_SAM_LOGON_RESPONSE_EX nt5_ex;
+ };
+
+};
+
+struct nbt_netlogon_response
+{
+ enum {NETLOGON_GET_PDC, NETLOGON_SAMLOGON} response_type;
+ union {
+ struct nbt_netlogon_response_from_pdc get_pdc;
+ struct netlogon_samlogon_response samlogon;
+ };
+};
+
+#include "libcli/netlogon_proto.h"
+#include "libcli/ndr_netlogon_proto.h"
+#endif /* __CLDAP_SERVER_PROTO_H__ */
diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c
index 1dcf2d1c53..49838e8a1c 100644
--- a/source4/libcli/raw/clisocket.c
+++ b/source4/libcli/raw/clisocket.c
@@ -59,12 +59,7 @@ struct composite_context *smbcli_sock_connect_send(TALLOC_CTX *mem_ctx,
if (result == NULL) goto failed;
result->state = COMPOSITE_STATE_IN_PROGRESS;
- if (event_ctx != NULL) {
- result->event_ctx = talloc_reference(result, event_ctx);
- } else {
- result->event_ctx = event_context_init(result);
- }
-
+ result->event_ctx = talloc_reference(result, event_ctx);
if (result->event_ctx == NULL) goto failed;
state = talloc(result, struct sock_connect_state);
@@ -202,6 +197,11 @@ _PUBLIC_ struct smbcli_socket *smbcli_sock_connect_byname(const char *host, cons
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
struct smbcli_socket *result;
+ if (event_ctx == NULL) {
+ DEBUG(0, ("Invalid NULL event context passed in as parameter\n"));
+ return NULL;
+ }
+
if (tmp_ctx == NULL) {
DEBUG(0, ("talloc_new failed\n"));
return NULL;
@@ -214,16 +214,6 @@ _PUBLIC_ struct smbcli_socket *smbcli_sock_connect_byname(const char *host, cons
return NULL;
}
- if (event_ctx == NULL) {
- event_ctx = event_context_init(mem_ctx);
- }
-
- if (event_ctx == NULL) {
- DEBUG(0, ("event_context_init failed\n"));
- talloc_free(tmp_ctx);
- return NULL;
- }
-
/* allow hostnames of the form NAME#xx and do a netbios lookup */
if ((p = strchr(name, '#'))) {
name_type = strtol(p+1, NULL, 16);
diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c
index d5075f9271..15cd70833c 100644
--- a/source4/libcli/raw/clitree.c
+++ b/source4/libcli/raw/clitree.c
@@ -193,6 +193,11 @@ NTSTATUS smbcli_tree_full_connection(TALLOC_CTX *parent_ctx,
io.in.service_type = service_type;
io.in.credentials = credentials;
io.in.fallback_to_anonymous = false;
+
+ /* This workgroup gets sent out by the SPNEGO session setup.
+ * I don't know of any servers that look at it, so we might
+ * hardcode it to "" some day, when the war on global_loadparm
+ * is complete -- abartlet 2008-04-28 */
io.in.workgroup = lp_workgroup(global_loadparm);
io.in.options = *options;
diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h
index 3965c58204..bae0e67b02 100644
--- a/source4/libcli/raw/interfaces.h
+++ b/source4/libcli/raw/interfaces.h
@@ -684,7 +684,8 @@ union smb_fileinfo {
uint32_t ea_size;
uint32_t access_mask;
uint64_t position;
- uint64_t mode;
+ uint32_t mode;
+ uint32_t alignment_requirement;
struct smb_wire_string fname;
} out;
} all_info2;
@@ -1587,6 +1588,14 @@ union smb_open {
/* optional list of extended attributes */
struct smb_ea_list eas;
+
+ struct smb2_create_blobs {
+ uint32_t num_blobs;
+ struct smb2_create_blob {
+ const char *tag;
+ DATA_BLOB data;
+ } *blobs;
+ } blobs;
} in;
struct {
union smb_handle file;
@@ -1706,19 +1715,27 @@ union smb_read {
/* static body buffer 48 (0x30) bytes */
/* uint16_t buffer_code; 0x31 = 0x30 + 1 */
- uint16_t _pad;
+ uint8_t _pad;
+ uint8_t reserved;
uint32_t length;
uint64_t offset;
/* struct smb2_handle handle; */
- uint64_t unknown1; /* 0x0000000000000000 */
- uint64_t unknown2; /* 0x0000000000000000 */
+ uint32_t min_count;
+ uint32_t channel;
+ uint32_t remaining;
+ /* the docs give no indication of what
+ these channel variables are for */
+ uint16_t channel_offset;
+ uint16_t channel_length;
} in;
struct {
/* static body buffer 16 (0x10) bytes */
/* uint16_t buffer_code; 0x11 = 0x10 + 1 */
- /* uint16_t data_ofs; */
+ /* uint8_t data_ofs; */
+ /* uint8_t reserved; */
/* uint32_t data_size; */
- uint64_t unknown1; /* 0x0000000000000000 */
+ uint32_t remaining;
+ uint32_t reserved;
/* dynamic body */
DATA_BLOB data;
@@ -1846,16 +1863,16 @@ enum smb_lock_level {
RAW_LOCK_LOCK,
RAW_LOCK_UNLOCK,
RAW_LOCK_LOCKX,
- RAW_LOCK_SMB2
+ RAW_LOCK_SMB2,
+ RAW_LOCK_SMB2_BREAK
};
-/* the generic interface is defined to be equal to the lockingX interface */
-#define RAW_LOCK_GENERIC RAW_LOCK_LOCKX
+#define RAW_LOCK_GENERIC RAW_LOCK_LOCKX
/* union for lock() backend call
*/
union smb_lock {
- /* SMBlockingX (and generic) interface */
+ /* SMBlockingX and generic interface */
struct {
enum smb_lock_level level;
struct {
@@ -1870,7 +1887,7 @@ union smb_lock {
uint64_t count;
} *locks; /* unlocks are first in the arrray */
} in;
- } lockx, generic;
+ } generic, lockx;
/* SMBlock and SMBunlock interface */
struct {
@@ -1890,25 +1907,42 @@ union smb_lock {
/* static body buffer 48 (0x30) bytes */
/* uint16_t buffer_code; 0x30 */
- uint16_t unknown1; /* must be 0x0001 */
- uint32_t unknown2;
+ uint16_t lock_count;
+ uint32_t reserved;
/* struct smb2_handle handle; */
- uint64_t offset;
- uint64_t count;
- uint32_t unknown5;
+ struct smb2_lock_element {
+ uint64_t offset;
+ uint64_t length;
+/* these flags are the same as the SMB2 lock flags */
#define SMB2_LOCK_FLAG_NONE 0x00000000
#define SMB2_LOCK_FLAG_SHARED 0x00000001
-#define SMB2_LOCK_FLAG_EXCLUSIV 0x00000002
+#define SMB2_LOCK_FLAG_EXCLUSIVE 0x00000002
#define SMB2_LOCK_FLAG_UNLOCK 0x00000004
-#define SMB2_LOCK_FLAG_NO_PENDING 0x00000010
- uint32_t flags;
+#define SMB2_LOCK_FLAG_FAIL_IMMEDIATELY 0x00000010
+ uint32_t flags;
+ uint32_t reserved;
+ } *locks;
} in;
struct {
/* static body buffer 4 (0x04) bytes */
/* uint16_t buffer_code; 0x04 */
- uint16_t unknown1;
+ uint16_t reserved;
} out;
} smb2;
+
+ /* SMB2 Break */
+ struct smb2_break {
+ enum smb_lock_level level;
+ struct {
+ union smb_handle file;
+
+ /* static body buffer 24 (0x18) bytes */
+ uint8_t oplock_level;
+ uint8_t reserved;
+ uint32_t reserved2;
+ /* struct smb2_handle handle; */
+ } in, out;
+ } smb2_break;
};
@@ -2123,8 +2157,12 @@ union smb_flush {
enum smb_flush_level level;
struct {
union smb_handle file;
- uint32_t unknown;
+ uint16_t reserved1;
+ uint32_t reserved2;
} in;
+ struct {
+ uint16_t reserved;
+ } out;
} smb2;
};
@@ -2323,10 +2361,11 @@ union smb_search_first {
#define SMB2_FIND_ID_BOTH_DIRECTORY_INFO 0x25
#define SMB2_FIND_ID_FULL_DIRECTORY_INFO 0x26
-/* flags for RAW_FILEINFO_SMB2_ALL_EAS */
+/* flags for SMB2 find */
#define SMB2_CONTINUE_FLAG_RESTART 0x01
#define SMB2_CONTINUE_FLAG_SINGLE 0x02
-#define SMB2_CONTINUE_FLAG_NEW 0x10
+#define SMB2_CONTINUE_FLAG_INDEX 0x04
+#define SMB2_CONTINUE_FLAG_REOPEN 0x10
/* SMB2 Find */
struct smb2_find {
@@ -2339,7 +2378,7 @@ union smb_search_first {
/* uint16_t buffer_code; 0x21 = 0x20 + 1 */
uint8_t level;
uint8_t continue_flags; /* SMB2_CONTINUE_FLAG_* */
- uint32_t unknown; /* perhaps a continue token? */
+ uint32_t file_index;
/* struct smb2_handle handle; */
/* uint16_t pattern_ofs; */
/* uint16_t pattern_size; */
diff --git a/source4/libcli/raw/raweas.c b/source4/libcli/raw/raweas.c
index 8ea8e621c9..07b517ade3 100644
--- a/source4/libcli/raw/raweas.c
+++ b/source4/libcli/raw/raweas.c
@@ -54,13 +54,13 @@ static uint_t ea_name_list_size(uint_t num_names, struct ea_name *eas)
This assumes the names are strict ascii, which should be a
reasonable assumption
*/
-size_t ea_list_size_chained(uint_t num_eas, struct ea_struct *eas)
+size_t ea_list_size_chained(uint_t num_eas, struct ea_struct *eas, unsigned alignment)
{
uint_t total = 0;
int i;
for (i=0;i<num_eas;i++) {
uint_t len = 8 + strlen(eas[i].name.s)+1 + eas[i].value.length;
- len = (len + 3) & ~3;
+ len = (len + (alignment-1)) & ~(alignment-1);
total += len;
}
return total;
@@ -96,14 +96,15 @@ void ea_put_list(uint8_t *data, uint_t num_eas, struct ea_struct *eas)
put a chained ea_list into a pre-allocated buffer - buffer must be
at least of size ea_list_size()
*/
-void ea_put_list_chained(uint8_t *data, uint_t num_eas, struct ea_struct *eas)
+void ea_put_list_chained(uint8_t *data, uint_t num_eas, struct ea_struct *eas,
+ unsigned alignment)
{
int i;
for (i=0;i<num_eas;i++) {
uint_t nlen = strlen(eas[i].name.s);
uint32_t len = 8+nlen+1+eas[i].value.length;
- uint_t pad = ((len + 3) & ~3) - len;
+ uint_t pad = ((len + (alignment-1)) & ~(alignment-1)) - len;
if (i == num_eas-1) {
SIVAL(data, 0, 0);
} else {
diff --git a/source4/libcli/raw/rawfile.c b/source4/libcli/raw/rawfile.c
index 3c5c1b742b..d39c61551b 100644
--- a/source4/libcli/raw/rawfile.c
+++ b/source4/libcli/raw/rawfile.c
@@ -314,14 +314,14 @@ static struct smbcli_request *smb_raw_nttrans_create_send(struct smbcli_tree *tr
if (parms->ntcreatex.in.ea_list) {
uint32_t ea_size = ea_list_size_chained(parms->ntcreatex.in.ea_list->num_eas,
- parms->ntcreatex.in.ea_list->eas);
+ parms->ntcreatex.in.ea_list->eas, 4);
ea_blob = data_blob_talloc(mem_ctx, NULL, ea_size);
if (ea_blob.data == NULL) {
return NULL;
}
ea_put_list_chained(ea_blob.data,
parms->ntcreatex.in.ea_list->num_eas,
- parms->ntcreatex.in.ea_list->eas);
+ parms->ntcreatex.in.ea_list->eas, 4);
}
nt.in.params = data_blob_talloc(mem_ctx, NULL, 53);
diff --git a/source4/libcli/raw/rawfileinfo.c b/source4/libcli/raw/rawfileinfo.c
index 71900be49c..0ea5a93606 100644
--- a/source4/libcli/raw/rawfileinfo.c
+++ b/source4/libcli/raw/rawfileinfo.c
@@ -243,7 +243,8 @@ NTSTATUS smb_raw_fileinfo_passthru_parse(const DATA_BLOB *blob, TALLOC_CTX *mem_
parms->all_info2.out.ea_size = IVAL(blob->data, 0x48);
parms->all_info2.out.access_mask = IVAL(blob->data, 0x4C);
parms->all_info2.out.position = BVAL(blob->data, 0x50);
- parms->all_info2.out.mode = BVAL(blob->data, 0x58);
+ parms->all_info2.out.mode = IVAL(blob->data, 0x58);
+ parms->all_info2.out.alignment_requirement = IVAL(blob->data, 0x5C);
smbcli_blob_pull_string(NULL, mem_ctx, blob,
&parms->all_info2.out.fname, 0x60, 0x64, STR_UNICODE);
return NT_STATUS_OK;
diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c
index a42c710547..ef856c6ea1 100644
--- a/source4/libcli/raw/rawrequest.c
+++ b/source4/libcli/raw/rawrequest.c
@@ -700,10 +700,10 @@ DATA_BLOB smbcli_req_pull_blob(struct request_bufinfo *bufinfo, TALLOC_CTX *mem_
static bool smbcli_req_data_oob(struct request_bufinfo *bufinfo, const uint8_t *ptr, uint32_t count)
{
/* be careful with wraparound! */
- if (ptr < bufinfo->data ||
- ptr >= bufinfo->data + bufinfo->data_size ||
+ if ((uintptr_t)ptr < (uintptr_t)bufinfo->data ||
+ (uintptr_t)ptr >= (uintptr_t)bufinfo->data + bufinfo->data_size ||
count > bufinfo->data_size ||
- ptr + count > bufinfo->data + bufinfo->data_size) {
+ (uintptr_t)ptr + count > (uintptr_t)bufinfo->data + bufinfo->data_size) {
return true;
}
return false;
diff --git a/source4/libcli/raw/rawtrans.c b/source4/libcli/raw/rawtrans.c
index 29881afd2b..0f15b2151b 100644
--- a/source4/libcli/raw/rawtrans.c
+++ b/source4/libcli/raw/rawtrans.c
@@ -40,10 +40,10 @@ static bool raw_trans_oob(struct smbcli_request *req,
ptr = req->in.hdr + offset;
/* be careful with wraparound! */
- if (ptr < req->in.data ||
- ptr >= req->in.data + req->in.data_size ||
+ if ((uintptr_t)ptr < (uintptr_t)req->in.data ||
+ (uintptr_t)ptr >= (uintptr_t)req->in.data + req->in.data_size ||
count > req->in.data_size ||
- ptr + count > req->in.data + req->in.data_size) {
+ (uintptr_t)ptr + count > (uintptr_t)req->in.data + req->in.data_size) {
return true;
}
return false;
diff --git a/source4/libcli/raw/smb.h b/source4/libcli/raw/smb.h
index e054ed6522..74869e8a45 100644
--- a/source4/libcli/raw/smb.h
+++ b/source4/libcli/raw/smb.h
@@ -370,6 +370,7 @@
#define FILE_ATTRIBUTE_OFFLINE 0x1000
#define FILE_ATTRIBUTE_NONINDEXED 0x2000
#define FILE_ATTRIBUTE_ENCRYPTED 0x4000
+#define FILE_ATTRIBUTE_ALL_MASK 0x7FFF
/* Flags - combined with attributes. */
#define FILE_FLAG_WRITE_THROUGH 0x80000000L
diff --git a/source4/libcli/resolve/host.c b/source4/libcli/resolve/host.c
index 4b8f3f9553..1a695432ee 100644
--- a/source4/libcli/resolve/host.c
+++ b/source4/libcli/resolve/host.c
@@ -135,7 +135,6 @@ struct composite_context *resolve_name_host_send(TALLOC_CTX *mem_ctx,
c = composite_create(mem_ctx, event_ctx);
if (c == NULL) return NULL;
- c->event_ctx = talloc_reference(c, event_ctx);
if (composite_nomem(c->event_ctx, c)) return c;
state = talloc(c, struct host_state);
diff --git a/source4/libcli/resolve/nbtlist.c b/source4/libcli/resolve/nbtlist.c
index 887bdd7ecf..8f085c5404 100644
--- a/source4/libcli/resolve/nbtlist.c
+++ b/source4/libcli/resolve/nbtlist.c
@@ -110,10 +110,9 @@ struct composite_context *resolve_name_nbtlist_send(TALLOC_CTX *mem_ctx,
struct nbtlist_state *state;
int i;
- c = composite_create(event_ctx, event_ctx);
+ c = composite_create(mem_ctx, event_ctx);
if (c == NULL) return NULL;
- c->event_ctx = talloc_reference(c, event_ctx);
if (composite_nomem(c->event_ctx, c)) return c;
state = talloc(c, struct nbtlist_state);
diff --git a/source4/libcli/resolve/resolve.c b/source4/libcli/resolve/resolve.c
index 33ace09443..d89b50e430 100644
--- a/source4/libcli/resolve/resolve.c
+++ b/source4/libcli/resolve/resolve.c
@@ -136,19 +136,13 @@ struct composite_context *resolve_name_send(struct resolve_context *ctx,
struct composite_context *c;
struct resolve_state *state;
- c = composite_create(event_ctx, event_ctx);
- if (c == NULL) return NULL;
-
- if (ctx == NULL) {
- composite_error(c, NT_STATUS_INVALID_PARAMETER);
- return c;
+ if (ctx == NULL || event_ctx == NULL) {
+ return NULL;
}
- if (event_ctx == NULL) {
- c->event_ctx = event_context_init(c);
- } else {
- c->event_ctx = talloc_reference(c, event_ctx);
- }
+ c = composite_create(ctx, event_ctx);
+ if (c == NULL) return NULL;
+
if (composite_nomem(c->event_ctx, c)) return c;
state = talloc(c, struct resolve_state);
diff --git a/source4/libcli/security/config.mk b/source4/libcli/security/config.mk
index 8c66df0325..f2883d1ede 100644
--- a/source4/libcli/security/config.mk
+++ b/source4/libcli/security/config.mk
@@ -1,13 +1,18 @@
[SUBSYSTEM::LIBSECURITY]
-PRIVATE_PROTO_HEADER = proto.h
-OBJ_FILES = security_token.o \
- security_descriptor.o \
- dom_sid.o \
- access_check.o \
- privilege.o \
- sddl.o
PUBLIC_DEPENDENCIES = NDR_MISC LIBNDR
+LIBSECURITY_OBJ_FILES = $(addprefix $(libclisrcdir)/security/, \
+ security_token.o security_descriptor.o \
+ dom_sid.o access_check.o privilege.o sddl.o)
+
+$(eval $(call proto_header_template,$(libclisrcdir)/security/proto.h,$(LIBSECURITY_OBJ_FILES:.o=.c)))
+
[PYTHON::swig_security]
-SWIG_FILE = security.i
+LIBRARY_REALNAME = samba/_security.$(SHLIBEXT)
PRIVATE_DEPENDENCIES = LIBSECURITY
+
+swig_security_OBJ_FILES = $(libclisrcdir)/security/security_wrap.o
+
+$(eval $(call python_py_module_template,samba/security.py,$(libclisrcdir)/security/security.py))
+
+$(swig_security_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
diff --git a/source4/libcli/security/security.py b/source4/libcli/security/security.py
index 10b263b27b..7e56e22cef 100644
--- a/source4/libcli/security/security.py
+++ b/source4/libcli/security/security.py
@@ -1,5 +1,5 @@
# This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.33
+# Version 1.3.35
#
# Don't modify this file, modify the SWIG interface instead.
diff --git a/source4/libcli/security/security_wrap.c b/source4/libcli/security/security_wrap.c
index eb9e4c45d9..aabf6c27ee 100644
--- a/source4/libcli/security/security_wrap.c
+++ b/source4/libcli/security/security_wrap.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.33
+ * Version 1.3.35
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
@@ -126,7 +126,7 @@
/* This should only be incremented when either the layout of swig_type_info changes,
or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "3"
+#define SWIG_RUNTIME_VERSION "4"
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
#ifdef SWIG_TYPE_TABLE
@@ -161,6 +161,7 @@
/* Flags for pointer conversions */
#define SWIG_POINTER_DISOWN 0x1
+#define SWIG_CAST_NEW_MEMORY 0x2
/* Flags for new pointer objects */
#define SWIG_POINTER_OWN 0x1
@@ -301,10 +302,10 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) {
extern "C" {
#endif
-typedef void *(*swig_converter_func)(void *);
+typedef void *(*swig_converter_func)(void *, int *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);
-/* Structure to store inforomation on one type */
+/* Structure to store information on one type */
typedef struct swig_type_info {
const char *name; /* mangled name of this type */
const char *str; /* human readable name of this type */
@@ -431,8 +432,8 @@ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
Cast a pointer up an inheritance hierarchy
*/
SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
- return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
+SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
}
/*
@@ -856,7 +857,7 @@ SWIG_Python_AddErrorMsg(const char* mesg)
Py_DECREF(old_str);
Py_DECREF(value);
} else {
- PyErr_Format(PyExc_RuntimeError, mesg);
+ PyErr_SetString(PyExc_RuntimeError, mesg);
}
}
@@ -1416,7 +1417,7 @@ PySwigObject_dealloc(PyObject *v)
{
PySwigObject *sobj = (PySwigObject *) v;
PyObject *next = sobj->next;
- if (sobj->own) {
+ if (sobj->own == SWIG_POINTER_OWN) {
swig_type_info *ty = sobj->ty;
PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
PyObject *destroy = data ? data->destroy : 0;
@@ -1434,12 +1435,13 @@ PySwigObject_dealloc(PyObject *v)
res = ((*meth)(mself, v));
}
Py_XDECREF(res);
- } else {
- const char *name = SWIG_TypePrettyName(ty);
+ }
#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
- printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
-#endif
+ else {
+ const char *name = SWIG_TypePrettyName(ty);
+ printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
}
+#endif
}
Py_XDECREF(next);
PyObject_DEL(v);
@@ -1944,7 +1946,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
SWIGRUNTIME int
SWIG_Python_AcquirePtr(PyObject *obj, int own) {
- if (own) {
+ if (own == SWIG_POINTER_OWN) {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
if (sobj) {
int oldown = sobj->own;
@@ -1965,6 +1967,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
return SWIG_OK;
} else {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+ if (own)
+ *own = 0;
while (sobj) {
void *vptr = sobj->ptr;
if (ty) {
@@ -1978,7 +1982,15 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
if (!tc) {
sobj = (PySwigObject *)sobj->next;
} else {
- if (ptr) *ptr = SWIG_TypeCast(tc,vptr);
+ if (ptr) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
+ assert(own);
+ if (own)
+ *own = *own | SWIG_CAST_NEW_MEMORY;
+ }
+ }
break;
}
}
@@ -1988,7 +2000,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
}
}
if (sobj) {
- if (own) *own = sobj->own;
+ if (own)
+ *own = *own | sobj->own;
if (flags & SWIG_POINTER_DISOWN) {
sobj->own = 0;
}
@@ -2053,8 +2066,13 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
}
if (ty) {
swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
- if (!tc) return SWIG_ERROR;
- *ptr = SWIG_TypeCast(tc,vptr);
+ if (tc) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ assert(!newmemory); /* newmemory handling not yet implemented */
+ } else {
+ return SWIG_ERROR;
+ }
} else {
*ptr = vptr;
}
@@ -2503,7 +2521,7 @@ static swig_module_info swig_module = {swig_types, 14, 0, 0, 0, 0};
#define SWIG_name "_security"
-#define SWIGVERSION 0x010333
+#define SWIGVERSION 0x010335
#define SWIG_VERSION SWIGVERSION
@@ -3674,7 +3692,7 @@ SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
- int found;
+ int found, init;
clientdata = clientdata;
@@ -3684,6 +3702,9 @@ SWIG_InitializeModule(void *clientdata) {
swig_module.type_initial = swig_type_initial;
swig_module.cast_initial = swig_cast_initial;
swig_module.next = &swig_module;
+ init = 1;
+ } else {
+ init = 0;
}
/* Try and load any already created modules */
@@ -3712,6 +3733,12 @@ SWIG_InitializeModule(void *clientdata) {
module_head->next = &swig_module;
}
+ /* When multiple interpeters are used, a module could have already been initialized in
+ a different interpreter, but not yet have a pointer in this interpreter.
+ In this case, we do not want to continue adding types... everything should be
+ set up already */
+ if (init == 0) return;
+
/* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: size %d\n", swig_module.size);
diff --git a/source4/libcli/security/tests/bindings.py b/source4/libcli/security/tests/bindings.py
index 59a5e69640..82ce7aeba8 100644
--- a/source4/libcli/security/tests/bindings.py
+++ b/source4/libcli/security/tests/bindings.py
@@ -18,7 +18,7 @@
#
import unittest
-import security
+from samba import security
class SecurityTokenTests(unittest.TestCase):
def setUp(self):
diff --git a/source4/libcli/smb2/break.c b/source4/libcli/smb2/break.c
new file mode 100644
index 0000000000..fe0cceb829
--- /dev/null
+++ b/source4/libcli/smb2/break.c
@@ -0,0 +1,74 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ SMB2 client oplock break handling
+
+ Copyright (C) Stefan Metzmacher 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 "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+
+/*
+ send a break request
+*/
+struct smb2_request *smb2_break_send(struct smb2_tree *tree, struct smb2_break *io)
+{
+ struct smb2_request *req;
+
+ req = smb2_request_init_tree(tree, SMB2_OP_BREAK, 0x18, false, 0);
+ if (req == NULL) return NULL;
+
+ SCVAL(req->out.body, 0x02, io->in.oplock_level);
+ SCVAL(req->out.body, 0x03, io->in.reserved);
+ SIVAL(req->out.body, 0x04, io->in.reserved2);
+ smb2_push_handle(req->out.body+0x08, &io->in.file.handle);
+
+ smb2_transport_send(req);
+
+ return req;
+}
+
+
+/*
+ recv a break reply
+*/
+NTSTATUS smb2_break_recv(struct smb2_request *req, struct smb2_break *io)
+{
+ if (!smb2_request_receive(req) ||
+ !smb2_request_is_ok(req)) {
+ return smb2_request_destroy(req);
+ }
+
+ SMB2_CHECK_PACKET_RECV(req, 0x18, false);
+
+ io->out.oplock_level = CVAL(req->in.body, 0x02);
+ io->out.reserved = CVAL(req->in.body, 0x03);
+ io->out.reserved2 = IVAL(req->in.body, 0x04);
+ smb2_pull_handle(req->in.body+0x08, &io->out.file.handle);
+
+ return smb2_request_destroy(req);
+}
+
+/*
+ sync flush request
+*/
+NTSTATUS smb2_break(struct smb2_tree *tree, struct smb2_break *io)
+{
+ struct smb2_request *req = smb2_break_send(tree, io);
+ return smb2_break_recv(req, io);
+}
diff --git a/source4/libcli/smb2/config.mk b/source4/libcli/smb2/config.mk
index ab079fefde..00b6305def 100644
--- a/source4/libcli/smb2/config.mk
+++ b/source4/libcli/smb2/config.mk
@@ -1,25 +1,10 @@
[SUBSYSTEM::LIBCLI_SMB2]
-PRIVATE_PROTO_HEADER = smb2_proto.h
-OBJ_FILES = \
- transport.o \
- request.o \
- negprot.o \
- session.o \
- tcon.o \
- create.o \
- close.o \
- connect.o \
- getinfo.o \
- write.o \
- read.o \
- setinfo.o \
- find.o \
- ioctl.o \
- logoff.o \
- tdis.o \
- flush.o \
- lock.o \
- notify.o \
- cancel.o \
- keepalive.o
PUBLIC_DEPENDENCIES = LIBCLI_RAW LIBPACKET gensec
+
+LIBCLI_SMB2_OBJ_FILES = $(addprefix $(libclisrcdir)/smb2/, \
+ transport.o request.o negprot.o session.o tcon.o \
+ create.o close.o connect.o getinfo.o write.o read.o \
+ setinfo.o find.o ioctl.o logoff.o tdis.o flush.o \
+ lock.o notify.o cancel.o keepalive.o break.o util.o)
+
+$(eval $(call proto_header_template,$(libclisrcdir)/smb2/smb2_proto.h,$(LIBCLI_SMB2_OBJ_FILES:.o=.c)))
diff --git a/source4/libcli/smb2/connect.c b/source4/libcli/smb2/connect.c
index d68b85ad54..eabfa410ad 100644
--- a/source4/libcli/smb2/connect.c
+++ b/source4/libcli/smb2/connect.c
@@ -44,7 +44,7 @@ struct smb2_connect_state {
*/
static void continue_tcon(struct smb2_request *req)
{
- struct composite_context *c = talloc_get_type(req->async.private,
+ struct composite_context *c = talloc_get_type(req->async.private_data,
struct composite_context);
struct smb2_connect_state *state = talloc_get_type(c->private_data,
struct smb2_connect_state);
@@ -83,7 +83,7 @@ static void continue_session(struct composite_context *creq)
if (composite_nomem(req, c)) return;
req->async.fn = continue_tcon;
- req->async.private = c;
+ req->async.private_data = c;
}
/*
@@ -91,7 +91,7 @@ static void continue_session(struct composite_context *creq)
*/
static void continue_negprot(struct smb2_request *req)
{
- struct composite_context *c = talloc_get_type(req->async.private,
+ struct composite_context *c = talloc_get_type(req->async.private_data,
struct composite_context);
struct smb2_connect_state *state = talloc_get_type(c->private_data,
struct smb2_connect_state);
@@ -101,6 +101,9 @@ static void continue_negprot(struct smb2_request *req)
c->status = smb2_negprot_recv(req, c, &state->negprot);
if (!composite_is_ok(c)) return;
+ transport->negotiate.system_time = state->negprot.out.system_time;
+ transport->negotiate.server_start_time = state->negprot.out.server_start_time;
+
state->session = smb2_session_init(transport, global_loadparm, state, true);
if (composite_nomem(state->session, c)) return;
@@ -121,7 +124,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];
+ uint16_t dialects[2];
c->status = smbcli_sock_connect_recv(creq, state, &sock);
if (!composite_is_ok(c)) return;
@@ -130,18 +133,19 @@ static void continue_socket(struct composite_context *creq)
if (composite_nomem(transport, c)) return;
ZERO_STRUCT(state->negprot);
- state->negprot.in.dialect_count = 1;
+ state->negprot.in.dialect_count = 2;
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;
+ dialects[0] = 0;
+ dialects[1] = SMB2_DIALECT_REVISION;
state->negprot.in.dialects = dialects;
req = smb2_negprot_send(transport, &state->negprot);
if (composite_nomem(req, c)) return;
req->async.fn = continue_negprot;
- req->async.private = c;
+ req->async.private_data = c;
}
diff --git a/source4/libcli/smb2/create.c b/source4/libcli/smb2/create.c
index 999c10ab08..b1b8b0ccfa 100644
--- a/source4/libcli/smb2/create.c
+++ b/source4/libcli/smb2/create.c
@@ -28,30 +28,59 @@
/*
add a blob to a smb2_create attribute blob
*/
-NTSTATUS smb2_create_blob_add(TALLOC_CTX *mem_ctx, DATA_BLOB *blob,
- const char *tag,
- DATA_BLOB add, bool last)
+static NTSTATUS smb2_create_blob_push_one(TALLOC_CTX *mem_ctx, DATA_BLOB *buffer,
+ const struct smb2_create_blob *blob,
+ bool last)
{
- uint32_t ofs = blob->length;
- 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))
+ uint32_t ofs = buffer->length;
+ size_t tag_length = strlen(blob->tag);
+ uint8_t pad = smb2_padding_size(blob->data.length+tag_length, 4);
+
+ if (!data_blob_realloc(mem_ctx, buffer,
+ buffer->length + 0x14 + tag_length + blob->data.length + pad))
return NT_STATUS_NO_MEMORY;
-
+
if (last) {
- SIVAL(blob->data, ofs+0x00, 0);
+ SIVAL(buffer->data, ofs+0x00, 0);
} else {
- SIVAL(blob->data, ofs+0x00, 0x14 + tag_length + add.length + pad);
+ SIVAL(buffer->data, ofs+0x00, 0x14 + tag_length + blob->data.length + pad);
}
- SSVAL(blob->data, ofs+0x04, 0x10); /* offset of tag */
- 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);
- 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);
+ SSVAL(buffer->data, ofs+0x04, 0x10); /* offset of tag */
+ SIVAL(buffer->data, ofs+0x06, tag_length); /* tag length */
+ SSVAL(buffer->data, ofs+0x0A, 0x14 + tag_length); /* offset of data */
+ SIVAL(buffer->data, ofs+0x0C, blob->data.length);
+ memcpy(buffer->data+ofs+0x10, blob->tag, tag_length);
+ SIVAL(buffer->data, ofs+0x10+tag_length, 0); /* pad? */
+ memcpy(buffer->data+ofs+0x14+tag_length, blob->data.data, blob->data.length);
+ memset(buffer->data+ofs+0x14+tag_length+blob->data.length, 0, pad);
+
+ return NT_STATUS_OK;
+}
+
+NTSTATUS smb2_create_blob_add(TALLOC_CTX *mem_ctx, struct smb2_create_blobs *b,
+ const char *tag, DATA_BLOB data)
+{
+ struct smb2_create_blob *array;
+
+ array = talloc_realloc(mem_ctx, b->blobs,
+ struct smb2_create_blob,
+ b->num_blobs + 1);
+ NT_STATUS_HAVE_NO_MEMORY(array);
+ b->blobs = array;
+
+ b->blobs[b->num_blobs].tag = talloc_strdup(b->blobs, tag);
+ NT_STATUS_HAVE_NO_MEMORY(b->blobs[b->num_blobs].tag);
+
+ if (data.data) {
+ b->blobs[b->num_blobs].data = data_blob_talloc(b->blobs,
+ data.data,
+ data.length);
+ NT_STATUS_HAVE_NO_MEMORY(b->blobs[b->num_blobs].data.data);
+ } else {
+ b->blobs[b->num_blobs].data = data_blob(NULL, 0);
+ }
+
+ b->num_blobs += 1;
return NT_STATUS_OK;
}
@@ -64,6 +93,7 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
struct smb2_request *req;
NTSTATUS status;
DATA_BLOB blob = data_blob(NULL, 0);
+ uint32_t i;
req = smb2_request_init_tree(tree, SMB2_OP_CREATE, 0x38, true, 0);
if (req == NULL) return NULL;
@@ -87,9 +117,10 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
if (io->in.eas.num_eas != 0) {
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, SMB2_CREATE_TAG_EXTA, b, false);
+ ea_list_size_chained(io->in.eas.num_eas, io->in.eas.eas, 4));
+ ea_put_list_chained(b.data, io->in.eas.num_eas, io->in.eas.eas, 4);
+ status = smb2_create_blob_add(req, &io->in.blobs,
+ SMB2_CREATE_TAG_EXTA, b);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(req);
return NULL;
@@ -99,13 +130,30 @@ 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, SMB2_CREATE_TAG_MXAC,
- data_blob(NULL, 0), true);
-
+ status = smb2_create_blob_add(req, &io->in.blobs,
+ SMB2_CREATE_TAG_MXAC, data_blob(NULL, 0));
if (!NT_STATUS_IS_OK(status)) {
talloc_free(req);
return NULL;
}
+
+ for (i=0; i < io->in.blobs.num_blobs; i++) {
+ bool last = false;
+ const struct smb2_create_blob *c;
+
+ if ((i + 1) == io->in.blobs.num_blobs) {
+ last = true;
+ }
+
+ c = &io->in.blobs.blobs[i];
+ status = smb2_create_blob_push_one(req, &blob,
+ c, last);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(req);
+ return NULL;
+ }
+ }
+
status = smb2_push_o32s32_blob(&req->out, 0x30, blob);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(req);
diff --git a/source4/libcli/smb2/find.c b/source4/libcli/smb2/find.c
index 6b4902a026..8ebfd81bcd 100644
--- a/source4/libcli/smb2/find.c
+++ b/source4/libcli/smb2/find.c
@@ -38,7 +38,7 @@ struct smb2_request *smb2_find_send(struct smb2_tree *tree, struct smb2_find *io
SCVAL(req->out.body, 0x02, io->in.level);
SCVAL(req->out.body, 0x03, io->in.continue_flags);
- SIVAL(req->out.body, 0x04, io->in.unknown);
+ SIVAL(req->out.body, 0x04, io->in.file_index);
smb2_push_handle(req->out.body+0x08, &io->in.file.handle);
status = smb2_push_o16s16_string(&req->out, 0x18, io->in.pattern);
diff --git a/source4/libcli/smb2/flush.c b/source4/libcli/smb2/flush.c
index 116068ed6e..577d1ba1ba 100644
--- a/source4/libcli/smb2/flush.c
+++ b/source4/libcli/smb2/flush.c
@@ -33,8 +33,8 @@ struct smb2_request *smb2_flush_send(struct smb2_tree *tree, struct smb2_flush *
req = smb2_request_init_tree(tree, SMB2_OP_FLUSH, 0x18, false, 0);
if (req == NULL) return NULL;
- SSVAL(req->out.body, 0x02, 0); /* pad? */
- SIVAL(req->out.body, 0x04, io->in.unknown);
+ SSVAL(req->out.body, 0x02, io->in.reserved1);
+ SIVAL(req->out.body, 0x04, io->in.reserved2);
smb2_push_handle(req->out.body+0x08, &io->in.file.handle);
smb2_transport_send(req);
@@ -55,6 +55,8 @@ NTSTATUS smb2_flush_recv(struct smb2_request *req, struct smb2_flush *io)
SMB2_CHECK_PACKET_RECV(req, 0x04, false);
+ io->out.reserved = SVAL(req->in.body, 0x02);
+
return smb2_request_destroy(req);
}
diff --git a/source4/libcli/smb2/lock.c b/source4/libcli/smb2/lock.c
index d71a337d56..62c6e5dba7 100644
--- a/source4/libcli/smb2/lock.c
+++ b/source4/libcli/smb2/lock.c
@@ -29,17 +29,25 @@
struct smb2_request *smb2_lock_send(struct smb2_tree *tree, struct smb2_lock *io)
{
struct smb2_request *req;
+ int i;
- req = smb2_request_init_tree(tree, SMB2_OP_LOCK, 0x30, false, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_LOCK,
+ 24 + io->in.lock_count*24, false, 0);
if (req == NULL) return NULL;
- SSVAL(req->out.body, 0x02, io->in.unknown1);
- SIVAL(req->out.body, 0x04, io->in.unknown2);
+ /* this is quite bizarre - the spec says we must lie about the length! */
+ SSVAL(req->out.body, 0, 0x30);
+
+ SSVAL(req->out.body, 0x02, io->in.lock_count);
+ SIVAL(req->out.body, 0x04, io->in.reserved);
smb2_push_handle(req->out.body+0x08, &io->in.file.handle);
- SBVAL(req->out.body, 0x18, io->in.offset);
- SBVAL(req->out.body, 0x20, io->in.count);
- SIVAL(req->out.body, 0x24, io->in.unknown5);
- SIVAL(req->out.body, 0x28, io->in.flags);
+
+ for (i=0;i<io->in.lock_count;i++) {
+ SBVAL(req->out.body, 0x18 + i*24, io->in.locks[i].offset);
+ SBVAL(req->out.body, 0x20 + i*24, io->in.locks[i].length);
+ SIVAL(req->out.body, 0x28 + i*24, io->in.locks[i].flags);
+ SIVAL(req->out.body, 0x2C + i*24, io->in.locks[i].reserved);
+ }
smb2_transport_send(req);
@@ -59,7 +67,7 @@ NTSTATUS smb2_lock_recv(struct smb2_request *req, struct smb2_lock *io)
SMB2_CHECK_PACKET_RECV(req, 0x04, false);
- io->out.unknown1 = SVAL(req->in.body, 0x02);
+ io->out.reserved = SVAL(req->in.body, 0x02);
return smb2_request_destroy(req);
}
diff --git a/source4/libcli/smb2/read.c b/source4/libcli/smb2/read.c
index b61f918481..9d40e32a4d 100644
--- a/source4/libcli/smb2/read.c
+++ b/source4/libcli/smb2/read.c
@@ -33,12 +33,16 @@ struct smb2_request *smb2_read_send(struct smb2_tree *tree, struct smb2_read *io
req = smb2_request_init_tree(tree, SMB2_OP_READ, 0x30, true, 0);
if (req == NULL) return NULL;
- SSVAL(req->out.body, 0x02, 0); /* pad */
+ SCVAL(req->out.body, 0x02, 0); /* pad */
+ SCVAL(req->out.body, 0x03, 0); /* reserved */
SIVAL(req->out.body, 0x04, io->in.length);
SBVAL(req->out.body, 0x08, io->in.offset);
smb2_push_handle(req->out.body+0x10, &io->in.file.handle);
- SBVAL(req->out.body, 0x20, io->in.unknown1);
- SBVAL(req->out.body, 0x28, io->in.unknown2);
+ SIVAL(req->out.body, 0x20, io->in.min_count);
+ SIVAL(req->out.body, 0x24, io->in.channel);
+ SIVAL(req->out.body, 0x28, io->in.remaining);
+ SSVAL(req->out.body, 0x2C, io->in.channel_offset);
+ SSVAL(req->out.body, 0x2E, io->in.channel_length);
smb2_transport_send(req);
@@ -67,7 +71,8 @@ NTSTATUS smb2_read_recv(struct smb2_request *req,
return status;
}
- io->out.unknown1 = BVAL(req->in.body, 0x08);
+ io->out.remaining = IVAL(req->in.body, 0x08);
+ io->out.reserved = IVAL(req->in.body, 0x0C);
return smb2_request_destroy(req);
}
diff --git a/source4/libcli/smb2/request.c b/source4/libcli/smb2/request.c
index 2471fcaa4d..64d427f889 100644
--- a/source4/libcli/smb2/request.c
+++ b/source4/libcli/smb2/request.c
@@ -43,6 +43,18 @@ void smb2_setup_bufinfo(struct smb2_request *req)
}
}
+
+/* destroy a request structure */
+static int smb2_request_destructor(struct smb2_request *req)
+{
+ if (req->transport) {
+ /* remove it from the list of pending requests (a null op if
+ its not in the list) */
+ DLIST_REMOVE(req->transport->pending_recv, req);
+ }
+ return 0;
+}
+
/*
initialise a smb2 request
*/
@@ -122,6 +134,8 @@ struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_
SCVAL(req->out.dynamic, 0, 0);
}
+ talloc_set_destructor(req, smb2_request_destructor);
+
return req;
}
@@ -154,18 +168,13 @@ NTSTATUS smb2_request_destroy(struct smb2_request *req)
_send() call fails completely */
if (!req) return NT_STATUS_UNSUCCESSFUL;
- if (req->transport) {
- /* remove it from the list of pending requests (a null op if
- its not in the list) */
- DLIST_REMOVE(req->transport->pending_recv, req);
- }
-
if (req->state == SMB2_REQUEST_ERROR &&
NT_STATUS_IS_OK(req->status)) {
- req->status = NT_STATUS_INTERNAL_ERROR;
+ status = NT_STATUS_INTERNAL_ERROR;
+ } else {
+ status = req->status;
}
- status = req->status;
talloc_free(req);
return status;
}
@@ -211,10 +220,10 @@ bool smb2_oob(struct smb2_request_buffer *buf, const uint8_t *ptr, size_t size)
return false;
}
/* be careful with wraparound! */
- if (ptr < buf->body ||
- ptr >= buf->body + buf->body_size ||
+ if ((uintptr_t)ptr < (uintptr_t)buf->body ||
+ (uintptr_t)ptr >= (uintptr_t)buf->body + buf->body_size ||
size > buf->body_size ||
- ptr + size > buf->body + buf->body_size) {
+ (uintptr_t)ptr + size > (uintptr_t)buf->body + buf->body_size) {
return true;
}
return false;
@@ -669,7 +678,7 @@ NTSTATUS smb2_push_o16s16_string(struct smb2_request_buffer *buf,
}
if (*str == 0) {
- blob.data = str;
+ blob.data = discard_const(str);
blob.length = 0;
return smb2_push_o16s16_blob(buf, ofs, blob);
}
diff --git a/source4/libcli/smb2/session.c b/source4/libcli/smb2/session.c
index 18fe3486a4..29af6652f2 100644
--- a/source4/libcli/smb2/session.c
+++ b/source4/libcli/smb2/session.c
@@ -145,7 +145,7 @@ struct smb2_session_state {
*/
static void session_request_handler(struct smb2_request *req)
{
- struct composite_context *c = talloc_get_type(req->async.private,
+ struct composite_context *c = talloc_get_type(req->async.private_data,
struct composite_context);
struct smb2_session_state *state = talloc_get_type(c->private_data,
struct smb2_session_state);
@@ -178,7 +178,7 @@ static void session_request_handler(struct smb2_request *req)
}
state->req->async.fn = session_request_handler;
- state->req->async.private = c;
+ state->req->async.private_data = c;
return;
}
diff --git a/source4/libcli/smb2/smb2.h b/source4/libcli/smb2/smb2.h
index 726df64090..b55da05e21 100644
--- a/source4/libcli/smb2/smb2.h
+++ b/source4/libcli/smb2/smb2.h
@@ -19,8 +19,13 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifndef __LIBCLI_SMB2_SMB2_H__
+#define __LIBCLI_SMB2_SMB2_H__
+
#include "libcli/raw/request.h"
+struct smb2_handle;
+
struct smb2_options {
uint32_t timeout;
};
@@ -30,6 +35,8 @@ struct smb2_options {
*/
struct smb2_negotiate {
DATA_BLOB secblob;
+ NTTIME system_time;
+ NTTIME server_start_time;
};
/* this is the context for the smb2 transport layer */
@@ -58,6 +65,15 @@ struct smb2_transport {
void *private;
uint_t period;
} idle;
+
+ struct {
+ /* a oplock break request handler */
+ bool (*handler)(struct smb2_transport *transport,
+ const struct smb2_handle *handle,
+ uint8_t level, void *private_data);
+ /* private data passed to the oplock handler */
+ void *private_data;
+ } oplock;
};
@@ -154,7 +170,7 @@ struct smb2_request {
*/
struct {
void (*fn)(struct smb2_request *);
- void *private;
+ void *private_data;
} async;
};
@@ -271,3 +287,5 @@ struct smb2_request {
return NT_STATUS_INVALID_PARAMETER; \
} \
} while (0)
+
+#endif
diff --git a/source4/libcli/smb2/transport.c b/source4/libcli/smb2/transport.c
index af19fcb0a9..8eb60a06f1 100644
--- a/source4/libcli/smb2/transport.c
+++ b/source4/libcli/smb2/transport.c
@@ -140,6 +140,44 @@ void smb2_transport_dead(struct smb2_transport *transport, NTSTATUS status)
}
}
+static bool smb2_handle_oplock_break(struct smb2_transport *transport,
+ const DATA_BLOB *blob)
+{
+ uint8_t *hdr;
+ uint16_t opcode;
+ uint64_t seqnum;
+
+ hdr = blob->data+NBT_HDR_SIZE;
+
+ if (blob->length < (SMB2_MIN_SIZE+0x18)) {
+ DEBUG(1,("Discarding smb2 oplock reply of size %u\n",
+ blob->length));
+ return false;
+ }
+
+ opcode = SVAL(hdr, SMB2_HDR_OPCODE);
+ seqnum = BVAL(hdr, SMB2_HDR_MESSAGE_ID);
+
+ if ((opcode != SMB2_OP_BREAK) ||
+ (seqnum != UINT64_MAX)) {
+ return false;
+ }
+
+ if (transport->oplock.handler) {
+ uint8_t *body = hdr+SMB2_HDR_BODY;
+ struct smb2_handle h;
+ uint8_t level;
+
+ level = CVAL(body, 0x02);
+ smb2_pull_handle(body+0x08, &h);
+
+ transport->oplock.handler(transport, &h, level,
+ transport->oplock.private_data);
+ }
+
+ return true;
+}
+
/*
we have a full request in our receive buffer - match it to a pending request
and process
@@ -167,6 +205,11 @@ static NTSTATUS smb2_transport_finish_recv(void *private, DATA_BLOB blob)
goto error;
}
+ if (smb2_handle_oplock_break(transport, &blob)) {
+ talloc_free(buffer);
+ return NT_STATUS_OK;
+ }
+
flags = IVAL(hdr, SMB2_HDR_FLAGS);
seqnum = BVAL(hdr, SMB2_HDR_MESSAGE_ID);
diff --git a/source4/libcli/smb2/util.c b/source4/libcli/smb2/util.c
new file mode 100644
index 0000000000..9eb344e83f
--- /dev/null
+++ b/source4/libcli/smb2/util.c
@@ -0,0 +1,200 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ SMB2 client utility functions
+
+ Copyright (C) Andrew Tridgell 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 "libcli/raw/libcliraw.h"
+#include "libcli/raw/raw_proto.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+#include "libcli/smb_composite/smb_composite.h"
+
+/*
+ simple close wrapper with SMB2
+*/
+NTSTATUS smb2_util_close(struct smb2_tree *tree, struct smb2_handle h)
+{
+ struct smb2_close c;
+
+ ZERO_STRUCT(c);
+ c.in.file.handle = h;
+
+ return smb2_close(tree, &c);
+}
+
+/*
+ unlink a file with SMB2
+*/
+NTSTATUS smb2_util_unlink(struct smb2_tree *tree, const char *fname)
+{
+ union smb_unlink io;
+
+ ZERO_STRUCT(io);
+ io.unlink.in.pattern = fname;
+
+ return smb2_composite_unlink(tree, &io);
+}
+
+
+/*
+ rmdir with SMB2
+*/
+NTSTATUS smb2_util_rmdir(struct smb2_tree *tree, const char *dname)
+{
+ struct smb_rmdir io;
+
+ ZERO_STRUCT(io);
+ io.in.path = dname;
+
+ return smb2_composite_rmdir(tree, &io);
+}
+
+
+/*
+ mkdir with SMB2
+*/
+NTSTATUS smb2_util_mkdir(struct smb2_tree *tree, const char *dname)
+{
+ union smb_mkdir io;
+
+ ZERO_STRUCT(io);
+ io.mkdir.level = RAW_MKDIR_MKDIR;
+ io.mkdir.in.path = dname;
+
+ return smb2_composite_mkdir(tree, &io);
+}
+
+
+/*
+ set file attribute with SMB2
+*/
+NTSTATUS smb2_util_setatr(struct smb2_tree *tree, const char *name, uint32_t attrib)
+{
+ union smb_setfileinfo io;
+
+ ZERO_STRUCT(io);
+ io.basic_info.level = RAW_SFILEINFO_BASIC_INFORMATION;
+ io.basic_info.in.file.path = name;
+ io.basic_info.in.attrib = attrib;
+
+ return smb2_composite_setpathinfo(tree, &io);
+}
+
+
+
+
+/*
+ recursively descend a tree deleting all files
+ returns the number of files deleted, or -1 on error
+*/
+int smb2_deltree(struct smb2_tree *tree, const char *dname)
+{
+ NTSTATUS status;
+ uint32_t total_deleted = 0;
+ uint_t count, i;
+ union smb_search_data *list;
+ TALLOC_CTX *tmp_ctx = talloc_new(tree);
+ struct smb2_find f;
+ struct smb2_create create_parm;
+
+ /* it might be a file */
+ status = smb2_util_unlink(tree, dname);
+ if (NT_STATUS_IS_OK(status)) {
+ talloc_free(tmp_ctx);
+ return 1;
+ }
+ if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND) ||
+ NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_PATH_NOT_FOUND) ||
+ NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_FILE)) {
+ talloc_free(tmp_ctx);
+ return 0;
+ }
+
+ ZERO_STRUCT(create_parm);
+ create_parm.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
+ create_parm.in.share_access =
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE;
+ create_parm.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+ create_parm.in.create_disposition = NTCREATEX_DISP_OPEN;
+ create_parm.in.fname = dname;
+
+ status = smb2_create(tree, tmp_ctx, &create_parm);
+ if (NT_STATUS_IS_ERR(status)) {
+ DEBUG(2,("Failed to open %s - %s\n", dname, nt_errstr(status)));
+ talloc_free(tmp_ctx);
+ return -1;
+ }
+
+
+ ZERO_STRUCT(f);
+ f.in.file.handle = create_parm.out.file.handle;
+ f.in.max_response_size = 0x10000;
+ f.in.level = SMB2_FIND_NAME_INFO;
+ f.in.pattern = "*";
+
+ status = smb2_find_level(tree, tmp_ctx, &f, &count, &list);
+ if (NT_STATUS_IS_ERR(status)) {
+ DEBUG(2,("Failed to list %s - %s\n",
+ dname, nt_errstr(status)));
+ smb2_util_close(tree, create_parm.out.file.handle);
+ talloc_free(tmp_ctx);
+ return -1;
+ }
+
+ for (i=0;i<count;i++) {
+ char *name;
+ if (strcmp(".", list[i].name_info.name.s) == 0 ||
+ strcmp("..", list[i].name_info.name.s) == 0) {
+ continue;
+ }
+ name = talloc_asprintf(tmp_ctx, "%s\\%s", dname, list[i].name_info.name.s);
+ status = smb2_util_unlink(tree, name);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) {
+ /* it could be read-only */
+ status = smb2_util_setatr(tree, name, FILE_ATTRIBUTE_NORMAL);
+ status = smb2_util_unlink(tree, name);
+ }
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_FILE_IS_A_DIRECTORY)) {
+ int ret;
+ ret = smb2_deltree(tree, name);
+ if (ret > 0) total_deleted += ret;
+ }
+ talloc_free(name);
+ if (NT_STATUS_IS_OK(status)) {
+ total_deleted++;
+ }
+ }
+
+ smb2_util_close(tree, create_parm.out.file.handle);
+
+ status = smb2_util_rmdir(tree, dname);
+ if (NT_STATUS_IS_ERR(status)) {
+ DEBUG(2,("Failed to delete %s - %s\n",
+ dname, nt_errstr(status)));
+ talloc_free(tmp_ctx);
+ return -1;
+ }
+
+ talloc_free(tmp_ctx);
+
+ return total_deleted;
+}
diff --git a/source4/libcli/smb_composite/connect.c b/source4/libcli/smb_composite/connect.c
index c44c62f868..e56339f96b 100644
--- a/source4/libcli/smb_composite/connect.c
+++ b/source4/libcli/smb_composite/connect.c
@@ -38,7 +38,9 @@ enum connect_stage {CONNECT_RESOLVE,
CONNECT_NEGPROT,
CONNECT_SESSION_SETUP,
CONNECT_SESSION_SETUP_ANON,
- CONNECT_TCON};
+ CONNECT_TCON,
+ CONNECT_DONE
+};
struct connect_state {
enum connect_stage stage;
@@ -57,25 +59,6 @@ static void request_handler(struct smbcli_request *);
static void composite_handler(struct composite_context *);
/*
- setup a negprot send
-*/
-static NTSTATUS connect_send_negprot(struct composite_context *c,
- struct smb_composite_connect *io)
-{
- struct connect_state *state = talloc_get_type(c->private_data, struct connect_state);
-
- state->req = smb_raw_negotiate_send(state->transport, io->in.options.unicode, io->in.options.max_protocol);
- NT_STATUS_HAVE_NO_MEMORY(state->req);
-
- state->req->async.fn = request_handler;
- state->req->async.private = c;
- state->stage = CONNECT_NEGPROT;
-
- return NT_STATUS_OK;
-}
-
-
-/*
a tree connect request has completed
*/
static NTSTATUS connect_tcon(struct composite_context *c,
@@ -97,8 +80,7 @@ static NTSTATUS connect_tcon(struct composite_context *c,
state->io_tcon->tconx.out.fs_type);
}
- /* all done! */
- c->state = COMPOSITE_STATE_DONE;
+ state->stage = CONNECT_DONE;
return NT_STATUS_OK;
}
@@ -121,9 +103,6 @@ static NTSTATUS connect_session_setup_anon(struct composite_context *c,
state->session->vuid = state->io_setup->out.vuid;
/* setup for a tconx */
- io->out.tree = smbcli_tree_init(state->session, state, true);
- NT_STATUS_HAVE_NO_MEMORY(io->out.tree);
-
state->io_tcon = talloc(c, union smb_tcon);
NT_STATUS_HAVE_NO_MEMORY(state->io_tcon);
@@ -203,9 +182,12 @@ static NTSTATUS connect_session_setup(struct composite_context *c,
state->session->vuid = state->io_setup->out.vuid;
- /* setup for a tconx */
- io->out.tree = smbcli_tree_init(state->session, state, true);
- NT_STATUS_HAVE_NO_MEMORY(io->out.tree);
+ /* If we don't have a remote share name then this indicates that
+ * we don't want to do a tree connect */
+ if (!io->in.service) {
+ state->stage = CONNECT_DONE;
+ return NT_STATUS_OK;
+ }
state->io_tcon = talloc(c, union smb_tcon);
NT_STATUS_HAVE_NO_MEMORY(state->io_tcon);
@@ -254,6 +236,18 @@ static NTSTATUS connect_negprot(struct composite_context *c,
/* next step is a session setup */
state->session = smbcli_session_init(state->transport, state, true);
NT_STATUS_HAVE_NO_MEMORY(state->session);
+
+ /* setup for a tconx (or at least have the structure ready to
+ * return, if we won't go that far) */
+ io->out.tree = smbcli_tree_init(state->session, state, true);
+ NT_STATUS_HAVE_NO_MEMORY(io->out.tree);
+
+ /* If we don't have any credentials then this indicates that
+ * we don't want to do a session setup */
+ if (!io->in.credentials) {
+ state->stage = CONNECT_DONE;
+ return NT_STATUS_OK;
+ }
state->io_setup = talloc(c, struct smb_composite_sesssetup);
NT_STATUS_HAVE_NO_MEMORY(state->io_setup);
@@ -272,11 +266,30 @@ static NTSTATUS connect_negprot(struct composite_context *c,
state->creq->async.fn = composite_handler;
state->creq->async.private_data = c;
+
state->stage = CONNECT_SESSION_SETUP;
return NT_STATUS_OK;
}
+/*
+ setup a negprot send
+*/
+static NTSTATUS connect_send_negprot(struct composite_context *c,
+ struct smb_composite_connect *io)
+{
+ struct connect_state *state = talloc_get_type(c->private_data, struct connect_state);
+
+ state->req = smb_raw_negotiate_send(state->transport, io->in.options.unicode, io->in.options.max_protocol);
+ NT_STATUS_HAVE_NO_MEMORY(state->req);
+
+ state->req->async.fn = request_handler;
+ state->req->async.private = c;
+ state->stage = CONNECT_NEGPROT;
+
+ return NT_STATUS_OK;
+}
+
/*
a session request operation has completed
@@ -405,13 +418,11 @@ static void state_handler(struct composite_context *c)
break;
}
- if (!NT_STATUS_IS_OK(c->status)) {
- c->state = COMPOSITE_STATE_ERROR;
- }
-
- if (c->state >= COMPOSITE_STATE_DONE &&
- c->async.fn) {
- c->async.fn(c);
+ if (state->stage == CONNECT_DONE) {
+ /* all done! */
+ composite_done(c);
+ } else {
+ composite_is_ok(c);
}
}
@@ -451,17 +462,15 @@ struct composite_context *smb_composite_connect_send(struct smb_composite_connec
c = talloc_zero(mem_ctx, struct composite_context);
if (c == NULL) goto failed;
+ c->event_ctx = talloc_reference(c, event_ctx);
+ if (c->event_ctx == NULL) goto failed;
+
state = talloc_zero(c, struct connect_state);
if (state == NULL) goto failed;
- if (event_ctx == NULL) {
- event_ctx = event_context_init(mem_ctx);
- }
-
state->io = io;
c->state = COMPOSITE_STATE_IN_PROGRESS;
- c->event_ctx = talloc_reference(c, event_ctx);
c->private_data = state;
state->stage = CONNECT_RESOLVE;
diff --git a/source4/libcli/smb_composite/fetchfile.c b/source4/libcli/smb_composite/fetchfile.c
index d8d7481270..9cd02a51f4 100644
--- a/source4/libcli/smb_composite/fetchfile.c
+++ b/source4/libcli/smb_composite/fetchfile.c
@@ -62,7 +62,6 @@ static NTSTATUS fetchfile_connect(struct composite_context *c,
state->creq->async.fn = fetchfile_composite_handler;
state->stage = FETCHFILE_READ;
- c->event_ctx = talloc_reference(c, state->creq->event_ctx);
return NT_STATUS_OK;
}
@@ -158,7 +157,6 @@ struct composite_context *smb_composite_fetchfile_send(struct smb_composite_fetc
c->state = COMPOSITE_STATE_IN_PROGRESS;
state->stage = FETCHFILE_CONNECT;
- c->event_ctx = talloc_reference(c, state->creq->event_ctx);
c->private_data = state;
return c;
diff --git a/source4/libcli/smb_composite/fsinfo.c b/source4/libcli/smb_composite/fsinfo.c
index 2ec13df9b6..270d71f518 100644
--- a/source4/libcli/smb_composite/fsinfo.c
+++ b/source4/libcli/smb_composite/fsinfo.c
@@ -52,7 +52,6 @@ static NTSTATUS fsinfo_connect(struct composite_context *c,
state->req->async.fn = fsinfo_raw_handler;
state->stage = FSINFO_QUERY;
- c->event_ctx = talloc_reference(c, state->req->session->transport->socket->event.ctx);
return NT_STATUS_OK;
}
@@ -158,7 +157,6 @@ struct composite_context *smb_composite_fsinfo_send(struct smbcli_tree *tree,
c->state = COMPOSITE_STATE_IN_PROGRESS;
state->stage = FSINFO_CONNECT;
- c->event_ctx = talloc_reference(c, tree->session->transport->socket->event.ctx);
c->private_data = state;
state->creq = smb_composite_connect_send(state->connect, state,
diff --git a/source4/libcli/smb_composite/sesssetup.c b/source4/libcli/smb_composite/sesssetup.c
index 1427fe525b..11ac37e257 100644
--- a/source4/libcli/smb_composite/sesssetup.c
+++ b/source4/libcli/smb_composite/sesssetup.c
@@ -224,7 +224,6 @@ static NTSTATUS session_setup_nt1(struct composite_context *c,
{
NTSTATUS nt_status;
struct sesssetup_state *state = talloc_get_type(c->private_data, struct sesssetup_state);
- const char *password = cli_credentials_get_password(io->in.credentials);
DATA_BLOB names_blob = NTLMv2_generate_names_blob(state, lp_iconv_convenience(global_loadparm), session->transport->socket->hostname, lp_workgroup(global_loadparm));
DATA_BLOB session_key;
int flags = CLI_CRED_NTLM_AUTH;
@@ -266,6 +265,7 @@ static NTSTATUS session_setup_nt1(struct composite_context *c,
data_blob_free(&session_key);
} else if (session->options.plaintext_auth) {
+ const char *password = cli_credentials_get_password(io->in.credentials);
state->setup.nt1.in.password1 = data_blob_talloc(state, password, strlen(password));
state->setup.nt1.in.password2 = data_blob(NULL, 0);
} else {
diff --git a/source4/libcli/smb_composite/smb2.c b/source4/libcli/smb_composite/smb2.c
new file mode 100644
index 0000000000..6e005e03c0
--- /dev/null
+++ b/source4/libcli/smb_composite/smb2.c
@@ -0,0 +1,371 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Copyright (C) Andrew Tridgell 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/>.
+*/
+/*
+ a composite API for making SMB-like calls using SMB2. This is useful
+ as SMB2 often requires more than one requests where a single SMB
+ request would do. In converting code that uses SMB to use SMB2,
+ these routines make life a lot easier
+*/
+
+
+#include "includes.h"
+#include "libcli/raw/libcliraw.h"
+#include "libcli/raw/raw_proto.h"
+#include "libcli/composite/composite.h"
+#include "libcli/smb_composite/smb_composite.h"
+#include "param/param.h"
+#include "libcli/smb2/smb2_calls.h"
+
+/*
+ continue after a SMB2 close
+ */
+static void continue_close(struct smb2_request *req)
+{
+ struct composite_context *ctx = talloc_get_type(req->async.private_data,
+ struct composite_context);
+ NTSTATUS status;
+ struct smb2_close close_parm;
+
+ status = smb2_close_recv(req, &close_parm);
+ composite_error(ctx, status);
+}
+
+/*
+ continue after the create in a composite unlink
+ */
+static void continue_unlink(struct smb2_request *req)
+{
+ struct composite_context *ctx = talloc_get_type(req->async.private_data,
+ struct composite_context);
+ struct smb2_tree *tree = req->tree;
+ struct smb2_create create_parm;
+ struct smb2_close close_parm;
+ NTSTATUS status;
+
+ status = smb2_create_recv(req, ctx, &create_parm);
+ if (!NT_STATUS_IS_OK(status)) {
+ composite_error(ctx, status);
+ return;
+ }
+
+ ZERO_STRUCT(close_parm);
+ close_parm.in.file.handle = create_parm.out.file.handle;
+
+ req = smb2_close_send(tree, &close_parm);
+ composite_continue_smb2(ctx, req, continue_close, ctx);
+}
+
+/*
+ composite SMB2 unlink call
+*/
+struct composite_context *smb2_composite_unlink_send(struct smb2_tree *tree,
+ union smb_unlink *io)
+{
+ struct composite_context *ctx;
+ struct smb2_create create_parm;
+ struct smb2_request *req;
+
+ ctx = composite_create(tree, tree->session->transport->socket->event.ctx);
+ if (ctx == NULL) return NULL;
+
+ /* check for wildcards - we could support these with a
+ search, but for now they aren't necessary */
+ if (strpbrk(io->unlink.in.pattern, "*?<>") != NULL) {
+ composite_error(ctx, NT_STATUS_NOT_SUPPORTED);
+ return ctx;
+ }
+
+ ZERO_STRUCT(create_parm);
+ create_parm.in.desired_access = SEC_STD_DELETE;
+ create_parm.in.create_disposition = NTCREATEX_DISP_OPEN;
+ create_parm.in.share_access =
+ NTCREATEX_SHARE_ACCESS_DELETE|
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE;
+ create_parm.in.create_options =
+ NTCREATEX_OPTIONS_DELETE_ON_CLOSE |
+ NTCREATEX_OPTIONS_NON_DIRECTORY_FILE;
+ create_parm.in.fname = io->unlink.in.pattern;
+ if (create_parm.in.fname[0] == '\\') {
+ create_parm.in.fname++;
+ }
+
+ req = smb2_create_send(tree, &create_parm);
+
+ composite_continue_smb2(ctx, req, continue_unlink, ctx);
+ return ctx;
+}
+
+
+/*
+ composite unlink call - sync interface
+*/
+NTSTATUS smb2_composite_unlink(struct smb2_tree *tree, union smb_unlink *io)
+{
+ struct composite_context *c = smb2_composite_unlink_send(tree, io);
+ return composite_wait_free(c);
+}
+
+
+
+
+/*
+ continue after the create in a composite mkdir
+ */
+static void continue_mkdir(struct smb2_request *req)
+{
+ struct composite_context *ctx = talloc_get_type(req->async.private_data,
+ struct composite_context);
+ struct smb2_tree *tree = req->tree;
+ struct smb2_create create_parm;
+ struct smb2_close close_parm;
+ NTSTATUS status;
+
+ status = smb2_create_recv(req, ctx, &create_parm);
+ if (!NT_STATUS_IS_OK(status)) {
+ composite_error(ctx, status);
+ return;
+ }
+
+ ZERO_STRUCT(close_parm);
+ close_parm.in.file.handle = create_parm.out.file.handle;
+
+ req = smb2_close_send(tree, &close_parm);
+ composite_continue_smb2(ctx, req, continue_close, ctx);
+}
+
+/*
+ composite SMB2 mkdir call
+*/
+struct composite_context *smb2_composite_mkdir_send(struct smb2_tree *tree,
+ union smb_mkdir *io)
+{
+ struct composite_context *ctx;
+ struct smb2_create create_parm;
+ struct smb2_request *req;
+
+ ctx = composite_create(tree, tree->session->transport->socket->event.ctx);
+ if (ctx == NULL) return NULL;
+
+ ZERO_STRUCT(create_parm);
+
+ create_parm.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
+ create_parm.in.share_access =
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE;
+ create_parm.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+ create_parm.in.file_attributes = FILE_ATTRIBUTE_DIRECTORY;
+ create_parm.in.create_disposition = NTCREATEX_DISP_CREATE;
+ create_parm.in.fname = io->mkdir.in.path;
+ if (create_parm.in.fname[0] == '\\') {
+ create_parm.in.fname++;
+ }
+
+ req = smb2_create_send(tree, &create_parm);
+
+ composite_continue_smb2(ctx, req, continue_mkdir, ctx);
+
+ return ctx;
+}
+
+
+/*
+ composite mkdir call - sync interface
+*/
+NTSTATUS smb2_composite_mkdir(struct smb2_tree *tree, union smb_mkdir *io)
+{
+ struct composite_context *c = smb2_composite_mkdir_send(tree, io);
+ return composite_wait_free(c);
+}
+
+
+
+/*
+ continue after the create in a composite rmdir
+ */
+static void continue_rmdir(struct smb2_request *req)
+{
+ struct composite_context *ctx = talloc_get_type(req->async.private_data,
+ struct composite_context);
+ struct smb2_tree *tree = req->tree;
+ struct smb2_create create_parm;
+ struct smb2_close close_parm;
+ NTSTATUS status;
+
+ status = smb2_create_recv(req, ctx, &create_parm);
+ if (!NT_STATUS_IS_OK(status)) {
+ composite_error(ctx, status);
+ return;
+ }
+
+ ZERO_STRUCT(close_parm);
+ close_parm.in.file.handle = create_parm.out.file.handle;
+
+ req = smb2_close_send(tree, &close_parm);
+ composite_continue_smb2(ctx, req, continue_close, ctx);
+}
+
+/*
+ composite SMB2 rmdir call
+*/
+struct composite_context *smb2_composite_rmdir_send(struct smb2_tree *tree,
+ struct smb_rmdir *io)
+{
+ struct composite_context *ctx;
+ struct smb2_create create_parm;
+ struct smb2_request *req;
+
+ ctx = composite_create(tree, tree->session->transport->socket->event.ctx);
+ if (ctx == NULL) return NULL;
+
+ ZERO_STRUCT(create_parm);
+ create_parm.in.desired_access = SEC_STD_DELETE;
+ create_parm.in.create_disposition = NTCREATEX_DISP_OPEN;
+ create_parm.in.share_access =
+ NTCREATEX_SHARE_ACCESS_DELETE|
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE;
+ create_parm.in.create_options =
+ NTCREATEX_OPTIONS_DIRECTORY |
+ NTCREATEX_OPTIONS_DELETE_ON_CLOSE;
+ create_parm.in.fname = io->in.path;
+ if (create_parm.in.fname[0] == '\\') {
+ create_parm.in.fname++;
+ }
+
+ req = smb2_create_send(tree, &create_parm);
+
+ composite_continue_smb2(ctx, req, continue_rmdir, ctx);
+ return ctx;
+}
+
+
+/*
+ composite rmdir call - sync interface
+*/
+NTSTATUS smb2_composite_rmdir(struct smb2_tree *tree, struct smb_rmdir *io)
+{
+ struct composite_context *c = smb2_composite_rmdir_send(tree, io);
+ return composite_wait_free(c);
+}
+
+
+/*
+ continue after the setfileinfo in a composite setpathinfo
+ */
+static void continue_setpathinfo_close(struct smb2_request *req)
+{
+ struct composite_context *ctx = talloc_get_type(req->async.private_data,
+ struct composite_context);
+ struct smb2_tree *tree = req->tree;
+ struct smb2_close close_parm;
+ NTSTATUS status;
+ union smb_setfileinfo *io2 = talloc_get_type(ctx->private_data,
+ union smb_setfileinfo);
+
+ status = smb2_setinfo_recv(req);
+ if (!NT_STATUS_IS_OK(status)) {
+ composite_error(ctx, status);
+ return;
+ }
+
+ ZERO_STRUCT(close_parm);
+ close_parm.in.file.handle = io2->generic.in.file.handle;
+
+ req = smb2_close_send(tree, &close_parm);
+ composite_continue_smb2(ctx, req, continue_close, ctx);
+}
+
+
+/*
+ continue after the create in a composite setpathinfo
+ */
+static void continue_setpathinfo(struct smb2_request *req)
+{
+ struct composite_context *ctx = talloc_get_type(req->async.private_data,
+ struct composite_context);
+ struct smb2_tree *tree = req->tree;
+ struct smb2_create create_parm;
+ NTSTATUS status;
+ union smb_setfileinfo *io2 = talloc_get_type(ctx->private_data,
+ union smb_setfileinfo);
+
+ status = smb2_create_recv(req, ctx, &create_parm);
+ if (!NT_STATUS_IS_OK(status)) {
+ composite_error(ctx, status);
+ return;
+ }
+
+ io2->generic.in.file.handle = create_parm.out.file.handle;
+
+ req = smb2_setinfo_file_send(tree, io2);
+ composite_continue_smb2(ctx, req, continue_setpathinfo_close, ctx);
+}
+
+
+/*
+ composite SMB2 setpathinfo call
+*/
+struct composite_context *smb2_composite_setpathinfo_send(struct smb2_tree *tree,
+ union smb_setfileinfo *io)
+{
+ struct composite_context *ctx;
+ struct smb2_create create_parm;
+ struct smb2_request *req;
+ union smb_setfileinfo *io2;
+
+ ctx = composite_create(tree, tree->session->transport->socket->event.ctx);
+ if (ctx == NULL) return NULL;
+
+ ZERO_STRUCT(create_parm);
+ create_parm.in.desired_access = SEC_FLAG_MAXIMUM_ALLOWED;
+ create_parm.in.create_disposition = NTCREATEX_DISP_OPEN;
+ create_parm.in.share_access =
+ NTCREATEX_SHARE_ACCESS_DELETE|
+ NTCREATEX_SHARE_ACCESS_READ|
+ NTCREATEX_SHARE_ACCESS_WRITE;
+ create_parm.in.create_options = 0;
+ create_parm.in.fname = io->generic.in.file.path;
+ if (create_parm.in.fname[0] == '\\') {
+ create_parm.in.fname++;
+ }
+
+ req = smb2_create_send(tree, &create_parm);
+
+ io2 = talloc(ctx, union smb_setfileinfo);
+ if (composite_nomem(io2, ctx)) {
+ return ctx;
+ }
+ *io2 = *io;
+
+ ctx->private_data = io2;
+
+ composite_continue_smb2(ctx, req, continue_setpathinfo, ctx);
+ return ctx;
+}
+
+
+/*
+ composite setpathinfo call
+ */
+NTSTATUS smb2_composite_setpathinfo(struct smb2_tree *tree, union smb_setfileinfo *io)
+{
+ struct composite_context *c = smb2_composite_setpathinfo_send(tree, io);
+ return composite_wait_free(c);
+}
diff --git a/source4/libcli/smb_composite/smb_composite.h b/source4/libcli/smb_composite/smb_composite.h
index e7e131869c..7f4b9d73e4 100644
--- a/source4/libcli/smb_composite/smb_composite.h
+++ b/source4/libcli/smb_composite/smb_composite.h
@@ -29,6 +29,7 @@
#include "libcli/raw/signing.h"
#include "libcli/raw/libcliraw.h"
+#include "libcli/smb2/smb2.h"
/*
@@ -83,8 +84,8 @@ struct smb_composite_savefile {
- socket establishment
- session request
- negprot
- - session setup
- - tree connect
+ - session setup (if credentials are not NULL)
+ - tree connect (if service is not NULL)
*/
struct smb_composite_connect {
struct {
diff --git a/source4/libcli/swig/libcli_nbt.py b/source4/libcli/swig/libcli_nbt.py
index b49e240bc2..a26aa6092e 100644
--- a/source4/libcli/swig/libcli_nbt.py
+++ b/source4/libcli/swig/libcli_nbt.py
@@ -1,5 +1,5 @@
# This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.33
+# Version 1.3.35
#
# Don't modify this file, modify the SWIG interface instead.
diff --git a/source4/libcli/swig/libcli_nbt_wrap.c b/source4/libcli/swig/libcli_nbt_wrap.c
index e0bdb27cfc..2deec98cb5 100644
--- a/source4/libcli/swig/libcli_nbt_wrap.c
+++ b/source4/libcli/swig/libcli_nbt_wrap.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.33
+ * Version 1.3.35
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
@@ -126,7 +126,7 @@
/* This should only be incremented when either the layout of swig_type_info changes,
or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "3"
+#define SWIG_RUNTIME_VERSION "4"
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
#ifdef SWIG_TYPE_TABLE
@@ -161,6 +161,7 @@
/* Flags for pointer conversions */
#define SWIG_POINTER_DISOWN 0x1
+#define SWIG_CAST_NEW_MEMORY 0x2
/* Flags for new pointer objects */
#define SWIG_POINTER_OWN 0x1
@@ -301,10 +302,10 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) {
extern "C" {
#endif
-typedef void *(*swig_converter_func)(void *);
+typedef void *(*swig_converter_func)(void *, int *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);
-/* Structure to store inforomation on one type */
+/* Structure to store information on one type */
typedef struct swig_type_info {
const char *name; /* mangled name of this type */
const char *str; /* human readable name of this type */
@@ -431,8 +432,8 @@ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
Cast a pointer up an inheritance hierarchy
*/
SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
- return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
+SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
}
/*
@@ -856,7 +857,7 @@ SWIG_Python_AddErrorMsg(const char* mesg)
Py_DECREF(old_str);
Py_DECREF(value);
} else {
- PyErr_Format(PyExc_RuntimeError, mesg);
+ PyErr_SetString(PyExc_RuntimeError, mesg);
}
}
@@ -1416,7 +1417,7 @@ PySwigObject_dealloc(PyObject *v)
{
PySwigObject *sobj = (PySwigObject *) v;
PyObject *next = sobj->next;
- if (sobj->own) {
+ if (sobj->own == SWIG_POINTER_OWN) {
swig_type_info *ty = sobj->ty;
PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
PyObject *destroy = data ? data->destroy : 0;
@@ -1434,12 +1435,13 @@ PySwigObject_dealloc(PyObject *v)
res = ((*meth)(mself, v));
}
Py_XDECREF(res);
- } else {
- const char *name = SWIG_TypePrettyName(ty);
+ }
#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
- printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
-#endif
+ else {
+ const char *name = SWIG_TypePrettyName(ty);
+ printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
}
+#endif
}
Py_XDECREF(next);
PyObject_DEL(v);
@@ -1944,7 +1946,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
SWIGRUNTIME int
SWIG_Python_AcquirePtr(PyObject *obj, int own) {
- if (own) {
+ if (own == SWIG_POINTER_OWN) {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
if (sobj) {
int oldown = sobj->own;
@@ -1965,6 +1967,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
return SWIG_OK;
} else {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+ if (own)
+ *own = 0;
while (sobj) {
void *vptr = sobj->ptr;
if (ty) {
@@ -1978,7 +1982,15 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
if (!tc) {
sobj = (PySwigObject *)sobj->next;
} else {
- if (ptr) *ptr = SWIG_TypeCast(tc,vptr);
+ if (ptr) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
+ assert(own);
+ if (own)
+ *own = *own | SWIG_CAST_NEW_MEMORY;
+ }
+ }
break;
}
}
@@ -1988,7 +2000,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
}
}
if (sobj) {
- if (own) *own = sobj->own;
+ if (own)
+ *own = *own | sobj->own;
if (flags & SWIG_POINTER_DISOWN) {
sobj->own = 0;
}
@@ -2053,8 +2066,13 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
}
if (ty) {
swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
- if (!tc) return SWIG_ERROR;
- *ptr = SWIG_TypeCast(tc,vptr);
+ if (tc) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ assert(!newmemory); /* newmemory handling not yet implemented */
+ } else {
+ return SWIG_ERROR;
+ }
} else {
*ptr = vptr;
}
@@ -2507,7 +2525,7 @@ static swig_module_info swig_module = {swig_types, 18, 0, 0, 0, 0};
#define SWIG_name "_libcli_nbt"
-#define SWIGVERSION 0x010333
+#define SWIGVERSION 0x010335
#define SWIG_VERSION SWIGVERSION
@@ -3134,7 +3152,7 @@ SWIGINTERN PyObject *_wrap_new_nbt_name(PyObject *SWIGUNUSEDPARM(self), PyObject
struct nbt_name *result = 0 ;
if (!SWIG_Python_UnpackTuple(args,"new_nbt_name",0,0,0)) SWIG_fail;
- result = (struct nbt_name *)(struct nbt_name *) calloc(1, sizeof(struct nbt_name));
+ result = (struct nbt_name *)calloc(1, sizeof(struct nbt_name));
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_nbt_name, SWIG_POINTER_NEW | 0 );
return resultobj;
fail:
@@ -3227,7 +3245,7 @@ SWIGINTERN PyObject *_wrap_new_nbt_name_query(PyObject *SWIGUNUSEDPARM(self), Py
struct nbt_name_query *result = 0 ;
if (!SWIG_Python_UnpackTuple(args,"new_nbt_name_query",0,0,0)) SWIG_fail;
- result = (struct nbt_name_query *)(struct nbt_name_query *) calloc(1, sizeof(struct nbt_name_query));
+ result = (struct nbt_name_query *)calloc(1, sizeof(struct nbt_name_query));
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_nbt_name_query, SWIG_POINTER_NEW | 0 );
return resultobj;
fail:
@@ -3493,7 +3511,7 @@ SWIGINTERN PyObject *_wrap_new_nbt_name_query_out(PyObject *SWIGUNUSEDPARM(self)
nbt_name_query_out *result = 0 ;
if (!SWIG_Python_UnpackTuple(args,"new_nbt_name_query_out",0,0,0)) SWIG_fail;
- result = (nbt_name_query_out *)(nbt_name_query_out *) calloc(1, sizeof(nbt_name_query_out));
+ result = (nbt_name_query_out *)calloc(1, sizeof(nbt_name_query_out));
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_nbt_name_query_out, SWIG_POINTER_NEW | 0 );
return resultobj;
fail:
@@ -3865,7 +3883,7 @@ SWIGINTERN PyObject *_wrap_new_nbt_name_query_in(PyObject *SWIGUNUSEDPARM(self),
nbt_name_query_in *result = 0 ;
if (!SWIG_Python_UnpackTuple(args,"new_nbt_name_query_in",0,0,0)) SWIG_fail;
- result = (nbt_name_query_in *)(nbt_name_query_in *) calloc(1, sizeof(nbt_name_query_in));
+ result = (nbt_name_query_in *)calloc(1, sizeof(nbt_name_query_in));
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_nbt_name_query_in, SWIG_POINTER_NEW | 0 );
return resultobj;
fail:
@@ -4280,7 +4298,7 @@ SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
- int found;
+ int found, init;
clientdata = clientdata;
@@ -4290,6 +4308,9 @@ SWIG_InitializeModule(void *clientdata) {
swig_module.type_initial = swig_type_initial;
swig_module.cast_initial = swig_cast_initial;
swig_module.next = &swig_module;
+ init = 1;
+ } else {
+ init = 0;
}
/* Try and load any already created modules */
@@ -4318,6 +4339,12 @@ SWIG_InitializeModule(void *clientdata) {
module_head->next = &swig_module;
}
+ /* When multiple interpeters are used, a module could have already been initialized in
+ a different interpreter, but not yet have a pointer in this interpreter.
+ In this case, we do not want to continue adding types... everything should be
+ set up already */
+ if (init == 0) return;
+
/* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: size %d\n", swig_module.size);
diff --git a/source4/libcli/swig/libcli_smb.py b/source4/libcli/swig/libcli_smb.py
index 80c4040237..6e4fe036c7 100644
--- a/source4/libcli/swig/libcli_smb.py
+++ b/source4/libcli/swig/libcli_smb.py
@@ -1,5 +1,5 @@
# This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.33
+# Version 1.3.35
#
# Don't modify this file, modify the SWIG interface instead.
diff --git a/source4/libcli/swig/libcli_smb_wrap.c b/source4/libcli/swig/libcli_smb_wrap.c
index 8b71f2c3be..de8e6ba1e4 100644
--- a/source4/libcli/swig/libcli_smb_wrap.c
+++ b/source4/libcli/swig/libcli_smb_wrap.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.33
+ * Version 1.3.35
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
@@ -126,7 +126,7 @@
/* This should only be incremented when either the layout of swig_type_info changes,
or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "3"
+#define SWIG_RUNTIME_VERSION "4"
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
#ifdef SWIG_TYPE_TABLE
@@ -161,6 +161,7 @@
/* Flags for pointer conversions */
#define SWIG_POINTER_DISOWN 0x1
+#define SWIG_CAST_NEW_MEMORY 0x2
/* Flags for new pointer objects */
#define SWIG_POINTER_OWN 0x1
@@ -301,10 +302,10 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) {
extern "C" {
#endif
-typedef void *(*swig_converter_func)(void *);
+typedef void *(*swig_converter_func)(void *, int *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);
-/* Structure to store inforomation on one type */
+/* Structure to store information on one type */
typedef struct swig_type_info {
const char *name; /* mangled name of this type */
const char *str; /* human readable name of this type */
@@ -431,8 +432,8 @@ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
Cast a pointer up an inheritance hierarchy
*/
SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
- return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
+SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
}
/*
@@ -856,7 +857,7 @@ SWIG_Python_AddErrorMsg(const char* mesg)
Py_DECREF(old_str);
Py_DECREF(value);
} else {
- PyErr_Format(PyExc_RuntimeError, mesg);
+ PyErr_SetString(PyExc_RuntimeError, mesg);
}
}
@@ -1416,7 +1417,7 @@ PySwigObject_dealloc(PyObject *v)
{
PySwigObject *sobj = (PySwigObject *) v;
PyObject *next = sobj->next;
- if (sobj->own) {
+ if (sobj->own == SWIG_POINTER_OWN) {
swig_type_info *ty = sobj->ty;
PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
PyObject *destroy = data ? data->destroy : 0;
@@ -1434,12 +1435,13 @@ PySwigObject_dealloc(PyObject *v)
res = ((*meth)(mself, v));
}
Py_XDECREF(res);
- } else {
- const char *name = SWIG_TypePrettyName(ty);
+ }
#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
- printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
-#endif
+ else {
+ const char *name = SWIG_TypePrettyName(ty);
+ printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
}
+#endif
}
Py_XDECREF(next);
PyObject_DEL(v);
@@ -1944,7 +1946,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
SWIGRUNTIME int
SWIG_Python_AcquirePtr(PyObject *obj, int own) {
- if (own) {
+ if (own == SWIG_POINTER_OWN) {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
if (sobj) {
int oldown = sobj->own;
@@ -1965,6 +1967,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
return SWIG_OK;
} else {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+ if (own)
+ *own = 0;
while (sobj) {
void *vptr = sobj->ptr;
if (ty) {
@@ -1978,7 +1982,15 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
if (!tc) {
sobj = (PySwigObject *)sobj->next;
} else {
- if (ptr) *ptr = SWIG_TypeCast(tc,vptr);
+ if (ptr) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
+ assert(own);
+ if (own)
+ *own = *own | SWIG_CAST_NEW_MEMORY;
+ }
+ }
break;
}
}
@@ -1988,7 +2000,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
}
}
if (sobj) {
- if (own) *own = sobj->own;
+ if (own)
+ *own = *own | sobj->own;
if (flags & SWIG_POINTER_DISOWN) {
sobj->own = 0;
}
@@ -2053,8 +2066,13 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
}
if (ty) {
swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
- if (!tc) return SWIG_ERROR;
- *ptr = SWIG_TypeCast(tc,vptr);
+ if (tc) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ assert(!newmemory); /* newmemory handling not yet implemented */
+ } else {
+ return SWIG_ERROR;
+ }
} else {
*ptr = vptr;
}
@@ -2495,7 +2513,7 @@ static swig_module_info swig_module = {swig_types, 6, 0, 0, 0, 0};
#define SWIG_name "_libcli_smb"
-#define SWIGVERSION 0x010333
+#define SWIGVERSION 0x010335
#define SWIG_VERSION SWIGVERSION
@@ -2769,7 +2787,7 @@ SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
- int found;
+ int found, init;
clientdata = clientdata;
@@ -2779,6 +2797,9 @@ SWIG_InitializeModule(void *clientdata) {
swig_module.type_initial = swig_type_initial;
swig_module.cast_initial = swig_cast_initial;
swig_module.next = &swig_module;
+ init = 1;
+ } else {
+ init = 0;
}
/* Try and load any already created modules */
@@ -2807,6 +2828,12 @@ SWIG_InitializeModule(void *clientdata) {
module_head->next = &swig_module;
}
+ /* When multiple interpeters are used, a module could have already been initialized in
+ a different interpreter, but not yet have a pointer in this interpreter.
+ In this case, we do not want to continue adding types... everything should be
+ set up already */
+ if (init == 0) return;
+
/* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: size %d\n", swig_module.size);
diff --git a/source4/libcli/wbclient/config.mk b/source4/libcli/wbclient/config.mk
index 9384a172ff..00df5dbb22 100644
--- a/source4/libcli/wbclient/config.mk
+++ b/source4/libcli/wbclient/config.mk
@@ -1,4 +1,5 @@
[SUBSYSTEM::LIBWBCLIENT]
-OBJ_FILES = wbclient.o
PUBLIC_DEPENDENCIES = LIBSAMBA-ERRORS LIBEVENTS
PRIVATE_DEPENDENCIES = NDR_WINBIND MESSAGING
+
+LIBWBCLIENT_OBJ_FILES = $(libclisrcdir)/wbclient/wbclient.o
diff --git a/source4/libcli/wrepl/winsrepl.c b/source4/libcli/wrepl/winsrepl.c
index 3e7793c0c7..0a4e52bd7b 100644
--- a/source4/libcli/wrepl/winsrepl.c
+++ b/source4/libcli/wrepl/winsrepl.c
@@ -172,11 +172,7 @@ struct wrepl_socket *wrepl_socket_init(TALLOC_CTX *mem_ctx,
wrepl_socket = talloc_zero(mem_ctx, struct wrepl_socket);
if (!wrepl_socket) return NULL;
- if (event_ctx == NULL) {
- wrepl_socket->event.ctx = event_context_init(wrepl_socket);
- } else {
- wrepl_socket->event.ctx = talloc_reference(wrepl_socket, event_ctx);
- }
+ wrepl_socket->event.ctx = talloc_reference(wrepl_socket, event_ctx);
if (!wrepl_socket->event.ctx) goto failed;
wrepl_socket->iconv_convenience = iconv_convenience;
diff --git a/source4/libnet/config.mk b/source4/libnet/config.mk
index 00af6b37f2..fac8af18b7 100644
--- a/source4/libnet/config.mk
+++ b/source4/libnet/config.mk
@@ -1,36 +1,18 @@
[SUBSYSTEM::LIBSAMBA-NET]
-PRIVATE_PROTO_HEADER = libnet_proto.h
-OBJ_FILES = \
- libnet.o \
- libnet_passwd.o \
- libnet_time.o \
- libnet_rpc.o \
- libnet_join.o \
- libnet_site.o \
- libnet_become_dc.o \
- libnet_unbecome_dc.o \
- libnet_vampire.o \
- libnet_samdump.o \
- libnet_samdump_keytab.o \
- libnet_samsync_ldb.o \
- libnet_user.o \
- libnet_group.o \
- libnet_share.o \
- libnet_lookup.o \
- libnet_domain.o \
- userinfo.o \
- groupinfo.o \
- 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 LIBCLI_CLDAP LIBCLI_FINDDCS gensec_schannel LIBCLI_AUTH LIBNDR SMBPASSWD
+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 PROVISION
-#PUBLIC_HEADERS += $(addprefix libnet/, libnet.h libnet_join.h libnet_lookup.h libnet_passwd.h \
-# libnet_rpc.h libnet_share.h libnet_time.h \
-# libnet_user.h libnet_site.h libnet_vampire.h \
-# userinfo.h userman.h)
+LIBSAMBA-NET_OBJ_FILES = $(addprefix $(libnetsrcdir)/, \
+ libnet.o libnet_passwd.o libnet_time.o libnet_rpc.o \
+ libnet_join.o libnet_site.o libnet_become_dc.o libnet_unbecome_dc.o \
+ libnet_vampire.o libnet_samdump.o libnet_samdump_keytab.o \
+ libnet_samsync_ldb.o libnet_user.o libnet_group.o libnet_share.o \
+ libnet_lookup.o libnet_domain.o userinfo.o groupinfo.o userman.o \
+ groupman.o prereq_domain.o libnet_samsync.o)
+$(eval $(call proto_header_template,$(libnetsrcdir)/libnet_proto.h,$(LIBSAMBA-NET_OBJ_FILES:.o=.c)))
-[PYTHON::swig_net]
+[PYTHON::python_net]
+LIBRARY_REALNAME = samba/net.$(SHLIBEXT)
PRIVATE_DEPENDENCIES = LIBSAMBA-NET
-SWIG_FILE = net.i
+
+python_net_OBJ_FILES = $(libnetsrcdir)/py_net.o
diff --git a/source4/libnet/libnet.c b/source4/libnet/libnet.c
index d1605bc17d..c966898cee 100644
--- a/source4/libnet/libnet.c
+++ b/source4/libnet/libnet.c
@@ -28,20 +28,17 @@ struct libnet_context *libnet_context_init(struct event_context *ev,
{
struct libnet_context *ctx;
+ /* We require an event context here */
+ if (!ev) {
+ return NULL;
+ }
+
/* create brand new libnet context */
ctx = talloc(ev, struct libnet_context);
if (!ctx) {
return NULL;
}
- /* events */
- if (ev == NULL) {
- ev = event_context_find(ctx);
- if (ev == NULL) {
- talloc_free(ctx);
- return NULL;
- }
- }
ctx->event_ctx = ev;
ctx->lp_ctx = lp_ctx;
diff --git a/source4/libnet/libnet.h b/source4/libnet/libnet.h
index 015661a074..b65a13ce37 100644
--- a/source4/libnet/libnet.h
+++ b/source4/libnet/libnet.h
@@ -68,6 +68,7 @@ struct libnet_context {
#include "libnet/libnet_site.h"
#include "libnet/libnet_become_dc.h"
#include "libnet/libnet_unbecome_dc.h"
+#include "libnet/libnet_samsync.h"
#include "libnet/libnet_vampire.h"
#include "libnet/libnet_user.h"
#include "libnet/libnet_group.h"
diff --git a/source4/libnet/libnet_become_dc.c b/source4/libnet/libnet_become_dc.c
index c4f9cabb11..1c4c1d0732 100644
--- a/source4/libnet/libnet_become_dc.c
+++ b/source4/libnet/libnet_become_dc.c
@@ -30,6 +30,7 @@
#include "libcli/security/security.h"
#include "librpc/gen_ndr/ndr_misc.h"
#include "librpc/gen_ndr/ndr_security.h"
+#include "librpc/gen_ndr/ndr_nbt.h"
#include "librpc/gen_ndr/ndr_drsuapi.h"
#include "auth/gensec/gensec.h"
#include "param/param.h"
@@ -687,7 +688,7 @@ struct libnet_BecomeDC_state {
struct {
struct cldap_socket *sock;
struct cldap_netlogon io;
- struct nbt_cldap_netlogon_5 netlogon5;
+ struct NETLOGON_SAM_LOGON_RESPONSE_EX netlogon;
} cldap;
struct becomeDC_ldap {
@@ -745,7 +746,8 @@ static void becomeDC_send_cldap(struct libnet_BecomeDC_state *s)
s->cldap.io.in.domain_guid = NULL;
s->cldap.io.in.domain_sid = NULL;
s->cldap.io.in.acct_control = -1;
- s->cldap.io.in.version = 6;
+ s->cldap.io.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX;
+ s->cldap.io.in.map_response = true;
s->cldap.sock = cldap_socket_init(s, s->libnet->event_ctx,
lp_iconv_convenience(s->libnet->lp_ctx));
@@ -768,19 +770,19 @@ static void becomeDC_recv_cldap(struct cldap_request *req)
c->status = cldap_netlogon_recv(req, s, &s->cldap.io);
if (!composite_is_ok(c)) return;
- s->cldap.netlogon5 = s->cldap.io.out.netlogon.logon5;
+ s->cldap.netlogon = s->cldap.io.out.netlogon.nt5_ex;
- s->domain.dns_name = s->cldap.netlogon5.dns_domain;
- s->domain.netbios_name = s->cldap.netlogon5.domain;
- s->domain.guid = s->cldap.netlogon5.domain_uuid;
+ s->domain.dns_name = s->cldap.netlogon.dns_domain;
+ s->domain.netbios_name = s->cldap.netlogon.domain;
+ s->domain.guid = s->cldap.netlogon.domain_uuid;
- s->forest.dns_name = s->cldap.netlogon5.forest;
+ s->forest.dns_name = s->cldap.netlogon.forest;
- s->source_dsa.dns_name = s->cldap.netlogon5.pdc_dns_name;
- s->source_dsa.netbios_name = s->cldap.netlogon5.pdc_name;
- s->source_dsa.site_name = s->cldap.netlogon5.server_site;
+ s->source_dsa.dns_name = s->cldap.netlogon.pdc_dns_name;
+ s->source_dsa.netbios_name = s->cldap.netlogon.pdc_name;
+ s->source_dsa.site_name = s->cldap.netlogon.server_site;
- s->dest_dsa.site_name = s->cldap.netlogon5.client_site;
+ s->dest_dsa.site_name = s->cldap.netlogon.client_site;
becomeDC_connect_ldap1(s);
}
@@ -793,7 +795,7 @@ static NTSTATUS becomeDC_ldap_connect(struct libnet_BecomeDC_state *s,
url = talloc_asprintf(s, "ldap://%s/", s->source_dsa.dns_name);
NT_STATUS_HAVE_NO_MEMORY(url);
- ldap->ldb = ldb_wrap_connect(s, s->libnet->lp_ctx, url,
+ ldap->ldb = ldb_wrap_connect(s, s->libnet->event_ctx, s->libnet->lp_ctx, url,
NULL,
s->libnet->cred,
0, NULL);
diff --git a/source4/libnet/libnet_join.c b/source4/libnet/libnet_join.c
index 22134518d6..b5b28df81d 100644
--- a/source4/libnet/libnet_join.c
+++ b/source4/libnet/libnet_join.c
@@ -230,7 +230,7 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
return NT_STATUS_NO_MEMORY;
}
- remote_ldb = ldb_wrap_connect(tmp_ctx, ctx->lp_ctx,
+ remote_ldb = ldb_wrap_connect(tmp_ctx, ctx->event_ctx, ctx->lp_ctx,
remote_ldb_url,
NULL, ctx->cred, 0, NULL);
if (!remote_ldb) {
@@ -839,13 +839,11 @@ NTSTATUS libnet_JoinDomain(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, stru
return status;
}
-static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
- TALLOC_CTX *mem_ctx,
- struct libnet_Join *r)
+NTSTATUS libnet_set_join_secrets(struct libnet_context *ctx,
+ TALLOC_CTX *mem_ctx,
+ struct libnet_set_join_secrets *r)
{
- NTSTATUS status;
TALLOC_CTX *tmp_mem;
- struct libnet_JoinDomain *r2;
int ret, rtn;
struct ldb_context *ldb;
struct ldb_dn *base_dn;
@@ -860,56 +858,13 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
"privateKeytab",
NULL
};
- uint32_t acct_type = 0;
- const char *account_name;
- const char *netbios_name;
-
- r->out.error_string = NULL;
tmp_mem = talloc_new(mem_ctx);
if (!tmp_mem) {
return NT_STATUS_NO_MEMORY;
}
- r2 = talloc(tmp_mem, struct libnet_JoinDomain);
- if (!r2) {
- r->out.error_string = NULL;
- talloc_free(tmp_mem);
- return NT_STATUS_NO_MEMORY;
- }
-
- if (r->in.join_type == SEC_CHAN_BDC) {
- acct_type = ACB_SVRTRUST;
- } else if (r->in.join_type == SEC_CHAN_WKSTA) {
- acct_type = ACB_WSTRUST;
- } else {
- r->out.error_string = NULL;
- talloc_free(tmp_mem);
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- if (r->in.netbios_name != NULL) {
- netbios_name = r->in.netbios_name;
- } else {
- netbios_name = talloc_reference(tmp_mem, lp_netbios_name(ctx->lp_ctx));
- if (!netbios_name) {
- r->out.error_string = NULL;
- talloc_free(tmp_mem);
- return NT_STATUS_NO_MEMORY;
- }
- }
-
- account_name = talloc_asprintf(tmp_mem, "%s$", netbios_name);
- if (!account_name) {
- r->out.error_string = NULL;
- talloc_free(tmp_mem);
- return NT_STATUS_NO_MEMORY;
- }
-
- /*
- * Local secrets are stored in secrets.ldb
- * open it to make sure we can write the info into it after the join
- */
+ /* Open the secrets database */
ldb = secrets_db_connect(tmp_mem, ctx->lp_ctx);
if (!ldb) {
r->out.error_string
@@ -920,23 +875,6 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
}
/*
- * join the domain
- */
- ZERO_STRUCTP(r2);
- r2->in.domain_name = r->in.domain_name;
- r2->in.account_name = account_name;
- r2->in.netbios_name = netbios_name;
- r2->in.level = LIBNET_JOINDOMAIN_AUTOMATIC;
- r2->in.acct_type = acct_type;
- r2->in.recreate_account = false;
- status = libnet_JoinDomain(ctx, r2, r2);
- if (!NT_STATUS_IS_OK(status)) {
- r->out.error_string = talloc_steal(mem_ctx, r2->out.error_string);
- talloc_free(tmp_mem);
- return status;
- }
-
- /*
* now prepare the record for secrets.ldb
*/
sct = talloc_asprintf(tmp_mem, "%d", r->in.join_type);
@@ -961,21 +899,21 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
}
msg->dn = ldb_dn_copy(tmp_mem, base_dn);
- if ( ! ldb_dn_add_child_fmt(msg->dn, "flatname=%s", r2->out.domain_name)) {
+ if ( ! ldb_dn_add_child_fmt(msg->dn, "flatname=%s", r->in.domain_name)) {
r->out.error_string = NULL;
talloc_free(tmp_mem);
return NT_STATUS_NO_MEMORY;
}
- rtn = samdb_msg_add_string(ldb, tmp_mem, msg, "flatname", r2->out.domain_name);
+ rtn = samdb_msg_add_string(ldb, tmp_mem, msg, "flatname", r->in.domain_name);
if (rtn == -1) {
r->out.error_string = NULL;
talloc_free(tmp_mem);
return NT_STATUS_NO_MEMORY;
}
- if (r2->out.realm) {
- rtn = samdb_msg_add_string(ldb, tmp_mem, msg, "realm", r2->out.realm);
+ if (r->in.realm) {
+ rtn = samdb_msg_add_string(ldb, tmp_mem, msg, "realm", r->in.realm);
if (rtn == -1) {
r->out.error_string = NULL;
talloc_free(tmp_mem);
@@ -997,14 +935,14 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
return NT_STATUS_NO_MEMORY;
}
- rtn = samdb_msg_add_string(ldb, tmp_mem, msg, "secret", r2->out.join_password);
+ rtn = samdb_msg_add_string(ldb, tmp_mem, msg, "secret", r->in.join_password);
if (rtn == -1) {
r->out.error_string = NULL;
talloc_free(tmp_mem);
return NT_STATUS_NO_MEMORY;
}
- rtn = samdb_msg_add_string(ldb, tmp_mem, msg, "samAccountName", r2->in.account_name);
+ rtn = samdb_msg_add_string(ldb, tmp_mem, msg, "samAccountName", r->in.account_name);
if (rtn == -1) {
r->out.error_string = NULL;
talloc_free(tmp_mem);
@@ -1018,9 +956,9 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
return NT_STATUS_NO_MEMORY;
}
- if (r2->out.kvno) {
+ if (r->in.kvno) {
rtn = samdb_msg_add_uint(ldb, tmp_mem, msg, "msDS-KeyVersionNumber",
- r2->out.kvno);
+ r->in.kvno);
if (rtn == -1) {
r->out.error_string = NULL;
talloc_free(tmp_mem);
@@ -1028,9 +966,9 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
}
}
- if (r2->out.domain_sid) {
+ if (r->in.domain_sid) {
rtn = samdb_msg_add_dom_sid(ldb, tmp_mem, msg, "objectSid",
- r2->out.domain_sid);
+ r->in.domain_sid);
if (rtn == -1) {
r->out.error_string = NULL;
talloc_free(tmp_mem);
@@ -1047,7 +985,7 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
tmp_mem, base_dn,
&msgs, attrs,
"(|" SECRETS_PRIMARY_DOMAIN_FILTER "(realm=%s))",
- r2->out.domain_name, r2->out.realm);
+ r->in.domain_name, r->in.realm);
if (ret == 0) {
rtn = samdb_msg_set_string(ldb, tmp_mem, msg, "secretsKeytab", "secrets.keytab");
if (rtn == -1) {
@@ -1059,7 +997,7 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
r->out.error_string
= talloc_asprintf(mem_ctx,
"Search for domain: %s and realm: %s failed: %s",
- r2->out.domain_name, r2->out.realm, ldb_errstring(ldb));
+ r->in.domain_name, r->in.realm, ldb_errstring(ldb));
talloc_free(tmp_mem);
return NT_STATUS_INTERNAL_DB_CORRUPTION;
} else {
@@ -1082,7 +1020,7 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
return NT_STATUS_NO_MEMORY;
}
}
- rtn = samdb_msg_set_string(ldb, tmp_mem, msg, "secret", r2->out.join_password);
+ rtn = samdb_msg_set_string(ldb, tmp_mem, msg, "secret", r->in.join_password);
if (rtn == -1) {
r->out.error_string = NULL;
talloc_free(tmp_mem);
@@ -1101,7 +1039,7 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
}
}
- rtn = samdb_msg_set_string(ldb, tmp_mem, msg, "samAccountName", r2->in.account_name);
+ rtn = samdb_msg_set_string(ldb, tmp_mem, msg, "samAccountName", r->in.account_name);
if (rtn == -1) {
r->out.error_string = NULL;
talloc_free(tmp_mem);
@@ -1146,6 +1084,104 @@ static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS libnet_Join_primary_domain(struct libnet_context *ctx,
+ TALLOC_CTX *mem_ctx,
+ struct libnet_Join *r)
+{
+ NTSTATUS status;
+ TALLOC_CTX *tmp_mem;
+ struct libnet_JoinDomain *r2;
+ struct libnet_set_join_secrets *r3;
+ uint32_t acct_type = 0;
+ const char *account_name;
+ const char *netbios_name;
+
+ r->out.error_string = NULL;
+
+ tmp_mem = talloc_new(mem_ctx);
+ if (!tmp_mem) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ r2 = talloc(tmp_mem, struct libnet_JoinDomain);
+ if (!r2) {
+ r->out.error_string = NULL;
+ talloc_free(tmp_mem);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ if (r->in.join_type == SEC_CHAN_BDC) {
+ acct_type = ACB_SVRTRUST;
+ } else if (r->in.join_type == SEC_CHAN_WKSTA) {
+ acct_type = ACB_WSTRUST;
+ } else {
+ r->out.error_string = NULL;
+ talloc_free(tmp_mem);
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ if (r->in.netbios_name != NULL) {
+ netbios_name = r->in.netbios_name;
+ } else {
+ netbios_name = talloc_reference(tmp_mem, lp_netbios_name(ctx->lp_ctx));
+ if (!netbios_name) {
+ r->out.error_string = NULL;
+ talloc_free(tmp_mem);
+ return NT_STATUS_NO_MEMORY;
+ }
+ }
+
+ account_name = talloc_asprintf(tmp_mem, "%s$", netbios_name);
+ if (!account_name) {
+ r->out.error_string = NULL;
+ talloc_free(tmp_mem);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ /*
+ * join the domain
+ */
+ ZERO_STRUCTP(r2);
+ r2->in.domain_name = r->in.domain_name;
+ r2->in.account_name = account_name;
+ r2->in.netbios_name = netbios_name;
+ r2->in.level = LIBNET_JOINDOMAIN_AUTOMATIC;
+ r2->in.acct_type = acct_type;
+ r2->in.recreate_account = false;
+ status = libnet_JoinDomain(ctx, r2, r2);
+ if (!NT_STATUS_IS_OK(status)) {
+ r->out.error_string = talloc_steal(mem_ctx, r2->out.error_string);
+ talloc_free(tmp_mem);
+ return status;
+ }
+
+ r3 = talloc(tmp_mem, struct libnet_set_join_secrets);
+ if (!r3) {
+ r->out.error_string = NULL;
+ talloc_free(tmp_mem);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ ZERO_STRUCTP(r3);
+ r3->in.domain_name = r2->out.domain_name;
+ r3->in.realm = r2->out.realm;
+ r3->in.account_name = account_name;
+ r3->in.netbios_name = netbios_name;
+ r3->in.join_type = r->in.join_type;
+ r3->in.join_password = r2->out.join_password;
+ r3->in.kvno = r2->out.kvno;
+ r3->in.domain_sid = r2->out.domain_sid;
+
+ status = libnet_set_join_secrets(ctx, r3, r3);
+ if (!NT_STATUS_IS_OK(status)) {
+ r->out.error_string = talloc_steal(mem_ctx, r3->out.error_string);
+ talloc_free(tmp_mem);
+ return status;
+ }
+
/* move all out parameter to the callers TALLOC_CTX */
r->out.error_string = NULL;
r->out.join_password = r2->out.join_password;
diff --git a/source4/libnet/libnet_join.h b/source4/libnet/libnet_join.h
index 6da4564cb3..79884130d8 100644
--- a/source4/libnet/libnet_join.h
+++ b/source4/libnet/libnet_join.h
@@ -79,5 +79,22 @@ struct libnet_Join {
} out;
};
+struct libnet_set_join_secrets {
+ struct {
+ const char *domain_name;
+ const char *realm;
+ const char *netbios_name;
+ const char *account_name;
+ enum netr_SchannelType join_type;
+ const char *join_password;
+ int kvno;
+ struct dom_sid *domain_sid;
+ } in;
+
+ struct {
+ const char *error_string;
+ } out;
+};
+
#endif /* __LIBNET_JOIN_H__ */
diff --git a/source4/libnet/libnet_samdump_keytab.c b/source4/libnet/libnet_samdump_keytab.c
index c25cb4d9c5..0c4d3e5c59 100644
--- a/source4/libnet/libnet_samdump_keytab.c
+++ b/source4/libnet/libnet_samdump_keytab.c
@@ -26,8 +26,10 @@
#include "auth/credentials/credentials.h"
#include "auth/credentials/credentials_krb5.h"
#include "param/param.h"
+#include "lib/events/events.h"
static NTSTATUS samdump_keytab_handle_user(TALLOC_CTX *mem_ctx,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
const char *keytab_name,
struct netr_DELTA_ENUM *delta)
@@ -53,12 +55,12 @@ static NTSTATUS samdump_keytab_handle_user(TALLOC_CTX *mem_ctx,
* pass a value in here */
cli_credentials_set_kvno(credentials, 0);
cli_credentials_set_nt_hash(credentials, &user->ntpassword, CRED_SPECIFIED);
- ret = cli_credentials_set_keytab_name(credentials, lp_ctx, keytab_name, CRED_SPECIFIED);
+ ret = cli_credentials_set_keytab_name(credentials, event_ctx, lp_ctx, keytab_name, CRED_SPECIFIED);
if (ret) {
return NT_STATUS_UNSUCCESSFUL;
}
- ret = cli_credentials_update_keytab(credentials, lp_ctx);
+ ret = cli_credentials_update_keytab(credentials, event_ctx, lp_ctx);
if (ret) {
return NT_STATUS_UNSUCCESSFUL;
}
@@ -82,6 +84,7 @@ static NTSTATUS libnet_samdump_keytab_fn(TALLOC_CTX *mem_ctx,
/* not interested in builtin users */
if (database == SAM_DATABASE_DOMAIN) {
nt_status = samdump_keytab_handle_user(mem_ctx,
+ event_context_find(mem_ctx),
global_loadparm,
keytab_name,
delta);
diff --git a/source4/libnet/libnet_samsync.c b/source4/libnet/libnet_samsync.c
new file mode 100644
index 0000000000..0f82d98673
--- /dev/null
+++ b/source4/libnet/libnet_samsync.c
@@ -0,0 +1,399 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Extract the user/system database from a remote SamSync server
+
+ Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-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 "libnet/libnet.h"
+#include "libcli/auth/libcli_auth.h"
+#include "auth/gensec/gensec.h"
+#include "auth/credentials/credentials.h"
+#include "auth/gensec/schannel_proto.h"
+#include "librpc/gen_ndr/ndr_netlogon.h"
+#include "librpc/gen_ndr/ndr_netlogon_c.h"
+#include "param/param.h"
+
+
+/**
+ * Decrypt and extract the user's passwords.
+ *
+ * The writes decrypted (no longer 'RID encrypted' or arcfour encrypted) passwords back into the structure
+ */
+static NTSTATUS fix_user(TALLOC_CTX *mem_ctx,
+ struct creds_CredentialState *creds,
+ bool rid_crypt,
+ enum netr_SamDatabaseID database,
+ struct netr_DELTA_ENUM *delta,
+ char **error_string)
+{
+
+ uint32_t rid = delta->delta_id_union.rid;
+ struct netr_DELTA_USER *user = delta->delta_union.user;
+ struct samr_Password lm_hash;
+ struct samr_Password nt_hash;
+ const char *username = user->account_name.string;
+
+ if (rid_crypt) {
+ if (user->lm_password_present) {
+ sam_rid_crypt(rid, user->lmpassword.hash, lm_hash.hash, 0);
+ user->lmpassword = lm_hash;
+ }
+
+ if (user->nt_password_present) {
+ sam_rid_crypt(rid, user->ntpassword.hash, nt_hash.hash, 0);
+ user->ntpassword = nt_hash;
+ }
+ }
+
+ if (user->user_private_info.SensitiveData) {
+ DATA_BLOB data;
+ struct netr_USER_KEYS keys;
+ enum ndr_err_code ndr_err;
+ data.data = user->user_private_info.SensitiveData;
+ data.length = user->user_private_info.DataLength;
+ creds_arcfour_crypt(creds, data.data, data.length);
+ user->user_private_info.SensitiveData = data.data;
+ user->user_private_info.DataLength = data.length;
+
+ ndr_err = ndr_pull_struct_blob(&data, mem_ctx, NULL, &keys, (ndr_pull_flags_fn_t)ndr_pull_netr_USER_KEYS);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ *error_string = talloc_asprintf(mem_ctx, "Failed to parse Sensitive Data for %s:", username);
+ dump_data(10, data.data, data.length);
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ if (keys.keys.keys2.lmpassword.length == 16) {
+ if (rid_crypt) {
+ sam_rid_crypt(rid, keys.keys.keys2.lmpassword.pwd.hash, lm_hash.hash, 0);
+ user->lmpassword = lm_hash;
+ } else {
+ user->lmpassword = keys.keys.keys2.lmpassword.pwd;
+ }
+ user->lm_password_present = true;
+ }
+ if (keys.keys.keys2.ntpassword.length == 16) {
+ if (rid_crypt) {
+ sam_rid_crypt(rid, keys.keys.keys2.ntpassword.pwd.hash, nt_hash.hash, 0);
+ user->ntpassword = nt_hash;
+ } else {
+ user->ntpassword = keys.keys.keys2.ntpassword.pwd;
+ }
+ user->nt_password_present = true;
+ }
+ /* TODO: rid decrypt history fields */
+ }
+ return NT_STATUS_OK;
+}
+
+/**
+ * Decrypt and extract the secrets
+ *
+ * The writes decrypted secrets back into the structure
+ */
+static NTSTATUS fix_secret(TALLOC_CTX *mem_ctx,
+ struct creds_CredentialState *creds,
+ enum netr_SamDatabaseID database,
+ struct netr_DELTA_ENUM *delta,
+ char **error_string)
+{
+ struct netr_DELTA_SECRET *secret = delta->delta_union.secret;
+ creds_arcfour_crypt(creds, secret->current_cipher.cipher_data,
+ secret->current_cipher.maxlen);
+
+ creds_arcfour_crypt(creds, secret->old_cipher.cipher_data,
+ secret->old_cipher.maxlen);
+
+ return NT_STATUS_OK;
+}
+
+/**
+ * Fix up the delta, dealing with encryption issues so that the final
+ * callback need only do the printing or application logic
+ */
+
+static NTSTATUS fix_delta(TALLOC_CTX *mem_ctx,
+ struct creds_CredentialState *creds,
+ bool rid_crypt,
+ enum netr_SamDatabaseID database,
+ struct netr_DELTA_ENUM *delta,
+ char **error_string)
+{
+ NTSTATUS nt_status = NT_STATUS_OK;
+ *error_string = NULL;
+ switch (delta->delta_type) {
+ case NETR_DELTA_USER:
+ {
+ nt_status = fix_user(mem_ctx,
+ creds,
+ rid_crypt,
+ database,
+ delta,
+ error_string);
+ break;
+ }
+ case NETR_DELTA_SECRET:
+ {
+ nt_status = fix_secret(mem_ctx,
+ creds,
+ database,
+ delta,
+ error_string);
+ break;
+ }
+ default:
+ break;
+ }
+ return nt_status;
+}
+
+NTSTATUS libnet_SamSync_netlogon(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, struct libnet_SamSync *r)
+{
+ NTSTATUS nt_status, dbsync_nt_status;
+ TALLOC_CTX *samsync_ctx, *loop_ctx, *delta_ctx;
+ struct creds_CredentialState *creds;
+ struct netr_DatabaseSync dbsync;
+ struct cli_credentials *machine_account;
+ struct dcerpc_pipe *p;
+ struct libnet_context *machine_net_ctx;
+ struct libnet_RpcConnect *c;
+ struct libnet_SamSync_state *state;
+ const enum netr_SamDatabaseID database_ids[] = {SAM_DATABASE_DOMAIN, SAM_DATABASE_BUILTIN, SAM_DATABASE_PRIVS};
+ int i;
+
+ samsync_ctx = talloc_named(mem_ctx, 0, "SamSync top context");
+
+ if (!r->in.machine_account) {
+ machine_account = cli_credentials_init(samsync_ctx);
+ if (!machine_account) {
+ talloc_free(samsync_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+ cli_credentials_set_conf(machine_account, ctx->lp_ctx);
+ nt_status = cli_credentials_set_machine_account(machine_account, ctx->lp_ctx);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ r->out.error_string = talloc_strdup(mem_ctx, "Could not obtain machine account password - are we joined to the domain?");
+ talloc_free(samsync_ctx);
+ return nt_status;
+ }
+ } else {
+ machine_account = r->in.machine_account;
+ }
+
+ /* We cannot do this unless we are a BDC. Check, before we get odd errors later */
+ if (cli_credentials_get_secure_channel_type(machine_account) != SEC_CHAN_BDC) {
+ r->out.error_string
+ = talloc_asprintf(mem_ctx,
+ "Our join to domain %s is not as a BDC (%d), please rejoin as a BDC",
+ cli_credentials_get_domain(machine_account),
+ cli_credentials_get_secure_channel_type(machine_account));
+ talloc_free(samsync_ctx);
+ return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
+ }
+
+ c = talloc(samsync_ctx, struct libnet_RpcConnect);
+ if (!c) {
+ r->out.error_string = NULL;
+ talloc_free(samsync_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ c->level = LIBNET_RPC_CONNECT_DC_INFO;
+ if (r->in.binding_string) {
+ c->in.binding = r->in.binding_string;
+ c->in.name = NULL;
+ } else {
+ c->in.binding = NULL;
+ c->in.name = cli_credentials_get_domain(machine_account);
+ }
+
+ /* prepare connect to the NETLOGON pipe of PDC */
+ c->in.dcerpc_iface = &ndr_table_netlogon;
+
+ /* We must do this as the machine, not as any command-line
+ * user. So we override the credentials in the
+ * libnet_context */
+ machine_net_ctx = talloc(samsync_ctx, struct libnet_context);
+ if (!machine_net_ctx) {
+ r->out.error_string = NULL;
+ talloc_free(samsync_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+ *machine_net_ctx = *ctx;
+ machine_net_ctx->cred = machine_account;
+
+ /* connect to the NETLOGON pipe of the PDC */
+ nt_status = libnet_RpcConnect(machine_net_ctx, samsync_ctx, c);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ if (r->in.binding_string) {
+ r->out.error_string = talloc_asprintf(mem_ctx,
+ "Connection to NETLOGON pipe of DC %s failed: %s",
+ r->in.binding_string, c->out.error_string);
+ } else {
+ r->out.error_string = talloc_asprintf(mem_ctx,
+ "Connection to NETLOGON pipe of DC for %s failed: %s",
+ c->in.name, c->out.error_string);
+ }
+ talloc_free(samsync_ctx);
+ return nt_status;
+ }
+
+ /* This makes a new pipe, on which we can do schannel. We
+ * should do this in the RpcConnect code, but the abstaction
+ * layers do not suit yet */
+
+ nt_status = dcerpc_secondary_connection(c->out.dcerpc_pipe, &p,
+ c->out.dcerpc_pipe->binding);
+
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ r->out.error_string = talloc_asprintf(mem_ctx,
+ "Secondary connection to NETLOGON pipe of DC %s failed: %s",
+ dcerpc_server_name(p), nt_errstr(nt_status));
+ talloc_free(samsync_ctx);
+ return nt_status;
+ }
+
+ nt_status = dcerpc_bind_auth_schannel(samsync_ctx, p, &ndr_table_netlogon,
+ machine_account, ctx->lp_ctx, DCERPC_AUTH_LEVEL_PRIVACY);
+
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ r->out.error_string = talloc_asprintf(mem_ctx,
+ "SCHANNEL authentication to NETLOGON pipe of DC %s failed: %s",
+ dcerpc_server_name(p), nt_errstr(nt_status));
+ talloc_free(samsync_ctx);
+ return nt_status;
+ }
+
+ state = talloc(samsync_ctx, struct libnet_SamSync_state);
+ if (!state) {
+ r->out.error_string = NULL;
+ talloc_free(samsync_ctx);
+ return nt_status;
+ }
+
+ state->domain_name = c->out.domain_name;
+ state->domain_sid = c->out.domain_sid;
+ state->realm = c->out.realm;
+ state->domain_guid = c->out.guid;
+ state->machine_net_ctx = machine_net_ctx;
+ state->netlogon_pipe = p;
+
+ /* initialise the callback layer. It may wish to contact the
+ * server with ldap, now we know the name */
+
+ if (r->in.init_fn) {
+ char *error_string;
+ nt_status = r->in.init_fn(samsync_ctx,
+ r->in.fn_ctx,
+ state,
+ &error_string);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ r->out.error_string = talloc_steal(mem_ctx, error_string);
+ talloc_free(samsync_ctx);
+ return nt_status;
+ }
+ }
+
+ /* get NETLOGON credentials */
+
+ nt_status = dcerpc_schannel_creds(p->conn->security_state.generic_state, samsync_ctx, &creds);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ r->out.error_string = talloc_strdup(mem_ctx, "Could not obtain NETLOGON credentials from DCERPC/GENSEC layer");
+ talloc_free(samsync_ctx);
+ return nt_status;
+ }
+
+ /* Setup details for the synchronisation */
+ dbsync.in.logon_server = talloc_asprintf(samsync_ctx, "\\\\%s", dcerpc_server_name(p));
+ dbsync.in.computername = cli_credentials_get_workstation(machine_account);
+ dbsync.in.preferredmaximumlength = (uint32_t)-1;
+ ZERO_STRUCT(dbsync.in.return_authenticator);
+
+ for (i=0;i< ARRAY_SIZE(database_ids); i++) {
+ dbsync.in.sync_context = 0;
+ dbsync.in.database_id = database_ids[i];
+
+ do {
+ int d;
+ loop_ctx = talloc_named(samsync_ctx, 0, "DatabaseSync loop context");
+ creds_client_authenticator(creds, &dbsync.in.credential);
+
+ dbsync_nt_status = dcerpc_netr_DatabaseSync(p, loop_ctx, &dbsync);
+ if (!NT_STATUS_IS_OK(dbsync_nt_status) &&
+ !NT_STATUS_EQUAL(dbsync_nt_status, STATUS_MORE_ENTRIES)) {
+ r->out.error_string = talloc_asprintf(mem_ctx, "DatabaseSync failed - %s", nt_errstr(nt_status));
+ talloc_free(samsync_ctx);
+ return nt_status;
+ }
+
+ if (!creds_client_check(creds, &dbsync.out.return_authenticator.cred)) {
+ r->out.error_string = talloc_strdup(mem_ctx, "Credential chaining on incoming DatabaseSync failed");
+ talloc_free(samsync_ctx);
+ return NT_STATUS_ACCESS_DENIED;
+ }
+
+ dbsync.in.sync_context = dbsync.out.sync_context;
+
+ /* For every single remote 'delta' entry: */
+ for (d=0; d < dbsync.out.delta_enum_array->num_deltas; d++) {
+ char *error_string = NULL;
+ delta_ctx = talloc_named(loop_ctx, 0, "DatabaseSync delta context");
+ /* 'Fix' elements, by decrypting and
+ * de-obfuscating the data */
+ nt_status = fix_delta(delta_ctx,
+ creds,
+ r->in.rid_crypt,
+ dbsync.in.database_id,
+ &dbsync.out.delta_enum_array->delta_enum[d],
+ &error_string);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ r->out.error_string = talloc_steal(mem_ctx, error_string);
+ talloc_free(samsync_ctx);
+ return nt_status;
+ }
+
+ /* Now call the callback. This will
+ * do something like print the data or
+ * write to an ldb */
+ nt_status = r->in.delta_fn(delta_ctx,
+ r->in.fn_ctx,
+ dbsync.in.database_id,
+ &dbsync.out.delta_enum_array->delta_enum[d],
+ &error_string);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ r->out.error_string = talloc_steal(mem_ctx, error_string);
+ talloc_free(samsync_ctx);
+ return nt_status;
+ }
+ talloc_free(delta_ctx);
+ }
+ talloc_free(loop_ctx);
+ } while (NT_STATUS_EQUAL(dbsync_nt_status, STATUS_MORE_ENTRIES));
+
+ if (!NT_STATUS_IS_OK(dbsync_nt_status)) {
+ r->out.error_string = talloc_asprintf(mem_ctx, "libnet_SamSync_netlogon failed: unexpected inconsistancy. Should not get error %s here", nt_errstr(nt_status));
+ talloc_free(samsync_ctx);
+ return dbsync_nt_status;
+ }
+ nt_status = NT_STATUS_OK;
+ }
+ talloc_free(samsync_ctx);
+ return nt_status;
+}
+
diff --git a/source4/libnet/libnet_samsync.h b/source4/libnet/libnet_samsync.h
new file mode 100644
index 0000000000..d2ac30fe14
--- /dev/null
+++ b/source4/libnet/libnet_samsync.h
@@ -0,0 +1,84 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Copyright (C) Andrew Bartlett <abartlet@samba.org> 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 "librpc/gen_ndr/netlogon.h"
+
+struct libnet_SamSync_state {
+ struct libnet_context *machine_net_ctx;
+ struct dcerpc_pipe *netlogon_pipe;
+ const char *domain_name;
+ const struct dom_sid *domain_sid;
+ const char *realm;
+ struct GUID *domain_guid;
+};
+
+/* struct and enum for doing a remote domain vampire dump */
+struct libnet_SamSync {
+ struct {
+ const char *binding_string;
+ bool rid_crypt;
+ NTSTATUS (*init_fn)(TALLOC_CTX *mem_ctx,
+ void *private,
+ struct libnet_SamSync_state *samsync_state,
+ char **error_string);
+ NTSTATUS (*delta_fn)(TALLOC_CTX *mem_ctx,
+ void *private,
+ enum netr_SamDatabaseID database,
+ struct netr_DELTA_ENUM *delta,
+ char **error_string);
+ void *fn_ctx;
+ struct cli_credentials *machine_account;
+ } in;
+ struct {
+ const char *error_string;
+ } out;
+};
+
+struct libnet_SamDump {
+ struct {
+ const char *binding_string;
+ struct cli_credentials *machine_account;
+ } in;
+ struct {
+ const char *error_string;
+ } out;
+};
+
+struct libnet_SamDump_keytab {
+ struct {
+ const char *binding_string;
+ const char *keytab_name;
+ struct cli_credentials *machine_account;
+ } in;
+ struct {
+ const char *error_string;
+ } out;
+};
+
+struct libnet_samsync_ldb {
+ struct {
+ const char *binding_string;
+ struct cli_credentials *machine_account;
+ struct auth_session_info *session_info;
+ } in;
+ struct {
+ const char *error_string;
+ } out;
+};
+
diff --git a/source4/libnet/libnet_samsync_ldb.c b/source4/libnet/libnet_samsync_ldb.c
index a60b05189b..85e5dea2d7 100644
--- a/source4/libnet/libnet_samsync_ldb.c
+++ b/source4/libnet/libnet_samsync_ldb.c
@@ -1194,6 +1194,7 @@ static NTSTATUS libnet_samsync_ldb_init(TALLOC_CTX *mem_ctx,
ldap_url = talloc_asprintf(state, "ldap://%s", server);
state->remote_ldb = ldb_wrap_connect(mem_ctx,
+ state->samsync_state->machine_net_ctx->event_ctx,
state->samsync_state->machine_net_ctx->lp_ctx,
ldap_url,
NULL, state->samsync_state->machine_net_ctx->cred,
@@ -1222,6 +1223,7 @@ NTSTATUS libnet_samsync_ldb(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, str
state->trusted_domains = NULL;
state->sam_ldb = ldb_wrap_connect(mem_ctx,
+ ctx->event_ctx,
ctx->lp_ctx,
lp_sam_url(ctx->lp_ctx),
r->in.session_info,
diff --git a/source4/libnet/libnet_site.c b/source4/libnet/libnet_site.c
index dabd23a5be..bb65de1f54 100644
--- a/source4/libnet/libnet_site.c
+++ b/source4/libnet/libnet_site.c
@@ -30,7 +30,7 @@
* 1. Setup a CLDAP socket.
* 2. Lookup the default Site-Name.
*/
-NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_JoinSite *r)
+NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_context *lctx, struct libnet_JoinSite *r)
{
NTSTATUS status;
TALLOC_CTX *tmp_ctx;
@@ -53,11 +53,12 @@ NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_JoinSite *r)
search.in.dest_address = r->in.dest_address;
search.in.dest_port = r->in.cldap_port;
search.in.acct_control = -1;
- search.in.version = 6;
+ search.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX;
+ search.in.map_response = true;
- cldap = cldap_socket_init(tmp_ctx, NULL, lp_iconv_convenience(global_loadparm));
+ cldap = cldap_socket_init(tmp_ctx, lctx->event_ctx, lp_iconv_convenience(global_loadparm));
status = cldap_netlogon(cldap, tmp_ctx, &search);
- if (!NT_STATUS_IS_OK(status)) {
+ if (!NT_STATUS_IS_OK(status) || !search.out.netlogon.nt5_ex.client_site) {
/*
If cldap_netlogon() returns in error,
default to using Default-First-Site-Name.
@@ -71,7 +72,7 @@ NTSTATUS libnet_FindSite(TALLOC_CTX *ctx, struct libnet_JoinSite *r)
}
} else {
site_name_str = talloc_asprintf(tmp_ctx, "%s",
- search.out.netlogon.logon5.client_site);
+ search.out.netlogon.nt5_ex.client_site);
if (!site_name_str) {
r->out.error_string = NULL;
talloc_free(tmp_ctx);
@@ -148,7 +149,7 @@ NTSTATUS libnet_JoinSite(struct libnet_context *ctx,
}
make_nbt_name_client(&name, libnet_r->out.samr_binding->host);
- status = resolve_name(lp_resolve_context(ctx->lp_ctx), &name, r, &dest_addr, NULL);
+ status = resolve_name(lp_resolve_context(ctx->lp_ctx), &name, r, &dest_addr, ctx->event_ctx);
if (!NT_STATUS_IS_OK(status)) {
libnet_r->out.error_string = NULL;
talloc_free(tmp_ctx);
@@ -161,7 +162,7 @@ NTSTATUS libnet_JoinSite(struct libnet_context *ctx,
r->in.domain_dn_str = libnet_r->out.domain_dn_str;
r->in.cldap_port = lp_cldap_port(ctx->lp_ctx);
- status = libnet_FindSite(tmp_ctx, r);
+ status = libnet_FindSite(tmp_ctx, ctx, r);
if (!NT_STATUS_IS_OK(status)) {
libnet_r->out.error_string =
talloc_steal(libnet_r, r->out.error_string);
diff --git a/source4/libnet/libnet_unbecome_dc.c b/source4/libnet/libnet_unbecome_dc.c
index 5d346ac166..cff919018a 100644
--- a/source4/libnet/libnet_unbecome_dc.c
+++ b/source4/libnet/libnet_unbecome_dc.c
@@ -193,7 +193,7 @@ struct libnet_UnbecomeDC_state {
struct {
struct cldap_socket *sock;
struct cldap_netlogon io;
- struct nbt_cldap_netlogon_5 netlogon5;
+ struct NETLOGON_SAM_LOGON_RESPONSE_EX netlogon;
} cldap;
struct {
@@ -265,7 +265,8 @@ static void unbecomeDC_send_cldap(struct libnet_UnbecomeDC_state *s)
s->cldap.io.in.domain_guid = NULL;
s->cldap.io.in.domain_sid = NULL;
s->cldap.io.in.acct_control = -1;
- s->cldap.io.in.version = 6;
+ s->cldap.io.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX;
+ s->cldap.io.in.map_response = true;
s->cldap.sock = cldap_socket_init(s, s->libnet->event_ctx,
lp_iconv_convenience(s->libnet->lp_ctx));
@@ -288,17 +289,17 @@ static void unbecomeDC_recv_cldap(struct cldap_request *req)
c->status = cldap_netlogon_recv(req, s, &s->cldap.io);
if (!composite_is_ok(c)) return;
- s->cldap.netlogon5 = s->cldap.io.out.netlogon.logon5;
+ s->cldap.netlogon = s->cldap.io.out.netlogon.nt5_ex;
- s->domain.dns_name = s->cldap.netlogon5.dns_domain;
- s->domain.netbios_name = s->cldap.netlogon5.domain;
- s->domain.guid = s->cldap.netlogon5.domain_uuid;
+ s->domain.dns_name = s->cldap.netlogon.dns_domain;
+ s->domain.netbios_name = s->cldap.netlogon.domain;
+ s->domain.guid = s->cldap.netlogon.domain_uuid;
- s->source_dsa.dns_name = s->cldap.netlogon5.pdc_dns_name;
- s->source_dsa.netbios_name = s->cldap.netlogon5.pdc_name;
- s->source_dsa.site_name = s->cldap.netlogon5.server_site;
+ s->source_dsa.dns_name = s->cldap.netlogon.pdc_dns_name;
+ s->source_dsa.netbios_name = s->cldap.netlogon.pdc_name;
+ s->source_dsa.site_name = s->cldap.netlogon.server_site;
- s->dest_dsa.site_name = s->cldap.netlogon5.client_site;
+ s->dest_dsa.site_name = s->cldap.netlogon.client_site;
unbecomeDC_connect_ldap(s);
}
@@ -310,7 +311,7 @@ static NTSTATUS unbecomeDC_ldap_connect(struct libnet_UnbecomeDC_state *s)
url = talloc_asprintf(s, "ldap://%s/", s->source_dsa.dns_name);
NT_STATUS_HAVE_NO_MEMORY(url);
- s->ldap.ldb = ldb_wrap_connect(s, s->libnet->lp_ctx, url,
+ s->ldap.ldb = ldb_wrap_connect(s, s->libnet->event_ctx, s->libnet->lp_ctx, url,
NULL,
s->libnet->cred,
0, NULL);
diff --git a/source4/libnet/libnet_user.c b/source4/libnet/libnet_user.c
index 678c7a226e..dce7320c73 100644
--- a/source4/libnet/libnet_user.c
+++ b/source4/libnet/libnet_user.c
@@ -597,7 +597,9 @@ NTSTATUS libnet_ModifyUser(struct libnet_context *ctx, TALLOC_CTX *mem_ctx,
struct user_info_state {
struct libnet_context *ctx;
const char *domain_name;
+ enum libnet_UserInfo_level level;
const char *user_name;
+ const char *sid_string;
struct libnet_LookupName lookup;
struct libnet_DomainOpen domopen;
struct libnet_rpc_userinfo userinfo;
@@ -628,7 +630,7 @@ struct composite_context* libnet_UserInfo_send(struct libnet_context *ctx,
{
struct composite_context *c;
struct user_info_state *s;
- struct composite_context *lookup_req;
+ struct composite_context *lookup_req, *info_req;
bool prereq_met = false;
/* composite context allocation and setup */
@@ -644,23 +646,54 @@ struct composite_context* libnet_UserInfo_send(struct libnet_context *ctx,
s->monitor_fn = monitor;
s->ctx = ctx;
s->domain_name = talloc_strdup(c, r->in.domain_name);
- s->user_name = talloc_strdup(c, r->in.user_name);
+ s->level = r->in.level;
+ switch (s->level) {
+ case USER_INFO_BY_NAME:
+ s->user_name = talloc_strdup(c, r->in.data.user_name);
+ s->sid_string = NULL;
+ break;
+ case USER_INFO_BY_SID:
+ s->user_name = NULL;
+ s->sid_string = dom_sid_string(c, r->in.data.user_sid);
+ break;
+ }
/* prerequisite: make sure the domain is opened */
prereq_met = samr_domain_opened(ctx, s->domain_name, &c, &s->domopen,
continue_domain_open_info, monitor);
if (!prereq_met) return c;
- /* prepare arguments for LookupName call */
- s->lookup.in.domain_name = s->domain_name;
- s->lookup.in.name = s->user_name;
-
- /* send the request */
- lookup_req = libnet_LookupName_send(ctx, c, &s->lookup, s->monitor_fn);
- if (composite_nomem(lookup_req, c)) return c;
+ switch (s->level) {
+ case USER_INFO_BY_NAME:
+ /* prepare arguments for LookupName call */
+ s->lookup.in.domain_name = s->domain_name;
+ s->lookup.in.name = s->user_name;
+
+ /* send the request */
+ lookup_req = libnet_LookupName_send(ctx, c, &s->lookup,
+ s->monitor_fn);
+ if (composite_nomem(lookup_req, c)) return c;
+
+ /* set the next stage */
+ composite_continue(c, lookup_req, continue_name_found, c);
+ break;
+ case USER_INFO_BY_SID:
+ /* prepare arguments for UserInfo call */
+ s->userinfo.in.domain_handle = s->ctx->samr.handle;
+ s->userinfo.in.sid = s->sid_string;
+ s->userinfo.in.level = 21;
+
+ /* send the request */
+ info_req = libnet_rpc_userinfo_send(s->ctx->samr.pipe,
+ &s->userinfo,
+ s->monitor_fn);
+ if (composite_nomem(info_req, c)) return c;
+
+ /* set the next stage */
+ composite_continue(c, info_req, continue_info_received, c);
+ break;
+ }
- /* set the next stage */
- composite_continue(c, lookup_req, continue_name_found, c);
return c;
}
@@ -673,7 +706,7 @@ static void continue_domain_open_info(struct composite_context *ctx)
{
struct composite_context *c;
struct user_info_state *s;
- struct composite_context *lookup_req;
+ struct composite_context *lookup_req, *info_req;
struct monitor_msg msg;
c = talloc_get_type(ctx->async.private_data, struct composite_context);
@@ -686,16 +719,36 @@ static void continue_domain_open_info(struct composite_context *ctx)
/* send monitor message */
if (s->monitor_fn) s->monitor_fn(&msg);
- /* prepare arguments for LookupName call */
- s->lookup.in.domain_name = s->domain_name;
- s->lookup.in.name = s->user_name;
-
- /* send the request */
- lookup_req = libnet_LookupName_send(s->ctx, c, &s->lookup, s->monitor_fn);
- if (composite_nomem(lookup_req, c)) return;
-
- /* set the next stage */
- composite_continue(c, lookup_req, continue_name_found, c);
+ switch (s->level) {
+ case USER_INFO_BY_NAME:
+ /* prepare arguments for LookupName call */
+ s->lookup.in.domain_name = s->domain_name;
+ s->lookup.in.name = s->user_name;
+
+ /* send the request */
+ lookup_req = libnet_LookupName_send(s->ctx, c, &s->lookup, s->monitor_fn);
+ if (composite_nomem(lookup_req, c)) return;
+
+ /* set the next stage */
+ composite_continue(c, lookup_req, continue_name_found, c);
+ break;
+
+ case USER_INFO_BY_SID:
+ /* prepare arguments for UserInfo call */
+ s->userinfo.in.domain_handle = s->ctx->samr.handle;
+ s->userinfo.in.sid = s->sid_string;
+ s->userinfo.in.level = 21;
+
+ /* send the request */
+ info_req = libnet_rpc_userinfo_send(s->ctx->samr.pipe,
+ &s->userinfo,
+ s->monitor_fn);
+ if (composite_nomem(info_req, c)) return;
+
+ /* set the next stage */
+ composite_continue(c, info_req, continue_info_received, c);
+ break;
+ }
}
diff --git a/source4/libnet/libnet_user.h b/source4/libnet/libnet_user.h
index 94aa38464f..7095160004 100644
--- a/source4/libnet/libnet_user.h
+++ b/source4/libnet/libnet_user.h
@@ -99,11 +99,19 @@ struct libnet_ModifyUser {
} \
}
+enum libnet_UserInfo_level {
+ USER_INFO_BY_NAME=0,
+ USER_INFO_BY_SID
+};
struct libnet_UserInfo {
struct {
- const char *user_name;
const char *domain_name;
+ enum libnet_UserInfo_level level;
+ union {
+ const char *user_name;
+ const struct dom_sid *user_sid;
+ } data;
} in;
struct {
struct dom_sid *user_sid;
@@ -123,7 +131,6 @@ struct libnet_UserInfo {
struct timeval *last_logoff;
struct timeval *last_password_change;
uint32_t acct_flags;
-
const char *error_string;
} out;
};
diff --git a/source4/libnet/libnet_vampire.c b/source4/libnet/libnet_vampire.c
index 0f82d98673..56a8ebe034 100644
--- a/source4/libnet/libnet_vampire.c
+++ b/source4/libnet/libnet_vampire.c
@@ -1,9 +1,11 @@
/*
Unix SMB/CIFS implementation.
- Extract the user/system database from a remote SamSync server
+ Extract the user/system database from a remote server
- Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-2005
+ Copyright (C) Stefan Metzmacher 2004-2006
+ Copyright (C) Brad Henry 2005
+ Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005-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
@@ -22,378 +24,689 @@
#include "includes.h"
#include "libnet/libnet.h"
-#include "libcli/auth/libcli_auth.h"
-#include "auth/gensec/gensec.h"
-#include "auth/credentials/credentials.h"
-#include "auth/gensec/schannel_proto.h"
-#include "librpc/gen_ndr/ndr_netlogon.h"
-#include "librpc/gen_ndr/ndr_netlogon_c.h"
+#include "lib/events/events.h"
+#include "dsdb/samdb/samdb.h"
+#include "lib/util/dlinklist.h"
+#include "lib/ldb/include/ldb.h"
+#include "lib/ldb/include/ldb_errors.h"
+#include "librpc/ndr/libndr.h"
+#include "librpc/gen_ndr/ndr_drsuapi.h"
+#include "librpc/gen_ndr/ndr_drsblobs.h"
+#include "librpc/gen_ndr/ndr_misc.h"
+#include "system/time.h"
+#include "lib/ldb_wrap.h"
+#include "auth/auth.h"
#include "param/param.h"
+#include "param/provision.h"
+/*
+List of tasks vampire.py must perform:
+- Domain Join
+ - but don't write the secrets.ldb
+ - results for this should be enough to handle the provision
+- if vampire method is samsync
+ - Provision using these results
+ - do we still want to support this NT4 technology?
+- Start samsync with libnet code
+ - provision in the callback
+- Write out the secrets database, using the code from libnet_Join
+
+*/
+struct vampire_state {
+ const char *netbios_name;
+ struct libnet_JoinDomain *join;
+ struct cli_credentials *machine_account;
+ struct dsdb_schema *self_made_schema;
+ const struct dsdb_schema *schema;
+
+ struct ldb_context *ldb;
-/**
- * Decrypt and extract the user's passwords.
- *
- * The writes decrypted (no longer 'RID encrypted' or arcfour encrypted) passwords back into the structure
- */
-static NTSTATUS fix_user(TALLOC_CTX *mem_ctx,
- struct creds_CredentialState *creds,
- bool rid_crypt,
- enum netr_SamDatabaseID database,
- struct netr_DELTA_ENUM *delta,
- char **error_string)
+ struct {
+ uint32_t object_count;
+ struct drsuapi_DsReplicaObjectListItemEx *first_object;
+ struct drsuapi_DsReplicaObjectListItemEx *last_object;
+ } schema_part;
+
+ const char *targetdir;
+
+ struct loadparm_context *lp_ctx;
+ struct event_context *event_ctx;
+};
+
+static NTSTATUS vampire_prepare_db(void *private_data,
+ const struct libnet_BecomeDC_PrepareDB *p)
{
+ struct vampire_state *s = talloc_get_type(private_data, struct vampire_state);
+ struct provision_settings settings;
+ struct provision_result result;
+ NTSTATUS status;
+
+ 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.netbios_name = p->dest_dsa->netbios_name;
+ settings.realm = s->join->out.realm;
+ settings.domain = s->join->out.domain_name;
+ settings.server_dn_str = p->dest_dsa->server_dn_str;
+ settings.machine_password = generate_random_str(s, 16);
+ settings.targetdir = s->targetdir;
+
+ status = provision_bare(s, s->lp_ctx, &settings, &result);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
- uint32_t rid = delta->delta_id_union.rid;
- struct netr_DELTA_USER *user = delta->delta_union.user;
- struct samr_Password lm_hash;
- struct samr_Password nt_hash;
- const char *username = user->account_name.string;
+ s->ldb = result.samdb;
+ s->lp_ctx = result.lp_ctx;
- if (rid_crypt) {
- if (user->lm_password_present) {
- sam_rid_crypt(rid, user->lmpassword.hash, lm_hash.hash, 0);
- user->lmpassword = lm_hash;
- }
-
- if (user->nt_password_present) {
- sam_rid_crypt(rid, user->ntpassword.hash, nt_hash.hash, 0);
- user->ntpassword = nt_hash;
- }
+ return NT_STATUS_OK;
+
+
+}
+
+static NTSTATUS vampire_check_options(void *private_data,
+ const struct libnet_BecomeDC_CheckOptions *o)
+{
+ struct vampire_state *s = talloc_get_type(private_data, struct vampire_state);
+
+ DEBUG(0,("Become DC [%s] of Domain[%s]/[%s]\n",
+ s->netbios_name,
+ o->domain->netbios_name, o->domain->dns_name));
+
+ DEBUG(0,("Promotion Partner is Server[%s] from Site[%s]\n",
+ o->source_dsa->dns_name, o->source_dsa->site_name));
+
+ DEBUG(0,("Options:crossRef behavior_version[%u]\n"
+ "\tschema object_version[%u]\n"
+ "\tdomain behavior_version[%u]\n"
+ "\tdomain w2k3_update_revision[%u]\n",
+ o->forest->crossref_behavior_version,
+ o->forest->schema_object_version,
+ o->domain->behavior_version,
+ o->domain->w2k3_update_revision));
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS vampire_apply_schema(struct vampire_state *s,
+ const struct libnet_BecomeDC_StoreChunk *c)
+{
+ WERROR status;
+ const struct drsuapi_DsReplicaOIDMapping_Ctr *mapping_ctr;
+ uint32_t total_object_count;
+ uint32_t object_count;
+ struct drsuapi_DsReplicaObjectListItemEx *first_object;
+ struct drsuapi_DsReplicaObjectListItemEx *cur;
+ uint32_t linked_attributes_count;
+ struct drsuapi_DsReplicaLinkedAttribute *linked_attributes;
+ const struct drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector;
+ struct dsdb_extended_replicated_objects *objs;
+ struct repsFromTo1 *s_dsa;
+ char *tmp_dns_name;
+ struct ldb_message *msg;
+ struct ldb_val prefixMap_val;
+ struct ldb_message_element *prefixMap_el;
+ struct ldb_val schemaInfo_val;
+ uint32_t i;
+ int ret;
+ bool ok;
+
+ DEBUG(0,("Analyze and apply schema objects\n"));
+
+ s_dsa = talloc_zero(s, struct repsFromTo1);
+ NT_STATUS_HAVE_NO_MEMORY(s_dsa);
+ s_dsa->other_info = talloc(s_dsa, struct repsFromTo1OtherInfo);
+ NT_STATUS_HAVE_NO_MEMORY(s_dsa->other_info);
+
+ switch (c->ctr_level) {
+ case 1:
+ mapping_ctr = &c->ctr1->mapping_ctr;
+ total_object_count = c->ctr1->total_object_count;
+ object_count = s->schema_part.object_count;
+ first_object = s->schema_part.first_object;
+ linked_attributes_count = 0;
+ linked_attributes = NULL;
+ s_dsa->highwatermark = c->ctr1->new_highwatermark;
+ s_dsa->source_dsa_obj_guid = c->ctr1->source_dsa_guid;
+ s_dsa->source_dsa_invocation_id = c->ctr1->source_dsa_invocation_id;
+ uptodateness_vector = NULL; /* TODO: map it */
+ break;
+ case 6:
+ mapping_ctr = &c->ctr6->mapping_ctr;
+ total_object_count = c->ctr6->total_object_count;
+ object_count = s->schema_part.object_count;
+ first_object = s->schema_part.first_object;
+ linked_attributes_count = 0; /* TODO: ! */
+ linked_attributes = NULL; /* TODO: ! */;
+ s_dsa->highwatermark = c->ctr6->new_highwatermark;
+ s_dsa->source_dsa_obj_guid = c->ctr6->source_dsa_guid;
+ s_dsa->source_dsa_invocation_id = c->ctr6->source_dsa_invocation_id;
+ uptodateness_vector = c->ctr6->uptodateness_vector;
+ break;
+ default:
+ return NT_STATUS_INVALID_PARAMETER;
}
- if (user->user_private_info.SensitiveData) {
- DATA_BLOB data;
- struct netr_USER_KEYS keys;
- enum ndr_err_code ndr_err;
- data.data = user->user_private_info.SensitiveData;
- data.length = user->user_private_info.DataLength;
- creds_arcfour_crypt(creds, data.data, data.length);
- user->user_private_info.SensitiveData = data.data;
- user->user_private_info.DataLength = data.length;
-
- ndr_err = ndr_pull_struct_blob(&data, mem_ctx, NULL, &keys, (ndr_pull_flags_fn_t)ndr_pull_netr_USER_KEYS);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- *error_string = talloc_asprintf(mem_ctx, "Failed to parse Sensitive Data for %s:", username);
- dump_data(10, data.data, data.length);
- return ndr_map_error2ntstatus(ndr_err);
+ s_dsa->replica_flags = DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE
+ | DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP
+ | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS;
+ memset(s_dsa->schedule, 0x11, sizeof(s_dsa->schedule));
+
+ tmp_dns_name = GUID_string(s_dsa->other_info, &s_dsa->source_dsa_obj_guid);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name);
+ tmp_dns_name = talloc_asprintf_append_buffer(tmp_dns_name, "._msdcs.%s", c->forest->dns_name);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name);
+ s_dsa->other_info->dns_name = tmp_dns_name;
+
+ for (cur = first_object; cur; cur = cur->next_object) {
+ bool is_attr = false;
+ bool is_class = false;
+
+ for (i=0; i < cur->object.attribute_ctr.num_attributes; i++) {
+ struct drsuapi_DsReplicaAttribute *a;
+ uint32_t j;
+ const char *oid = NULL;
+
+ a = &cur->object.attribute_ctr.attributes[i];
+ status = dsdb_map_int2oid(s->self_made_schema, a->attid, s, &oid);
+ if (!W_ERROR_IS_OK(status)) {
+ return werror_to_ntstatus(status);
+ }
+
+ switch (a->attid) {
+ case DRSUAPI_ATTRIBUTE_objectClass:
+ for (j=0; j < a->value_ctr.num_values; j++) {
+ uint32_t val = 0xFFFFFFFF;
+
+ if (a->value_ctr.values[i].blob
+ && a->value_ctr.values[i].blob->length == 4) {
+ val = IVAL(a->value_ctr.values[i].blob->data,0);
+ }
+
+ if (val == DRSUAPI_OBJECTCLASS_attributeSchema) {
+ is_attr = true;
+ }
+ if (val == DRSUAPI_OBJECTCLASS_classSchema) {
+ is_class = true;
+ }
+ }
+
+ break;
+ default:
+ break;
+ }
}
- if (keys.keys.keys2.lmpassword.length == 16) {
- if (rid_crypt) {
- sam_rid_crypt(rid, keys.keys.keys2.lmpassword.pwd.hash, lm_hash.hash, 0);
- user->lmpassword = lm_hash;
- } else {
- user->lmpassword = keys.keys.keys2.lmpassword.pwd;
+ if (is_attr) {
+ struct dsdb_attribute *sa;
+
+ sa = talloc_zero(s->self_made_schema, struct dsdb_attribute);
+ NT_STATUS_HAVE_NO_MEMORY(sa);
+
+ status = dsdb_attribute_from_drsuapi(s->self_made_schema, &cur->object, s, sa);
+ if (!W_ERROR_IS_OK(status)) {
+ return werror_to_ntstatus(status);
}
- user->lm_password_present = true;
+
+ DLIST_ADD_END(s->self_made_schema->attributes, sa, struct dsdb_attribute *);
}
- if (keys.keys.keys2.ntpassword.length == 16) {
- if (rid_crypt) {
- sam_rid_crypt(rid, keys.keys.keys2.ntpassword.pwd.hash, nt_hash.hash, 0);
- user->ntpassword = nt_hash;
- } else {
- user->ntpassword = keys.keys.keys2.ntpassword.pwd;
+
+ if (is_class) {
+ struct dsdb_class *sc;
+
+ sc = talloc_zero(s->self_made_schema, struct dsdb_class);
+ NT_STATUS_HAVE_NO_MEMORY(sc);
+
+ status = dsdb_class_from_drsuapi(s->self_made_schema, &cur->object, s, sc);
+ if (!W_ERROR_IS_OK(status)) {
+ return werror_to_ntstatus(status);
}
- user->nt_password_present = true;
+
+ DLIST_ADD_END(s->self_made_schema->classes, sc, struct dsdb_class *);
}
- /* TODO: rid decrypt history fields */
}
- return NT_STATUS_OK;
-}
-/**
- * Decrypt and extract the secrets
- *
- * The writes decrypted secrets back into the structure
- */
-static NTSTATUS fix_secret(TALLOC_CTX *mem_ctx,
- struct creds_CredentialState *creds,
- enum netr_SamDatabaseID database,
- struct netr_DELTA_ENUM *delta,
- char **error_string)
-{
- struct netr_DELTA_SECRET *secret = delta->delta_union.secret;
- creds_arcfour_crypt(creds, secret->current_cipher.cipher_data,
- secret->current_cipher.maxlen);
+ /* attach the schema to the ldb */
+ ret = dsdb_set_schema(s->ldb, s->self_made_schema);
+ if (ret != LDB_SUCCESS) {
+ return NT_STATUS_FOOBAR;
+ }
+ /* we don't want to access the self made schema anymore */
+ s->self_made_schema = NULL;
+ s->schema = dsdb_get_schema(s->ldb);
+
+ status = dsdb_extended_replicated_objects_commit(s->ldb,
+ c->partition->nc.dn,
+ mapping_ctr,
+ object_count,
+ first_object,
+ linked_attributes_count,
+ linked_attributes,
+ s_dsa,
+ uptodateness_vector,
+ c->gensec_skey,
+ s, &objs);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status)));
+ return werror_to_ntstatus(status);
+ }
+
+ if (lp_parm_bool(s->lp_ctx, NULL, "become dc", "dump objects", false)) {
+ for (i=0; i < objs->num_objects; i++) {
+ struct ldb_ldif ldif;
+ fprintf(stdout, "#\n");
+ ldif.changetype = LDB_CHANGETYPE_NONE;
+ ldif.msg = objs->objects[i].msg;
+ ldb_ldif_write_file(s->ldb, stdout, &ldif);
+ NDR_PRINT_DEBUG(replPropertyMetaDataBlob, objs->objects[i].meta_data);
+ }
+ }
+
+ msg = ldb_msg_new(objs);
+ NT_STATUS_HAVE_NO_MEMORY(msg);
+ msg->dn = objs->partition_dn;
+
+ status = dsdb_get_oid_mappings_ldb(s->schema, msg, &prefixMap_val, &schemaInfo_val);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(0,("Failed dsdb_get_oid_mappings_ldb(%s)\n", win_errstr(status)));
+ return werror_to_ntstatus(status);
+ }
+
+ /* we only add prefixMap here, because schemaInfo is a replicated attribute and already applied */
+ ret = ldb_msg_add_value(msg, "prefixMap", &prefixMap_val, &prefixMap_el);
+ if (ret != LDB_SUCCESS) {
+ return NT_STATUS_FOOBAR;
+ }
+ prefixMap_el->flags = LDB_FLAG_MOD_REPLACE;
+
+ ret = ldb_modify(s->ldb, msg);
+ if (ret != LDB_SUCCESS) {
+ DEBUG(0,("Failed to add prefixMap and schemaInfo %s\n", ldb_strerror(ret)));
+ return NT_STATUS_FOOBAR;
+ }
+
+ talloc_free(s_dsa);
+ talloc_free(objs);
+
+ /* reopen the ldb */
+ talloc_free(s->ldb); /* this also free's the s->schema, because dsdb_set_schema() steals it */
+ s->schema = NULL;
+
+ DEBUG(0,("Reopen the SAM LDB with system credentials and a already stored schema\n"));
+ s->ldb = samdb_connect(s, s->event_ctx, s->lp_ctx,
+ system_session(s, s->lp_ctx));
+ if (!s->ldb) {
+ DEBUG(0,("Failed to reopen sam.ldb\n"));
+ return NT_STATUS_INTERNAL_DB_ERROR;
+ }
- creds_arcfour_crypt(creds, secret->old_cipher.cipher_data,
- secret->old_cipher.maxlen);
+ /* We must set these up to ensure the replMetaData is written correctly, before our NTDS Settings entry is replicated */
+ ok = samdb_set_ntds_invocation_id(s->ldb, &c->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, &c->dest_dsa->ntds_guid);
+ if (!ok) {
+ DEBUG(0,("Failed to set cached ntds objectGUID\n"));
+ return NT_STATUS_FOOBAR;
+ }
+
+ s->schema = dsdb_get_schema(s->ldb);
+ if (!s->schema) {
+ DEBUG(0,("Failed to get loaded dsdb_schema\n"));
+ return NT_STATUS_FOOBAR;
+ }
return NT_STATUS_OK;
}
-/**
- * Fix up the delta, dealing with encryption issues so that the final
- * callback need only do the printing or application logic
- */
-
-static NTSTATUS fix_delta(TALLOC_CTX *mem_ctx,
- struct creds_CredentialState *creds,
- bool rid_crypt,
- enum netr_SamDatabaseID database,
- struct netr_DELTA_ENUM *delta,
- char **error_string)
+static NTSTATUS vampire_schema_chunk(void *private_data,
+ const struct libnet_BecomeDC_StoreChunk *c)
{
- NTSTATUS nt_status = NT_STATUS_OK;
- *error_string = NULL;
- switch (delta->delta_type) {
- case NETR_DELTA_USER:
- {
- nt_status = fix_user(mem_ctx,
- creds,
- rid_crypt,
- database,
- delta,
- error_string);
+ struct vampire_state *s = talloc_get_type(private_data, struct vampire_state);
+ WERROR status;
+ const struct drsuapi_DsReplicaOIDMapping_Ctr *mapping_ctr;
+ uint32_t total_object_count;
+ uint32_t object_count;
+ struct drsuapi_DsReplicaObjectListItemEx *first_object;
+ struct drsuapi_DsReplicaObjectListItemEx *cur;
+
+ switch (c->ctr_level) {
+ case 1:
+ mapping_ctr = &c->ctr1->mapping_ctr;
+ total_object_count = c->ctr1->total_object_count;
+ object_count = c->ctr1->object_count;
+ first_object = c->ctr1->first_object;
break;
- }
- case NETR_DELTA_SECRET:
- {
- nt_status = fix_secret(mem_ctx,
- creds,
- database,
- delta,
- error_string);
+ case 6:
+ mapping_ctr = &c->ctr6->mapping_ctr;
+ total_object_count = c->ctr6->total_object_count;
+ object_count = c->ctr6->object_count;
+ first_object = c->ctr6->first_object;
break;
- }
default:
- break;
+ return NT_STATUS_INVALID_PARAMETER;
}
- return nt_status;
-}
-NTSTATUS libnet_SamSync_netlogon(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, struct libnet_SamSync *r)
-{
- NTSTATUS nt_status, dbsync_nt_status;
- TALLOC_CTX *samsync_ctx, *loop_ctx, *delta_ctx;
- struct creds_CredentialState *creds;
- struct netr_DatabaseSync dbsync;
- struct cli_credentials *machine_account;
- struct dcerpc_pipe *p;
- struct libnet_context *machine_net_ctx;
- struct libnet_RpcConnect *c;
- struct libnet_SamSync_state *state;
- const enum netr_SamDatabaseID database_ids[] = {SAM_DATABASE_DOMAIN, SAM_DATABASE_BUILTIN, SAM_DATABASE_PRIVS};
- int i;
-
- samsync_ctx = talloc_named(mem_ctx, 0, "SamSync top context");
-
- if (!r->in.machine_account) {
- machine_account = cli_credentials_init(samsync_ctx);
- if (!machine_account) {
- talloc_free(samsync_ctx);
- return NT_STATUS_NO_MEMORY;
+ if (total_object_count) {
+ DEBUG(0,("Schema-DN[%s] objects[%u/%u]\n",
+ c->partition->nc.dn, object_count, total_object_count));
+ } else {
+ DEBUG(0,("Schema-DN[%s] objects[%u]\n",
+ c->partition->nc.dn, object_count));
+ }
+
+ if (!s->schema) {
+ s->self_made_schema = dsdb_new_schema(s, lp_iconv_convenience(s->lp_ctx));
+
+ NT_STATUS_HAVE_NO_MEMORY(s->self_made_schema);
+
+ status = dsdb_load_oid_mappings_drsuapi(s->self_made_schema, mapping_ctr);
+ if (!W_ERROR_IS_OK(status)) {
+ return werror_to_ntstatus(status);
}
- cli_credentials_set_conf(machine_account, ctx->lp_ctx);
- nt_status = cli_credentials_set_machine_account(machine_account, ctx->lp_ctx);
- if (!NT_STATUS_IS_OK(nt_status)) {
- r->out.error_string = talloc_strdup(mem_ctx, "Could not obtain machine account password - are we joined to the domain?");
- talloc_free(samsync_ctx);
- return nt_status;
+
+ s->schema = s->self_made_schema;
+ } else {
+ status = dsdb_verify_oid_mappings_drsuapi(s->schema, mapping_ctr);
+ if (!W_ERROR_IS_OK(status)) {
+ return werror_to_ntstatus(status);
}
+ }
+
+ if (!s->schema_part.first_object) {
+ s->schema_part.object_count = object_count;
+ s->schema_part.first_object = talloc_steal(s, first_object);
} else {
- machine_account = r->in.machine_account;
+ s->schema_part.object_count += object_count;
+ s->schema_part.last_object->next_object = talloc_steal(s->schema_part.last_object,
+ first_object);
}
+ for (cur = first_object; cur->next_object; cur = cur->next_object) {}
+ s->schema_part.last_object = cur;
- /* We cannot do this unless we are a BDC. Check, before we get odd errors later */
- if (cli_credentials_get_secure_channel_type(machine_account) != SEC_CHAN_BDC) {
- r->out.error_string
- = talloc_asprintf(mem_ctx,
- "Our join to domain %s is not as a BDC (%d), please rejoin as a BDC",
- cli_credentials_get_domain(machine_account),
- cli_credentials_get_secure_channel_type(machine_account));
- talloc_free(samsync_ctx);
- return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
+ if (c->partition->highwatermark.tmp_highest_usn == c->partition->highwatermark.highest_usn) {
+ return vampire_apply_schema(s, c);
}
- c = talloc(samsync_ctx, struct libnet_RpcConnect);
- if (!c) {
- r->out.error_string = NULL;
- talloc_free(samsync_ctx);
- return NT_STATUS_NO_MEMORY;
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS vampire_store_chunk(void *private_data,
+ const struct libnet_BecomeDC_StoreChunk *c)
+{
+ struct vampire_state *s = talloc_get_type(private_data, struct vampire_state);
+ WERROR status;
+ const struct drsuapi_DsReplicaOIDMapping_Ctr *mapping_ctr;
+ uint32_t total_object_count;
+ uint32_t object_count;
+ struct drsuapi_DsReplicaObjectListItemEx *first_object;
+ uint32_t linked_attributes_count;
+ struct drsuapi_DsReplicaLinkedAttribute *linked_attributes;
+ const struct drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector;
+ struct dsdb_extended_replicated_objects *objs;
+ struct repsFromTo1 *s_dsa;
+ char *tmp_dns_name;
+ uint32_t i;
+
+ s_dsa = talloc_zero(s, struct repsFromTo1);
+ NT_STATUS_HAVE_NO_MEMORY(s_dsa);
+ s_dsa->other_info = talloc(s_dsa, struct repsFromTo1OtherInfo);
+ NT_STATUS_HAVE_NO_MEMORY(s_dsa->other_info);
+
+ switch (c->ctr_level) {
+ case 1:
+ mapping_ctr = &c->ctr1->mapping_ctr;
+ total_object_count = c->ctr1->total_object_count;
+ object_count = c->ctr1->object_count;
+ first_object = c->ctr1->first_object;
+ linked_attributes_count = 0;
+ linked_attributes = NULL;
+ s_dsa->highwatermark = c->ctr1->new_highwatermark;
+ s_dsa->source_dsa_obj_guid = c->ctr1->source_dsa_guid;
+ s_dsa->source_dsa_invocation_id = c->ctr1->source_dsa_invocation_id;
+ uptodateness_vector = NULL; /* TODO: map it */
+ break;
+ case 6:
+ mapping_ctr = &c->ctr6->mapping_ctr;
+ total_object_count = c->ctr6->total_object_count;
+ object_count = c->ctr6->object_count;
+ first_object = c->ctr6->first_object;
+ linked_attributes_count = c->ctr6->linked_attributes_count;
+ linked_attributes = c->ctr6->linked_attributes;
+ s_dsa->highwatermark = c->ctr6->new_highwatermark;
+ s_dsa->source_dsa_obj_guid = c->ctr6->source_dsa_guid;
+ s_dsa->source_dsa_invocation_id = c->ctr6->source_dsa_invocation_id;
+ uptodateness_vector = c->ctr6->uptodateness_vector;
+ break;
+ default:
+ return NT_STATUS_INVALID_PARAMETER;
}
- c->level = LIBNET_RPC_CONNECT_DC_INFO;
- if (r->in.binding_string) {
- c->in.binding = r->in.binding_string;
- c->in.name = NULL;
+ s_dsa->replica_flags = DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE
+ | DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP
+ | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS;
+ memset(s_dsa->schedule, 0x11, sizeof(s_dsa->schedule));
+
+ tmp_dns_name = GUID_string(s_dsa->other_info, &s_dsa->source_dsa_obj_guid);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name);
+ tmp_dns_name = talloc_asprintf_append_buffer(tmp_dns_name, "._msdcs.%s", c->forest->dns_name);
+ NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name);
+ s_dsa->other_info->dns_name = tmp_dns_name;
+
+ if (total_object_count) {
+ DEBUG(0,("Partition[%s] objects[%u/%u]\n",
+ c->partition->nc.dn, object_count, total_object_count));
} else {
- c->in.binding = NULL;
- c->in.name = cli_credentials_get_domain(machine_account);
+ DEBUG(0,("Partition[%s] objects[%u]\n",
+ c->partition->nc.dn, object_count));
}
-
- /* prepare connect to the NETLOGON pipe of PDC */
- c->in.dcerpc_iface = &ndr_table_netlogon;
-
- /* We must do this as the machine, not as any command-line
- * user. So we override the credentials in the
- * libnet_context */
- machine_net_ctx = talloc(samsync_ctx, struct libnet_context);
- if (!machine_net_ctx) {
- r->out.error_string = NULL;
- talloc_free(samsync_ctx);
- return NT_STATUS_NO_MEMORY;
+
+ status = dsdb_extended_replicated_objects_commit(s->ldb,
+ c->partition->nc.dn,
+ mapping_ctr,
+ object_count,
+ first_object,
+ linked_attributes_count,
+ linked_attributes,
+ s_dsa,
+ uptodateness_vector,
+ c->gensec_skey,
+ s, &objs);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(0,("Failed to commit objects: %s\n", win_errstr(status)));
+ return werror_to_ntstatus(status);
}
- *machine_net_ctx = *ctx;
- machine_net_ctx->cred = machine_account;
-
- /* connect to the NETLOGON pipe of the PDC */
- nt_status = libnet_RpcConnect(machine_net_ctx, samsync_ctx, c);
- if (!NT_STATUS_IS_OK(nt_status)) {
- if (r->in.binding_string) {
- r->out.error_string = talloc_asprintf(mem_ctx,
- "Connection to NETLOGON pipe of DC %s failed: %s",
- r->in.binding_string, c->out.error_string);
- } else {
- r->out.error_string = talloc_asprintf(mem_ctx,
- "Connection to NETLOGON pipe of DC for %s failed: %s",
- c->in.name, c->out.error_string);
+
+ if (lp_parm_bool(s->lp_ctx, NULL, "become dc", "dump objects", false)) {
+ for (i=0; i < objs->num_objects; i++) {
+ struct ldb_ldif ldif;
+ fprintf(stdout, "#\n");
+ ldif.changetype = LDB_CHANGETYPE_NONE;
+ ldif.msg = objs->objects[i].msg;
+ ldb_ldif_write_file(s->ldb, stdout, &ldif);
+ NDR_PRINT_DEBUG(replPropertyMetaDataBlob, objs->objects[i].meta_data);
}
- talloc_free(samsync_ctx);
- return nt_status;
}
+ talloc_free(s_dsa);
+ talloc_free(objs);
- /* This makes a new pipe, on which we can do schannel. We
- * should do this in the RpcConnect code, but the abstaction
- * layers do not suit yet */
+ for (i=0; i < linked_attributes_count; i++) {
+ const struct dsdb_attribute *sa;
+
+ if (!linked_attributes[i].identifier) {
+ return NT_STATUS_FOOBAR;
+ }
+
+ if (!linked_attributes[i].value.blob) {
+ return NT_STATUS_FOOBAR;
+ }
- nt_status = dcerpc_secondary_connection(c->out.dcerpc_pipe, &p,
- c->out.dcerpc_pipe->binding);
+ sa = dsdb_attribute_by_attributeID_id(s->schema,
+ linked_attributes[i].attid);
+ if (!sa) {
+ return NT_STATUS_FOOBAR;
+ }
- if (!NT_STATUS_IS_OK(nt_status)) {
- r->out.error_string = talloc_asprintf(mem_ctx,
- "Secondary connection to NETLOGON pipe of DC %s failed: %s",
- dcerpc_server_name(p), nt_errstr(nt_status));
- talloc_free(samsync_ctx);
- return nt_status;
+ if (lp_parm_bool(s->lp_ctx, NULL, "become dc", "dump objects", false)) {
+ DEBUG(0,("# %s\n", sa->lDAPDisplayName));
+ NDR_PRINT_DEBUG(drsuapi_DsReplicaLinkedAttribute, &linked_attributes[i]);
+ dump_data(0,
+ linked_attributes[i].value.blob->data,
+ linked_attributes[i].value.blob->length);
+ }
}
- nt_status = dcerpc_bind_auth_schannel(samsync_ctx, p, &ndr_table_netlogon,
- machine_account, ctx->lp_ctx, DCERPC_AUTH_LEVEL_PRIVACY);
+ return NT_STATUS_OK;
+}
- if (!NT_STATUS_IS_OK(nt_status)) {
- r->out.error_string = talloc_asprintf(mem_ctx,
- "SCHANNEL authentication to NETLOGON pipe of DC %s failed: %s",
- dcerpc_server_name(p), nt_errstr(nt_status));
- talloc_free(samsync_ctx);
- return nt_status;
+NTSTATUS libnet_Vampire(struct libnet_context *ctx, TALLOC_CTX *mem_ctx,
+ struct libnet_Vampire *r)
+{
+ struct libnet_JoinDomain *join;
+ struct libnet_set_join_secrets *set_secrets;
+ struct libnet_BecomeDC b;
+ struct vampire_state *s;
+ struct ldb_message *msg;
+ int ldb_ret;
+ uint32_t i;
+ NTSTATUS status;
+
+ const char *account_name;
+ const char *netbios_name;
+
+ r->out.error_string = NULL;
+
+ s = talloc_zero(mem_ctx, struct vampire_state);
+ if (!s) {
+ return NT_STATUS_NO_MEMORY;
}
- state = talloc(samsync_ctx, struct libnet_SamSync_state);
- if (!state) {
+ s->lp_ctx = ctx->lp_ctx;
+ s->event_ctx = ctx->event_ctx;
+
+ join = talloc_zero(s, struct libnet_JoinDomain);
+ if (!join) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ if (r->in.netbios_name != NULL) {
+ netbios_name = r->in.netbios_name;
+ } else {
+ netbios_name = talloc_reference(join, lp_netbios_name(ctx->lp_ctx));
+ if (!netbios_name) {
+ r->out.error_string = NULL;
+ talloc_free(s);
+ return NT_STATUS_NO_MEMORY;
+ }
+ }
+
+ account_name = talloc_asprintf(join, "%s$", netbios_name);
+ if (!account_name) {
r->out.error_string = NULL;
- talloc_free(samsync_ctx);
- return nt_status;
- }
-
- state->domain_name = c->out.domain_name;
- state->domain_sid = c->out.domain_sid;
- state->realm = c->out.realm;
- state->domain_guid = c->out.guid;
- state->machine_net_ctx = machine_net_ctx;
- state->netlogon_pipe = p;
-
- /* initialise the callback layer. It may wish to contact the
- * server with ldap, now we know the name */
+ talloc_free(s);
+ return NT_STATUS_NO_MEMORY;
+ }
- if (r->in.init_fn) {
- char *error_string;
- nt_status = r->in.init_fn(samsync_ctx,
- r->in.fn_ctx,
- state,
- &error_string);
- if (!NT_STATUS_IS_OK(nt_status)) {
- r->out.error_string = talloc_steal(mem_ctx, error_string);
- talloc_free(samsync_ctx);
- return nt_status;
- }
+ join->in.domain_name = r->in.domain_name;
+ join->in.account_name = account_name;
+ join->in.netbios_name = netbios_name;
+ join->in.level = LIBNET_JOINDOMAIN_AUTOMATIC;
+ join->in.acct_type = ACB_WSTRUST;
+ join->in.recreate_account = false;
+ status = libnet_JoinDomain(ctx, join, join);
+ if (!NT_STATUS_IS_OK(status)) {
+ r->out.error_string = talloc_steal(mem_ctx, join->out.error_string);
+ talloc_free(s);
+ return status;
+ }
+
+ s->join = join;
+
+ s->targetdir = r->in.targetdir;
+
+ ZERO_STRUCT(b);
+ b.in.domain_dns_name = join->out.realm;
+ b.in.domain_netbios_name = join->out.domain_name;
+ b.in.domain_sid = join->out.domain_sid;
+ b.in.source_dsa_address = join->out.samr_binding->host;
+ b.in.dest_dsa_netbios_name = netbios_name;
+
+ b.in.callbacks.private_data = s;
+ b.in.callbacks.check_options = vampire_check_options;
+ b.in.callbacks.prepare_db = vampire_prepare_db;
+ b.in.callbacks.schema_chunk = vampire_schema_chunk;
+ b.in.callbacks.config_chunk = vampire_store_chunk;
+ b.in.callbacks.domain_chunk = vampire_store_chunk;
+
+ status = libnet_BecomeDC(ctx, s, &b);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("libnet_BecomeDC() failed - %s\n", nt_errstr(status));
+ talloc_free(s);
+ return status;
}
- /* get NETLOGON credentials */
+ msg = ldb_msg_new(s);
+ if (!msg) {
+ printf("ldb_msg_new() failed\n");
+ talloc_free(s);
+ return NT_STATUS_NO_MEMORY;
+ }
+ msg->dn = ldb_dn_new(msg, s->ldb, "@ROOTDSE");
+ if (!msg->dn) {
+ printf("ldb_msg_new(@ROOTDSE) failed\n");
+ talloc_free(s);
+ return NT_STATUS_NO_MEMORY;
+ }
- nt_status = dcerpc_schannel_creds(p->conn->security_state.generic_state, samsync_ctx, &creds);
- if (!NT_STATUS_IS_OK(nt_status)) {
- r->out.error_string = talloc_strdup(mem_ctx, "Could not obtain NETLOGON credentials from DCERPC/GENSEC layer");
- talloc_free(samsync_ctx);
- return nt_status;
+ ldb_ret = ldb_msg_add_string(msg, "isSynchronized", "TRUE");
+ if (ldb_ret != LDB_SUCCESS) {
+ printf("ldb_msg_add_string(msg, isSynchronized, TRUE) failed: %d\n", ldb_ret);
+ talloc_free(s);
+ return NT_STATUS_NO_MEMORY;
}
- /* Setup details for the synchronisation */
- dbsync.in.logon_server = talloc_asprintf(samsync_ctx, "\\\\%s", dcerpc_server_name(p));
- dbsync.in.computername = cli_credentials_get_workstation(machine_account);
- dbsync.in.preferredmaximumlength = (uint32_t)-1;
- ZERO_STRUCT(dbsync.in.return_authenticator);
+ for (i=0; i < msg->num_elements; i++) {
+ msg->elements[i].flags = LDB_FLAG_MOD_REPLACE;
+ }
- for (i=0;i< ARRAY_SIZE(database_ids); i++) {
- dbsync.in.sync_context = 0;
- dbsync.in.database_id = database_ids[i];
-
- do {
- int d;
- loop_ctx = talloc_named(samsync_ctx, 0, "DatabaseSync loop context");
- creds_client_authenticator(creds, &dbsync.in.credential);
-
- dbsync_nt_status = dcerpc_netr_DatabaseSync(p, loop_ctx, &dbsync);
- if (!NT_STATUS_IS_OK(dbsync_nt_status) &&
- !NT_STATUS_EQUAL(dbsync_nt_status, STATUS_MORE_ENTRIES)) {
- r->out.error_string = talloc_asprintf(mem_ctx, "DatabaseSync failed - %s", nt_errstr(nt_status));
- talloc_free(samsync_ctx);
- return nt_status;
- }
-
- if (!creds_client_check(creds, &dbsync.out.return_authenticator.cred)) {
- r->out.error_string = talloc_strdup(mem_ctx, "Credential chaining on incoming DatabaseSync failed");
- talloc_free(samsync_ctx);
- return NT_STATUS_ACCESS_DENIED;
- }
-
- dbsync.in.sync_context = dbsync.out.sync_context;
-
- /* For every single remote 'delta' entry: */
- for (d=0; d < dbsync.out.delta_enum_array->num_deltas; d++) {
- char *error_string = NULL;
- delta_ctx = talloc_named(loop_ctx, 0, "DatabaseSync delta context");
- /* 'Fix' elements, by decrypting and
- * de-obfuscating the data */
- nt_status = fix_delta(delta_ctx,
- creds,
- r->in.rid_crypt,
- dbsync.in.database_id,
- &dbsync.out.delta_enum_array->delta_enum[d],
- &error_string);
- if (!NT_STATUS_IS_OK(nt_status)) {
- r->out.error_string = talloc_steal(mem_ctx, error_string);
- talloc_free(samsync_ctx);
- return nt_status;
- }
+ printf("mark ROOTDSE with isSynchronized=TRUE\n");
+ ldb_ret = ldb_modify(s->ldb, msg);
+ if (ldb_ret != LDB_SUCCESS) {
+ printf("ldb_modify() failed: %d\n", ldb_ret);
+ talloc_free(s);
+ return NT_STATUS_INTERNAL_DB_ERROR;
+ }
- /* Now call the callback. This will
- * do something like print the data or
- * write to an ldb */
- nt_status = r->in.delta_fn(delta_ctx,
- r->in.fn_ctx,
- dbsync.in.database_id,
- &dbsync.out.delta_enum_array->delta_enum[d],
- &error_string);
- if (!NT_STATUS_IS_OK(nt_status)) {
- r->out.error_string = talloc_steal(mem_ctx, error_string);
- talloc_free(samsync_ctx);
- return nt_status;
- }
- talloc_free(delta_ctx);
- }
- talloc_free(loop_ctx);
- } while (NT_STATUS_EQUAL(dbsync_nt_status, STATUS_MORE_ENTRIES));
+ set_secrets = talloc_zero(s, struct libnet_set_join_secrets);
+ if (!set_secrets) {
+ return NT_STATUS_NO_MEMORY;
+ }
- if (!NT_STATUS_IS_OK(dbsync_nt_status)) {
- r->out.error_string = talloc_asprintf(mem_ctx, "libnet_SamSync_netlogon failed: unexpected inconsistancy. Should not get error %s here", nt_errstr(nt_status));
- talloc_free(samsync_ctx);
- return dbsync_nt_status;
- }
- nt_status = NT_STATUS_OK;
+ set_secrets->in.domain_name = join->out.domain_name;
+ set_secrets->in.realm = join->out.realm;
+ set_secrets->in.account_name = account_name;
+ set_secrets->in.netbios_name = netbios_name;
+ set_secrets->in.join_type = SEC_CHAN_BDC;
+ set_secrets->in.join_password = join->out.join_password;
+ set_secrets->in.kvno = join->out.kvno;
+ set_secrets->in.domain_sid = join->out.domain_sid;
+
+ status = libnet_set_join_secrets(ctx, set_secrets, set_secrets);
+ if (!NT_STATUS_IS_OK(status)) {
+ r->out.error_string = talloc_steal(mem_ctx, set_secrets->out.error_string);
+ talloc_free(s);
+ return status;
}
- talloc_free(samsync_ctx);
- return nt_status;
-}
+ r->out.domain_name = talloc_steal(r, join->out.domain_name);
+ r->out.domain_sid = talloc_steal(r, join->out.domain_sid);
+ talloc_free(s);
+
+ return NT_STATUS_OK;
+
+}
diff --git a/source4/libnet/libnet_vampire.h b/source4/libnet/libnet_vampire.h
index d2ac30fe14..5e0c7594b2 100644
--- a/source4/libnet/libnet_vampire.h
+++ b/source4/libnet/libnet_vampire.h
@@ -1,7 +1,9 @@
/*
Unix SMB/CIFS implementation.
-
+
+ Copyright (C) Stefan Metzmacher 2004
Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
+ Copyright (C) Brad Henry 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
@@ -17,68 +19,22 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "librpc/gen_ndr/netlogon.h"
-
-struct libnet_SamSync_state {
- struct libnet_context *machine_net_ctx;
- struct dcerpc_pipe *netlogon_pipe;
- const char *domain_name;
- const struct dom_sid *domain_sid;
- const char *realm;
- struct GUID *domain_guid;
-};
-
-/* struct and enum for doing a remote domain vampire dump */
-struct libnet_SamSync {
- struct {
- const char *binding_string;
- bool rid_crypt;
- NTSTATUS (*init_fn)(TALLOC_CTX *mem_ctx,
- void *private,
- struct libnet_SamSync_state *samsync_state,
- char **error_string);
- NTSTATUS (*delta_fn)(TALLOC_CTX *mem_ctx,
- void *private,
- enum netr_SamDatabaseID database,
- struct netr_DELTA_ENUM *delta,
- char **error_string);
- void *fn_ctx;
- struct cli_credentials *machine_account;
- } in;
- struct {
- const char *error_string;
- } out;
-};
-
-struct libnet_SamDump {
- struct {
- const char *binding_string;
- struct cli_credentials *machine_account;
- } in;
- struct {
- const char *error_string;
- } out;
-};
+#ifndef __LIBNET_VAMPIRE_H__
+#define __LIBNET_VAMPIRE_H__
-struct libnet_SamDump_keytab {
+struct libnet_Vampire {
struct {
- const char *binding_string;
- const char *keytab_name;
- struct cli_credentials *machine_account;
+ const char *domain_name;
+ const char *netbios_name;
+ const char *targetdir;
} in;
+
struct {
+ struct dom_sid *domain_sid;
+ const char *domain_name;
const char *error_string;
} out;
};
-struct libnet_samsync_ldb {
- struct {
- const char *binding_string;
- struct cli_credentials *machine_account;
- struct auth_session_info *session_info;
- } in;
- struct {
- const char *error_string;
- } out;
-};
+#endif /* __LIBNET_VAMPIRE_H__ */
diff --git a/source4/libnet/net.i b/source4/libnet/net.i
deleted file mode 100644
index aad008939f..0000000000
--- a/source4/libnet/net.i
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-%module(package="samba.net") net
-
-%{
-#include "includes.h"
-#include "libnet/libnet.h"
-#include "lib/events/events.h"
-#include "param/param.h"
-typedef struct libnet_context libnet;
-%}
-
-%import "../libcli/util/errors.i"
-%import "../lib/events/events.i"
-%import "../lib/talloc/talloc.i"
-%import "../param/param.i"
-
-%talloctype(libnet_context);
-
-typedef struct libnet_context {
- struct cli_credentials *cred;
- %extend {
- libnet(struct event_context *ev, struct loadparm_context *lp_ctx) {
- return libnet_context_init(ev, lp_ctx);
- }
- NTSTATUS samsync_ldb(TALLOC_CTX *mem_ctx, struct libnet_samsync_ldb *r);
- NTSTATUS DomainList(TALLOC_CTX *mem_ctx, struct libnet_DomainList *io);
- NTSTATUS DomainClose(TALLOC_CTX *mem_ctx, struct libnet_DomainClose *io);
- NTSTATUS DomainOpen(TALLOC_CTX *mem_ctx, struct libnet_DomainOpen *io);
- NTSTATUS LookupName(TALLOC_CTX *mem_ctx, struct libnet_LookupName *io);
- NTSTATUS LookupDCs(TALLOC_CTX *mem_ctx, struct libnet_LookupDCs *io);
- NTSTATUS LookupHost(TALLOC_CTX *mem_ctx, struct libnet_Lookup *io);
- NTSTATUS Lookup(TALLOC_CTX *mem_ctx, struct libnet_Lookup *io);
- NTSTATUS ListShares(TALLOC_CTX *mem_ctx, struct libnet_ListShares *r);
- NTSTATUS AddShare(TALLOC_CTX *mem_ctx, struct libnet_AddShare *r);
- NTSTATUS DelShare(TALLOC_CTX *mem_ctx, struct libnet_DelShare *r);
- NTSTATUS GroupList(TALLOC_CTX *mem_ctx, struct libnet_GroupList *io);
- NTSTATUS GroupInfo(TALLOC_CTX *mem_ctx, struct libnet_GroupInfo *io);
- NTSTATUS UserList(TALLOC_CTX *mem_ctx, struct libnet_UserList *r);
- NTSTATUS UserInfo(TALLOC_CTX *mem_ctx, struct libnet_UserInfo *r);
- NTSTATUS ModifyUser(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r);
- NTSTATUS DeleteUser(TALLOC_CTX *mem_ctx, struct libnet_DeleteUser *r);
- NTSTATUS CreateUser(TALLOC_CTX *mem_ctx, struct libnet_CreateUser *r);
- NTSTATUS SamDump_keytab(TALLOC_CTX *mem_ctx, struct libnet_SamDump_keytab *r);
- NTSTATUS SamDump(TALLOC_CTX *mem_ctx, struct libnet_SamDump *r);
- NTSTATUS SamSync_netlogon(TALLOC_CTX *mem_ctx, struct libnet_SamSync *r);
- NTSTATUS UnbecomeDC(TALLOC_CTX *mem_ctx, struct libnet_UnbecomeDC *r);
- NTSTATUS BecomeDC(TALLOC_CTX *mem_ctx, struct libnet_BecomeDC *r);
- NTSTATUS JoinSite(struct ldb_context *remote_ldb, struct libnet_JoinDomain *libnet_r);
- NTSTATUS JoinDomain(TALLOC_CTX *mem_ctx, struct libnet_JoinDomain *r);
- NTSTATUS Join(TALLOC_CTX *mem_ctx, struct libnet_Join *r);
- NTSTATUS RpcConnect(TALLOC_CTX *mem_ctx, struct libnet_RpcConnect *r);
- NTSTATUS RemoteTOD(TALLOC_CTX *mem_ctx, union libnet_RemoteTOD *r);
- NTSTATUS ChangePassword(TALLOC_CTX *mem_ctx, union libnet_ChangePassword *r);
- NTSTATUS SetPassword(TALLOC_CTX *mem_ctx, union libnet_SetPassword *r);
- }
-} libnet;
diff --git a/source4/libnet/net.py b/source4/libnet/net.py
deleted file mode 100644
index ae659b8449..0000000000
--- a/source4/libnet/net.py
+++ /dev/null
@@ -1,103 +0,0 @@
-# This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.33
-#
-# Don't modify this file, modify the SWIG interface instead.
-
-import _net
-import new
-new_instancemethod = new.instancemethod
-try:
- _swig_property = property
-except NameError:
- pass # Python < 2.2 doesn't have 'property'.
-def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
- if (name == "thisown"): return self.this.own(value)
- if (name == "this"):
- if type(value).__name__ == 'PySwigObject':
- self.__dict__[name] = value
- return
- method = class_type.__swig_setmethods__.get(name,None)
- if method: return method(self,value)
- if (not static) or hasattr(self,name):
- self.__dict__[name] = value
- else:
- raise AttributeError("You cannot add attributes to %s" % self)
-
-def _swig_setattr(self,class_type,name,value):
- return _swig_setattr_nondynamic(self,class_type,name,value,0)
-
-def _swig_getattr(self,class_type,name):
- if (name == "thisown"): return self.this.own()
- method = class_type.__swig_getmethods__.get(name,None)
- if method: return method(self)
- raise AttributeError,name
-
-def _swig_repr(self):
- try: strthis = "proxy of " + self.this.__repr__()
- except: strthis = ""
- return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
-
-import types
-try:
- _object = types.ObjectType
- _newclass = 1
-except AttributeError:
- class _object : pass
- _newclass = 0
-del types
-
-
-def _swig_setattr_nondynamic_method(set):
- def set_attr(self,name,value):
- if (name == "thisown"): return self.this.own(value)
- if hasattr(self,name) or (name == "this"):
- set(self,name,value)
- else:
- raise AttributeError("You cannot add attributes to %s" % self)
- return set_attr
-
-
-import events
-import param
-class libnet(object):
- thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
- __repr__ = _swig_repr
- cred = _swig_property(_net.libnet_cred_get, _net.libnet_cred_set)
- def __init__(self, *args, **kwargs):
- _net.libnet_swiginit(self,_net.new_libnet(*args, **kwargs))
- __swig_destroy__ = _net.delete_libnet
-libnet.samsync_ldb = new_instancemethod(_net.libnet_samsync_ldb,None,libnet)
-libnet.DomainList = new_instancemethod(_net.libnet_DomainList,None,libnet)
-libnet.DomainClose = new_instancemethod(_net.libnet_DomainClose,None,libnet)
-libnet.DomainOpen = new_instancemethod(_net.libnet_DomainOpen,None,libnet)
-libnet.LookupName = new_instancemethod(_net.libnet_LookupName,None,libnet)
-libnet.LookupDCs = new_instancemethod(_net.libnet_LookupDCs,None,libnet)
-libnet.LookupHost = new_instancemethod(_net.libnet_LookupHost,None,libnet)
-libnet.Lookup = new_instancemethod(_net.libnet_Lookup,None,libnet)
-libnet.ListShares = new_instancemethod(_net.libnet_ListShares,None,libnet)
-libnet.AddShare = new_instancemethod(_net.libnet_AddShare,None,libnet)
-libnet.DelShare = new_instancemethod(_net.libnet_DelShare,None,libnet)
-libnet.GroupList = new_instancemethod(_net.libnet_GroupList,None,libnet)
-libnet.GroupInfo = new_instancemethod(_net.libnet_GroupInfo,None,libnet)
-libnet.UserList = new_instancemethod(_net.libnet_UserList,None,libnet)
-libnet.UserInfo = new_instancemethod(_net.libnet_UserInfo,None,libnet)
-libnet.ModifyUser = new_instancemethod(_net.libnet_ModifyUser,None,libnet)
-libnet.DeleteUser = new_instancemethod(_net.libnet_DeleteUser,None,libnet)
-libnet.CreateUser = new_instancemethod(_net.libnet_CreateUser,None,libnet)
-libnet.SamDump_keytab = new_instancemethod(_net.libnet_SamDump_keytab,None,libnet)
-libnet.SamDump = new_instancemethod(_net.libnet_SamDump,None,libnet)
-libnet.SamSync_netlogon = new_instancemethod(_net.libnet_SamSync_netlogon,None,libnet)
-libnet.UnbecomeDC = new_instancemethod(_net.libnet_UnbecomeDC,None,libnet)
-libnet.BecomeDC = new_instancemethod(_net.libnet_BecomeDC,None,libnet)
-libnet.JoinSite = new_instancemethod(_net.libnet_JoinSite,None,libnet)
-libnet.JoinDomain = new_instancemethod(_net.libnet_JoinDomain,None,libnet)
-libnet.Join = new_instancemethod(_net.libnet_Join,None,libnet)
-libnet.RpcConnect = new_instancemethod(_net.libnet_RpcConnect,None,libnet)
-libnet.RemoteTOD = new_instancemethod(_net.libnet_RemoteTOD,None,libnet)
-libnet.ChangePassword = new_instancemethod(_net.libnet_ChangePassword,None,libnet)
-libnet.SetPassword = new_instancemethod(_net.libnet_SetPassword,None,libnet)
-libnet_swigregister = _net.libnet_swigregister
-libnet_swigregister(libnet)
-
-
-
diff --git a/source4/libnet/net_wrap.c b/source4/libnet/net_wrap.c
deleted file mode 100644
index 29b30a87c2..0000000000
--- a/source4/libnet/net_wrap.c
+++ /dev/null
@@ -1,4711 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.33
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-#define SWIGPYTHON
-#define SWIG_PYTHON_NO_BUILD_NONE
-/* -----------------------------------------------------------------------------
- * This section contains generic SWIG labels for method/variable
- * declarations/attributes, and other compiler dependent labels.
- * ----------------------------------------------------------------------------- */
-
-/* template workaround for compilers that cannot correctly implement the C++ standard */
-#ifndef SWIGTEMPLATEDISAMBIGUATOR
-# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
-# define SWIGTEMPLATEDISAMBIGUATOR template
-# elif defined(__HP_aCC)
-/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
-/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
-# define SWIGTEMPLATEDISAMBIGUATOR template
-# else
-# define SWIGTEMPLATEDISAMBIGUATOR
-# endif
-#endif
-
-/* inline attribute */
-#ifndef SWIGINLINE
-# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
-# define SWIGINLINE inline
-# else
-# define SWIGINLINE
-# endif
-#endif
-
-/* attribute recognised by some compilers to avoid 'unused' warnings */
-#ifndef SWIGUNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define SWIGUNUSED __attribute__ ((__unused__))
-# else
-# define SWIGUNUSED
-# endif
-# elif defined(__ICC)
-# define SWIGUNUSED __attribute__ ((__unused__))
-# else
-# define SWIGUNUSED
-# endif
-#endif
-
-#ifndef SWIGUNUSEDPARM
-# ifdef __cplusplus
-# define SWIGUNUSEDPARM(p)
-# else
-# define SWIGUNUSEDPARM(p) p SWIGUNUSED
-# endif
-#endif
-
-/* internal SWIG method */
-#ifndef SWIGINTERN
-# define SWIGINTERN static SWIGUNUSED
-#endif
-
-/* internal inline SWIG method */
-#ifndef SWIGINTERNINLINE
-# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
-#endif
-
-/* exporting methods */
-#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
-# ifndef GCC_HASCLASSVISIBILITY
-# define GCC_HASCLASSVISIBILITY
-# endif
-#endif
-
-#ifndef SWIGEXPORT
-# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-# if defined(STATIC_LINKED)
-# define SWIGEXPORT
-# else
-# define SWIGEXPORT __declspec(dllexport)
-# endif
-# else
-# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
-# define SWIGEXPORT __attribute__ ((visibility("default")))
-# else
-# define SWIGEXPORT
-# endif
-# endif
-#endif
-
-/* calling conventions for Windows */
-#ifndef SWIGSTDCALL
-# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-# define SWIGSTDCALL __stdcall
-# else
-# define SWIGSTDCALL
-# endif
-#endif
-
-/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
-#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
-# define _CRT_SECURE_NO_DEPRECATE
-#endif
-
-/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
-#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
-# define _SCL_SECURE_NO_DEPRECATE
-#endif
-
-
-
-/* Python.h has to appear first */
-#include <Python.h>
-
-/* -----------------------------------------------------------------------------
- * swigrun.swg
- *
- * This file contains generic CAPI SWIG runtime support for pointer
- * type checking.
- * ----------------------------------------------------------------------------- */
-
-/* This should only be incremented when either the layout of swig_type_info changes,
- or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "3"
-
-/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
-#ifdef SWIG_TYPE_TABLE
-# define SWIG_QUOTE_STRING(x) #x
-# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
-# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
-#else
-# define SWIG_TYPE_TABLE_NAME
-#endif
-
-/*
- You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
- creating a static or dynamic library from the swig runtime code.
- In 99.9% of the cases, swig just needs to declare them as 'static'.
-
- But only do this if is strictly necessary, ie, if you have problems
- with your compiler or so.
-*/
-
-#ifndef SWIGRUNTIME
-# define SWIGRUNTIME SWIGINTERN
-#endif
-
-#ifndef SWIGRUNTIMEINLINE
-# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
-#endif
-
-/* Generic buffer size */
-#ifndef SWIG_BUFFER_SIZE
-# define SWIG_BUFFER_SIZE 1024
-#endif
-
-/* Flags for pointer conversions */
-#define SWIG_POINTER_DISOWN 0x1
-
-/* Flags for new pointer objects */
-#define SWIG_POINTER_OWN 0x1
-
-
-/*
- Flags/methods for returning states.
-
- The swig conversion methods, as ConvertPtr, return and integer
- that tells if the conversion was successful or not. And if not,
- an error code can be returned (see swigerrors.swg for the codes).
-
- Use the following macros/flags to set or process the returning
- states.
-
- In old swig versions, you usually write code as:
-
- if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
- // success code
- } else {
- //fail code
- }
-
- Now you can be more explicit as:
-
- int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
- if (SWIG_IsOK(res)) {
- // success code
- } else {
- // fail code
- }
-
- that seems to be the same, but now you can also do
-
- Type *ptr;
- int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
- if (SWIG_IsOK(res)) {
- // success code
- if (SWIG_IsNewObj(res) {
- ...
- delete *ptr;
- } else {
- ...
- }
- } else {
- // fail code
- }
-
- I.e., now SWIG_ConvertPtr can return new objects and you can
- identify the case and take care of the deallocation. Of course that
- requires also to SWIG_ConvertPtr to return new result values, as
-
- int SWIG_ConvertPtr(obj, ptr,...) {
- if (<obj is ok>) {
- if (<need new object>) {
- *ptr = <ptr to new allocated object>;
- return SWIG_NEWOBJ;
- } else {
- *ptr = <ptr to old object>;
- return SWIG_OLDOBJ;
- }
- } else {
- return SWIG_BADOBJ;
- }
- }
-
- Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
- more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
- swig errors code.
-
- Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
- allows to return the 'cast rank', for example, if you have this
-
- int food(double)
- int fooi(int);
-
- and you call
-
- food(1) // cast rank '1' (1 -> 1.0)
- fooi(1) // cast rank '0'
-
- just use the SWIG_AddCast()/SWIG_CheckState()
-
-
- */
-#define SWIG_OK (0)
-#define SWIG_ERROR (-1)
-#define SWIG_IsOK(r) (r >= 0)
-#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
-
-/* The CastRankLimit says how many bits are used for the cast rank */
-#define SWIG_CASTRANKLIMIT (1 << 8)
-/* The NewMask denotes the object was created (using new/malloc) */
-#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
-/* The TmpMask is for in/out typemaps that use temporal objects */
-#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
-/* Simple returning values */
-#define SWIG_BADOBJ (SWIG_ERROR)
-#define SWIG_OLDOBJ (SWIG_OK)
-#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
-#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
-/* Check, add and del mask methods */
-#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
-#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
-#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
-#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
-#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
-#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
-
-
-/* Cast-Rank Mode */
-#if defined(SWIG_CASTRANK_MODE)
-# ifndef SWIG_TypeRank
-# define SWIG_TypeRank unsigned long
-# endif
-# ifndef SWIG_MAXCASTRANK /* Default cast allowed */
-# define SWIG_MAXCASTRANK (2)
-# endif
-# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
-# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
-SWIGINTERNINLINE int SWIG_AddCast(int r) {
- return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
-}
-SWIGINTERNINLINE int SWIG_CheckState(int r) {
- return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
-}
-#else /* no cast-rank mode */
-# define SWIG_AddCast
-# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
-#endif
-
-
-
-
-#include <string.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void *(*swig_converter_func)(void *);
-typedef struct swig_type_info *(*swig_dycast_func)(void **);
-
-/* Structure to store inforomation on one type */
-typedef struct swig_type_info {
- const char *name; /* mangled name of this type */
- const char *str; /* human readable name of this type */
- swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
- struct swig_cast_info *cast; /* linked list of types that can cast into this type */
- void *clientdata; /* language specific type data */
- int owndata; /* flag if the structure owns the clientdata */
-} swig_type_info;
-
-/* Structure to store a type and conversion function used for casting */
-typedef struct swig_cast_info {
- swig_type_info *type; /* pointer to type that is equivalent to this type */
- swig_converter_func converter; /* function to cast the void pointers */
- struct swig_cast_info *next; /* pointer to next cast in linked list */
- struct swig_cast_info *prev; /* pointer to the previous cast */
-} swig_cast_info;
-
-/* Structure used to store module information
- * Each module generates one structure like this, and the runtime collects
- * all of these structures and stores them in a circularly linked list.*/
-typedef struct swig_module_info {
- swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
- size_t size; /* Number of types in this module */
- struct swig_module_info *next; /* Pointer to next element in circularly linked list */
- swig_type_info **type_initial; /* Array of initially generated type structures */
- swig_cast_info **cast_initial; /* Array of initially generated casting structures */
- void *clientdata; /* Language specific module data */
-} swig_module_info;
-
-/*
- Compare two type names skipping the space characters, therefore
- "char*" == "char *" and "Class<int>" == "Class<int >", etc.
-
- Return 0 when the two name types are equivalent, as in
- strncmp, but skipping ' '.
-*/
-SWIGRUNTIME int
-SWIG_TypeNameComp(const char *f1, const char *l1,
- const char *f2, const char *l2) {
- for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
- while ((*f1 == ' ') && (f1 != l1)) ++f1;
- while ((*f2 == ' ') && (f2 != l2)) ++f2;
- if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
- }
- return (int)((l1 - f1) - (l2 - f2));
-}
-
-/*
- Check type equivalence in a name list like <name1>|<name2>|...
- Return 0 if not equal, 1 if equal
-*/
-SWIGRUNTIME int
-SWIG_TypeEquiv(const char *nb, const char *tb) {
- int equiv = 0;
- const char* te = tb + strlen(tb);
- const char* ne = nb;
- while (!equiv && *ne) {
- for (nb = ne; *ne; ++ne) {
- if (*ne == '|') break;
- }
- equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
- if (*ne) ++ne;
- }
- return equiv;
-}
-
-/*
- Check type equivalence in a name list like <name1>|<name2>|...
- Return 0 if equal, -1 if nb < tb, 1 if nb > tb
-*/
-SWIGRUNTIME int
-SWIG_TypeCompare(const char *nb, const char *tb) {
- int equiv = 0;
- const char* te = tb + strlen(tb);
- const char* ne = nb;
- while (!equiv && *ne) {
- for (nb = ne; *ne; ++ne) {
- if (*ne == '|') break;
- }
- equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
- if (*ne) ++ne;
- }
- return equiv;
-}
-
-
-/* think of this as a c++ template<> or a scheme macro */
-#define SWIG_TypeCheck_Template(comparison, ty) \
- if (ty) { \
- swig_cast_info *iter = ty->cast; \
- while (iter) { \
- if (comparison) { \
- if (iter == ty->cast) return iter; \
- /* Move iter to the top of the linked list */ \
- iter->prev->next = iter->next; \
- if (iter->next) \
- iter->next->prev = iter->prev; \
- iter->next = ty->cast; \
- iter->prev = 0; \
- if (ty->cast) ty->cast->prev = iter; \
- ty->cast = iter; \
- return iter; \
- } \
- iter = iter->next; \
- } \
- } \
- return 0
-
-/*
- Check the typename
-*/
-SWIGRUNTIME swig_cast_info *
-SWIG_TypeCheck(const char *c, swig_type_info *ty) {
- SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
-}
-
-/* Same as previous function, except strcmp is replaced with a pointer comparison */
-SWIGRUNTIME swig_cast_info *
-SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
- SWIG_TypeCheck_Template(iter->type == from, into);
-}
-
-/*
- Cast a pointer up an inheritance hierarchy
-*/
-SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
- return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
-}
-
-/*
- Dynamic pointer casting. Down an inheritance hierarchy
-*/
-SWIGRUNTIME swig_type_info *
-SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
- swig_type_info *lastty = ty;
- if (!ty || !ty->dcast) return ty;
- while (ty && (ty->dcast)) {
- ty = (*ty->dcast)(ptr);
- if (ty) lastty = ty;
- }
- return lastty;
-}
-
-/*
- Return the name associated with this type
-*/
-SWIGRUNTIMEINLINE const char *
-SWIG_TypeName(const swig_type_info *ty) {
- return ty->name;
-}
-
-/*
- Return the pretty name associated with this type,
- that is an unmangled type name in a form presentable to the user.
-*/
-SWIGRUNTIME const char *
-SWIG_TypePrettyName(const swig_type_info *type) {
- /* The "str" field contains the equivalent pretty names of the
- type, separated by vertical-bar characters. We choose
- to print the last name, as it is often (?) the most
- specific. */
- if (!type) return NULL;
- if (type->str != NULL) {
- const char *last_name = type->str;
- const char *s;
- for (s = type->str; *s; s++)
- if (*s == '|') last_name = s+1;
- return last_name;
- }
- else
- return type->name;
-}
-
-/*
- Set the clientdata field for a type
-*/
-SWIGRUNTIME void
-SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
- swig_cast_info *cast = ti->cast;
- /* if (ti->clientdata == clientdata) return; */
- ti->clientdata = clientdata;
-
- while (cast) {
- if (!cast->converter) {
- swig_type_info *tc = cast->type;
- if (!tc->clientdata) {
- SWIG_TypeClientData(tc, clientdata);
- }
- }
- cast = cast->next;
- }
-}
-SWIGRUNTIME void
-SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
- SWIG_TypeClientData(ti, clientdata);
- ti->owndata = 1;
-}
-
-/*
- Search for a swig_type_info structure only by mangled name
- Search is a O(log #types)
-
- We start searching at module start, and finish searching when start == end.
- Note: if start == end at the beginning of the function, we go all the way around
- the circular list.
-*/
-SWIGRUNTIME swig_type_info *
-SWIG_MangledTypeQueryModule(swig_module_info *start,
- swig_module_info *end,
- const char *name) {
- swig_module_info *iter = start;
- do {
- if (iter->size) {
- register size_t l = 0;
- register size_t r = iter->size - 1;
- do {
- /* since l+r >= 0, we can (>> 1) instead (/ 2) */
- register size_t i = (l + r) >> 1;
- const char *iname = iter->types[i]->name;
- if (iname) {
- register int compare = strcmp(name, iname);
- if (compare == 0) {
- return iter->types[i];
- } else if (compare < 0) {
- if (i) {
- r = i - 1;
- } else {
- break;
- }
- } else if (compare > 0) {
- l = i + 1;
- }
- } else {
- break; /* should never happen */
- }
- } while (l <= r);
- }
- iter = iter->next;
- } while (iter != end);
- return 0;
-}
-
-/*
- Search for a swig_type_info structure for either a mangled name or a human readable name.
- It first searches the mangled names of the types, which is a O(log #types)
- If a type is not found it then searches the human readable names, which is O(#types).
-
- We start searching at module start, and finish searching when start == end.
- Note: if start == end at the beginning of the function, we go all the way around
- the circular list.
-*/
-SWIGRUNTIME swig_type_info *
-SWIG_TypeQueryModule(swig_module_info *start,
- swig_module_info *end,
- const char *name) {
- /* STEP 1: Search the name field using binary search */
- swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
- if (ret) {
- return ret;
- } else {
- /* STEP 2: If the type hasn't been found, do a complete search
- of the str field (the human readable name) */
- swig_module_info *iter = start;
- do {
- register size_t i = 0;
- for (; i < iter->size; ++i) {
- if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
- return iter->types[i];
- }
- iter = iter->next;
- } while (iter != end);
- }
-
- /* neither found a match */
- return 0;
-}
-
-/*
- Pack binary data into a string
-*/
-SWIGRUNTIME char *
-SWIG_PackData(char *c, void *ptr, size_t sz) {
- static const char hex[17] = "0123456789abcdef";
- register const unsigned char *u = (unsigned char *) ptr;
- register const unsigned char *eu = u + sz;
- for (; u != eu; ++u) {
- register unsigned char uu = *u;
- *(c++) = hex[(uu & 0xf0) >> 4];
- *(c++) = hex[uu & 0xf];
- }
- return c;
-}
-
-/*
- Unpack binary data from a string
-*/
-SWIGRUNTIME const char *
-SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
- register unsigned char *u = (unsigned char *) ptr;
- register const unsigned char *eu = u + sz;
- for (; u != eu; ++u) {
- register char d = *(c++);
- register unsigned char uu;
- if ((d >= '0') && (d <= '9'))
- uu = ((d - '0') << 4);
- else if ((d >= 'a') && (d <= 'f'))
- uu = ((d - ('a'-10)) << 4);
- else
- return (char *) 0;
- d = *(c++);
- if ((d >= '0') && (d <= '9'))
- uu |= (d - '0');
- else if ((d >= 'a') && (d <= 'f'))
- uu |= (d - ('a'-10));
- else
- return (char *) 0;
- *u = uu;
- }
- return c;
-}
-
-/*
- Pack 'void *' into a string buffer.
-*/
-SWIGRUNTIME char *
-SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
- char *r = buff;
- if ((2*sizeof(void *) + 2) > bsz) return 0;
- *(r++) = '_';
- r = SWIG_PackData(r,&ptr,sizeof(void *));
- if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
- strcpy(r,name);
- return buff;
-}
-
-SWIGRUNTIME const char *
-SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
- if (*c != '_') {
- if (strcmp(c,"NULL") == 0) {
- *ptr = (void *) 0;
- return name;
- } else {
- return 0;
- }
- }
- return SWIG_UnpackData(++c,ptr,sizeof(void *));
-}
-
-SWIGRUNTIME char *
-SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
- char *r = buff;
- size_t lname = (name ? strlen(name) : 0);
- if ((2*sz + 2 + lname) > bsz) return 0;
- *(r++) = '_';
- r = SWIG_PackData(r,ptr,sz);
- if (lname) {
- strncpy(r,name,lname+1);
- } else {
- *r = 0;
- }
- return buff;
-}
-
-SWIGRUNTIME const char *
-SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
- if (*c != '_') {
- if (strcmp(c,"NULL") == 0) {
- memset(ptr,0,sz);
- return name;
- } else {
- return 0;
- }
- }
- return SWIG_UnpackData(++c,ptr,sz);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-/* Errors in SWIG */
-#define SWIG_UnknownError -1
-#define SWIG_IOError -2
-#define SWIG_RuntimeError -3
-#define SWIG_IndexError -4
-#define SWIG_TypeError -5
-#define SWIG_DivisionByZero -6
-#define SWIG_OverflowError -7
-#define SWIG_SyntaxError -8
-#define SWIG_ValueError -9
-#define SWIG_SystemError -10
-#define SWIG_AttributeError -11
-#define SWIG_MemoryError -12
-#define SWIG_NullReferenceError -13
-
-
-
-
-/* Add PyOS_snprintf for old Pythons */
-#if PY_VERSION_HEX < 0x02020000
-# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
-# define PyOS_snprintf _snprintf
-# else
-# define PyOS_snprintf snprintf
-# endif
-#endif
-
-/* A crude PyString_FromFormat implementation for old Pythons */
-#if PY_VERSION_HEX < 0x02020000
-
-#ifndef SWIG_PYBUFFER_SIZE
-# define SWIG_PYBUFFER_SIZE 1024
-#endif
-
-static PyObject *
-PyString_FromFormat(const char *fmt, ...) {
- va_list ap;
- char buf[SWIG_PYBUFFER_SIZE * 2];
- int res;
- va_start(ap, fmt);
- res = vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
- return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf);
-}
-#endif
-
-/* Add PyObject_Del for old Pythons */
-#if PY_VERSION_HEX < 0x01060000
-# define PyObject_Del(op) PyMem_DEL((op))
-#endif
-#ifndef PyObject_DEL
-# define PyObject_DEL PyObject_Del
-#endif
-
-/* A crude PyExc_StopIteration exception for old Pythons */
-#if PY_VERSION_HEX < 0x02020000
-# ifndef PyExc_StopIteration
-# define PyExc_StopIteration PyExc_RuntimeError
-# endif
-# ifndef PyObject_GenericGetAttr
-# define PyObject_GenericGetAttr 0
-# endif
-#endif
-/* Py_NotImplemented is defined in 2.1 and up. */
-#if PY_VERSION_HEX < 0x02010000
-# ifndef Py_NotImplemented
-# define Py_NotImplemented PyExc_RuntimeError
-# endif
-#endif
-
-
-/* A crude PyString_AsStringAndSize implementation for old Pythons */
-#if PY_VERSION_HEX < 0x02010000
-# ifndef PyString_AsStringAndSize
-# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;}
-# endif
-#endif
-
-/* PySequence_Size for old Pythons */
-#if PY_VERSION_HEX < 0x02000000
-# ifndef PySequence_Size
-# define PySequence_Size PySequence_Length
-# endif
-#endif
-
-
-/* PyBool_FromLong for old Pythons */
-#if PY_VERSION_HEX < 0x02030000
-static
-PyObject *PyBool_FromLong(long ok)
-{
- PyObject *result = ok ? Py_True : Py_False;
- Py_INCREF(result);
- return result;
-}
-#endif
-
-/* Py_ssize_t for old Pythons */
-/* This code is as recommended by: */
-/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */
-#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
-typedef int Py_ssize_t;
-# define PY_SSIZE_T_MAX INT_MAX
-# define PY_SSIZE_T_MIN INT_MIN
-#endif
-
-/* -----------------------------------------------------------------------------
- * error manipulation
- * ----------------------------------------------------------------------------- */
-
-SWIGRUNTIME PyObject*
-SWIG_Python_ErrorType(int code) {
- PyObject* type = 0;
- switch(code) {
- case SWIG_MemoryError:
- type = PyExc_MemoryError;
- break;
- case SWIG_IOError:
- type = PyExc_IOError;
- break;
- case SWIG_RuntimeError:
- type = PyExc_RuntimeError;
- break;
- case SWIG_IndexError:
- type = PyExc_IndexError;
- break;
- case SWIG_TypeError:
- type = PyExc_TypeError;
- break;
- case SWIG_DivisionByZero:
- type = PyExc_ZeroDivisionError;
- break;
- case SWIG_OverflowError:
- type = PyExc_OverflowError;
- break;
- case SWIG_SyntaxError:
- type = PyExc_SyntaxError;
- break;
- case SWIG_ValueError:
- type = PyExc_ValueError;
- break;
- case SWIG_SystemError:
- type = PyExc_SystemError;
- break;
- case SWIG_AttributeError:
- type = PyExc_AttributeError;
- break;
- default:
- type = PyExc_RuntimeError;
- }
- return type;
-}
-
-
-SWIGRUNTIME void
-SWIG_Python_AddErrorMsg(const char* mesg)
-{
- PyObject *type = 0;
- PyObject *value = 0;
- PyObject *traceback = 0;
-
- if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
- if (value) {
- PyObject *old_str = PyObject_Str(value);
- PyErr_Clear();
- Py_XINCREF(type);
- PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
- Py_DECREF(old_str);
- Py_DECREF(value);
- } else {
- PyErr_Format(PyExc_RuntimeError, mesg);
- }
-}
-
-
-
-#if defined(SWIG_PYTHON_NO_THREADS)
-# if defined(SWIG_PYTHON_THREADS)
-# undef SWIG_PYTHON_THREADS
-# endif
-#endif
-#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */
-# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL)
-# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */
-# define SWIG_PYTHON_USE_GIL
-# endif
-# endif
-# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */
-# ifndef SWIG_PYTHON_INITIALIZE_THREADS
-# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads()
-# endif
-# ifdef __cplusplus /* C++ code */
- class SWIG_Python_Thread_Block {
- bool status;
- PyGILState_STATE state;
- public:
- void end() { if (status) { PyGILState_Release(state); status = false;} }
- SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {}
- ~SWIG_Python_Thread_Block() { end(); }
- };
- class SWIG_Python_Thread_Allow {
- bool status;
- PyThreadState *save;
- public:
- void end() { if (status) { PyEval_RestoreThread(save); status = false; }}
- SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {}
- ~SWIG_Python_Thread_Allow() { end(); }
- };
-# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block
-# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end()
-# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow
-# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end()
-# else /* C code */
-# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure()
-# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block)
-# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread()
-# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow)
-# endif
-# else /* Old thread way, not implemented, user must provide it */
-# if !defined(SWIG_PYTHON_INITIALIZE_THREADS)
-# define SWIG_PYTHON_INITIALIZE_THREADS
-# endif
-# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK)
-# define SWIG_PYTHON_THREAD_BEGIN_BLOCK
-# endif
-# if !defined(SWIG_PYTHON_THREAD_END_BLOCK)
-# define SWIG_PYTHON_THREAD_END_BLOCK
-# endif
-# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW)
-# define SWIG_PYTHON_THREAD_BEGIN_ALLOW
-# endif
-# if !defined(SWIG_PYTHON_THREAD_END_ALLOW)
-# define SWIG_PYTHON_THREAD_END_ALLOW
-# endif
-# endif
-#else /* No thread support */
-# define SWIG_PYTHON_INITIALIZE_THREADS
-# define SWIG_PYTHON_THREAD_BEGIN_BLOCK
-# define SWIG_PYTHON_THREAD_END_BLOCK
-# define SWIG_PYTHON_THREAD_BEGIN_ALLOW
-# define SWIG_PYTHON_THREAD_END_ALLOW
-#endif
-
-/* -----------------------------------------------------------------------------
- * Python API portion that goes into the runtime
- * ----------------------------------------------------------------------------- */
-
-#ifdef __cplusplus
-extern "C" {
-#if 0
-} /* cc-mode */
-#endif
-#endif
-
-/* -----------------------------------------------------------------------------
- * Constant declarations
- * ----------------------------------------------------------------------------- */
-
-/* Constant Types */
-#define SWIG_PY_POINTER 4
-#define SWIG_PY_BINARY 5
-
-/* Constant information structure */
-typedef struct swig_const_info {
- int type;
- char *name;
- long lvalue;
- double dvalue;
- void *pvalue;
- swig_type_info **ptype;
-} swig_const_info;
-
-#ifdef __cplusplus
-#if 0
-{ /* cc-mode */
-#endif
-}
-#endif
-
-
-/* -----------------------------------------------------------------------------
- * See the LICENSE file for information on copyright, usage and redistribution
- * of SWIG, and the README file for authors - http://www.swig.org/release.html.
- *
- * pyrun.swg
- *
- * This file contains the runtime support for Python modules
- * and includes code for managing global variables and pointer
- * type checking.
- *
- * ----------------------------------------------------------------------------- */
-
-/* Common SWIG API */
-
-/* for raw pointers */
-#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
-#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags)
-#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)
-#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags)
-#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty)
-#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src)
-#define swig_owntype int
-
-/* for raw packed data */
-#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
-#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
-
-/* for class or struct pointers */
-#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags)
-#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags)
-
-/* for C or C++ function pointers */
-#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type)
-#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0)
-
-/* for C++ member pointers, ie, member methods */
-#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
-#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
-
-
-/* Runtime API */
-
-#define SWIG_GetModule(clientdata) SWIG_Python_GetModule()
-#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
-#define SWIG_NewClientData(obj) PySwigClientData_New(obj)
-
-#define SWIG_SetErrorObj SWIG_Python_SetErrorObj
-#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg
-#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
-#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg)
-#define SWIG_fail goto fail
-
-
-/* Runtime API implementation */
-
-/* Error manipulation */
-
-SWIGINTERN void
-SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
- SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- PyErr_SetObject(errtype, obj);
- Py_DECREF(obj);
- SWIG_PYTHON_THREAD_END_BLOCK;
-}
-
-SWIGINTERN void
-SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
- SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- PyErr_SetString(errtype, (char *) msg);
- SWIG_PYTHON_THREAD_END_BLOCK;
-}
-
-#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj)
-
-/* Set a constant value */
-
-SWIGINTERN void
-SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {
- PyDict_SetItemString(d, (char*) name, obj);
- Py_DECREF(obj);
-}
-
-/* Append a value to the result obj */
-
-SWIGINTERN PyObject*
-SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
-#if !defined(SWIG_PYTHON_OUTPUT_TUPLE)
- if (!result) {
- result = obj;
- } else if (result == Py_None) {
- Py_DECREF(result);
- result = obj;
- } else {
- if (!PyList_Check(result)) {
- PyObject *o2 = result;
- result = PyList_New(1);
- PyList_SetItem(result, 0, o2);
- }
- PyList_Append(result,obj);
- Py_DECREF(obj);
- }
- return result;
-#else
- PyObject* o2;
- PyObject* o3;
- if (!result) {
- result = obj;
- } else if (result == Py_None) {
- Py_DECREF(result);
- result = obj;
- } else {
- if (!PyTuple_Check(result)) {
- o2 = result;
- result = PyTuple_New(1);
- PyTuple_SET_ITEM(result, 0, o2);
- }
- o3 = PyTuple_New(1);
- PyTuple_SET_ITEM(o3, 0, obj);
- o2 = result;
- result = PySequence_Concat(o2, o3);
- Py_DECREF(o2);
- Py_DECREF(o3);
- }
- return result;
-#endif
-}
-
-/* Unpack the argument tuple */
-
-SWIGINTERN int
-SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
-{
- if (!args) {
- if (!min && !max) {
- return 1;
- } else {
- PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none",
- name, (min == max ? "" : "at least "), (int)min);
- return 0;
- }
- }
- if (!PyTuple_Check(args)) {
- PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
- return 0;
- } else {
- register Py_ssize_t l = PyTuple_GET_SIZE(args);
- if (l < min) {
- PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
- name, (min == max ? "" : "at least "), (int)min, (int)l);
- return 0;
- } else if (l > max) {
- PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
- name, (min == max ? "" : "at most "), (int)max, (int)l);
- return 0;
- } else {
- register int i;
- for (i = 0; i < l; ++i) {
- objs[i] = PyTuple_GET_ITEM(args, i);
- }
- for (; l < max; ++l) {
- objs[l] = 0;
- }
- return i + 1;
- }
- }
-}
-
-/* A functor is a function object with one single object argument */
-#if PY_VERSION_HEX >= 0x02020000
-#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL);
-#else
-#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj);
-#endif
-
-/*
- Helper for static pointer initialization for both C and C++ code, for example
- static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...);
-*/
-#ifdef __cplusplus
-#define SWIG_STATIC_POINTER(var) var
-#else
-#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var
-#endif
-
-/* -----------------------------------------------------------------------------
- * Pointer declarations
- * ----------------------------------------------------------------------------- */
-
-/* Flags for new pointer objects */
-#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1)
-#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN)
-
-#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1)
-
-#ifdef __cplusplus
-extern "C" {
-#if 0
-} /* cc-mode */
-#endif
-#endif
-
-/* How to access Py_None */
-#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
-# ifndef SWIG_PYTHON_NO_BUILD_NONE
-# ifndef SWIG_PYTHON_BUILD_NONE
-# define SWIG_PYTHON_BUILD_NONE
-# endif
-# endif
-#endif
-
-#ifdef SWIG_PYTHON_BUILD_NONE
-# ifdef Py_None
-# undef Py_None
-# define Py_None SWIG_Py_None()
-# endif
-SWIGRUNTIMEINLINE PyObject *
-_SWIG_Py_None(void)
-{
- PyObject *none = Py_BuildValue((char*)"");
- Py_DECREF(none);
- return none;
-}
-SWIGRUNTIME PyObject *
-SWIG_Py_None(void)
-{
- static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
- return none;
-}
-#endif
-
-/* The python void return value */
-
-SWIGRUNTIMEINLINE PyObject *
-SWIG_Py_Void(void)
-{
- PyObject *none = Py_None;
- Py_INCREF(none);
- return none;
-}
-
-/* PySwigClientData */
-
-typedef struct {
- PyObject *klass;
- PyObject *newraw;
- PyObject *newargs;
- PyObject *destroy;
- int delargs;
- int implicitconv;
-} PySwigClientData;
-
-SWIGRUNTIMEINLINE int
-SWIG_Python_CheckImplicit(swig_type_info *ty)
-{
- PySwigClientData *data = (PySwigClientData *)ty->clientdata;
- return data ? data->implicitconv : 0;
-}
-
-SWIGRUNTIMEINLINE PyObject *
-SWIG_Python_ExceptionType(swig_type_info *desc) {
- PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0;
- PyObject *klass = data ? data->klass : 0;
- return (klass ? klass : PyExc_RuntimeError);
-}
-
-
-SWIGRUNTIME PySwigClientData *
-PySwigClientData_New(PyObject* obj)
-{
- if (!obj) {
- return 0;
- } else {
- PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData));
- /* the klass element */
- data->klass = obj;
- Py_INCREF(data->klass);
- /* the newraw method and newargs arguments used to create a new raw instance */
- if (PyClass_Check(obj)) {
- data->newraw = 0;
- data->newargs = obj;
- Py_INCREF(obj);
- } else {
-#if (PY_VERSION_HEX < 0x02020000)
- data->newraw = 0;
-#else
- data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
-#endif
- if (data->newraw) {
- Py_INCREF(data->newraw);
- data->newargs = PyTuple_New(1);
- PyTuple_SetItem(data->newargs, 0, obj);
- } else {
- data->newargs = obj;
- }
- Py_INCREF(data->newargs);
- }
- /* the destroy method, aka as the C++ delete method */
- data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
- if (PyErr_Occurred()) {
- PyErr_Clear();
- data->destroy = 0;
- }
- if (data->destroy) {
- int flags;
- Py_INCREF(data->destroy);
- flags = PyCFunction_GET_FLAGS(data->destroy);
-#ifdef METH_O
- data->delargs = !(flags & (METH_O));
-#else
- data->delargs = 0;
-#endif
- } else {
- data->delargs = 0;
- }
- data->implicitconv = 0;
- return data;
- }
-}
-
-SWIGRUNTIME void
-PySwigClientData_Del(PySwigClientData* data)
-{
- Py_XDECREF(data->newraw);
- Py_XDECREF(data->newargs);
- Py_XDECREF(data->destroy);
-}
-
-/* =============== PySwigObject =====================*/
-
-typedef struct {
- PyObject_HEAD
- void *ptr;
- swig_type_info *ty;
- int own;
- PyObject *next;
-} PySwigObject;
-
-SWIGRUNTIME PyObject *
-PySwigObject_long(PySwigObject *v)
-{
- return PyLong_FromVoidPtr(v->ptr);
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_format(const char* fmt, PySwigObject *v)
-{
- PyObject *res = NULL;
- PyObject *args = PyTuple_New(1);
- if (args) {
- if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) {
- PyObject *ofmt = PyString_FromString(fmt);
- if (ofmt) {
- res = PyString_Format(ofmt,args);
- Py_DECREF(ofmt);
- }
- Py_DECREF(args);
- }
- }
- return res;
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_oct(PySwigObject *v)
-{
- return PySwigObject_format("%o",v);
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_hex(PySwigObject *v)
-{
- return PySwigObject_format("%x",v);
-}
-
-SWIGRUNTIME PyObject *
-#ifdef METH_NOARGS
-PySwigObject_repr(PySwigObject *v)
-#else
-PySwigObject_repr(PySwigObject *v, PyObject *args)
-#endif
-{
- const char *name = SWIG_TypePrettyName(v->ty);
- PyObject *hex = PySwigObject_hex(v);
- PyObject *repr = PyString_FromFormat("<Swig Object of type '%s' at 0x%s>", name, PyString_AsString(hex));
- Py_DECREF(hex);
- if (v->next) {
-#ifdef METH_NOARGS
- PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next);
-#else
- PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args);
-#endif
- PyString_ConcatAndDel(&repr,nrep);
- }
- return repr;
-}
-
-SWIGRUNTIME int
-PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
-{
-#ifdef METH_NOARGS
- PyObject *repr = PySwigObject_repr(v);
-#else
- PyObject *repr = PySwigObject_repr(v, NULL);
-#endif
- if (repr) {
- fputs(PyString_AsString(repr), fp);
- Py_DECREF(repr);
- return 0;
- } else {
- return 1;
- }
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_str(PySwigObject *v)
-{
- char result[SWIG_BUFFER_SIZE];
- return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ?
- PyString_FromString(result) : 0;
-}
-
-SWIGRUNTIME int
-PySwigObject_compare(PySwigObject *v, PySwigObject *w)
-{
- void *i = v->ptr;
- void *j = w->ptr;
- return (i < j) ? -1 : ((i > j) ? 1 : 0);
-}
-
-SWIGRUNTIME PyTypeObject* _PySwigObject_type(void);
-
-SWIGRUNTIME PyTypeObject*
-PySwigObject_type(void) {
- static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type();
- return type;
-}
-
-SWIGRUNTIMEINLINE int
-PySwigObject_Check(PyObject *op) {
- return ((op)->ob_type == PySwigObject_type())
- || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0);
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_New(void *ptr, swig_type_info *ty, int own);
-
-SWIGRUNTIME void
-PySwigObject_dealloc(PyObject *v)
-{
- PySwigObject *sobj = (PySwigObject *) v;
- PyObject *next = sobj->next;
- if (sobj->own) {
- swig_type_info *ty = sobj->ty;
- PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
- PyObject *destroy = data ? data->destroy : 0;
- if (destroy) {
- /* destroy is always a VARARGS method */
- PyObject *res;
- if (data->delargs) {
- /* we need to create a temporal object to carry the destroy operation */
- PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0);
- res = SWIG_Python_CallFunctor(destroy, tmp);
- Py_DECREF(tmp);
- } else {
- PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
- PyObject *mself = PyCFunction_GET_SELF(destroy);
- res = ((*meth)(mself, v));
- }
- Py_XDECREF(res);
- } else {
- const char *name = SWIG_TypePrettyName(ty);
-#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
- printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
-#endif
- }
- }
- Py_XDECREF(next);
- PyObject_DEL(v);
-}
-
-SWIGRUNTIME PyObject*
-PySwigObject_append(PyObject* v, PyObject* next)
-{
- PySwigObject *sobj = (PySwigObject *) v;
-#ifndef METH_O
- PyObject *tmp = 0;
- if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
- next = tmp;
-#endif
- if (!PySwigObject_Check(next)) {
- return NULL;
- }
- sobj->next = next;
- Py_INCREF(next);
- return SWIG_Py_Void();
-}
-
-SWIGRUNTIME PyObject*
-#ifdef METH_NOARGS
-PySwigObject_next(PyObject* v)
-#else
-PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
-#endif
-{
- PySwigObject *sobj = (PySwigObject *) v;
- if (sobj->next) {
- Py_INCREF(sobj->next);
- return sobj->next;
- } else {
- return SWIG_Py_Void();
- }
-}
-
-SWIGINTERN PyObject*
-#ifdef METH_NOARGS
-PySwigObject_disown(PyObject *v)
-#else
-PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
-#endif
-{
- PySwigObject *sobj = (PySwigObject *)v;
- sobj->own = 0;
- return SWIG_Py_Void();
-}
-
-SWIGINTERN PyObject*
-#ifdef METH_NOARGS
-PySwigObject_acquire(PyObject *v)
-#else
-PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
-#endif
-{
- PySwigObject *sobj = (PySwigObject *)v;
- sobj->own = SWIG_POINTER_OWN;
- return SWIG_Py_Void();
-}
-
-SWIGINTERN PyObject*
-PySwigObject_own(PyObject *v, PyObject *args)
-{
- PyObject *val = 0;
-#if (PY_VERSION_HEX < 0x02020000)
- if (!PyArg_ParseTuple(args,(char *)"|O:own",&val))
-#else
- if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val))
-#endif
- {
- return NULL;
- }
- else
- {
- PySwigObject *sobj = (PySwigObject *)v;
- PyObject *obj = PyBool_FromLong(sobj->own);
- if (val) {
-#ifdef METH_NOARGS
- if (PyObject_IsTrue(val)) {
- PySwigObject_acquire(v);
- } else {
- PySwigObject_disown(v);
- }
-#else
- if (PyObject_IsTrue(val)) {
- PySwigObject_acquire(v,args);
- } else {
- PySwigObject_disown(v,args);
- }
-#endif
- }
- return obj;
- }
-}
-
-#ifdef METH_O
-static PyMethodDef
-swigobject_methods[] = {
- {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"},
- {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"},
- {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
- {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"},
- {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"},
- {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"},
- {0, 0, 0, 0}
-};
-#else
-static PyMethodDef
-swigobject_methods[] = {
- {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"},
- {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"},
- {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
- {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"},
- {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"},
- {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"},
- {0, 0, 0, 0}
-};
-#endif
-
-#if PY_VERSION_HEX < 0x02020000
-SWIGINTERN PyObject *
-PySwigObject_getattr(PySwigObject *sobj,char *name)
-{
- return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
-}
-#endif
-
-SWIGRUNTIME PyTypeObject*
-_PySwigObject_type(void) {
- static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
-
- static PyNumberMethods PySwigObject_as_number = {
- (binaryfunc)0, /*nb_add*/
- (binaryfunc)0, /*nb_subtract*/
- (binaryfunc)0, /*nb_multiply*/
- (binaryfunc)0, /*nb_divide*/
- (binaryfunc)0, /*nb_remainder*/
- (binaryfunc)0, /*nb_divmod*/
- (ternaryfunc)0,/*nb_power*/
- (unaryfunc)0, /*nb_negative*/
- (unaryfunc)0, /*nb_positive*/
- (unaryfunc)0, /*nb_absolute*/
- (inquiry)0, /*nb_nonzero*/
- 0, /*nb_invert*/
- 0, /*nb_lshift*/
- 0, /*nb_rshift*/
- 0, /*nb_and*/
- 0, /*nb_xor*/
- 0, /*nb_or*/
- (coercion)0, /*nb_coerce*/
- (unaryfunc)PySwigObject_long, /*nb_int*/
- (unaryfunc)PySwigObject_long, /*nb_long*/
- (unaryfunc)0, /*nb_float*/
- (unaryfunc)PySwigObject_oct, /*nb_oct*/
- (unaryfunc)PySwigObject_hex, /*nb_hex*/
-#if PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
-#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
-#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */
- 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
-#endif
- };
-
- static PyTypeObject pyswigobject_type;
- static int type_init = 0;
- if (!type_init) {
- const PyTypeObject tmp
- = {
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- (char *)"PySwigObject", /* tp_name */
- sizeof(PySwigObject), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)PySwigObject_dealloc, /* tp_dealloc */
- (printfunc)PySwigObject_print, /* tp_print */
-#if PY_VERSION_HEX < 0x02020000
- (getattrfunc)PySwigObject_getattr, /* tp_getattr */
-#else
- (getattrfunc)0, /* tp_getattr */
-#endif
- (setattrfunc)0, /* tp_setattr */
- (cmpfunc)PySwigObject_compare, /* tp_compare */
- (reprfunc)PySwigObject_repr, /* tp_repr */
- &PySwigObject_as_number, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- (hashfunc)0, /* tp_hash */
- (ternaryfunc)0, /* tp_call */
- (reprfunc)PySwigObject_str, /* tp_str */
- PyObject_GenericGetAttr, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- swigobject_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
-#if PY_VERSION_HEX >= 0x02020000
- 0, /* tp_iter */
- 0, /* tp_iternext */
- swigobject_methods, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
- 0, /* tp_free */
- 0, /* tp_is_gc */
- 0, /* tp_bases */
- 0, /* tp_mro */
- 0, /* tp_cache */
- 0, /* tp_subclasses */
- 0, /* tp_weaklist */
-#endif
-#if PY_VERSION_HEX >= 0x02030000
- 0, /* tp_del */
-#endif
-#ifdef COUNT_ALLOCS
- 0,0,0,0 /* tp_alloc -> tp_next */
-#endif
- };
- pyswigobject_type = tmp;
- pyswigobject_type.ob_type = &PyType_Type;
- type_init = 1;
- }
- return &pyswigobject_type;
-}
-
-SWIGRUNTIME PyObject *
-PySwigObject_New(void *ptr, swig_type_info *ty, int own)
-{
- PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type());
- if (sobj) {
- sobj->ptr = ptr;
- sobj->ty = ty;
- sobj->own = own;
- sobj->next = 0;
- }
- return (PyObject *)sobj;
-}
-
-/* -----------------------------------------------------------------------------
- * Implements a simple Swig Packed type, and use it instead of string
- * ----------------------------------------------------------------------------- */
-
-typedef struct {
- PyObject_HEAD
- void *pack;
- swig_type_info *ty;
- size_t size;
-} PySwigPacked;
-
-SWIGRUNTIME int
-PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
-{
- char result[SWIG_BUFFER_SIZE];
- fputs("<Swig Packed ", fp);
- if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
- fputs("at ", fp);
- fputs(result, fp);
- }
- fputs(v->ty->name,fp);
- fputs(">", fp);
- return 0;
-}
-
-SWIGRUNTIME PyObject *
-PySwigPacked_repr(PySwigPacked *v)
-{
- char result[SWIG_BUFFER_SIZE];
- if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
- return PyString_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
- } else {
- return PyString_FromFormat("<Swig Packed %s>", v->ty->name);
- }
-}
-
-SWIGRUNTIME PyObject *
-PySwigPacked_str(PySwigPacked *v)
-{
- char result[SWIG_BUFFER_SIZE];
- if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
- return PyString_FromFormat("%s%s", result, v->ty->name);
- } else {
- return PyString_FromString(v->ty->name);
- }
-}
-
-SWIGRUNTIME int
-PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w)
-{
- size_t i = v->size;
- size_t j = w->size;
- int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
- return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
-}
-
-SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void);
-
-SWIGRUNTIME PyTypeObject*
-PySwigPacked_type(void) {
- static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type();
- return type;
-}
-
-SWIGRUNTIMEINLINE int
-PySwigPacked_Check(PyObject *op) {
- return ((op)->ob_type == _PySwigPacked_type())
- || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0);
-}
-
-SWIGRUNTIME void
-PySwigPacked_dealloc(PyObject *v)
-{
- if (PySwigPacked_Check(v)) {
- PySwigPacked *sobj = (PySwigPacked *) v;
- free(sobj->pack);
- }
- PyObject_DEL(v);
-}
-
-SWIGRUNTIME PyTypeObject*
-_PySwigPacked_type(void) {
- static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
- static PyTypeObject pyswigpacked_type;
- static int type_init = 0;
- if (!type_init) {
- const PyTypeObject tmp
- = {
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- (char *)"PySwigPacked", /* tp_name */
- sizeof(PySwigPacked), /* tp_basicsize */
- 0, /* tp_itemsize */
- (destructor)PySwigPacked_dealloc, /* tp_dealloc */
- (printfunc)PySwigPacked_print, /* tp_print */
- (getattrfunc)0, /* tp_getattr */
- (setattrfunc)0, /* tp_setattr */
- (cmpfunc)PySwigPacked_compare, /* tp_compare */
- (reprfunc)PySwigPacked_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- (hashfunc)0, /* tp_hash */
- (ternaryfunc)0, /* tp_call */
- (reprfunc)PySwigPacked_str, /* tp_str */
- PyObject_GenericGetAttr, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- swigpacked_doc, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
-#if PY_VERSION_HEX >= 0x02020000
- 0, /* tp_iter */
- 0, /* tp_iternext */
- 0, /* tp_methods */
- 0, /* tp_members */
- 0, /* tp_getset */
- 0, /* tp_base */
- 0, /* tp_dict */
- 0, /* tp_descr_get */
- 0, /* tp_descr_set */
- 0, /* tp_dictoffset */
- 0, /* tp_init */
- 0, /* tp_alloc */
- 0, /* tp_new */
- 0, /* tp_free */
- 0, /* tp_is_gc */
- 0, /* tp_bases */
- 0, /* tp_mro */
- 0, /* tp_cache */
- 0, /* tp_subclasses */
- 0, /* tp_weaklist */
-#endif
-#if PY_VERSION_HEX >= 0x02030000
- 0, /* tp_del */
-#endif
-#ifdef COUNT_ALLOCS
- 0,0,0,0 /* tp_alloc -> tp_next */
-#endif
- };
- pyswigpacked_type = tmp;
- pyswigpacked_type.ob_type = &PyType_Type;
- type_init = 1;
- }
- return &pyswigpacked_type;
-}
-
-SWIGRUNTIME PyObject *
-PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty)
-{
- PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type());
- if (sobj) {
- void *pack = malloc(size);
- if (pack) {
- memcpy(pack, ptr, size);
- sobj->pack = pack;
- sobj->ty = ty;
- sobj->size = size;
- } else {
- PyObject_DEL((PyObject *) sobj);
- sobj = 0;
- }
- }
- return (PyObject *) sobj;
-}
-
-SWIGRUNTIME swig_type_info *
-PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
-{
- if (PySwigPacked_Check(obj)) {
- PySwigPacked *sobj = (PySwigPacked *)obj;
- if (sobj->size != size) return 0;
- memcpy(ptr, sobj->pack, size);
- return sobj->ty;
- } else {
- return 0;
- }
-}
-
-/* -----------------------------------------------------------------------------
- * pointers/data manipulation
- * ----------------------------------------------------------------------------- */
-
-SWIGRUNTIMEINLINE PyObject *
-_SWIG_This(void)
-{
- return PyString_FromString("this");
-}
-
-SWIGRUNTIME PyObject *
-SWIG_This(void)
-{
- static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
- return swig_this;
-}
-
-/* #define SWIG_PYTHON_SLOW_GETSET_THIS */
-
-SWIGRUNTIME PySwigObject *
-SWIG_Python_GetSwigThis(PyObject *pyobj)
-{
- if (PySwigObject_Check(pyobj)) {
- return (PySwigObject *) pyobj;
- } else {
- PyObject *obj = 0;
-#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
- if (PyInstance_Check(pyobj)) {
- obj = _PyInstance_Lookup(pyobj, SWIG_This());
- } else {
- PyObject **dictptr = _PyObject_GetDictPtr(pyobj);
- if (dictptr != NULL) {
- PyObject *dict = *dictptr;
- obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
- } else {
-#ifdef PyWeakref_CheckProxy
- if (PyWeakref_CheckProxy(pyobj)) {
- PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
- return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
- }
-#endif
- obj = PyObject_GetAttr(pyobj,SWIG_This());
- if (obj) {
- Py_DECREF(obj);
- } else {
- if (PyErr_Occurred()) PyErr_Clear();
- return 0;
- }
- }
- }
-#else
- obj = PyObject_GetAttr(pyobj,SWIG_This());
- if (obj) {
- Py_DECREF(obj);
- } else {
- if (PyErr_Occurred()) PyErr_Clear();
- return 0;
- }
-#endif
- if (obj && !PySwigObject_Check(obj)) {
- /* a PyObject is called 'this', try to get the 'real this'
- PySwigObject from it */
- return SWIG_Python_GetSwigThis(obj);
- }
- return (PySwigObject *)obj;
- }
-}
-
-/* Acquire a pointer value */
-
-SWIGRUNTIME int
-SWIG_Python_AcquirePtr(PyObject *obj, int own) {
- if (own) {
- PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
- if (sobj) {
- int oldown = sobj->own;
- sobj->own = own;
- return oldown;
- }
- }
- return 0;
-}
-
-/* Convert a pointer value */
-
-SWIGRUNTIME int
-SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
- if (!obj) return SWIG_ERROR;
- if (obj == Py_None) {
- if (ptr) *ptr = 0;
- return SWIG_OK;
- } else {
- PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
- while (sobj) {
- void *vptr = sobj->ptr;
- if (ty) {
- swig_type_info *to = sobj->ty;
- if (to == ty) {
- /* no type cast needed */
- if (ptr) *ptr = vptr;
- break;
- } else {
- swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
- if (!tc) {
- sobj = (PySwigObject *)sobj->next;
- } else {
- if (ptr) *ptr = SWIG_TypeCast(tc,vptr);
- break;
- }
- }
- } else {
- if (ptr) *ptr = vptr;
- break;
- }
- }
- if (sobj) {
- if (own) *own = sobj->own;
- if (flags & SWIG_POINTER_DISOWN) {
- sobj->own = 0;
- }
- return SWIG_OK;
- } else {
- int res = SWIG_ERROR;
- if (flags & SWIG_POINTER_IMPLICIT_CONV) {
- PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
- if (data && !data->implicitconv) {
- PyObject *klass = data->klass;
- if (klass) {
- PyObject *impconv;
- data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/
- impconv = SWIG_Python_CallFunctor(klass, obj);
- data->implicitconv = 0;
- if (PyErr_Occurred()) {
- PyErr_Clear();
- impconv = 0;
- }
- if (impconv) {
- PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv);
- if (iobj) {
- void *vptr;
- res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
- if (SWIG_IsOK(res)) {
- if (ptr) {
- *ptr = vptr;
- /* transfer the ownership to 'ptr' */
- iobj->own = 0;
- res = SWIG_AddCast(res);
- res = SWIG_AddNewMask(res);
- } else {
- res = SWIG_AddCast(res);
- }
- }
- }
- Py_DECREF(impconv);
- }
- }
- }
- }
- return res;
- }
- }
-}
-
-/* Convert a function ptr value */
-
-SWIGRUNTIME int
-SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
- if (!PyCFunction_Check(obj)) {
- return SWIG_ConvertPtr(obj, ptr, ty, 0);
- } else {
- void *vptr = 0;
-
- /* here we get the method pointer for callbacks */
- const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
- const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
- if (desc) {
- desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
- if (!desc) return SWIG_ERROR;
- }
- if (ty) {
- swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
- if (!tc) return SWIG_ERROR;
- *ptr = SWIG_TypeCast(tc,vptr);
- } else {
- *ptr = vptr;
- }
- return SWIG_OK;
- }
-}
-
-/* Convert a packed value value */
-
-SWIGRUNTIME int
-SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
- swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz);
- if (!to) return SWIG_ERROR;
- if (ty) {
- if (to != ty) {
- /* check type cast? */
- swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
- if (!tc) return SWIG_ERROR;
- }
- }
- return SWIG_OK;
-}
-
-/* -----------------------------------------------------------------------------
- * Create a new pointer object
- * ----------------------------------------------------------------------------- */
-
-/*
- Create a new instance object, whitout calling __init__, and set the
- 'this' attribute.
-*/
-
-SWIGRUNTIME PyObject*
-SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this)
-{
-#if (PY_VERSION_HEX >= 0x02020000)
- PyObject *inst = 0;
- PyObject *newraw = data->newraw;
- if (newraw) {
- inst = PyObject_Call(newraw, data->newargs, NULL);
- if (inst) {
-#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
- PyObject **dictptr = _PyObject_GetDictPtr(inst);
- if (dictptr != NULL) {
- PyObject *dict = *dictptr;
- if (dict == NULL) {
- dict = PyDict_New();
- *dictptr = dict;
- PyDict_SetItem(dict, SWIG_This(), swig_this);
- }
- }
-#else
- PyObject *key = SWIG_This();
- PyObject_SetAttr(inst, key, swig_this);
-#endif
- }
- } else {
- PyObject *dict = PyDict_New();
- PyDict_SetItem(dict, SWIG_This(), swig_this);
- inst = PyInstance_NewRaw(data->newargs, dict);
- Py_DECREF(dict);
- }
- return inst;
-#else
-#if (PY_VERSION_HEX >= 0x02010000)
- PyObject *inst;
- PyObject *dict = PyDict_New();
- PyDict_SetItem(dict, SWIG_This(), swig_this);
- inst = PyInstance_NewRaw(data->newargs, dict);
- Py_DECREF(dict);
- return (PyObject *) inst;
-#else
- PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
- if (inst == NULL) {
- return NULL;
- }
- inst->in_class = (PyClassObject *)data->newargs;
- Py_INCREF(inst->in_class);
- inst->in_dict = PyDict_New();
- if (inst->in_dict == NULL) {
- Py_DECREF(inst);
- return NULL;
- }
-#ifdef Py_TPFLAGS_HAVE_WEAKREFS
- inst->in_weakreflist = NULL;
-#endif
-#ifdef Py_TPFLAGS_GC
- PyObject_GC_Init(inst);
-#endif
- PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this);
- return (PyObject *) inst;
-#endif
-#endif
-}
-
-SWIGRUNTIME void
-SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
-{
- PyObject *dict;
-#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
- PyObject **dictptr = _PyObject_GetDictPtr(inst);
- if (dictptr != NULL) {
- dict = *dictptr;
- if (dict == NULL) {
- dict = PyDict_New();
- *dictptr = dict;
- }
- PyDict_SetItem(dict, SWIG_This(), swig_this);
- return;
- }
-#endif
- dict = PyObject_GetAttrString(inst, (char*)"__dict__");
- PyDict_SetItem(dict, SWIG_This(), swig_this);
- Py_DECREF(dict);
-}
-
-
-SWIGINTERN PyObject *
-SWIG_Python_InitShadowInstance(PyObject *args) {
- PyObject *obj[2];
- if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) {
- return NULL;
- } else {
- PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
- if (sthis) {
- PySwigObject_append((PyObject*) sthis, obj[1]);
- } else {
- SWIG_Python_SetSwigThis(obj[0], obj[1]);
- }
- return SWIG_Py_Void();
- }
-}
-
-/* Create a new pointer object */
-
-SWIGRUNTIME PyObject *
-SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
- if (!ptr) {
- return SWIG_Py_Void();
- } else {
- int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
- PyObject *robj = PySwigObject_New(ptr, type, own);
- PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0;
- if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
- PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
- if (inst) {
- Py_DECREF(robj);
- robj = inst;
- }
- }
- return robj;
- }
-}
-
-/* Create a new packed object */
-
-SWIGRUNTIMEINLINE PyObject *
-SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
- return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
-}
-
-/* -----------------------------------------------------------------------------*
- * Get type list
- * -----------------------------------------------------------------------------*/
-
-#ifdef SWIG_LINK_RUNTIME
-void *SWIG_ReturnGlobalTypeList(void *);
-#endif
-
-SWIGRUNTIME swig_module_info *
-SWIG_Python_GetModule(void) {
- static void *type_pointer = (void *)0;
- /* first check if module already created */
- if (!type_pointer) {
-#ifdef SWIG_LINK_RUNTIME
- type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
-#else
- type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
- (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
- if (PyErr_Occurred()) {
- PyErr_Clear();
- type_pointer = (void *)0;
- }
-#endif
- }
- return (swig_module_info *) type_pointer;
-}
-
-#if PY_MAJOR_VERSION < 2
-/* PyModule_AddObject function was introduced in Python 2.0. The following function
- is copied out of Python/modsupport.c in python version 2.3.4 */
-SWIGINTERN int
-PyModule_AddObject(PyObject *m, char *name, PyObject *o)
-{
- PyObject *dict;
- if (!PyModule_Check(m)) {
- PyErr_SetString(PyExc_TypeError,
- "PyModule_AddObject() needs module as first arg");
- return SWIG_ERROR;
- }
- if (!o) {
- PyErr_SetString(PyExc_TypeError,
- "PyModule_AddObject() needs non-NULL value");
- return SWIG_ERROR;
- }
-
- dict = PyModule_GetDict(m);
- if (dict == NULL) {
- /* Internal error -- modules must have a dict! */
- PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
- PyModule_GetName(m));
- return SWIG_ERROR;
- }
- if (PyDict_SetItemString(dict, name, o))
- return SWIG_ERROR;
- Py_DECREF(o);
- return SWIG_OK;
-}
-#endif
-
-SWIGRUNTIME void
-SWIG_Python_DestroyModule(void *vptr)
-{
- swig_module_info *swig_module = (swig_module_info *) vptr;
- swig_type_info **types = swig_module->types;
- size_t i;
- for (i =0; i < swig_module->size; ++i) {
- swig_type_info *ty = types[i];
- if (ty->owndata) {
- PySwigClientData *data = (PySwigClientData *) ty->clientdata;
- if (data) PySwigClientData_Del(data);
- }
- }
- Py_DECREF(SWIG_This());
-}
-
-SWIGRUNTIME void
-SWIG_Python_SetModule(swig_module_info *swig_module) {
- static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
-
- PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
- swig_empty_runtime_method_table);
- PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
- if (pointer && module) {
- PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
- } else {
- Py_XDECREF(pointer);
- }
-}
-
-/* The python cached type query */
-SWIGRUNTIME PyObject *
-SWIG_Python_TypeCache(void) {
- static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
- return cache;
-}
-
-SWIGRUNTIME swig_type_info *
-SWIG_Python_TypeQuery(const char *type)
-{
- PyObject *cache = SWIG_Python_TypeCache();
- PyObject *key = PyString_FromString(type);
- PyObject *obj = PyDict_GetItem(cache, key);
- swig_type_info *descriptor;
- if (obj) {
- descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
- } else {
- swig_module_info *swig_module = SWIG_Python_GetModule();
- descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
- if (descriptor) {
- obj = PyCObject_FromVoidPtr(descriptor, NULL);
- PyDict_SetItem(cache, key, obj);
- Py_DECREF(obj);
- }
- }
- Py_DECREF(key);
- return descriptor;
-}
-
-/*
- For backward compatibility only
-*/
-#define SWIG_POINTER_EXCEPTION 0
-#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg)
-#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags)
-
-SWIGRUNTIME int
-SWIG_Python_AddErrMesg(const char* mesg, int infront)
-{
- if (PyErr_Occurred()) {
- PyObject *type = 0;
- PyObject *value = 0;
- PyObject *traceback = 0;
- PyErr_Fetch(&type, &value, &traceback);
- if (value) {
- PyObject *old_str = PyObject_Str(value);
- Py_XINCREF(type);
- PyErr_Clear();
- if (infront) {
- PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str));
- } else {
- PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
- }
- Py_DECREF(old_str);
- }
- return 1;
- } else {
- return 0;
- }
-}
-
-SWIGRUNTIME int
-SWIG_Python_ArgFail(int argnum)
-{
- if (PyErr_Occurred()) {
- /* add information about failing argument */
- char mesg[256];
- PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
- return SWIG_Python_AddErrMesg(mesg, 1);
- } else {
- return 0;
- }
-}
-
-SWIGRUNTIMEINLINE const char *
-PySwigObject_GetDesc(PyObject *self)
-{
- PySwigObject *v = (PySwigObject *)self;
- swig_type_info *ty = v ? v->ty : 0;
- return ty ? ty->str : (char*)"";
-}
-
-SWIGRUNTIME void
-SWIG_Python_TypeError(const char *type, PyObject *obj)
-{
- if (type) {
-#if defined(SWIG_COBJECT_TYPES)
- if (obj && PySwigObject_Check(obj)) {
- const char *otype = (const char *) PySwigObject_GetDesc(obj);
- if (otype) {
- PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received",
- type, otype);
- return;
- }
- } else
-#endif
- {
- const char *otype = (obj ? obj->ob_type->tp_name : 0);
- if (otype) {
- PyObject *str = PyObject_Str(obj);
- const char *cstr = str ? PyString_AsString(str) : 0;
- if (cstr) {
- PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
- type, otype, cstr);
- } else {
- PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
- type, otype);
- }
- Py_XDECREF(str);
- return;
- }
- }
- PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
- } else {
- PyErr_Format(PyExc_TypeError, "unexpected type is received");
- }
-}
-
-
-/* Convert a pointer value, signal an exception on a type mismatch */
-SWIGRUNTIME void *
-SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) {
- void *result;
- if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
- PyErr_Clear();
- if (flags & SWIG_POINTER_EXCEPTION) {
- SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
- SWIG_Python_ArgFail(argnum);
- }
- }
- return result;
-}
-
-
-#ifdef __cplusplus
-#if 0
-{ /* cc-mode */
-#endif
-}
-#endif
-
-
-
-#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0)
-
-#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else
-
-
-
-/* -------- TYPES TABLE (BEGIN) -------- */
-
-#define SWIGTYPE_p_TALLOC_CTX swig_types[0]
-#define SWIGTYPE_p_char swig_types[1]
-#define SWIGTYPE_p_cli_credentials swig_types[2]
-#define SWIGTYPE_p_event_context swig_types[3]
-#define SWIGTYPE_p_int swig_types[4]
-#define SWIGTYPE_p_ldb_context swig_types[5]
-#define SWIGTYPE_p_libnet_AddShare swig_types[6]
-#define SWIGTYPE_p_libnet_BecomeDC swig_types[7]
-#define SWIGTYPE_p_libnet_ChangePassword swig_types[8]
-#define SWIGTYPE_p_libnet_CreateUser swig_types[9]
-#define SWIGTYPE_p_libnet_DelShare swig_types[10]
-#define SWIGTYPE_p_libnet_DeleteUser swig_types[11]
-#define SWIGTYPE_p_libnet_DomainClose swig_types[12]
-#define SWIGTYPE_p_libnet_DomainList swig_types[13]
-#define SWIGTYPE_p_libnet_DomainOpen swig_types[14]
-#define SWIGTYPE_p_libnet_GroupInfo swig_types[15]
-#define SWIGTYPE_p_libnet_GroupList swig_types[16]
-#define SWIGTYPE_p_libnet_Join swig_types[17]
-#define SWIGTYPE_p_libnet_JoinDomain swig_types[18]
-#define SWIGTYPE_p_libnet_ListShares swig_types[19]
-#define SWIGTYPE_p_libnet_Lookup swig_types[20]
-#define SWIGTYPE_p_libnet_LookupDCs swig_types[21]
-#define SWIGTYPE_p_libnet_LookupName swig_types[22]
-#define SWIGTYPE_p_libnet_ModifyUser swig_types[23]
-#define SWIGTYPE_p_libnet_RemoteTOD swig_types[24]
-#define SWIGTYPE_p_libnet_RpcConnect swig_types[25]
-#define SWIGTYPE_p_libnet_SamDump swig_types[26]
-#define SWIGTYPE_p_libnet_SamDump_keytab swig_types[27]
-#define SWIGTYPE_p_libnet_SamSync swig_types[28]
-#define SWIGTYPE_p_libnet_SetPassword swig_types[29]
-#define SWIGTYPE_p_libnet_UnbecomeDC swig_types[30]
-#define SWIGTYPE_p_libnet_UserInfo swig_types[31]
-#define SWIGTYPE_p_libnet_UserList swig_types[32]
-#define SWIGTYPE_p_libnet_context swig_types[33]
-#define SWIGTYPE_p_libnet_samsync_ldb swig_types[34]
-#define SWIGTYPE_p_loadparm_context swig_types[35]
-#define SWIGTYPE_p_loadparm_service swig_types[36]
-#define SWIGTYPE_p_long_long swig_types[37]
-#define SWIGTYPE_p_param_context swig_types[38]
-#define SWIGTYPE_p_param_opt swig_types[39]
-#define SWIGTYPE_p_param_section swig_types[40]
-#define SWIGTYPE_p_short swig_types[41]
-#define SWIGTYPE_p_signed_char swig_types[42]
-#define SWIGTYPE_p_unsigned_char swig_types[43]
-#define SWIGTYPE_p_unsigned_int swig_types[44]
-#define SWIGTYPE_p_unsigned_long_long swig_types[45]
-#define SWIGTYPE_p_unsigned_short swig_types[46]
-static swig_type_info *swig_types[48];
-static swig_module_info swig_module = {swig_types, 47, 0, 0, 0, 0};
-#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
-#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
-
-/* -------- TYPES TABLE (END) -------- */
-
-#if (PY_VERSION_HEX <= 0x02000000)
-# if !defined(SWIG_PYTHON_CLASSIC)
-# error "This python version requires swig to be run with the '-classic' option"
-# endif
-#endif
-#if (PY_VERSION_HEX <= 0x02020000)
-# error "This python version requires swig to be run with the '-nomodern' option"
-#endif
-#if (PY_VERSION_HEX <= 0x02020000)
-# error "This python version requires swig to be run with the '-nomodernargs' option"
-#endif
-#ifndef METH_O
-# error "This python version requires swig to be run with the '-nofastunpack' option"
-#endif
-#ifdef SWIG_TypeQuery
-# undef SWIG_TypeQuery
-#endif
-#define SWIG_TypeQuery SWIG_Python_TypeQuery
-
-/*-----------------------------------------------
- @(target):= _net.so
- ------------------------------------------------*/
-#define SWIG_init init_net
-
-#define SWIG_name "_net"
-
-#define SWIGVERSION 0x010333
-#define SWIG_VERSION SWIGVERSION
-
-
-#define SWIG_as_voidptr(a) (void *)((const void *)(a))
-#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
-
-
-#include "includes.h"
-#include "libnet/libnet.h"
-#include "lib/events/events.h"
-#include "param/param.h"
-typedef struct libnet_context libnet;
-
-SWIGINTERN libnet *new_libnet(struct event_context *ev,struct loadparm_context *lp_ctx){
- return libnet_context_init(ev, lp_ctx);
- }
-#ifdef __cplusplus
-extern "C" {
-#endif
-SWIGINTERN PyObject *_wrap_libnet_cred_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- struct cli_credentials *arg2 = (struct cli_credentials *) 0 ;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp2 = 0 ;
- int res2 = 0 ;
- PyObject *swig_obj[2] ;
-
- if (!SWIG_Python_UnpackTuple(args,"libnet_cred_set",2,2,swig_obj)) SWIG_fail;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_cred_set" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_cli_credentials, SWIG_POINTER_DISOWN | 0 );
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "libnet_cred_set" "', argument " "2"" of type '" "struct cli_credentials *""'");
- }
- arg2 = (struct cli_credentials *)(argp2);
- if (arg1) (arg1)->cred = arg2;
-
- resultobj = SWIG_Py_Void();
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_cred_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- struct cli_credentials *result = 0 ;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_cred_get" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- result = (struct cli_credentials *) ((arg1)->cred);
- resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_cli_credentials, 0 | 0 );
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_new_libnet(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- struct event_context *arg1 = (struct event_context *) 0 ;
- struct loadparm_context *arg2 = (struct loadparm_context *) 0 ;
- libnet *result = 0 ;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp2 = 0 ;
- int res2 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "ev",(char *) "lp_ctx", NULL
- };
-
- arg1 = event_context_init(NULL);
- arg2 = loadparm_init(NULL);
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:new_libnet",kwnames,&obj0,&obj1)) SWIG_fail;
- if (obj0) {
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_event_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_libnet" "', argument " "1"" of type '" "struct event_context *""'");
- }
- arg1 = (struct event_context *)(argp1);
- }
- if (obj1) {
- res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_loadparm_context, 0 | 0 );
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_libnet" "', argument " "2"" of type '" "struct loadparm_context *""'");
- }
- arg2 = (struct loadparm_context *)(argp2);
- }
- result = (libnet *)new_libnet(arg1,arg2);
- resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_libnet_context, SWIG_POINTER_NEW | 0 );
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_samsync_ldb(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_samsync_ldb *arg3 = (struct libnet_samsync_ldb *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_samsync_ldb",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_samsync_ldb" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_samsync_ldb, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_samsync_ldb" "', argument " "3"" of type '" "struct libnet_samsync_ldb *""'");
- }
- arg3 = (struct libnet_samsync_ldb *)(argp3);
- result = libnet_samsync_ldb(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_DomainList(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_DomainList *arg3 = (struct libnet_DomainList *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "io", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_DomainList",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_DomainList" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_DomainList, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_DomainList" "', argument " "3"" of type '" "struct libnet_DomainList *""'");
- }
- arg3 = (struct libnet_DomainList *)(argp3);
- result = libnet_DomainList(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_DomainClose(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_DomainClose *arg3 = (struct libnet_DomainClose *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "io", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_DomainClose",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_DomainClose" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_DomainClose, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_DomainClose" "', argument " "3"" of type '" "struct libnet_DomainClose *""'");
- }
- arg3 = (struct libnet_DomainClose *)(argp3);
- result = libnet_DomainClose(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_DomainOpen(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_DomainOpen *arg3 = (struct libnet_DomainOpen *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "io", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_DomainOpen",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_DomainOpen" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_DomainOpen, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_DomainOpen" "', argument " "3"" of type '" "struct libnet_DomainOpen *""'");
- }
- arg3 = (struct libnet_DomainOpen *)(argp3);
- result = libnet_DomainOpen(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_LookupName(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_LookupName *arg3 = (struct libnet_LookupName *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "io", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_LookupName",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_LookupName" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_LookupName, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_LookupName" "', argument " "3"" of type '" "struct libnet_LookupName *""'");
- }
- arg3 = (struct libnet_LookupName *)(argp3);
- result = libnet_LookupName(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_LookupDCs(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_LookupDCs *arg3 = (struct libnet_LookupDCs *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "io", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_LookupDCs",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_LookupDCs" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_LookupDCs, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_LookupDCs" "', argument " "3"" of type '" "struct libnet_LookupDCs *""'");
- }
- arg3 = (struct libnet_LookupDCs *)(argp3);
- result = libnet_LookupDCs(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_LookupHost(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_Lookup *arg3 = (struct libnet_Lookup *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "io", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_LookupHost",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_LookupHost" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_Lookup, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_LookupHost" "', argument " "3"" of type '" "struct libnet_Lookup *""'");
- }
- arg3 = (struct libnet_Lookup *)(argp3);
- result = libnet_LookupHost(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_Lookup(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_Lookup *arg3 = (struct libnet_Lookup *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "io", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_Lookup",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_Lookup" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_Lookup, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_Lookup" "', argument " "3"" of type '" "struct libnet_Lookup *""'");
- }
- arg3 = (struct libnet_Lookup *)(argp3);
- result = libnet_Lookup(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_ListShares(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_ListShares *arg3 = (struct libnet_ListShares *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_ListShares",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_ListShares" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_ListShares, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_ListShares" "', argument " "3"" of type '" "struct libnet_ListShares *""'");
- }
- arg3 = (struct libnet_ListShares *)(argp3);
- result = libnet_ListShares(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_AddShare(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_AddShare *arg3 = (struct libnet_AddShare *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_AddShare",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_AddShare" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_AddShare, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_AddShare" "', argument " "3"" of type '" "struct libnet_AddShare *""'");
- }
- arg3 = (struct libnet_AddShare *)(argp3);
- result = libnet_AddShare(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_DelShare(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_DelShare *arg3 = (struct libnet_DelShare *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_DelShare",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_DelShare" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_DelShare, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_DelShare" "', argument " "3"" of type '" "struct libnet_DelShare *""'");
- }
- arg3 = (struct libnet_DelShare *)(argp3);
- result = libnet_DelShare(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_GroupList(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_GroupList *arg3 = (struct libnet_GroupList *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "io", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_GroupList",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_GroupList" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_GroupList, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_GroupList" "', argument " "3"" of type '" "struct libnet_GroupList *""'");
- }
- arg3 = (struct libnet_GroupList *)(argp3);
- result = libnet_GroupList(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_GroupInfo(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_GroupInfo *arg3 = (struct libnet_GroupInfo *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "io", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_GroupInfo",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_GroupInfo" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_GroupInfo, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_GroupInfo" "', argument " "3"" of type '" "struct libnet_GroupInfo *""'");
- }
- arg3 = (struct libnet_GroupInfo *)(argp3);
- result = libnet_GroupInfo(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_UserList(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_UserList *arg3 = (struct libnet_UserList *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_UserList",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_UserList" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_UserList, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_UserList" "', argument " "3"" of type '" "struct libnet_UserList *""'");
- }
- arg3 = (struct libnet_UserList *)(argp3);
- result = libnet_UserList(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_UserInfo(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_UserInfo *arg3 = (struct libnet_UserInfo *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_UserInfo",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_UserInfo" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_UserInfo, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_UserInfo" "', argument " "3"" of type '" "struct libnet_UserInfo *""'");
- }
- arg3 = (struct libnet_UserInfo *)(argp3);
- result = libnet_UserInfo(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_ModifyUser(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_ModifyUser *arg3 = (struct libnet_ModifyUser *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_ModifyUser",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_ModifyUser" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_ModifyUser, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_ModifyUser" "', argument " "3"" of type '" "struct libnet_ModifyUser *""'");
- }
- arg3 = (struct libnet_ModifyUser *)(argp3);
- result = libnet_ModifyUser(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_DeleteUser(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_DeleteUser *arg3 = (struct libnet_DeleteUser *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_DeleteUser",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_DeleteUser" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_DeleteUser, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_DeleteUser" "', argument " "3"" of type '" "struct libnet_DeleteUser *""'");
- }
- arg3 = (struct libnet_DeleteUser *)(argp3);
- result = libnet_DeleteUser(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_CreateUser(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_CreateUser *arg3 = (struct libnet_CreateUser *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_CreateUser",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_CreateUser" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_CreateUser, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_CreateUser" "', argument " "3"" of type '" "struct libnet_CreateUser *""'");
- }
- arg3 = (struct libnet_CreateUser *)(argp3);
- result = libnet_CreateUser(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_SamDump_keytab(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_SamDump_keytab *arg3 = (struct libnet_SamDump_keytab *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_SamDump_keytab",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_SamDump_keytab" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_SamDump_keytab, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_SamDump_keytab" "', argument " "3"" of type '" "struct libnet_SamDump_keytab *""'");
- }
- arg3 = (struct libnet_SamDump_keytab *)(argp3);
- result = libnet_SamDump_keytab(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_SamDump(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_SamDump *arg3 = (struct libnet_SamDump *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_SamDump",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_SamDump" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_SamDump, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_SamDump" "', argument " "3"" of type '" "struct libnet_SamDump *""'");
- }
- arg3 = (struct libnet_SamDump *)(argp3);
- result = libnet_SamDump(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_SamSync_netlogon(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_SamSync *arg3 = (struct libnet_SamSync *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_SamSync_netlogon",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_SamSync_netlogon" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_SamSync, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_SamSync_netlogon" "', argument " "3"" of type '" "struct libnet_SamSync *""'");
- }
- arg3 = (struct libnet_SamSync *)(argp3);
- result = libnet_SamSync_netlogon(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_UnbecomeDC(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_UnbecomeDC *arg3 = (struct libnet_UnbecomeDC *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_UnbecomeDC",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_UnbecomeDC" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_UnbecomeDC, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_UnbecomeDC" "', argument " "3"" of type '" "struct libnet_UnbecomeDC *""'");
- }
- arg3 = (struct libnet_UnbecomeDC *)(argp3);
- result = libnet_UnbecomeDC(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_BecomeDC(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_BecomeDC *arg3 = (struct libnet_BecomeDC *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_BecomeDC",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_BecomeDC" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_BecomeDC, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_BecomeDC" "', argument " "3"" of type '" "struct libnet_BecomeDC *""'");
- }
- arg3 = (struct libnet_BecomeDC *)(argp3);
- result = libnet_BecomeDC(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_JoinSite(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- struct ldb_context *arg2 = (struct ldb_context *) 0 ;
- struct libnet_JoinDomain *arg3 = (struct libnet_JoinDomain *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp2 = 0 ;
- int res2 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- PyObject * obj2 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "remote_ldb",(char *) "libnet_r", NULL
- };
-
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:libnet_JoinSite",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_JoinSite" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_ldb_context, 0 | 0 );
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "libnet_JoinSite" "', argument " "2"" of type '" "struct ldb_context *""'");
- }
- arg2 = (struct ldb_context *)(argp2);
- res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_libnet_JoinDomain, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_JoinSite" "', argument " "3"" of type '" "struct libnet_JoinDomain *""'");
- }
- arg3 = (struct libnet_JoinDomain *)(argp3);
- result = libnet_JoinSite(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_JoinDomain(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_JoinDomain *arg3 = (struct libnet_JoinDomain *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_JoinDomain",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_JoinDomain" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_JoinDomain, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_JoinDomain" "', argument " "3"" of type '" "struct libnet_JoinDomain *""'");
- }
- arg3 = (struct libnet_JoinDomain *)(argp3);
- result = libnet_JoinDomain(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_Join(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_Join *arg3 = (struct libnet_Join *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_Join",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_Join" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_Join, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_Join" "', argument " "3"" of type '" "struct libnet_Join *""'");
- }
- arg3 = (struct libnet_Join *)(argp3);
- result = libnet_Join(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_RpcConnect(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- struct libnet_RpcConnect *arg3 = (struct libnet_RpcConnect *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_RpcConnect",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_RpcConnect" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_RpcConnect, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_RpcConnect" "', argument " "3"" of type '" "struct libnet_RpcConnect *""'");
- }
- arg3 = (struct libnet_RpcConnect *)(argp3);
- result = libnet_RpcConnect(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_RemoteTOD(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- union libnet_RemoteTOD *arg3 = (union libnet_RemoteTOD *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_RemoteTOD",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_RemoteTOD" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_RemoteTOD, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_RemoteTOD" "', argument " "3"" of type '" "union libnet_RemoteTOD *""'");
- }
- arg3 = (union libnet_RemoteTOD *)(argp3);
- result = libnet_RemoteTOD(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_ChangePassword(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- union libnet_ChangePassword *arg3 = (union libnet_ChangePassword *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_ChangePassword",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_ChangePassword" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_ChangePassword, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_ChangePassword" "', argument " "3"" of type '" "union libnet_ChangePassword *""'");
- }
- arg3 = (union libnet_ChangePassword *)(argp3);
- result = libnet_ChangePassword(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_libnet_SetPassword(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ;
- union libnet_SetPassword *arg3 = (union libnet_SetPassword *) 0 ;
- NTSTATUS result;
- void *argp1 = 0 ;
- int res1 = 0 ;
- void *argp3 = 0 ;
- int res3 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
- char * kwnames[] = {
- (char *) "self",(char *) "r", NULL
- };
-
- arg2 = NULL;
- if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:libnet_SetPassword",kwnames,&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_libnet_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "libnet_SetPassword" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- res3 = SWIG_ConvertPtr(obj1, &argp3,SWIGTYPE_p_libnet_SetPassword, 0 | 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "libnet_SetPassword" "', argument " "3"" of type '" "union libnet_SetPassword *""'");
- }
- arg3 = (union libnet_SetPassword *)(argp3);
- result = libnet_SetPassword(arg1,arg2,arg3);
- if (NT_STATUS_IS_ERR(result)) {
- PyObject *obj = Py_BuildValue((char *)"(i,s)", NT_STATUS_V(result), nt_errstr(result));
- PyErr_SetObject(PyExc_RuntimeError, obj);
- SWIG_fail;
- } else if (resultobj == NULL) {
- resultobj = Py_None;
- }
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_delete_libnet(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- libnet *arg1 = (libnet *) 0 ;
- void *argp1 = 0 ;
- int res1 = 0 ;
- PyObject *swig_obj[1] ;
-
- if (!args) SWIG_fail;
- swig_obj[0] = args;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_libnet_context, SWIG_POINTER_DISOWN | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_libnet" "', argument " "1"" of type '" "libnet *""'");
- }
- arg1 = (libnet *)(argp1);
- free((char *) arg1);
-
- resultobj = SWIG_Py_Void();
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *libnet_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *obj;
- if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL;
- SWIG_TypeNewClientData(SWIGTYPE_p_libnet_context, SWIG_NewClientData(obj));
- return SWIG_Py_Void();
-}
-
-SWIGINTERN PyObject *libnet_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- return SWIG_Python_InitShadowInstance(args);
-}
-
-static PyMethodDef SwigMethods[] = {
- { (char *)"libnet_cred_set", _wrap_libnet_cred_set, METH_VARARGS, NULL},
- { (char *)"libnet_cred_get", (PyCFunction)_wrap_libnet_cred_get, METH_O, NULL},
- { (char *)"new_libnet", (PyCFunction) _wrap_new_libnet, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_samsync_ldb", (PyCFunction) _wrap_libnet_samsync_ldb, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_DomainList", (PyCFunction) _wrap_libnet_DomainList, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_DomainClose", (PyCFunction) _wrap_libnet_DomainClose, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_DomainOpen", (PyCFunction) _wrap_libnet_DomainOpen, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_LookupName", (PyCFunction) _wrap_libnet_LookupName, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_LookupDCs", (PyCFunction) _wrap_libnet_LookupDCs, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_LookupHost", (PyCFunction) _wrap_libnet_LookupHost, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_Lookup", (PyCFunction) _wrap_libnet_Lookup, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_ListShares", (PyCFunction) _wrap_libnet_ListShares, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_AddShare", (PyCFunction) _wrap_libnet_AddShare, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_DelShare", (PyCFunction) _wrap_libnet_DelShare, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_GroupList", (PyCFunction) _wrap_libnet_GroupList, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_GroupInfo", (PyCFunction) _wrap_libnet_GroupInfo, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_UserList", (PyCFunction) _wrap_libnet_UserList, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_UserInfo", (PyCFunction) _wrap_libnet_UserInfo, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_ModifyUser", (PyCFunction) _wrap_libnet_ModifyUser, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_DeleteUser", (PyCFunction) _wrap_libnet_DeleteUser, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_CreateUser", (PyCFunction) _wrap_libnet_CreateUser, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_SamDump_keytab", (PyCFunction) _wrap_libnet_SamDump_keytab, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_SamDump", (PyCFunction) _wrap_libnet_SamDump, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_SamSync_netlogon", (PyCFunction) _wrap_libnet_SamSync_netlogon, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_UnbecomeDC", (PyCFunction) _wrap_libnet_UnbecomeDC, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_BecomeDC", (PyCFunction) _wrap_libnet_BecomeDC, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_JoinSite", (PyCFunction) _wrap_libnet_JoinSite, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_JoinDomain", (PyCFunction) _wrap_libnet_JoinDomain, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_Join", (PyCFunction) _wrap_libnet_Join, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_RpcConnect", (PyCFunction) _wrap_libnet_RpcConnect, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_RemoteTOD", (PyCFunction) _wrap_libnet_RemoteTOD, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_ChangePassword", (PyCFunction) _wrap_libnet_ChangePassword, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"libnet_SetPassword", (PyCFunction) _wrap_libnet_SetPassword, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"delete_libnet", (PyCFunction)_wrap_delete_libnet, METH_O, NULL},
- { (char *)"libnet_swigregister", libnet_swigregister, METH_VARARGS, NULL},
- { (char *)"libnet_swiginit", libnet_swiginit, METH_VARARGS, NULL},
- { NULL, NULL, 0, NULL }
-};
-
-
-/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
-
-static swig_type_info _swigt__p_TALLOC_CTX = {"_p_TALLOC_CTX", "TALLOC_CTX *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_cli_credentials = {"_p_cli_credentials", "struct cli_credentials *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_event_context = {"_p_event_context", "struct event_context *|event *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_int = {"_p_int", "intptr_t *|int *|int_least32_t *|int_fast32_t *|int32_t *|int_fast16_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_ldb_context = {"_p_ldb_context", "struct ldb_context *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_AddShare = {"_p_libnet_AddShare", "struct libnet_AddShare *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_BecomeDC = {"_p_libnet_BecomeDC", "struct libnet_BecomeDC *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_ChangePassword = {"_p_libnet_ChangePassword", "union libnet_ChangePassword *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_CreateUser = {"_p_libnet_CreateUser", "struct libnet_CreateUser *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_DelShare = {"_p_libnet_DelShare", "struct libnet_DelShare *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_DeleteUser = {"_p_libnet_DeleteUser", "struct libnet_DeleteUser *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_DomainClose = {"_p_libnet_DomainClose", "struct libnet_DomainClose *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_DomainList = {"_p_libnet_DomainList", "struct libnet_DomainList *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_DomainOpen = {"_p_libnet_DomainOpen", "struct libnet_DomainOpen *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_GroupInfo = {"_p_libnet_GroupInfo", "struct libnet_GroupInfo *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_GroupList = {"_p_libnet_GroupList", "struct libnet_GroupList *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_Join = {"_p_libnet_Join", "struct libnet_Join *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_JoinDomain = {"_p_libnet_JoinDomain", "struct libnet_JoinDomain *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_ListShares = {"_p_libnet_ListShares", "struct libnet_ListShares *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_Lookup = {"_p_libnet_Lookup", "struct libnet_Lookup *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_LookupDCs = {"_p_libnet_LookupDCs", "struct libnet_LookupDCs *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_LookupName = {"_p_libnet_LookupName", "struct libnet_LookupName *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_ModifyUser = {"_p_libnet_ModifyUser", "struct libnet_ModifyUser *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_RemoteTOD = {"_p_libnet_RemoteTOD", "union libnet_RemoteTOD *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_RpcConnect = {"_p_libnet_RpcConnect", "struct libnet_RpcConnect *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_SamDump = {"_p_libnet_SamDump", "struct libnet_SamDump *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_SamDump_keytab = {"_p_libnet_SamDump_keytab", "struct libnet_SamDump_keytab *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_SamSync = {"_p_libnet_SamSync", "struct libnet_SamSync *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_SetPassword = {"_p_libnet_SetPassword", "union libnet_SetPassword *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_UnbecomeDC = {"_p_libnet_UnbecomeDC", "struct libnet_UnbecomeDC *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_UserInfo = {"_p_libnet_UserInfo", "struct libnet_UserInfo *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_UserList = {"_p_libnet_UserList", "struct libnet_UserList *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_context = {"_p_libnet_context", "struct libnet_context *|libnet *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_libnet_samsync_ldb = {"_p_libnet_samsync_ldb", "struct libnet_samsync_ldb *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_loadparm_context = {"_p_loadparm_context", "struct loadparm_context *|loadparm_context *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_loadparm_service = {"_p_loadparm_service", "struct loadparm_service *|loadparm_service *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_param_context = {"_p_param_context", "struct param_context *|param *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_param_opt = {"_p_param_opt", "struct param_opt *|param_opt *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_param_section = {"_p_param_section", "struct param_section *|param_section *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *|uint_least8_t *|uint_fast8_t *|uint8_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uintptr_t *|uint_least32_t *|uint_fast32_t *|uint32_t *|unsigned int *|uint_fast16_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_long_long = {"_p_unsigned_long_long", "uint_least64_t *|uint_fast64_t *|uint64_t *|unsigned long long *|uintmax_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *|uint_least16_t *|uint16_t *", 0, 0, (void*)0, 0};
-
-static swig_type_info *swig_type_initial[] = {
- &_swigt__p_TALLOC_CTX,
- &_swigt__p_char,
- &_swigt__p_cli_credentials,
- &_swigt__p_event_context,
- &_swigt__p_int,
- &_swigt__p_ldb_context,
- &_swigt__p_libnet_AddShare,
- &_swigt__p_libnet_BecomeDC,
- &_swigt__p_libnet_ChangePassword,
- &_swigt__p_libnet_CreateUser,
- &_swigt__p_libnet_DelShare,
- &_swigt__p_libnet_DeleteUser,
- &_swigt__p_libnet_DomainClose,
- &_swigt__p_libnet_DomainList,
- &_swigt__p_libnet_DomainOpen,
- &_swigt__p_libnet_GroupInfo,
- &_swigt__p_libnet_GroupList,
- &_swigt__p_libnet_Join,
- &_swigt__p_libnet_JoinDomain,
- &_swigt__p_libnet_ListShares,
- &_swigt__p_libnet_Lookup,
- &_swigt__p_libnet_LookupDCs,
- &_swigt__p_libnet_LookupName,
- &_swigt__p_libnet_ModifyUser,
- &_swigt__p_libnet_RemoteTOD,
- &_swigt__p_libnet_RpcConnect,
- &_swigt__p_libnet_SamDump,
- &_swigt__p_libnet_SamDump_keytab,
- &_swigt__p_libnet_SamSync,
- &_swigt__p_libnet_SetPassword,
- &_swigt__p_libnet_UnbecomeDC,
- &_swigt__p_libnet_UserInfo,
- &_swigt__p_libnet_UserList,
- &_swigt__p_libnet_context,
- &_swigt__p_libnet_samsync_ldb,
- &_swigt__p_loadparm_context,
- &_swigt__p_loadparm_service,
- &_swigt__p_long_long,
- &_swigt__p_param_context,
- &_swigt__p_param_opt,
- &_swigt__p_param_section,
- &_swigt__p_short,
- &_swigt__p_signed_char,
- &_swigt__p_unsigned_char,
- &_swigt__p_unsigned_int,
- &_swigt__p_unsigned_long_long,
- &_swigt__p_unsigned_short,
-};
-
-static swig_cast_info _swigc__p_TALLOC_CTX[] = { {&_swigt__p_TALLOC_CTX, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_cli_credentials[] = { {&_swigt__p_cli_credentials, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_event_context[] = { {&_swigt__p_event_context, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_ldb_context[] = { {&_swigt__p_ldb_context, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_AddShare[] = { {&_swigt__p_libnet_AddShare, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_BecomeDC[] = { {&_swigt__p_libnet_BecomeDC, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_ChangePassword[] = { {&_swigt__p_libnet_ChangePassword, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_CreateUser[] = { {&_swigt__p_libnet_CreateUser, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_DelShare[] = { {&_swigt__p_libnet_DelShare, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_DeleteUser[] = { {&_swigt__p_libnet_DeleteUser, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_DomainClose[] = { {&_swigt__p_libnet_DomainClose, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_DomainList[] = { {&_swigt__p_libnet_DomainList, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_DomainOpen[] = { {&_swigt__p_libnet_DomainOpen, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_GroupInfo[] = { {&_swigt__p_libnet_GroupInfo, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_GroupList[] = { {&_swigt__p_libnet_GroupList, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_Join[] = { {&_swigt__p_libnet_Join, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_JoinDomain[] = { {&_swigt__p_libnet_JoinDomain, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_ListShares[] = { {&_swigt__p_libnet_ListShares, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_Lookup[] = { {&_swigt__p_libnet_Lookup, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_LookupDCs[] = { {&_swigt__p_libnet_LookupDCs, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_LookupName[] = { {&_swigt__p_libnet_LookupName, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_ModifyUser[] = { {&_swigt__p_libnet_ModifyUser, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_RemoteTOD[] = { {&_swigt__p_libnet_RemoteTOD, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_RpcConnect[] = { {&_swigt__p_libnet_RpcConnect, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_SamDump[] = { {&_swigt__p_libnet_SamDump, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_SamDump_keytab[] = { {&_swigt__p_libnet_SamDump_keytab, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_SamSync[] = { {&_swigt__p_libnet_SamSync, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_SetPassword[] = { {&_swigt__p_libnet_SetPassword, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_UnbecomeDC[] = { {&_swigt__p_libnet_UnbecomeDC, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_UserInfo[] = { {&_swigt__p_libnet_UserInfo, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_UserList[] = { {&_swigt__p_libnet_UserList, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_context[] = { {&_swigt__p_libnet_context, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_libnet_samsync_ldb[] = { {&_swigt__p_libnet_samsync_ldb, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_loadparm_context[] = { {&_swigt__p_loadparm_context, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_loadparm_service[] = { {&_swigt__p_loadparm_service, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_param_context[] = { {&_swigt__p_param_context, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_param_opt[] = { {&_swigt__p_param_opt, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_param_section[] = { {&_swigt__p_param_section, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_unsigned_long_long[] = { {&_swigt__p_unsigned_long_long, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}};
-
-static swig_cast_info *swig_cast_initial[] = {
- _swigc__p_TALLOC_CTX,
- _swigc__p_char,
- _swigc__p_cli_credentials,
- _swigc__p_event_context,
- _swigc__p_int,
- _swigc__p_ldb_context,
- _swigc__p_libnet_AddShare,
- _swigc__p_libnet_BecomeDC,
- _swigc__p_libnet_ChangePassword,
- _swigc__p_libnet_CreateUser,
- _swigc__p_libnet_DelShare,
- _swigc__p_libnet_DeleteUser,
- _swigc__p_libnet_DomainClose,
- _swigc__p_libnet_DomainList,
- _swigc__p_libnet_DomainOpen,
- _swigc__p_libnet_GroupInfo,
- _swigc__p_libnet_GroupList,
- _swigc__p_libnet_Join,
- _swigc__p_libnet_JoinDomain,
- _swigc__p_libnet_ListShares,
- _swigc__p_libnet_Lookup,
- _swigc__p_libnet_LookupDCs,
- _swigc__p_libnet_LookupName,
- _swigc__p_libnet_ModifyUser,
- _swigc__p_libnet_RemoteTOD,
- _swigc__p_libnet_RpcConnect,
- _swigc__p_libnet_SamDump,
- _swigc__p_libnet_SamDump_keytab,
- _swigc__p_libnet_SamSync,
- _swigc__p_libnet_SetPassword,
- _swigc__p_libnet_UnbecomeDC,
- _swigc__p_libnet_UserInfo,
- _swigc__p_libnet_UserList,
- _swigc__p_libnet_context,
- _swigc__p_libnet_samsync_ldb,
- _swigc__p_loadparm_context,
- _swigc__p_loadparm_service,
- _swigc__p_long_long,
- _swigc__p_param_context,
- _swigc__p_param_opt,
- _swigc__p_param_section,
- _swigc__p_short,
- _swigc__p_signed_char,
- _swigc__p_unsigned_char,
- _swigc__p_unsigned_int,
- _swigc__p_unsigned_long_long,
- _swigc__p_unsigned_short,
-};
-
-
-/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
-
-static swig_const_info swig_const_table[] = {
-{0, 0, 0, 0.0, 0, 0}};
-
-#ifdef __cplusplus
-}
-#endif
-/* -----------------------------------------------------------------------------
- * Type initialization:
- * This problem is tough by the requirement that no dynamic
- * memory is used. Also, since swig_type_info structures store pointers to
- * swig_cast_info structures and swig_cast_info structures store pointers back
- * to swig_type_info structures, we need some lookup code at initialization.
- * The idea is that swig generates all the structures that are needed.
- * The runtime then collects these partially filled structures.
- * The SWIG_InitializeModule function takes these initial arrays out of
- * swig_module, and does all the lookup, filling in the swig_module.types
- * array with the correct data and linking the correct swig_cast_info
- * structures together.
- *
- * The generated swig_type_info structures are assigned staticly to an initial
- * array. We just loop through that array, and handle each type individually.
- * First we lookup if this type has been already loaded, and if so, use the
- * loaded structure instead of the generated one. Then we have to fill in the
- * cast linked list. The cast data is initially stored in something like a
- * two-dimensional array. Each row corresponds to a type (there are the same
- * number of rows as there are in the swig_type_initial array). Each entry in
- * a column is one of the swig_cast_info structures for that type.
- * The cast_initial array is actually an array of arrays, because each row has
- * a variable number of columns. So to actually build the cast linked list,
- * we find the array of casts associated with the type, and loop through it
- * adding the casts to the list. The one last trick we need to do is making
- * sure the type pointer in the swig_cast_info struct is correct.
- *
- * First off, we lookup the cast->type name to see if it is already loaded.
- * There are three cases to handle:
- * 1) If the cast->type has already been loaded AND the type we are adding
- * casting info to has not been loaded (it is in this module), THEN we
- * replace the cast->type pointer with the type pointer that has already
- * been loaded.
- * 2) If BOTH types (the one we are adding casting info to, and the
- * cast->type) are loaded, THEN the cast info has already been loaded by
- * the previous module so we just ignore it.
- * 3) Finally, if cast->type has not already been loaded, then we add that
- * swig_cast_info to the linked list (because the cast->type) pointer will
- * be correct.
- * ----------------------------------------------------------------------------- */
-
-#ifdef __cplusplus
-extern "C" {
-#if 0
-} /* c-mode */
-#endif
-#endif
-
-#if 0
-#define SWIGRUNTIME_DEBUG
-#endif
-
-
-SWIGRUNTIME void
-SWIG_InitializeModule(void *clientdata) {
- size_t i;
- swig_module_info *module_head, *iter;
- int found;
-
- clientdata = clientdata;
-
- /* check to see if the circular list has been setup, if not, set it up */
- if (swig_module.next==0) {
- /* Initialize the swig_module */
- swig_module.type_initial = swig_type_initial;
- swig_module.cast_initial = swig_cast_initial;
- swig_module.next = &swig_module;
- }
-
- /* Try and load any already created modules */
- module_head = SWIG_GetModule(clientdata);
- if (!module_head) {
- /* This is the first module loaded for this interpreter */
- /* so set the swig module into the interpreter */
- SWIG_SetModule(clientdata, &swig_module);
- module_head = &swig_module;
- } else {
- /* the interpreter has loaded a SWIG module, but has it loaded this one? */
- found=0;
- iter=module_head;
- do {
- if (iter==&swig_module) {
- found=1;
- break;
- }
- iter=iter->next;
- } while (iter!= module_head);
-
- /* if the is found in the list, then all is done and we may leave */
- if (found) return;
- /* otherwise we must add out module into the list */
- swig_module.next = module_head->next;
- module_head->next = &swig_module;
- }
-
- /* Now work on filling in swig_module.types */
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: size %d\n", swig_module.size);
-#endif
- for (i = 0; i < swig_module.size; ++i) {
- swig_type_info *type = 0;
- swig_type_info *ret;
- swig_cast_info *cast;
-
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
-#endif
-
- /* if there is another module already loaded */
- if (swig_module.next != &swig_module) {
- type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
- }
- if (type) {
- /* Overwrite clientdata field */
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: found type %s\n", type->name);
-#endif
- if (swig_module.type_initial[i]->clientdata) {
- type->clientdata = swig_module.type_initial[i]->clientdata;
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
-#endif
- }
- } else {
- type = swig_module.type_initial[i];
- }
-
- /* Insert casting types */
- cast = swig_module.cast_initial[i];
- while (cast->type) {
- /* Don't need to add information already in the list */
- ret = 0;
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
-#endif
- if (swig_module.next != &swig_module) {
- ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
-#ifdef SWIGRUNTIME_DEBUG
- if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
-#endif
- }
- if (ret) {
- if (type == swig_module.type_initial[i]) {
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
-#endif
- cast->type = ret;
- ret = 0;
- } else {
- /* Check for casting already in the list */
- swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
-#ifdef SWIGRUNTIME_DEBUG
- if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
-#endif
- if (!ocast) ret = 0;
- }
- }
-
- if (!ret) {
-#ifdef SWIGRUNTIME_DEBUG
- printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
-#endif
- if (type->cast) {
- type->cast->prev = cast;
- cast->next = type->cast;
- }
- type->cast = cast;
- }
- cast++;
- }
- /* Set entry in modules->types array equal to the type */
- swig_module.types[i] = type;
- }
- swig_module.types[i] = 0;
-
-#ifdef SWIGRUNTIME_DEBUG
- printf("**** SWIG_InitializeModule: Cast List ******\n");
- for (i = 0; i < swig_module.size; ++i) {
- int j = 0;
- swig_cast_info *cast = swig_module.cast_initial[i];
- printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
- while (cast->type) {
- printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
- cast++;
- ++j;
- }
- printf("---- Total casts: %d\n",j);
- }
- printf("**** SWIG_InitializeModule: Cast List ******\n");
-#endif
-}
-
-/* This function will propagate the clientdata field of type to
-* any new swig_type_info structures that have been added into the list
-* of equivalent types. It is like calling
-* SWIG_TypeClientData(type, clientdata) a second time.
-*/
-SWIGRUNTIME void
-SWIG_PropagateClientData(void) {
- size_t i;
- swig_cast_info *equiv;
- static int init_run = 0;
-
- if (init_run) return;
- init_run = 1;
-
- for (i = 0; i < swig_module.size; i++) {
- if (swig_module.types[i]->clientdata) {
- equiv = swig_module.types[i]->cast;
- while (equiv) {
- if (!equiv->converter) {
- if (equiv->type && !equiv->type->clientdata)
- SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
- }
- equiv = equiv->next;
- }
- }
- }
-}
-
-#ifdef __cplusplus
-#if 0
-{
- /* c-mode */
-#endif
-}
-#endif
-
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- /* Python-specific SWIG API */
-#define SWIG_newvarlink() SWIG_Python_newvarlink()
-#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr)
-#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants)
-
- /* -----------------------------------------------------------------------------
- * global variable support code.
- * ----------------------------------------------------------------------------- */
-
- typedef struct swig_globalvar {
- char *name; /* Name of global variable */
- PyObject *(*get_attr)(void); /* Return the current value */
- int (*set_attr)(PyObject *); /* Set the value */
- struct swig_globalvar *next;
- } swig_globalvar;
-
- typedef struct swig_varlinkobject {
- PyObject_HEAD
- swig_globalvar *vars;
- } swig_varlinkobject;
-
- SWIGINTERN PyObject *
- swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {
- return PyString_FromString("<Swig global variables>");
- }
-
- SWIGINTERN PyObject *
- swig_varlink_str(swig_varlinkobject *v) {
- PyObject *str = PyString_FromString("(");
- swig_globalvar *var;
- for (var = v->vars; var; var=var->next) {
- PyString_ConcatAndDel(&str,PyString_FromString(var->name));
- if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", "));
- }
- PyString_ConcatAndDel(&str,PyString_FromString(")"));
- return str;
- }
-
- SWIGINTERN int
- swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) {
- PyObject *str = swig_varlink_str(v);
- fprintf(fp,"Swig global variables ");
- fprintf(fp,"%s\n", PyString_AsString(str));
- Py_DECREF(str);
- return 0;
- }
-
- SWIGINTERN void
- swig_varlink_dealloc(swig_varlinkobject *v) {
- swig_globalvar *var = v->vars;
- while (var) {
- swig_globalvar *n = var->next;
- free(var->name);
- free(var);
- var = n;
- }
- }
-
- SWIGINTERN PyObject *
- swig_varlink_getattr(swig_varlinkobject *v, char *n) {
- PyObject *res = NULL;
- swig_globalvar *var = v->vars;
- while (var) {
- if (strcmp(var->name,n) == 0) {
- res = (*var->get_attr)();
- break;
- }
- var = var->next;
- }
- if (res == NULL && !PyErr_Occurred()) {
- PyErr_SetString(PyExc_NameError,"Unknown C global variable");
- }
- return res;
- }
-
- SWIGINTERN int
- swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) {
- int res = 1;
- swig_globalvar *var = v->vars;
- while (var) {
- if (strcmp(var->name,n) == 0) {
- res = (*var->set_attr)(p);
- break;
- }
- var = var->next;
- }
- if (res == 1 && !PyErr_Occurred()) {
- PyErr_SetString(PyExc_NameError,"Unknown C global variable");
- }
- return res;
- }
-
- SWIGINTERN PyTypeObject*
- swig_varlink_type(void) {
- static char varlink__doc__[] = "Swig var link object";
- static PyTypeObject varlink_type;
- static int type_init = 0;
- if (!type_init) {
- const PyTypeObject tmp
- = {
- PyObject_HEAD_INIT(NULL)
- 0, /* Number of items in variable part (ob_size) */
- (char *)"swigvarlink", /* Type name (tp_name) */
- sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */
- 0, /* Itemsize (tp_itemsize) */
- (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */
- (printfunc) swig_varlink_print, /* Print (tp_print) */
- (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */
- (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */
- 0, /* tp_compare */
- (reprfunc) swig_varlink_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_hash */
- 0, /* tp_call */
- (reprfunc)swig_varlink_str, /* tp_str */
- 0, /* tp_getattro */
- 0, /* tp_setattro */
- 0, /* tp_as_buffer */
- 0, /* tp_flags */
- varlink__doc__, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
-#if PY_VERSION_HEX >= 0x02020000
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
-#endif
-#if PY_VERSION_HEX >= 0x02030000
- 0, /* tp_del */
-#endif
-#ifdef COUNT_ALLOCS
- 0,0,0,0 /* tp_alloc -> tp_next */
-#endif
- };
- varlink_type = tmp;
- varlink_type.ob_type = &PyType_Type;
- type_init = 1;
- }
- return &varlink_type;
- }
-
- /* Create a variable linking object for use later */
- SWIGINTERN PyObject *
- SWIG_Python_newvarlink(void) {
- swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type());
- if (result) {
- result->vars = 0;
- }
- return ((PyObject*) result);
- }
-
- SWIGINTERN void
- SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) {
- swig_varlinkobject *v = (swig_varlinkobject *) p;
- swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar));
- if (gv) {
- size_t size = strlen(name)+1;
- gv->name = (char *)malloc(size);
- if (gv->name) {
- strncpy(gv->name,name,size);
- gv->get_attr = get_attr;
- gv->set_attr = set_attr;
- gv->next = v->vars;
- }
- }
- v->vars = gv;
- }
-
- SWIGINTERN PyObject *
- SWIG_globals(void) {
- static PyObject *_SWIG_globals = 0;
- if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink();
- return _SWIG_globals;
- }
-
- /* -----------------------------------------------------------------------------
- * constants/methods manipulation
- * ----------------------------------------------------------------------------- */
-
- /* Install Constants */
- SWIGINTERN void
- SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
- PyObject *obj = 0;
- size_t i;
- for (i = 0; constants[i].type; ++i) {
- switch(constants[i].type) {
- case SWIG_PY_POINTER:
- obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
- break;
- case SWIG_PY_BINARY:
- obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
- break;
- default:
- obj = 0;
- break;
- }
- if (obj) {
- PyDict_SetItemString(d, constants[i].name, obj);
- Py_DECREF(obj);
- }
- }
- }
-
- /* -----------------------------------------------------------------------------*/
- /* Fix SwigMethods to carry the callback ptrs when needed */
- /* -----------------------------------------------------------------------------*/
-
- SWIGINTERN void
- SWIG_Python_FixMethods(PyMethodDef *methods,
- swig_const_info *const_table,
- swig_type_info **types,
- swig_type_info **types_initial) {
- size_t i;
- for (i = 0; methods[i].ml_name; ++i) {
- const char *c = methods[i].ml_doc;
- if (c && (c = strstr(c, "swig_ptr: "))) {
- int j;
- swig_const_info *ci = 0;
- const char *name = c + 10;
- for (j = 0; const_table[j].type; ++j) {
- if (strncmp(const_table[j].name, name,
- strlen(const_table[j].name)) == 0) {
- ci = &(const_table[j]);
- break;
- }
- }
- if (ci) {
- size_t shift = (ci->ptype) - types;
- swig_type_info *ty = types_initial[shift];
- size_t ldoc = (c - methods[i].ml_doc);
- size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
- char *ndoc = (char*)malloc(ldoc + lptr + 10);
- if (ndoc) {
- char *buff = ndoc;
- void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
- if (ptr) {
- strncpy(buff, methods[i].ml_doc, ldoc);
- buff += ldoc;
- strncpy(buff, "swig_ptr: ", 10);
- buff += 10;
- SWIG_PackVoidPtr(buff, ptr, ty->name, lptr);
- methods[i].ml_doc = ndoc;
- }
- }
- }
- }
- }
- }
-
-#ifdef __cplusplus
-}
-#endif
-
-/* -----------------------------------------------------------------------------*
- * Partial Init method
- * -----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-#endif
-SWIGEXPORT void SWIG_init(void) {
- PyObject *m, *d;
-
- /* Fix SwigMethods to carry the callback ptrs when needed */
- SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
-
- m = Py_InitModule((char *) SWIG_name, SwigMethods);
- d = PyModule_GetDict(m);
-
- SWIG_InitializeModule(0);
- SWIG_InstallConstants(d,swig_const_table);
-
-
-}
-
diff --git a/source4/libnet/py_net.c b/source4/libnet/py_net.c
new file mode 100644
index 0000000000..443da299c7
--- /dev/null
+++ b/source4/libnet/py_net.c
@@ -0,0 +1,85 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+ Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include <Python.h>
+#include "libnet.h"
+#include "param/param.h"
+#include "libcli/security/security.h"
+#include "lib/events/events.h"
+
+struct libnet_context *py_net_ctx(PyObject *obj, struct event_context *ev)
+{
+ /* FIXME: Use obj */
+ return libnet_context_init(ev, global_loadparm);
+}
+
+static PyObject *py_net_join(PyObject *cls, PyObject *args, PyObject *kwargs)
+{
+ struct libnet_Join r;
+ NTSTATUS status;
+ PyObject *result;
+ TALLOC_CTX *mem_ctx;
+ struct event_context *ev;
+ struct libnet_context *libnet_ctx;
+ const char *kwnames[] = { "domain_name", "netbios_name", "join_type", "level", NULL };
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ssii:Join", discard_const_p(char *, kwnames),
+ &r.in.domain_name, &r.in.netbios_name,
+ &r.in.join_type, &r.in.level))
+ return NULL;
+
+ /* FIXME: we really need to get a context from the caller or we may end
+ * up with 2 event contexts */
+ ev = event_context_init(NULL);
+ mem_ctx = talloc_new(ev);
+
+ libnet_ctx = py_net_ctx(cls, ev);
+
+ status = libnet_Join(libnet_ctx, mem_ctx, &r);
+ if (NT_STATUS_IS_ERR(status)) {
+ PyErr_SetString(PyExc_RuntimeError, r.out.error_string);
+ talloc_free(mem_ctx);
+ return NULL;
+ }
+
+ result = Py_BuildValue("sss", r.out.join_password,
+ dom_sid_string(mem_ctx, r.out.domain_sid),
+ r.out.domain_name);
+
+ talloc_free(mem_ctx);
+
+ if (result == NULL)
+ return NULL;
+
+ return result;
+}
+
+static char py_net_join_doc[] = "join(domain_name, netbios_name, join_type, level) -> (join_password, domain_sid, domain_name)\n\n" \
+"Join the domain with the specified name.";
+
+static struct PyMethodDef net_methods[] = {
+ {"Join", (PyCFunction)py_net_join, METH_VARARGS|METH_KEYWORDS, py_net_join_doc},
+ {NULL }
+};
+
+void initnet(void)
+{
+ Py_InitModule("net", net_methods);
+}
diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk
index 23ad66274a..c7cbf27667 100644
--- a/source4/librpc/config.mk
+++ b/source4/librpc/config.mk
@@ -1,28 +1,30 @@
+ndrsrcdir = $(librpcsrcdir)/ndr
+gen_ndrsrcdir = $(librpcsrcdir)/gen_ndr
+dcerpcsrcdir = $(librpcsrcdir)/rpc
+
################################################
# Start SUBSYSTEM LIBNDR
[LIBRARY::LIBNDR]
-VERSION = 0.0.1
-SO_VERSION = 0
-PC_FILE = ndr.pc
-PRIVATE_PROTO_HEADER = ndr/libndr_proto.h
-OBJ_FILES = \
- ndr/ndr.o \
- ndr/ndr_basic.o \
- ndr/ndr_string.o \
- ndr/uuid.o
PUBLIC_DEPENDENCIES = LIBSAMBA-ERRORS LIBTALLOC LIBSAMBA-UTIL CHARSET \
LIBSAMBA-HOSTCONFIG
+
+LIBNDR_OBJ_FILES = $(addprefix $(ndrsrcdir)/, ndr.o ndr_basic.o ndr_string.o uuid.o)
+
+$(eval $(call proto_header_template,$(ndrsrcdir)/libndr_proto.h,$(LIBNDR_OBJ_FILES:.o=.c)))
+
+PC_FILES += $(librpcsrcdir)/ndr.pc
+LIBNDR_VERSION = 0.0.1
+LIBNDR_SOVERSION = 0
+
# End SUBSYSTEM LIBNDR
################################################
-PUBLIC_HEADERS += librpc/ndr/libndr.h
+PUBLIC_HEADERS += $(ndrsrcdir)/libndr.h
#################################
# Start BINARY ndrdump
[BINARY::ndrdump]
INSTALLDIR = BINDIR
-OBJ_FILES = \
- tools/ndrdump.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-HOSTCONFIG \
LIBSAMBA-UTIL \
@@ -34,274 +36,333 @@ PRIVATE_DEPENDENCIES = \
# End BINARY ndrdump
#################################
-MANPAGES += librpc/tools/ndrdump.1
+ndrdump_OBJ_FILES = $(librpcsrcdir)/tools/ndrdump.o
+
+MANPAGES += $(librpcsrcdir)/tools/ndrdump.1
################################################
# Start SUBSYSTEM NDR_COMPRESSION
[SUBSYSTEM::NDR_COMPRESSION]
-PRIVATE_PROTO_HEADER = ndr/ndr_compression.h
-OBJ_FILES = \
- ndr/ndr_compression.o
PUBLIC_DEPENDENCIES = LIBCOMPRESSION LIBSAMBA-ERRORS LIBNDR
# End SUBSYSTEM NDR_COMPRESSION
################################################
+NDR_COMPRESSION_OBJ_FILES = $(ndrsrcdir)/ndr_compression.o
+
+$(eval $(call proto_header_template,$(ndrsrcdir)/ndr_compression.h,$(NDR_COMPRESSION_OBJ_FILES:.o=.c)))
+
[SUBSYSTEM::NDR_SECURITY]
-OBJ_FILES = gen_ndr/ndr_security.o ndr/ndr_sec_helper.o
PUBLIC_DEPENDENCIES = NDR_MISC LIBSECURITY
-PUBLIC_HEADERS += librpc/gen_ndr/security.h
+NDR_SECURITY_OBJ_FILES = $(gen_ndrsrcdir)/ndr_security.o $(ndrsrcdir)/ndr_sec_helper.o
+
+PUBLIC_HEADERS += $(gen_ndrsrcdir)/security.h
[SUBSYSTEM::NDR_AUDIOSRV]
-OBJ_FILES = gen_ndr/ndr_audiosrv.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_AUDIOSRV_OBJ_FILES = $(gen_ndrsrcdir)/ndr_audiosrv.o
+
[SUBSYSTEM::NDR_DNSSERVER]
-OBJ_FILES = gen_ndr/ndr_dnsserver.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_DNSSERVER_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dnsserver.o
+
[SUBSYSTEM::NDR_WINSTATION]
-OBJ_FILES = gen_ndr/ndr_winstation.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_WINSTATION_OBJ_FILES = $(gen_ndrsrcdir)/ndr_winstation.o
+
[SUBSYSTEM::NDR_ECHO]
-OBJ_FILES = gen_ndr/ndr_echo.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_ECHO_OBJ_FILES = $(gen_ndrsrcdir)/ndr_echo.o
+
[SUBSYSTEM::NDR_IRPC]
-OBJ_FILES = gen_ndr/ndr_irpc.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_SECURITY NDR_NBT
+NDR_IRPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_irpc.o
+
[SUBSYSTEM::NDR_DSBACKUP]
-OBJ_FILES = gen_ndr/ndr_dsbackup.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_DSBACKUP_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dsbackup.o
+
[SUBSYSTEM::NDR_EFS]
-OBJ_FILES = gen_ndr/ndr_efs.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_SECURITY
+NDR_EFS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_efs.o
+
[SUBSYSTEM::NDR_MISC]
-OBJ_FILES = gen_ndr/ndr_misc.o ndr/ndr_misc.o
PUBLIC_DEPENDENCIES = LIBNDR
-PUBLIC_HEADERS += librpc/gen_ndr/misc.h librpc/gen_ndr/ndr_misc.h
+NDR_MISC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_misc.o $(ndrsrcdir)/ndr_misc.o
+
+PUBLIC_HEADERS += $(gen_ndrsrcdir)/misc.h $(gen_ndrsrcdir)/ndr_misc.h
[SUBSYSTEM::NDR_ROT]
-OBJ_FILES = gen_ndr/ndr_rot.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_ORPC
+NDR_ROT_OBJ_FILES = $(gen_ndrsrcdir)/ndr_rot.o
+
[SUBSYSTEM::NDR_LSA]
-OBJ_FILES = gen_ndr/ndr_lsa.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_SECURITY
-PUBLIC_HEADERS += librpc/gen_ndr/lsa.h
+NDR_LSA_OBJ_FILES = $(gen_ndrsrcdir)/ndr_lsa.o
+
+PUBLIC_HEADERS += $(gen_ndrsrcdir)/lsa.h
[SUBSYSTEM::NDR_DFS]
-OBJ_FILES = gen_ndr/ndr_dfs.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC
+NDR_DFS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dfs.o
+
[SUBSYSTEM::NDR_FRSRPC]
-OBJ_FILES = gen_ndr/ndr_frsrpc.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_FRSRPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_frsrpc.o
+
[SUBSYSTEM::NDR_FRSAPI]
-OBJ_FILES = gen_ndr/ndr_frsapi.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_FRSAPI_OBJ_FILES = $(gen_ndrsrcdir)/ndr_frsapi.o
+
[SUBSYSTEM::NDR_DRSUAPI]
-OBJ_FILES = gen_ndr/ndr_drsuapi.o ndr/ndr_drsuapi.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_COMPRESSION NDR_SECURITY NDR_SAMR ASN1_UTIL
+NDR_DRSUAPI_OBJ_FILES = $(gen_ndrsrcdir)/ndr_drsuapi.o $(ndrsrcdir)/ndr_drsuapi.o
+
[SUBSYSTEM::NDR_DRSBLOBS]
-OBJ_FILES = gen_ndr/ndr_drsblobs.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC NDR_DRSUAPI
+NDR_DRSBLOBS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_drsblobs.o
+
[SUBSYSTEM::NDR_SASL_HELPERS]
-OBJ_FILES = gen_ndr/ndr_sasl_helpers.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_SASL_HELPERS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_sasl_helpers.o
+
[SUBSYSTEM::NDR_POLICYAGENT]
-OBJ_FILES = gen_ndr/ndr_policyagent.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_POLICYAGENT_OBJ_FILES = $(gen_ndrsrcdir)/ndr_policyagent.o
+
[SUBSYSTEM::NDR_UNIXINFO]
-OBJ_FILES = gen_ndr/ndr_unixinfo.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_SECURITY
+NDR_UNIXINFO_OBJ_FILES = $(gen_ndrsrcdir)/ndr_unixinfo.o
+
[SUBSYSTEM::NDR_SAMR]
-OBJ_FILES = gen_ndr/ndr_samr.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC NDR_LSA NDR_SECURITY
-PUBLIC_HEADERS += $(addprefix librpc/, gen_ndr/samr.h gen_ndr/ndr_samr.h gen_ndr/ndr_samr_c.h)
+NDR_SAMR_OBJ_FILES = $(gen_ndrsrcdir)/ndr_samr.o
+
+PUBLIC_HEADERS += $(addprefix $(librpcsrcdir)/, gen_ndr/samr.h gen_ndr/ndr_samr.h gen_ndr/ndr_samr_c.h)
[SUBSYSTEM::NDR_NFS4ACL]
-OBJ_FILES = gen_ndr/ndr_nfs4acl.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC NDR_SECURITY
+NDR_NFS4ACL_OBJ_FILES = $(gen_ndrsrcdir)/ndr_nfs4acl.o
+
[SUBSYSTEM::NDR_SPOOLSS]
-OBJ_FILES = gen_ndr/ndr_spoolss.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_SPOOLSS_BUF NDR_SECURITY
+NDR_SPOOLSS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_spoolss.o
+
[SUBSYSTEM::NDR_SPOOLSS_BUF]
-PRIVATE_PROTO_HEADER = ndr/ndr_spoolss_buf.h
-OBJ_FILES = ndr/ndr_spoolss_buf.o
+
+NDR_SPOOLSS_BUF_OBJ_FILES = $(ndrsrcdir)/ndr_spoolss_buf.o
+
+$(eval $(call proto_header_template,$(ndrsrcdir)/ndr_spoolss_buf.h,$(NDR_SPOOLSS_BUF_OBJ_FILES:.o=.c)))
[SUBSYSTEM::NDR_WKSSVC]
-OBJ_FILES = gen_ndr/ndr_wkssvc.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_SRVSVC NDR_MISC NDR_SECURITY
+NDR_WKSSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_wkssvc.o
+
[SUBSYSTEM::NDR_SRVSVC]
-OBJ_FILES = gen_ndr/ndr_srvsvc.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_SVCCTL NDR_SECURITY
+NDR_SRVSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_srvsvc.o
+
[SUBSYSTEM::NDR_SVCCTL]
-OBJ_FILES = gen_ndr/ndr_svcctl.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC
-PUBLIC_HEADERS += $(addprefix librpc/, gen_ndr/ndr_svcctl.h gen_ndr/svcctl.h)
+NDR_SVCCTL_OBJ_FILES = $(gen_ndrsrcdir)/ndr_svcctl.o
+
+PUBLIC_HEADERS += $(addprefix $(librpcsrcdir)/, gen_ndr/ndr_svcctl.h gen_ndr/svcctl.h)
[SUBSYSTEM::NDR_ATSVC]
-OBJ_FILES = gen_ndr/ndr_atsvc.o
PUBLIC_DEPENDENCIES = LIBNDR
-PUBLIC_HEADERS += $(addprefix librpc/, gen_ndr/atsvc.h gen_ndr/ndr_atsvc.h)
+NDR_ATSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_atsvc.o
+
+PUBLIC_HEADERS += $(addprefix $(librpcsrcdir)/, gen_ndr/atsvc.h gen_ndr/ndr_atsvc.h)
[SUBSYSTEM::NDR_EVENTLOG]
-OBJ_FILES = gen_ndr/ndr_eventlog.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_LSA
+NDR_EVENTLOG_OBJ_FILES = $(gen_ndrsrcdir)/ndr_eventlog.o
+
[SUBSYSTEM::NDR_EPMAPPER]
-OBJ_FILES = gen_ndr/ndr_epmapper.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC
+NDR_EPMAPPER_OBJ_FILES = $(gen_ndrsrcdir)/ndr_epmapper.o
+
[SUBSYSTEM::NDR_DBGIDL]
-OBJ_FILES = gen_ndr/ndr_dbgidl.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_DBGIDL_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dbgidl.o
+
[SUBSYSTEM::NDR_DSSETUP]
-OBJ_FILES = gen_ndr/ndr_dssetup.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC
+NDR_DSSETUP_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dssetup.o
+
[SUBSYSTEM::NDR_MSGSVC]
-OBJ_FILES = gen_ndr/ndr_msgsvc.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_MSGSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_msgsvc.o
+
[SUBSYSTEM::NDR_WINS]
-OBJ_FILES = gen_ndr/ndr_wins.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_WINS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_wins.o
+
[SUBSYSTEM::NDR_WINREG]
-OBJ_FILES = gen_ndr/ndr_winreg.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_INITSHUTDOWN NDR_SECURITY NDR_MISC
+NDR_WINREG_OBJ_FILES = $(gen_ndrsrcdir)/ndr_winreg.o
+
[SUBSYSTEM::NDR_INITSHUTDOWN]
-OBJ_FILES = gen_ndr/ndr_initshutdown.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_INITSHUTDOWN_OBJ_FILES = $(gen_ndrsrcdir)/ndr_initshutdown.o
+
[SUBSYSTEM::NDR_MGMT]
-OBJ_FILES = gen_ndr/ndr_mgmt.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_MGMT_OBJ_FILES = $(gen_ndrsrcdir)/ndr_mgmt.o
+
[SUBSYSTEM::NDR_PROTECTED_STORAGE]
-OBJ_FILES = gen_ndr/ndr_protected_storage.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_PROTECTED_STORAGE_OBJ_FILES = $(gen_ndrsrcdir)/ndr_protected_storage.o
+
[SUBSYSTEM::NDR_ORPC]
-OBJ_FILES = gen_ndr/ndr_orpc.o ndr/ndr_orpc.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_ORPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_orpc.o $(ndrsrcdir)/ndr_orpc.o
+
[SUBSYSTEM::NDR_OXIDRESOLVER]
-OBJ_FILES = gen_ndr/ndr_oxidresolver.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_ORPC NDR_MISC
+NDR_OXIDRESOLVER_OBJ_FILES = $(gen_ndrsrcdir)/ndr_oxidresolver.o
+
[SUBSYSTEM::NDR_REMACT]
-OBJ_FILES = gen_ndr/ndr_remact.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_ORPC NDR_MISC
+NDR_REMACT_OBJ_FILES = $(gen_ndrsrcdir)/ndr_remact.o
+
[SUBSYSTEM::NDR_WZCSVC]
-OBJ_FILES = gen_ndr/ndr_wzcsvc.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_WZCSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_wzcsvc.o
+
[SUBSYSTEM::NDR_BROWSER]
-OBJ_FILES = gen_ndr/ndr_browser.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_BROWSER_OBJ_FILES = $(gen_ndrsrcdir)/ndr_browser.o
+
[SUBSYSTEM::NDR_W32TIME]
-OBJ_FILES = gen_ndr/ndr_w32time.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_W32TIME_OBJ_FILES = $(gen_ndrsrcdir)/ndr_w32time.o
+
[SUBSYSTEM::NDR_SCERPC]
-OBJ_FILES = gen_ndr/ndr_scerpc.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_SCERPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_scerpc.o
+
[SUBSYSTEM::NDR_NTSVCS]
-OBJ_FILES = gen_ndr/ndr_ntsvcs.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_NTSVCS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_ntsvcs.o
+
[SUBSYSTEM::NDR_NETLOGON]
-OBJ_FILES = gen_ndr/ndr_netlogon.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_SAMR NDR_LSA NDR_SECURITY
-PUBLIC_HEADERS += $(addprefix librpc/, gen_ndr/netlogon.h)
+NDR_NETLOGON_OBJ_FILES = $(gen_ndrsrcdir)/ndr_netlogon.o
+
+PUBLIC_HEADERS += $(addprefix $(librpcsrcdir)/, gen_ndr/netlogon.h)
[SUBSYSTEM::NDR_TRKWKS]
-OBJ_FILES = gen_ndr/ndr_trkwks.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_TRKWKS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_trkwks.o
+
[SUBSYSTEM::NDR_KEYSVC]
-OBJ_FILES = gen_ndr/ndr_keysvc.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_KEYSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_keysvc.o
+
[SUBSYSTEM::NDR_KRB5PAC]
-OBJ_FILES = gen_ndr/ndr_krb5pac.o ndr/ndr_krb5pac.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_NETLOGON NDR_SECURITY
+NDR_KRB5PAC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_krb5pac.o $(ndrsrcdir)/ndr_krb5pac.o
+
[SUBSYSTEM::NDR_XATTR]
-OBJ_FILES = gen_ndr/ndr_xattr.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_SECURITY
+NDR_XATTR_OBJ_FILES = $(gen_ndrsrcdir)/ndr_xattr.o
+
[SUBSYSTEM::NDR_OPENDB]
-OBJ_FILES = gen_ndr/ndr_opendb.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_OPENDB_OBJ_FILES = $(gen_ndrsrcdir)/ndr_opendb.o
+
[SUBSYSTEM::NDR_NOTIFY]
-OBJ_FILES = gen_ndr/ndr_notify.o
PUBLIC_DEPENDENCIES = LIBNDR
+NDR_NOTIFY_OBJ_FILES = $(gen_ndrsrcdir)/ndr_notify.o
+
[SUBSYSTEM::NDR_SCHANNEL]
-OBJ_FILES = gen_ndr/ndr_schannel.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_NBT
+NDR_SCHANNEL_OBJ_FILES = $(gen_ndrsrcdir)/ndr_schannel.o
+
[SUBSYSTEM::NDR_NBT]
-OBJ_FILES = gen_ndr/ndr_nbt.o
-PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC NDR_NBT_BUF NDR_SVCCTL NDR_SECURITY
+PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC NDR_NBT_BUF NDR_SVCCTL NDR_SECURITY NDR_SAMR LIBCLI_NDR_NETLOGON
+
+NDR_NBT_OBJ_FILES = $(gen_ndrsrcdir)/ndr_nbt.o
-PUBLIC_HEADERS += librpc/gen_ndr/nbt.h
+PUBLIC_HEADERS += $(gen_ndrsrcdir)/nbt.h
[SUBSYSTEM::NDR_WINSREPL]
-OBJ_FILES = gen_ndr/ndr_winsrepl.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_NBT
+NDR_WINSREPL_OBJ_FILES = $(gen_ndrsrcdir)/ndr_winsrepl.o
+
[SUBSYSTEM::NDR_WINBIND]
-OBJ_FILES = gen_ndr/ndr_winbind.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_NETLOGON
-librpc/idl-deps:
- ./librpc/idl-deps.pl librpc/idl/*.idl >$@
+NDR_WINBIND_OBJ_FILES = $(gen_ndrsrcdir)/ndr_winbind.o
+#PUBLIC_HEADERS += $(gen_ndrsrcdir)/winbind.h
+
+$(librpcsrcdir)/idl-deps:
+ ./$(librpcsrcdir)/idl-deps.pl $(librpcsrcdir)/idl/*.idl >$@
clean::
- rm -f librpc/idl-deps
+ rm -f $(librpcsrcdir)/idl-deps
-include librpc/idl-deps
+include $(librpcsrcdir)/idl-deps
-librpc/gen_ndr/tables.c: $(IDL_NDR_PARSE_H_FILES)
+$(gen_ndrsrcdir)/tables.c: $(IDL_NDR_PARSE_H_FILES)
@echo Generating $@
- @$(PERL) $(srcdir)/librpc/tables.pl --output=$@ $^ > librpc/gen_ndr/tables.x
- @mv librpc/gen_ndr/tables.x $@
+ @$(PERL) $(librpcsrcdir)/tables.pl --output=$@ $^ > $(gen_ndrsrcdir)/tables.x
+ @mv $(gen_ndrsrcdir)/tables.x $@
[SUBSYSTEM::NDR_TABLE]
-OBJ_FILES = ndr/ndr_table.o gen_ndr/tables.o
-PRIVATE_PROTO_HEADER = ndr/ndr_table.h
PUBLIC_DEPENDENCIES = \
NDR_AUDIOSRV NDR_ECHO NDR_DCERPC \
NDR_DSBACKUP NDR_EFS NDR_MISC NDR_LSA NDR_DFS NDR_DRSUAPI \
@@ -314,184 +375,212 @@ PUBLIC_DEPENDENCIES = \
NDR_INITSHUTDOWN NDR_DNSSERVER NDR_WINSTATION NDR_IRPC NDR_OPENDB \
NDR_SASL_HELPERS NDR_NOTIFY NDR_WINBIND NDR_FRSRPC NDR_FRSAPI NDR_NFS4ACL
+NDR_TABLE_OBJ_FILES = $(ndrsrcdir)/ndr_table.o $(gen_ndrsrcdir)/tables.o
+
+$(eval $(call proto_header_template,$(ndrsrcdir)/ndr_table.h,$(NDR_TABLE_OBJ_FILES:.o=.c)))
+
[SUBSYSTEM::RPC_NDR_ROT]
-OBJ_FILES = gen_ndr/ndr_rot_c.o
PUBLIC_DEPENDENCIES = NDR_ROT dcerpc
+RPC_NDR_ROT_OBJ_FILES = $(gen_ndrsrcdir)/ndr_rot_c.o
+
[SUBSYSTEM::RPC_NDR_AUDIOSRV]
-OBJ_FILES = gen_ndr/ndr_audiosrv_c.o
PUBLIC_DEPENDENCIES = NDR_AUDIOSRV dcerpc
+RPC_NDR_AUDIOSRV_OBJ_FILES = $(gen_ndrsrcdir)/ndr_audiosrv_c.o
+
[SUBSYSTEM::RPC_NDR_ECHO]
-OBJ_FILES = gen_ndr/ndr_echo_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_ECHO
+RPC_NDR_ECHO_OBJ_FILES = $(gen_ndrsrcdir)/ndr_echo_c.o
+
[SUBSYSTEM::RPC_NDR_DSBACKUP]
-OBJ_FILES = gen_ndr/ndr_dsbackup_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_DSBACKUP
+RPC_NDR_DSBACKUP_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dsbackup_c.o
+
[SUBSYSTEM::RPC_NDR_EFS]
-OBJ_FILES = gen_ndr/ndr_efs_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_EFS
+RPC_NDR_EFS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_efs_c.o
+
[SUBSYSTEM::RPC_NDR_LSA]
-OBJ_FILES = gen_ndr/ndr_lsa_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_LSA
+RPC_NDR_LSA_OBJ_FILES = $(gen_ndrsrcdir)/ndr_lsa_c.o
+
[SUBSYSTEM::RPC_NDR_DFS]
-OBJ_FILES = gen_ndr/ndr_dfs_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_DFS
+RPC_NDR_DFS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dfs_c.o
+
[SUBSYSTEM::RPC_NDR_FRSAPI]
-OBJ_FILES = gen_ndr/ndr_frsapi_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_FRSAPI
+RPC_NDR_FRSAPI_OBJ_FILES = $(gen_ndrsrcdir)/ndr_frsapi_c.o
+
[SUBSYSTEM::RPC_NDR_DRSUAPI]
-OBJ_FILES = gen_ndr/ndr_drsuapi_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_DRSUAPI
+RPC_NDR_DRSUAPI_OBJ_FILES = $(gen_ndrsrcdir)/ndr_drsuapi_c.o
+
[SUBSYSTEM::RPC_NDR_POLICYAGENT]
-OBJ_FILES = gen_ndr/ndr_policyagent_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_POLICYAGENT
+RPC_NDR_POLICYAGENT_OBJ_FILES = $(gen_ndrsrcdir)/ndr_policyagent_c.o
+
[SUBSYSTEM::RPC_NDR_UNIXINFO]
-OBJ_FILES = gen_ndr/ndr_unixinfo_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_UNIXINFO
+RPC_NDR_UNIXINFO_OBJ_FILES = $(gen_ndrsrcdir)/ndr_unixinfo_c.o
+
[LIBRARY::dcerpc_samr]
-OBJ_FILES = gen_ndr/ndr_samr_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_SAMR
-PC_FILE = dcerpc_samr.pc
-VERSION = 0.0.1
-SO_VERSION = 0
+
+PC_FILES += $(librpcsrcdir)/dcerpc_samr.pc
+
+dcerpc_samr_VERSION = 0.0.1
+dcerpc_samr_SOVERSION = 0
+dcerpc_samr_OBJ_FILES = $(gen_ndrsrcdir)/ndr_samr_c.o
[SUBSYSTEM::RPC_NDR_SPOOLSS]
-OBJ_FILES = gen_ndr/ndr_spoolss_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_SPOOLSS
+RPC_NDR_SPOOLSS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_spoolss_c.o
+
[SUBSYSTEM::RPC_NDR_WKSSVC]
-OBJ_FILES = gen_ndr/ndr_wkssvc_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_WKSSVC
+RPC_NDR_WKSSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_wkssvc_c.o
+
[SUBSYSTEM::RPC_NDR_SRVSVC]
-OBJ_FILES = gen_ndr/ndr_srvsvc_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_SRVSVC
+RPC_NDR_SRVSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_srvsvc_c.o
+
[SUBSYSTEM::RPC_NDR_SVCCTL]
-OBJ_FILES = gen_ndr/ndr_svcctl_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_SVCCTL
-PUBLIC_HEADERS += librpc/gen_ndr/ndr_svcctl_c.h
+RPC_NDR_SVCCTL_OBJ_FILES = $(gen_ndrsrcdir)/ndr_svcctl_c.o
+
+PUBLIC_HEADERS += $(gen_ndrsrcdir)/ndr_svcctl_c.h
[LIBRARY::dcerpc_atsvc]
-OBJ_FILES = gen_ndr/ndr_atsvc_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_ATSVC
-PC_FILE = dcerpc_atsvc.pc
-VERSION = 0.0.1
-SO_VERSION = 0
-PUBLIC_HEADERS += librpc/gen_ndr/ndr_atsvc_c.h
+dcerpc_atsvc_VERSION = 0.0.1
+dcerpc_atsvc_SOVERSION = 0
+
+dcerpc_atsvc_OBJ_FILES = $(gen_ndrsrcdir)/ndr_atsvc_c.o
+PC_FILES += $(librpcsrcdir)/dcerpc_atsvc.pc
+
+PUBLIC_HEADERS += $(gen_ndrsrcdir)/ndr_atsvc_c.h
[SUBSYSTEM::RPC_NDR_EVENTLOG]
-OBJ_FILES = gen_ndr/ndr_eventlog_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_EVENTLOG
+RPC_NDR_EVENTLOG_OBJ_FILES = $(gen_ndrsrcdir)/ndr_eventlog_c.o
+
[SUBSYSTEM::RPC_NDR_EPMAPPER]
-OBJ_FILES = gen_ndr/ndr_epmapper_c.o
PUBLIC_DEPENDENCIES = NDR_EPMAPPER
+RPC_NDR_EPMAPPER_OBJ_FILES = $(gen_ndrsrcdir)/ndr_epmapper_c.o
+
[SUBSYSTEM::RPC_NDR_DBGIDL]
-OBJ_FILES = gen_ndr/ndr_dbgidl_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_DBGIDL
+RPC_NDR_DBGIDL_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dbgidl_c.o
+
[SUBSYSTEM::RPC_NDR_DSSETUP]
-OBJ_FILES = gen_ndr/ndr_dssetup_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_DSSETUP
+RPC_NDR_DSSETUP_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dssetup_c.o
+
[SUBSYSTEM::RPC_NDR_MSGSVC]
-OBJ_FILES = gen_ndr/ndr_msgsvc_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_MSGSVC
+RPC_NDR_MSGSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_msgsvc_c.o
+
[SUBSYSTEM::RPC_NDR_WINS]
-OBJ_FILES = gen_ndr/ndr_wins_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_WINS
+RPC_NDR_WINS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_wins_c.o
+
[SUBSYSTEM::RPC_NDR_WINREG]
-OBJ_FILES = gen_ndr/ndr_winreg_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_WINREG
+RPC_NDR_WINREG_OBJ_FILES = $(gen_ndrsrcdir)/ndr_winreg_c.o
+
[SUBSYSTEM::RPC_NDR_INITSHUTDOWN]
-OBJ_FILES = gen_ndr/ndr_initshutdown_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_INITSHUTDOWN
+RPC_NDR_INITSHUTDOWN_OBJ_FILES = $(gen_ndrsrcdir)/ndr_initshutdown_c.o
+
[SUBSYSTEM::RPC_NDR_MGMT]
-OBJ_FILES = gen_ndr/ndr_mgmt_c.o
PRIVATE_DEPENDENCIES = NDR_MGMT
+RPC_NDR_MGMT_OBJ_FILES = $(gen_ndrsrcdir)/ndr_mgmt_c.o
+
[SUBSYSTEM::RPC_NDR_PROTECTED_STORAGE]
-OBJ_FILES = gen_ndr/ndr_protected_storage_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_PROTECTED_STORAGE
+RPC_NDR_PROTECTED_STORAGE_OBJ_FILES = $(gen_ndrsrcdir)/ndr_protected_storage_c.o
+
[SUBSYSTEM::RPC_NDR_OXIDRESOLVER]
-OBJ_FILES = gen_ndr/ndr_oxidresolver_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_OXIDRESOLVER
+RPC_NDR_OXIDRESOLVER_OBJ_FILES = $(gen_ndrsrcdir)/ndr_oxidresolver_c.o
+
[SUBSYSTEM::RPC_NDR_REMACT]
-OBJ_FILES = gen_ndr/ndr_remact_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_REMACT
+RPC_NDR_REMACT_OBJ_FILES = $(gen_ndrsrcdir)/ndr_remact_c.o
+
[SUBSYSTEM::RPC_NDR_WZCSVC]
-OBJ_FILES = gen_ndr/ndr_wzcsvc_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_WZCSVC
+RPC_NDR_WZCSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_wzcsvc_c.o
+
[SUBSYSTEM::RPC_NDR_W32TIME]
-OBJ_FILES = gen_ndr/ndr_w32time_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_W32TIME
+RPC_NDR_W32TIME_OBJ_FILES = $(gen_ndrsrcdir)/ndr_w32time_c.o
+
[SUBSYSTEM::RPC_NDR_SCERPC]
-OBJ_FILES = gen_ndr/ndr_scerpc_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_SCERPC
+RPC_NDR_SCERPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_scerpc_c.o
+
[SUBSYSTEM::RPC_NDR_NTSVCS]
-OBJ_FILES = gen_ndr/ndr_ntsvcs_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_NTSVCS
+RPC_NDR_NTSVCS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_ntsvcs_c.o
+
[SUBSYSTEM::RPC_NDR_NETLOGON]
-OBJ_FILES = gen_ndr/ndr_netlogon_c.o
PUBLIC_DEPENDENCIES = NDR_NETLOGON
+RPC_NDR_NETLOGON_OBJ_FILES = $(gen_ndrsrcdir)/ndr_netlogon_c.o
+
[SUBSYSTEM::RPC_NDR_TRKWKS]
-OBJ_FILES = gen_ndr/ndr_trkwks_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_TRKWKS
+RPC_NDR_TRKWKS_OBJ_FILES = $(gen_ndrsrcdir)/ndr_trkwks_c.o
+
[SUBSYSTEM::RPC_NDR_KEYSVC]
-OBJ_FILES = gen_ndr/ndr_keysvc_c.o
PUBLIC_DEPENDENCIES = dcerpc NDR_KEYSVC
+RPC_NDR_KEYSVC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_keysvc_c.o
+
[SUBSYSTEM::NDR_DCERPC]
-OBJ_FILES = gen_ndr/ndr_dcerpc.o
PUBLIC_DEPENDENCIES = LIBNDR NDR_MISC
-PUBLIC_HEADERS += $(addprefix librpc/, gen_ndr/dcerpc.h gen_ndr/ndr_dcerpc.h)
+NDR_DCERPC_OBJ_FILES = $(gen_ndrsrcdir)/ndr_dcerpc.o
+
+PUBLIC_HEADERS += $(addprefix $(librpcsrcdir)/, gen_ndr/dcerpc.h gen_ndr/ndr_dcerpc.h)
################################################
# Start SUBSYSTEM dcerpc
[LIBRARY::dcerpc]
-VERSION = 0.0.1
-SO_VERSION = 0
-PC_FILE = dcerpc.pc
-PRIVATE_PROTO_HEADER = rpc/dcerpc_proto.h
-OBJ_FILES = \
- rpc/dcerpc.o \
- rpc/dcerpc_auth.o \
- rpc/dcerpc_schannel.o \
- rpc/dcerpc_util.o \
- rpc/dcerpc_error.o \
- rpc/dcerpc_smb.o \
- rpc/dcerpc_smb2.o \
- rpc/dcerpc_sock.o \
- rpc/dcerpc_connect.o \
- rpc/dcerpc_secondary.o
PRIVATE_DEPENDENCIES = \
samba-socket LIBCLI_RESOLVE LIBCLI_SMB LIBCLI_SMB2 \
LIBNDR NDR_DCERPC RPC_NDR_EPMAPPER \
@@ -503,154 +592,131 @@ PUBLIC_DEPENDENCIES = CREDENTIALS
# End SUBSYSTEM dcerpc
################################################
-PUBLIC_HEADERS += $(addprefix librpc/, rpc/dcerpc.h \
+PC_FILES += $(librpcsrcdir)/dcerpc.pc
+dcerpc_VERSION = 0.0.1
+dcerpc_SOVERSION = 0
+
+dcerpc_OBJ_FILES = $(addprefix $(dcerpcsrcdir)/, dcerpc.o dcerpc_auth.o dcerpc_schannel.o dcerpc_util.o binding.o \
+ dcerpc_error.o dcerpc_smb.o dcerpc_smb2.o dcerpc_sock.o dcerpc_connect.o dcerpc_secondary.o)
+
+$(eval $(call proto_header_template,$(dcerpcsrcdir)/dcerpc_proto.h,$(dcerpc_OBJ_FILES:.o=.c)))
+
+
+PUBLIC_HEADERS += $(addprefix $(librpcsrcdir)/, rpc/dcerpc.h \
gen_ndr/mgmt.h gen_ndr/ndr_mgmt.h gen_ndr/ndr_mgmt_c.h \
gen_ndr/epmapper.h gen_ndr/ndr_epmapper.h gen_ndr/ndr_epmapper_c.h)
-[MODULE::RPC_EJS_ECHO]
-INIT_FUNCTION = ejs_init_rpcecho
-OBJ_FILES = gen_ndr/ndr_echo_ejs.o
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_ECHO EJSRPC
-
-[MODULE::RPC_EJS_MISC]
-INIT_FUNCTION = ejs_init_misc
-OBJ_FILES = gen_ndr/ndr_misc_ejs.o
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_MISC EJSRPC
-
-[MODULE::RPC_EJS_SAMR]
-INIT_FUNCTION = ejs_init_samr
-OBJ_FILES = gen_ndr/ndr_samr_ejs.o
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_SAMR EJSRPC RPC_EJS_LSA RPC_EJS_SECURITY RPC_EJS_MISC
-
-[MODULE::RPC_EJS_SECURITY]
-INIT_FUNCTION = ejs_init_security
-OBJ_FILES = gen_ndr/ndr_security_ejs.o
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_SECURITY EJSRPC
-
-[MODULE::RPC_EJS_LSA]
-INIT_FUNCTION = ejs_init_lsarpc
-OBJ_FILES = gen_ndr/ndr_lsa_ejs.o
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_LSA EJSRPC RPC_EJS_SECURITY RPC_EJS_MISC
-
-[MODULE::RPC_EJS_DFS]
-INIT_FUNCTION = ejs_init_netdfs
-OBJ_FILES = gen_ndr/ndr_dfs_ejs.o
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_DFS EJSRPC
-
-[MODULE::RPC_EJS_DRSUAPI]
-INIT_FUNCTION = ejs_init_drsuapi
-OBJ_FILES = gen_ndr/ndr_drsuapi_ejs.o
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_DRSUAPI EJSRPC RPC_EJS_MISC RPC_EJS_SAMR
-
-[MODULE::RPC_EJS_SPOOLSS]
-INIT_FUNCTION = ejs_init_spoolss
-OBJ_FILES = gen_ndr/ndr_spoolss_ejs.o
-SUBSYSTEM = smbcalls
-ENABLE = NO
-PRIVATE_DEPENDENCIES = dcerpc NDR_SPOOLSS EJSRPC
-
-[MODULE::RPC_EJS_WKSSVC]
-INIT_FUNCTION = ejs_init_wkssvc
-OBJ_FILES = gen_ndr/ndr_wkssvc_ejs.o
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_WKSSVC EJSRPC RPC_EJS_SRVSVC RPC_EJS_MISC
-
-[MODULE::RPC_EJS_SRVSVC]
-INIT_FUNCTION = ejs_init_srvsvc
-OBJ_FILES = gen_ndr/ndr_srvsvc_ejs.o
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_SRVSVC EJSRPC RPC_EJS_MISC RPC_EJS_SVCCTL RPC_EJS_SECURITY
-
-[MODULE::RPC_EJS_EVENTLOG]
-INIT_FUNCTION = ejs_init_eventlog
-OBJ_FILES = gen_ndr/ndr_eventlog_ejs.o
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_EVENTLOG EJSRPC RPC_EJS_MISC
-
-[MODULE::RPC_EJS_WINREG]
-INIT_FUNCTION = ejs_init_winreg
-OBJ_FILES = gen_ndr/ndr_winreg_ejs.o
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_WINREG EJSRPC RPC_EJS_INITSHUTDOWN \
- RPC_EJS_MISC RPC_EJS_SECURITY
-
-[MODULE::RPC_EJS_INITSHUTDOWN]
-INIT_FUNCTION = ejs_init_initshutdown
-OBJ_FILES = gen_ndr/ndr_initshutdown_ejs.o
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_INITSHUTDOWN EJSRPC
-
-[MODULE::RPC_EJS_NETLOGON]
-INIT_FUNCTION = ejs_init_netlogon
-OBJ_FILES = gen_ndr/ndr_netlogon_ejs.o
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_NETLOGON EJSRPC RPC_EJS_SAMR RPC_EJS_SECURITY RPC_EJS_MISC
-
-[MODULE::RPC_EJS_SVCCTL]
-INIT_FUNCTION = ejs_init_svcctl
-OBJ_FILES = gen_ndr/ndr_svcctl_ejs.o
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_SVCCTL EJSRPC RPC_EJS_MISC
-
-[MODULE::RPC_EJS_IRPC]
-INIT_FUNCTION = ejs_init_irpc
-OBJ_FILES = gen_ndr/ndr_irpc_ejs.o
-SUBSYSTEM = smbcalls
-PRIVATE_DEPENDENCIES = dcerpc NDR_IRPC EJSRPC
-
[PYTHON::swig_dcerpc]
-SWIG_FILE = rpc/dcerpc.i
+LIBRARY_REALNAME = samba/dcerpc/_dcerpc.$(SHLIBEXT)
PUBLIC_DEPENDENCIES = LIBCLI_SMB NDR_MISC LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG dcerpc_samr RPC_NDR_LSA DYNCONFIG
+swig_dcerpc_OBJ_FILES = $(dcerpcsrcdir)/dcerpc_wrap.o
+
+$(eval $(call python_py_module_template,samba/dcerpc/__init__.py,$(dcerpcsrcdir)/dcerpc.py))
+
+$(swig_dcerpc_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
+
[PYTHON::python_echo]
-OBJ_FILES = gen_ndr/py_echo.o
-PRIVATE_DEPENDENCIES = RPC_NDR_ECHO
+LIBRARY_REALNAME = samba/dcerpc/echo.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = RPC_NDR_ECHO PYTALLOC param swig_credentials
+
+python_echo_OBJ_FILES = $(gen_ndrsrcdir)/py_echo.o
[PYTHON::python_winreg]
-OBJ_FILES = gen_ndr/py_winreg.o
-PRIVATE_DEPENDENCIES = RPC_NDR_WINREG python_misc
+LIBRARY_REALNAME = samba/dcerpc/winreg.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = RPC_NDR_WINREG python_misc PYTALLOC param swig_credentials python_dcerpc_misc python_lsa
+
+python_winreg_OBJ_FILES = $(gen_ndrsrcdir)/py_winreg.o
[PYTHON::python_dcerpc_misc]
-OBJ_FILES = gen_ndr/py_misc.o
+LIBRARY_REALNAME = samba/dcerpc/misc.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = PYTALLOC
+
+python_dcerpc_misc_OBJ_FILES = $(gen_ndrsrcdir)/py_misc.o
[PYTHON::python_initshutdown]
-OBJ_FILES = gen_ndr/py_initshutdown.o
-PRIVATE_DEPENDENCIES = RPC_NDR_INITSHUTDOWN
+LIBRARY_REALNAME = samba/dcerpc/initshutdown.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = RPC_NDR_INITSHUTDOWN PYTALLOC param swig_credentials python_lsa python_dcerpc_security
+
+python_initshutdown_OBJ_FILES = $(gen_ndrsrcdir)/py_initshutdown.o
[PYTHON::python_epmapper]
-OBJ_FILES = gen_ndr/py_epmapper.o
+LIBRARY_REALNAME = samba/dcerpc/epmapper.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = dcerpc PYTALLOC param swig_credentials python_dcerpc_misc
+
+python_epmapper_OBJ_FILES = $(gen_ndrsrcdir)/py_epmapper.o
[PYTHON::python_mgmt]
-OBJ_FILES = gen_ndr/py_mgmt.o
-PRIVATE_DEPENDENCIES = dcerpc_mgmt
+LIBRARY_REALNAME = samba/dcerpc/mgmt.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = PYTALLOC param swig_credentials dcerpc python_dcerpc_misc
+
+python_mgmt_OBJ_FILES = $(gen_ndrsrcdir)/py_mgmt.o
[PYTHON::python_atsvc]
-OBJ_FILES = gen_ndr/py_atsvc.o
-PRIVATE_DEPENDENCIES = dcerpc_atsvc
+LIBRARY_REALNAME = samba/dcerpc/atsvc.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = dcerpc_atsvc PYTALLOC param swig_credentials
+
+python_atsvc_OBJ_FILES = $(gen_ndrsrcdir)/py_atsvc.o
[PYTHON::python_samr]
-OBJ_FILES = gen_ndr/py_samr.o
-PRIVATE_DEPENDENCIES = dcerpc_samr
+LIBRARY_REALNAME = samba/dcerpc/samr.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = dcerpc_samr PYTALLOC python_dcerpc_security python_lsa python_dcerpc_misc swig_credentials param
+
+python_samr_OBJ_FILES = $(gen_ndrsrcdir)/py_samr.o
[PYTHON::python_svcctl]
-OBJ_FILES = gen_ndr/py_svcctl.o
-PRIVATE_DEPENDENCIES = RPC_NDR_SVCCTL
+LIBRARY_REALNAME = samba/dcerpc/svcctl.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = RPC_NDR_SVCCTL PYTALLOC param swig_credentials python_dcerpc_misc
+
+python_svcctl_OBJ_FILES = $(gen_ndrsrcdir)/py_svcctl.o
[PYTHON::python_lsa]
-OBJ_FILES = gen_ndr/py_lsa.o
-PRIVATE_DEPENDENCIES = RPC_NDR_LSA
+LIBRARY_REALNAME = samba/dcerpc/lsa.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = RPC_NDR_LSA PYTALLOC param swig_credentials python_dcerpc_security
+
+python_lsa_OBJ_FILES = $(gen_ndrsrcdir)/py_lsa.o
[PYTHON::python_wkssvc]
-OBJ_FILES = gen_ndr/py_wkssvc.o
-PRIVATE_DEPENDENCIES = RPC_NDR_WKSSVC
+LIBRARY_REALNAME = samba/dcerpc/wkssvc.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = RPC_NDR_WKSSVC PYTALLOC param swig_credentials python_lsa python_dcerpc_security
+
+python_wkssvc_OBJ_FILES = $(gen_ndrsrcdir)/py_wkssvc.o
+
+[PYTHON::python_dfs]
+LIBRARY_REALNAME = samba/dcerpc/dfs.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = RPC_NDR_DFS PYTALLOC param swig_credentials python_dcerpc_misc
+
+python_dfs_OBJ_FILES = $(gen_ndrsrcdir)/py_dfs.o
+
+[PYTHON::python_unixinfo]
+LIBRARY_REALNAME = samba/dcerpc/unixinfo.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = RPC_NDR_UNIXINFO PYTALLOC param swig_credentials python_dcerpc_security python_dcerpc_misc
+
+python_unixinfo_OBJ_FILES = $(gen_ndrsrcdir)/py_unixinfo.o
+
+[PYTHON::python_drsuapi]
+LIBRARY_REALNAME = samba/dcerpc/drsuapi.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = RPC_NDR_DRSUAPI PYTALLOC param swig_credentials python_dcerpc_misc python_dcerpc_security
+
+python_drsuapi_OBJ_FILES = $(gen_ndrsrcdir)/py_drsuapi.o
[PYTHON::python_dcerpc_security]
-OBJ_FILES = gen_ndr/py_security.o
+LIBRARY_REALNAME = samba/dcerpc/security.$(SHLIBEXT)
+PRIVATE_DEPENDENCIES = PYTALLOC python_dcerpc_misc
+
+python_dcerpc_security_OBJ_FILES = $(gen_ndrsrcdir)/py_security.o
+
+$(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:: $(pidldir)/lib/Parse/Pidl/IDL.pm $(pidldir)/lib/Parse/Pidl/Expr.pm
+ @CPP="$(CPP)" PIDL="$(PIDL)" $(librpcsrcdir)/scripts/build_idl.sh FULL $(librpcsrcdir)/idl $(librpcsrcdir)/gen_ndr
+
+idl:: $(pidldir)/lib/Parse/Pidl/IDL.pm $(pidldir)/lib/Parse/Pidl/Expr.pm
+ @CPP="$(CPP)" PIDL="$(PIDL)" $(librpcsrcdir)/scripts/build_idl.sh PARTIAL $(librpcsrcdir)/idl $(librpcsrcdir)/gen_ndr
+
+
diff --git a/source4/librpc/idl-deps.pl b/source4/librpc/idl-deps.pl
index d5bfe0b2ec..e630ee4f61 100755
--- a/source4/librpc/idl-deps.pl
+++ b/source4/librpc/idl-deps.pl
@@ -6,17 +6,17 @@ my %vars = ();
foreach(@ARGV) {
push (@{$vars{IDL_FILES}}, $_);
my $b = $_; $b =~ s/.*\/(.*?).idl$/$1/;
- push (@{$vars{IDL_HEADER_FILES}}, "librpc/gen_ndr/$b.h");
- push (@{$vars{IDL_NDR_PARSE_H_FILES}}, "librpc/gen_ndr/ndr_$b.h");
- push (@{$vars{IDL_NDR_PARSE_C_FILES}}, "librpc/gen_ndr/ndr_$b.c");
- push (@{$vars{IDL_NDR_CLIENT_C_FILES}}, "librpc/gen_ndr/ndr_$b\_c.c");
- push (@{$vars{IDL_NDR_CLIENT_H_FILES}}, "librpc/gen_ndr/ndr_$b\_c.h");
- push (@{$vars{IDL_SWIG_FILES}}, "librpc/gen_ndr/$b.i");
- push (@{$vars{IDL_NDR_SERVER_C_FILES}}, "librpc/gen_ndr/ndr_$b\_s.c");
- push (@{$vars{IDL_NDR_EJS_C_FILES}}, "librpc/gen_ndr/ndr_$b\_ejs.c");
- push (@{$vars{IDL_NDR_EJS_H_FILES}}, "librpc/gen_ndr/ndr_$b\_ejs.h");
- push (@{$vars{IDL_NDR_PY_C_FILES}}, "librpc/gen_ndr/py_$b.c");
- push (@{$vars{IDL_NDR_PY_H_FILES}}, "librpc/gen_ndr/py_$b.h");
+ push (@{$vars{IDL_HEADER_FILES}}, "\$(librpcsrcdir)/gen_ndr/$b.h");
+ push (@{$vars{IDL_NDR_PARSE_H_FILES}}, "\$(librpcsrcdir)/gen_ndr/ndr_$b.h");
+ push (@{$vars{IDL_NDR_PARSE_C_FILES}}, "\$(librpcsrcdir)/gen_ndr/ndr_$b.c");
+ push (@{$vars{IDL_NDR_CLIENT_C_FILES}}, "\$(librpcsrcdir)/gen_ndr/ndr_$b\_c.c");
+ push (@{$vars{IDL_NDR_CLIENT_H_FILES}}, "\$(librpcsrcdir)/gen_ndr/ndr_$b\_c.h");
+ push (@{$vars{IDL_SWIG_FILES}}, "\$(librpcsrcdir)/gen_ndr/$b.i");
+ push (@{$vars{IDL_NDR_SERVER_C_FILES}}, "\$(librpcsrcdir)/gen_ndr/ndr_$b\_s.c");
+ push (@{$vars{IDL_NDR_EJS_C_FILES}}, "\$(librpcsrcdir)/gen_ndr/ndr_$b\_ejs.c");
+ push (@{$vars{IDL_NDR_EJS_H_FILES}}, "\$(librpcsrcdir)/gen_ndr/ndr_$b\_ejs.h");
+ push (@{$vars{IDL_NDR_PY_C_FILES}}, "\$(librpcsrcdir)/gen_ndr/py_$b.c");
+ push (@{$vars{IDL_NDR_PY_H_FILES}}, "\$(librpcsrcdir)/gen_ndr/py_$b.h");
}
foreach (keys %vars) {
diff --git a/source4/librpc/idl/audiosrv.idl b/source4/librpc/idl/audiosrv.idl
index 9b9399ffee..1b059868ff 100644
--- a/source4/librpc/idl/audiosrv.idl
+++ b/source4/librpc/idl/audiosrv.idl
@@ -5,19 +5,19 @@
helpstring("Audio Server")
] interface audiosrv
{
- void audiosrv_CreatezoneFactoriesList();
- void audiosrv_CreateGfxFactoriesList();
- void audiosrv_CreateGfxList();
- void audiosrv_RemoveGfx();
- void audiosrv_AddGfx();
- void audiosrv_ModifyGfx();
- void audiosrv_OpenGfx();
- void audiosrv_Logon();
- void audiosrv_Logoff();
- void audiosrv_RegisterSessionNotificationEvent();
- void audiosrv_UnregisterSessionNotificationEvent();
- void audiosrv_SessionConnectState();
- void audiosrv_DriverOpenDrvRegKey();
- void audiosrv_AdvisePreferredDeviceChange();
- void audiosrv_GetPnpInfo();
+ [todo] void audiosrv_CreatezoneFactoriesList();
+ [todo] void audiosrv_CreateGfxFactoriesList();
+ [todo] void audiosrv_CreateGfxList();
+ [todo] void audiosrv_RemoveGfx();
+ [todo] void audiosrv_AddGfx();
+ [todo] void audiosrv_ModifyGfx();
+ [todo] void audiosrv_OpenGfx();
+ [todo] void audiosrv_Logon();
+ [todo] void audiosrv_Logoff();
+ [todo] void audiosrv_RegisterSessionNotificationEvent();
+ [todo] void audiosrv_UnregisterSessionNotificationEvent();
+ [todo] void audiosrv_SessionConnectState();
+ [todo] void audiosrv_DriverOpenDrvRegKey();
+ [todo] void audiosrv_AdvisePreferredDeviceChange();
+ [todo] void audiosrv_GetPnpInfo();
}
diff --git a/source4/librpc/idl/browser.idl b/source4/librpc/idl/browser.idl
index 5cc2475119..5b05be9cbb 100644
--- a/source4/librpc/idl/browser.idl
+++ b/source4/librpc/idl/browser.idl
@@ -9,50 +9,50 @@ interface browser
{
/******************/
/* Function 0x00 */
- NTSTATUS BrowserrServerEnum();
+ [todo] NTSTATUS BrowserrServerEnum();
/******************/
/* Function 0x01 */
- NTSTATUS BrowserrDebugCall();
+ [todo] NTSTATUS BrowserrDebugCall();
/******************/
/* Function 0x02 */
- NTSTATUS BrowserrQueryOtherDomains();
+ [todo] NTSTATUS BrowserrQueryOtherDomains();
/******************/
/* Function 0x03 */
- NTSTATUS BrowserrResetNetlogonState();
+ [todo] NTSTATUS BrowserrResetNetlogonState();
/******************/
/* Function 0x04 */
- NTSTATUS BrowserrDebugTrace();
+ [todo] NTSTATUS BrowserrDebugTrace();
/******************/
/* Function 0x05 */
- NTSTATUS BrowserrQueryStatistics();
+ [todo] NTSTATUS BrowserrQueryStatistics();
/******************/
/* Function 0x06 */
- NTSTATUS BrowserResetStatistics();
+ [todo] NTSTATUS BrowserResetStatistics();
/******************/
/* Function 0x07 */
- NTSTATUS NetrBrowserStatisticsClear();
+ [todo] NTSTATUS NetrBrowserStatisticsClear();
/******************/
/* Function 0x08 */
- NTSTATUS NetrBrowserStatisticsGet();
+ [todo] NTSTATUS NetrBrowserStatisticsGet();
/******************/
/* Function 0x09 */
- NTSTATUS BrowserrSetNetlogonState();
+ [todo] NTSTATUS BrowserrSetNetlogonState();
/******************/
/* Function 0x0a */
- NTSTATUS BrowserrQueryEmulatedDomains();
+ [todo] NTSTATUS BrowserrQueryEmulatedDomains();
/******************/
/* Function 0x0b */
- NTSTATUS BrowserrServerEnumEx();
+ [todo] NTSTATUS BrowserrServerEnumEx();
}
diff --git a/source4/librpc/idl/dcerpc.idl b/source4/librpc/idl/dcerpc.idl
index b2c67542f5..e228d85c46 100644
--- a/source4/librpc/idl/dcerpc.idl
+++ b/source4/librpc/idl/dcerpc.idl
@@ -116,6 +116,7 @@ interface dcerpc
uint16 context_id;
uint8 cancel_count;
uint32 status;
+ [flag(NDR_REMAINING)] DATA_BLOB _pad;
} dcerpc_fault;
/* the auth types we know about */
diff --git a/source4/librpc/idl/dfs.idl b/source4/librpc/idl/dfs.idl
index dbbd15039c..b279f555d9 100644
--- a/source4/librpc/idl/dfs.idl
+++ b/source4/librpc/idl/dfs.idl
@@ -308,16 +308,16 @@ import "misc.idl";
);
/* Function 0x06 */
- WERROR dfs_Rename();
+ [todo] WERROR dfs_Rename();
/* Function 0x07 */
- WERROR dfs_Move();
+ [todo] WERROR dfs_Move();
/* Function 0x08 */
- WERROR dfs_ManagerGetConfigInfo();
+ [todo] WERROR dfs_ManagerGetConfigInfo();
/* Function 0x09 */
- WERROR dfs_ManagerSendSiteInfo();
+ [todo] WERROR dfs_ManagerSendSiteInfo();
/* Function 0x0a */
typedef struct {
@@ -399,10 +399,10 @@ import "misc.idl";
);
/* Function 0x13 */
- WERROR dfs_Add2();
+ [todo] WERROR dfs_Add2();
/* Function 0x14 */
- WERROR dfs_Remove2();
+ [todo] WERROR dfs_Remove2();
/* Function 0x15 */
[public] WERROR dfs_EnumEx(
@@ -414,5 +414,5 @@ import "misc.idl";
);
/* Function 0x16 */
- WERROR dfs_SetInfo2();
+ [todo] WERROR dfs_SetInfo2();
}
diff --git a/source4/librpc/idl/drsuapi.idl b/source4/librpc/idl/drsuapi.idl
index fb24122e26..2f48287233 100644
--- a/source4/librpc/idl/drsuapi.idl
+++ b/source4/librpc/idl/drsuapi.idl
@@ -666,7 +666,7 @@ interface drsuapi
/* TODO ... */
} drsuapi_DsReplicaAddOptions;
- WERROR DRSUAPI_REPLICA_ADD();
+ [todo] WERROR DRSUAPI_REPLICA_ADD();
/*****************/
/* Function 0x06 */
@@ -676,7 +676,7 @@ interface drsuapi
/* TODO ... */
} drsuapi_DsReplicaDeleteOptions;
- WERROR DRSUAPI_REPLICA_DEL();
+ [todo] WERROR DRSUAPI_REPLICA_DEL();
/*****************/
/* Function 0x07 */
@@ -685,11 +685,11 @@ interface drsuapi
DRSUAPI_DS_REPLICA_MODIFY_WRITEABLE = 0x00000002
} drsuapi_DsReplicaModifyOptions;
- WERROR DRSUAPI_REPLICA_MODIFY();
+ [todo] WERROR DRSUAPI_REPLICA_MODIFY();
/*****************/
/* Function 0x08 */
- WERROR DRSUAPI_VERIFY_NAMES();
+ [todo] WERROR DRSUAPI_VERIFY_NAMES();
/*****************/
/* Function 0x09 */
@@ -732,7 +732,7 @@ interface drsuapi
[case(1)] drsuapi_DsGetMembershipsRequest1 req1;
} drsuapi_DsGetMembershipsRequest;
- WERROR drsuapi_DsGetMemberships(
+ [todo] WERROR drsuapi_DsGetMemberships(
[in] policy_handle *bind_handle,
[in,out] int32 level,
[in] [switch_is(level)] drsuapi_DsGetMembershipsRequest req,
@@ -741,7 +741,7 @@ interface drsuapi
/*****************/
/* Function 0x0a */
- WERROR DRSUAPI_INTER_DOMAIN_MOVE();
+ [todo] WERROR DRSUAPI_INTER_DOMAIN_MOVE();
/*****************/
/* Function 0x0b */
@@ -774,7 +774,7 @@ interface drsuapi
[case(1)] drsuapi_DsGetNT4ChangeLogInfo1 info1;
} drsuapi_DsGetNT4ChangeLogInfo;
- WERROR drsuapi_DsGetNT4ChangeLog(
+ [todo] WERROR drsuapi_DsGetNT4ChangeLog(
[in] policy_handle *bind_handle,
[in,out] uint32 level,
[in] [switch_is(level)] drsuapi_DsGetNT4ChangeLogRequest req,
@@ -920,7 +920,7 @@ interface drsuapi
/*****************/
/* Function 0x0f */
- WERROR DRSUAPI_REMOVE_DS_DOMAIN();
+ [todo] WERROR DRSUAPI_REMOVE_DS_DOMAIN();
/*****************/
/* Function 0x10 */
@@ -1138,7 +1138,7 @@ interface drsuapi
/*****************/
/* Function 0x12 */
- WERROR DRSUAPI_EXECUTE_KCC();
+ [todo] WERROR DRSUAPI_EXECUTE_KCC();
/*****************/
/* Function 0x13 */
@@ -1419,7 +1419,7 @@ interface drsuapi
/*****************/
/* Function 0x14 */
- WERROR DRSUAPI_ADD_SID_HISTORY();
+ [todo] WERROR DRSUAPI_ADD_SID_HISTORY();
/*****************/
/* Function 0x15 */
@@ -1452,11 +1452,11 @@ interface drsuapi
/*****************/
/* Function 0x16 */
- WERROR DRSUAPI_REPLICA_VERIFY_OBJECTS();
+ [todo] WERROR DRSUAPI_REPLICA_VERIFY_OBJECTS();
/*****************/
/* Function 0x17 */
- WERROR DRSUAPI_GET_OBJECT_EXISTENCE();
+ [todo] WERROR DRSUAPI_GET_OBJECT_EXISTENCE();
/*****************/
/* Function 0x18 */
diff --git a/source4/librpc/idl/dsbackup.idl b/source4/librpc/idl/dsbackup.idl
index 21dca8fa0e..72e8bf9c2b 100644
--- a/source4/librpc/idl/dsbackup.idl
+++ b/source4/librpc/idl/dsbackup.idl
@@ -5,15 +5,15 @@
helpstring("Backup support for Active Directory")
] interface ad_backup
{
- void HrRBackupPrepare();
- void HrRBackupEnd();
- void HrRBackupGetAttachmentInformation();
- void HrRBackupOpenFile();
- void HrRBackupRead();
- void HrRBackupClose();
- void HrRBackupGetBackupLogs();
- void HrRBackupTruncateLogs();
- void HrRBackupPing();
+ [todo] void HrRBackupPrepare();
+ [todo] void HrRBackupEnd();
+ [todo] void HrRBackupGetAttachmentInformation();
+ [todo] void HrRBackupOpenFile();
+ [todo] void HrRBackupRead();
+ [todo] void HrRBackupClose();
+ [todo] void HrRBackupGetBackupLogs();
+ [todo] void HrRBackupTruncateLogs();
+ [todo] void HrRBackupPing();
}
[
@@ -23,12 +23,12 @@
helpstring("Restoring Active Directory backups")
] interface ad_restore
{
- void HrRIsNTDSOnline();
- void HrRRestorePrepare();
- void HrRRestoreRegister();
- void HrRRestoreRegisterComplete();
- void HrRRestoreGetDatabaseLocations();
- void HrRRestoreEnd();
- void HrRRestoreSetCurrentLogNumber();
- void HrRRestoreCheckLogsForBackup();
+ [todo] void HrRIsNTDSOnline();
+ [todo] void HrRRestorePrepare();
+ [todo] void HrRRestoreRegister();
+ [todo] void HrRRestoreRegisterComplete();
+ [todo] void HrRRestoreGetDatabaseLocations();
+ [todo] void HrRRestoreEnd();
+ [todo] void HrRRestoreSetCurrentLogNumber();
+ [todo] void HrRRestoreCheckLogsForBackup();
}
diff --git a/source4/librpc/idl/dssetup.idl b/source4/librpc/idl/dssetup.idl
index af6350cc43..14de9f7633 100644
--- a/source4/librpc/idl/dssetup.idl
+++ b/source4/librpc/idl/dssetup.idl
@@ -88,14 +88,14 @@ import "misc.idl";
These stubs are left here only as a way of documenting the names
of the calls in case they ever turn up on the wire.
*/
- WERROR dssetup_DsRoleDnsNameToFlatName();
- WERROR dssetup_DsRoleDcAsDc();
- WERROR dssetup_DsRoleDcAsReplica();
- WERROR dssetup_DsRoleDemoteDc();
- WERROR dssetup_DsRoleGetDcOperationProgress();
- WERROR dssetup_DsRoleGetDcOperationResults();
- WERROR dssetup_DsRoleCancel();
- WERROR dssetup_DsRoleServerSaveStateForUpgrade();
- WERROR dssetup_DsRoleUpgradeDownlevelServer();
- WERROR dssetup_DsRoleAbortDownlevelServerUpgrade();
+ [todo] WERROR dssetup_DsRoleDnsNameToFlatName();
+ [todo] WERROR dssetup_DsRoleDcAsDc();
+ [todo] WERROR dssetup_DsRoleDcAsReplica();
+ [todo] WERROR dssetup_DsRoleDemoteDc();
+ [todo] WERROR dssetup_DsRoleGetDcOperationProgress();
+ [todo] WERROR dssetup_DsRoleGetDcOperationResults();
+ [todo] WERROR dssetup_DsRoleCancel();
+ [todo] WERROR dssetup_DsRoleServerSaveStateForUpgrade();
+ [todo] WERROR dssetup_DsRoleUpgradeDownlevelServer();
+ [todo] WERROR dssetup_DsRoleAbortDownlevelServerUpgrade();
}
diff --git a/source4/librpc/idl/efs.idl b/source4/librpc/idl/efs.idl
index 62fefda606..4279b08d13 100644
--- a/source4/librpc/idl/efs.idl
+++ b/source4/librpc/idl/efs.idl
@@ -18,13 +18,13 @@ WERROR EfsRpcOpenFileRaw(
[in] uint32 Flags
);
-WERROR EfsRpcReadFileRaw(
+[todo] WERROR EfsRpcReadFileRaw(
[in,ref] policy_handle *pvContext
/* incomplete */
);
-WERROR EfsRpcWriteFileRaw(
+[todo] WERROR EfsRpcWriteFileRaw(
[in,ref] policy_handle *pvContext
/* incomplete */
);
@@ -70,12 +70,12 @@ WERROR EfsRpcQueryRecoveryAgents(
[out,ref,unique] ENCRYPTION_CERTIFICATE_HASH_LIST **pRecoveryAgents
);
-WERROR EfsRpcRemoveUsersFromFile(
+[todo] WERROR EfsRpcRemoveUsersFromFile(
[in] [charset(UTF16),string] uint16 FileName[]
/* [in] ENCRYPTION_CERTIFICATE_LIST Hashes*/
);
-WERROR EfsRpcAddUsersToFile(
+[todo] WERROR EfsRpcAddUsersToFile(
[in] [charset(UTF16),string] uint16 FileName[]
/* [in] ENCRYPTION_CERTIFICATE_LIST Hashes*/
);
@@ -96,13 +96,13 @@ WERROR EfsRpcSetFileEncryptionKey(
[in] [unique] ENCRYPTION_CERTIFICATE *pEncryptionCertificate
);
-WERROR EfsRpcNotSupported(
+[todo] WERROR EfsRpcNotSupported(
);
-WERROR EfsRpcFileKeyInfo(
+[todo] WERROR EfsRpcFileKeyInfo(
);
-WERROR EfsRpcDuplicateEncryptionInfoFile(
+[todo] WERROR EfsRpcDuplicateEncryptionInfoFile(
);
}
diff --git a/source4/librpc/idl/epmapper.idl b/source4/librpc/idl/epmapper.idl
index 60ff338ec4..ea04878094 100644
--- a/source4/librpc/idl/epmapper.idl
+++ b/source4/librpc/idl/epmapper.idl
@@ -310,5 +310,5 @@ interface epmapper
/**********************/
/* Function 0x07 */
- error_status_t epm_MapAuth();
+ [todo] error_status_t epm_MapAuth();
}
diff --git a/source4/librpc/idl/eventlog.idl b/source4/librpc/idl/eventlog.idl
index 3defd99400..ee42300c7c 100644
--- a/source4/librpc/idl/eventlog.idl
+++ b/source4/librpc/idl/eventlog.idl
@@ -65,7 +65,7 @@ import "lsa.idl", "security.idl";
/******************/
/* Function: 0x01 */
- NTSTATUS eventlog_BackupEventLogW();
+ [todo] NTSTATUS eventlog_BackupEventLogW();
/******************/
/* Function: 0x02 */
@@ -75,7 +75,7 @@ import "lsa.idl", "security.idl";
/******************/
/* Function: 0x03 */
- NTSTATUS eventlog_DeregisterEventSource();
+ [todo] NTSTATUS eventlog_DeregisterEventSource();
/******************/
/* Function: 0x04 */
@@ -86,11 +86,11 @@ import "lsa.idl", "security.idl";
/******************/
/* Function: 0x05 */
- NTSTATUS eventlog_GetOldestRecord();
+ [todo] NTSTATUS eventlog_GetOldestRecord();
/******************/
/* Function: 0x06 */
- NTSTATUS eventlog_ChangeNotify();
+ [todo] NTSTATUS eventlog_ChangeNotify();
/******************/
/* Function: 0x07 */
@@ -105,11 +105,11 @@ import "lsa.idl", "security.idl";
/******************/
/* Function: 0x08 */
- NTSTATUS eventlog_RegisterEventSourceW();
+ [todo] NTSTATUS eventlog_RegisterEventSourceW();
/******************/
/* Function: 0x09 */
- NTSTATUS eventlog_OpenBackupEventLogW();
+ [todo] NTSTATUS eventlog_OpenBackupEventLogW();
/******************/
/* Function: 0x0a */
@@ -125,51 +125,51 @@ import "lsa.idl", "security.idl";
/*****************/
/* Function 0x0b */
- NTSTATUS eventlog_ReportEventW();
+ [todo] NTSTATUS eventlog_ReportEventW();
/*****************/
/* Function 0x0c */
- NTSTATUS eventlog_ClearEventLogA();
+ [todo] NTSTATUS eventlog_ClearEventLogA();
/******************/
/* Function: 0x0d */
- NTSTATUS eventlog_BackupEventLogA();
+ [todo] NTSTATUS eventlog_BackupEventLogA();
/*****************/
/* Function 0x0e */
- NTSTATUS eventlog_OpenEventLogA();
+ [todo] NTSTATUS eventlog_OpenEventLogA();
/*****************/
/* Function 0x0f */
- NTSTATUS eventlog_RegisterEventSourceA();
+ [todo] NTSTATUS eventlog_RegisterEventSourceA();
/*****************/
/* Function 0x10 */
- NTSTATUS eventlog_OpenBackupEventLogA();
+ [todo] NTSTATUS eventlog_OpenBackupEventLogA();
/*****************/
/* Function 0x11 */
- NTSTATUS eventlog_ReadEventLogA();
+ [todo] NTSTATUS eventlog_ReadEventLogA();
/*****************/
/* Function 0x12 */
- NTSTATUS eventlog_ReportEventA();
+ [todo] NTSTATUS eventlog_ReportEventA();
/*****************/
/* Function 0x13 */
- NTSTATUS eventlog_RegisterClusterSvc();
+ [todo] NTSTATUS eventlog_RegisterClusterSvc();
/*****************/
/* Function 0x14 */
- NTSTATUS eventlog_DeregisterClusterSvc();
+ [todo] NTSTATUS eventlog_DeregisterClusterSvc();
/*****************/
/* Function 0x15 */
- NTSTATUS eventlog_WriteClusterEvents();
+ [todo] NTSTATUS eventlog_WriteClusterEvents();
/*****************/
/* Function 0x16 */
- NTSTATUS eventlog_GetLogIntormation();
+ [todo] NTSTATUS eventlog_GetLogIntormation();
/*****************/
/* Function 0x17 */
diff --git a/source4/librpc/idl/frsapi.idl b/source4/librpc/idl/frsapi.idl
index 2931a83da4..11593f479a 100644
--- a/source4/librpc/idl/frsapi.idl
+++ b/source4/librpc/idl/frsapi.idl
@@ -13,19 +13,19 @@ interface frsapi
{
/****************/
/* Function 0x00 */
- void FRSAPI_VERIFY_PROMOTION();
+ [todo] void FRSAPI_VERIFY_PROMOTION();
/****************/
/* Function 0x01 */
- void FRSAPI_PROMOTION_STATUS();
+ [todo] void FRSAPI_PROMOTION_STATUS();
/****************/
/* Function 0x02 */
- void FRSAPI_START_DEMOTION();
+ [todo] void FRSAPI_START_DEMOTION();
/****************/
/* Function 0x03 */
- void FRSAPI_COMMIT_DEMOTION();
+ [todo] void FRSAPI_COMMIT_DEMOTION();
/****************/
/* Function 0x04 */
@@ -49,7 +49,7 @@ interface frsapi
/****************/
/* Function 0x06 */
- void FRSAPI_VERIFY_PROMOTION_W();
+ [todo] void FRSAPI_VERIFY_PROMOTION_W();
/****************/
/* Function 0x07 */
@@ -106,7 +106,7 @@ interface frsapi
/****************/
/* Function 0x09 */
- void FRSAPI_WRITER_COMMAND();
+ [todo] void FRSAPI_WRITER_COMMAND();
/****************/
/* Function 0x0a */
diff --git a/source4/librpc/idl/frsrpc.idl b/source4/librpc/idl/frsrpc.idl
index 6a0ec394d0..1019a25b28 100644
--- a/source4/librpc/idl/frsrpc.idl
+++ b/source4/librpc/idl/frsrpc.idl
@@ -128,41 +128,41 @@ interface frsrpc
/*****************/
/* Function 0x01 */
- void FRSRPC_VERIFY_PROMOTION_PARENT();
+ [todo] void FRSRPC_VERIFY_PROMOTION_PARENT();
/*****************/
/* Function 0x02 */
- void FRSRPC_START_PROMOTION_PARENT();
+ [todo] void FRSRPC_START_PROMOTION_PARENT();
/*****************/
/* Function 0x03 */
- void FRSRPC_NOP();
+ [todo] void FRSRPC_NOP();
/*****************/
/* Function 0x04 */
- void FRSRPC_BACKUP_COMPLETE();
+ [todo] void FRSRPC_BACKUP_COMPLETE();
/*****************/
/* Function 0x05 */
- void FRSRPC_BACKUP_COMPLETE_5();
+ [todo] void FRSRPC_BACKUP_COMPLETE_5();
/*****************/
/* Function 0x06 */
- void FRSRPC_BACKUP_COMPLETE_6();
+ [todo] void FRSRPC_BACKUP_COMPLETE_6();
/*****************/
/* Function 0x07 */
- void FRSRPC_BACKUP_COMPLETE_7();
+ [todo] void FRSRPC_BACKUP_COMPLETE_7();
/*****************/
/* Function 0x08 */
- void FRSRPC_BACKUP_COMPLETE_8();
+ [todo] void FRSRPC_BACKUP_COMPLETE_8();
/*****************/
/* Function 0x09 */
- void FRSRPC_BACKUP_COMPLETE_9();
+ [todo] void FRSRPC_BACKUP_COMPLETE_9();
/*****************/
/* Function 0x0a */
- void FRSRPC_VERIFY_PROMOTION_PARENT_EX();
+ [todo] void FRSRPC_VERIFY_PROMOTION_PARENT_EX();
}
diff --git a/source4/librpc/idl/lsa.idl b/source4/librpc/idl/lsa.idl
index e36e79f5c4..93cfdee201 100644
--- a/source4/librpc/idl/lsa.idl
+++ b/source4/librpc/idl/lsa.idl
@@ -94,12 +94,12 @@ import "misc.idl", "security.idl";
/******************/
/* Function: 0x04 */
- NTSTATUS lsa_SetSecObj ();
+ [todo] NTSTATUS lsa_SetSecObj ();
/******************/
/* Function: 0x05 */
- NTSTATUS lsa_ChangePassword ();
+ [todo] NTSTATUS lsa_ChangePassword ();
/******************/
@@ -273,7 +273,7 @@ import "misc.idl", "security.idl";
/******************/
/* Function: 0x09 */
- NTSTATUS lsa_ClearAuditLog ();
+ [todo] NTSTATUS lsa_ClearAuditLog ();
/******************/
/* Function: 0x0a */
@@ -477,15 +477,15 @@ import "misc.idl", "security.idl";
);
/* Function: 0x15 */
- NTSTATUS lsa_GetQuotasForAccount();
+ [todo] NTSTATUS lsa_GetQuotasForAccount();
/* Function: 0x16 */
- NTSTATUS lsa_SetQuotasForAccount();
+ [todo] NTSTATUS lsa_SetQuotasForAccount();
/* Function: 0x17 */
- NTSTATUS lsa_GetSystemAccessAccount();
+ [todo] NTSTATUS lsa_GetSystemAccessAccount();
/* Function: 0x18 */
- NTSTATUS lsa_SetSystemAccessAccount();
+ [todo] NTSTATUS lsa_SetSystemAccessAccount();
/* Function: 0x19 */
NTSTATUS lsa_OpenTrustedDomain(
@@ -599,7 +599,7 @@ import "misc.idl", "security.idl";
);
/* Function: 0x1b */
- NTSTATUS lsa_SetInformationTrustedDomain();
+ [todo] NTSTATUS lsa_SetInformationTrustedDomain();
/* Function: 0x1c */
[public] NTSTATUS lsa_OpenSecret(
@@ -659,7 +659,7 @@ import "misc.idl", "security.idl";
);
/* Function: 0x22 */
- NTSTATUS lsa_DeleteObject();
+ [todo] NTSTATUS lsa_DeleteObject();
/*******************/
@@ -713,7 +713,7 @@ import "misc.idl", "security.idl";
);
/* Function: 0x28 */
- NTSTATUS lsa_SetTrustedDomainInfo();
+ [todo] NTSTATUS lsa_SetTrustedDomainInfo();
/* Function: 0x29 */
NTSTATUS lsa_DeleteTrustedDomain(
[in] policy_handle *handle,
@@ -721,9 +721,9 @@ import "misc.idl", "security.idl";
);
/* Function: 0x2a */
- NTSTATUS lsa_StorePrivateData();
+ [todo] NTSTATUS lsa_StorePrivateData();
/* Function: 0x2b */
- NTSTATUS lsa_RetrievePrivateData();
+ [todo] NTSTATUS lsa_RetrievePrivateData();
/**********************/
@@ -800,7 +800,7 @@ import "misc.idl", "security.idl";
/* Function 0x33 */
- NTSTATUS lsa_CreateTrustedDomainEx();
+ [todo] NTSTATUS lsa_CreateTrustedDomainEx();
/* Function 0x34 */
NTSTATUS lsa_CloseTrustedDomainEx(
@@ -858,7 +858,7 @@ import "misc.idl", "security.idl";
);
/* Function 0x38 */
- NTSTATUS lsa_TestCall();
+ [todo] NTSTATUS lsa_TestCall();
/**********************/
/* Function 0x39 */
@@ -914,31 +914,31 @@ import "misc.idl", "security.idl";
);
/* Function 0x3b */
- NTSTATUS lsa_CreateTrustedDomainEx2();
+ [todo] NTSTATUS lsa_CreateTrustedDomainEx2();
/* Function 0x3c */
- NTSTATUS lsa_CREDRWRITE();
+ [todo] NTSTATUS lsa_CREDRWRITE();
/* Function 0x3d */
- NTSTATUS lsa_CREDRREAD();
+ [todo] NTSTATUS lsa_CREDRREAD();
/* Function 0x3e */
- NTSTATUS lsa_CREDRENUMERATE();
+ [todo] NTSTATUS lsa_CREDRENUMERATE();
/* Function 0x3f */
- NTSTATUS lsa_CREDRWRITEDOMAINCREDENTIALS();
+ [todo] NTSTATUS lsa_CREDRWRITEDOMAINCREDENTIALS();
/* Function 0x40 */
- NTSTATUS lsa_CREDRREADDOMAINCREDENTIALS();
+ [todo] NTSTATUS lsa_CREDRREADDOMAINCREDENTIALS();
/* Function 0x41 */
- NTSTATUS lsa_CREDRDELETE();
+ [todo] NTSTATUS lsa_CREDRDELETE();
/* Function 0x42 */
- NTSTATUS lsa_CREDRGETTARGETINFO();
+ [todo] NTSTATUS lsa_CREDRGETTARGETINFO();
/* Function 0x43 */
- NTSTATUS lsa_CREDRPROFILELOADED();
+ [todo] NTSTATUS lsa_CREDRPROFILELOADED();
/**********************/
/* Function 0x44 */
@@ -967,16 +967,16 @@ import "misc.idl", "security.idl";
);
/* Function 0x45 */
- NTSTATUS lsa_CREDRGETSESSIONTYPES();
+ [todo] NTSTATUS lsa_CREDRGETSESSIONTYPES();
/* Function 0x46 */
- NTSTATUS lsa_LSARREGISTERAUDITEVENT();
+ [todo] NTSTATUS lsa_LSARREGISTERAUDITEVENT();
/* Function 0x47 */
- NTSTATUS lsa_LSARGENAUDITEVENT();
+ [todo] NTSTATUS lsa_LSARGENAUDITEVENT();
/* Function 0x48 */
- NTSTATUS lsa_LSARUNREGISTERAUDITEVENT();
+ [todo] NTSTATUS lsa_LSARUNREGISTERAUDITEVENT();
/* Function 0x49 */
typedef struct {
@@ -1024,10 +1024,10 @@ import "misc.idl", "security.idl";
);
/* Function 0x4a */
- NTSTATUS lsa_LSARSETFORESTTRUSTINFORMATION();
+ [todo] NTSTATUS lsa_LSARSETFORESTTRUSTINFORMATION();
/* Function 0x4b */
- NTSTATUS lsa_CREDRRENAME();
+ [todo] NTSTATUS lsa_CREDRRENAME();
/*****************/
/* Function 0x4c */
@@ -1055,15 +1055,15 @@ import "misc.idl", "security.idl";
);
/* Function 0x4e */
- NTSTATUS lsa_LSAROPENPOLICYSCE();
+ [todo] NTSTATUS lsa_LSAROPENPOLICYSCE();
/* Function 0x4f */
- NTSTATUS lsa_LSARADTREGISTERSECURITYEVENTSOURCE();
+ [todo] NTSTATUS lsa_LSARADTREGISTERSECURITYEVENTSOURCE();
/* Function 0x50 */
- NTSTATUS lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE();
+ [todo] NTSTATUS lsa_LSARADTUNREGISTERSECURITYEVENTSOURCE();
/* Function 0x51 */
- NTSTATUS lsa_LSARADTREPORTSECURITYEVENT();
+ [todo] NTSTATUS lsa_LSARADTREPORTSECURITYEVENT();
}
diff --git a/source4/librpc/idl/msgsvc.idl b/source4/librpc/idl/msgsvc.idl
index 09878ac7a4..d196daf06b 100644
--- a/source4/librpc/idl/msgsvc.idl
+++ b/source4/librpc/idl/msgsvc.idl
@@ -7,10 +7,10 @@
helpstring("Messaging Service")
] interface msgsvc
{
- void NetrMessageNameAdd();
- void NetrMessageNameEnum();
- void NetrMessageNameGetInfo();
- void NetrMessageNameDel();
+ [todo] void NetrMessageNameAdd();
+ [todo] void NetrMessageNameEnum();
+ [todo] void NetrMessageNameGetInfo();
+ [todo] void NetrMessageNameDel();
}
[
@@ -18,5 +18,5 @@
version(1.0)
] interface msgsvcsend
{
- void NetrSendMessage();
+ [todo] void NetrSendMessage();
}
diff --git a/source4/librpc/idl/nbt.idl b/source4/librpc/idl/nbt.idl
index aa88360882..783f04eb42 100644
--- a/source4/librpc/idl/nbt.idl
+++ b/source4/librpc/idl/nbt.idl
@@ -8,9 +8,9 @@
encoding if it doesn't work out
*/
-import "misc.idl", "security.idl", "svcctl.idl";
+import "misc.idl", "security.idl", "svcctl.idl", "samr.idl";
[
-helper("libcli/nbt/libnbt.h")
+ helper("libcli/netlogon.h", "libcli/nbt/libnbt.h")
]
interface nbt
{
@@ -338,52 +338,19 @@ interface nbt
} nbt_dgram_packet;
- /*******************************************/
- /* \MAILSLOT\NET\NETLOGON mailslot requests */
- typedef enum {
- NETLOGON_QUERY_FOR_PDC = 0x7,
- NETLOGON_ANNOUNCE_UAS = 0xa,
- NETLOGON_RESPONSE_FROM_PDC = 0xc,
- NETLOGON_QUERY_FOR_PDC2 = 0x12,
- NETLOGON_RESPONSE_FROM_PDC2 = 0x17,
- NETLOGON_RESPONSE_FROM_PDC_USER = 0x19
- } nbt_netlogon_command;
-
- /* query for pdc request */
- typedef struct {
- astring computer_name;
- astring mailslot_name;
- [flag(NDR_ALIGN2)] DATA_BLOB _pad;
- nstring unicode_name;
- uint32 nt_version;
- uint16 lmnt_token;
- uint16 lm20_token;
- } nbt_netlogon_query_for_pdc;
-
- /* query for pdc request - new style */
- typedef struct {
- uint16 request_count;
- nstring computer_name;
- nstring user_name;
- astring mailslot_name;
- uint32 unknown[2];
- uint32 nt_version;
- uint16 lmnt_token;
- uint16 lm20_token;
- } nbt_netlogon_query_for_pdc2;
+ /******************************************
+ * \MAILSLOT\NET\NETLOGON mailslot requests
+ * and
+ * \MAILSLOT\NET\NTLOGON mailslot requests
+ */
- /* response from pdc */
- typedef struct {
- astring pdc_name;
- [flag(NDR_ALIGN2)] DATA_BLOB _pad;
- nstring unicode_pdc_name;
- nstring domain_name;
- uint32 nt_version;
- uint16 lmnt_token;
- uint16 lm20_token;
- } nbt_netlogon_response_from_pdc;
+ typedef [public,gensize] struct {
+ uint32 sa_family;
+ [flag(NDR_BIG_ENDIAN)] ipv4address pdc_ip;
+ [flag(NDR_REMAINING)] DATA_BLOB remaining;
+ } nbt_sockaddr;
- typedef [bitmap32bit] bitmap {
+ typedef [bitmap32bit,public] bitmap {
NBT_SERVER_PDC = 0x00000001,
NBT_SERVER_GC = 0x00000004,
NBT_SERVER_LDAP = 0x00000008,
@@ -395,108 +362,90 @@ interface nbt
NBT_SERVER_GOOD_TIMESERV = 0x00000200
} nbt_server_type;
- /* response from pdc - type2 */
- typedef struct {
- [flag(NDR_ALIGN4)] DATA_BLOB _pad;
- nbt_server_type server_type;
- GUID domain_uuid;
- nbt_string forest;
- nbt_string dns_domain;
- nbt_string pdc_dns_name;
- nbt_string domain;
- nbt_string pdc_name;
- nbt_string user_name;
- nbt_string server_site;
- nbt_string client_site;
- uint8 unknown;
- uint32 unknown2;
- [flag(NDR_BIG_ENDIAN)]
- ipv4address pdc_ip;
- uint32 unknown3[2];
- uint32 nt_version;
+ typedef [bitmap32bit,public] bitmap {
+ NETLOGON_NT_VERSION_1 = 0x00000001,
+ NETLOGON_NT_VERSION_5 = 0x00000002,
+ NETLOGON_NT_VERSION_5EX = 0x00000004,
+ NETLOGON_NT_VERSION_5EX_WITH_IP = 0x00000008,
+ NETLOGON_NT_VERSION_WITH_CLOSEST_SITE = 0x00000010,
+ NETLOGON_NT_VERSION_AVIOD_NT4EMUL = 0x01000000,
+ NETLOGON_NT_VERSION_PDC = 0x10000000,
+ NETLOGON_NT_VERSION_IP = 0x20000000,
+ NETLOGON_NT_VERSION_LOCAL = 0x40000000,
+ NETLOGON_NT_VERSION_GC = 0x80000000
+ } netlogon_nt_version_flags;
+
+
+ typedef [enum16bit,public] enum {
+ LOGON_PRIMARY_QUERY = 7, /* Was also NETLOGON_QUERY_FOR_PDC */
+ NETLOGON_ANNOUNCE_UAS = 10,
+ NETLOGON_RESPONSE_FROM_PDC = 12,
+ LOGON_SAM_LOGON_REQUEST = 18, /* Was also NETLOGON_QUERY_FOR_PDC2, NTLOGON_SAM_LOGON */
+ LOGON_SAM_LOGON_RESPONSE = 19, /* Was also NTLOGON_SAM_LOGON_REPLY */
+ LOGON_SAM_LOGON_PAUSE_RESPONSE = 20,
+ LOGON_SAM_LOGON_USER_UNKNOWN = 21, /* Was also NTLOGON_SAM_LOGON_REPLY15 */
+ LOGON_SAM_LOGON_RESPONSE_EX = 23, /* was NETLOGON_RESPONSE_FROM_PDC2 */
+ LOGON_SAM_LOGON_PAUSE_RESPONSE_EX = 24,
+ LOGON_SAM_LOGON_USER_UNKNOWN_EX = 25 /* was NETLOGON_RESPONSE_FROM_PDC_USER */
+ } netlogon_command;
+
+ typedef bitmap samr_AcctFlags samr_AcctFlags;
+
+ /* query to dc hand marshaled, as it has 'optional'
+ * parts */
+ typedef [nopull,nopush] struct {
+ uint16 request_count;
+ nstring computer_name;
+ nstring user_name;
+ astring mailslot_name;
+ samr_AcctFlags acct_control;
+ [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size;
+ /* The manual alignment is required because this
+ * structure is marked flag(NDR_NOALIGN) via the
+ * nbt_netlogon_packet below.
+ *
+ * However, both MUST only be present if sid_size > 0
+ */
+ [flag(NDR_ALIGN4)] DATA_BLOB _pad;
+ [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid;
+ netlogon_nt_version_flags nt_version;
uint16 lmnt_token;
uint16 lm20_token;
- } nbt_netlogon_response_from_pdc2;
-
- typedef enum netr_SamDatabaseID netr_SamDatabaseID;
-
- /* announce change to UAS or SAM */
- typedef struct {
- netr_SamDatabaseID db_index;
- hyper serial;
- NTTIME timestamp;
- } nbt_db_change;
-
- /* used to announce SAM changes */
- typedef struct {
- uint32 serial_lo;
- time_t timestamp;
- uint32 pulse;
- uint32 random;
- astring pdc_name;
- astring domain;
- [flag(NDR_ALIGN2)] DATA_BLOB _pad;
- nstring unicode_pdc_name;
- nstring unicode_domain;
- uint32 db_count;
- nbt_db_change dbchange[db_count];
- [value(ndr_size_dom_sid(&sid, ndr->flags))] uint32 sid_size;
- [flag(NDR_ALIGN4)] DATA_BLOB _pad2;
- dom_sid sid;
- uint32 nt_version;
- uint16 lmnt_token;
- uint16 lm20_token;
- } nbt_netlogon_announce_uas;
-
- typedef [nodiscriminant] union {
- [case(NETLOGON_QUERY_FOR_PDC)] nbt_netlogon_query_for_pdc pdc;
- [case(NETLOGON_QUERY_FOR_PDC2)] nbt_netlogon_query_for_pdc2 pdc2;
- [case(NETLOGON_ANNOUNCE_UAS)] nbt_netlogon_announce_uas uas;
- [case(NETLOGON_RESPONSE_FROM_PDC)] nbt_netlogon_response_from_pdc response;
- [case(NETLOGON_RESPONSE_FROM_PDC2)] nbt_netlogon_response_from_pdc2 response2;
- [case(NETLOGON_RESPONSE_FROM_PDC_USER)] nbt_netlogon_response_from_pdc2 response2;
- } nbt_netlogon_request;
+ } NETLOGON_SAM_LOGON_REQUEST;
typedef [flag(NDR_NOALIGN),public] struct {
- nbt_netlogon_command command;
- [switch_is(command)] nbt_netlogon_request req;
- } nbt_netlogon_packet;
-
- /*******************************************/
- /* CLDAP netlogon response */
-
- /* note that these structures are very similar to, but not
- quite identical to, the netlogon structures above */
-
- typedef struct {
- uint16 type;
- nstring pdc_name;
+ netlogon_command command;
+ nstring server;
nstring user_name;
- nstring domain_name;
- [value(1)] uint32 nt_version;
+ nstring domain;
+ netlogon_nt_version_flags nt_version;
uint16 lmnt_token;
- uint16 lm20_token;
- } nbt_cldap_netlogon_1;
+ uint16 lm20_token;
+ } NETLOGON_SAM_LOGON_RESPONSE_NT40;
- typedef struct {
- uint16 type;
+ typedef [flag(NDR_NOALIGN),public] struct {
+ netlogon_command command;
nstring pdc_name;
nstring user_name;
nstring domain_name;
GUID domain_uuid;
- GUID unknown_uuid;
+ GUID zero_uuid;
nbt_string forest;
nbt_string dns_domain;
nbt_string pdc_dns_name;
ipv4address pdc_ip;
nbt_server_type server_type;
- [value(3)] uint32 nt_version;
+ netlogon_nt_version_flags nt_version;
uint16 lmnt_token;
uint16 lm20_token;
- } nbt_cldap_netlogon_3;
+ } NETLOGON_SAM_LOGON_RESPONSE;
- typedef struct {
- uint32 type;
+ /* response from pdc hand marshaled (we have an additional
+ * function that uses this structure), as it has 'optional'
+ * parts */
+ typedef [flag(NDR_NOALIGN),public] struct {
+ netlogon_command command;
+ uint16 sbz; /* From the docs */
nbt_server_type server_type;
GUID domain_uuid;
nbt_string forest;
@@ -507,86 +456,91 @@ interface nbt
nbt_string user_name;
nbt_string server_site;
nbt_string client_site;
- [value(5)] uint32 nt_version;
- uint16 lmnt_token;
- uint16 lm20_token;
- } nbt_cldap_netlogon_5;
- typedef struct {
- uint32 type;
- nbt_server_type server_type;
- GUID domain_uuid;
- nbt_string forest;
- nbt_string dns_domain;
- nbt_string pdc_dns_name;
- nbt_string domain;
- nbt_string pdc_name;
- nbt_string user_name;
- nbt_string server_site;
- nbt_string client_site;
- uint8 unknown;
- uint32 unknown2;
- [flag(NDR_BIG_ENDIAN)]
- ipv4address pdc_ip;
- uint32 unknown3[2];
- [value(13)] uint32 nt_version;
+ /* Optional on NETLOGON_NT_VERSION_5EX_WITH_IP */
+ [value(ndr_size_nbt_sockaddr(&sockaddr, ndr->flags))] uint8 sockaddr_size;
+ [subcontext(0),subcontext_size(sockaddr_size)] nbt_sockaddr sockaddr;
+
+ /* Optional on NETLOGON_NT_VERSION_WITH_CLOSEST_SITE */
+ nbt_string next_closest_site;
+
+ netlogon_nt_version_flags nt_version;
uint16 lmnt_token;
uint16 lm20_token;
- } nbt_cldap_netlogon_13;
-
- typedef [flag(NDR_NOALIGN),public,nodiscriminant] union {
- [case(0)] nbt_cldap_netlogon_1 logon1;
- [case(1)] nbt_cldap_netlogon_1 logon1;
- [case(2)] nbt_cldap_netlogon_3 logon3;
- [case(3)] nbt_cldap_netlogon_3 logon3;
- [case(4)] nbt_cldap_netlogon_5 logon5;
- [case(5)] nbt_cldap_netlogon_5 logon5;
- [case(6)] nbt_cldap_netlogon_5 logon5;
- [case(7)] nbt_cldap_netlogon_5 logon5;
- [default] nbt_cldap_netlogon_13 logon13;
- } nbt_cldap_netlogon;
-
- /*******************************************/
- /* \MAILSLOT\NET\NTLOGON mailslot requests */
- typedef enum {
- NTLOGON_SAM_LOGON = 0x12,
- NTLOGON_SAM_LOGON_REPLY = 0x13,
- NTLOGON_SAM_LOGON_REPLY15 = 0x15
- } nbt_ntlogon_command;
+ } NETLOGON_SAM_LOGON_RESPONSE_EX;
+ /* query for pdc request */
typedef struct {
- uint16 request_count;
- nstring computer_name;
- nstring user_name;
+ astring computer_name;
astring mailslot_name;
- uint32 acct_control;
- [value(ndr_size_dom_sid(&sid, ndr->flags))] uint32 sid_size;
- [flag(NDR_ALIGN4)] DATA_BLOB _pad;
- dom_sid sid;
- uint32 nt_version;
+ [flag(NDR_ALIGN2)] DATA_BLOB _pad;
+ nstring unicode_name;
+ netlogon_nt_version_flags nt_version;
uint16 lmnt_token;
uint16 lm20_token;
- } nbt_ntlogon_sam_logon;
+ } nbt_netlogon_query_for_pdc;
- typedef struct {
- nstring server;
- nstring user_name;
- nstring domain;
- uint32 nt_version;
+ /* response from pdc */
+ typedef [flag(NDR_NOALIGN),public] struct {
+ netlogon_command command;
+ astring pdc_name;
+ [flag(NDR_ALIGN2)] DATA_BLOB _pad;
+ nstring unicode_pdc_name;
+ nstring domain_name;
+ netlogon_nt_version_flags nt_version;
uint16 lmnt_token;
uint16 lm20_token;
- } nbt_ntlogon_sam_logon_reply;
+ } nbt_netlogon_response_from_pdc;
+
+ typedef enum netr_SamDatabaseID netr_SamDatabaseID;
+
+ /* used to announce SAM changes - MS-NRPC 2.2.1.5.1 */
+ typedef struct {
+ netr_SamDatabaseID db_index;
+ hyper serial;
+ NTTIME timestamp;
+ } nbt_db_change_info;
+
+ typedef struct {
+ uint32 serial_lo;
+ time_t timestamp;
+ uint32 pulse;
+ uint32 random;
+ astring pdc_name;
+ astring domain;
+ [flag(NDR_ALIGN2)] DATA_BLOB _pad;
+ nstring unicode_pdc_name;
+ nstring unicode_domain;
+ uint32 db_count;
+ nbt_db_change_info dbchange[db_count];
+ [value(ndr_size_dom_sid0(&sid, ndr->flags))] uint32 sid_size;
+ [subcontext(0),subcontext_size(sid_size)] dom_sid0 sid;
+ uint32 message_format_version;
+ uint32 message_token;
+ } NETLOGON_DB_CHANGE;
typedef [nodiscriminant] union {
- [case(NTLOGON_SAM_LOGON)] nbt_ntlogon_sam_logon logon;
- [case(NTLOGON_SAM_LOGON_REPLY)] nbt_ntlogon_sam_logon_reply reply;
- [case(NTLOGON_SAM_LOGON_REPLY15)] nbt_ntlogon_sam_logon_reply reply;
- } nbt_ntlogon_request;
+ [case(LOGON_SAM_LOGON_REQUEST)] NETLOGON_SAM_LOGON_REQUEST logon;
+ [case(LOGON_PRIMARY_QUERY)] nbt_netlogon_query_for_pdc pdc;
+ [case(NETLOGON_ANNOUNCE_UAS)] NETLOGON_DB_CHANGE uas;
+ } nbt_netlogon_request;
+
+#if 0
+ [case(NETLOGON_RESPONSE_FROM_PDC)] nbt_netlogon_response_from_pdc response;
+ [case(NETLOGON_RESPONSE_FROM_PDC_USER)] nbt_netlogon_response_from_pdc2 response2;
+
+ [case(LOGON_SAM_LOGON_PAUSE_RESPONSE)] NETLOGON_SAM_LOGON_RESPONSE reply;
+ [case(LOGON_SAM_LOGON_RESPONSE)] NETLOGON_SAM_LOGON_RESPONSE reply;
+ [case(LOGON_SAM_LOGON_USER_UNKNOWN)] NETLOGON_SAM_LOGON_RESPONSE reply;
+ [case(LOGON_SAM_LOGON_RESPONSE_EX)] NETLOGON_SAM_LOGON_RESPONSE_EX reply_ex;
+ [case(LOGON_SAM_LOGON_PAUSE_RESPONSE_EX)] NETLOGON_SAM_LOGON_RESPONSE_EX reply_ex;
+ [case(LOGON_SAM_LOGON_USER_UNKNOWN_EX)] NETLOGON_SAM_LOGON_RESPONSE_EX reply_ex;
+#endif
typedef [flag(NDR_NOALIGN),public] struct {
- nbt_ntlogon_command command;
- [switch_is(command)] nbt_ntlogon_request req;
- } nbt_ntlogon_packet;
+ netlogon_command command;
+ [switch_is(command)] nbt_netlogon_request req;
+ } nbt_netlogon_packet;
/********************************************************/
/* \MAILSLOT\BROWSE mailslot requests */
diff --git a/source4/librpc/idl/netlogon.idl b/source4/librpc/idl/netlogon.idl
index b29fc50bfa..6da496a486 100644
--- a/source4/librpc/idl/netlogon.idl
+++ b/source4/librpc/idl/netlogon.idl
@@ -983,11 +983,11 @@ interface netlogon
/*****************/
/* Function 0x15 */
- WERROR netr_NETRLOGONDUMMYROUTINE1();
+ [todo] WERROR netr_NETRLOGONDUMMYROUTINE1();
/****************/
/* Function 0x16 */
- WERROR netr_NETRLOGONSETSERVICEBITS();
+ [todo] WERROR netr_NETRLOGONSETSERVICEBITS();
/****************/
/* Function 0x17 */
@@ -999,11 +999,11 @@ interface netlogon
/****************/
/* Function 0x18 */
- WERROR netr_NETRLOGONCOMPUTESERVERDIGEST();
+ [todo] WERROR netr_NETRLOGONCOMPUTESERVERDIGEST();
/****************/
/* Function 0x19 */
- WERROR netr_NETRLOGONCOMPUTECLIENTDIGEST();
+ [todo] WERROR netr_NETRLOGONCOMPUTECLIENTDIGEST();
/****************/
/* Function 0x1a */
@@ -1128,7 +1128,7 @@ interface netlogon
/****************/
/* Function 0x20 */
- WERROR netr_NETRLOGONSENDTOSAM();
+ [todo] WERROR netr_NETRLOGONSENDTOSAM();
/****************/
/* Function 0x21 */
@@ -1164,7 +1164,7 @@ interface netlogon
/****************/
/* Function 0x23 */
- WERROR netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN();
+ [todo] WERROR netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN();
/****************/
/* Function 0x24 */
@@ -1332,5 +1332,5 @@ interface netlogon
/****************/
/* Function 0x2e */
- WERROR netr_NETRSERVERGETTRUSTINFO();
+ [todo] WERROR netr_NETRSERVERGETTRUSTINFO();
}
diff --git a/source4/librpc/idl/ntsvcs.idl b/source4/librpc/idl/ntsvcs.idl
index 05ba68e727..1cdf8eecaa 100644
--- a/source4/librpc/idl/ntsvcs.idl
+++ b/source4/librpc/idl/ntsvcs.idl
@@ -9,69 +9,69 @@
]
interface ntsvcs
{
- void PNP_Disconnect();
- void PNP_Connect();
- void PNP_GetVersion();
- void PNP_GetGlobalState();
- void PNP_InitDetection();
- void PNP_ReportLogOn();
- void PNP_ValidateDeviceInstance();
- void PNP_GetRootDeviceInstance();
- void PNP_GetRelatedDeviceInstance();
- void PNP_EnumerateSubKeys();
- void PNP_GetDeviceList();
- void PNP_GetDeviceListSize();
- void PNP_GetDepth();
- void PNP_GetDeviceRegProp();
- void PNP_SetDeviceRegProp();
- void PNP_GetClassInstance();
- void PNP_CreateKey();
- void PNP_DeleteRegistryKey();
- void PNP_GetClassCount();
- void PNP_GetClassName();
- void PNP_DeleteClassKey();
- void PNP_GetInterfaceDeviceAlias();
- void PNP_GetInterfaceDeviceList();
- void PNP_GetInterfaceDeviceListSize();
- void PNP_RegisterDeviceClassAssociation();
- void PNP_UnregisterDeviceClassAssociation();
- void PNP_GetClassRegProp();
- void PNP_SetClassRegProp();
- void PNP_CreateDevInst();
- void PNP_DeviceInstanceAction();
- void PNP_GetDeviceStatus();
- void PNP_SetDeviceProblem();
- void PNP_DisableDevInst();
- void PNP_UninstallDevInst();
- void PNP_AddID();
- void PNP_RegisterDriver();
- void PNP_QueryRemove();
- void PNP_RequestDeviceEject();
- void PNP_IsDockStationPresent();
- void PNP_RequestEjectPC();
- void PNP_HwProfFlags();
- void PNP_GetHwProfInfo();
- void PNP_AddEmptyLogConf();
- void PNP_FreeLogConf();
- void PNP_GetFirstLogConf();
- void PNP_GetNextLogConf();
- void PNP_GetLogConfPriority();
- void PNP_AddResDes();
- void PNP_FreeResDes();
- void PNP_GetNextResDes();
- void PNP_GetResDesData();
- void PNP_GetResDesDataSize();
- void PNP_ModifyResDes();
- void PNP_DetectResourceLimit();
- void PNP_QueryResConfList();
- void PNP_SetHwProf();
- void PNP_QueryArbitratorFreeData();
- void PNP_QueryArbitratorFreeSize();
- void PNP_RunDetection();
- void PNP_RegisterNotification();
- void PNP_UnregisterNotification();
- void PNP_GetCustomDevProp();
- void PNP_GetVersionInternal();
- void PNP_GetBlockedDriverInfo();
- void PNP_GetServerSideDeviceInstallFlags();
+ [todo] void PNP_Disconnect();
+ [todo] void PNP_Connect();
+ [todo] void PNP_GetVersion();
+ [todo] void PNP_GetGlobalState();
+ [todo] void PNP_InitDetection();
+ [todo] void PNP_ReportLogOn();
+ [todo] void PNP_ValidateDeviceInstance();
+ [todo] void PNP_GetRootDeviceInstance();
+ [todo] void PNP_GetRelatedDeviceInstance();
+ [todo] void PNP_EnumerateSubKeys();
+ [todo] void PNP_GetDeviceList();
+ [todo] void PNP_GetDeviceListSize();
+ [todo] void PNP_GetDepth();
+ [todo] void PNP_GetDeviceRegProp();
+ [todo] void PNP_SetDeviceRegProp();
+ [todo] void PNP_GetClassInstance();
+ [todo] void PNP_CreateKey();
+ [todo] void PNP_DeleteRegistryKey();
+ [todo] void PNP_GetClassCount();
+ [todo] void PNP_GetClassName();
+ [todo] void PNP_DeleteClassKey();
+ [todo] void PNP_GetInterfaceDeviceAlias();
+ [todo] void PNP_GetInterfaceDeviceList();
+ [todo] void PNP_GetInterfaceDeviceListSize();
+ [todo] void PNP_RegisterDeviceClassAssociation();
+ [todo] void PNP_UnregisterDeviceClassAssociation();
+ [todo] void PNP_GetClassRegProp();
+ [todo] void PNP_SetClassRegProp();
+ [todo] void PNP_CreateDevInst();
+ [todo] void PNP_DeviceInstanceAction();
+ [todo] void PNP_GetDeviceStatus();
+ [todo] void PNP_SetDeviceProblem();
+ [todo] void PNP_DisableDevInst();
+ [todo] void PNP_UninstallDevInst();
+ [todo] void PNP_AddID();
+ [todo] void PNP_RegisterDriver();
+ [todo] void PNP_QueryRemove();
+ [todo] void PNP_RequestDeviceEject();
+ [todo] void PNP_IsDockStationPresent();
+ [todo] void PNP_RequestEjectPC();
+ [todo] void PNP_HwProfFlags();
+ [todo] void PNP_GetHwProfInfo();
+ [todo] void PNP_AddEmptyLogConf();
+ [todo] void PNP_FreeLogConf();
+ [todo] void PNP_GetFirstLogConf();
+ [todo] void PNP_GetNextLogConf();
+ [todo] void PNP_GetLogConfPriority();
+ [todo] void PNP_AddResDes();
+ [todo] void PNP_FreeResDes();
+ [todo] void PNP_GetNextResDes();
+ [todo] void PNP_GetResDesData();
+ [todo] void PNP_GetResDesDataSize();
+ [todo] void PNP_ModifyResDes();
+ [todo] void PNP_DetectResourceLimit();
+ [todo] void PNP_QueryResConfList();
+ [todo] void PNP_SetHwProf();
+ [todo] void PNP_QueryArbitratorFreeData();
+ [todo] void PNP_QueryArbitratorFreeSize();
+ [todo] void PNP_RunDetection();
+ [todo] void PNP_RegisterNotification();
+ [todo] void PNP_UnregisterNotification();
+ [todo] void PNP_GetCustomDevProp();
+ [todo] void PNP_GetVersionInternal();
+ [todo] void PNP_GetBlockedDriverInfo();
+ [todo] void PNP_GetServerSideDeviceInstallFlags();
}
diff --git a/source4/librpc/idl/policyagent.idl b/source4/librpc/idl/policyagent.idl
index 295b70a2a1..ab137faf27 100644
--- a/source4/librpc/idl/policyagent.idl
+++ b/source4/librpc/idl/policyagent.idl
@@ -9,5 +9,5 @@
{
/*****************/
/* Function 0x00 */
- WERROR policyagent_Dummy();
+ [todo] WERROR policyagent_Dummy();
}
diff --git a/source4/librpc/idl/security.idl b/source4/librpc/idl/security.idl
index 753fad85cf..314846c53f 100644
--- a/source4/librpc/idl/security.idl
+++ b/source4/librpc/idl/security.idl
@@ -22,6 +22,9 @@ cpp_quote("#define dom_sid2 dom_sid")
/* same struct as dom_sid but inside a 28 bytes fixed buffer in NDR */
cpp_quote("#define dom_sid28 dom_sid")
+/* same struct as dom_sid but in a variable byte buffer, which is maybe empty in NDR */
+cpp_quote("#define dom_sid0 dom_sid")
+
[
pointer_default(unique)
]
diff --git a/source4/librpc/idl/spoolss.idl b/source4/librpc/idl/spoolss.idl
index 64cfd46b0e..6b4b0b8a16 100644
--- a/source4/librpc/idl/spoolss.idl
+++ b/source4/librpc/idl/spoolss.idl
@@ -386,14 +386,14 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x05 */
- WERROR spoolss_AddPrinter(
+ [todo] WERROR spoolss_AddPrinter(
/* This function is not implemented in Samba 3 as no
clients have been observed using it. */
);
/******************/
/* Function: 0x06 */
- WERROR spoolss_DeletePrinter(
+ [todo] WERROR spoolss_DeletePrinter(
);
/******************/
@@ -442,7 +442,7 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x09 */
- WERROR spoolss_AddPrinterDriver(
+ [todo] WERROR spoolss_AddPrinterDriver(
);
typedef struct {
@@ -564,7 +564,7 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x0b */
- WERROR spoolss_GetPrinterDriver(
+ [todo] WERROR spoolss_GetPrinterDriver(
);
/******************/
@@ -602,7 +602,7 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x0e */
- WERROR spoolss_AddPrintProcessor(
+ [todo] WERROR spoolss_AddPrintProcessor(
);
/******************/
@@ -644,7 +644,7 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x10 */
- WERROR spoolss_GetPrintProcessorDirectory(
+ [todo] WERROR spoolss_GetPrintProcessorDirectory(
);
/******************/
@@ -713,12 +713,12 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x18 */
- WERROR spoolss_AddJob(
+ [todo] WERROR spoolss_AddJob(
);
/******************/
/* Function: 0x19 */
- WERROR spoolss_ScheduleJob(
+ [todo] WERROR spoolss_ScheduleJob(
);
/******************/
@@ -806,7 +806,7 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x1c */
- WERROR spoolss_WaitForPrinterChange(
+ [todo] WERROR spoolss_WaitForPrinterChange(
);
/******************/
@@ -1022,79 +1022,79 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x26 */
- WERROR spoolss_ConfigurePort(
+ [todo] WERROR spoolss_ConfigurePort(
);
/******************/
/* Function: 0x27 */
- WERROR spoolss_DeletePort(
+ [todo] WERROR spoolss_DeletePort(
);
/******************/
/* Function: 0x28 */
- WERROR spoolss_CreatePrinterIC(
+ [todo] WERROR spoolss_CreatePrinterIC(
);
/******************/
/* Function: 0x29 */
- WERROR spoolss_PlayGDIScriptOnPrinterIC(
+ [todo] WERROR spoolss_PlayGDIScriptOnPrinterIC(
);
/******************/
/* Function: 0x2a */
- WERROR spoolss_DeletePrinterIC(
+ [todo] WERROR spoolss_DeletePrinterIC(
);
/******************/
/* Function: 0x2b */
- WERROR spoolss_AddPrinterConnection(
+ [todo] WERROR spoolss_AddPrinterConnection(
);
/******************/
/* Function: 0x2c */
- WERROR spoolss_DeletePrinterConnection(
+ [todo] WERROR spoolss_DeletePrinterConnection(
);
/******************/
/* Function: 0x2d */
- WERROR spoolss_PrinterMessageBox(
+ [todo] WERROR spoolss_PrinterMessageBox(
/* Marked as obsolete in MSDN. "Not necessary and has
no effect". */
);
/******************/
/* Function: 0x2e */
- WERROR spoolss_AddMonitor(
+ [todo] WERROR spoolss_AddMonitor(
);
/******************/
/* Function: 0x2f */
- WERROR spoolss_DeleteMonitor(
+ [todo] WERROR spoolss_DeleteMonitor(
);
/******************/
/* Function: 0x30 */
- WERROR spoolss_DeletePrintProcessor(
+ [todo] WERROR spoolss_DeletePrintProcessor(
);
/******************/
/* Function: 0x31 */
- WERROR spoolss_AddPrintProvidor(
+ [todo] WERROR spoolss_AddPrintProvidor(
);
/******************/
/* Function: 0x32 */
- WERROR spoolss_DeletePrintProvidor(
+ [todo] WERROR spoolss_DeletePrintProvidor(
);
/******************/
/* Function: 0x33 */
- WERROR spoolss_EnumPrintProcDataTypes(
+ [todo] WERROR spoolss_EnumPrintProcDataTypes(
);
/******************/
/* Function: 0x34 */
- WERROR spoolss_ResetPrinter(
+ [todo] WERROR spoolss_ResetPrinter(
);
/******************/
@@ -1115,12 +1115,12 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x36 */
- WERROR spoolss_FindFirstPrinterChangeNotification(
+ [todo] WERROR spoolss_FindFirstPrinterChangeNotification(
);
/******************/
/* Function: 0x37 */
- WERROR spoolss_FindNextPrinterChangeNotification(
+ [todo] WERROR spoolss_FindNextPrinterChangeNotification(
);
/******************/
@@ -1131,7 +1131,7 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x39 */
- WERROR spoolss_RouterFindFirstPrinterChangeNotificationOld(
+ [todo] WERROR spoolss_RouterFindFirstPrinterChangeNotificationOld(
);
/******************/
@@ -1147,7 +1147,7 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x3b */
- WERROR spoolss_RouterReplyPrinter(
+ [todo] WERROR spoolss_RouterReplyPrinter(
);
/******************/
@@ -1158,22 +1158,22 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x3d */
- WERROR spoolss_AddPortEx(
+ [todo] WERROR spoolss_AddPortEx(
);
/******************/
/* Function: 0x3e */
- WERROR spoolss_RouterFindFirstPrinterChangeNotification(
+ [todo] WERROR spoolss_RouterFindFirstPrinterChangeNotification(
);
/******************/
/* Function: 0x3f */
- WERROR spoolss_SpoolerInit(
+ [todo] WERROR spoolss_SpoolerInit(
);
/******************/
/* Function: 0x40 */
- WERROR spoolss_ResetPrinterEx(
+ [todo] WERROR spoolss_ResetPrinterEx(
);
typedef [enum16bit] enum {
@@ -1239,7 +1239,7 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x42 */
- WERROR spoolss_RouterRefreshPrinterChangeNotification(
+ [todo] WERROR spoolss_RouterRefreshPrinterChangeNotification(
);
typedef struct {
@@ -1295,7 +1295,7 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x44 */
- WERROR spoolss_44(
+ [todo] WERROR spoolss_44(
);
typedef struct {
@@ -1399,7 +1399,7 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x47 */
- WERROR spoolss_47(
+ [todo] WERROR spoolss_47(
);
/******************/
@@ -1425,17 +1425,17 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x4a */
- WERROR spoolss_4a(
+ [todo] WERROR spoolss_4a(
);
/******************/
/* Function: 0x4b */
- WERROR spoolss_4b(
+ [todo] WERROR spoolss_4b(
);
/******************/
/* Function: 0x4c */
- WERROR spoolss_4c(
+ [todo] WERROR spoolss_4c(
);
/******************/
@@ -1492,32 +1492,32 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x52 */
- WERROR spoolss_DeletePrinterKey(
+ [todo] WERROR spoolss_DeletePrinterKey(
);
/******************/
/* Function: 0x53 */
- WERROR spoolss_53(
+ [todo] WERROR spoolss_53(
);
/******************/
/* Function: 0x54 */
- WERROR spoolss_DeletePrinterDriverEx(
+ [todo] WERROR spoolss_DeletePrinterDriverEx(
);
/******************/
/* Function: 0x55 */
- WERROR spoolss_55(
+ [todo] WERROR spoolss_55(
);
/******************/
/* Function: 0x56 */
- WERROR spoolss_56(
+ [todo] WERROR spoolss_56(
);
/******************/
/* Function: 0x57 */
- WERROR spoolss_57(
+ [todo] WERROR spoolss_57(
);
/******************/
@@ -1536,36 +1536,36 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x59 */
- [public] WERROR spoolss_AddPrinterDriverEx(
+ [public,todo] WERROR spoolss_AddPrinterDriverEx(
);
/******************/
/* Function: 0x5a */
- WERROR spoolss_5a(
+ [todo] WERROR spoolss_5a(
);
/******************/
/* Function: 0x5b */
- WERROR spoolss_5b(
+ [todo] WERROR spoolss_5b(
);
/******************/
/* Function: 0x5c */
- WERROR spoolss_5c(
+ [todo] WERROR spoolss_5c(
);
/******************/
/* Function: 0x5d */
- WERROR spoolss_5d(
+ [todo] WERROR spoolss_5d(
);
/******************/
/* Function: 0x5e */
- WERROR spoolss_5e(
+ [todo] WERROR spoolss_5e(
);
/******************/
/* Function: 0x5f */
- WERROR spoolss_5f(
+ [todo] WERROR spoolss_5f(
);
}
diff --git a/source4/librpc/idl/srvsvc.idl b/source4/librpc/idl/srvsvc.idl
index 8ef49413bc..703f3281cf 100644
--- a/source4/librpc/idl/srvsvc.idl
+++ b/source4/librpc/idl/srvsvc.idl
@@ -1370,7 +1370,7 @@ import "security.idl", "svcctl.idl";
/******************/
/* Function: 0x22 */
- WERROR srvsvc_NETRPRNAMECANONICALIZE(
+ [todo] WERROR srvsvc_NETRPRNAMECANONICALIZE(
);
/******************/
@@ -1464,56 +1464,56 @@ import "security.idl", "svcctl.idl";
/******************/
/* Function: 0x2b */
- WERROR srvsvc_NETRDFSGETVERSION(
+ [todo] WERROR srvsvc_NETRDFSGETVERSION(
);
/******************/
/* Function: 0x2c */
- WERROR srvsvc_NETRDFSCREATELOCALPARTITION(
+ [todo] WERROR srvsvc_NETRDFSCREATELOCALPARTITION(
);
/******************/
/* Function: 0x2d */
- WERROR srvsvc_NETRDFSDELETELOCALPARTITION(
+ [todo] WERROR srvsvc_NETRDFSDELETELOCALPARTITION(
);
/******************/
/* Function: 0x2e */
- WERROR srvsvc_NETRDFSSETLOCALVOLUMESTATE(
+ [todo] WERROR srvsvc_NETRDFSSETLOCALVOLUMESTATE(
);
/******************/
/* Function: 0x2f */
- WERROR srvsvc_NETRDFSSETSERVERINFO(
+ [todo] WERROR srvsvc_NETRDFSSETSERVERINFO(
);
/******************/
/* Function: 0x30 */
- WERROR srvsvc_NETRDFSCREATEEXITPOINT(
+ [todo] WERROR srvsvc_NETRDFSCREATEEXITPOINT(
);
/******************/
/* Function: 0x31 */
- WERROR srvsvc_NETRDFSDELETEEXITPOINT(
+ [todo] WERROR srvsvc_NETRDFSDELETEEXITPOINT(
);
/******************/
/* Function: 0x32 */
- WERROR srvsvc_NETRDFSMODIFYPREFIX(
+ [todo] WERROR srvsvc_NETRDFSMODIFYPREFIX(
);
/******************/
/* Function: 0x33 */
- WERROR srvsvc_NETRDFSFIXLOCALVOLUME(
+ [todo] WERROR srvsvc_NETRDFSFIXLOCALVOLUME(
);
/******************/
/* Function: 0x34 */
- WERROR srvsvc_NETRDFSMANAGERREPORTSITEINFO(
+ [todo] WERROR srvsvc_NETRDFSMANAGERREPORTSITEINFO(
);
/******************/
/* Function: 0x35 */
- WERROR srvsvc_NETRSERVERTRANSPORTDELEX(
+ [todo] WERROR srvsvc_NETRSERVERTRANSPORTDELEX(
);
}
diff --git a/source4/librpc/idl/svcctl.idl b/source4/librpc/idl/svcctl.idl
index 8f368ef878..615f4e3dab 100644
--- a/source4/librpc/idl/svcctl.idl
+++ b/source4/librpc/idl/svcctl.idl
@@ -115,12 +115,12 @@ import "misc.idl";
/*****************/
/* Function 0x04 */
- WERROR svcctl_QueryServiceObjectSecurity(
+ [todo] WERROR svcctl_QueryServiceObjectSecurity(
);
/*****************/
/* Function 0x05 */
- WERROR svcctl_SetServiceObjectSecurity(
+ [todo] WERROR svcctl_SetServiceObjectSecurity(
);
/*****************/
@@ -132,7 +132,7 @@ import "misc.idl";
/*****************/
/* Function 0x07 */
- WERROR svcctl_SetServiceStatus(
+ [todo] WERROR svcctl_SetServiceStatus(
);
/*****************/
@@ -143,7 +143,7 @@ import "misc.idl";
/*****************/
/* Function 0x09 */
- WERROR svcctl_NotifyBootConfigStatus(
+ [todo] WERROR svcctl_NotifyBootConfigStatus(
);
/*****************/
@@ -408,12 +408,12 @@ import "misc.idl";
/*****************/
/* Function 0x22 */
- WERROR svcctl_GetCurrentGroupeStateW(
+ [todo] WERROR svcctl_GetCurrentGroupeStateW(
);
/*****************/
/* Function 0x23 */
- WERROR svcctl_EnumServiceGroupW(
+ [todo] WERROR svcctl_EnumServiceGroupW(
);
/*****************/
@@ -494,6 +494,6 @@ import "misc.idl";
/*****************/
/* Function 0x2b */
- WERROR svcctl_SCSendTSMessage(
+ [todo] WERROR svcctl_SCSendTSMessage(
);
}
diff --git a/source4/librpc/idl/w32time.idl b/source4/librpc/idl/w32time.idl
index c3c6e014de..4839899629 100644
--- a/source4/librpc/idl/w32time.idl
+++ b/source4/librpc/idl/w32time.idl
@@ -14,8 +14,8 @@ interface w32time
/*****************/
/* Function 0x00 */
- WERROR w32time_SyncTime();
+ [todo] WERROR w32time_SyncTime();
- WERROR w32time_GetNetLogonServiceBits();
- WERROR w32time_QueryProviderStatus();
+ [todo] WERROR w32time_GetNetLogonServiceBits();
+ [todo] WERROR w32time_QueryProviderStatus();
}
diff --git a/source4/librpc/idl/winreg.idl b/source4/librpc/idl/winreg.idl
index 5e5d5542b6..1e01a91197 100644
--- a/source4/librpc/idl/winreg.idl
+++ b/source4/librpc/idl/winreg.idl
@@ -249,7 +249,7 @@ import "lsa.idl", "security.idl";
/******************/
/* Function: 0x12 */
- WERROR winreg_ReplaceKey(
+ [todo] WERROR winreg_ReplaceKey(
);
/******************/
@@ -295,7 +295,7 @@ import "lsa.idl", "security.idl";
/******************/
/* Function: 0x17 */
- WERROR winreg_UnLoadKey(
+ [todo] WERROR winreg_UnLoadKey(
);
/******************/
@@ -375,7 +375,7 @@ import "lsa.idl", "security.idl";
/******************/
/* Function: 0x1f */
- WERROR winreg_SaveKeyEx(
+ [todo] WERROR winreg_SaveKeyEx(
);
/******************/
@@ -396,6 +396,6 @@ import "lsa.idl", "security.idl";
/******************/
/* Function: 0x22 */
- WERROR winreg_QueryMultipleValues2(
+ [todo] WERROR winreg_QueryMultipleValues2(
);
}
diff --git a/source4/librpc/idl/xattr.idl b/source4/librpc/idl/xattr.idl
index 7e73baee7d..2010d51ce1 100644
--- a/source4/librpc/idl/xattr.idl
+++ b/source4/librpc/idl/xattr.idl
@@ -31,8 +31,14 @@ interface xattr
NTTIME change_time;
} xattr_DosInfo1;
- const int XATTR_ATTRIB_FLAG_STICKY_WRITE_TIME = 0x1;
+/*
+ We use xattrDosInfo1 again when we store values.
+ Because the sticky write time is now stored in the opendb
+ and xattr_DosInfo2Old is only present to parse existing
+ values from disk.
+ const int XATTR_ATTRIB_FLAG_STICKY_WRITE_TIME = 0x1;
+*/
typedef struct {
uint32 flags;
uint32 attrib;
@@ -43,11 +49,11 @@ interface xattr
NTTIME change_time;
NTTIME write_time; /* only used when sticky write time is set */
utf8string name;
- } xattr_DosInfo2;
+ } xattr_DosInfo2Old;
typedef [switch_type(uint16)] union {
[case(1)] xattr_DosInfo1 info1;
- [case(2)] xattr_DosInfo2 info2;
+ [case(2)] xattr_DosInfo2Old oldinfo2;
} xattr_DosInfo;
typedef [public] struct {
diff --git a/source4/librpc/ndr/libndr.h b/source4/librpc/ndr/libndr.h
index 2439c386db..b719be2bab 100644
--- a/source4/librpc/ndr/libndr.h
+++ b/source4/librpc/ndr/libndr.h
@@ -336,6 +336,10 @@ enum ndr_err_code ndr_push_dom_sid28(struct ndr_push *ndr, int ndr_flags, const
enum ndr_err_code ndr_pull_dom_sid28(struct ndr_pull *ndr, int ndr_flags, struct dom_sid *sid);
void ndr_print_dom_sid28(struct ndr_print *ndr, const char *name, const struct dom_sid *sid);
size_t ndr_size_dom_sid28(const struct dom_sid *sid, int flags);
+enum ndr_err_code ndr_push_dom_sid0(struct ndr_push *ndr, int ndr_flags, const struct dom_sid *sid);
+enum ndr_err_code ndr_pull_dom_sid0(struct ndr_pull *ndr, int ndr_flags, struct dom_sid *sid);
+void ndr_print_dom_sid0(struct ndr_print *ndr, const char *name, const struct dom_sid *sid);
+size_t ndr_size_dom_sid0(const struct dom_sid *sid, int flags);
void ndr_print_ipv4_addr(struct ndr_print *ndr, const char *name, const struct in_addr *_ip);
void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid);
enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, const void *p, ndr_push_flags_fn_t fn);
diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c
index 93a177f94e..1d2b47c850 100644
--- a/source4/librpc/ndr/ndr_basic.c
+++ b/source4/librpc/ndr/ndr_basic.c
@@ -196,7 +196,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, u
*/
_PUBLIC_ enum ndr_err_code ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v)
{
- intptr_t h;
+ uintptr_t h;
NDR_PULL_ALIGN(ndr, sizeof(h));
NDR_PULL_NEED_BYTES(ndr, sizeof(h));
memcpy(&h, ndr->data+ndr->offset, sizeof(h));
@@ -393,7 +393,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, u
*/
_PUBLIC_ enum ndr_err_code ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v)
{
- intptr_t h = (intptr_t)v;
+ uintptr_t h = (intptr_t)v;
NDR_PUSH_ALIGN(ndr, sizeof(h));
NDR_PUSH_NEED_BYTES(ndr, sizeof(h));
memcpy(ndr->data+ndr->offset, &h, sizeof(h));
diff --git a/source4/librpc/ndr/ndr_sec_helper.c b/source4/librpc/ndr/ndr_sec_helper.c
index 5a0178bd25..1256d7dd2d 100644
--- a/source4/librpc/ndr/ndr_sec_helper.c
+++ b/source4/librpc/ndr/ndr_sec_helper.c
@@ -48,6 +48,11 @@ size_t ndr_size_dom_sid28(const struct dom_sid *sid, int flags)
return 8 + 4*sid->num_auths;
}
+size_t ndr_size_dom_sid0(const struct dom_sid *sid, int flags)
+{
+ return ndr_size_dom_sid28(sid, flags);
+}
+
/*
return the wire size of a security_ace
*/
@@ -128,6 +133,11 @@ void ndr_print_dom_sid28(struct ndr_print *ndr, const char *name, const struct d
ndr_print_dom_sid(ndr, name, sid);
}
+void ndr_print_dom_sid0(struct ndr_print *ndr, const char *name, const struct dom_sid *sid)
+{
+ ndr_print_dom_sid(ndr, name, sid);
+}
+
/*
parse a dom_sid2 - this is a dom_sid but with an extra copy of the num_auths field
@@ -225,3 +235,44 @@ enum ndr_err_code ndr_push_dom_sid28(struct ndr_push *ndr, int ndr_flags, const
return NDR_ERR_SUCCESS;
}
+/*
+ parse a dom_sid0 - this is a dom_sid in a variable byte buffer, which is maybe empty
+*/
+enum ndr_err_code ndr_pull_dom_sid0(struct ndr_pull *ndr, int ndr_flags, struct dom_sid *sid)
+{
+ if (!(ndr_flags & NDR_SCALARS)) {
+ return NDR_ERR_SUCCESS;
+ }
+
+ if (ndr->data_size == ndr->offset) {
+ ZERO_STRUCTP(sid);
+ return NDR_ERR_SUCCESS;
+ }
+
+ return ndr_pull_dom_sid(ndr, ndr_flags, sid);
+}
+
+/*
+ push a dom_sid0 - this is a dom_sid in a variable byte buffer, which is maybe empty
+*/
+enum ndr_err_code ndr_push_dom_sid0(struct ndr_push *ndr, int ndr_flags, const struct dom_sid *sid)
+{
+ struct dom_sid zero_sid;
+
+ if (!(ndr_flags & NDR_SCALARS)) {
+ return NDR_ERR_SUCCESS;
+ }
+
+ if (!sid) {
+ return NDR_ERR_SUCCESS;
+ }
+
+ ZERO_STRUCT(zero_sid);
+
+ if (memcmp(&zero_sid, sid, sizeof(zero_sid)) == 0) {
+ return NDR_ERR_SUCCESS;
+ }
+
+ return ndr_push_dom_sid(ndr, ndr_flags, sid);
+}
+
diff --git a/source4/librpc/rpc/binding.c b/source4/librpc/rpc/binding.c
new file mode 100644
index 0000000000..ae88dce1be
--- /dev/null
+++ b/source4/librpc/rpc/binding.c
@@ -0,0 +1,724 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ dcerpc utility functions
+
+ Copyright (C) Andrew Tridgell 2003
+ Copyright (C) Jelmer Vernooij 2004
+ Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005
+ Copyright (C) Rafal Szczesniak 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 "lib/events/events.h"
+#include "librpc/gen_ndr/ndr_epmapper_c.h"
+#include "librpc/gen_ndr/ndr_dcerpc.h"
+#include "librpc/gen_ndr/ndr_misc.h"
+
+#define MAX_PROTSEQ 10
+
+static const struct {
+ const char *name;
+ enum dcerpc_transport_t transport;
+ int num_protocols;
+ enum epm_protocol protseq[MAX_PROTSEQ];
+} transports[] = {
+ { "ncacn_np", NCACN_NP, 3,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_SMB, EPM_PROTOCOL_NETBIOS }},
+ { "ncacn_ip_tcp", NCACN_IP_TCP, 3,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_TCP, EPM_PROTOCOL_IP } },
+ { "ncacn_http", NCACN_HTTP, 3,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_HTTP, EPM_PROTOCOL_IP } },
+ { "ncadg_ip_udp", NCACN_IP_UDP, 3,
+ { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_UDP, EPM_PROTOCOL_IP } },
+ { "ncalrpc", NCALRPC, 2,
+ { EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_PIPE } },
+ { "ncacn_unix_stream", NCACN_UNIX_STREAM, 2,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_UNIX_DS } },
+ { "ncadg_unix_dgram", NCADG_UNIX_DGRAM, 2,
+ { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_UNIX_DS } },
+ { "ncacn_at_dsp", NCACN_AT_DSP, 3,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_APPLETALK, EPM_PROTOCOL_DSP } },
+ { "ncadg_at_ddp", NCADG_AT_DDP, 3,
+ { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_APPLETALK, EPM_PROTOCOL_DDP } },
+ { "ncacn_vns_ssp", NCACN_VNS_SPP, 3,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_STREETTALK, EPM_PROTOCOL_VINES_SPP } },
+ { "ncacn_vns_ipc", NCACN_VNS_IPC, 3,
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_STREETTALK, EPM_PROTOCOL_VINES_IPC }, },
+ { "ncadg_ipx", NCADG_IPX, 2,
+ { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_IPX },
+ },
+ { "ncacn_spx", NCACN_SPX, 3,
+ /* I guess some MS programmer confused the identifier for
+ * EPM_PROTOCOL_UUID (0x0D or 13) with the one for
+ * EPM_PROTOCOL_SPX (0x13) here. -- jelmer*/
+ { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_UUID },
+ },
+};
+
+static const struct {
+ const char *name;
+ uint32_t flag;
+} ncacn_options[] = {
+ {"sign", DCERPC_SIGN},
+ {"seal", DCERPC_SEAL},
+ {"connect", DCERPC_CONNECT},
+ {"spnego", DCERPC_AUTH_SPNEGO},
+ {"ntlm", DCERPC_AUTH_NTLM},
+ {"krb5", DCERPC_AUTH_KRB5},
+ {"validate", DCERPC_DEBUG_VALIDATE_BOTH},
+ {"print", DCERPC_DEBUG_PRINT_BOTH},
+ {"padcheck", DCERPC_DEBUG_PAD_CHECK},
+ {"bigendian", DCERPC_PUSH_BIGENDIAN},
+ {"smb2", DCERPC_SMB2}
+};
+
+const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor)
+{
+ struct ndr_syntax_id syntax;
+ NTSTATUS status;
+
+ switch(epm_floor->lhs.protocol) {
+ case EPM_PROTOCOL_UUID:
+ status = dcerpc_floor_get_lhs_data(epm_floor, &syntax);
+ if (NT_STATUS_IS_OK(status)) {
+ /* lhs is used: UUID */
+ char *uuidstr;
+
+ if (GUID_equal(&syntax.uuid, &ndr_transfer_syntax.uuid)) {
+ return "NDR";
+ }
+
+ if (GUID_equal(&syntax.uuid, &ndr64_transfer_syntax.uuid)) {
+ return "NDR64";
+ }
+
+ uuidstr = GUID_string(mem_ctx, &syntax.uuid);
+
+ return talloc_asprintf(mem_ctx, " uuid %s/0x%02x", uuidstr, syntax.if_version);
+ } else { /* IPX */
+ return talloc_asprintf(mem_ctx, "IPX:%s",
+ data_blob_hex_string(mem_ctx, &epm_floor->rhs.uuid.unknown));
+ }
+
+ case EPM_PROTOCOL_NCACN:
+ return "RPC-C";
+
+ case EPM_PROTOCOL_NCADG:
+ return "RPC";
+
+ case EPM_PROTOCOL_NCALRPC:
+ return "NCALRPC";
+
+ case EPM_PROTOCOL_DNET_NSP:
+ return "DNET/NSP";
+
+ case EPM_PROTOCOL_IP:
+ return talloc_asprintf(mem_ctx, "IP:%s", epm_floor->rhs.ip.ipaddr);
+
+ case EPM_PROTOCOL_PIPE:
+ return talloc_asprintf(mem_ctx, "PIPE:%s", epm_floor->rhs.pipe.path);
+
+ case EPM_PROTOCOL_SMB:
+ return talloc_asprintf(mem_ctx, "SMB:%s", epm_floor->rhs.smb.unc);
+
+ case EPM_PROTOCOL_UNIX_DS:
+ return talloc_asprintf(mem_ctx, "Unix:%s", epm_floor->rhs.unix_ds.path);
+
+ case EPM_PROTOCOL_NETBIOS:
+ return talloc_asprintf(mem_ctx, "NetBIOS:%s", epm_floor->rhs.netbios.name);
+
+ case EPM_PROTOCOL_NETBEUI:
+ return "NETBeui";
+
+ case EPM_PROTOCOL_SPX:
+ return "SPX";
+
+ case EPM_PROTOCOL_NB_IPX:
+ return "NB_IPX";
+
+ case EPM_PROTOCOL_HTTP:
+ return talloc_asprintf(mem_ctx, "HTTP:%d", epm_floor->rhs.http.port);
+
+ case EPM_PROTOCOL_TCP:
+ return talloc_asprintf(mem_ctx, "TCP:%d", epm_floor->rhs.tcp.port);
+
+ case EPM_PROTOCOL_UDP:
+ return talloc_asprintf(mem_ctx, "UDP:%d", epm_floor->rhs.udp.port);
+
+ default:
+ return talloc_asprintf(mem_ctx, "UNK(%02x):", epm_floor->lhs.protocol);
+ }
+}
+
+
+/*
+ form a binding string from a binding structure
+*/
+_PUBLIC_ char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_binding *b)
+{
+ char *s = talloc_strdup(mem_ctx, "");
+ int i;
+ const char *t_name = NULL;
+
+ if (b->transport != NCA_UNKNOWN) {
+ for (i=0;i<ARRAY_SIZE(transports);i++) {
+ if (transports[i].transport == b->transport) {
+ t_name = transports[i].name;
+ }
+ }
+ if (!t_name) {
+ return NULL;
+ }
+ }
+
+ if (!GUID_all_zero(&b->object.uuid)) {
+ s = talloc_asprintf(s, "%s@",
+ GUID_string(mem_ctx, &b->object.uuid));
+ }
+
+ if (t_name != NULL) {
+ s = talloc_asprintf_append_buffer(s, "%s:", t_name);
+ if (s == NULL) {
+ return NULL;
+ }
+ }
+
+ if (b->host) {
+ s = talloc_asprintf_append_buffer(s, "%s", b->host);
+ }
+
+ if (!b->endpoint && !b->options && !b->flags) {
+ return s;
+ }
+
+ s = talloc_asprintf_append_buffer(s, "[");
+
+ if (b->endpoint) {
+ s = talloc_asprintf_append_buffer(s, "%s", b->endpoint);
+ }
+
+ /* this is a *really* inefficent way of dealing with strings,
+ but this is rarely called and the strings are always short,
+ so I don't care */
+ for (i=0;b->options && b->options[i];i++) {
+ s = talloc_asprintf_append_buffer(s, ",%s", b->options[i]);
+ if (!s) return NULL;
+ }
+
+ for (i=0;i<ARRAY_SIZE(ncacn_options);i++) {
+ if (b->flags & ncacn_options[i].flag) {
+ s = talloc_asprintf_append_buffer(s, ",%s", ncacn_options[i].name);
+ if (!s) return NULL;
+ }
+ }
+
+ s = talloc_asprintf_append_buffer(s, "]");
+
+ return s;
+}
+
+/*
+ parse a binding string into a dcerpc_binding structure
+*/
+_PUBLIC_ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_binding **b_out)
+{
+ struct dcerpc_binding *b;
+ char *options;
+ char *p;
+ int i, j, comma_count;
+
+ b = talloc(mem_ctx, struct dcerpc_binding);
+ if (!b) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ p = strchr(s, '@');
+
+ if (p && PTR_DIFF(p, s) == 36) { /* 36 is the length of a UUID */
+ NTSTATUS status;
+
+ status = GUID_from_string(s, &b->object.uuid);
+
+ if (NT_STATUS_IS_ERR(status)) {
+ DEBUG(0, ("Failed parsing UUID\n"));
+ return status;
+ }
+
+ s = p + 1;
+ } else {
+ ZERO_STRUCT(b->object);
+ }
+
+ b->object.if_version = 0;
+
+ p = strchr(s, ':');
+
+ if (p == NULL) {
+ b->transport = NCA_UNKNOWN;
+ } else {
+ char *type = talloc_strndup(mem_ctx, s, PTR_DIFF(p, s));
+ if (!type) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i=0;i<ARRAY_SIZE(transports);i++) {
+ if (strcasecmp(type, transports[i].name) == 0) {
+ b->transport = transports[i].transport;
+ break;
+ }
+ }
+
+ if (i==ARRAY_SIZE(transports)) {
+ DEBUG(0,("Unknown dcerpc transport '%s'\n", type));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ talloc_free(type);
+
+ s = p+1;
+ }
+
+ p = strchr(s, '[');
+ if (p) {
+ b->host = talloc_strndup(b, s, PTR_DIFF(p, s));
+ options = talloc_strdup(mem_ctx, p+1);
+ if (options[strlen(options)-1] != ']') {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+ options[strlen(options)-1] = 0;
+ } else {
+ b->host = talloc_strdup(b, s);
+ options = NULL;
+ }
+ if (!b->host) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ b->target_hostname = b->host;
+
+ b->options = NULL;
+ b->flags = 0;
+ b->assoc_group_id = 0;
+ b->endpoint = NULL;
+
+ if (!options) {
+ *b_out = b;
+ return NT_STATUS_OK;
+ }
+
+ comma_count = count_chars(options, ',');
+
+ b->options = talloc_array(b, const char *, comma_count+2);
+ if (!b->options) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ for (i=0; (p = strchr(options, ',')); i++) {
+ b->options[i] = talloc_strndup(b, options, PTR_DIFF(p, options));
+ if (!b->options[i]) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ options = p+1;
+ }
+ b->options[i] = options;
+ b->options[i+1] = NULL;
+
+ /* some options are pre-parsed for convenience */
+ for (i=0;b->options[i];i++) {
+ for (j=0;j<ARRAY_SIZE(ncacn_options);j++) {
+ if (strcasecmp(ncacn_options[j].name, b->options[i]) == 0) {
+ int k;
+ b->flags |= ncacn_options[j].flag;
+ for (k=i;b->options[k];k++) {
+ b->options[k] = b->options[k+1];
+ }
+ i--;
+ break;
+ }
+ }
+ }
+
+ if (b->options[0]) {
+ /* Endpoint is first option */
+ b->endpoint = b->options[0];
+ if (strlen(b->endpoint) == 0) b->endpoint = NULL;
+
+ for (i=0;b->options[i];i++) {
+ b->options[i] = b->options[i+1];
+ }
+ }
+
+ if (b->options[0] == NULL)
+ b->options = NULL;
+
+ *b_out = b;
+ return NT_STATUS_OK;
+}
+
+_PUBLIC_ NTSTATUS dcerpc_floor_get_lhs_data(struct epm_floor *epm_floor, struct ndr_syntax_id *syntax)
+{
+ TALLOC_CTX *mem_ctx = talloc_init("floor_get_lhs_data");
+ struct ndr_pull *ndr = ndr_pull_init_blob(&epm_floor->lhs.lhs_data, mem_ctx, NULL);
+ enum ndr_err_code ndr_err;
+ uint16_t if_version=0;
+
+ ndr->flags |= LIBNDR_FLAG_NOALIGN;
+
+ ndr_err = ndr_pull_GUID(ndr, NDR_SCALARS | NDR_BUFFERS, &syntax->uuid);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ talloc_free(mem_ctx);
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ ndr_err = ndr_pull_uint16(ndr, NDR_SCALARS, &if_version);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ talloc_free(mem_ctx);
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ syntax->if_version = if_version;
+
+ talloc_free(mem_ctx);
+
+ return NT_STATUS_OK;
+}
+
+static DATA_BLOB dcerpc_floor_pack_lhs_data(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax)
+{
+ struct ndr_push *ndr = ndr_push_init_ctx(mem_ctx, NULL);
+
+ ndr->flags |= LIBNDR_FLAG_NOALIGN;
+
+ ndr_push_GUID(ndr, NDR_SCALARS | NDR_BUFFERS, &syntax->uuid);
+ ndr_push_uint16(ndr, NDR_SCALARS, syntax->if_version);
+
+ return ndr_push_blob(ndr);
+}
+
+const char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor)
+{
+ switch (epm_floor->lhs.protocol) {
+ case EPM_PROTOCOL_TCP:
+ if (epm_floor->rhs.tcp.port == 0) return NULL;
+ return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.tcp.port);
+
+ case EPM_PROTOCOL_UDP:
+ if (epm_floor->rhs.udp.port == 0) return NULL;
+ return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.udp.port);
+
+ case EPM_PROTOCOL_HTTP:
+ if (epm_floor->rhs.http.port == 0) return NULL;
+ return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.http.port);
+
+ case EPM_PROTOCOL_IP:
+ return talloc_strdup(mem_ctx, epm_floor->rhs.ip.ipaddr);
+
+ case EPM_PROTOCOL_NCACN:
+ return NULL;
+
+ case EPM_PROTOCOL_NCADG:
+ return NULL;
+
+ case EPM_PROTOCOL_SMB:
+ if (strlen(epm_floor->rhs.smb.unc) == 0) return NULL;
+ return talloc_strdup(mem_ctx, epm_floor->rhs.smb.unc);
+
+ case EPM_PROTOCOL_PIPE:
+ if (strlen(epm_floor->rhs.pipe.path) == 0) return NULL;
+ return talloc_strdup(mem_ctx, epm_floor->rhs.pipe.path);
+
+ case EPM_PROTOCOL_NETBIOS:
+ if (strlen(epm_floor->rhs.netbios.name) == 0) return NULL;
+ return talloc_strdup(mem_ctx, epm_floor->rhs.netbios.name);
+
+ case EPM_PROTOCOL_NCALRPC:
+ return NULL;
+
+ case EPM_PROTOCOL_VINES_SPP:
+ return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.vines_spp.port);
+
+ case EPM_PROTOCOL_VINES_IPC:
+ return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.vines_ipc.port);
+
+ case EPM_PROTOCOL_STREETTALK:
+ return talloc_strdup(mem_ctx, epm_floor->rhs.streettalk.streettalk);
+
+ case EPM_PROTOCOL_UNIX_DS:
+ if (strlen(epm_floor->rhs.unix_ds.path) == 0) return NULL;
+ return talloc_strdup(mem_ctx, epm_floor->rhs.unix_ds.path);
+
+ case EPM_PROTOCOL_NULL:
+ return NULL;
+
+ default:
+ DEBUG(0,("Unsupported lhs protocol %d\n", epm_floor->lhs.protocol));
+ break;
+ }
+
+ return NULL;
+}
+
+static NTSTATUS dcerpc_floor_set_rhs_data(TALLOC_CTX *mem_ctx,
+ struct epm_floor *epm_floor,
+ const char *data)
+{
+ switch (epm_floor->lhs.protocol) {
+ case EPM_PROTOCOL_TCP:
+ epm_floor->rhs.tcp.port = atoi(data);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_UDP:
+ epm_floor->rhs.udp.port = atoi(data);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_HTTP:
+ epm_floor->rhs.http.port = atoi(data);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_IP:
+ epm_floor->rhs.ip.ipaddr = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.ip.ipaddr);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_NCACN:
+ epm_floor->rhs.ncacn.minor_version = 0;
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_NCADG:
+ epm_floor->rhs.ncadg.minor_version = 0;
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_SMB:
+ epm_floor->rhs.smb.unc = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.smb.unc);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_PIPE:
+ epm_floor->rhs.pipe.path = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.pipe.path);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_NETBIOS:
+ epm_floor->rhs.netbios.name = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.netbios.name);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_NCALRPC:
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_VINES_SPP:
+ epm_floor->rhs.vines_spp.port = atoi(data);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_VINES_IPC:
+ epm_floor->rhs.vines_ipc.port = atoi(data);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_STREETTALK:
+ epm_floor->rhs.streettalk.streettalk = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.streettalk.streettalk);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_UNIX_DS:
+ epm_floor->rhs.unix_ds.path = talloc_strdup(mem_ctx, data);
+ NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.unix_ds.path);
+ return NT_STATUS_OK;
+
+ case EPM_PROTOCOL_NULL:
+ return NT_STATUS_OK;
+
+ default:
+ DEBUG(0,("Unsupported lhs protocol %d\n", epm_floor->lhs.protocol));
+ break;
+ }
+
+ return NT_STATUS_NOT_SUPPORTED;
+}
+
+enum dcerpc_transport_t dcerpc_transport_by_endpoint_protocol(int prot)
+{
+ int i;
+
+ /* Find a transport that has 'prot' as 4th protocol */
+ for (i=0;i<ARRAY_SIZE(transports);i++) {
+ if (transports[i].num_protocols >= 2 &&
+ transports[i].protseq[1] == prot) {
+ return transports[i].transport;
+ }
+ }
+
+ /* Unknown transport */
+ return (unsigned int)-1;
+}
+
+_PUBLIC_ enum dcerpc_transport_t dcerpc_transport_by_tower(struct epm_tower *tower)
+{
+ int i;
+
+ /* Find a transport that matches this tower */
+ for (i=0;i<ARRAY_SIZE(transports);i++) {
+ int j;
+ if (transports[i].num_protocols != tower->num_floors - 2) {
+ continue;
+ }
+
+ for (j = 0; j < transports[i].num_protocols; j++) {
+ if (transports[i].protseq[j] != tower->floors[j+2].lhs.protocol) {
+ break;
+ }
+ }
+
+ if (j == transports[i].num_protocols) {
+ return transports[i].transport;
+ }
+ }
+
+ /* Unknown transport */
+ return (unsigned int)-1;
+}
+
+_PUBLIC_ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx,
+ struct epm_tower *tower,
+ struct dcerpc_binding **b_out)
+{
+ NTSTATUS status;
+ struct dcerpc_binding *binding;
+
+ binding = talloc(mem_ctx, struct dcerpc_binding);
+ NT_STATUS_HAVE_NO_MEMORY(binding);
+
+ ZERO_STRUCT(binding->object);
+ binding->options = NULL;
+ binding->host = NULL;
+ binding->target_hostname = NULL;
+ binding->flags = 0;
+ binding->assoc_group_id = 0;
+
+ binding->transport = dcerpc_transport_by_tower(tower);
+
+ if (binding->transport == (unsigned int)-1) {
+ return NT_STATUS_NOT_SUPPORTED;
+ }
+
+ if (tower->num_floors < 1) {
+ return NT_STATUS_OK;
+ }
+
+ /* Set object uuid */
+ status = dcerpc_floor_get_lhs_data(&tower->floors[0], &binding->object);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("Error pulling object uuid and version: %s", nt_errstr(status)));
+ return status;
+ }
+
+ /* Ignore floor 1, it contains the NDR version info */
+
+ binding->options = NULL;
+
+ /* Set endpoint */
+ if (tower->num_floors >= 4) {
+ binding->endpoint = dcerpc_floor_get_rhs_data(mem_ctx, &tower->floors[3]);
+ } else {
+ binding->endpoint = NULL;
+ }
+
+ /* Set network address */
+ if (tower->num_floors >= 5) {
+ binding->host = dcerpc_floor_get_rhs_data(mem_ctx, &tower->floors[4]);
+ NT_STATUS_HAVE_NO_MEMORY(binding->host);
+ binding->target_hostname = binding->host;
+ }
+ *b_out = binding;
+ return NT_STATUS_OK;
+}
+
+_PUBLIC_ NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx, struct dcerpc_binding *binding, struct epm_tower *tower)
+{
+ const enum epm_protocol *protseq = NULL;
+ int num_protocols = -1, i;
+ NTSTATUS status;
+
+ /* Find transport */
+ for (i=0;i<ARRAY_SIZE(transports);i++) {
+ if (transports[i].transport == binding->transport) {
+ protseq = transports[i].protseq;
+ num_protocols = transports[i].num_protocols;
+ break;
+ }
+ }
+
+ if (num_protocols == -1) {
+ DEBUG(0, ("Unable to find transport with id '%d'\n", binding->transport));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ tower->num_floors = 2 + num_protocols;
+ tower->floors = talloc_array(mem_ctx, struct epm_floor, tower->num_floors);
+
+ /* Floor 0 */
+ tower->floors[0].lhs.protocol = EPM_PROTOCOL_UUID;
+
+ tower->floors[0].lhs.lhs_data = dcerpc_floor_pack_lhs_data(mem_ctx, &binding->object);
+
+ tower->floors[0].rhs.uuid.unknown = data_blob_talloc_zero(mem_ctx, 2);
+
+ /* Floor 1 */
+ tower->floors[1].lhs.protocol = EPM_PROTOCOL_UUID;
+
+ tower->floors[1].lhs.lhs_data = dcerpc_floor_pack_lhs_data(mem_ctx,
+ &ndr_transfer_syntax);
+
+ tower->floors[1].rhs.uuid.unknown = data_blob_talloc_zero(mem_ctx, 2);
+
+ /* Floor 2 to num_protocols */
+ for (i = 0; i < num_protocols; i++) {
+ tower->floors[2 + i].lhs.protocol = protseq[i];
+ tower->floors[2 + i].lhs.lhs_data = data_blob_talloc(mem_ctx, NULL, 0);
+ ZERO_STRUCT(tower->floors[2 + i].rhs);
+ dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[2 + i], "");
+ }
+
+ /* The 4th floor contains the endpoint */
+ if (num_protocols >= 2 && binding->endpoint) {
+ status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[3], binding->endpoint);
+ if (NT_STATUS_IS_ERR(status)) {
+ return status;
+ }
+ }
+
+ /* The 5th contains the network address */
+ if (num_protocols >= 3 && binding->host) {
+ if (is_ipaddress(binding->host)) {
+ status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[4],
+ binding->host);
+ } else {
+ /* note that we don't attempt to resolve the
+ name here - when we get a hostname here we
+ are in the client code, and want to put in
+ a wildcard all-zeros IP for the server to
+ fill in */
+ status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[4],
+ "0.0.0.0");
+ }
+ if (NT_STATUS_IS_ERR(status)) {
+ return status;
+ }
+ }
+
+ return NT_STATUS_OK;
+}
diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c
index 5e32f6f5bf..4758189d3b 100644
--- a/source4/librpc/rpc/dcerpc.c
+++ b/source4/librpc/rpc/dcerpc.c
@@ -67,22 +67,15 @@ static struct dcerpc_connection *dcerpc_connection_init(TALLOC_CTX *mem_ctx,
return NULL;
}
- if (ev == NULL) {
- ev = event_context_init(c);
- if (ev == NULL) {
- talloc_free(c);
- return NULL;
- }
- }
-
c->iconv_convenience = talloc_reference(c, ic);
- c->event_ctx = ev;
-
- if (!talloc_reference(c, ev)) {
+ c->event_ctx = talloc_reference(c, ev);
+
+ if (c->event_ctx == NULL) {
talloc_free(c);
return NULL;
}
+
c->call_id = 1;
c->security_state.auth_info = NULL;
c->security_state.session_key = dcerpc_generic_session_key;
diff --git a/source4/librpc/rpc/dcerpc.py b/source4/librpc/rpc/dcerpc.py
index 7e4d82d7c4..db5b95cee8 100644
--- a/source4/librpc/rpc/dcerpc.py
+++ b/source4/librpc/rpc/dcerpc.py
@@ -1,5 +1,5 @@
# This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.33
+# Version 1.3.35
#
# Don't modify this file, modify the SWIG interface instead.
@@ -57,8 +57,6 @@ def _swig_setattr_nondynamic_method(set):
return set_attr
-import credentials
-import param
pipe_connect = _dcerpc.pipe_connect
dcerpc_server_name = _dcerpc.dcerpc_server_name
diff --git a/source4/librpc/rpc/dcerpc_connect.c b/source4/librpc/rpc/dcerpc_connect.c
index cc7f2ddbaa..a22cad9a4a 100644
--- a/source4/librpc/rpc/dcerpc_connect.c
+++ b/source4/librpc/rpc/dcerpc_connect.c
@@ -717,12 +717,6 @@ _PUBLIC_ struct composite_context* dcerpc_pipe_connect_b_send(TALLOC_CTX *parent
struct pipe_connect_state *s;
struct event_context *new_ev = NULL;
- if (ev == NULL) {
- new_ev = event_context_init(parent_ctx);
- if (new_ev == NULL) return NULL;
- ev = new_ev;
- }
-
/* composite context allocation and setup */
c = composite_create(parent_ctx, ev);
if (c == NULL) {
@@ -844,21 +838,12 @@ _PUBLIC_ struct composite_context* dcerpc_pipe_connect_send(TALLOC_CTX *parent_c
struct pipe_conn_state *s;
struct dcerpc_binding *b;
struct composite_context *pipe_conn_req;
- struct event_context *new_ev = NULL;
-
- if (ev == NULL) {
- new_ev = event_context_init(parent_ctx);
- if (new_ev == NULL) return NULL;
- ev = new_ev;
- }
/* composite context allocation and setup */
c = composite_create(parent_ctx, ev);
if (c == NULL) {
- talloc_free(new_ev);
return NULL;
}
- talloc_steal(c, new_ev);
s = talloc_zero(c, struct pipe_conn_state);
if (composite_nomem(s, c)) return c;
diff --git a/source4/librpc/rpc/dcerpc_smb2.c b/source4/librpc/rpc/dcerpc_smb2.c
index 8adca4caba..4767165fba 100644
--- a/source4/librpc/rpc/dcerpc_smb2.c
+++ b/source4/librpc/rpc/dcerpc_smb2.c
@@ -83,7 +83,7 @@ static void smb2_read_callback(struct smb2_request *req)
uint16_t frag_length;
NTSTATUS status;
- state = talloc_get_type(req->async.private, struct smb2_read_state);
+ state = talloc_get_type(req->async.private_data, struct smb2_read_state);
smb = talloc_get_type(state->c->transport.private_data, struct smb2_private);
status = smb2_read_recv(req, state, &io);
@@ -136,7 +136,7 @@ static void smb2_read_callback(struct smb2_request *req)
}
req->async.fn = smb2_read_callback;
- req->async.private = state;
+ req->async.private_data = state;
}
@@ -180,7 +180,7 @@ static NTSTATUS send_read_request_continue(struct dcerpc_connection *c, DATA_BLO
}
req->async.fn = smb2_read_callback;
- req->async.private = state;
+ req->async.private_data = state;
return NT_STATUS_OK;
}
@@ -212,7 +212,7 @@ struct smb2_trans_state {
*/
static void smb2_trans_callback(struct smb2_request *req)
{
- struct smb2_trans_state *state = talloc_get_type(req->async.private,
+ struct smb2_trans_state *state = talloc_get_type(req->async.private_data,
struct smb2_trans_state);
struct dcerpc_connection *c = state->c;
NTSTATUS status;
@@ -269,7 +269,7 @@ static NTSTATUS smb2_send_trans_request(struct dcerpc_connection *c, DATA_BLOB *
}
req->async.fn = smb2_trans_callback;
- req->async.private = state;
+ req->async.private_data = state;
talloc_steal(state, req);
@@ -281,7 +281,7 @@ static NTSTATUS smb2_send_trans_request(struct dcerpc_connection *c, DATA_BLOB *
*/
static void smb2_write_callback(struct smb2_request *req)
{
- struct dcerpc_connection *c = (struct dcerpc_connection *)req->async.private;
+ struct dcerpc_connection *c = (struct dcerpc_connection *)req->async.private_data;
if (!NT_STATUS_IS_OK(req->status)) {
DEBUG(0,("dcerpc_smb2: write callback error\n"));
@@ -319,7 +319,7 @@ static NTSTATUS smb2_send_request(struct dcerpc_connection *c, DATA_BLOB *blob,
}
req->async.fn = smb2_write_callback;
- req->async.private = c;
+ req->async.private_data = c;
return NT_STATUS_OK;
}
@@ -444,7 +444,7 @@ struct composite_context *dcerpc_pipe_open_smb2_send(struct dcerpc_pipe *p,
static void pipe_open_recv(struct smb2_request *req)
{
struct pipe_open_smb2_state *state =
- talloc_get_type(req->async.private,
+ talloc_get_type(req->async.private_data,
struct pipe_open_smb2_state);
struct composite_context *ctx = state->ctx;
struct dcerpc_connection *c = state->c;
diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c
index 3b8768ccc2..71c6d5f2cc 100644
--- a/source4/librpc/rpc/dcerpc_util.c
+++ b/source4/librpc/rpc/dcerpc_util.c
@@ -97,701 +97,6 @@ NTSTATUS ncacn_push_auth(DATA_BLOB *blob, TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
-#define MAX_PROTSEQ 10
-
-static const struct {
- const char *name;
- enum dcerpc_transport_t transport;
- int num_protocols;
- enum epm_protocol protseq[MAX_PROTSEQ];
-} transports[] = {
- { "ncacn_np", NCACN_NP, 3,
- { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_SMB, EPM_PROTOCOL_NETBIOS }},
- { "ncacn_ip_tcp", NCACN_IP_TCP, 3,
- { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_TCP, EPM_PROTOCOL_IP } },
- { "ncacn_http", NCACN_HTTP, 3,
- { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_HTTP, EPM_PROTOCOL_IP } },
- { "ncadg_ip_udp", NCACN_IP_UDP, 3,
- { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_UDP, EPM_PROTOCOL_IP } },
- { "ncalrpc", NCALRPC, 2,
- { EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_PIPE } },
- { "ncacn_unix_stream", NCACN_UNIX_STREAM, 2,
- { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_UNIX_DS } },
- { "ncadg_unix_dgram", NCADG_UNIX_DGRAM, 2,
- { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_UNIX_DS } },
- { "ncacn_at_dsp", NCACN_AT_DSP, 3,
- { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_APPLETALK, EPM_PROTOCOL_DSP } },
- { "ncadg_at_ddp", NCADG_AT_DDP, 3,
- { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_APPLETALK, EPM_PROTOCOL_DDP } },
- { "ncacn_vns_ssp", NCACN_VNS_SPP, 3,
- { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_STREETTALK, EPM_PROTOCOL_VINES_SPP } },
- { "ncacn_vns_ipc", NCACN_VNS_IPC, 3,
- { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_STREETTALK, EPM_PROTOCOL_VINES_IPC }, },
- { "ncadg_ipx", NCADG_IPX, 2,
- { EPM_PROTOCOL_NCADG, EPM_PROTOCOL_IPX },
- },
- { "ncacn_spx", NCACN_SPX, 3,
- /* I guess some MS programmer confused the identifier for
- * EPM_PROTOCOL_UUID (0x0D or 13) with the one for
- * EPM_PROTOCOL_SPX (0x13) here. -- jelmer*/
- { EPM_PROTOCOL_NCACN, EPM_PROTOCOL_NCALRPC, EPM_PROTOCOL_UUID },
- },
-};
-
-static const struct {
- const char *name;
- uint32_t flag;
-} ncacn_options[] = {
- {"sign", DCERPC_SIGN},
- {"seal", DCERPC_SEAL},
- {"connect", DCERPC_CONNECT},
- {"spnego", DCERPC_AUTH_SPNEGO},
- {"ntlm", DCERPC_AUTH_NTLM},
- {"krb5", DCERPC_AUTH_KRB5},
- {"validate", DCERPC_DEBUG_VALIDATE_BOTH},
- {"print", DCERPC_DEBUG_PRINT_BOTH},
- {"padcheck", DCERPC_DEBUG_PAD_CHECK},
- {"bigendian", DCERPC_PUSH_BIGENDIAN},
- {"smb2", DCERPC_SMB2}
-};
-
-const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor)
-{
- struct ndr_syntax_id syntax;
- NTSTATUS status;
-
- switch(epm_floor->lhs.protocol) {
- case EPM_PROTOCOL_UUID:
- status = dcerpc_floor_get_lhs_data(epm_floor, &syntax);
- if (NT_STATUS_IS_OK(status)) {
- /* lhs is used: UUID */
- char *uuidstr;
-
- if (GUID_equal(&syntax.uuid, &ndr_transfer_syntax.uuid)) {
- return "NDR";
- }
-
- if (GUID_equal(&syntax.uuid, &ndr64_transfer_syntax.uuid)) {
- return "NDR64";
- }
-
- uuidstr = GUID_string(mem_ctx, &syntax.uuid);
-
- return talloc_asprintf(mem_ctx, " uuid %s/0x%02x", uuidstr, syntax.if_version);
- } else { /* IPX */
- return talloc_asprintf(mem_ctx, "IPX:%s",
- data_blob_hex_string(mem_ctx, &epm_floor->rhs.uuid.unknown));
- }
-
- case EPM_PROTOCOL_NCACN:
- return "RPC-C";
-
- case EPM_PROTOCOL_NCADG:
- return "RPC";
-
- case EPM_PROTOCOL_NCALRPC:
- return "NCALRPC";
-
- case EPM_PROTOCOL_DNET_NSP:
- return "DNET/NSP";
-
- case EPM_PROTOCOL_IP:
- return talloc_asprintf(mem_ctx, "IP:%s", epm_floor->rhs.ip.ipaddr);
-
- case EPM_PROTOCOL_PIPE:
- return talloc_asprintf(mem_ctx, "PIPE:%s", epm_floor->rhs.pipe.path);
-
- case EPM_PROTOCOL_SMB:
- return talloc_asprintf(mem_ctx, "SMB:%s", epm_floor->rhs.smb.unc);
-
- case EPM_PROTOCOL_UNIX_DS:
- return talloc_asprintf(mem_ctx, "Unix:%s", epm_floor->rhs.unix_ds.path);
-
- case EPM_PROTOCOL_NETBIOS:
- return talloc_asprintf(mem_ctx, "NetBIOS:%s", epm_floor->rhs.netbios.name);
-
- case EPM_PROTOCOL_NETBEUI:
- return "NETBeui";
-
- case EPM_PROTOCOL_SPX:
- return "SPX";
-
- case EPM_PROTOCOL_NB_IPX:
- return "NB_IPX";
-
- case EPM_PROTOCOL_HTTP:
- return talloc_asprintf(mem_ctx, "HTTP:%d", epm_floor->rhs.http.port);
-
- case EPM_PROTOCOL_TCP:
- return talloc_asprintf(mem_ctx, "TCP:%d", epm_floor->rhs.tcp.port);
-
- case EPM_PROTOCOL_UDP:
- return talloc_asprintf(mem_ctx, "UDP:%d", epm_floor->rhs.udp.port);
-
- default:
- return talloc_asprintf(mem_ctx, "UNK(%02x):", epm_floor->lhs.protocol);
- }
-}
-
-
-/*
- form a binding string from a binding structure
-*/
-_PUBLIC_ char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_binding *b)
-{
- char *s = talloc_strdup(mem_ctx, "");
- int i;
- const char *t_name = NULL;
-
- if (b->transport != NCA_UNKNOWN) {
- for (i=0;i<ARRAY_SIZE(transports);i++) {
- if (transports[i].transport == b->transport) {
- t_name = transports[i].name;
- }
- }
- if (!t_name) {
- return NULL;
- }
- }
-
- if (!GUID_all_zero(&b->object.uuid)) {
- s = talloc_asprintf(s, "%s@",
- GUID_string(mem_ctx, &b->object.uuid));
- }
-
- if (t_name != NULL) {
- s = talloc_asprintf_append_buffer(s, "%s:", t_name);
- if (s == NULL) {
- return NULL;
- }
- }
-
- if (b->host) {
- s = talloc_asprintf_append_buffer(s, "%s", b->host);
- }
-
- if (!b->endpoint && !b->options && !b->flags) {
- return s;
- }
-
- s = talloc_asprintf_append_buffer(s, "[");
-
- if (b->endpoint) {
- s = talloc_asprintf_append_buffer(s, "%s", b->endpoint);
- }
-
- /* this is a *really* inefficent way of dealing with strings,
- but this is rarely called and the strings are always short,
- so I don't care */
- for (i=0;b->options && b->options[i];i++) {
- s = talloc_asprintf_append_buffer(s, ",%s", b->options[i]);
- if (!s) return NULL;
- }
-
- for (i=0;i<ARRAY_SIZE(ncacn_options);i++) {
- if (b->flags & ncacn_options[i].flag) {
- s = talloc_asprintf_append_buffer(s, ",%s", ncacn_options[i].name);
- if (!s) return NULL;
- }
- }
-
- s = talloc_asprintf_append_buffer(s, "]");
-
- return s;
-}
-
-/*
- parse a binding string into a dcerpc_binding structure
-*/
-_PUBLIC_ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struct dcerpc_binding **b_out)
-{
- struct dcerpc_binding *b;
- char *options;
- char *p;
- int i, j, comma_count;
-
- b = talloc(mem_ctx, struct dcerpc_binding);
- if (!b) {
- return NT_STATUS_NO_MEMORY;
- }
-
- p = strchr(s, '@');
-
- if (p && PTR_DIFF(p, s) == 36) { /* 36 is the length of a UUID */
- NTSTATUS status;
-
- status = GUID_from_string(s, &b->object.uuid);
-
- if (NT_STATUS_IS_ERR(status)) {
- DEBUG(0, ("Failed parsing UUID\n"));
- return status;
- }
-
- s = p + 1;
- } else {
- ZERO_STRUCT(b->object);
- }
-
- b->object.if_version = 0;
-
- p = strchr(s, ':');
-
- if (p == NULL) {
- b->transport = NCA_UNKNOWN;
- } else {
- char *type = talloc_strndup(mem_ctx, s, PTR_DIFF(p, s));
- if (!type) {
- return NT_STATUS_NO_MEMORY;
- }
-
- for (i=0;i<ARRAY_SIZE(transports);i++) {
- if (strcasecmp(type, transports[i].name) == 0) {
- b->transport = transports[i].transport;
- break;
- }
- }
-
- if (i==ARRAY_SIZE(transports)) {
- DEBUG(0,("Unknown dcerpc transport '%s'\n", type));
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- talloc_free(type);
-
- s = p+1;
- }
-
- p = strchr(s, '[');
- if (p) {
- b->host = talloc_strndup(b, s, PTR_DIFF(p, s));
- options = talloc_strdup(mem_ctx, p+1);
- if (options[strlen(options)-1] != ']') {
- return NT_STATUS_INVALID_PARAMETER;
- }
- options[strlen(options)-1] = 0;
- } else {
- b->host = talloc_strdup(b, s);
- options = NULL;
- }
- if (!b->host) {
- return NT_STATUS_NO_MEMORY;
- }
-
- b->target_hostname = b->host;
-
- b->options = NULL;
- b->flags = 0;
- b->assoc_group_id = 0;
- b->endpoint = NULL;
-
- if (!options) {
- *b_out = b;
- return NT_STATUS_OK;
- }
-
- comma_count = count_chars(options, ',');
-
- b->options = talloc_array(b, const char *, comma_count+2);
- if (!b->options) {
- return NT_STATUS_NO_MEMORY;
- }
-
- for (i=0; (p = strchr(options, ',')); i++) {
- b->options[i] = talloc_strndup(b, options, PTR_DIFF(p, options));
- if (!b->options[i]) {
- return NT_STATUS_NO_MEMORY;
- }
- options = p+1;
- }
- b->options[i] = options;
- b->options[i+1] = NULL;
-
- /* some options are pre-parsed for convenience */
- for (i=0;b->options[i];i++) {
- for (j=0;j<ARRAY_SIZE(ncacn_options);j++) {
- if (strcasecmp(ncacn_options[j].name, b->options[i]) == 0) {
- int k;
- b->flags |= ncacn_options[j].flag;
- for (k=i;b->options[k];k++) {
- b->options[k] = b->options[k+1];
- }
- i--;
- break;
- }
- }
- }
-
- if (b->options[0]) {
- /* Endpoint is first option */
- b->endpoint = b->options[0];
- if (strlen(b->endpoint) == 0) b->endpoint = NULL;
-
- for (i=0;b->options[i];i++) {
- b->options[i] = b->options[i+1];
- }
- }
-
- if (b->options[0] == NULL)
- b->options = NULL;
-
- *b_out = b;
- return NT_STATUS_OK;
-}
-
-_PUBLIC_ NTSTATUS dcerpc_floor_get_lhs_data(struct epm_floor *epm_floor, struct ndr_syntax_id *syntax)
-{
- TALLOC_CTX *mem_ctx = talloc_init("floor_get_lhs_data");
- struct ndr_pull *ndr = ndr_pull_init_blob(&epm_floor->lhs.lhs_data, mem_ctx, NULL);
- enum ndr_err_code ndr_err;
- uint16_t if_version=0;
-
- ndr->flags |= LIBNDR_FLAG_NOALIGN;
-
- ndr_err = ndr_pull_GUID(ndr, NDR_SCALARS | NDR_BUFFERS, &syntax->uuid);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- talloc_free(mem_ctx);
- return ndr_map_error2ntstatus(ndr_err);
- }
-
- ndr_err = ndr_pull_uint16(ndr, NDR_SCALARS, &if_version);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- talloc_free(mem_ctx);
- return ndr_map_error2ntstatus(ndr_err);
- }
-
- syntax->if_version = if_version;
-
- talloc_free(mem_ctx);
-
- return NT_STATUS_OK;
-}
-
-static DATA_BLOB dcerpc_floor_pack_lhs_data(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *syntax)
-{
- struct ndr_push *ndr = ndr_push_init_ctx(mem_ctx, NULL);
-
- ndr->flags |= LIBNDR_FLAG_NOALIGN;
-
- ndr_push_GUID(ndr, NDR_SCALARS | NDR_BUFFERS, &syntax->uuid);
- ndr_push_uint16(ndr, NDR_SCALARS, syntax->if_version);
-
- return ndr_push_blob(ndr);
-}
-
-const char *dcerpc_floor_get_rhs_data(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor)
-{
- switch (epm_floor->lhs.protocol) {
- case EPM_PROTOCOL_TCP:
- if (epm_floor->rhs.tcp.port == 0) return NULL;
- return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.tcp.port);
-
- case EPM_PROTOCOL_UDP:
- if (epm_floor->rhs.udp.port == 0) return NULL;
- return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.udp.port);
-
- case EPM_PROTOCOL_HTTP:
- if (epm_floor->rhs.http.port == 0) return NULL;
- return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.http.port);
-
- case EPM_PROTOCOL_IP:
- return talloc_strdup(mem_ctx, epm_floor->rhs.ip.ipaddr);
-
- case EPM_PROTOCOL_NCACN:
- return NULL;
-
- case EPM_PROTOCOL_NCADG:
- return NULL;
-
- case EPM_PROTOCOL_SMB:
- if (strlen(epm_floor->rhs.smb.unc) == 0) return NULL;
- return talloc_strdup(mem_ctx, epm_floor->rhs.smb.unc);
-
- case EPM_PROTOCOL_PIPE:
- if (strlen(epm_floor->rhs.pipe.path) == 0) return NULL;
- return talloc_strdup(mem_ctx, epm_floor->rhs.pipe.path);
-
- case EPM_PROTOCOL_NETBIOS:
- if (strlen(epm_floor->rhs.netbios.name) == 0) return NULL;
- return talloc_strdup(mem_ctx, epm_floor->rhs.netbios.name);
-
- case EPM_PROTOCOL_NCALRPC:
- return NULL;
-
- case EPM_PROTOCOL_VINES_SPP:
- return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.vines_spp.port);
-
- case EPM_PROTOCOL_VINES_IPC:
- return talloc_asprintf(mem_ctx, "%d", epm_floor->rhs.vines_ipc.port);
-
- case EPM_PROTOCOL_STREETTALK:
- return talloc_strdup(mem_ctx, epm_floor->rhs.streettalk.streettalk);
-
- case EPM_PROTOCOL_UNIX_DS:
- if (strlen(epm_floor->rhs.unix_ds.path) == 0) return NULL;
- return talloc_strdup(mem_ctx, epm_floor->rhs.unix_ds.path);
-
- case EPM_PROTOCOL_NULL:
- return NULL;
-
- default:
- DEBUG(0,("Unsupported lhs protocol %d\n", epm_floor->lhs.protocol));
- break;
- }
-
- return NULL;
-}
-
-static NTSTATUS dcerpc_floor_set_rhs_data(TALLOC_CTX *mem_ctx,
- struct epm_floor *epm_floor,
- const char *data)
-{
- switch (epm_floor->lhs.protocol) {
- case EPM_PROTOCOL_TCP:
- epm_floor->rhs.tcp.port = atoi(data);
- return NT_STATUS_OK;
-
- case EPM_PROTOCOL_UDP:
- epm_floor->rhs.udp.port = atoi(data);
- return NT_STATUS_OK;
-
- case EPM_PROTOCOL_HTTP:
- epm_floor->rhs.http.port = atoi(data);
- return NT_STATUS_OK;
-
- case EPM_PROTOCOL_IP:
- epm_floor->rhs.ip.ipaddr = talloc_strdup(mem_ctx, data);
- NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.ip.ipaddr);
- return NT_STATUS_OK;
-
- case EPM_PROTOCOL_NCACN:
- epm_floor->rhs.ncacn.minor_version = 0;
- return NT_STATUS_OK;
-
- case EPM_PROTOCOL_NCADG:
- epm_floor->rhs.ncadg.minor_version = 0;
- return NT_STATUS_OK;
-
- case EPM_PROTOCOL_SMB:
- epm_floor->rhs.smb.unc = talloc_strdup(mem_ctx, data);
- NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.smb.unc);
- return NT_STATUS_OK;
-
- case EPM_PROTOCOL_PIPE:
- epm_floor->rhs.pipe.path = talloc_strdup(mem_ctx, data);
- NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.pipe.path);
- return NT_STATUS_OK;
-
- case EPM_PROTOCOL_NETBIOS:
- epm_floor->rhs.netbios.name = talloc_strdup(mem_ctx, data);
- NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.netbios.name);
- return NT_STATUS_OK;
-
- case EPM_PROTOCOL_NCALRPC:
- return NT_STATUS_OK;
-
- case EPM_PROTOCOL_VINES_SPP:
- epm_floor->rhs.vines_spp.port = atoi(data);
- return NT_STATUS_OK;
-
- case EPM_PROTOCOL_VINES_IPC:
- epm_floor->rhs.vines_ipc.port = atoi(data);
- return NT_STATUS_OK;
-
- case EPM_PROTOCOL_STREETTALK:
- epm_floor->rhs.streettalk.streettalk = talloc_strdup(mem_ctx, data);
- NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.streettalk.streettalk);
- return NT_STATUS_OK;
-
- case EPM_PROTOCOL_UNIX_DS:
- epm_floor->rhs.unix_ds.path = talloc_strdup(mem_ctx, data);
- NT_STATUS_HAVE_NO_MEMORY(epm_floor->rhs.unix_ds.path);
- return NT_STATUS_OK;
-
- case EPM_PROTOCOL_NULL:
- return NT_STATUS_OK;
-
- default:
- DEBUG(0,("Unsupported lhs protocol %d\n", epm_floor->lhs.protocol));
- break;
- }
-
- return NT_STATUS_NOT_SUPPORTED;
-}
-
-enum dcerpc_transport_t dcerpc_transport_by_endpoint_protocol(int prot)
-{
- int i;
-
- /* Find a transport that has 'prot' as 4th protocol */
- for (i=0;i<ARRAY_SIZE(transports);i++) {
- if (transports[i].num_protocols >= 2 &&
- transports[i].protseq[1] == prot) {
- return transports[i].transport;
- }
- }
-
- /* Unknown transport */
- return (unsigned int)-1;
-}
-
-_PUBLIC_ enum dcerpc_transport_t dcerpc_transport_by_tower(struct epm_tower *tower)
-{
- int i;
-
- /* Find a transport that matches this tower */
- for (i=0;i<ARRAY_SIZE(transports);i++) {
- int j;
- if (transports[i].num_protocols != tower->num_floors - 2) {
- continue;
- }
-
- for (j = 0; j < transports[i].num_protocols; j++) {
- if (transports[i].protseq[j] != tower->floors[j+2].lhs.protocol) {
- break;
- }
- }
-
- if (j == transports[i].num_protocols) {
- return transports[i].transport;
- }
- }
-
- /* Unknown transport */
- return (unsigned int)-1;
-}
-
-_PUBLIC_ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx,
- struct epm_tower *tower,
- struct dcerpc_binding **b_out)
-{
- NTSTATUS status;
- struct dcerpc_binding *binding;
-
- binding = talloc(mem_ctx, struct dcerpc_binding);
- NT_STATUS_HAVE_NO_MEMORY(binding);
-
- ZERO_STRUCT(binding->object);
- binding->options = NULL;
- binding->host = NULL;
- binding->target_hostname = NULL;
- binding->flags = 0;
- binding->assoc_group_id = 0;
-
- binding->transport = dcerpc_transport_by_tower(tower);
-
- if (binding->transport == (unsigned int)-1) {
- return NT_STATUS_NOT_SUPPORTED;
- }
-
- if (tower->num_floors < 1) {
- return NT_STATUS_OK;
- }
-
- /* Set object uuid */
- status = dcerpc_floor_get_lhs_data(&tower->floors[0], &binding->object);
-
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(1, ("Error pulling object uuid and version: %s", nt_errstr(status)));
- return status;
- }
-
- /* Ignore floor 1, it contains the NDR version info */
-
- binding->options = NULL;
-
- /* Set endpoint */
- if (tower->num_floors >= 4) {
- binding->endpoint = dcerpc_floor_get_rhs_data(mem_ctx, &tower->floors[3]);
- } else {
- binding->endpoint = NULL;
- }
-
- /* Set network address */
- if (tower->num_floors >= 5) {
- binding->host = dcerpc_floor_get_rhs_data(mem_ctx, &tower->floors[4]);
- NT_STATUS_HAVE_NO_MEMORY(binding->host);
- binding->target_hostname = binding->host;
- }
- *b_out = binding;
- return NT_STATUS_OK;
-}
-
-_PUBLIC_ NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx, struct dcerpc_binding *binding, struct epm_tower *tower)
-{
- const enum epm_protocol *protseq = NULL;
- int num_protocols = -1, i;
- NTSTATUS status;
-
- /* Find transport */
- for (i=0;i<ARRAY_SIZE(transports);i++) {
- if (transports[i].transport == binding->transport) {
- protseq = transports[i].protseq;
- num_protocols = transports[i].num_protocols;
- break;
- }
- }
-
- if (num_protocols == -1) {
- DEBUG(0, ("Unable to find transport with id '%d'\n", binding->transport));
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- tower->num_floors = 2 + num_protocols;
- tower->floors = talloc_array(mem_ctx, struct epm_floor, tower->num_floors);
-
- /* Floor 0 */
- tower->floors[0].lhs.protocol = EPM_PROTOCOL_UUID;
-
- tower->floors[0].lhs.lhs_data = dcerpc_floor_pack_lhs_data(mem_ctx, &binding->object);
-
- tower->floors[0].rhs.uuid.unknown = data_blob_talloc_zero(mem_ctx, 2);
-
- /* Floor 1 */
- tower->floors[1].lhs.protocol = EPM_PROTOCOL_UUID;
-
- tower->floors[1].lhs.lhs_data = dcerpc_floor_pack_lhs_data(mem_ctx,
- &ndr_transfer_syntax);
-
- tower->floors[1].rhs.uuid.unknown = data_blob_talloc_zero(mem_ctx, 2);
-
- /* Floor 2 to num_protocols */
- for (i = 0; i < num_protocols; i++) {
- tower->floors[2 + i].lhs.protocol = protseq[i];
- tower->floors[2 + i].lhs.lhs_data = data_blob_talloc(mem_ctx, NULL, 0);
- ZERO_STRUCT(tower->floors[2 + i].rhs);
- dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[2 + i], "");
- }
-
- /* The 4th floor contains the endpoint */
- if (num_protocols >= 2 && binding->endpoint) {
- status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[3], binding->endpoint);
- if (NT_STATUS_IS_ERR(status)) {
- return status;
- }
- }
-
- /* The 5th contains the network address */
- if (num_protocols >= 3 && binding->host) {
- if (is_ipaddress(binding->host)) {
- status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[4],
- binding->host);
- } else {
- /* note that we don't attempt to resolve the
- name here - when we get a hostname here we
- are in the client code, and want to put in
- a wildcard all-zeros IP for the server to
- fill in */
- status = dcerpc_floor_set_rhs_data(mem_ctx, &tower->floors[4],
- "0.0.0.0");
- }
- if (NT_STATUS_IS_ERR(status)) {
- return status;
- }
- }
-
- return NT_STATUS_OK;
-}
-
struct epm_map_binding_state {
struct dcerpc_binding *binding;
@@ -904,32 +209,20 @@ struct composite_context *dcerpc_epm_map_binding_send(TALLOC_CTX *mem_ctx,
struct epm_map_binding_state *s;
struct composite_context *pipe_connect_req;
struct cli_credentials *anon_creds;
- struct event_context *new_ev = NULL;
NTSTATUS status;
struct dcerpc_binding *epmapper_binding;
int i;
- /* Try to find event context in memory context in case passed
- * event_context (argument) was NULL. If there's none, just
- * create a new one.
- */
if (ev == NULL) {
- ev = event_context_find(mem_ctx);
- if (ev == NULL) {
- new_ev = event_context_init(mem_ctx);
- if (new_ev == NULL) return NULL;
- ev = new_ev;
- }
+ return NULL;
}
/* composite context allocation and setup */
c = composite_create(mem_ctx, ev);
if (c == NULL) {
- talloc_free(new_ev);
return NULL;
}
- talloc_steal(c, new_ev);
s = talloc_zero(c, struct epm_map_binding_state);
if (composite_nomem(s, c)) return c;
@@ -940,7 +233,6 @@ struct composite_context *dcerpc_epm_map_binding_send(TALLOC_CTX *mem_ctx,
/* anonymous credentials for rpc connection used to get endpoint mapping */
anon_creds = cli_credentials_init(mem_ctx);
- cli_credentials_set_event_context(anon_creds, ev);
cli_credentials_set_anonymous(anon_creds);
/*
diff --git a/source4/librpc/rpc/dcerpc_wrap.c b/source4/librpc/rpc/dcerpc_wrap.c
index bae41c2c22..ff5cdbd390 100644
--- a/source4/librpc/rpc/dcerpc_wrap.c
+++ b/source4/librpc/rpc/dcerpc_wrap.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.33
+ * Version 1.3.35
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
@@ -126,7 +126,7 @@
/* This should only be incremented when either the layout of swig_type_info changes,
or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "3"
+#define SWIG_RUNTIME_VERSION "4"
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
#ifdef SWIG_TYPE_TABLE
@@ -161,6 +161,7 @@
/* Flags for pointer conversions */
#define SWIG_POINTER_DISOWN 0x1
+#define SWIG_CAST_NEW_MEMORY 0x2
/* Flags for new pointer objects */
#define SWIG_POINTER_OWN 0x1
@@ -301,10 +302,10 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) {
extern "C" {
#endif
-typedef void *(*swig_converter_func)(void *);
+typedef void *(*swig_converter_func)(void *, int *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);
-/* Structure to store inforomation on one type */
+/* Structure to store information on one type */
typedef struct swig_type_info {
const char *name; /* mangled name of this type */
const char *str; /* human readable name of this type */
@@ -431,8 +432,8 @@ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
Cast a pointer up an inheritance hierarchy
*/
SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
- return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
+SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
}
/*
@@ -856,7 +857,7 @@ SWIG_Python_AddErrorMsg(const char* mesg)
Py_DECREF(old_str);
Py_DECREF(value);
} else {
- PyErr_Format(PyExc_RuntimeError, mesg);
+ PyErr_SetString(PyExc_RuntimeError, mesg);
}
}
@@ -1416,7 +1417,7 @@ PySwigObject_dealloc(PyObject *v)
{
PySwigObject *sobj = (PySwigObject *) v;
PyObject *next = sobj->next;
- if (sobj->own) {
+ if (sobj->own == SWIG_POINTER_OWN) {
swig_type_info *ty = sobj->ty;
PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
PyObject *destroy = data ? data->destroy : 0;
@@ -1434,12 +1435,13 @@ PySwigObject_dealloc(PyObject *v)
res = ((*meth)(mself, v));
}
Py_XDECREF(res);
- } else {
- const char *name = SWIG_TypePrettyName(ty);
+ }
#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
- printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
-#endif
+ else {
+ const char *name = SWIG_TypePrettyName(ty);
+ printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
}
+#endif
}
Py_XDECREF(next);
PyObject_DEL(v);
@@ -1944,7 +1946,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
SWIGRUNTIME int
SWIG_Python_AcquirePtr(PyObject *obj, int own) {
- if (own) {
+ if (own == SWIG_POINTER_OWN) {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
if (sobj) {
int oldown = sobj->own;
@@ -1965,6 +1967,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
return SWIG_OK;
} else {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+ if (own)
+ *own = 0;
while (sobj) {
void *vptr = sobj->ptr;
if (ty) {
@@ -1978,7 +1982,15 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
if (!tc) {
sobj = (PySwigObject *)sobj->next;
} else {
- if (ptr) *ptr = SWIG_TypeCast(tc,vptr);
+ if (ptr) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
+ assert(own);
+ if (own)
+ *own = *own | SWIG_CAST_NEW_MEMORY;
+ }
+ }
break;
}
}
@@ -1988,7 +2000,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
}
}
if (sobj) {
- if (own) *own = sobj->own;
+ if (own)
+ *own = *own | sobj->own;
if (flags & SWIG_POINTER_DISOWN) {
sobj->own = 0;
}
@@ -2053,8 +2066,13 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
}
if (ty) {
swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
- if (!tc) return SWIG_ERROR;
- *ptr = SWIG_TypeCast(tc,vptr);
+ if (tc) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ assert(!newmemory); /* newmemory handling not yet implemented */
+ } else {
+ return SWIG_ERROR;
+ }
} else {
*ptr = vptr;
}
@@ -2510,7 +2528,7 @@ static swig_module_info swig_module = {swig_types, 21, 0, 0, 0, 0};
#define SWIG_name "_dcerpc"
-#define SWIGVERSION 0x010333
+#define SWIGVERSION 0x010335
#define SWIG_VERSION SWIGVERSION
@@ -2912,7 +2930,7 @@ SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
- int found;
+ int found, init;
clientdata = clientdata;
@@ -2922,6 +2940,9 @@ SWIG_InitializeModule(void *clientdata) {
swig_module.type_initial = swig_type_initial;
swig_module.cast_initial = swig_cast_initial;
swig_module.next = &swig_module;
+ init = 1;
+ } else {
+ init = 0;
}
/* Try and load any already created modules */
@@ -2950,6 +2971,12 @@ SWIG_InitializeModule(void *clientdata) {
module_head->next = &swig_module;
}
+ /* When multiple interpeters are used, a module could have already been initialized in
+ a different interpreter, but not yet have a pointer in this interpreter.
+ In this case, we do not want to continue adding types... everything should be
+ set up already */
+ if (init == 0) return;
+
/* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: size %d\n", swig_module.size);
diff --git a/source4/script/build_idl.sh b/source4/librpc/scripts/build_idl.sh
index ea0cb78b0e..3f13b64a2e 100755
--- a/source4/script/build_idl.sh
+++ b/source4/librpc/scripts/build_idl.sh
@@ -1,24 +1,26 @@
#!/bin/sh
FULLBUILD=$1
-shift 1
+IDLDIR=$2
+OUTDIR=$3
+shift 3
PIDL_EXTRA_ARGS="$*"
-[ -d librpc/gen_ndr ] || mkdir -p librpc/gen_ndr || exit 1
+[ -d $OUTDIR ] || mkdir -p $OUTDIR || exit 1
-PIDL="$PERL $srcdir/pidl/pidl --outputdir librpc/gen_ndr --header --ndr-parser --server --client --swig --ejs --python $PIDL_EXTRA_ARGS"
+PIDL="$PIDL --outputdir $OUTDIR --header --ndr-parser --server --client --swig --python $PIDL_EXTRA_ARGS"
if [ x$FULLBUILD = xFULL ]; then
- echo Rebuilding all idl files in librpc/idl
- $PIDL $srcdir/librpc/idl/*.idl || exit 1
+ echo Rebuilding all idl files in $IDLDIR
+ $PIDL $IDLDIR/*.idl || exit 1
exit 0
fi
list=""
-for f in $srcdir/librpc/idl/*.idl ; do
+for f in $IDLDIR/*.idl ; do
basename=`basename $f .idl`
- ndr="librpc/gen_ndr/ndr_$basename.c"
+ ndr="$OUTDIR/ndr_$basename.c"
# blergh - most shells don't have the -nt function
if [ -f $ndr ]; then
if [ x`find $f -newer $ndr -print` = x$f ]; then
diff --git a/source4/main.mk b/source4/main.mk
index b8364aca5a..5e31044c09 100644
--- a/source4/main.mk
+++ b/source4/main.mk
@@ -1,31 +1,95 @@
mkinclude dynconfig.mk
+heimdalsrcdir := heimdal
mkinclude heimdal_build/config.mk
mkinclude config.mk
+dsdbsrcdir := dsdb
mkinclude dsdb/config.mk
+smbdsrcdir := smbd
mkinclude smbd/config.mk
+clustersrcdir := cluster
mkinclude cluster/config.mk
mkinclude smbd/process_model.mk
+libnetsrcdir := libnet
mkinclude libnet/config.mk
+authsrcdir := auth
mkinclude auth/config.mk
+nsswitchsrcdir := nsswitch
mkinclude nsswitch/config.mk
+libsrcdir := lib
+mkinclude lib/samba3/config.mk
+libsocketsrcdir := lib/socket
+mkinclude lib/socket/config.mk
+libcharsetsrcdir := lib/charset
+mkinclude lib/charset/config.mk
+ldb_sambasrcdir := lib/ldb-samba
+mkinclude lib/ldb-samba/config.mk
+libtlssrcdir := lib/tls
+mkinclude lib/tls/config.mk
+libregistrysrcdir := lib/registry
+mkinclude lib/registry/config.mk
+libmessagingsrcdir := lib/messaging
+mkinclude lib/messaging/config.mk
+libeventssrcdir := lib/events
+mkinclude lib/events/config.mk
+libcmdlinesrcdir := lib/cmdline
+mkinclude lib/cmdline/config.mk
+socketwrappersrcdir := lib/socket_wrapper
+mkinclude lib/socket_wrapper/config.mk
+nsswrappersrcdir := lib/nss_wrapper
+mkinclude lib/nss_wrapper/config.mk
+appwebsrcdir := lib/appweb
+mkinclude lib/appweb/config.mk
+libstreamsrcdir := lib/stream
+mkinclude lib/stream/config.mk
+libutilsrcdir := lib/util
+mkinclude lib/util/config.mk
+libtdrsrcdir := lib/tdr
+mkinclude lib/tdr/config.mk
+libdbwrapsrcdir := lib/dbwrap
+mkinclude lib/dbwrap/config.mk
+libcryptosrcdir := lib/crypto
+mkinclude lib/crypto/config.mk
+libtorturesrcdir := lib/torture
+mkinclude lib/torture/config.mk
+libcompressionsrcdir := lib/compression
+libgencachesrcdir := lib
mkinclude lib/basic.mk
+paramsrcdir := param
mkinclude param/config.mk
+smb_serversrcdir := smb_server
mkinclude smb_server/config.mk
+rpc_serversrcdir := rpc_server
mkinclude rpc_server/config.mk
+ldap_serversrcdir := ldap_server
mkinclude ldap_server/config.mk
+web_serversrcdir := web_server
mkinclude web_server/config.mk
+winbindsrcdir := winbind
mkinclude winbind/config.mk
+nbt_serversrcdir := nbt_server
mkinclude nbt_server/config.mk
+wrepl_serversrcdir := wrepl_server
mkinclude wrepl_server/config.mk
+cldap_serversrcdir := cldap_server
mkinclude cldap_server/config.mk
+utilssrcdir := utils
mkinclude utils/net/config.mk
mkinclude utils/config.mk
+ntvfssrcdir := ntvfs
mkinclude ntvfs/config.mk
+ntptrsrcdir := ntptr
mkinclude ntptr/config.mk
+torturesrcdir := torture
mkinclude torture/config.mk
+librpcsrcdir := librpc
mkinclude librpc/config.mk
+clientsrcdir := client
mkinclude client/config.mk
+libclisrcdir := libcli
mkinclude libcli/config.mk
+ejsscriptsrcdir := scripting/ejs
mkinclude scripting/ejs/config.mk
+pyscriptsrcdir := scripting/python
mkinclude scripting/python/config.mk
+kdcsrcdir := kdc
mkinclude kdc/config.mk
diff --git a/source4/nbt_server/config.mk b/source4/nbt_server/config.mk
index b510a6e2d6..b17fd4ce52 100644
--- a/source4/nbt_server/config.mk
+++ b/source4/nbt_server/config.mk
@@ -3,76 +3,76 @@
#######################
# Start SUBSYSTEM WINSDB
[SUBSYSTEM::WINSDB]
-OBJ_FILES = \
- wins/winsdb.o \
- wins/wins_hook.o
-PRIVATE_PROTO_HEADER = wins/winsdb_proto.h
PUBLIC_DEPENDENCIES = \
LIBLDB
# End SUBSYSTEM WINSDB
#######################
+WINSDB_OBJ_FILES = $(addprefix $(nbt_serversrcdir)/wins/, winsdb.o wins_hook.o)
+
+$(eval $(call proto_header_template,$(nbt_serversrcdir)/wins/winsdb_proto.h,$(WINSDB_OBJ_FILES:.o=.c)))
+
#######################
# Start MODULE ldb_wins_ldb
[MODULE::ldb_wins_ldb]
SUBSYSTEM = LIBLDB
OUTPUT_TYPE = SHARED_LIBRARY
-INIT_FUNCTION = &ldb_wins_ldb_module_ops
-OBJ_FILES = \
- wins/wins_ldb.o
+INIT_FUNCTION = LDB_MODULE(wins_ldb)
PRIVATE_DEPENDENCIES = \
LIBNETIF LIBSAMBA-HOSTCONFIG LIBSAMBA-UTIL
# End MODULE ldb_wins_ldb
#######################
+ldb_wins_ldb_OBJ_FILES = $(nbt_serversrcdir)/wins/wins_ldb.o
+
#######################
# Start SUBSYSTEM NBTD_WINS
[SUBSYSTEM::NBTD_WINS]
-OBJ_FILES = \
- wins/winsserver.o \
- wins/winsclient.o \
- wins/winswack.o \
- wins/wins_dns_proxy.o
-PRIVATE_PROTO_HEADER = wins/winsserver_proto.h
PRIVATE_DEPENDENCIES = \
LIBCLI_NBT WINSDB
# End SUBSYSTEM NBTD_WINS
#######################
+
+NBTD_WINS_OBJ_FILES = $(addprefix $(nbt_serversrcdir)/wins/, winsserver.o winsclient.o winswack.o wins_dns_proxy.o)
+
+$(eval $(call proto_header_template,$(nbt_serversrcdir)/wins/winsserver_proto.h,$(NBTD_WINS_OBJ_FILES:.o=.c)))
+
#######################
# Start SUBSYSTEM NBTD_DGRAM
[SUBSYSTEM::NBTD_DGRAM]
-PRIVATE_PROTO_HEADER = dgram/proto.h
-OBJ_FILES = \
- dgram/request.o \
- dgram/netlogon.o \
- dgram/ntlogon.o \
- dgram/browse.o
PRIVATE_DEPENDENCIES = \
LIBCLI_DGRAM
# End SUBSYSTEM NBTD_DGRAM
#######################
+NBTD_DGRAM_OBJ_FILES = $(addprefix $(nbt_serversrcdir)/dgram/, request.o netlogon.o browse.o)
+
+$(eval $(call proto_header_template,$(nbt_serversrcdir)/dgram/proto.h,$(NBTD_DGRAM_OBJ_FILES:.o=.c)))
+
#######################
# Start SUBSYSTEM NBTD
[SUBSYSTEM::NBT_SERVER]
-OBJ_FILES = \
+PRIVATE_DEPENDENCIES = \
+ LIBCLI_NBT NBTD_WINS NBTD_DGRAM
+# End SUBSYSTEM NBTD
+#######################
+
+NBT_SERVER_OBJ_FILES = $(addprefix $(nbt_serversrcdir)/, \
interfaces.o \
register.o \
query.o \
nodestatus.o \
defense.o \
packet.o \
- irpc.o
-PRIVATE_PROTO_HEADER = nbt_server_proto.h
-PRIVATE_DEPENDENCIES = \
- LIBCLI_NBT NBTD_WINS NBTD_DGRAM
-# End SUBSYSTEM NBTD
-#######################
+ irpc.o)
+
+$(eval $(call proto_header_template,$(nbt_serversrcdir)/nbt_server_proto.h,$(NBT_SERVER_OBJ_FILES:.o=.c)))
[MODULE::service_nbtd]
INIT_FUNCTION = server_service_nbtd_init
-SUBSYSTEM = service
-OBJ_FILES = \
- nbt_server.o
+SUBSYSTEM = smbd
PRIVATE_DEPENDENCIES = NBT_SERVER process_model
+
+service_nbtd_OBJ_FILES = \
+ $(nbt_serversrcdir)/nbt_server.o
diff --git a/source4/nbt_server/dgram/netlogon.c b/source4/nbt_server/dgram/netlogon.c
index 46bfaa9381..5e263a5854 100644
--- a/source4/nbt_server/dgram/netlogon.c
+++ b/source4/nbt_server/dgram/netlogon.c
@@ -4,7 +4,8 @@
NBT datagram netlogon server
Copyright (C) Andrew Tridgell 2005
-
+ Copyright (C) Andrew Bartlett <abartlet@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
@@ -26,9 +27,10 @@
#include "dsdb/samdb/samdb.h"
#include "auth/auth.h"
#include "util/util_ldb.h"
-#include "librpc/gen_ndr/ndr_nbt.h"
#include "param/param.h"
#include "smbd/service_task.h"
+#include "cldap_server/cldap_server.h"
+#include "libcli/security/security.h"
/*
reply to a GETDC request
@@ -41,12 +43,12 @@ static void nbtd_netlogon_getdc(struct dgram_mailslot_handler *dgmslot,
{
struct nbt_name *name = &packet->data.msg.dest_name;
struct nbtd_interface *reply_iface = nbtd_find_reply_iface(iface, src->addr, false);
- struct nbt_netlogon_packet reply;
struct nbt_netlogon_response_from_pdc *pdc;
const char *ref_attrs[] = {"nETBIOSName", NULL};
struct ldb_message **ref_res;
struct ldb_context *samctx;
struct ldb_dn *partitions_basedn;
+ struct nbt_netlogon_response netlogon_response;
int ret;
/* only answer getdc requests on the PDC or LOGON names */
@@ -54,12 +56,17 @@ static void nbtd_netlogon_getdc(struct dgram_mailslot_handler *dgmslot,
return;
}
- samctx = samdb_connect(packet, iface->nbtsrv->task->lp_ctx, anonymous_session(packet, iface->nbtsrv->task->lp_ctx));
+ samctx = samdb_connect(packet, iface->nbtsrv->task->event_ctx, iface->nbtsrv->task->lp_ctx, anonymous_session(packet, iface->nbtsrv->task->event_ctx, iface->nbtsrv->task->lp_ctx));
if (samctx == NULL) {
DEBUG(2,("Unable to open sam in getdc reply\n"));
return;
}
+ if (!samdb_is_pdc(samctx)) {
+ DEBUG(2, ("Not a PDC, so not processing LOGON_PRIMARY_QUERY\n"));
+ return;
+ }
+
partitions_basedn = samdb_partitions_dn(samctx, packet);
ret = gendb_search(samctx, packet, partitions_basedn, &ref_res, ref_attrs,
@@ -72,10 +79,11 @@ static void nbtd_netlogon_getdc(struct dgram_mailslot_handler *dgmslot,
}
/* setup a GETDC reply */
- ZERO_STRUCT(reply);
- reply.command = NETLOGON_RESPONSE_FROM_PDC;
- pdc = &reply.req.response;
+ ZERO_STRUCT(netlogon_response);
+ netlogon_response.response_type = NETLOGON_GET_PDC;
+ pdc = &netlogon_response.get_pdc;
+ pdc->command = NETLOGON_RESPONSE_FROM_PDC;
pdc->pdc_name = lp_netbios_name(iface->nbtsrv->task->lp_ctx);
pdc->unicode_pdc_name = pdc->pdc_name;
pdc->domain_name = samdb_result_string(ref_res[0], "nETBIOSName", name->name);;
@@ -83,38 +91,31 @@ static void nbtd_netlogon_getdc(struct dgram_mailslot_handler *dgmslot,
pdc->lmnt_token = 0xFFFF;
pdc->lm20_token = 0xFFFF;
-
- packet->data.msg.dest_name.type = 0;
-
dgram_mailslot_netlogon_reply(reply_iface->dgmsock,
packet,
lp_netbios_name(iface->nbtsrv->task->lp_ctx),
netlogon->req.pdc.mailslot_name,
- &reply);
+ &netlogon_response);
}
/*
reply to a ADS style GETDC request
*/
-static void nbtd_netlogon_getdc2(struct dgram_mailslot_handler *dgmslot,
- struct nbtd_interface *iface,
- struct nbt_dgram_packet *packet,
- const struct socket_address *src,
- struct nbt_netlogon_packet *netlogon)
+static void nbtd_netlogon_samlogon(struct dgram_mailslot_handler *dgmslot,
+ struct nbtd_interface *iface,
+ struct nbt_dgram_packet *packet,
+ const struct socket_address *src,
+ struct nbt_netlogon_packet *netlogon)
{
struct nbt_name *name = &packet->data.msg.dest_name;
struct nbtd_interface *reply_iface = nbtd_find_reply_iface(iface, src->addr, false);
- struct nbt_netlogon_packet reply;
- struct nbt_netlogon_response_from_pdc2 *pdc;
struct ldb_context *samctx;
- const char *ref_attrs[] = {"nETBIOSName", "dnsRoot", "ncName", NULL};
- const char *dom_attrs[] = {"objectGUID", NULL};
- struct ldb_message **ref_res, **dom_res;
- int ret;
- const char **services = lp_server_services(iface->nbtsrv->task->lp_ctx);
const char *my_ip = reply_iface->ip_address;
- struct ldb_dn *partitions_basedn;
+ struct dom_sid *sid;
+ struct nbt_netlogon_response netlogon_response;
+ NTSTATUS status;
+
if (!my_ip) {
DEBUG(0, ("Could not obtain own IP address for datagram socket\n"));
return;
@@ -125,96 +126,36 @@ static void nbtd_netlogon_getdc2(struct dgram_mailslot_handler *dgmslot,
return;
}
- samctx = samdb_connect(packet, iface->nbtsrv->task->lp_ctx, anonymous_session(packet, iface->nbtsrv->task->lp_ctx));
+ samctx = samdb_connect(packet, iface->nbtsrv->task->event_ctx, iface->nbtsrv->task->lp_ctx, anonymous_session(packet, iface->nbtsrv->task->event_ctx, iface->nbtsrv->task->lp_ctx));
if (samctx == NULL) {
DEBUG(2,("Unable to open sam in getdc reply\n"));
return;
}
- partitions_basedn = samdb_partitions_dn(samctx, packet);
-
- ret = gendb_search(samctx, packet, partitions_basedn, &ref_res, ref_attrs,
- "(&(&(nETBIOSName=%s)(objectclass=crossRef))(ncName=*))",
- name->name);
-
- if (ret != 1) {
- DEBUG(2,("Unable to find domain reference '%s' in sam\n", name->name));
- return;
+ if (netlogon->req.logon.sid_size) {
+ sid = &netlogon->req.logon.sid;
+ } else {
+ sid = NULL;
}
- /* try and find the domain */
- ret = gendb_search_dn(samctx, packet,
- samdb_result_dn(samctx, samctx, ref_res[0], "ncName", NULL),
- &dom_res, dom_attrs);
- if (ret != 1) {
- DEBUG(2,("Unable to find domain from reference '%s' in sam\n",
- ldb_dn_get_linearized(ref_res[0]->dn)));
+ status = fill_netlogon_samlogon_response(samctx, packet, NULL, name->name, sid, NULL,
+ netlogon->req.logon.user_name, netlogon->req.logon.acct_control, src->addr,
+ netlogon->req.logon.nt_version, iface->nbtsrv->task->lp_ctx, &netlogon_response.samlogon);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(2,("NBT netlogon query failed domain=%s sid=%s version=%d - %s\n",
+ name->name, dom_sid_string(packet, sid), netlogon->req.logon.nt_version, nt_errstr(status)));
return;
}
- /* setup a GETDC reply */
- ZERO_STRUCT(reply);
- reply.command = NETLOGON_RESPONSE_FROM_PDC2;
-
-#if 0
- /* newer testing shows that the reply command type is not
- changed based on whether a username is given in the
- reply. This was what was causing the w2k join to be so
- slow */
- if (netlogon->req.pdc2.user_name[0]) {
- reply.command = NETLOGON_RESPONSE_FROM_PDC_USER;
- }
-#endif
-
- pdc = &reply.req.response2;
-
- /* TODO: accurately depict which services we are running */
- pdc->server_type =
- NBT_SERVER_PDC | NBT_SERVER_GC |
- NBT_SERVER_DS | NBT_SERVER_TIMESERV |
- NBT_SERVER_CLOSEST | NBT_SERVER_WRITABLE |
- NBT_SERVER_GOOD_TIMESERV;
-
- /* hmm, probably a better way to do this */
- if (str_list_check(services, "ldap")) {
- pdc->server_type |= NBT_SERVER_LDAP;
- }
-
- if (str_list_check(services, "kdc")) {
- pdc->server_type |= NBT_SERVER_KDC;
- }
-
- pdc->domain_uuid = samdb_result_guid(dom_res[0], "objectGUID");
- pdc->forest = samdb_result_string(ref_res[0], "dnsRoot",
- lp_realm(iface->nbtsrv->task->lp_ctx));
- pdc->dns_domain = samdb_result_string(ref_res[0], "dnsRoot",
- lp_realm(iface->nbtsrv->task->lp_ctx));
-
- /* TODO: get our full DNS name from somewhere else */
- pdc->pdc_dns_name = talloc_asprintf(packet, "%s.%s",
- strlower_talloc(packet,
- lp_netbios_name(iface->nbtsrv->task->lp_ctx)),
- pdc->dns_domain);
- pdc->domain = samdb_result_string(ref_res[0], "nETBIOSName", name->name);;
- pdc->pdc_name = lp_netbios_name(iface->nbtsrv->task->lp_ctx);
- pdc->user_name = netlogon->req.pdc2.user_name;
- /* TODO: we need to make sure these are in our DNS zone */
- pdc->server_site = "Default-First-Site-Name";
- pdc->client_site = "Default-First-Site-Name";
- pdc->unknown = 0x10; /* what is this? */
- pdc->unknown2 = 2; /* and this ... */
- pdc->pdc_ip = my_ip;
- pdc->nt_version = 13;
- pdc->lmnt_token = 0xFFFF;
- pdc->lm20_token = 0xFFFF;
+ netlogon_response.response_type = NETLOGON_SAMLOGON;
packet->data.msg.dest_name.type = 0;
dgram_mailslot_netlogon_reply(reply_iface->dgmsock,
packet,
lp_netbios_name(iface->nbtsrv->task->lp_ctx),
- netlogon->req.pdc2.mailslot_name,
- &reply);
+ netlogon->req.logon.mailslot_name,
+ &netlogon_response);
}
@@ -246,15 +187,17 @@ void nbtd_mailslot_netlogon_handler(struct dgram_mailslot_handler *dgmslot,
DEBUG(2,("netlogon request to %s from %s:%d\n",
nbt_name_string(netlogon, name), src->addr, src->port));
- status = dgram_mailslot_netlogon_parse(dgmslot, netlogon, packet, netlogon);
+ status = dgram_mailslot_netlogon_parse_request(dgmslot, netlogon, packet, netlogon);
if (!NT_STATUS_IS_OK(status)) goto failed;
switch (netlogon->command) {
- case NETLOGON_QUERY_FOR_PDC:
- nbtd_netlogon_getdc(dgmslot, iface, packet, src, netlogon);
+ case LOGON_PRIMARY_QUERY:
+ nbtd_netlogon_getdc(dgmslot, iface, packet,
+ src, netlogon);
break;
- case NETLOGON_QUERY_FOR_PDC2:
- nbtd_netlogon_getdc2(dgmslot, iface, packet, src, netlogon);
+ case LOGON_SAM_LOGON_REQUEST:
+ nbtd_netlogon_samlogon(dgmslot, iface, packet,
+ src, netlogon);
break;
default:
DEBUG(2,("unknown netlogon op %d from %s:%d\n",
diff --git a/source4/nbt_server/dgram/request.c b/source4/nbt_server/dgram/request.c
index 205a544209..277b64741d 100644
--- a/source4/nbt_server/dgram/request.c
+++ b/source4/nbt_server/dgram/request.c
@@ -35,8 +35,10 @@ static const struct {
const char *mailslot_name;
dgram_mailslot_handler_t handler;
} mailslot_handlers[] = {
+ /* Handle both NTLOGON and NETLOGON in the same function, as
+ * they are very similar */
{ NBT_MAILSLOT_NETLOGON, nbtd_mailslot_netlogon_handler },
- { NBT_MAILSLOT_NTLOGON, nbtd_mailslot_ntlogon_handler },
+ { NBT_MAILSLOT_NTLOGON, nbtd_mailslot_netlogon_handler },
{ NBT_MAILSLOT_BROWSE, nbtd_mailslot_browse_handler }
};
diff --git a/source4/nbt_server/irpc.c b/source4/nbt_server/irpc.c
index 8f2f7fc2c2..8f1f74afcf 100644
--- a/source4/nbt_server/irpc.c
+++ b/source4/nbt_server/irpc.c
@@ -49,7 +49,7 @@ static NTSTATUS nbtd_information(struct irpc_message *msg,
/*
- winbind needs to be able to do a getdc request, but some windows
+ winbind needs to be able to do a getdc request, but most (all?) windows
servers always send the reply to port 138, regardless of the request
port. To cope with this we use a irpc request to the NBT server
which has port 138 open, and thus can receive the replies
@@ -59,57 +59,49 @@ struct getdc_state {
struct nbtd_getdcname *req;
};
-static void getdc_recv_ntlogon_reply(struct dgram_mailslot_handler *dgmslot,
- struct nbt_dgram_packet *packet,
- struct socket_address *src)
+static void getdc_recv_netlogon_reply(struct dgram_mailslot_handler *dgmslot,
+ struct nbt_dgram_packet *packet,
+ struct socket_address *src)
{
struct getdc_state *s =
talloc_get_type(dgmslot->private, struct getdc_state);
-
- struct nbt_ntlogon_packet ntlogon;
+ const char *p;
+ struct nbt_netlogon_response netlogon;
NTSTATUS status;
- status = dgram_mailslot_ntlogon_parse(dgmslot, packet, packet,
- &ntlogon);
+ status = dgram_mailslot_netlogon_parse_response(dgmslot, packet, packet,
+ &netlogon);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(5, ("dgram_mailslot_ntlogon_parse failed: %s\n",
nt_errstr(status)));
goto done;
}
- status = NT_STATUS_NO_LOGON_SERVERS;
+ /* We asked for version 1 only */
+ if (netlogon.response_type == NETLOGON_SAMLOGON
+ && netlogon.samlogon.ntver != NETLOGON_NT_VERSION_1) {
+ status = NT_STATUS_INVALID_NETWORK_RESPONSE;
+ goto done;
+ }
- DEBUG(10, ("reply: command=%d\n", ntlogon.command));
+ p = netlogon.samlogon.nt4.server;
- switch (ntlogon.command) {
- case NTLOGON_SAM_LOGON:
- DEBUG(0, ("Huh -- got NTLOGON_SAM_LOGON as reply\n"));
- break;
- case NTLOGON_SAM_LOGON_REPLY:
- case NTLOGON_SAM_LOGON_REPLY15: {
- const char *p = ntlogon.req.reply.server;
-
- DEBUG(10, ("NTLOGON_SAM_LOGON_REPLY: server: %s, user: %s, "
- "domain: %s\n", p, ntlogon.req.reply.user_name,
- ntlogon.req.reply.domain));
-
- if (*p == '\\') p += 1;
- if (*p == '\\') p += 1;
-
- s->req->out.dcname = talloc_strdup(s->req, p);
- if (s->req->out.dcname == NULL) {
- DEBUG(0, ("talloc failed\n"));
- status = NT_STATUS_NO_MEMORY;
- goto done;
- }
- status = NT_STATUS_OK;
- break;
- }
- default:
- DEBUG(0, ("Got unknown packet: %d\n", ntlogon.command));
- break;
+ DEBUG(10, ("NTLOGON_SAM_LOGON_REPLY: server: %s, user: %s, "
+ "domain: %s\n", p, netlogon.samlogon.nt4.user_name,
+ netlogon.samlogon.nt4.domain));
+
+ if (*p == '\\') p += 1;
+ if (*p == '\\') p += 1;
+
+ s->req->out.dcname = talloc_strdup(s->req, p);
+ if (s->req->out.dcname == NULL) {
+ DEBUG(0, ("talloc failed\n"));
+ status = NT_STATUS_NO_MEMORY;
+ goto done;
}
+ status = NT_STATUS_OK;
+
done:
irpc_send_reply(s->msg, status);
}
@@ -121,8 +113,8 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg,
talloc_get_type(msg->private, struct nbtd_server);
struct nbtd_interface *iface = nbtd_find_request_iface(server, req->in.ip_address, true);
struct getdc_state *s;
- struct nbt_ntlogon_packet p;
- struct nbt_ntlogon_sam_logon *r;
+ struct nbt_netlogon_packet p;
+ struct NETLOGON_SAM_LOGON_REQUEST *r;
struct nbt_name src, dst;
struct socket_address *dest;
struct dgram_mailslot_handler *handler;
@@ -137,11 +129,11 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg,
s->req = req;
handler = dgram_mailslot_temp(iface->dgmsock, NBT_MAILSLOT_GETDC,
- getdc_recv_ntlogon_reply, s);
+ getdc_recv_netlogon_reply, s);
NT_STATUS_HAVE_NO_MEMORY(handler);
ZERO_STRUCT(p);
- p.command = NTLOGON_SAM_LOGON;
+ p.command = LOGON_SAM_LOGON_REQUEST;
r = &p.req.logon;
r->request_count = 0;
r->computer_name = req->in.my_computername;
@@ -149,7 +141,7 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg,
r->mailslot_name = handler->mailslot_name;
r->acct_control = req->in.account_control;
r->sid = *req->in.domain_sid;
- r->nt_version = 1;
+ r->nt_version = NETLOGON_NT_VERSION_1;
r->lmnt_token = 0xffff;
r->lm20_token = 0xffff;
@@ -160,9 +152,10 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg,
req->in.ip_address, 138);
NT_STATUS_HAVE_NO_MEMORY(dest);
- status = dgram_mailslot_ntlogon_send(iface->dgmsock, DGRAM_DIRECT_GROUP,
- &dst, dest,
- &src, &p);
+ status = dgram_mailslot_netlogon_send(iface->dgmsock,
+ &dst, dest,
+ NBT_MAILSLOT_NETLOGON,
+ &src, &p);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("dgram_mailslot_ntlogon_send failed: %s\n",
nt_errstr(status)));
diff --git a/source4/nbt_server/nbt_server.c b/source4/nbt_server/nbt_server.c
index 2ac1fb4ef3..832bbe0103 100644
--- a/source4/nbt_server/nbt_server.c
+++ b/source4/nbt_server/nbt_server.c
@@ -66,7 +66,7 @@ static void nbtd_task_init(struct task_server *task)
return;
}
- nbtsrv->sam_ctx = samdb_connect(nbtsrv, task->lp_ctx, anonymous_session(nbtsrv, task->lp_ctx));
+ nbtsrv->sam_ctx = samdb_connect(nbtsrv, task->event_ctx, task->lp_ctx, anonymous_session(nbtsrv, task->event_ctx, task->lp_ctx));
if (nbtsrv->sam_ctx == NULL) {
task_server_terminate(task, "nbtd failed to open samdb");
return;
diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c
index 7de5bba468..c84b01f2b2 100644
--- a/source4/nbt_server/wins/winsdb.c
+++ b/source4/nbt_server/wins/winsdb.c
@@ -945,7 +945,8 @@ failed:
return NBT_RCODE_SVR;
}
-static bool winsdb_check_or_add_module_list(struct loadparm_context *lp_ctx, struct winsdb_handle *h)
+static bool winsdb_check_or_add_module_list(struct event_context *ev_ctx,
+ struct loadparm_context *lp_ctx, struct winsdb_handle *h)
{
int trans;
int ret;
@@ -992,7 +993,7 @@ static bool winsdb_check_or_add_module_list(struct loadparm_context *lp_ctx, str
flags |= LDB_FLG_NOSYNC;
}
- h->ldb = ldb_wrap_connect(h, lp_ctx, lock_path(h, lp_ctx, lp_wins_url(lp_ctx)),
+ h->ldb = ldb_wrap_connect(h, ev_ctx, lp_ctx, lock_path(h, lp_ctx, lp_wins_url(lp_ctx)),
NULL, NULL, flags, NULL);
if (!h->ldb) goto failed;
@@ -1010,7 +1011,9 @@ failed:
return false;
}
-struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
+struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx,
+ struct event_context *ev_ctx,
+ struct loadparm_context *lp_ctx,
const char *owner,
enum winsdb_handle_caller caller)
{
@@ -1026,7 +1029,7 @@ struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx, struct loadparm_contex
flags |= LDB_FLG_NOSYNC;
}
- h->ldb = ldb_wrap_connect(h, lp_ctx, lock_path(h, lp_ctx, lp_wins_url(lp_ctx)),
+ h->ldb = ldb_wrap_connect(h, ev_ctx, lp_ctx, lock_path(h, lp_ctx, lp_wins_url(lp_ctx)),
NULL, NULL, flags, NULL);
if (!h->ldb) goto failed;
@@ -1037,7 +1040,7 @@ struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx, struct loadparm_contex
if (!h->local_owner) goto failed;
/* make sure the module list is available and used */
- ret = winsdb_check_or_add_module_list(lp_ctx, h);
+ ret = winsdb_check_or_add_module_list(ev_ctx, lp_ctx, h);
if (!ret) goto failed;
ldb_err = ldb_set_opaque(h->ldb, "winsdb_handle", h);
diff --git a/source4/nbt_server/wins/winsserver.c b/source4/nbt_server/wins/winsserver.c
index f116c45898..f8901ce09d 100644
--- a/source4/nbt_server/wins/winsserver.c
+++ b/source4/nbt_server/wins/winsserver.c
@@ -985,7 +985,8 @@ NTSTATUS nbtd_winsserver_init(struct nbtd_server *nbtsrv)
owner = iface_n_ip(ifaces, 0);
}
- nbtsrv->winssrv->wins_db = winsdb_connect(nbtsrv->winssrv, nbtsrv->task->lp_ctx,
+ nbtsrv->winssrv->wins_db = winsdb_connect(nbtsrv->winssrv, nbtsrv->task->event_ctx,
+ nbtsrv->task->lp_ctx,
owner, WINSDB_HANDLE_CALLER_NBTD);
if (!nbtsrv->winssrv->wins_db) {
return NT_STATUS_INTERNAL_DB_ERROR;
diff --git a/source4/nsswitch/config.m4 b/source4/nsswitch/config.m4
index a3b7412841..207b7fa53f 100644
--- a/source4/nsswitch/config.m4
+++ b/source4/nsswitch/config.m4
@@ -4,8 +4,7 @@ case "$host_os" in
*linux*)
SMB_LIBRARY(nss_winbind,
[nsswitch/winbind_nss_linux.o],
- [LIBWINBIND-CLIENT],
- [2],[2])
+ [LIBWINBIND-CLIENT])
;;
*)
;;
diff --git a/source4/nsswitch/config.mk b/source4/nsswitch/config.mk
index c7c70c141e..e8b9600882 100644
--- a/source4/nsswitch/config.mk
+++ b/source4/nsswitch/config.mk
@@ -1,13 +1,12 @@
[SUBSYSTEM::LIBWINBIND-CLIENT]
-OBJ_FILES = wb_common.o
PRIVATE_DEPENDENCIES = SOCKET_WRAPPER
+LIBWINBIND-CLIENT_OBJ_FILES = $(nsswitchsrcdir)/wb_common.o
+
#################################
# Start BINARY nsstest
[BINARY::nsstest]
INSTALLDIR = BINDIR
-OBJ_FILES = \
- nsstest.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-UTIL \
LIBREPLACE_EXT \
@@ -15,12 +14,12 @@ PRIVATE_DEPENDENCIES = \
# End BINARY nsstest
#################################
+nsstest_OBJ_FILES = $(nsswitchsrcdir)/nsstest.o
+
#################################
# Start BINARY wbinfo
[BINARY::wbinfo]
INSTALLDIR = BINDIR
-OBJ_FILES = \
- wbinfo.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-UTIL \
LIBREPLACE_EXT \
@@ -30,3 +29,6 @@ PRIVATE_DEPENDENCIES = \
LIBWINBIND-CLIENT
# End BINARY nsstest
#################################
+
+wbinfo_OBJ_FILES = \
+ $(nsswitchsrcdir)/wbinfo.o
diff --git a/source4/ntptr/config.mk b/source4/ntptr/config.mk
index 4c1f46ff17..71b3bc05a8 100644
--- a/source4/ntptr/config.mk
+++ b/source4/ntptr/config.mk
@@ -5,21 +5,23 @@
[MODULE::ntptr_simple_ldb]
INIT_FUNCTION = ntptr_simple_ldb_init
SUBSYSTEM = ntptr
-OBJ_FILES = \
- simple_ldb/ntptr_simple_ldb.o
PRIVATE_DEPENDENCIES = \
LIBLDB NDR_SPOOLSS DCERPC_COMMON
# End MODULE ntptr_simple_ldb
################################################
+ntptr_simple_ldb_OBJ_FILES = $(ntptrsrcdir)/simple_ldb/ntptr_simple_ldb.o
+
################################################
# Start SUBSYSTEM ntptr
[SUBSYSTEM::ntptr]
-PRIVATE_PROTO_HEADER = ntptr_proto.h
-OBJ_FILES = \
- ntptr_base.o \
- ntptr_interface.o
PUBLIC_DEPENDENCIES = DCERPC_COMMON
#
# End SUBSYSTEM ntptr
################################################
+
+ntptr_OBJ_FILES = \
+ $(ntptrsrcdir)/ntptr_base.o \
+ $(ntptrsrcdir)/ntptr_interface.o
+
+$(eval $(call proto_header_template,$(ntptrsrcdir)/ntptr_proto.h,$(ntptr_OBJ_FILES:.o=.c)))
diff --git a/source4/ntptr/ntptr.h b/source4/ntptr/ntptr.h
index 3e95c3c5e1..7138a2fdfb 100644
--- a/source4/ntptr/ntptr.h
+++ b/source4/ntptr/ntptr.h
@@ -220,6 +220,7 @@ struct ntptr_ops {
struct ntptr_context {
const struct ntptr_ops *ops;
void *private_data;
+ struct event_context *ev_ctx;
struct loadparm_context *lp_ctx;
};
diff --git a/source4/ntptr/ntptr_base.c b/source4/ntptr/ntptr_base.c
index 26e192d64b..a7004be90b 100644
--- a/source4/ntptr/ntptr_base.c
+++ b/source4/ntptr/ntptr_base.c
@@ -24,7 +24,6 @@
#include "includes.h"
#include "ntptr/ntptr.h"
-#include "build.h"
#include "param/param.h"
/* the list of currently registered NTPTR backends */
@@ -71,6 +70,7 @@ NTSTATUS ntptr_register(const void *_ops)
NTSTATUS ntptr_init(struct loadparm_context *lp_ctx)
{
+ extern NTSTATUS ntptr_simple_ldb_init(void);
init_module_fn static_init[] = { STATIC_ntptr_MODULES };
init_module_fn *shared_init = load_samba_modules(NULL, lp_ctx, "ntptr");
@@ -119,7 +119,8 @@ const struct ntptr_critical_sizes *ntptr_interface_version(void)
/*
create a ntptr_context with a specified NTPTR backend
*/
-NTSTATUS ntptr_init_context(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
+NTSTATUS ntptr_init_context(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx,
+ struct loadparm_context *lp_ctx,
const char *providor, struct ntptr_context **_ntptr)
{
NTSTATUS status;
@@ -133,6 +134,7 @@ NTSTATUS ntptr_init_context(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx
NT_STATUS_HAVE_NO_MEMORY(ntptr);
ntptr->private_data = NULL;
ntptr->ops = ntptr_backend_byname(providor);
+ ntptr->ev_ctx = ev_ctx;
ntptr->lp_ctx = lp_ctx;
if (!ntptr->ops) {
diff --git a/source4/ntptr/simple_ldb/ntptr_simple_ldb.c b/source4/ntptr/simple_ldb/ntptr_simple_ldb.c
index 47f3c0ddf0..3573fac3ea 100644
--- a/source4/ntptr/simple_ldb/ntptr_simple_ldb.c
+++ b/source4/ntptr/simple_ldb/ntptr_simple_ldb.c
@@ -42,9 +42,9 @@
connect to the SPOOLSS database
return a ldb_context pointer on success, or NULL on failure
*/
-static struct ldb_context *sptr_db_connect(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
+static struct ldb_context *sptr_db_connect(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx, struct loadparm_context *lp_ctx)
{
- return ldb_wrap_connect(mem_ctx, lp_ctx, lp_spoolss_url(lp_ctx), system_session(mem_ctx, lp_ctx),
+ return ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx, lp_spoolss_url(lp_ctx), system_session(mem_ctx, lp_ctx),
NULL, 0, NULL);
}
@@ -87,7 +87,7 @@ static int sptr_db_search(struct ldb_context *ldb,
static NTSTATUS sptr_init_context(struct ntptr_context *ntptr)
{
- struct ldb_context *sptr_db = sptr_db_connect(ntptr, ntptr->lp_ctx);
+ struct ldb_context *sptr_db = sptr_db_connect(ntptr, ntptr->ev_ctx, ntptr->lp_ctx);
NT_STATUS_HAVE_NO_MEMORY(sptr_db);
ntptr->private_data = sptr_db;
diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c
index 2feb1a0efe..2b61268733 100644
--- a/source4/ntvfs/cifs/vfs_cifs.c
+++ b/source4/ntvfs/cifs/vfs_cifs.c
@@ -171,7 +171,6 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs,
if (!credentials) {
return NT_STATUS_NO_MEMORY;
}
- cli_credentials_set_event_context(credentials, ntvfs->ctx->event_ctx);
cli_credentials_set_conf(credentials, ntvfs->ctx->lp_ctx);
cli_credentials_set_username(credentials, user, CRED_SPECIFIED);
if (domain) {
@@ -181,7 +180,6 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs,
} else if (machine_account) {
DEBUG(5, ("CIFS backend: Using machine account\n"));
credentials = cli_credentials_init(private);
- cli_credentials_set_event_context(credentials, ntvfs->ctx->event_ctx);
cli_credentials_set_conf(credentials, ntvfs->ctx->lp_ctx);
if (domain) {
cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED);
diff --git a/source4/ntvfs/common/config.mk b/source4/ntvfs/common/config.mk
index 3963ebcdee..1fe093bb69 100644
--- a/source4/ntvfs/common/config.mk
+++ b/source4/ntvfs/common/config.mk
@@ -1,18 +1,12 @@
################################################
# Start LIBRARY ntvfs_common
[SUBSYSTEM::ntvfs_common]
-PRIVATE_PROTO_HEADER = proto.h
-OBJ_FILES = \
- init.o \
- brlock.o \
- brlock_tdb.o \
- opendb.o \
- opendb_tdb.o \
- notify.o
-PUBLIC_DEPENDENCIES = \
- NDR_OPENDB NDR_NOTIFY \
- sys_notify sys_lease \
- share LIBDBWRAP
+PUBLIC_DEPENDENCIES = NDR_OPENDB NDR_NOTIFY sys_notify sys_lease share LIBDBWRAP
PRIVATE_DEPENDENCIES = brlock_ctdb opendb_ctdb
# End LIBRARY ntvfs_common
################################################
+
+ntvfs_common_OBJ_FILES = $(addprefix $(ntvfssrcdir)/common/, init.o brlock.o brlock_tdb.o opendb.o opendb_tdb.o notify.o)
+
+$(eval $(call proto_header_template,$(ntvfssrcdir)/common/proto.h,$(ntvfs_common_OBJ_FILES:.o=.c)))
+
diff --git a/source4/ntvfs/common/notify.c b/source4/ntvfs/common/notify.c
index 23aa3fb668..9055d6ece3 100644
--- a/source4/ntvfs/common/notify.c
+++ b/source4/ntvfs/common/notify.c
@@ -93,6 +93,10 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
return NULL;
}
+ if (ev == NULL) {
+ return NULL;
+ }
+
notify = talloc(mem_ctx, struct notify_context);
if (notify == NULL) {
return NULL;
diff --git a/source4/ntvfs/config.mk b/source4/ntvfs/config.mk
index 2f57c787ef..bf34c4082a 100644
--- a/source4/ntvfs/config.mk
+++ b/source4/ntvfs/config.mk
@@ -9,85 +9,95 @@ mkinclude sysdep/config.mk
[MODULE::ntvfs_cifs]
INIT_FUNCTION = ntvfs_cifs_init
SUBSYSTEM = ntvfs
-OBJ_FILES = \
- cifs/vfs_cifs.o
PRIVATE_DEPENDENCIES = \
LIBCLI_SMB LIBCLI_RAW
# End MODULE ntvfs_cifs
################################################
+ntvfs_cifs_OBJ_FILES = $(ntvfssrcdir)/cifs/vfs_cifs.o
+
+
+################################################
+# Start MODULE ntvfs_smb2
+[MODULE::ntvfs_smb2]
+INIT_FUNCTION = ntvfs_smb2_init
+SUBSYSTEM = ntvfs
+PRIVATE_DEPENDENCIES = \
+ LIBCLI_SMB LIBCLI_RAW
+# End MODULE ntvfs_smb2
+################################################
+
+ntvfs_smb2_OBJ_FILES = ntvfs/smb2/vfs_smb2.o
+
+
################################################
# Start MODULE ntvfs_simple
[MODULE::ntvfs_simple]
INIT_FUNCTION = ntvfs_simple_init
SUBSYSTEM = ntvfs
-PRIVATE_PROTO_HEADER = simple/proto.h
-OBJ_FILES = \
- simple/vfs_simple.o \
- simple/svfs_util.o
# End MODULE ntvfs_simple
################################################
+ntvfs_simple_OBJ_FILES = $(addprefix $(ntvfssrcdir)/simple/, vfs_simple.o svfs_util.o)
+
+$(eval $(call proto_header_template,$(ntvfssrcdir)/simple/proto.h,$(ntvfs_simple_OBJ_FILES:.o=.c)))
+
################################################
# Start MODULE ntvfs_cifsposix
[MODULE::ntvfs_cifsposix]
#ENABLE = NO
INIT_FUNCTION = ntvfs_cifs_posix_init
SUBSYSTEM = ntvfs
-PRIVATE_PROTO_HEADER = cifs_posix_cli/proto.h
-OBJ_FILES = \
- cifs_posix_cli/vfs_cifs_posix.o \
- cifs_posix_cli/svfs_util.o
# End MODULE ntvfs_cifsposix
################################################
+ntvfs_cifsposix_OBJ_FILES = \
+ $(addprefix $(ntvfssrcdir)/cifs_posix_cli/, vfs_cifs_posix.o svfs_util.o)
+
+$(eval $(call proto_header_template,$(ntvfssrcdir)/cifs_posix_cli/proto.h,$(ntvfs_cifsposix_OBJ_FILES:.o=.c)))
+
################################################
# Start MODULE ntvfs_print
[MODULE::ntvfs_print]
INIT_FUNCTION = ntvfs_print_init
SUBSYSTEM = ntvfs
-OBJ_FILES = \
- print/vfs_print.o
# End MODULE ntvfs_print
################################################
+ntvfs_print_OBJ_FILES = $(ntvfssrcdir)/print/vfs_print.o
+
################################################
# Start MODULE ntvfs_ipc
[MODULE::ntvfs_ipc]
SUBSYSTEM = ntvfs
INIT_FUNCTION = ntvfs_ipc_init
-PRIVATE_PROTO_HEADER = ipc/proto.h
-OBJ_FILES = \
- ipc/vfs_ipc.o \
- ipc/ipc_rap.o \
- ipc/rap_server.o
PRIVATE_DEPENDENCIES = dcerpc_server DCERPC_COMMON
# End MODULE ntvfs_ipc
################################################
+ntvfs_ipc_OBJ_FILES = $(addprefix $(ntvfssrcdir)/ipc/, vfs_ipc.o ipc_rap.o rap_server.o)
+
+$(eval $(call proto_header_template,$(ntvfssrcdir)/ipc/proto.h,$(ntvfs_ipc_OBJ_FILES:.o=.c)))
################################################
# Start MODULE ntvfs_nbench
[MODULE::ntvfs_nbench]
SUBSYSTEM = ntvfs
INIT_FUNCTION = ntvfs_nbench_init
-OBJ_FILES = \
- nbench/vfs_nbench.o
# End MODULE ntvfs_nbench
################################################
+ntvfs_nbench_OBJ_FILES = $(ntvfssrcdir)/nbench/vfs_nbench.o
################################################
# Start SUBSYSTEM NTVFS
[SUBSYSTEM::ntvfs]
-PRIVATE_PROTO_HEADER = ntvfs_proto.h
-OBJ_FILES = \
- ntvfs_base.o \
- ntvfs_generic.o \
- ntvfs_interface.o \
- ntvfs_util.o
-
-# PUBLIC_HEADERS += ntvfs/ntvfs.h
+
+ntvfs_OBJ_FILES = $(addprefix $(ntvfssrcdir)/, ntvfs_base.o ntvfs_generic.o ntvfs_interface.o ntvfs_util.o)
+
+$(eval $(call proto_header_template,$(ntvfssrcdir)/ntvfs_proto.h,$(ntvfs_OBJ_FILES:.o=.c)))
+
+# PUBLIC_HEADERS += $(ntvfssrcdir)/ntvfs.h
#
# End SUBSYSTEM NTVFS
################################################
diff --git a/source4/ntvfs/ipc/ipc_rap.c b/source4/ntvfs/ipc/ipc_rap.c
index faf48705c4..4969f1a791 100644
--- a/source4/ntvfs/ipc/ipc_rap.c
+++ b/source4/ntvfs/ipc/ipc_rap.c
@@ -21,6 +21,7 @@
#include "includes.h"
#include "libcli/raw/interfaces.h"
#include "libcli/rap/rap.h"
+#include "events/events.h"
#include "ntvfs/ipc/proto.h"
#include "librpc/ndr/libndr.h"
#include "param/param.h"
@@ -100,11 +101,14 @@ struct rap_call {
struct ndr_pull *ndr_pull_param;
struct ndr_pull *ndr_pull_data;
+
+ struct event_context *event_ctx;
};
#define RAPNDR_FLAGS (LIBNDR_FLAG_NOALIGN|LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
static struct rap_call *new_rap_srv_call(TALLOC_CTX *mem_ctx,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx,
struct smb_trans2 *trans)
{
@@ -118,6 +122,7 @@ static struct rap_call *new_rap_srv_call(TALLOC_CTX *mem_ctx,
ZERO_STRUCTP(call);
call->lp_ctx = talloc_reference(call, lp_ctx);
+ call->event_ctx = ev_ctx;
call->mem_ctx = mem_ctx;
@@ -271,7 +276,7 @@ static NTSTATUS _rap_netshareenum(struct rap_call *call)
break;
}
- result = rap_netshareenum(call, call->lp_ctx, &r);
+ result = rap_netshareenum(call, call->event_ctx, call->lp_ctx, &r);
if (!NT_STATUS_IS_OK(result))
return result;
@@ -430,7 +435,7 @@ static const struct
{NULL, -1, api_Unsupported}
};
-NTSTATUS ipc_rap_call(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
+NTSTATUS ipc_rap_call(TALLOC_CTX *mem_ctx, struct event_context *event_ctx, struct loadparm_context *lp_ctx,
struct smb_trans2 *trans)
{
int i;
@@ -440,7 +445,7 @@ NTSTATUS ipc_rap_call(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
struct ndr_push *final_param;
struct ndr_push *final_data;
- call = new_rap_srv_call(mem_ctx, lp_ctx, trans);
+ call = new_rap_srv_call(mem_ctx, event_ctx, lp_ctx, trans);
if (call == NULL)
return NT_STATUS_NO_MEMORY;
diff --git a/source4/ntvfs/ipc/rap_server.c b/source4/ntvfs/ipc/rap_server.c
index 633f0bf36e..d9fb7e21b2 100644
--- a/source4/ntvfs/ipc/rap_server.c
+++ b/source4/ntvfs/ipc/rap_server.c
@@ -29,6 +29,7 @@
* idea. */
NTSTATUS rap_netshareenum(TALLOC_CTX *mem_ctx,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct rap_NetShareEnum *r)
{
@@ -42,7 +43,7 @@ NTSTATUS rap_netshareenum(TALLOC_CTX *mem_ctx,
r->out.available = 0;
r->out.info = NULL;
- nterr = share_get_context_by_name(mem_ctx, lp_share_backend(lp_ctx), lp_ctx, &sctx);
+ nterr = share_get_context_by_name(mem_ctx, lp_share_backend(lp_ctx), event_ctx, lp_ctx, &sctx);
if (!NT_STATUS_IS_OK(nterr)) {
return nterr;
}
diff --git a/source4/ntvfs/ipc/vfs_ipc.c b/source4/ntvfs/ipc/vfs_ipc.c
index 92f0eadae1..ea7b54ae6a 100644
--- a/source4/ntvfs/ipc/vfs_ipc.c
+++ b/source4/ntvfs/ipc/vfs_ipc.c
@@ -805,7 +805,7 @@ static NTSTATUS ipc_trans(struct ntvfs_module_context *ntvfs,
NTSTATUS status;
if (strequal(trans->in.trans_name, "\\PIPE\\LANMAN"))
- return ipc_rap_call(req, ntvfs->ctx->lp_ctx, trans);
+ return ipc_rap_call(req, ntvfs->ctx->event_ctx, ntvfs->ctx->lp_ctx, trans);
if (trans->in.setup_count != 2) {
return NT_STATUS_INVALID_PARAMETER;
diff --git a/source4/ntvfs/ntvfs_base.c b/source4/ntvfs/ntvfs_base.c
index 51faa44372..6de13e4a0a 100644
--- a/source4/ntvfs/ntvfs_base.c
+++ b/source4/ntvfs/ntvfs_base.c
@@ -24,7 +24,6 @@
#include "includes.h"
#include "lib/util/dlinklist.h"
-#include "build.h"
#include "ntvfs/ntvfs.h"
#include "param/param.h"
@@ -204,6 +203,17 @@ NTSTATUS ntvfs_init_connection(TALLOC_CTX *mem_ctx, struct share_config *scfg, e
NTSTATUS ntvfs_init(struct loadparm_context *lp_ctx)
{
static bool initialized = false;
+ extern NTSTATUS ntvfs_posix_init(void);
+ extern NTSTATUS ntvfs_cifs_init(void);
+ extern NTSTATUS ntvfs_smb2_init(void);
+ extern NTSTATUS ntvfs_nbench_init(void);
+ extern NTSTATUS ntvfs_unixuid_init(void);
+ extern NTSTATUS ntvfs_ipc_init(void);
+ extern NTSTATUS pvfs_acl_nfs4_init(void);
+ extern NTSTATUS pvfs_acl_xattr_init(void);
+ extern NTSTATUS ntvfs_print_init(void);
+ extern NTSTATUS ntvfs_simple_init(void);
+ extern NTSTATUS ntvfs_cifs_posix_init(void);
init_module_fn static_init[] = { STATIC_ntvfs_MODULES };
init_module_fn *shared_init;
diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c
index e1a86c07c0..62a1427405 100644
--- a/source4/ntvfs/ntvfs_generic.c
+++ b/source4/ntvfs/ntvfs_generic.c
@@ -208,7 +208,21 @@ 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_level = 0;
+ switch (io2->generic.out.oplock_level) {
+ case BATCH_OPLOCK_RETURN:
+ io->smb2.out.oplock_level = SMB2_OPLOCK_LEVEL_BATCH;
+ break;
+ case EXCLUSIVE_OPLOCK_RETURN:
+ io->smb2.out.oplock_level = SMB2_OPLOCK_LEVEL_EXCLUSIVE;
+ break;
+ case LEVEL_II_OPLOCK_RETURN:
+ io->smb2.out.oplock_level = SMB2_OPLOCK_LEVEL_II;
+ break;
+ default:
+ io->smb2.out.oplock_level = SMB2_OPLOCK_LEVEL_NONE;
+ break;
+ }
+ io->smb2.out.reserved = 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;
@@ -484,7 +498,18 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs,
status = ntvfs->ops->open(ntvfs, req, io2);
break;
case RAW_OPEN_SMB2:
- io2->generic.in.flags = 0;
+ switch (io->smb2.in.oplock_level) {
+ case SMB2_OPLOCK_LEVEL_BATCH:
+ io2->generic.in.flags = NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK |
+ NTCREATEX_FLAGS_REQUEST_OPLOCK;
+ break;
+ case SMB2_OPLOCK_LEVEL_EXCLUSIVE:
+ io2->generic.in.flags = NTCREATEX_FLAGS_REQUEST_OPLOCK;
+ break;
+ default:
+ io2->generic.in.flags = 0;
+ break;
+ }
io2->generic.in.root_fid = 0;
io2->generic.in.access_mask = io->smb2.in.desired_access;
io2->generic.in.alloc_size = 0;
@@ -986,37 +1011,72 @@ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs,
locks->count = lck->unlock.in.count;
break;
- case RAW_LOCK_SMB2:
- if (lck->smb2.in.unknown1 != 1) {
+ case RAW_LOCK_SMB2: {
+ /* this is only approximate! We need to change the
+ generic structure to fix this properly */
+ int i;
+ if (lck->smb2.in.lock_count < 1) {
return NT_STATUS_INVALID_PARAMETER;
}
lck2->generic.level = RAW_LOCK_GENERIC;
lck2->generic.in.file.ntvfs= lck->smb2.in.file.ntvfs;
- if (lck->smb2.in.flags & SMB2_LOCK_FLAG_EXCLUSIV) {
- lck2->generic.in.mode = 0;
- } else {
- lck2->generic.in.mode = LOCKING_ANDX_SHARED_LOCK;
+ lck2->generic.in.timeout = UINT32_MAX;
+ lck2->generic.in.mode = 0;
+ lck2->generic.in.lock_cnt = 0;
+ lck2->generic.in.ulock_cnt = 0;
+ lck2->generic.in.locks = talloc_zero_array(lck2, struct smb_lock_entry,
+ lck->smb2.in.lock_count);
+ if (lck2->generic.in.locks == NULL) {
+ return NT_STATUS_NO_MEMORY;
}
- if (lck->smb2.in.flags & SMB2_LOCK_FLAG_NO_PENDING) {
- lck2->generic.in.timeout = 0;
- } else {
- lck2->generic.in.timeout = UINT32_MAX;
+ for (i=0;i<lck->smb2.in.lock_count;i++) {
+ if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK) {
+ int j = lck2->generic.in.ulock_cnt;
+ lck2->generic.in.ulock_cnt++;
+ lck2->generic.in.locks[j].pid = 0;
+ lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset;
+ lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length;
+ lck2->generic.in.locks[j].pid = 0;
+ }
}
- if (lck->smb2.in.flags & SMB2_LOCK_FLAG_UNLOCK) {
- lck2->generic.in.ulock_cnt = 1;
- lck2->generic.in.lock_cnt = 0;
- } else {
- lck2->generic.in.ulock_cnt = 0;
- lck2->generic.in.lock_cnt = 1;
+ for (i=0;i<lck->smb2.in.lock_count;i++) {
+ if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_UNLOCK)) {
+ int j = lck2->generic.in.ulock_cnt +
+ lck2->generic.in.lock_cnt;
+ lck2->generic.in.lock_cnt++;
+ lck2->generic.in.locks[j].pid = 0;
+ lck2->generic.in.locks[j].offset = lck->smb2.in.locks[i].offset;
+ lck2->generic.in.locks[j].count = lck->smb2.in.locks[i].length;
+ lck2->generic.in.locks[j].pid = 0;
+ if (!(lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_EXCLUSIVE)) {
+ lck2->generic.in.mode = LOCKING_ANDX_SHARED_LOCK;
+ }
+ if (lck->smb2.in.locks[i].flags & SMB2_LOCK_FLAG_FAIL_IMMEDIATELY) {
+ lck2->generic.in.timeout = 0;
+ }
+ }
}
- lck2->generic.in.locks = locks;
- locks->pid = 0;
- locks->offset = lck->smb2.in.offset;
- locks->count = lck->smb2.in.count;
+ /* initialize output value */
+ lck->smb2.out.reserved = 0;
+ break;
+ }
+
+ case RAW_LOCK_SMB2_BREAK:
+ lck2->generic.level = RAW_LOCK_GENERIC;
+ lck2->generic.in.file.ntvfs = lck->smb2_break.in.file.ntvfs;
+ lck2->generic.in.mode = LOCKING_ANDX_OPLOCK_RELEASE |
+ ((lck->smb2_break.in.oplock_level << 8) & 0xFF00);
+ lck2->generic.in.timeout = 0;
+ lck2->generic.in.ulock_cnt = 0;
+ lck2->generic.in.lock_cnt = 0;
+ lck2->generic.in.locks = NULL;
/* initialize output value */
- lck->smb2.out.unknown1 = 0;
+ lck->smb2_break.out.oplock_level= lck->smb2_break.in.oplock_level;
+ lck->smb2_break.out.reserved = lck->smb2_break.in.reserved;
+ lck->smb2_break.out.reserved2 = lck->smb2_break.in.reserved2;
+ lck->smb2_break.out.file = lck->smb2_break.in.file;
break;
}
@@ -1214,7 +1274,13 @@ static NTSTATUS ntvfs_map_read_finish(struct ntvfs_module_context *ntvfs,
break;
case RAW_READ_SMB2:
rd->smb2.out.data.length= rd2->generic.out.nread;
- rd->smb2.out.unknown1 = 0;
+ rd->smb2.out.remaining = 0;
+ rd->smb2.out.reserved = 0;
+ if (NT_STATUS_IS_OK(status) &&
+ rd->smb2.out.data.length == 0 &&
+ rd->smb2.in.length != 0) {
+ status = NT_STATUS_END_OF_FILE;
+ }
break;
default:
return NT_STATUS_INVALID_LEVEL;
diff --git a/source4/ntvfs/posix/config.mk b/source4/ntvfs/posix/config.mk
index 88048c2af7..0ee3e3be16 100644
--- a/source4/ntvfs/posix/config.mk
+++ b/source4/ntvfs/posix/config.mk
@@ -3,38 +3,44 @@
[MODULE::pvfs_acl_xattr]
INIT_FUNCTION = pvfs_acl_xattr_init
SUBSYSTEM = ntvfs
-OBJ_FILES = \
- pvfs_acl_xattr.o
PRIVATE_DEPENDENCIES = NDR_XATTR ntvfs_posix
# End MODULE pvfs_acl_xattr
################################################
+pvfs_acl_xattr_OBJ_FILES = $(ntvfssrcdir)/posix/pvfs_acl_xattr.o
+
################################################
# Start MODULE pvfs_acl_nfs4
[MODULE::pvfs_acl_nfs4]
INIT_FUNCTION = pvfs_acl_nfs4_init
SUBSYSTEM = ntvfs
-OBJ_FILES = \
- pvfs_acl_nfs4.o
PRIVATE_DEPENDENCIES = NDR_NFS4ACL SAMDB ntvfs_posix
# End MODULE pvfs_acl_nfs4
################################################
+pvfs_acl_nfs4_OBJ_FILES = $(ntvfssrcdir)/posix/pvfs_acl_nfs4.o
+
################################################
[MODULE::pvfs_aio]
SUBSYSTEM = ntvfs
-OBJ_FILES = pvfs_aio.o
PRIVATE_DEPENDENCIES = LIBAIO_LINUX
################################################
+pvfs_aio_OBJ_FILES = $(ntvfssrcdir)/posix/pvfs_aio.o
+
################################################
# Start MODULE ntvfs_posix
[MODULE::ntvfs_posix]
SUBSYSTEM = ntvfs
OUTPUT_TYPE = MERGED_OBJ
INIT_FUNCTION = ntvfs_posix_init
-PRIVATE_PROTO_HEADER = vfs_posix_proto.h
-OBJ_FILES = \
+#PRIVATE_DEPENDENCIES = pvfs_acl_xattr pvfs_acl_nfs4
+PRIVATE_DEPENDENCIES = NDR_XATTR WRAP_XATTR BLKID ntvfs_common MESSAGING pvfs_aio \
+ LIBWBCLIENT
+# End MODULE ntvfs_posix
+################################################
+
+ntvfs_posix_OBJ_FILES = $(addprefix $(ntvfssrcdir)/posix/, \
vfs_posix.o \
pvfs_util.o \
pvfs_search.o \
@@ -62,8 +68,7 @@ OBJ_FILES = \
pvfs_acl.o \
pvfs_notify.o \
xattr_system.o \
- xattr_tdb.o
-#PRIVATE_DEPENDENCIES = pvfs_acl_xattr pvfs_acl_nfs4
-PRIVATE_DEPENDENCIES = NDR_XATTR WRAP_XATTR BLKID ntvfs_common MESSAGING pvfs_aio
-# End MODULE ntvfs_posix
-################################################
+ xattr_tdb.o)
+
+$(eval $(call proto_header_template,$(ntvfssrcdir)/posix/vfs_posix_proto.h,$(ntvfs_posix_OBJ_FILES:.o=.c)))
+
diff --git a/source4/ntvfs/posix/pvfs_acl.c b/source4/ntvfs/posix/pvfs_acl.c
index 2393a2e7a3..f1e469f790 100644
--- a/source4/ntvfs/posix/pvfs_acl.c
+++ b/source4/ntvfs/posix/pvfs_acl.c
@@ -135,7 +135,7 @@ static NTSTATUS pvfs_default_acl(struct pvfs_state *pvfs,
}
sd = *psd;
- ids = talloc_array(sd, struct id_mapping, 2);
+ ids = talloc_zero_array(sd, struct id_mapping, 2);
NT_STATUS_HAVE_NO_MEMORY(ids);
ids[0].unixid = talloc(ids, struct unixid);
diff --git a/source4/ntvfs/posix/pvfs_fileinfo.c b/source4/ntvfs/posix/pvfs_fileinfo.c
index 4c383ed45d..04f6ad78d0 100644
--- a/source4/ntvfs/posix/pvfs_fileinfo.c
+++ b/source4/ntvfs/posix/pvfs_fileinfo.c
@@ -58,6 +58,8 @@ NTSTATUS pvfs_fill_dos_info(struct pvfs_state *pvfs, struct pvfs_filename *name,
if (S_ISDIR(name->st.st_mode)) {
name->st.st_size = 0;
name->st.st_nlink = 1;
+ } else if (name->stream_id == 0) {
+ name->stream_name = NULL;
}
/* for now just use the simple samba mapping */
@@ -75,6 +77,11 @@ NTSTATUS pvfs_fill_dos_info(struct pvfs_state *pvfs, struct pvfs_filename *name,
name->dos.alloc_size = pvfs_round_alloc_size(pvfs, name->st.st_size);
name->dos.nlink = name->st.st_nlink;
name->dos.ea_size = 4;
+ if (pvfs->ntvfs->ctx->protocol == PROTOCOL_SMB2) {
+ /* SMB2 represents a null EA with zero bytes */
+ name->dos.ea_size = 0;
+ }
+
name->dos.file_id = (((uint64_t)name->st.st_dev)<<32) | name->st.st_ino;
name->dos.flags = 0;
diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c
index 6e77cb7c75..926c99d37e 100644
--- a/source4/ntvfs/posix/pvfs_open.c
+++ b/source4/ntvfs/posix/pvfs_open.c
@@ -182,12 +182,19 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
bool del_on_close;
uint32_t create_options;
uint32_t share_access;
+ bool forced;
create_options = io->generic.in.create_options;
share_access = io->generic.in.share_access;
+ forced = (io->generic.in.create_options & NTCREATEX_OPTIONS_DIRECTORY)?true:false;
+
if (name->stream_name) {
- return NT_STATUS_NOT_A_DIRECTORY;
+ if (forced) {
+ return NT_STATUS_NOT_A_DIRECTORY;
+ } else {
+ return NT_STATUS_FILE_IS_A_DIRECTORY;
+ }
}
/* if the client says it must be a directory, and it isn't,
@@ -262,7 +269,6 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
f->handle->position = 0;
f->handle->mode = 0;
f->handle->oplock = NULL;
- f->handle->sticky_write_time = false;
f->handle->open_completed = false;
if ((create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) &&
@@ -416,16 +422,6 @@ cleanup_delete:
*/
static int pvfs_handle_destructor(struct pvfs_file_handle *h)
{
- /* the write time is no longer sticky */
- if (h->sticky_write_time) {
- NTSTATUS status;
- status = pvfs_dosattrib_load(h->pvfs, h->name, h->fd);
- if (NT_STATUS_IS_OK(status)) {
- h->name->dos.flags &= ~XATTR_ATTRIB_FLAG_STICKY_WRITE_TIME;
- pvfs_dosattrib_save(h->pvfs, h->name, h->fd);
- }
- }
-
if ((h->create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) &&
h->name->stream_name) {
NTSTATUS status;
@@ -559,6 +555,10 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
uint32_t oplock_level = OPLOCK_NONE, oplock_granted;
bool allow_level_II_oplock = false;
+ if (io->ntcreatex.in.file_attr & ~FILE_ATTRIBUTE_ALL_MASK) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
if ((io->ntcreatex.in.file_attr & FILE_ATTRIBUTE_READONLY) &&
(create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE)) {
return NT_STATUS_CANNOT_DELETE;
@@ -707,7 +707,6 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
f->handle->mode = 0;
f->handle->oplock = NULL;
f->handle->have_opendb_entry = true;
- f->handle->sticky_write_time = false;
f->handle->open_completed = false;
status = odb_open_file(lck, f->handle, name->full_name,
@@ -1129,6 +1128,20 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
return status;
}
+ /* if the client specified that it must not be a directory then
+ check that it isn't */
+ if (name->exists && (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) &&
+ (io->generic.in.create_options & NTCREATEX_OPTIONS_NON_DIRECTORY_FILE)) {
+ return NT_STATUS_FILE_IS_A_DIRECTORY;
+ }
+
+ /* if the client specified that it must be a directory then
+ check that it is */
+ if (name->exists && !(name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) &&
+ (io->generic.in.create_options & NTCREATEX_OPTIONS_DIRECTORY)) {
+ return NT_STATUS_NOT_A_DIRECTORY;
+ }
+
/* directory opens are handled separately */
if ((name->exists && (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY)) ||
(io->generic.in.create_options & NTCREATEX_OPTIONS_DIRECTORY)) {
@@ -1257,7 +1270,6 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
f->handle->mode = 0;
f->handle->oplock = NULL;
f->handle->have_opendb_entry = false;
- f->handle->sticky_write_time = false;
f->handle->open_completed = false;
/* form the lock context used for byte range locking and
@@ -1479,10 +1491,6 @@ NTSTATUS pvfs_close(struct ntvfs_module_context *ntvfs,
unix_times.actime = 0;
unix_times.modtime = io->close.in.write_time;
utime(f->handle->name->full_name, &unix_times);
- } else if (f->handle->sticky_write_time) {
- unix_times.actime = 0;
- unix_times.modtime = nt_time_to_unix(f->handle->name->dos.write_time);
- utime(f->handle->name->full_name, &unix_times);
}
talloc_free(f);
diff --git a/source4/ntvfs/posix/pvfs_qfileinfo.c b/source4/ntvfs/posix/pvfs_qfileinfo.c
index 6bc21e5e3e..6e3092b744 100644
--- a/source4/ntvfs/posix/pvfs_qfileinfo.c
+++ b/source4/ntvfs/posix/pvfs_qfileinfo.c
@@ -301,7 +301,14 @@ static NTSTATUS pvfs_map_fileinfo(struct pvfs_state *pvfs,
info->all_info2.out.access_mask = 0; /* only set by qfileinfo */
info->all_info2.out.position = 0; /* only set by qfileinfo */
info->all_info2.out.mode = 0; /* only set by qfileinfo */
- info->all_info2.out.fname.s = name->original_name;
+ /* windows wants the full path on disk for this
+ result, but I really don't want to expose that on
+ the wire, so I'll give the path with a share
+ prefix, which is a good approximation */
+ info->all_info2.out.fname.s = talloc_asprintf(req, "\\%s\\%s",
+ pvfs->share_name,
+ name->original_name);
+ NT_STATUS_HAVE_NO_MEMORY(info->all_info2.out.fname.s);
return NT_STATUS_OK;
}
diff --git a/source4/ntvfs/posix/pvfs_resolve.c b/source4/ntvfs/posix/pvfs_resolve.c
index 325bc74f8f..2e97925c49 100644
--- a/source4/ntvfs/posix/pvfs_resolve.c
+++ b/source4/ntvfs/posix/pvfs_resolve.c
@@ -202,7 +202,13 @@ static NTSTATUS parse_stream_name(struct pvfs_filename *name, const char *s)
}
*p = 0;
if (strcmp(name->stream_name, "") == 0) {
- name->stream_name = NULL;
+ /*
+ * we don't set stream_name to NULL, here
+ * as this would be wrong for directories
+ *
+ * pvfs_fill_dos_info() will set it to NULL
+ * if it's not a directory.
+ */
name->stream_id = 0;
} else {
name->stream_id = pvfs_name_hash(name->stream_name,
diff --git a/source4/ntvfs/posix/pvfs_setfileinfo.c b/source4/ntvfs/posix/pvfs_setfileinfo.c
index ad47fe90c9..0beca75ead 100644
--- a/source4/ntvfs/posix/pvfs_setfileinfo.c
+++ b/source4/ntvfs/posix/pvfs_setfileinfo.c
@@ -342,8 +342,6 @@ NTSTATUS pvfs_setfileinfo(struct ntvfs_module_context *ntvfs,
}
if (!null_nttime(info->basic_info.in.write_time)) {
newstats.dos.write_time = info->basic_info.in.write_time;
- newstats.dos.flags |= XATTR_ATTRIB_FLAG_STICKY_WRITE_TIME;
- h->sticky_write_time = true;
}
if (!null_nttime(info->basic_info.in.change_time)) {
newstats.dos.change_time = info->basic_info.in.change_time;
diff --git a/source4/ntvfs/posix/pvfs_streams.c b/source4/ntvfs/posix/pvfs_streams.c
index 7e6173ef2f..3cd9952fd5 100644
--- a/source4/ntvfs/posix/pvfs_streams.c
+++ b/source4/ntvfs/posix/pvfs_streams.c
@@ -36,6 +36,13 @@ NTSTATUS pvfs_stream_information(struct pvfs_state *pvfs,
int i;
NTSTATUS status;
+ /* directories don't have streams */
+ if (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) {
+ info->num_streams = 0;
+ info->streams = NULL;
+ return NT_STATUS_OK;
+ }
+
streams = talloc(mem_ctx, struct xattr_DosStreams);
if (streams == NULL) {
return NT_STATUS_NO_MEMORY;
diff --git a/source4/ntvfs/posix/pvfs_xattr.c b/source4/ntvfs/posix/pvfs_xattr.c
index 3043b80538..3cbbcbe92f 100644
--- a/source4/ntvfs/posix/pvfs_xattr.c
+++ b/source4/ntvfs/posix/pvfs_xattr.c
@@ -162,7 +162,7 @@ NTSTATUS pvfs_dosattrib_load(struct pvfs_state *pvfs, struct pvfs_filename *name
struct xattr_DosAttrib attrib;
TALLOC_CTX *mem_ctx = talloc_new(name);
struct xattr_DosInfo1 *info1;
- struct xattr_DosInfo2 *info2;
+ struct xattr_DosInfo2Old *info2;
if (name->stream_name != NULL) {
name->stream_exists = false;
@@ -210,7 +210,11 @@ NTSTATUS pvfs_dosattrib_load(struct pvfs_state *pvfs, struct pvfs_filename *name
break;
case 2:
- info2 = &attrib.info.info2;
+ /*
+ * Note: This is only used to parse existing values from disk
+ * We use xattr_DosInfo1 again for storing new values
+ */
+ info2 = &attrib.info.oldinfo2;
name->dos.attrib = pvfs_attrib_normalise(info2->attrib,
name->st.st_mode);
name->dos.ea_size = info2->ea_size;
@@ -225,9 +229,6 @@ NTSTATUS pvfs_dosattrib_load(struct pvfs_state *pvfs, struct pvfs_filename *name
name->dos.change_time = info2->change_time;
}
name->dos.flags = info2->flags;
- if (name->dos.flags & XATTR_ATTRIB_FLAG_STICKY_WRITE_TIME) {
- name->dos.write_time = info2->write_time;
- }
break;
default:
@@ -250,26 +251,23 @@ NTSTATUS pvfs_dosattrib_load(struct pvfs_state *pvfs, struct pvfs_filename *name
NTSTATUS pvfs_dosattrib_save(struct pvfs_state *pvfs, struct pvfs_filename *name, int fd)
{
struct xattr_DosAttrib attrib;
- struct xattr_DosInfo2 *info2;
+ struct xattr_DosInfo1 *info1;
if (!(pvfs->flags & PVFS_FLAG_XATTR_ENABLE)) {
return NT_STATUS_OK;
}
- attrib.version = 2;
- info2 = &attrib.info.info2;
+ attrib.version = 1;
+ info1 = &attrib.info.info1;
name->dos.attrib = pvfs_attrib_normalise(name->dos.attrib, name->st.st_mode);
- info2->attrib = name->dos.attrib;
- info2->ea_size = name->dos.ea_size;
- info2->size = name->st.st_size;
- info2->alloc_size = name->dos.alloc_size;
- info2->create_time = name->dos.create_time;
- info2->change_time = name->dos.change_time;
- info2->write_time = name->dos.write_time;
- info2->flags = name->dos.flags;
- info2->name = "";
+ info1->attrib = name->dos.attrib;
+ info1->ea_size = name->dos.ea_size;
+ info1->size = name->st.st_size;
+ info1->alloc_size = name->dos.alloc_size;
+ info1->create_time = name->dos.create_time;
+ info1->change_time = name->dos.change_time;
return pvfs_xattr_ndr_save(pvfs, name->full_name, fd,
XATTR_DOSATTRIB_NAME, &attrib,
diff --git a/source4/ntvfs/posix/vfs_posix.c b/source4/ntvfs/posix/vfs_posix.c
index ebc2d88e70..14b5210fd0 100644
--- a/source4/ntvfs/posix/vfs_posix.c
+++ b/source4/ntvfs/posix/vfs_posix.c
@@ -219,7 +219,7 @@ static NTSTATUS pvfs_connect(struct ntvfs_module_context *ntvfs,
pvfs->ntvfs->ctx->server_id,
pvfs->ntvfs->ctx->msg_ctx,
pvfs->ntvfs->ctx->lp_ctx,
- event_context_find(pvfs),
+ pvfs->ntvfs->ctx->event_ctx,
pvfs->ntvfs->ctx->config);
pvfs->wbc_ctx = wbc_init(pvfs,
diff --git a/source4/ntvfs/posix/vfs_posix.h b/source4/ntvfs/posix/vfs_posix.h
index 441424142f..c194698b64 100644
--- a/source4/ntvfs/posix/vfs_posix.h
+++ b/source4/ntvfs/posix/vfs_posix.h
@@ -169,9 +169,6 @@ struct pvfs_file_handle {
/* we need this hook back to our parent for lock destruction */
struct pvfs_state *pvfs;
- /* have we set a sticky write time that we should remove on close */
- bool sticky_write_time;
-
/* the open went through to completion */
bool open_completed;
};
diff --git a/source4/ntvfs/smb2/vfs_smb2.c b/source4/ntvfs/smb2/vfs_smb2.c
new file mode 100644
index 0000000000..cc09daf83f
--- /dev/null
+++ b/source4/ntvfs/smb2/vfs_smb2.c
@@ -0,0 +1,844 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ CIFS-to-SMB2 NTVFS filesystem backend
+
+ Copyright (C) Andrew Tridgell 2008
+
+ largely based on vfs_cifs.c which was
+ Copyright (C) Andrew Tridgell 2003
+ Copyright (C) James J Myers 2003 <myersjj@samba.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ this implements a CIFS->CIFS NTVFS filesystem backend.
+
+*/
+
+#include "includes.h"
+#include "libcli/raw/libcliraw.h"
+#include "libcli/raw/raw_proto.h"
+#include "libcli/composite/composite.h"
+#include "libcli/smb_composite/smb_composite.h"
+#include "auth/auth.h"
+#include "auth/credentials/credentials.h"
+#include "ntvfs/ntvfs.h"
+#include "lib/util/dlinklist.h"
+#include "param/param.h"
+#include "libcli/resolve/resolve.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+
+struct cvfs_file {
+ struct cvfs_file *prev, *next;
+ uint16_t fnum;
+ struct ntvfs_handle *h;
+};
+
+/* this is stored in ntvfs_private */
+struct cvfs_private {
+ struct smb2_tree *tree;
+ struct smb2_transport *transport;
+ struct ntvfs_module_context *ntvfs;
+ struct async_info *pending;
+ struct cvfs_file *files;
+
+ /* a handle on the root of the share */
+ /* TODO: leaving this handle open could prevent other users
+ from opening the share with exclusive access. We probably
+ need to open it on demand */
+ struct smb2_handle roothandle;
+};
+
+
+/* a structure used to pass information to an async handler */
+struct async_info {
+ struct async_info *next, *prev;
+ struct cvfs_private *cvfs;
+ struct ntvfs_request *req;
+ void *c_req;
+ struct composite_context *c_comp;
+ struct cvfs_file *f;
+ void *parms;
+};
+
+#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)
+
+#define SETUP_FILE do { \
+ struct cvfs_file *f; \
+ SETUP_FILE_HERE(f); \
+} while (0)
+
+#define SMB2_SERVER "smb2:server"
+#define SMB2_USER "smb2:user"
+#define SMB2_PASSWORD "smb2:password"
+#define SMB2_DOMAIN "smb2:domain"
+#define SMB2_SHARE "smb2:share"
+#define SMB2_USE_MACHINE_ACCT "smb2:use-machine-account"
+
+#define SMB2_USE_MACHINE_ACCT_DEFAULT false
+
+/*
+ a handler for oplock break events from the server - these need to be passed
+ along to the client
+ */
+static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *p_private)
+{
+ struct cvfs_private *private = p_private;
+ NTSTATUS status;
+ struct ntvfs_handle *h = NULL;
+ struct cvfs_file *f;
+
+ for (f=private->files; f; f=f->next) {
+ if (f->fnum != fnum) continue;
+ h = f->h;
+ break;
+ }
+
+ if (!h) {
+ DEBUG(5,("vfs_smb2: ignoring oplock break level %d for fnum %d\n", level, fnum));
+ return true;
+ }
+
+ DEBUG(5,("vfs_smb2: sending oplock break level %d for fnum %d\n", level, fnum));
+ status = ntvfs_send_oplock_break(private->ntvfs, h, level);
+ if (!NT_STATUS_IS_OK(status)) return false;
+ return true;
+}
+
+/*
+ return a handle to the root of the share
+*/
+static NTSTATUS smb2_get_roothandle(struct smb2_tree *tree, struct smb2_handle *handle)
+{
+ struct smb2_create io;
+ NTSTATUS status;
+
+ ZERO_STRUCT(io);
+ 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_WRITE|
+ NTCREATEX_SHARE_ACCESS_DELETE;
+ io.in.create_options = 0;
+ io.in.fname = NULL;
+
+ status = smb2_create(tree, tree, &io);
+ NT_STATUS_NOT_OK_RETURN(status);
+
+ *handle = io.out.file.handle;
+
+ return NT_STATUS_OK;
+}
+
+/*
+ connect to a share - used when a tree_connect operation comes in.
+*/
+static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, const char *sharename)
+{
+ NTSTATUS status;
+ struct cvfs_private *private;
+ const char *host, *user, *pass, *domain, *remote_share;
+ struct composite_context *creq;
+ struct share_config *scfg = ntvfs->ctx->config;
+ struct smb2_tree *tree;
+
+ struct cli_credentials *credentials;
+ bool machine_account;
+
+ /* Here we need to determine which server to connect to.
+ * For now we use parametric options, type cifs.
+ * Later we will use security=server and auth_server.c.
+ */
+ host = share_string_option(scfg, SMB2_SERVER, NULL);
+ user = share_string_option(scfg, SMB2_USER, NULL);
+ pass = share_string_option(scfg, SMB2_PASSWORD, NULL);
+ domain = share_string_option(scfg, SMB2_DOMAIN, NULL);
+ remote_share = share_string_option(scfg, SMB2_SHARE, NULL);
+ if (!remote_share) {
+ remote_share = sharename;
+ }
+
+ machine_account = share_bool_option(scfg, SMB2_USE_MACHINE_ACCT, SMB2_USE_MACHINE_ACCT_DEFAULT);
+
+ private = talloc_zero(ntvfs, struct cvfs_private);
+ if (!private) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ ntvfs->private_data = private;
+
+ if (!host) {
+ DEBUG(1,("CIFS backend: You must supply server\n"));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ if (user && pass) {
+ DEBUG(5, ("CIFS backend: Using specified password\n"));
+ credentials = cli_credentials_init(private);
+ if (!credentials) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ cli_credentials_set_conf(credentials, ntvfs->ctx->lp_ctx);
+ cli_credentials_set_username(credentials, user, CRED_SPECIFIED);
+ if (domain) {
+ cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED);
+ }
+ cli_credentials_set_password(credentials, pass, CRED_SPECIFIED);
+ } else if (machine_account) {
+ DEBUG(5, ("CIFS backend: Using machine account\n"));
+ credentials = cli_credentials_init(private);
+ cli_credentials_set_conf(credentials, ntvfs->ctx->lp_ctx);
+ if (domain) {
+ cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED);
+ }
+ status = cli_credentials_set_machine_account(credentials, ntvfs->ctx->lp_ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ } else if (req->session_info->credentials) {
+ DEBUG(5, ("CIFS backend: Using delegated credentials\n"));
+ credentials = req->session_info->credentials;
+ } else {
+ DEBUG(1,("CIFS backend: NO delegated credentials found: You must supply server, user and password or the client must supply delegated credentials\n"));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ creq = smb2_connect_send(private, host, remote_share,
+ lp_resolve_context(ntvfs->ctx->lp_ctx),
+ credentials,
+ ntvfs->ctx->event_ctx);
+
+ status = smb2_connect_recv(creq, private, &tree);
+ NT_STATUS_NOT_OK_RETURN(status);
+
+ status = smb2_get_roothandle(tree, &private->roothandle);
+ NT_STATUS_NOT_OK_RETURN(status);
+
+ private->tree = tree;
+ private->transport = private->tree->session->transport;
+ private->ntvfs = ntvfs;
+
+ ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS");
+ NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type);
+ ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:");
+ NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type);
+
+ /* we need to receive oplock break requests from the server */
+ /* TODO: enable oplocks
+ smbcli_oplock_handler(private->transport, oplock_handler, private);
+ */
+ return NT_STATUS_OK;
+}
+
+/*
+ disconnect from a share
+*/
+static NTSTATUS cvfs_disconnect(struct ntvfs_module_context *ntvfs)
+{
+ struct cvfs_private *private = ntvfs->private_data;
+ struct async_info *a, *an;
+
+ /* first cleanup pending requests */
+ for (a=private->pending; a; a = an) {
+ an = a->next;
+ talloc_free(a->c_req);
+ talloc_free(a);
+ }
+
+ talloc_free(private);
+ ntvfs->private_data = NULL;
+
+ return NT_STATUS_OK;
+}
+
+/*
+ destroy an async info structure
+*/
+static int async_info_destructor(struct async_info *async)
+{
+ DLIST_REMOVE(async->cvfs->pending, async);
+ return 0;
+}
+
+/*
+ a handler for simple async SMB2 replies
+ this handler can only be used for functions that don't return any
+ parameters (those that just return a status code)
+ */
+static void async_simple_smb2(struct smb2_request *c_req)
+{
+ struct async_info *async = c_req->async.private_data;
+ struct ntvfs_request *req = async->req;
+
+ smb2_request_receive(c_req);
+ req->async_states->status = smb2_request_destroy(c_req);
+ talloc_free(async);
+ req->async_states->send_fn(req);
+}
+
+/*
+ a handler for simple async composite replies
+ this handler can only be used for functions that don't return any
+ parameters (those that just return a status code)
+ */
+static void async_simple_composite(struct composite_context *c_req)
+{
+ struct async_info *async = c_req->async.private_data;
+ struct ntvfs_request *req = async->req;
+
+ req->async_states->status = composite_wait_free(c_req);
+ talloc_free(async);
+ req->async_states->send_fn(req);
+}
+
+
+/* save some typing for the simple functions */
+#define ASYNC_RECV_TAIL_F(io, async_fn, file) do { \
+ if (!c_req) return NT_STATUS_UNSUCCESSFUL; \
+ { \
+ struct async_info *async; \
+ async = talloc(req, struct async_info); \
+ if (!async) return NT_STATUS_NO_MEMORY; \
+ async->parms = io; \
+ async->req = req; \
+ async->f = file; \
+ async->cvfs = private; \
+ async->c_req = c_req; \
+ DLIST_ADD(private->pending, async); \
+ c_req->async.private_data = async; \
+ talloc_set_destructor(async, async_info_destructor); \
+ } \
+ c_req->async.fn = async_fn; \
+ req->async_states->state |= NTVFS_ASYNC_STATE_ASYNC; \
+ return NT_STATUS_OK; \
+} while (0)
+
+#define ASYNC_RECV_TAIL(io, async_fn) ASYNC_RECV_TAIL_F(io, async_fn, NULL)
+
+#define SIMPLE_ASYNC_TAIL ASYNC_RECV_TAIL(NULL, async_simple_smb2)
+#define SIMPLE_COMPOSITE_TAIL ASYNC_RECV_TAIL(NULL, async_simple_composite)
+
+#define CHECK_ASYNC(req) do { \
+ if (!(req->async_states->state & NTVFS_ASYNC_STATE_MAY_ASYNC)) { \
+ DEBUG(0,("SMB2 proxy backend does not support sync operation at %s\n", \
+ __location__)); \
+ return NT_STATUS_NOT_IMPLEMENTED; \
+ }} while (0)
+
+/*
+ delete a file - the dirtype specifies the file types to include in the search.
+ The name can contain CIFS wildcards, but rarely does (except with OS/2 clients)
+
+ BUGS:
+ - doesn't handle wildcards
+ - doesn't obey attrib restrictions
+*/
+static NTSTATUS cvfs_unlink(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, union smb_unlink *unl)
+{
+ struct cvfs_private *private = ntvfs->private_data;
+ struct composite_context *c_req;
+
+ CHECK_ASYNC(req);
+
+ c_req = smb2_composite_unlink_send(private->tree, unl);
+
+ SIMPLE_COMPOSITE_TAIL;
+}
+
+/*
+ ioctl interface
+*/
+static NTSTATUS cvfs_ioctl(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, union smb_ioctl *io)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/*
+ check if a directory exists
+*/
+static NTSTATUS cvfs_chkpath(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, union smb_chkpath *cp)
+{
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smb2_request *c_req;
+ struct smb2_find f;
+
+ CHECK_ASYNC(req);
+
+ /* SMB2 doesn't have a chkpath operation, and also doesn't
+ have a query path info call, so the best seems to be to do a
+ find call, using the roothandle we established at connect
+ time */
+ ZERO_STRUCT(f);
+ f.in.file.handle = private->roothandle;
+ f.in.level = SMB2_FIND_DIRECTORY_INFO;
+ f.in.pattern = cp->chkpath.in.path;
+ /* SMB2 find doesn't accept \ or the empty string - this is the best
+ approximation */
+ if (strcmp(f.in.pattern, "\\") == 0 ||
+ strcmp(f.in.pattern, "") == 0) {
+ f.in.pattern = "?";
+ }
+ f.in.continue_flags = SMB2_CONTINUE_FLAG_SINGLE | SMB2_CONTINUE_FLAG_RESTART;
+ f.in.max_response_size = 0x1000;
+
+ c_req = smb2_find_send(private->tree, &f);
+
+ SIMPLE_ASYNC_TAIL;
+}
+
+/*
+ return info on a pathname
+*/
+static NTSTATUS cvfs_qpathinfo(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, union smb_fileinfo *info)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/*
+ query info on a open file
+*/
+static NTSTATUS cvfs_qfileinfo(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, union smb_fileinfo *io)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+
+/*
+ set info on a pathname
+*/
+static NTSTATUS cvfs_setpathinfo(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, union smb_setfileinfo *st)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+
+/*
+ open a file
+*/
+static NTSTATUS cvfs_open(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, union smb_open *io)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/*
+ create a directory
+*/
+static NTSTATUS cvfs_mkdir(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, union smb_mkdir *md)
+{
+ struct cvfs_private *private = ntvfs->private_data;
+ struct composite_context *c_req;
+
+ CHECK_ASYNC(req);
+
+ c_req = smb2_composite_mkdir_send(private->tree, md);
+
+ SIMPLE_COMPOSITE_TAIL;
+}
+
+/*
+ remove a directory
+*/
+static NTSTATUS cvfs_rmdir(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, struct smb_rmdir *rd)
+{
+ struct cvfs_private *private = ntvfs->private_data;
+ struct composite_context *c_req;
+
+ CHECK_ASYNC(req);
+
+ c_req = smb2_composite_rmdir_send(private->tree, rd);
+
+ SIMPLE_COMPOSITE_TAIL;
+}
+
+/*
+ rename a set of files
+*/
+static NTSTATUS cvfs_rename(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, union smb_rename *ren)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/*
+ copy a set of files
+*/
+static NTSTATUS cvfs_copy(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, struct smb_copy *cp)
+{
+ return NT_STATUS_NOT_SUPPORTED;
+}
+
+/*
+ read from a file
+*/
+static NTSTATUS cvfs_read(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, union smb_read *io)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/*
+ write to a file
+*/
+static NTSTATUS cvfs_write(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, union smb_write *io)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/*
+ seek in a file
+*/
+static NTSTATUS cvfs_seek(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req,
+ union smb_seek *io)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/*
+ flush a file
+*/
+static NTSTATUS cvfs_flush(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req,
+ union smb_flush *io)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/*
+ close a file
+*/
+static NTSTATUS cvfs_close(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, union smb_close *io)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/*
+ exit - closing files open by the pid
+*/
+static NTSTATUS cvfs_exit(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/*
+ logoff - closing files open by the user
+*/
+static NTSTATUS cvfs_logoff(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req)
+{
+ /* we can't do this right in the cifs backend .... */
+ return NT_STATUS_OK;
+}
+
+/*
+ setup for an async call - nothing to do yet
+*/
+static NTSTATUS cvfs_async_setup(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req,
+ void *private)
+{
+ return NT_STATUS_OK;
+}
+
+/*
+ cancel an async call
+*/
+static NTSTATUS cvfs_cancel(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/*
+ lock a byte range
+*/
+static NTSTATUS cvfs_lock(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, union smb_lock *io)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/*
+ set info on a open file
+*/
+static NTSTATUS cvfs_setfileinfo(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req,
+ union smb_setfileinfo *io)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+
+/*
+ a handler for async fsinfo replies
+ */
+static void async_fsinfo(struct smb2_request *c_req)
+{
+ struct async_info *async = c_req->async.private_data;
+ struct ntvfs_request *req = async->req;
+ req->async_states->status = smb2_getinfo_fs_recv(c_req, req, async->parms);
+ talloc_free(async);
+ req->async_states->send_fn(req);
+}
+
+/*
+ return filesystem space info
+*/
+static NTSTATUS cvfs_fsinfo(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, union smb_fsinfo *fs)
+{
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smb2_request *c_req;
+ enum smb_fsinfo_level level = fs->generic.level;
+
+ CHECK_ASYNC(req);
+
+ switch (level) {
+ /* some levels go straight through */
+ case RAW_QFS_VOLUME_INFORMATION:
+ case RAW_QFS_SIZE_INFORMATION:
+ case RAW_QFS_DEVICE_INFORMATION:
+ case RAW_QFS_ATTRIBUTE_INFORMATION:
+ case RAW_QFS_QUOTA_INFORMATION:
+ case RAW_QFS_FULL_SIZE_INFORMATION:
+ case RAW_QFS_OBJECTID_INFORMATION:
+ break;
+
+ /* some get mapped */
+ case RAW_QFS_VOLUME_INFO:
+ level = RAW_QFS_VOLUME_INFORMATION;
+ break;
+ case RAW_QFS_SIZE_INFO:
+ level = RAW_QFS_SIZE_INFORMATION;
+ break;
+ case RAW_QFS_DEVICE_INFO:
+ level = RAW_QFS_DEVICE_INFORMATION;
+ break;
+ case RAW_QFS_ATTRIBUTE_INFO:
+ level = RAW_QFS_ATTRIBUTE_INFO;
+ break;
+
+ default:
+ /* the rest get refused for now */
+ DEBUG(0,("fsinfo level %u not possible on SMB2\n",
+ (unsigned)fs->generic.level));
+ break;
+ }
+
+ fs->generic.level = level;
+ fs->generic.handle = private->roothandle;
+
+ c_req = smb2_getinfo_fs_send(private->tree, fs);
+
+ ASYNC_RECV_TAIL(fs, async_fsinfo);
+}
+
+/*
+ return print queue info
+*/
+static NTSTATUS cvfs_lpq(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, union smb_lpq *lpq)
+{
+ return NT_STATUS_NOT_SUPPORTED;
+}
+
+/*
+ list files in a directory matching a wildcard pattern
+*/
+static NTSTATUS cvfs_search_first(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, union smb_search_first *io,
+ void *search_private,
+ bool (*callback)(void *, const union smb_search_data *))
+{
+ struct cvfs_private *private = ntvfs->private_data;
+ struct smb2_find f;
+ enum smb_search_data_level smb2_level;
+ uint_t count, i;
+ union smb_search_data *data;
+ NTSTATUS status;
+
+ if (io->generic.level != RAW_SEARCH_TRANS2) {
+ DEBUG(0,("We only support trans2 search in smb2 backend\n"));
+ return NT_STATUS_NOT_SUPPORTED;
+ }
+
+ switch (io->generic.data_level) {
+ case RAW_SEARCH_DATA_DIRECTORY_INFO:
+ smb2_level = SMB2_FIND_DIRECTORY_INFO;
+ break;
+ case RAW_SEARCH_DATA_FULL_DIRECTORY_INFO:
+ smb2_level = SMB2_FIND_FULL_DIRECTORY_INFO;
+ break;
+ case RAW_SEARCH_DATA_BOTH_DIRECTORY_INFO:
+ smb2_level = SMB2_FIND_BOTH_DIRECTORY_INFO;
+ break;
+ case RAW_SEARCH_DATA_NAME_INFO:
+ smb2_level = SMB2_FIND_NAME_INFO;
+ break;
+ case RAW_SEARCH_DATA_ID_FULL_DIRECTORY_INFO:
+ smb2_level = SMB2_FIND_ID_FULL_DIRECTORY_INFO;
+ break;
+ case RAW_SEARCH_DATA_ID_BOTH_DIRECTORY_INFO:
+ smb2_level = SMB2_FIND_ID_BOTH_DIRECTORY_INFO;
+ break;
+ default:
+ DEBUG(0,("Unsupported search level %u for smb2 backend\n",
+ (unsigned)io->generic.data_level));
+ return NT_STATUS_INVALID_INFO_CLASS;
+ }
+
+ /* we do the search on the roothandle. This only works because
+ search is synchronous, otherwise we'd have no way to
+ distinguish multiple searches happening at once
+ */
+ ZERO_STRUCT(f);
+ f.in.file.handle = private->roothandle;
+ f.in.level = smb2_level;
+ f.in.pattern = io->t2ffirst.in.pattern;
+ while (f.in.pattern[0] == '\\') {
+ f.in.pattern++;
+ }
+ f.in.continue_flags = 0;
+ f.in.max_response_size = 0x10000;
+
+ status = smb2_find_level(private->tree, req, &f, &count, &data);
+ NT_STATUS_NOT_OK_RETURN(status);
+
+ for (i=0;i<count;i++) {
+ if (!callback(search_private, &data[i])) break;
+ }
+
+ io->t2ffirst.out.handle = 0;
+ io->t2ffirst.out.count = i;
+ /* TODO: fix end_of_file */
+ io->t2ffirst.out.end_of_search = 1;
+
+ talloc_free(data);
+
+ return NT_STATUS_OK;
+}
+
+/* continue a search */
+static NTSTATUS cvfs_search_next(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, union smb_search_next *io,
+ void *search_private,
+ bool (*callback)(void *, const union smb_search_data *))
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/* close a search */
+static NTSTATUS cvfs_search_close(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req, union smb_search_close *io)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/* SMBtrans - not used on file shares */
+static NTSTATUS cvfs_trans(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req,
+ struct smb_trans2 *trans2)
+{
+ return NT_STATUS_ACCESS_DENIED;
+}
+
+/* change notify request - always async */
+static NTSTATUS cvfs_notify(struct ntvfs_module_context *ntvfs,
+ struct ntvfs_request *req,
+ union smb_notify *io)
+{
+ return NT_STATUS_NOT_IMPLEMENTED;
+}
+
+/*
+ initialise the CIFS->CIFS backend, registering ourselves with the ntvfs subsystem
+ */
+NTSTATUS ntvfs_smb2_init(void)
+{
+ NTSTATUS ret;
+ struct ntvfs_ops ops;
+ NTVFS_CURRENT_CRITICAL_SIZES(vers);
+
+ ZERO_STRUCT(ops);
+
+ /* fill in the name and type */
+ ops.name = "smb2";
+ ops.type = NTVFS_DISK;
+
+ /* fill in all the operations */
+ ops.connect = cvfs_connect;
+ ops.disconnect = cvfs_disconnect;
+ ops.unlink = cvfs_unlink;
+ ops.chkpath = cvfs_chkpath;
+ ops.qpathinfo = cvfs_qpathinfo;
+ ops.setpathinfo = cvfs_setpathinfo;
+ ops.open = cvfs_open;
+ ops.mkdir = cvfs_mkdir;
+ ops.rmdir = cvfs_rmdir;
+ ops.rename = cvfs_rename;
+ ops.copy = cvfs_copy;
+ ops.ioctl = cvfs_ioctl;
+ ops.read = cvfs_read;
+ ops.write = cvfs_write;
+ ops.seek = cvfs_seek;
+ ops.flush = cvfs_flush;
+ ops.close = cvfs_close;
+ ops.exit = cvfs_exit;
+ ops.lock = cvfs_lock;
+ ops.setfileinfo = cvfs_setfileinfo;
+ ops.qfileinfo = cvfs_qfileinfo;
+ ops.fsinfo = cvfs_fsinfo;
+ ops.lpq = cvfs_lpq;
+ ops.search_first = cvfs_search_first;
+ ops.search_next = cvfs_search_next;
+ ops.search_close = cvfs_search_close;
+ ops.trans = cvfs_trans;
+ ops.logoff = cvfs_logoff;
+ ops.async_setup = cvfs_async_setup;
+ ops.cancel = cvfs_cancel;
+ ops.notify = cvfs_notify;
+
+ /* register ourselves with the NTVFS subsystem. We register
+ under the name 'smb2'. */
+ ret = ntvfs_register(&ops, &vers);
+
+ if (!NT_STATUS_IS_OK(ret)) {
+ DEBUG(0,("Failed to register SMB2 backend\n"));
+ }
+
+ return ret;
+}
diff --git a/source4/ntvfs/sysdep/config.mk b/source4/ntvfs/sysdep/config.mk
index 048226efad..1122d5c39d 100644
--- a/source4/ntvfs/sysdep/config.mk
+++ b/source4/ntvfs/sysdep/config.mk
@@ -3,34 +3,23 @@
[MODULE::sys_notify_inotify]
SUBSYSTEM = sys_notify
INIT_FUNCTION = sys_notify_inotify_init
-OBJ_FILES = \
- inotify.o
# End MODULE sys_notify_inotify
################################################
+sys_notify_inotify_OBJ_FILES = $(ntvfssrcdir)/sysdep/inotify.o
+
################################################
# Start SUBSYSTEM sys_notify
[SUBSYSTEM::sys_notify]
-OBJ_FILES = \
- sys_notify.o
-PUBLIC_DEPENDENCIES =
# End SUBSYSTEM sys_notify
################################################
-################################################
-# Start MODULE sys_lease_linux
-[MODULE::sys_lease_linux]
-SUBSYSTEM = sys_lease
-INIT_FUNCTION = sys_lease_linux_init
-OBJ_FILES = \
- sys_lease_linux.o
-# End MODULE sys_lease_linux
-################################################
+sys_notify_OBJ_FILES = $(ntvfssrcdir)/sysdep/sys_notify.o
+
+[SUBSYSTEM::sys_lease_linux]
+
+sys_lease_linux_OBJ_FILES = $(ntvfssrcdir)/sysdep/sys_lease_linux.o
-################################################
-# Start SUBSYSTEM sys_lease
[SUBSYSTEM::sys_lease]
-OBJ_FILES = \
- sys_lease.o
-# End SUBSYSTEM sys_lease
-################################################
+
+sys_lease_OBJ_FILES = $(ntvfssrcdir)/sysdep/sys_lease.o
diff --git a/source4/ntvfs/sysdep/sys_lease.c b/source4/ntvfs/sysdep/sys_lease.c
index 28dd27a708..a0322bbcc1 100644
--- a/source4/ntvfs/sysdep/sys_lease.c
+++ b/source4/ntvfs/sysdep/sys_lease.c
@@ -28,7 +28,6 @@
#include "lib/events/events.h"
#include "lib/util/dlinklist.h"
#include "param/param.h"
-#include "build.h"
/* list of registered backends */
static struct sys_lease_ops *backends;
@@ -55,7 +54,7 @@ _PUBLIC_ struct sys_lease_context *sys_lease_context_create(struct share_config
}
if (ev == NULL) {
- ev = event_context_find(mem_ctx);
+ return NULL;
}
ctx = talloc_zero(mem_ctx, struct sys_lease_context);
@@ -109,9 +108,14 @@ _PUBLIC_ NTSTATUS sys_lease_register(const struct sys_lease_ops *backend)
return NT_STATUS_OK;
}
+#ifndef STATIC_sys_lease_MODULES
+#define STATIC_sys_lease_MODULES NULL
+#endif
+
_PUBLIC_ NTSTATUS sys_lease_init(void)
{
static bool initialized = false;
+ extern NTSTATUS sys_lease_linux_init(void);
init_module_fn static_init[] = { STATIC_sys_lease_MODULES };
diff --git a/source4/ntvfs/sysdep/sys_notify.c b/source4/ntvfs/sysdep/sys_notify.c
index 84ba745f5b..9770323c3f 100644
--- a/source4/ntvfs/sysdep/sys_notify.c
+++ b/source4/ntvfs/sysdep/sys_notify.c
@@ -28,7 +28,6 @@
#include "lib/events/events.h"
#include "lib/util/dlinklist.h"
#include "param/param.h"
-#include "build.h"
/* list of registered backends */
static struct sys_notify_backend *backends;
@@ -52,7 +51,7 @@ _PUBLIC_ struct sys_notify_context *sys_notify_context_create(struct share_confi
}
if (ev == NULL) {
- ev = event_context_find(mem_ctx);
+ return NULL;
}
ctx = talloc_zero(mem_ctx, struct sys_notify_context);
@@ -124,6 +123,7 @@ _PUBLIC_ NTSTATUS sys_notify_register(struct sys_notify_backend *backend)
_PUBLIC_ NTSTATUS sys_notify_init(void)
{
static bool initialized = false;
+ extern NTSTATUS sys_notify_inotify_init(void);
init_module_fn static_init[] = { STATIC_sys_notify_MODULES };
diff --git a/source4/ntvfs/unixuid/config.mk b/source4/ntvfs/unixuid/config.mk
index 91976c6811..6377657cec 100644
--- a/source4/ntvfs/unixuid/config.mk
+++ b/source4/ntvfs/unixuid/config.mk
@@ -3,8 +3,8 @@
[MODULE::ntvfs_unixuid]
INIT_FUNCTION = ntvfs_unixuid_init
SUBSYSTEM = ntvfs
-OBJ_FILES = \
- vfs_unixuid.o
PRIVATE_DEPENDENCIES = SAMDB NSS_WRAPPER
# End MODULE ntvfs_unixuid
################################################
+
+ntvfs_unixuid_OBJ_FILES = $(ntvfssrcdir)/unixuid/vfs_unixuid.o
diff --git a/source4/param/config.mk b/source4/param/config.mk
index eee22cf1b8..02474d50b9 100644
--- a/source4/param/config.mk
+++ b/source4/param/config.mk
@@ -1,26 +1,33 @@
[LIBRARY::LIBSAMBA-HOSTCONFIG]
-VERSION = 0.0.1
-SO_VERSION = 1
-OBJ_FILES = loadparm.o \
- generic.o \
- util.o \
- ../lib/version.o
-PC_FILE = samba-hostconfig.pc
PUBLIC_DEPENDENCIES = LIBSAMBA-UTIL
PRIVATE_DEPENDENCIES = DYNCONFIG LIBREPLACE_EXT CHARSET
-PRIVATE_PROTO_HEADER = proto.h
+
+LIBSAMBA-HOSTCONFIG_VERSION = 0.0.1
+LIBSAMBA-HOSTCONFIG_SOVERSION = 0
+
+LIBSAMBA-HOSTCONFIG_OBJ_FILES = $(addprefix $(paramsrcdir)/, \
+ loadparm.o generic.o util.o) lib/version.o
PUBLIC_HEADERS += param/param.h
+PC_FILES += $(paramsrcdir)/samba-hostconfig.pc
+
+[SUBSYSTEM::PROVISION]
+PRIVATE_DEPENDENCIES = LIBPYTHON
+
+PROVISION_OBJ_FILES = $(paramsrcdir)/provision.o
+
#################################
# Start SUBSYSTEM share
[SUBSYSTEM::share]
-PRIVATE_PROTO_HEADER = share_proto.h
-OBJ_FILES = share.o
PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL
# End SUBSYSTEM share
#################################
+share_OBJ_FILES = $(paramsrcdir)/share.o
+
+$(eval $(call proto_header_template,$(paramsrcdir)/share_proto.h,$(share_OBJ_FILES:.o=.c)))
+
PUBLIC_HEADERS += param/share.h
################################################
@@ -28,25 +35,34 @@ PUBLIC_HEADERS += param/share.h
[MODULE::share_classic]
SUBSYSTEM = share
INIT_FUNCTION = share_classic_init
-OBJ_FILES = share_classic.o
PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL
# End MODULE share_classic
################################################
+share_classic_OBJ_FILES = $(paramsrcdir)/share_classic.o
+
################################################
# Start MODULE share_ldb
[MODULE::share_ldb]
SUBSYSTEM = share
INIT_FUNCTION = share_ldb_init
-OBJ_FILES = share_ldb.o
PRIVATE_DEPENDENCIES = LIBLDB LDB_WRAP
# End MODULE share_ldb
################################################
+share_ldb_OBJ_FILES = $(paramsrcdir)/share_ldb.o
+
[SUBSYSTEM::SECRETS]
-OBJ_FILES = secrets.o
PRIVATE_DEPENDENCIES = LIBLDB TDB_WRAP UTIL_TDB NDR_SECURITY
+SECRETS_OBJ_FILES = $(paramsrcdir)/secrets.o
+
[PYTHON::param]
-SWIG_FILE = param.i
+LIBRARY_REALNAME = samba/_param.$(SHLIBEXT)
PRIVATE_DEPENDENCIES = LIBSAMBA-HOSTCONFIG
+
+param_OBJ_FILES = $(paramsrcdir)/param_wrap.o
+
+$(eval $(call python_py_module_template,samba/param.py,$(paramsrcdir)/param.py))
+
+$(param_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
diff --git a/source4/param/param.i b/source4/param/param.i
index 77d781d6ff..2c15f8f5e3 100644
--- a/source4/param/param.i
+++ b/source4/param/param.i
@@ -50,22 +50,36 @@ typedef struct loadparm_context {
%extend {
loadparm_context(TALLOC_CTX *mem_ctx) { return loadparm_init(mem_ctx); }
struct loadparm_service *default_service() { return lp_default_service($self); }
+ %feature("docstring") load "S.load(filename) -> None\n" \
+ "Load specified file.";
bool load(const char *filename) { return lp_load($self, filename); }
+ %feature("docstring") load_default "S.load_default() -> None\n" \
+ "Load default smb.conf file.";
bool load_default() { return lp_load_default($self); }
#ifdef SWIGPYTHON
int __len__() { return lp_numservices($self); }
struct loadparm_service *__getitem__(const char *name) { return lp_service($self, name); }
#endif
+ %feature("docstring") configfile "S.configfile() -> string\n" \
+ "Return name of last config file that was loaded.";
const char *configfile() { return lp_configfile($self); }
+ %feature("docstring") is_mydomain "S.is_mydomain(domain_name) -> bool\n" \
+ "Check whether the specified name matches our domain name.";
bool is_mydomain(const char *domain) { return lp_is_mydomain($self, domain); }
+ %feature("docstring") is_myname "S.is_myname(netbios_name) -> bool\n" \
+ "Check whether the specified name matches one of our netbios names.";
bool is_myname(const char *name) { return lp_is_myname($self, name); }
int use(struct param_context *param_ctx) { return param_use($self, param_ctx); }
+ %feature("docstring") set "S.set(name, value) -> bool\n" \
+ "Change a parameter.";
bool set(const char *parm_name, const char *parm_value) {
if (parm_value == NULL)
return false;
return lp_set_cmdline($self, parm_name, parm_value);
}
+ %feature("docstring") set "S.get(name, service_name) -> value\n" \
+ "Find specified parameter.";
PyObject *get(const char *param_name, const char *service_name)
{
struct parm_struct *parm = NULL;
@@ -180,7 +194,11 @@ typedef struct loadparm_service {
typedef struct param_context {
%extend {
param(TALLOC_CTX *mem_ctx) { return param_init(mem_ctx); }
+ %feature("docstring") add_section "S.get_section(name) -> section\n"
+ "Get an existing section.";
struct param_section *get_section(const char *name);
+ %feature("docstring") add_section "S.add_section(name) -> section\n"
+ "Add a new section.";
struct param_section *add_section(const char *name);
struct param_opt *get(const char *name, const char *section_name="global");
const char *get_string(const char *name, const char *section_name="global");
@@ -198,10 +216,18 @@ typedef struct param_context {
#endif
+ %feature("docstring") first_section "S.first_section() -> section\n"
+ "Find first section";
struct param_section *first_section() { return $self->sections; }
+ %feature("docstring") next_section "S.next_section(prev) -> section\n"
+ "Find next section";
struct param_section *next_section(struct param_section *s) { return s->next; }
+ %feature("docstring") read "S.read(filename) -> bool\n"
+ "Read a filename.";
int read(const char *fn);
+ %feature("docstring") read "S.write(filename) -> bool\n"
+ "Write this object to a file.";
int write(const char *fn);
}
%pythoncode {
@@ -307,6 +333,15 @@ struct loadparm_context *lp_from_py_object(PyObject *py_obj)
return lp_ctx;
}
+ if (py_obj == Py_None) {
+ lp_ctx = loadparm_init(NULL);
+ if (!lp_load_default(lp_ctx)) {
+ talloc_free(lp_ctx);
+ return NULL;
+ }
+ return lp_ctx;
+ }
+
if (SWIG_ConvertPtr(py_obj, (void *)&lp_ctx, SWIGTYPE_p_loadparm_context, 0 | 0 ) < 0)
return NULL;
return lp_ctx;
diff --git a/source4/param/param.py b/source4/param/param.py
index 025acc6be1..3aebaf0e02 100644
--- a/source4/param/param.py
+++ b/source4/param/param.py
@@ -1,5 +1,5 @@
# This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.33
+# Version 1.3.35
#
# Don't modify this file, modify the SWIG interface instead.
@@ -62,6 +62,48 @@ class LoadParm(object):
__repr__ = _swig_repr
def __init__(self, *args, **kwargs):
_param.LoadParm_swiginit(self,_param.new_LoadParm(*args, **kwargs))
+ def load(*args, **kwargs):
+ """
+ S.load(filename) -> None
+ Load specified file.
+ """
+ return _param.LoadParm_load(*args, **kwargs)
+
+ def load_default(*args, **kwargs):
+ """
+ S.load_default() -> None
+ Load default smb.conf file.
+ """
+ return _param.LoadParm_load_default(*args, **kwargs)
+
+ def configfile(*args, **kwargs):
+ """
+ S.configfile() -> string
+ Return name of last config file that was loaded.
+ """
+ return _param.LoadParm_configfile(*args, **kwargs)
+
+ def is_mydomain(*args, **kwargs):
+ """
+ S.is_mydomain(domain_name) -> bool
+ Check whether the specified name matches our domain name.
+ """
+ return _param.LoadParm_is_mydomain(*args, **kwargs)
+
+ def is_myname(*args, **kwargs):
+ """
+ S.is_myname(netbios_name) -> bool
+ Check whether the specified name matches one of our netbios names.
+ """
+ return _param.LoadParm_is_myname(*args, **kwargs)
+
+ def set(*args, **kwargs):
+ """
+ S.set(name, value) -> bool
+ Change a parameter.
+ """
+ return _param.LoadParm_set(*args, **kwargs)
+
__swig_destroy__ = _param.delete_LoadParm
LoadParm.default_service = new_instancemethod(_param.LoadParm_default_service,None,LoadParm)
LoadParm.load = new_instancemethod(_param.LoadParm_load,None,LoadParm)
@@ -79,7 +121,7 @@ LoadParm_swigregister(LoadParm)
class loadparm_service(object):
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
- def __init__(self): raise AttributeError, "No constructor defined"
+ def __init__(self, *args, **kwargs): raise AttributeError, "No constructor defined"
__repr__ = _swig_repr
loadparm_service.volume_label = new_instancemethod(_param.loadparm_service_volume_label,None,loadparm_service)
loadparm_service.printername = new_instancemethod(_param.loadparm_service_printername,None,loadparm_service)
@@ -92,6 +134,34 @@ class ParamFile(object):
__repr__ = _swig_repr
def __init__(self, *args, **kwargs):
_param.ParamFile_swiginit(self,_param.new_ParamFile(*args, **kwargs))
+ def add_section(*args, **kwargs):
+ """
+ S.add_section(name) -> section
+ Add a new section.
+ """
+ return _param.ParamFile_add_section(*args, **kwargs)
+
+ def first_section(*args, **kwargs):
+ """
+ S.first_section() -> section
+ Find first section
+ """
+ return _param.ParamFile_first_section(*args, **kwargs)
+
+ def next_section(*args, **kwargs):
+ """
+ S.next_section(prev) -> section
+ Find next section
+ """
+ return _param.ParamFile_next_section(*args, **kwargs)
+
+ def read(*args, **kwargs):
+ """
+ S.read(filename) -> bool
+ Read a filename.
+ """
+ return _param.ParamFile_read(*args, **kwargs)
+
def __getitem__(self, name):
ret = self.get_section(name)
if ret is None:
@@ -137,7 +207,7 @@ ParamFile_swigregister(ParamFile)
class param_opt(object):
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
- def __init__(self): raise AttributeError, "No constructor defined"
+ def __init__(self, *args, **kwargs): raise AttributeError, "No constructor defined"
__repr__ = _swig_repr
key = _swig_property(_param.param_opt_key_get)
value = _swig_property(_param.param_opt_value_get)
diff --git a/source4/param/param_wrap.c b/source4/param/param_wrap.c
index e74f902645..aff239312d 100644
--- a/source4/param/param_wrap.c
+++ b/source4/param/param_wrap.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.33
+ * Version 1.3.35
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
@@ -126,7 +126,7 @@
/* This should only be incremented when either the layout of swig_type_info changes,
or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "3"
+#define SWIG_RUNTIME_VERSION "4"
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
#ifdef SWIG_TYPE_TABLE
@@ -161,6 +161,7 @@
/* Flags for pointer conversions */
#define SWIG_POINTER_DISOWN 0x1
+#define SWIG_CAST_NEW_MEMORY 0x2
/* Flags for new pointer objects */
#define SWIG_POINTER_OWN 0x1
@@ -301,10 +302,10 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) {
extern "C" {
#endif
-typedef void *(*swig_converter_func)(void *);
+typedef void *(*swig_converter_func)(void *, int *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);
-/* Structure to store inforomation on one type */
+/* Structure to store information on one type */
typedef struct swig_type_info {
const char *name; /* mangled name of this type */
const char *str; /* human readable name of this type */
@@ -431,8 +432,8 @@ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
Cast a pointer up an inheritance hierarchy
*/
SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
- return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
+SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
}
/*
@@ -856,7 +857,7 @@ SWIG_Python_AddErrorMsg(const char* mesg)
Py_DECREF(old_str);
Py_DECREF(value);
} else {
- PyErr_Format(PyExc_RuntimeError, mesg);
+ PyErr_SetString(PyExc_RuntimeError, mesg);
}
}
@@ -1416,7 +1417,7 @@ PySwigObject_dealloc(PyObject *v)
{
PySwigObject *sobj = (PySwigObject *) v;
PyObject *next = sobj->next;
- if (sobj->own) {
+ if (sobj->own == SWIG_POINTER_OWN) {
swig_type_info *ty = sobj->ty;
PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
PyObject *destroy = data ? data->destroy : 0;
@@ -1434,12 +1435,13 @@ PySwigObject_dealloc(PyObject *v)
res = ((*meth)(mself, v));
}
Py_XDECREF(res);
- } else {
- const char *name = SWIG_TypePrettyName(ty);
+ }
#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
- printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
-#endif
+ else {
+ const char *name = SWIG_TypePrettyName(ty);
+ printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
}
+#endif
}
Py_XDECREF(next);
PyObject_DEL(v);
@@ -1944,7 +1946,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
SWIGRUNTIME int
SWIG_Python_AcquirePtr(PyObject *obj, int own) {
- if (own) {
+ if (own == SWIG_POINTER_OWN) {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
if (sobj) {
int oldown = sobj->own;
@@ -1965,6 +1967,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
return SWIG_OK;
} else {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+ if (own)
+ *own = 0;
while (sobj) {
void *vptr = sobj->ptr;
if (ty) {
@@ -1978,7 +1982,15 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
if (!tc) {
sobj = (PySwigObject *)sobj->next;
} else {
- if (ptr) *ptr = SWIG_TypeCast(tc,vptr);
+ if (ptr) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
+ assert(own);
+ if (own)
+ *own = *own | SWIG_CAST_NEW_MEMORY;
+ }
+ }
break;
}
}
@@ -1988,7 +2000,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
}
}
if (sobj) {
- if (own) *own = sobj->own;
+ if (own)
+ *own = *own | sobj->own;
if (flags & SWIG_POINTER_DISOWN) {
sobj->own = 0;
}
@@ -2053,8 +2066,13 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
}
if (ty) {
swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
- if (!tc) return SWIG_ERROR;
- *ptr = SWIG_TypeCast(tc,vptr);
+ if (tc) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ assert(!newmemory); /* newmemory handling not yet implemented */
+ } else {
+ return SWIG_ERROR;
+ }
} else {
*ptr = vptr;
}
@@ -2504,7 +2522,7 @@ static swig_module_info swig_module = {swig_types, 15, 0, 0, 0, 0};
#define SWIG_name "_param"
-#define SWIGVERSION 0x010333
+#define SWIGVERSION 0x010335
#define SWIG_VERSION SWIGVERSION
@@ -2776,6 +2794,15 @@ struct loadparm_context *lp_from_py_object(PyObject *py_obj)
return lp_ctx;
}
+ if (py_obj == Py_None) {
+ lp_ctx = loadparm_init(NULL);
+ if (!lp_load_default(lp_ctx)) {
+ talloc_free(lp_ctx);
+ return NULL;
+ }
+ return lp_ctx;
+ }
+
if (SWIG_ConvertPtr(py_obj, (void *)&lp_ctx, SWIGTYPE_p_loadparm_context, 0 | 0 ) < 0)
return NULL;
return lp_ctx;
@@ -4073,7 +4100,7 @@ SWIGINTERN PyObject *_wrap_new_param_section(PyObject *SWIGUNUSEDPARM(self), PyO
param_section *result = 0 ;
if (!SWIG_Python_UnpackTuple(args,"new_param_section",0,0,0)) SWIG_fail;
- result = (param_section *)(param_section *) calloc(1, sizeof(param_section));
+ result = (param_section *)calloc(1, sizeof(param_section));
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_param_section, SWIG_POINTER_NEW | 0 );
return resultobj;
fail:
@@ -4141,15 +4168,33 @@ SWIGINTERN PyObject *Swig_var_default_config_get(void) {
static PyMethodDef SwigMethods[] = {
{ (char *)"new_LoadParm", (PyCFunction)_wrap_new_LoadParm, METH_NOARGS, NULL},
{ (char *)"LoadParm_default_service", (PyCFunction) _wrap_LoadParm_default_service, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"LoadParm_load", (PyCFunction) _wrap_LoadParm_load, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"LoadParm_load_default", (PyCFunction) _wrap_LoadParm_load_default, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"LoadParm_load", (PyCFunction) _wrap_LoadParm_load, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.load(filename) -> None\n"
+ "Load specified file.\n"
+ ""},
+ { (char *)"LoadParm_load_default", (PyCFunction) _wrap_LoadParm_load_default, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.load_default() -> None\n"
+ "Load default smb.conf file.\n"
+ ""},
{ (char *)"LoadParm___len__", (PyCFunction) _wrap_LoadParm___len__, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"LoadParm___getitem__", (PyCFunction) _wrap_LoadParm___getitem__, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"LoadParm_configfile", (PyCFunction) _wrap_LoadParm_configfile, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"LoadParm_is_mydomain", (PyCFunction) _wrap_LoadParm_is_mydomain, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"LoadParm_is_myname", (PyCFunction) _wrap_LoadParm_is_myname, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"LoadParm_configfile", (PyCFunction) _wrap_LoadParm_configfile, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.configfile() -> string\n"
+ "Return name of last config file that was loaded.\n"
+ ""},
+ { (char *)"LoadParm_is_mydomain", (PyCFunction) _wrap_LoadParm_is_mydomain, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.is_mydomain(domain_name) -> bool\n"
+ "Check whether the specified name matches our domain name.\n"
+ ""},
+ { (char *)"LoadParm_is_myname", (PyCFunction) _wrap_LoadParm_is_myname, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.is_myname(netbios_name) -> bool\n"
+ "Check whether the specified name matches one of our netbios names.\n"
+ ""},
{ (char *)"LoadParm_use", (PyCFunction) _wrap_LoadParm_use, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"LoadParm_set", (PyCFunction) _wrap_LoadParm_set, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"LoadParm_set", (PyCFunction) _wrap_LoadParm_set, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set(name, value) -> bool\n"
+ "Change a parameter.\n"
+ ""},
{ (char *)"LoadParm_get", (PyCFunction) _wrap_LoadParm_get, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"delete_LoadParm", (PyCFunction) _wrap_delete_LoadParm, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"LoadParm_swigregister", LoadParm_swigregister, METH_VARARGS, NULL},
@@ -4160,14 +4205,26 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"loadparm_service_swigregister", loadparm_service_swigregister, METH_VARARGS, NULL},
{ (char *)"new_ParamFile", (PyCFunction)_wrap_new_ParamFile, METH_NOARGS, NULL},
{ (char *)"ParamFile_get_section", (PyCFunction) _wrap_ParamFile_get_section, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"ParamFile_add_section", (PyCFunction) _wrap_ParamFile_add_section, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"ParamFile_add_section", (PyCFunction) _wrap_ParamFile_add_section, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.add_section(name) -> section\n"
+ "Add a new section.\n"
+ ""},
{ (char *)"ParamFile_get", (PyCFunction) _wrap_ParamFile_get, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"ParamFile_get_string", (PyCFunction) _wrap_ParamFile_get_string, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"ParamFile_set_string", (PyCFunction) _wrap_ParamFile_set_string, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"ParamFile_set", (PyCFunction) _wrap_ParamFile_set, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"ParamFile_first_section", (PyCFunction)_wrap_ParamFile_first_section, METH_O, NULL},
- { (char *)"ParamFile_next_section", (PyCFunction) _wrap_ParamFile_next_section, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"ParamFile_read", (PyCFunction) _wrap_ParamFile_read, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"ParamFile_first_section", (PyCFunction)_wrap_ParamFile_first_section, METH_O, (char *)"\n"
+ "S.first_section() -> section\n"
+ "Find first section\n"
+ ""},
+ { (char *)"ParamFile_next_section", (PyCFunction) _wrap_ParamFile_next_section, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.next_section(prev) -> section\n"
+ "Find next section\n"
+ ""},
+ { (char *)"ParamFile_read", (PyCFunction) _wrap_ParamFile_read, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.read(filename) -> bool\n"
+ "Read a filename.\n"
+ ""},
{ (char *)"ParamFile_write", (PyCFunction) _wrap_ParamFile_write, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"delete_ParamFile", (PyCFunction)_wrap_delete_ParamFile, METH_O, NULL},
{ (char *)"ParamFile_swigregister", ParamFile_swigregister, METH_VARARGS, NULL},
@@ -4325,7 +4382,7 @@ SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
- int found;
+ int found, init;
clientdata = clientdata;
@@ -4335,6 +4392,9 @@ SWIG_InitializeModule(void *clientdata) {
swig_module.type_initial = swig_type_initial;
swig_module.cast_initial = swig_cast_initial;
swig_module.next = &swig_module;
+ init = 1;
+ } else {
+ init = 0;
}
/* Try and load any already created modules */
@@ -4363,6 +4423,12 @@ SWIG_InitializeModule(void *clientdata) {
module_head->next = &swig_module;
}
+ /* When multiple interpeters are used, a module could have already been initialized in
+ a different interpreter, but not yet have a pointer in this interpreter.
+ In this case, we do not want to continue adding types... everything should be
+ set up already */
+ if (init == 0) return;
+
/* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: size %d\n", swig_module.size);
diff --git a/source4/torture/util_provision.c b/source4/param/provision.c
index cce8e18fdc..0e54acf9e4 100644
--- a/source4/torture/util_provision.c
+++ b/source4/param/provision.c
@@ -20,19 +20,21 @@
#include "includes.h"
#include "auth/auth.h"
#include "lib/ldb_wrap.h"
-#include "torture/torture.h"
#include "libcli/raw/libcliraw.h"
-#include "torture/util.h"
#include "librpc/ndr/libndr.h"
#include "param/param.h"
+#include "param/provision.h"
#include <Python.h>
#include "scripting/python/modules.h"
NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
- struct provision_settings *settings)
+ struct provision_settings *settings,
+ struct provision_result *result)
{
- PyObject *provision_mod, *provision_dict, *provision_fn, *result, *parameters;
+ extern struct loadparm_context *lp_from_py_object(PyObject *py_obj);
+ struct ldb_context *ldb_context_from_py_object(PyObject *py_obj);
+ PyObject *provision_mod, *provision_dict, *provision_fn, *py_result, *parameters;
DEBUG(0,("Provision for Become-DC test using python\n"));
@@ -62,20 +64,21 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
return NT_STATUS_UNSUCCESSFUL;
}
- DEBUG(0,("New Server[%s] in Site[%s]\n", settings->dns_name,
- settings->site_name));
+ DEBUG(0,("New Server in Site[%s]\n",
+ 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 targetdir[%s]\n",
settings->targetdir));
parameters = PyDict_New();
+ PyDict_SetItemString(parameters, "smbconf",
+ PyString_FromString(lp_configfile(lp_ctx)));
+
PyDict_SetItemString(parameters, "rootdn",
PyString_FromString(settings->root_dn_str));
if (settings->targetdir != NULL)
@@ -105,6 +108,10 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
PyDict_SetItemString(parameters, "configdn",
PyString_FromString(settings->config_dn_str));
+ if (settings->server_dn_str)
+ PyDict_SetItemString(parameters, "serverdn",
+ PyString_FromString(settings->server_dn_str));
+
if (settings->site_name)
PyDict_SetItemString(parameters, "sitename",
PyString_FromString(settings->site_name));
@@ -112,15 +119,21 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
PyDict_SetItemString(parameters, "machinepass",
PyString_FromString(settings->machine_password));
- result = PyEval_CallObjectWithKeywords(provision_fn, NULL, parameters);
+ py_result = PyEval_CallObjectWithKeywords(provision_fn, NULL, parameters);
Py_DECREF(parameters);
- if (result == NULL) {
+ if (py_result == NULL) {
PyErr_Print();
PyErr_Clear();
return NT_STATUS_UNSUCCESSFUL;
}
+ result->domaindn = talloc_strdup(mem_ctx, PyString_AsString(PyObject_GetAttrString(py_result, "domaindn")));
+
+ /* FIXME paths */
+ result->lp_ctx = lp_from_py_object(PyObject_GetAttrString(py_result, "lp"));
+ result->samdb = ldb_context_from_py_object(PyObject_GetAttrString(py_result, "samdb"));
+
return NT_STATUS_OK;
}
diff --git a/source4/param/provision.h b/source4/param/provision.h
new file mode 100644
index 0000000000..af9685d292
--- /dev/null
+++ b/source4/param/provision.h
@@ -0,0 +1,51 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+ Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _PROVISION_H_
+#define _PROVISION_H_
+
+struct provision_settings {
+ const char *site_name;
+ const char *root_dn_str;
+ const char *domain_dn_str;
+ const char *config_dn_str;
+ const char *schema_dn_str;
+ const char *server_dn_str;
+ const struct GUID *invocation_id;
+ const char *netbios_name;
+ const char *host_ip;
+ const char *realm;
+ const char *domain;
+ const char *ntds_dn_str;
+ const char *machine_password;
+ const char *targetdir;
+};
+
+/* FIXME: Rename this to hostconfig ? */
+struct provision_result {
+ const char *domaindn;
+ struct ldb_context *samdb;
+ struct loadparm_context *lp_ctx;
+};
+
+NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
+ struct provision_settings *settings,
+ struct provision_result *result);
+
+#endif /* _PROVISION_H_ */
diff --git a/source4/param/share.c b/source4/param/share.c
index bc2999b03d..47aea55751 100644
--- a/source4/param/share.c
+++ b/source4/param/share.c
@@ -21,7 +21,6 @@
#include "includes.h"
#include "param/share.h"
-#include "build.h"
#include "param/param.h"
const char *share_string_option(struct share_config *scfg, const char *opt_name, const char *defval)
@@ -127,6 +126,7 @@ NTSTATUS share_register(const struct share_ops *ops)
}
NTSTATUS share_get_context_by_name(TALLOC_CTX *mem_ctx, const char *backend_name,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct share_context **ctx)
{
@@ -138,7 +138,7 @@ NTSTATUS share_get_context_by_name(TALLOC_CTX *mem_ctx, const char *backend_name
return NT_STATUS_INTERNAL_ERROR;
}
- return ops->init(mem_ctx, ops, lp_ctx, ctx);
+ return ops->init(mem_ctx, ops, event_ctx, lp_ctx, ctx);
}
/*
@@ -146,6 +146,8 @@ NTSTATUS share_get_context_by_name(TALLOC_CTX *mem_ctx, const char *backend_name
*/
NTSTATUS share_init(void)
{
+ extern NTSTATUS share_ldb_init(void);
+ extern NTSTATUS share_classic_init(void);
init_module_fn static_init[] = { STATIC_share_MODULES };
run_init_functions(static_init);
diff --git a/source4/param/share.h b/source4/param/share.h
index 9f9cbdce5b..2a85fd4fbb 100644
--- a/source4/param/share.h
+++ b/source4/param/share.h
@@ -47,9 +47,12 @@ struct share_info {
void *value;
};
+struct event_context;
+
struct share_ops {
const char *name;
- NTSTATUS (*init)(TALLOC_CTX *, const struct share_ops*, struct loadparm_context *lp_ctx,
+ NTSTATUS (*init)(TALLOC_CTX *, const struct share_ops*, struct event_context *ev_ctx,
+ struct loadparm_context *lp_ctx,
struct share_context **);
const char *(*string_option)(struct share_config *, const char *, const char *);
int (*int_option)(struct share_config *, const char *, int);
diff --git a/source4/param/share_classic.c b/source4/param/share_classic.c
index c3adc4473c..bac1aac2d7 100644
--- a/source4/param/share_classic.c
+++ b/source4/param/share_classic.c
@@ -25,6 +25,7 @@
static NTSTATUS sclassic_init(TALLOC_CTX *mem_ctx,
const struct share_ops *ops,
+ struct event_context *event_ctx,
struct loadparm_context *lp_ctx,
struct share_context **ctx)
{
diff --git a/source4/param/share_ldb.c b/source4/param/share_ldb.c
index fb40f1e9bf..eba1665cc9 100644
--- a/source4/param/share_ldb.c
+++ b/source4/param/share_ldb.c
@@ -27,7 +27,9 @@
#include "param/share.h"
#include "param/param.h"
-static NTSTATUS sldb_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops, struct loadparm_context *lp_ctx,
+static NTSTATUS sldb_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops,
+ struct event_context *ev_ctx,
+ struct loadparm_context *lp_ctx,
struct share_context **ctx)
{
struct ldb_context *sdb;
@@ -38,7 +40,7 @@ static NTSTATUS sldb_init(TALLOC_CTX *mem_ctx, const struct share_ops *ops, stru
return NT_STATUS_NO_MEMORY;
}
- sdb = ldb_wrap_connect(*ctx, lp_ctx,
+ sdb = ldb_wrap_connect(*ctx, ev_ctx, lp_ctx,
private_path(*ctx, lp_ctx, "share.ldb"),
system_session(*ctx, lp_ctx),
NULL, 0, NULL);
diff --git a/source4/param/tests/bindings.py b/source4/param/tests/bindings.py
index 0dd186b9df..d1d71e4485 100644
--- a/source4/param/tests/bindings.py
+++ b/source4/param/tests/bindings.py
@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-import param
+from samba import param
import unittest
class LoadParmTestCase(unittest.TestCase):
diff --git a/source4/param/tests/share.c b/source4/param/tests/share.c
index 6d03b4e049..c64b5c607a 100644
--- a/source4/param/tests/share.c
+++ b/source4/param/tests/share.c
@@ -182,12 +182,12 @@ static void tcase_add_share_tests(struct torture_tcase *tcase)
static bool setup_ldb(struct torture_context *tctx, void **data)
{
- return NT_STATUS_IS_OK(share_get_context_by_name(tctx, "ldb", tctx->lp_ctx, (struct share_context **)data));
+ return NT_STATUS_IS_OK(share_get_context_by_name(tctx, "ldb", tctx->ev, tctx->lp_ctx, (struct share_context **)data));
}
static bool setup_classic(struct torture_context *tctx, void **data)
{
- return NT_STATUS_IS_OK(share_get_context_by_name(tctx, "classic", tctx->lp_ctx, (struct share_context **)data));
+ return NT_STATUS_IS_OK(share_get_context_by_name(tctx, "classic", tctx->ev, tctx->lp_ctx, (struct share_context **)data));
}
static bool teardown(struct torture_context *tctx, void *data)
diff --git a/source4/pidl/TODO b/source4/pidl/TODO
index f1cca0ab23..bc5c49a46f 100644
--- a/source4/pidl/TODO
+++ b/source4/pidl/TODO
@@ -1,6 +1,3 @@
-- EJS output backend shouldn't use the NDR levels stuff but instead
- as the "C levels" and NDR levels don't necessarily match.
-
- true multiple dimension array / strings in arrays support
- compatibility mode for generating MIDL-readable data:
@@ -31,3 +28,15 @@
- remove NDR_AUTO_REF_ALLOC flag
- automatic test generator based on IDL pointer types
+
+- support converting structs to tuples in Python rather than objects
+- convert structs with a single mattering member to that member directly, e.g.:
+ struct bar {
+ int size;
+ [size_is(size)] uint32 *array;
+ };
+
+ should be converted to an array of uint32's
+
+- python: fill in size members automatically in some places if the struct isn't being returned
+ (so we don't have to cope with the array growing)
diff --git a/source4/pidl/config.mk b/source4/pidl/config.mk
index 0d36473ade..07c8647ecd 100644
--- a/source4/pidl/config.mk
+++ b/source4/pidl/config.mk
@@ -1,37 +1,31 @@
-pidl/Makefile: pidl/Makefile.PL
- cd pidl && $(PERL) Makefile.PL
+PIDL = $(PERL) $(pidldir)/pidl
-pidl-testcov: pidl/Makefile
- cd pidl && cover -test
+$(pidldir)/Makefile: $(pidldir)/Makefile.PL
+ cd $(pidldir) && $(PERL) Makefile.PL PREFIX=$(prefix)
-installpidl:: pidl/Makefile
- $(MAKE) -C pidl install_vendor PREFIX=$(prefix)
+pidl-testcov: $(pidldir)/Makefile
+ cd $(pidldir) && cover -test
+
+installpidl:: $(pidldir)/Makefile
+ $(MAKE) -C $(pidldir) install_vendor VENDORPREFIX=$(prefix) \
+ INSTALLVENDORLIB=$(datarootdir)/perl5 \
+ INSTALLVENDORBIN=$(bindir) \
+ INSTALLVENDORSCRIPT=$(bindir) \
+ INSTALLVENDORMAN1DIR=$(mandir)/man1 \
+ INSTALLVENDORMAN3DIR=$(mandir)/man3
ifeq ($(HAVE_PERL_EXTUTILS_MAKEMAKER),1)
install:: installpidl
endif
-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
+$(pidldir)/lib/Parse/Pidl/IDL.pm: $(pidldir)/idl.yp
+ -$(YAPP) -m 'Parse::Pidl::IDL' -o $(pidldir)/lib/Parse/Pidl/IDL.pm $(pidldir)/idl.yp ||\
+ touch $(pidldir)/lib/Parse/Pidl/IDL.pm
-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
+$(pidldir)/lib/Parse/Pidl/Expr.pm: $(pidldir)/idl.yp
+ -$(YAPP) -m 'Parse::Pidl::Expr' -o $(pidldir)/lib/Parse/Pidl/Expr.pm $(pidldir)/expr.yp ||\
+ touch $(pidldir)/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/NDR.pm b/source4/pidl/lib/Parse/Pidl/NDR.pm
index 86ed1a8d10..33e5ad3196 100644
--- a/source4/pidl/lib/Parse/Pidl/NDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/NDR.pm
@@ -866,6 +866,7 @@ my %property_list = (
"nosize" => ["FUNCTION", "TYPEDEF"],
"noprint" => ["FUNCTION", "TYPEDEF"],
"noejs" => ["FUNCTION", "TYPEDEF"],
+ "todo" => ["FUNCTION"],
# union
"switch_is" => ["ELEMENT"],
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm b/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
index 7a2575b897..87ed29b54e 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
@@ -9,7 +9,7 @@ package Parse::Pidl::Samba3::ClientNDR;
use Exporter;
@ISA = qw(Exporter);
-@EXPORT_OK = qw(ParseFunction $res $res_hdr);
+@EXPORT_OK = qw(ParseFunction $res $res_hdr ParseOutputArgument);
use strict;
use Parse::Pidl qw(fatal warning);
@@ -73,6 +73,40 @@ sub HeaderProperties($$)
}
}
+sub ParseOutputArgument($$$)
+{
+ my ($self, $fn, $e) = @_;
+ my $level = 0;
+
+ fatal($e->{ORIGINAL}, "[out] argument is not a pointer or array") if ($e->{LEVELS}[0]->{TYPE} ne "POINTER" and $e->{LEVELS}[0]->{TYPE} ne "ARRAY");
+
+ if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
+ $level = 1;
+ if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
+ $self->pidl("if ($e->{NAME} && r.out.$e->{NAME}) {");
+ $self->indent;
+ }
+ }
+
+ if ($e->{LEVELS}[$level]->{TYPE} eq "ARRAY") {
+ # This is a call to GenerateFunctionInEnv intentionally.
+ # Since the data is being copied into a user-provided data
+ # structure, the user should be able to know the size beforehand
+ # to allocate a structure of the right size.
+ my $env = GenerateFunctionInEnv($fn, "r.");
+ my $size_is = ParseExpr($e->{LEVELS}[$level]->{SIZE_IS}, $env, $e->{ORIGINAL});
+ $self->pidl("memcpy($e->{NAME}, r.out.$e->{NAME}, $size_is * sizeof(*$e->{NAME}));");
+ } else {
+ $self->pidl("*$e->{NAME} = *r.out.$e->{NAME};");
+ }
+
+ if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
+ if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
+ $self->deindent;
+ $self->pidl("}");
+ }
+ }
+}
sub ParseFunction($$$)
{
@@ -147,36 +181,9 @@ sub ParseFunction($$$)
$self->pidl("/* Return variables */");
foreach my $e (@{$fn->{ELEMENTS}}) {
next unless (grep(/out/, @{$e->{DIRECTION}}));
- my $level = 0;
- fatal($e->{ORIGINAL}, "[out] argument is not a pointer or array") if ($e->{LEVELS}[0]->{TYPE} ne "POINTER" and $e->{LEVELS}[0]->{TYPE} ne "ARRAY");
-
- if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
- $level = 1;
- if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
- $self->pidl("if ($e->{NAME} && r.out.$e->{NAME}) {");
- $self->indent;
- }
- }
+ $self->ParseOutputArgument($fn, $e);
- if ($e->{LEVELS}[$level]->{TYPE} eq "ARRAY") {
- # This is a call to GenerateFunctionInEnv intentionally.
- # Since the data is being copied into a user-provided data
- # structure, the user should be able to know the size beforehand
- # to allocate a structure of the right size.
- my $env = GenerateFunctionInEnv($fn, "r.");
- my $size_is = ParseExpr($e->{LEVELS}[$level]->{SIZE_IS}, $env, $e->{ORIGINAL});
- $self->pidl("memcpy($e->{NAME}, r.out.$e->{NAME}, $size_is);");
- } else {
- $self->pidl("*$e->{NAME} = *r.out.$e->{NAME};");
- }
-
- if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
- if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
- $self->deindent;
- $self->pidl("}");
- }
- }
}
$self->pidl("");
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
index e9c158e933..f8209be654 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
@@ -7,6 +7,7 @@
package Parse::Pidl::Samba4::NDR::Client;
use Parse::Pidl::Samba4 qw(choose_header is_intree);
+use Parse::Pidl::Util qw(has_property);
use vars qw($VERSION);
$VERSION = '0.01';
@@ -15,30 +16,45 @@ use strict;
my($res,$res_hdr);
-#####################################################################
-# parse a function
-sub ParseFunction($$)
+sub ParseFunctionSend($$$)
{
- my ($interface, $fn) = @_;
- my $name = $fn->{NAME};
+ my ($interface, $fn, $name) = @_;
my $uname = uc $name;
- $res_hdr .= "\nstruct rpc_request *dcerpc_$name\_send(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r);
-NTSTATUS dcerpc_$name(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r);
-";
+ my $proto = "struct rpc_request *dcerpc_$name\_send(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r)";
- $res .= "
-struct rpc_request *dcerpc_$name\_send(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r)
-{
+ $res_hdr .= "\n$proto;\n";
+
+ $res .= "$proto\n{\n";
+
+ if (has_property($fn, "todo")) {
+ $res .= "\treturn NULL;\n";
+ } else {
+ $res .= "
if (p->conn->flags & DCERPC_DEBUG_PRINT_IN) {
NDR_PRINT_IN_DEBUG($name, r);
}
return dcerpc_ndr_request_send(p, NULL, &ndr_table_$interface->{NAME}, NDR_$uname, mem_ctx, r);
+";
+ }
+
+ $res .= "}\n\n";
}
-NTSTATUS dcerpc_$name(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r)
+sub ParseFunctionSync($$$)
{
+ my ($interface, $fn, $name) = @_;
+
+ my $proto = "NTSTATUS dcerpc_$name(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *r)";
+
+ $res_hdr .= "\n$proto;\n";
+ $res .= "$proto\n{\n";
+
+ if (has_property($fn, "todo")) {
+ $res .= "\treturn NT_STATUS_NOT_IMPLEMENTED;\n";
+ } else {
+ $res .= "
struct rpc_request *req;
NTSTATUS status;
@@ -58,8 +74,20 @@ NTSTATUS dcerpc_$name(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $name *
$res .=
"
return status;
-}
";
+ }
+
+ $res .= "}\n\n";
+}
+
+#####################################################################
+# parse a function
+sub ParseFunction($$)
+{
+ my ($interface, $fn) = @_;
+
+ ParseFunctionSend($interface, $fn, $fn->{NAME});
+ ParseFunctionSync($interface, $fn, $fn->{NAME});
}
my %done;
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index a959dc84f6..0d1806a0fa 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -2190,6 +2190,26 @@ sub ParseFunctionPull($$)
$self->pidl("");
}
+sub AuthServiceStruct($$$)
+{
+ my ($self, $ifacename, $authservice) = @_;
+ my @a = split /,/, $authservice;
+ my $authservice_count = $#a + 1;
+
+ $self->pidl("static const char * const $ifacename\_authservice_strings[] = {");
+ foreach my $ap (@a) {
+ $self->pidl("\t$ap, ");
+ }
+ $self->pidl("};");
+ $self->pidl("");
+
+ $self->pidl("static const struct ndr_interface_string_array $ifacename\_authservices = {");
+ $self->pidl("\t.count\t= $authservice_count,");
+ $self->pidl("\t.names\t= $ifacename\_authservice_strings");
+ $self->pidl("};");
+ $self->pidl("");
+}
+
#####################################################################
# produce a function call table
sub FunctionTable($$)
@@ -2237,21 +2257,8 @@ sub FunctionTable($$)
$interface->{PROPERTIES}->{authservice} = "\"host\"";
}
- my @a = split /,/, $interface->{PROPERTIES}->{authservice};
- my $authservice_count = $#a + 1;
-
- $self->pidl("static const char * const $interface->{NAME}\_authservice_strings[] = {");
- foreach my $ap (@a) {
- $self->pidl("\t$ap, ");
- }
- $self->pidl("};");
- $self->pidl("");
-
- $self->pidl("static const struct ndr_interface_string_array $interface->{NAME}\_authservices = {");
- $self->pidl("\t.count\t= $endpoint_count,");
- $self->pidl("\t.names\t= $interface->{NAME}\_authservice_strings");
- $self->pidl("};");
- $self->pidl("");
+ $self->AuthServiceStruct($interface->{NAME},
+ $interface->{PROPERTIES}->{authservice});
$self->pidl("\nconst struct ndr_interface_table ndr_table_$interface->{NAME} = {");
$self->pidl("\t.name\t\t= \"$interface->{NAME}\",");
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 2475925377..440b1bff97 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -21,7 +21,7 @@ $VERSION = '0.01';
sub new($) {
my ($class) = @_;
my $self = { res => "", res_hdr => "", tabs => "", constants => {},
- module_methods => []};
+ module_methods => [], module_objects => [], module_types => []};
bless($self, $class);
}
@@ -163,46 +163,35 @@ sub FromPythonToUnionFunction($$$$$)
$self->pidl("return ret;");
}
-sub PythonStruct($$$$)
+sub PythonStruct($$$$$$)
{
- my ($self, $name, $cname, $d) = @_;
+ my ($self, $modulename, $prettyname, $name, $cname, $d) = @_;
my $env = GenerateStructEnv($d, "object");
$self->pidl("");
- $self->pidl("static PyObject *py_$name\_getattr(PyObject *obj, char *name)");
- $self->pidl("{");
- $self->indent;
+ my $getsetters = "NULL";
+
if ($#{$d->{ELEMENTS}} > -1) {
- $self->pidl("$cname *object = py_talloc_get_ptr(obj);");
foreach my $e (@{$d->{ELEMENTS}}) {
- $self->pidl("if (!strcmp(name, \"$e->{NAME}\")) {");
my $varname = "object->$e->{NAME}";
+ $self->pidl("static PyObject *py_$name\_get_$e->{NAME}(PyObject *obj, void *closure)");
+ $self->pidl("{");
$self->indent;
+ $self->pidl("$cname *object = py_talloc_get_ptr(obj);");
$self->pidl("PyObject *py_$e->{NAME};");
$self->ConvertObjectToPython("py_talloc_get_mem_ctx(obj)", $env, $e, $varname, "py_$e->{NAME}");
$self->pidl("return py_$e->{NAME};");
$self->deindent;
$self->pidl("}");
- }
- }
- $self->pidl("PyErr_SetString(PyExc_AttributeError, \"no such attribute\");");
- $self->pidl("return NULL;");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
+ $self->pidl("");
- $self->pidl("static int py_$name\_setattr(PyObject *py_obj, char *name, PyObject *value)");
- $self->pidl("{");
- $self->indent;
- if ($#{$d->{ELEMENTS}} > -1) {
- $self->pidl("$cname *object = py_talloc_get_ptr(py_obj);");
- my $mem_ctx = "py_talloc_get_mem_ctx(py_obj)";
- foreach my $e (@{$d->{ELEMENTS}}) {
- $self->pidl("if (!strcmp(name, \"$e->{NAME}\")) {");
- my $varname = "object->$e->{NAME}";
+ $self->pidl("static int py_$name\_set_$e->{NAME}(PyObject *py_obj, PyObject *value, void *closure)");
+ $self->pidl("{");
$self->indent;
+ $self->pidl("$cname *object = py_talloc_get_ptr(py_obj);");
+ my $mem_ctx = "py_talloc_get_mem_ctx(py_obj)";
my $l = $e->{LEVELS}[0];
my $nl = GetNextLevel($e, $l);
if ($l->{TYPE} eq "POINTER" and
@@ -214,52 +203,74 @@ sub PythonStruct($$$$)
$self->pidl("return 0;");
$self->deindent;
$self->pidl("}");
+ $self->pidl("");
}
+
+ $getsetters = "py_$name\_getsetters";
+ $self->pidl("static PyGetSetDef ".$getsetters."[] = {");
+ $self->indent;
+ foreach my $e (@{$d->{ELEMENTS}}) {
+ $self->pidl("{ discard_const_p(char, \"$e->{NAME}\"), py_$name\_get_$e->{NAME}, py_$name\_set_$e->{NAME} },");
+ }
+ $self->pidl("{ NULL }");
+ $self->deindent;
+ $self->pidl("};");
+ $self->pidl("");
}
- $self->pidl("PyErr_SetString(PyExc_AttributeError, \"no such attribute\");");
- $self->pidl("return -1;");
+
+ $self->pidl("static PyObject *py_$name\_new(PyTypeObject *self, PyObject *args, PyObject *kwargs)");
+ $self->pidl("{");
+ $self->indent;
+ $self->pidl("$cname *ret = talloc_zero(NULL, $cname);");
+ $self->pidl("return py_talloc_import(&$name\_Type, ret);");
$self->deindent;
$self->pidl("}");
+
$self->pidl("");
$self->pidl_hdr("PyAPI_DATA(PyTypeObject) $name\_Type;\n");
$self->pidl_hdr("#define $name\_Check(op) PyObject_TypeCheck(op, &$name\_Type)\n");
$self->pidl_hdr("#define $name\_CheckExact(op) ((op)->ob_type == &$name\_Type)\n");
$self->pidl_hdr("\n");
- $self->pidl("PyTypeObject $name\_Type = {");
+ my $docstring = ($self->DocString($d, $name) or "NULL");
+ my $typeobject = "$name\_Type";
+ $self->pidl("PyTypeObject $typeobject = {");
$self->indent;
$self->pidl("PyObject_HEAD_INIT(NULL) 0,");
- $self->pidl(".tp_name = \"$name\",");
+ $self->pidl(".tp_name = \"$modulename.$prettyname\",");
$self->pidl(".tp_basicsize = sizeof(py_talloc_Object),");
$self->pidl(".tp_dealloc = py_talloc_dealloc,");
- $self->pidl(".tp_getattr = py_$name\_getattr,");
- $self->pidl(".tp_setattr = py_$name\_setattr,");
+ $self->pidl(".tp_getset = $getsetters,");
$self->pidl(".tp_repr = py_talloc_default_repr,");
+ $self->pidl(".tp_doc = $docstring,");
+ $self->pidl(".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,");
+ $self->pidl(".tp_new = py_$name\_new,");
$self->deindent;
$self->pidl("};");
$self->pidl("");
- my $py_fnname = "py_$name";
- $self->pidl("static PyObject *$py_fnname(PyObject *self, PyObject *args)");
- $self->pidl("{");
- $self->indent;
- $self->pidl("$cname *ret = talloc_zero(NULL, $cname);");
- $self->pidl("return py_talloc_import(&$name\_Type, ret);");
- $self->deindent;
- $self->pidl("}");
- $self->pidl("");
+ return "&$typeobject";
+}
- return $py_fnname;
+sub get_metadata_var($)
+{
+ my ($e) = @_;
+ sub get_var($) { my $x = shift; $x =~ s/\*//g; return $x; }
+
+ if (has_property($e, "length_is")) {
+ return get_var($e->{PROPERTIES}->{length_is});
+ } elsif (has_property($e, "size_is")) {
+ return get_var($e->{PROPERTIES}->{size_is});
+ }
+
+ return undef;
}
-sub PythonFunction($$$)
+sub PythonFunctionBody($$$)
{
- my ($self, $fn, $iface) = @_;
+ my ($self, $fn, $iface, $prettyname) = @_;
- $self->pidl("static PyObject *py_$fn->{NAME}(PyObject *self, PyObject *args, PyObject *kwargs)");
- $self->pidl("{");
- $self->indent;
$self->pidl("$iface\_InterfaceObject *iface = ($iface\_InterfaceObject *)self;");
$self->pidl("NTSTATUS status;");
$self->pidl("TALLOC_CTX *mem_ctx = talloc_new(NULL);");
@@ -273,7 +284,23 @@ sub PythonFunction($$$)
my $args_string = "";
my $args_names = "";
+ my $signature = "S.$prettyname(";
+
+ my $metadata_args = { in => {}, out => {} };
+
+ # Determine arguments that are metadata for other arguments (size_is/length_is)
+ foreach my $e (@{$fn->{ELEMENTS}}) {
+ foreach my $dir (@{$e->{DIRECTION}}) {
+ my $main = get_metadata_var($e);
+ if ($main) {
+ $metadata_args->{$dir}->{$main} = $e->{NAME};
+ }
+ }
+ }
+
foreach my $e (@{$fn->{ELEMENTS}}) {
+ next if (($metadata_args->{in}->{$e->{NAME}} and grep(/in/, @{$e->{DIRECTION}})) or
+ ($metadata_args->{out}->{$e->{NAME}}) and grep(/out/, @{$e->{DIRECTION}}));
$self->pidl("PyObject *py_$e->{NAME};");
if (grep(/out/,@{$e->{DIRECTION}})) {
$result_size++;
@@ -282,8 +309,14 @@ sub PythonFunction($$$)
$args_format .= "O";
$args_string .= ", &py_$e->{NAME}";
$args_names .= "\"$e->{NAME}\", ";
+ $signature .= "$e->{NAME}, ";
}
}
+ if (substr($signature, -2) eq ", ") {
+ $signature = substr($signature, 0, -2);
+ }
+ $signature.= ") -> ";
+
$self->pidl("const char *kwnames[] = {");
$self->indent;
$self->pidl($args_names . "NULL");
@@ -296,14 +329,27 @@ sub PythonFunction($$$)
$self->pidl("return NULL;");
$self->deindent;
$self->pidl("}");
+ $self->pidl("");
if ($fn->{RETURN_TYPE}) {
$result_size++ unless ($fn->{RETURN_TYPE} eq "WERROR" or $fn->{RETURN_TYPE} eq "NTSTATUS");
}
+ my $fail = "talloc_free(mem_ctx); return NULL;";
foreach my $e (@{$fn->{ELEMENTS}}) {
- if (grep(/in/,@{$e->{DIRECTION}})) {
- $self->ConvertObjectFromPython($env, "mem_ctx", $e, "py_$e->{NAME}", "r->in.$e->{NAME}", "talloc_free(mem_ctx); return NULL;");
+ next unless (grep(/in/,@{$e->{DIRECTION}}));
+ if ($metadata_args->{in}->{$e->{NAME}}) {
+ my $py_var = "py_".$metadata_args->{in}->{$e->{NAME}};
+ $self->pidl("PY_CHECK_TYPE(PyList, $py_var, $fail);");
+ my $val = "PyList_Size($py_var)";
+ if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
+ $self->pidl("r->in.$e->{NAME} = talloc_ptrtype(mem_ctx, r->in.$e->{NAME});");
+ $self->pidl("*r->in.$e->{NAME} = $val;");
+ } else {
+ $self->pidl("r->in.$e->{NAME} = $val;");
+ }
+ } else {
+ $self->ConvertObjectFromPython($env, "mem_ctx", $e, "py_$e->{NAME}", "r->in.$e->{NAME}", $fail);
}
}
$self->pidl("status = dcerpc_$fn->{NAME}(iface->pipe, mem_ctx, r);");
@@ -314,17 +360,23 @@ sub PythonFunction($$$)
if ($result_size > 1) {
$self->pidl("result = PyTuple_New($result_size);");
+ $signature .= "(";
+ } elsif ($result_size == 0) {
+ $signature .= "None";
}
foreach my $e (@{$fn->{ELEMENTS}}) {
+ next if ($metadata_args->{out}->{$e->{NAME}});
my $py_name = "py_$e->{NAME}";
if (grep(/out/,@{$e->{DIRECTION}})) {
$self->ConvertObjectToPython("r", $env, $e, "r->out.$e->{NAME}", $py_name);
if ($result_size > 1) {
$self->pidl("PyTuple_SetItem(result, $i, $py_name);");
$i++;
+ $signature .= "$e->{NAME}, ";
} else {
$self->pidl("result = $py_name;");
+ $signature .= $e->{NAME};
}
}
}
@@ -340,13 +392,51 @@ sub PythonFunction($$$)
} else {
$self->pidl("result = $conv;");
}
+ $signature .= "result";
+ }
+
+ if (substr($signature, -2) eq ", ") {
+ $signature = substr($signature, 0, -2);
+ }
+ if ($result_size > 1) {
+ $signature .= ")";
}
$self->pidl("talloc_free(mem_ctx);");
$self->pidl("return result;");
+
+ return $signature;
+}
+
+sub PythonFunction($$$)
+{
+ my ($self, $fn, $iface, $prettyname) = @_;
+
+ my $fnname = "py_$fn->{NAME}";
+ my $docstring = $self->DocString($fn, $fn->{NAME});
+
+ $self->pidl("static PyObject *$fnname(PyObject *self, PyObject *args, PyObject *kwargs)");
+ $self->pidl("{");
+ $self->indent;
+ if (has_property($fn, "todo")) {
+ $self->pidl("PyErr_SetString(PyExc_NotImplementedError, \"No marshalling code available yet for $prettyname\");");
+ $self->pidl("return NULL;");
+ unless ($docstring) { $docstring = "NULL"; }
+ } else {
+ my $signature = $self->PythonFunctionBody($fn, $iface, $prettyname);
+
+ if ($docstring) {
+ $docstring = "\"$signature\\n\\n\"$docstring";
+ } else {
+ $docstring = "\"$signature\"";
+ }
+ }
+
$self->deindent;
$self->pidl("}");
$self->pidl("");
+
+ return ($fnname, $docstring);
}
sub handle_werror($$$$)
@@ -377,9 +467,9 @@ sub handle_ntstatus($$$$)
$self->pidl("");
}
-sub PythonType($$$)
+sub PythonType($$$$)
{
- my ($self, $d, $interface, $basename) = @_;
+ my ($self, $modulename, $d, $interface, $basename) = @_;
my $actual_ctype = $d;
if ($actual_ctype->{TYPE} eq "TYPEDEF") {
@@ -387,19 +477,20 @@ sub PythonType($$$)
}
if ($actual_ctype->{TYPE} eq "STRUCT") {
- my $py_fnname;
- if ($d->{TYPE} eq "STRUCT") {
- $py_fnname = $self->PythonStruct($d->{NAME}, mapTypeName($d), $d);
- } else {
- $py_fnname = $self->PythonStruct($d->{NAME}, mapTypeName($d), $d->{DATA});
- }
-
+ my $typeobject;
my $fn_name = $d->{NAME};
$fn_name =~ s/^$interface->{NAME}_//;
$fn_name =~ s/^$basename\_//;
- $self->register_module_method($fn_name, $py_fnname, "METH_NOARGS", "NULL");
+
+ if ($d->{TYPE} eq "STRUCT") {
+ $typeobject = $self->PythonStruct($modulename, $fn_name, $d->{NAME}, mapTypeName($d), $d);
+ } else {
+ $typeobject = $self->PythonStruct($modulename, $fn_name, $d->{NAME}, mapTypeName($d), $d->{DATA});
+ }
+
+ $self->register_module_typeobject($fn_name, $typeobject);
}
if ($d->{TYPE} eq "ENUM" or $d->{TYPE} eq "BITMAP") {
@@ -429,6 +520,18 @@ sub PythonType($$$)
}
}
+sub DocString($$$)
+{
+ my ($self, $d, $name) = @_;
+ if (has_property($d, "helpstring")) {
+ my $docstring = uc("py_doc_$name");
+ $self->pidl("#define $docstring ".has_property($d, "helpstring"));
+ return $docstring;
+ }
+
+ return undef;
+}
+
sub Interface($$$)
{
my($self,$interface,$basename) = @_;
@@ -443,7 +546,7 @@ sub Interface($$$)
foreach my $d (@{$interface->{TYPES}}) {
next if has_property($d, "nopython");
- $self->PythonType($d, $interface, $basename);
+ $self->PythonType($basename, $d, $interface, $basename);
}
if (defined $interface->{PROPERTIES}->{uuid}) {
@@ -457,25 +560,27 @@ sub Interface($$$)
$self->pidl("");
+ my @fns = ();
+
foreach my $d (@{$interface->{FUNCTIONS}}) {
next if not defined($d->{OPNUM});
next if has_property($d, "nopython");
- $self->PythonFunction($d, $interface->{NAME});
- }
+ my $prettyname = $d->{NAME};
- $self->pidl("static PyMethodDef interface_$interface->{NAME}\_methods[] = {");
- $self->indent;
- foreach my $d (@{$interface->{FUNCTIONS}}) {
- next if not defined($d->{OPNUM});
- next if has_property($d, "nopython");
+ $prettyname =~ s/^$interface->{NAME}_//;
+ $prettyname =~ s/^$basename\_//;
- my $fn_name = $d->{NAME};
+ my ($fnname, $fndocstring) = $self->PythonFunction($d, $interface->{NAME}, $prettyname);
- $fn_name =~ s/^$interface->{NAME}_//;
- $fn_name =~ s/^$basename\_//;
+ push (@fns, [$fnname, $prettyname, $fndocstring]);
+ }
- $self->pidl("{ \"$fn_name\", (PyCFunction)py_$d->{NAME}, METH_VARARGS|METH_KEYWORDS, NULL },");
+ $self->pidl("static PyMethodDef interface_$interface->{NAME}\_methods[] = {");
+ $self->indent;
+ foreach my $d (@fns) {
+ my ($c_fn, $prettyname, $docstring) = @$d;
+ $self->pidl("{ \"$prettyname\", (PyCFunction)$c_fn, METH_VARARGS|METH_KEYWORDS, $docstring },");
}
$self->pidl("{ NULL, NULL, 0, NULL }");
$self->deindent;
@@ -492,37 +597,16 @@ sub Interface($$$)
$self->pidl("}");
$self->pidl("");
- $self->pidl("static PyObject *interface_$interface->{NAME}_getattr(PyObject *obj, char *name)");
- $self->pidl("{");
- $self->indent;
- $self->pidl("return Py_FindMethod(interface_$interface->{NAME}\_methods, obj, name);");
- $self->deindent;
- $self->pidl("}");
-
- $self->pidl("");
-
- $self->pidl("PyTypeObject $interface->{NAME}_InterfaceType = {");
- $self->indent;
- $self->pidl("PyObject_HEAD_INIT(NULL) 0,");
- $self->pidl(".tp_name = \"$interface->{NAME}\",");
- $self->pidl(".tp_basicsize = sizeof($interface->{NAME}_InterfaceObject),");
- $self->pidl(".tp_dealloc = interface_$interface->{NAME}_dealloc,");
- $self->pidl(".tp_getattr = interface_$interface->{NAME}_getattr,");
- $self->deindent;
- $self->pidl("};");
-
- $self->pidl("");
-
- $self->register_module_method($interface->{NAME}, "interface_$interface->{NAME}", "METH_VARARGS|METH_KEYWORDS", "NULL");
- $self->pidl("static PyObject *interface_$interface->{NAME}(PyObject *self, PyObject *args, PyObject *kwargs)");
+ $self->pidl("static PyObject *interface_$interface->{NAME}_new(PyTypeObject *self, PyObject *args, PyObject *kwargs)");
$self->pidl("{");
$self->indent;
$self->pidl("$interface->{NAME}_InterfaceObject *ret;");
$self->pidl("const char *binding_string;");
$self->pidl("struct cli_credentials *credentials;");
$self->pidl("struct loadparm_context *lp_ctx = NULL;");
- $self->pidl("PyObject *py_lp_ctx = NULL, *py_credentials = Py_None;");
+ $self->pidl("PyObject *py_lp_ctx = Py_None, *py_credentials = Py_None;");
$self->pidl("TALLOC_CTX *mem_ctx = NULL;");
+ $self->pidl("struct event_context *event_ctx;");
$self->pidl("NTSTATUS status;");
$self->pidl("");
$self->pidl("const char *kwnames[] = {");
@@ -533,14 +617,12 @@ sub Interface($$$)
$self->pidl("extern struct loadparm_context *lp_from_py_object(PyObject *py_obj);");
$self->pidl("extern struct cli_credentials *cli_credentials_from_py_object(PyObject *py_obj);");
$self->pidl("");
- $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, \"sO|O:$interface->{NAME}\", discard_const_p(char *, kwnames), &binding_string, &py_lp_ctx, &py_credentials)) {");
+ $self->pidl("if (!PyArg_ParseTupleAndKeywords(args, kwargs, \"s|OO:$interface->{NAME}\", discard_const_p(char *, kwnames), &binding_string, &py_lp_ctx, &py_credentials)) {");
$self->indent;
$self->pidl("return NULL;");
$self->deindent;
$self->pidl("}");
$self->pidl("");
- $self->pidl("if (py_lp_ctx != NULL) {");
- $self->indent;
$self->pidl("lp_ctx = lp_from_py_object(py_lp_ctx);");
$self->pidl("if (lp_ctx == NULL) {");
$self->indent;
@@ -548,8 +630,6 @@ sub Interface($$$)
$self->pidl("return NULL;");
$self->deindent;
$self->pidl("}");
- $self->deindent;
- $self->pidl("}");
$self->pidl("");
$self->pidl("credentials = cli_credentials_from_py_object(py_credentials);");
@@ -562,9 +642,11 @@ sub Interface($$$)
$self->pidl("ret = PyObject_New($interface->{NAME}_InterfaceObject, &$interface->{NAME}_InterfaceType);");
$self->pidl("");
+ $self->pidl("event_ctx = event_context_init(mem_ctx);");
+ $self->pidl("");
$self->pidl("status = dcerpc_pipe_connect(NULL, &ret->pipe, binding_string, ");
- $self->pidl(" &ndr_table_$interface->{NAME}, credentials, NULL, lp_ctx);");
+ $self->pidl(" &ndr_table_$interface->{NAME}, credentials, event_ctx, lp_ctx);");
$self->handle_ntstatus("status", "NULL", "mem_ctx");
$self->pidl("ret->pipe->conn->flags |= DCERPC_NDR_REF_ALLOC;");
@@ -574,6 +656,38 @@ sub Interface($$$)
$self->pidl("}");
$self->pidl("");
+
+ my $signature =
+"\"$interface->{NAME}(binding, lp_ctx=None, credentials=None) -> connection\\n\"
+\"\\n\"
+\"binding should be a DCE/RPC binding string (for example: ncacn_ip_tcp:127.0.0.1)\\n\"
+\"lp_ctx should be a path to a smb.conf file or a param.LoadParm object\\n\"
+\"credentials should be a credentials.Credentials object.\\n\\n\"";
+
+ my $docstring = $self->DocString($interface, $interface->{NAME});
+
+ if ($docstring) {
+ $docstring = "$signature$docstring";
+ } else {
+ $docstring = $signature;
+ }
+
+ $self->pidl("PyTypeObject $interface->{NAME}_InterfaceType = {");
+ $self->indent;
+ $self->pidl("PyObject_HEAD_INIT(NULL) 0,");
+ $self->pidl(".tp_name = \"$basename.$interface->{NAME}\",");
+ $self->pidl(".tp_basicsize = sizeof($interface->{NAME}_InterfaceObject),");
+ $self->pidl(".tp_dealloc = interface_$interface->{NAME}_dealloc,");
+ $self->pidl(".tp_methods = interface_$interface->{NAME}_methods,");
+ $self->pidl(".tp_doc = $docstring,");
+ $self->pidl(".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,");
+ $self->pidl(".tp_new = interface_$interface->{NAME}_new,");
+ $self->deindent;
+ $self->pidl("};");
+
+ $self->pidl("");
+
+ $self->register_module_typeobject($interface->{NAME}, "&$interface->{NAME}_InterfaceType");
}
$self->pidl_hdr("\n");
@@ -587,6 +701,22 @@ sub register_module_method($$$$$)
push (@{$self->{module_methods}}, [$fn_name, $pyfn_name, $flags, $doc])
}
+sub register_module_typeobject($$$)
+{
+ my ($self, $name, $py_name) = @_;
+
+ $self->register_module_object($name, "(PyObject *)$py_name");
+
+ push (@{$self->{module_types}}, [$name, $py_name])
+}
+
+sub register_module_object($$$)
+{
+ my ($self, $name, $py_name) = @_;
+
+ push (@{$self->{module_objects}}, [$name, $py_name])
+}
+
sub assign($$$)
{
my ($self, $dest, $src) = @_;
@@ -828,16 +958,15 @@ sub ConvertObjectToPythonLevel($$$$$)
$self->pidl("}");
}
} elsif ($l->{TYPE} eq "ARRAY") {
- if (is_charset_array($e, $l)) {
+ my $pl = GetPrevLevel($e, $l);
+ if ($pl && $pl->{TYPE} eq "POINTER") {
$var_name = get_pointer_to($var_name);
+ }
+
+ if (is_charset_array($e, $l)) {
# FIXME: Use Unix charset setting rather than utf-8
$self->pidl("$py_var = PyUnicode_Decode($var_name, strlen($var_name), \"utf-8\", \"ignore\");");
} else {
- my $pl = GetPrevLevel($e, $l);
- if ($pl && $pl->{TYPE} eq "POINTER") {
- $var_name = get_pointer_to($var_name);
- }
-
die("No SIZE_IS for array $var_name") unless (defined($l->{SIZE_IS}));
my $length = $l->{SIZE_IS};
if (defined($l->{LENGTH_IS})) {
@@ -901,6 +1030,7 @@ sub Parse($$$$$)
#include \"librpc/rpc/dcerpc.h\"
#include \"scripting/python/pytalloc.h\"
#include \"scripting/python/pyrpc.h\"
+#include \"lib/events/events.h\"
#include \"$hdr\"
#include \"$ndr_hdr\"
#include \"$py_hdr\"
@@ -929,7 +1059,20 @@ sub Parse($$$$$)
$self->pidl("{");
$self->indent;
$self->pidl("PyObject *m;");
- $self->pidl("m = Py_InitModule(\"$basename\", $basename\_methods);");
+ $self->pidl("");
+
+ foreach (@{$self->{module_types}}) {
+ my ($object_name, $c_name) = @$_;
+ $self->pidl("if (PyType_Ready($c_name) < 0)");
+ $self->pidl("\treturn;");
+ }
+
+ $self->pidl("");
+
+ $self->pidl("m = Py_InitModule3(\"$basename\", $basename\_methods, \"$basename DCE/RPC\");");
+ $self->pidl("if (m == NULL)");
+ $self->pidl("\treturn;");
+ $self->pidl("");
foreach my $name (keys %{$self->{constants}}) {
my $py_obj;
my ($ctype, $cvar) = @{$self->{constants}->{$name}};
@@ -943,6 +1086,13 @@ sub Parse($$$$$)
$self->pidl("PyModule_AddObject(m, \"$name\", $py_obj);");
}
+
+ foreach (@{$self->{module_objects}}) {
+ my ($object_name, $c_name) = @$_;
+ $self->pidl("Py_INCREF($c_name);");
+ $self->pidl("PyModule_AddObject(m, \"$object_name\", $c_name);");
+ }
+
$self->deindent;
$self->pidl("}");
return ($self->{res_hdr}, $self->{res});
diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl
index a14111961f..114ca01cfa 100755
--- a/source4/pidl/tests/samba-ndr.pl
+++ b/source4/pidl/tests/samba-ndr.pl
@@ -4,7 +4,7 @@
use strict;
use warnings;
-use Test::More tests => 30;
+use Test::More tests => 31;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
@@ -277,3 +277,17 @@ $generator->ParseElementPrint({ NAME => "x", TYPE => "uint32", REPRESENTATION_TY
PROPERTIES => { value => "23" },
LEVELS => [ { TYPE => "DATA", DATA_TYPE => "uint32"} ]}, "var", { "x" => "r->foobar" } );
is($generator->{res}, "ndr_print_uint32(ndr, \"x\", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?23:var);\n");
+
+$generator = new Parse::Pidl::Samba4::NDR::Parser();
+$generator->AuthServiceStruct("bridge", "\"rot13\",\"onetimepad\"");
+is($generator->{res}, "static const char * const bridge_authservice_strings[] = {
+ \"rot13\",
+ \"onetimepad\",
+};
+
+static const struct ndr_interface_string_array bridge_authservices = {
+ .count = 2,
+ .names = bridge_authservice_strings
+};
+
+");
diff --git a/source4/pidl/tests/samba3-cli.pl b/source4/pidl/tests/samba3-cli.pl
index f5b51b7d34..80725d28cf 100755
--- a/source4/pidl/tests/samba3-cli.pl
+++ b/source4/pidl/tests/samba3-cli.pl
@@ -4,12 +4,12 @@
use strict;
use warnings;
-use Test::More tests => 8;
+use Test::More tests => 9;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
use Parse::Pidl::Util qw(MyDumper);
-use Parse::Pidl::Samba3::ClientNDR qw(ParseFunction);
+use Parse::Pidl::Samba3::ClientNDR qw(ParseFunction ParseOutputArgument);
use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv);
# Make sure GenerateFunctionInEnv and GenerateFunctionOutEnv work
@@ -117,3 +117,12 @@ is($x->{res},
}
");
+
+$x = new Parse::Pidl::Samba3::ClientNDR();
+
+$fn = { NAME => "bar", ELEMENTS => [ ], RETURN_TYPE => "WERROR" };
+my $e = { NAME => "foo", ORIGINAL => { FILE => "f", LINE => -1 },
+ LEVELS => [ { TYPE => "ARRAY", SIZE_IS => "mysize" }, { TYPE => "DATA", DATA_TYPE => "int" } ]};
+
+$x->ParseOutputArgument($fn, $e);
+is($x->{res}, "memcpy(foo, r.out.foo, mysize * sizeof(*foo));\n");
diff --git a/source4/rpc_server/common/server_info.c b/source4/rpc_server/common/server_info.c
index 646879ad0d..da034e85ea 100644
--- a/source4/rpc_server/common/server_info.c
+++ b/source4/rpc_server/common/server_info.c
@@ -82,7 +82,7 @@ uint32_t dcesrv_common_get_version_build(TALLOC_CTX *mem_ctx, struct loadparm_co
}
/* This hardcoded value should go into a ldb database! */
-uint32_t dcesrv_common_get_server_type(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
+uint32_t dcesrv_common_get_server_type(TALLOC_CTX *mem_ctx, struct event_context *event_ctx, struct dcesrv_context *dce_ctx)
{
int default_server_announce = 0;
default_server_announce |= SV_TYPE_WORKSTATION;
@@ -118,7 +118,7 @@ uint32_t dcesrv_common_get_server_type(TALLOC_CTX *mem_ctx, struct dcesrv_contex
break;
}
/* open main ldb */
- samctx = samdb_connect(tmp_ctx, dce_ctx->lp_ctx, anonymous_session(tmp_ctx, dce_ctx->lp_ctx));
+ samctx = samdb_connect(tmp_ctx, event_ctx, dce_ctx->lp_ctx, anonymous_session(tmp_ctx, event_ctx, dce_ctx->lp_ctx));
if (samctx == NULL) {
DEBUG(2,("Unable to open samdb in determining server announce flags\n"));
} else {
diff --git a/source4/rpc_server/config.mk b/source4/rpc_server/config.mk
index d6d77dd0d9..6b1813544e 100644
--- a/source4/rpc_server/config.mk
+++ b/source4/rpc_server/config.mk
@@ -3,81 +3,82 @@
################################################
# Start SUBSYSTEM DCERPC_COMMON
[SUBSYSTEM::DCERPC_COMMON]
-PRIVATE_PROTO_HEADER = common/proto.h
-OBJ_FILES = \
- common/server_info.o \
- common/share_info.o
#
# End SUBSYSTEM DCERPC_COMMON
################################################
+DCERPC_COMMON_OBJ_FILES = $(addprefix $(rpc_serversrcdir)/common/, server_info.o share_info.o)
+
+$(eval $(call proto_header_template,$(rpc_serversrcdir)/common/proto.h,$(DCERPC_COMMON_OBJ_FILES:.o=.c)))
+
+PUBLIC_HEADERS += $(rpc_serversrcdir)/common/common.h
+
################################################
# Start MODULE dcerpc_rpcecho
[MODULE::dcerpc_rpcecho]
INIT_FUNCTION = dcerpc_server_rpcecho_init
-SUBSYSTEM = dcerpc_server
-OBJ_FILES = \
- echo/rpc_echo.o
+SUBSYSTEM = DCESRV
PRIVATE_DEPENDENCIES = NDR_ECHO
# End MODULE dcerpc_rpcecho
################################################
+dcerpc_rpcecho_OBJ_FILES = $(rpc_serversrcdir)/echo/rpc_echo.o
+
################################################
# Start MODULE dcerpc_epmapper
[MODULE::dcerpc_epmapper]
INIT_FUNCTION = dcerpc_server_epmapper_init
-SUBSYSTEM = dcerpc_server
-OBJ_FILES = \
- epmapper/rpc_epmapper.o
+SUBSYSTEM = DCESRV
PRIVATE_DEPENDENCIES = NDR_EPMAPPER
# End MODULE dcerpc_epmapper
################################################
+dcerpc_epmapper_OBJ_FILES = $(rpc_serversrcdir)/epmapper/rpc_epmapper.o
+
################################################
# Start MODULE dcerpc_remote
[MODULE::dcerpc_remote]
INIT_FUNCTION = dcerpc_server_remote_init
-SUBSYSTEM = dcerpc_server
-OBJ_FILES = \
- remote/dcesrv_remote.o
+SUBSYSTEM = DCESRV
PRIVATE_DEPENDENCIES = \
LIBCLI_SMB NDR_TABLE
# End MODULE dcerpc_remote
################################################
+dcerpc_remote_OBJ_FILES = $(rpc_serversrcdir)/remote/dcesrv_remote.o
+
################################################
# Start MODULE dcerpc_srvsvc
[MODULE::dcerpc_srvsvc]
INIT_FUNCTION = dcerpc_server_srvsvc_init
-PRIVATE_PROTO_HEADER = srvsvc/proto.h
-SUBSYSTEM = dcerpc_server
-OBJ_FILES = \
- srvsvc/dcesrv_srvsvc.o \
- srvsvc/srvsvc_ntvfs.o
+SUBSYSTEM = DCESRV
PRIVATE_DEPENDENCIES = \
DCERPC_COMMON NDR_SRVSVC share
# End MODULE dcerpc_srvsvc
################################################
+
+dcerpc_srvsvc_OBJ_FILES = $(addprefix $(rpc_serversrcdir)/srvsvc/, dcesrv_srvsvc.o srvsvc_ntvfs.o)
+
+$(eval $(call proto_header_template,$(rpc_serversrcdir)/srvsvc/proto.h,$(dcerpc_srvsvc_OBJ_FILES:.o=.c)))
+
################################################
# Start MODULE dcerpc_wkssvc
[MODULE::dcerpc_wkssvc]
INIT_FUNCTION = dcerpc_server_wkssvc_init
-SUBSYSTEM = dcerpc_server
-OBJ_FILES = \
- wkssvc/dcesrv_wkssvc.o
+SUBSYSTEM = DCESRV
PRIVATE_DEPENDENCIES = \
DCERPC_COMMON NDR_WKSSVC
# End MODULE dcerpc_wkssvc
################################################
+dcerpc_wkssvc_OBJ_FILES = $(rpc_serversrcdir)/wkssvc/dcesrv_wkssvc.o
+
################################################
# Start MODULE dcerpc_unixinfo
[MODULE::dcerpc_unixinfo]
INIT_FUNCTION = dcerpc_server_unixinfo_init
-SUBSYSTEM = dcerpc_server
-OBJ_FILES = \
- unixinfo/dcesrv_unixinfo.o
+SUBSYSTEM = DCESRV
PRIVATE_DEPENDENCIES = \
DCERPC_COMMON \
SAMDB \
@@ -87,15 +88,13 @@ PRIVATE_DEPENDENCIES = \
# End MODULE dcerpc_unixinfo
################################################
+dcerpc_unixinfo_OBJ_FILES = $(rpc_serversrcdir)/unixinfo/dcesrv_unixinfo.o
+
################################################
# Start MODULE dcesrv_samr
[MODULE::dcesrv_samr]
INIT_FUNCTION = dcerpc_server_samr_init
-PRIVATE_PROTO_HEADER = samr/proto.h
-SUBSYSTEM = dcerpc_server
-OBJ_FILES = \
- samr/dcesrv_samr.o \
- samr/samr_password.o
+SUBSYSTEM = DCESRV
PRIVATE_DEPENDENCIES = \
SAMDB \
DCERPC_COMMON \
@@ -103,26 +102,28 @@ PRIVATE_DEPENDENCIES = \
# End MODULE dcesrv_samr
################################################
+dcesrv_samr_OBJ_FILES = $(addprefix $(rpc_serversrcdir)/samr/, dcesrv_samr.o samr_password.o)
+
+$(eval $(call proto_header_template,$(rpc_serversrcdir)/samr/proto.h,$(dcesrv_samr_OBJ_FILES:.o=.c)))
+
################################################
# Start MODULE dcerpc_winreg
[MODULE::dcerpc_winreg]
INIT_FUNCTION = dcerpc_server_winreg_init
-SUBSYSTEM = dcerpc_server
+SUBSYSTEM = DCESRV
OUTPUT_TYPE = MERGED_OBJ
-OBJ_FILES = \
- winreg/rpc_winreg.o
PRIVATE_DEPENDENCIES = \
registry NDR_WINREG
# End MODULE dcerpc_winreg
################################################
+dcerpc_winreg_OBJ_FILES = $(rpc_serversrcdir)/winreg/rpc_winreg.o
+
################################################
# Start MODULE dcerpc_netlogon
[MODULE::dcerpc_netlogon]
INIT_FUNCTION = dcerpc_server_netlogon_init
-SUBSYSTEM = dcerpc_server
-OBJ_FILES = \
- netlogon/dcerpc_netlogon.o
+SUBSYSTEM = DCESRV
PRIVATE_DEPENDENCIES = \
DCERPC_COMMON \
SCHANNELDB \
@@ -131,16 +132,13 @@ PRIVATE_DEPENDENCIES = \
# End MODULE dcerpc_netlogon
################################################
+dcerpc_netlogon_OBJ_FILES = $(rpc_serversrcdir)/netlogon/dcerpc_netlogon.o
+
################################################
# Start MODULE dcerpc_lsa
[MODULE::dcerpc_lsarpc]
INIT_FUNCTION = dcerpc_server_lsa_init
-SUBSYSTEM = dcerpc_server
-PRIVATE_PROTO_HEADER= lsa/proto.h
-OBJ_FILES = \
- lsa/dcesrv_lsa.o \
- lsa/lsa_init.o \
- lsa/lsa_lookup.o
+SUBSYSTEM = DCESRV
PRIVATE_DEPENDENCIES = \
SAMDB \
DCERPC_COMMON \
@@ -150,14 +148,17 @@ PRIVATE_DEPENDENCIES = \
# End MODULE dcerpc_lsa
################################################
+dcerpc_lsarpc_OBJ_FILES = $(addprefix $(rpc_serversrcdir)/lsa/, dcesrv_lsa.o lsa_init.o lsa_lookup.o)
+
+$(eval $(call proto_header_template,$(rpc_serversrcdir)/lsa/proto.h,$(dcerpc_lsarpc_OBJ_FILES:.o=.c)))
+
+
################################################
# Start MODULE dcerpc_spoolss
[MODULE::dcerpc_spoolss]
INIT_FUNCTION = dcerpc_server_spoolss_init
-SUBSYSTEM = dcerpc_server
+SUBSYSTEM = DCESRV
OUTPUT_TYPE = MERGED_OBJ
-OBJ_FILES = \
- spoolss/dcesrv_spoolss.o
PRIVATE_DEPENDENCIES = \
DCERPC_COMMON \
NDR_SPOOLSS \
@@ -166,13 +167,13 @@ PRIVATE_DEPENDENCIES = \
# End MODULE dcerpc_spoolss
################################################
+dcerpc_spoolss_OBJ_FILES = $(rpc_serversrcdir)/spoolss/dcesrv_spoolss.o
+
################################################
# Start MODULE dcerpc_drsuapi
[MODULE::dcerpc_drsuapi]
INIT_FUNCTION = dcerpc_server_drsuapi_init
-SUBSYSTEM = dcerpc_server
-OBJ_FILES = \
- drsuapi/dcesrv_drsuapi.o
+SUBSYSTEM = DCESRV
PRIVATE_DEPENDENCIES = \
SAMDB \
DCERPC_COMMON \
@@ -180,27 +181,32 @@ PRIVATE_DEPENDENCIES = \
# End MODULE dcerpc_drsuapi
################################################
+dcerpc_drsuapi_OBJ_FILES = $(rpc_serversrcdir)/drsuapi/dcesrv_drsuapi.o
+
################################################
# Start SUBSYSTEM dcerpc_server
[SUBSYSTEM::dcerpc_server]
-PRIVATE_PROTO_HEADER = dcerpc_server_proto.h
-OBJ_FILES = \
- dcerpc_server.o \
- dcesrv_auth.o \
- dcesrv_mgmt.o \
- handles.o
PRIVATE_DEPENDENCIES = \
LIBCLI_AUTH \
LIBNDR \
dcerpc
-#
+
+dcerpc_server_OBJ_FILES = $(addprefix $(rpc_serversrcdir)/, \
+ dcerpc_server.o \
+ dcesrv_auth.o \
+ dcesrv_mgmt.o \
+ handles.o)
+
+$(eval $(call proto_header_template,$(rpc_serversrcdir)/dcerpc_server_proto.h,$(dcerpc_server_OBJ_FILES:.o=.c)))
+
# End SUBSYSTEM DCERPC
################################################
-PUBLIC_HEADERS += rpc_server/dcerpc_server.h
+PUBLIC_HEADERS += $(rpc_serversrcdir)/dcerpc_server.h
[MODULE::DCESRV]
INIT_FUNCTION = server_service_rpc_init
-OBJ_FILES = service_rpc.o
-SUBSYSTEM = service
+SUBSYSTEM = smbd
PRIVATE_DEPENDENCIES = dcerpc_server
+
+DCESRV_OBJ_FILES = $(rpc_serversrcdir)/service_rpc.o
diff --git a/source4/rpc_server/dcerpc_server.c b/source4/rpc_server/dcerpc_server.c
index beb795ea22..e0351bb259 100644
--- a/source4/rpc_server/dcerpc_server.c
+++ b/source4/rpc_server/dcerpc_server.c
@@ -34,7 +34,6 @@
#include "smbd/service.h"
#include "system/filesys.h"
#include "libcli/security/security.h"
-#include "build.h"
#include "param/param.h"
extern const struct dcesrv_interface dcesrv_mgmt_interface;
@@ -446,6 +445,7 @@ static NTSTATUS dcesrv_fault(struct dcesrv_call_state *call, uint32_t fault_code
{
struct ncacn_packet pkt;
struct data_blob_list_item *rep;
+ uint8_t zeros[4];
NTSTATUS status;
/* setup a bind_ack */
@@ -459,6 +459,9 @@ static NTSTATUS dcesrv_fault(struct dcesrv_call_state *call, uint32_t fault_code
pkt.u.fault.cancel_count = 0;
pkt.u.fault.status = fault_code;
+ ZERO_STRUCT(zeros);
+ pkt.u.fault._pad = data_blob_const(zeros, sizeof(zeros));
+
rep = talloc(call, struct data_blob_list_item);
if (!rep) {
return NT_STATUS_NO_MEMORY;
@@ -685,6 +688,7 @@ static NTSTATUS dcesrv_alter_new_context(struct dcesrv_call_state *call, uint32_
struct dcesrv_connection_context *context;
const struct dcesrv_interface *iface;
struct GUID uuid, *transfer_syntax_uuid;
+ NTSTATUS status;
if_version = call->pkt.u.alter.ctx_list[0].abstract_syntax.if_version;
uuid = call->pkt.u.alter.ctx_list[0].abstract_syntax.uuid;
@@ -718,6 +722,13 @@ static NTSTATUS dcesrv_alter_new_context(struct dcesrv_call_state *call, uint32_
DLIST_ADD(call->conn->contexts, context);
call->context = context;
+ if (iface) {
+ status = iface->bind(call, iface);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ }
+
return NT_STATUS_OK;
}
diff --git a/source4/rpc_server/drsuapi/dcesrv_drsuapi.c b/source4/rpc_server/drsuapi/dcesrv_drsuapi.c
index a97b93a051..e0a222e767 100644
--- a/source4/rpc_server/drsuapi/dcesrv_drsuapi.c
+++ b/source4/rpc_server/drsuapi/dcesrv_drsuapi.c
@@ -58,7 +58,7 @@ static WERROR dcesrv_drsuapi_DsBind(struct dcesrv_call_state *dce_call, TALLOC_C
/*
* connect to the samdb
*/
- b_state->sam_ctx = samdb_connect(b_state, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
+ b_state->sam_ctx = samdb_connect(b_state, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
if (!b_state->sam_ctx) {
return WERR_FOOBAR;
}
diff --git a/source4/rpc_server/lsa/lsa_init.c b/source4/rpc_server/lsa/lsa_init.c
index 4dcd606435..0dc21fd9c5 100644
--- a/source4/rpc_server/lsa/lsa_init.c
+++ b/source4/rpc_server/lsa/lsa_init.c
@@ -50,7 +50,7 @@ NTSTATUS dcesrv_lsa_get_policy_state(struct dcesrv_call_state *dce_call, TALLOC_
}
/* make sure the sam database is accessible */
- state->sam_ldb = samdb_connect(state, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
+ state->sam_ldb = samdb_connect(state, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
if (state->sam_ldb == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
diff --git a/source4/rpc_server/lsa/lsa_lookup.c b/source4/rpc_server/lsa/lsa_lookup.c
index c6b9e3bd40..30bceb8139 100644
--- a/source4/rpc_server/lsa/lsa_lookup.c
+++ b/source4/rpc_server/lsa/lsa_lookup.c
@@ -195,7 +195,8 @@ static NTSTATUS lookup_well_known_sids(TALLOC_CTX *mem_ctx,
/*
lookup a SID for 1 name
*/
-static NTSTATUS dcesrv_lsa_lookup_name(struct loadparm_context *lp_ctx,
+static NTSTATUS dcesrv_lsa_lookup_name(struct event_context *ev_ctx,
+ struct loadparm_context *lp_ctx,
struct lsa_policy_state *state, TALLOC_CTX *mem_ctx,
const char *name, const char **authority_name,
struct dom_sid **sid, enum lsa_SidType *rtype)
@@ -218,7 +219,7 @@ static NTSTATUS dcesrv_lsa_lookup_name(struct loadparm_context *lp_ctx,
}
username = p + 1;
} else if (strchr_m(name, '@')) {
- status = crack_name_to_nt4_name(mem_ctx, lp_ctx, DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL, name, &domain, &username);
+ status = crack_name_to_nt4_name(mem_ctx, ev_ctx, lp_ctx, DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL, name, &domain, &username);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(3, ("Failed to crack name %s into an NT4 name: %s\n", name, nt_errstr(status)));
return status;
@@ -265,7 +266,7 @@ static NTSTATUS dcesrv_lsa_lookup_name(struct loadparm_context *lp_ctx,
if (!name) {
return NT_STATUS_NO_MEMORY;
}
- status = dcesrv_lsa_lookup_name(lp_ctx, state, mem_ctx, name, authority_name, sid, rtype);
+ status = dcesrv_lsa_lookup_name(ev_ctx, lp_ctx, state, mem_ctx, name, authority_name, sid, rtype);
if (NT_STATUS_IS_OK(status)) {
return status;
}
@@ -275,7 +276,7 @@ static NTSTATUS dcesrv_lsa_lookup_name(struct loadparm_context *lp_ctx,
if (!name) {
return NT_STATUS_NO_MEMORY;
}
- status = dcesrv_lsa_lookup_name(lp_ctx, state, mem_ctx, name, authority_name, sid, rtype);
+ status = dcesrv_lsa_lookup_name(ev_ctx, lp_ctx, state, mem_ctx, name, authority_name, sid, rtype);
if (NT_STATUS_IS_OK(status)) {
return status;
}
@@ -285,7 +286,7 @@ static NTSTATUS dcesrv_lsa_lookup_name(struct loadparm_context *lp_ctx,
if (!name) {
return NT_STATUS_NO_MEMORY;
}
- status = dcesrv_lsa_lookup_name(lp_ctx, state, mem_ctx, name, authority_name, sid, rtype);
+ status = dcesrv_lsa_lookup_name(ev_ctx, lp_ctx, state, mem_ctx, name, authority_name, sid, rtype);
if (NT_STATUS_IS_OK(status)) {
return status;
}
@@ -721,7 +722,7 @@ NTSTATUS dcesrv_lsa_LookupNames3(struct dcesrv_call_state *dce_call,
r->out.sids->sids[i].sid_index = 0xFFFFFFFF;
r->out.sids->sids[i].unknown = 0;
- status2 = dcesrv_lsa_lookup_name(lp_ctx, policy_state, mem_ctx, name, &authority_name, &sid, &rtype);
+ status2 = dcesrv_lsa_lookup_name(dce_call->event_ctx, lp_ctx, policy_state, mem_ctx, name, &authority_name, &sid, &rtype);
if (!NT_STATUS_IS_OK(status2) || sid->num_auths == 0) {
continue;
}
@@ -854,7 +855,7 @@ NTSTATUS dcesrv_lsa_LookupNames2(struct dcesrv_call_state *dce_call,
r->out.sids->sids[i].sid_index = 0xFFFFFFFF;
r->out.sids->sids[i].unknown = 0;
- status2 = dcesrv_lsa_lookup_name(lp_ctx, state, mem_ctx, name,
+ status2 = dcesrv_lsa_lookup_name(dce_call->event_ctx, lp_ctx, state, mem_ctx, name,
&authority_name, &sid, &rtype);
if (!NT_STATUS_IS_OK(status2)) {
continue;
diff --git a/source4/rpc_server/netlogon/dcerpc_netlogon.c b/source4/rpc_server/netlogon/dcerpc_netlogon.c
index 37e6351864..d9ae92c0fa 100644
--- a/source4/rpc_server/netlogon/dcerpc_netlogon.c
+++ b/source4/rpc_server/netlogon/dcerpc_netlogon.c
@@ -93,7 +93,7 @@ static NTSTATUS dcesrv_netr_ServerAuthenticate3(struct dcesrv_call_state *dce_ca
return NT_STATUS_ACCESS_DENIED;
}
- sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx,
+ sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx,
system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
@@ -176,7 +176,7 @@ static NTSTATUS dcesrv_netr_ServerAuthenticate3(struct dcesrv_call_state *dce_ca
/* remember this session key state */
- nt_status = schannel_store_session_key(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, creds);
+ nt_status = schannel_store_session_key(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, creds);
return nt_status;
}
@@ -236,7 +236,8 @@ static NTSTATUS dcesrv_netr_ServerAuthenticate2(struct dcesrv_call_state *dce_ca
the caller needs some of that information.
*/
-static NTSTATUS dcesrv_netr_creds_server_step_check(struct loadparm_context *lp_ctx,
+static NTSTATUS dcesrv_netr_creds_server_step_check(struct event_context *event_ctx,
+ struct loadparm_context *lp_ctx,
const char *computer_name,
TALLOC_CTX *mem_ctx,
struct netr_Authenticator *received_authenticator,
@@ -248,7 +249,7 @@ static NTSTATUS dcesrv_netr_creds_server_step_check(struct loadparm_context *lp_
struct ldb_context *ldb;
int ret;
- ldb = schannel_db_connect(mem_ctx, lp_ctx);
+ ldb = schannel_db_connect(mem_ctx, event_ctx, lp_ctx);
if (!ldb) {
return NT_STATUS_ACCESS_DENIED;
}
@@ -300,13 +301,13 @@ static NTSTATUS dcesrv_netr_ServerPasswordSet(struct dcesrv_call_state *dce_call
struct ldb_context *sam_ctx;
NTSTATUS nt_status;
- nt_status = dcesrv_netr_creds_server_step_check(dce_call->conn->dce_ctx->lp_ctx,
+ nt_status = dcesrv_netr_creds_server_step_check(dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx,
r->in.computer_name, mem_ctx,
&r->in.credential, &r->out.return_authenticator,
&creds);
NT_STATUS_NOT_OK_RETURN(nt_status);
- sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
+ sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
@@ -339,13 +340,13 @@ static NTSTATUS dcesrv_netr_ServerPasswordSet2(struct dcesrv_call_state *dce_cal
struct samr_CryptPassword password_buf;
- nt_status = dcesrv_netr_creds_server_step_check(dce_call->conn->dce_ctx->lp_ctx,
+ nt_status = dcesrv_netr_creds_server_step_check(dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx,
r->in.computer_name, mem_ctx,
&r->in.credential, &r->out.return_authenticator,
&creds);
NT_STATUS_NOT_OK_RETURN(nt_status);
- sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
+ sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
@@ -561,7 +562,7 @@ static NTSTATUS dcesrv_netr_LogonSamLogonEx(struct dcesrv_call_state *dce_call,
{
NTSTATUS nt_status;
struct creds_CredentialState *creds;
- nt_status = schannel_fetch_session_key(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, r->in.computer_name, lp_workgroup(dce_call->conn->dce_ctx->lp_ctx), &creds);
+ nt_status = schannel_fetch_session_key(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, r->in.computer_name, lp_workgroup(dce_call->conn->dce_ctx->lp_ctx), &creds);
if (!NT_STATUS_IS_OK(nt_status)) {
return nt_status;
}
@@ -589,7 +590,7 @@ static NTSTATUS dcesrv_netr_LogonSamLogonWithFlags(struct dcesrv_call_state *dce
return_authenticator = talloc(mem_ctx, struct netr_Authenticator);
NT_STATUS_HAVE_NO_MEMORY(return_authenticator);
- nt_status = dcesrv_netr_creds_server_step_check(dce_call->conn->dce_ctx->lp_ctx,
+ nt_status = dcesrv_netr_creds_server_step_check(dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx,
r->in.computer_name, mem_ctx,
r->in.credential, return_authenticator,
&creds);
@@ -891,14 +892,14 @@ static NTSTATUS dcesrv_netr_LogonGetDomainInfo(struct dcesrv_call_state *dce_cal
const char *local_domain;
- status = dcesrv_netr_creds_server_step_check(dce_call->conn->dce_ctx->lp_ctx,
+ status = dcesrv_netr_creds_server_step_check(dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx,
r->in.computer_name, mem_ctx,
r->in.credential,
r->out.return_authenticator,
NULL);
NT_STATUS_NOT_OK_RETURN(status);
- sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
+ sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
@@ -1003,7 +1004,7 @@ static WERROR dcesrv_netr_DsRGetDCNameEx2(struct dcesrv_call_state *dce_call, TA
ZERO_STRUCT(r->out);
- sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
+ sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
if (sam_ctx == NULL) {
return WERR_DS_SERVICE_UNAVAILABLE;
}
@@ -1165,7 +1166,7 @@ static WERROR dcesrv_netr_DsrEnumerateDomainTrusts(struct dcesrv_call_state *dce
ZERO_STRUCT(r->out);
- sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
+ sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
if (sam_ctx == NULL) {
return WERR_GENERAL_FAILURE;
}
diff --git a/source4/rpc_server/samr/dcesrv_samr.c b/source4/rpc_server/samr/dcesrv_samr.c
index 0aa4d65d8c..8ee77a6a30 100644
--- a/source4/rpc_server/samr/dcesrv_samr.c
+++ b/source4/rpc_server/samr/dcesrv_samr.c
@@ -156,7 +156,7 @@ static NTSTATUS dcesrv_samr_Connect(struct dcesrv_call_state *dce_call, TALLOC_C
}
/* make sure the sam database is accessible */
- c_state->sam_ctx = samdb_connect(c_state, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
+ c_state->sam_ctx = samdb_connect(c_state, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
if (c_state->sam_ctx == NULL) {
talloc_free(c_state);
return NT_STATUS_INVALID_SYSTEM_SERVICE;
@@ -4135,7 +4135,7 @@ static NTSTATUS dcesrv_samr_GetDomPwInfo(struct dcesrv_call_state *dce_call, TAL
ZERO_STRUCT(r->out.info);
- sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
+ sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info);
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
diff --git a/source4/rpc_server/samr/samr_password.c b/source4/rpc_server/samr/samr_password.c
index ec91b8eada..b78a9ceaa7 100644
--- a/source4/rpc_server/samr/samr_password.c
+++ b/source4/rpc_server/samr/samr_password.c
@@ -66,7 +66,7 @@ NTSTATUS dcesrv_samr_ChangePasswordUser(struct dcesrv_call_state *dce_call,
}
/* To change a password we need to open as system */
- sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
+ sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
@@ -205,7 +205,7 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call,
}
/* To change a password we need to open as system */
- sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
+ sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
@@ -343,7 +343,7 @@ NTSTATUS dcesrv_samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call,
}
/* To change a password we need to open as system */
- sam_ctx = samdb_connect(mem_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
+ sam_ctx = samdb_connect(mem_ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, system_session(mem_ctx, dce_call->conn->dce_ctx->lp_ctx));
if (sam_ctx == NULL) {
return NT_STATUS_INVALID_SYSTEM_SERVICE;
}
diff --git a/source4/rpc_server/service_rpc.c b/source4/rpc_server/service_rpc.c
index ddcf1c2a99..00f0d261ca 100644
--- a/source4/rpc_server/service_rpc.c
+++ b/source4/rpc_server/service_rpc.c
@@ -37,7 +37,6 @@
#include "lib/messaging/irpc.h"
#include "system/network.h"
#include "lib/socket/netif.h"
-#include "build.h"
#include "param/param.h"
struct dcesrv_socket_context {
@@ -107,7 +106,7 @@ static void dcesrv_sock_accept(struct stream_connection *srv_conn)
struct dcesrv_connection *dcesrv_conn = NULL;
struct auth_session_info *session_info = NULL;
- status = auth_anonymous_session_info(srv_conn, dcesrv_sock->dcesrv_ctx->lp_ctx, &session_info);
+ status = auth_anonymous_session_info(srv_conn, srv_conn->event.ctx, dcesrv_sock->dcesrv_ctx->lp_ctx, &session_info);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("dcesrv_sock_accept: auth_anonymous_session_info failed: %s\n",
nt_errstr(status)));
@@ -459,7 +458,19 @@ failed:
NTSTATUS server_service_rpc_init(void)
{
- init_module_fn static_init[] = { STATIC_dcerpc_server_MODULES };
+ extern NTSTATUS dcerpc_server_wkssvc_init(void);
+ extern NTSTATUS dcerpc_server_drsuapi_init(void);
+ extern NTSTATUS dcerpc_server_winreg_init(void);
+ extern NTSTATUS dcerpc_server_spoolss_init(void);
+ extern NTSTATUS dcerpc_server_epmapper_init(void);
+ extern NTSTATUS dcerpc_server_srvsvc_init(void);
+ extern NTSTATUS dcerpc_server_netlogon_init(void);
+ extern NTSTATUS dcerpc_server_rpcecho_init(void);
+ extern NTSTATUS dcerpc_server_unixinfo_init(void);
+ extern NTSTATUS dcerpc_server_samr_init(void);
+ extern NTSTATUS dcerpc_server_remote_init(void);
+ extern NTSTATUS dcerpc_server_lsa_init(void);
+ init_module_fn static_init[] = { STATIC_DCESRV_MODULES };
init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "dcerpc_server");
run_init_functions(static_init);
diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.c b/source4/rpc_server/spoolss/dcesrv_spoolss.c
index 7c701ec50a..28e30002e2 100644
--- a/source4/rpc_server/spoolss/dcesrv_spoolss.c
+++ b/source4/rpc_server/spoolss/dcesrv_spoolss.c
@@ -216,7 +216,7 @@ static NTSTATUS dcerpc_spoolss_bind(struct dcesrv_call_state *dce_call, const st
NTSTATUS status;
struct ntptr_context *ntptr;
- status = ntptr_init_context(dce_call->context, dce_call->conn->dce_ctx->lp_ctx,
+ status = ntptr_init_context(dce_call->context, dce_call->conn->event_ctx, dce_call->conn->dce_ctx->lp_ctx,
lp_ntptr_providor(dce_call->conn->dce_ctx->lp_ctx), &ntptr);
NT_STATUS_NOT_OK_RETURN(status);
@@ -1156,7 +1156,8 @@ static WERROR dcesrv_spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct dcesrv_
creds = cli_credentials_init_anon(mem_ctx); /* FIXME: Use machine credentials instead ? */
status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_spoolss,
- creds, NULL, dce_call->conn->dce_ctx->lp_ctx);
+ creds, dce_call->event_ctx,
+ dce_call->conn->dce_ctx->lp_ctx);
if (NT_STATUS_IS_ERR(status)) {
DEBUG(0, ("unable to call back to %s\n", r->in.str));
diff --git a/source4/rpc_server/srvsvc/dcesrv_srvsvc.c b/source4/rpc_server/srvsvc/dcesrv_srvsvc.c
index 23e40d9976..8dc42bf43b 100644
--- a/source4/rpc_server/srvsvc/dcesrv_srvsvc.c
+++ b/source4/rpc_server/srvsvc/dcesrv_srvsvc.c
@@ -445,7 +445,7 @@ static WERROR dcesrv_srvsvc_NetShareAdd(struct dcesrv_call_state *dce_call, TALL
int count = 8;
int i;
- nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->conn->dce_ctx->lp_ctx, &sctx);
+ nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
if (!NT_STATUS_IS_OK(nterr)) {
return ntstatus_to_werror(nterr);
}
@@ -543,7 +543,7 @@ static WERROR dcesrv_srvsvc_NetShareAdd(struct dcesrv_call_state *dce_call, TALL
int count = 10;
int i;
- nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->conn->dce_ctx->lp_ctx, &sctx);
+ nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
if (!NT_STATUS_IS_OK(nterr)) {
return ntstatus_to_werror(nterr);
}
@@ -735,7 +735,7 @@ static WERROR dcesrv_srvsvc_NetShareEnumAll(struct dcesrv_call_state *dce_call,
/* TODO: - paging of results
*/
- nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->conn->dce_ctx->lp_ctx, &sctx);
+ nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
if (!NT_STATUS_IS_OK(nterr)) {
return ntstatus_to_werror(nterr);
}
@@ -984,7 +984,7 @@ static WERROR dcesrv_srvsvc_NetShareGetInfo(struct dcesrv_call_state *dce_call,
return WERR_INVALID_PARAM;
}
- nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->conn->dce_ctx->lp_ctx, &sctx);
+ nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
if (!NT_STATUS_IS_OK(nterr)) {
return ntstatus_to_werror(nterr);
}
@@ -1238,7 +1238,7 @@ static WERROR dcesrv_srvsvc_NetShareSetInfo(struct dcesrv_call_state *dce_call,
return WERR_INVALID_PARAM;
}
- nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->conn->dce_ctx->lp_ctx, &sctx);
+ nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
if (!NT_STATUS_IS_OK(nterr)) {
return ntstatus_to_werror(nterr);
}
@@ -1415,7 +1415,7 @@ static WERROR dcesrv_srvsvc_NetShareCheck(struct dcesrv_call_state *dce_call, TA
}
all_string_sub(device, "\\", "/", 0);
- nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->conn->dce_ctx->lp_ctx, &sctx);
+ nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
if (!NT_STATUS_IS_OK(nterr)) {
return ntstatus_to_werror(nterr);
}
@@ -1499,7 +1499,7 @@ static WERROR dcesrv_srvsvc_NetSrvGetInfo(struct dcesrv_call_state *dce_call, TA
info101->version_major = dcesrv_common_get_version_major(mem_ctx, dce_ctx->lp_ctx);
info101->version_minor = dcesrv_common_get_version_minor(mem_ctx, dce_ctx->lp_ctx);
- info101->server_type = dcesrv_common_get_server_type(mem_ctx, dce_ctx);
+ info101->server_type = dcesrv_common_get_server_type(mem_ctx, dce_call->event_ctx, dce_ctx);
info101->comment = talloc_strdup(mem_ctx, lp_serverstring(dce_ctx->lp_ctx));
W_ERROR_HAVE_NO_MEMORY(info101->comment);
@@ -1519,7 +1519,7 @@ static WERROR dcesrv_srvsvc_NetSrvGetInfo(struct dcesrv_call_state *dce_call, TA
info102->version_major = dcesrv_common_get_version_major(mem_ctx, dce_ctx->lp_ctx);
info102->version_minor = dcesrv_common_get_version_minor(mem_ctx, dce_ctx->lp_ctx);
- info102->server_type = dcesrv_common_get_server_type(mem_ctx, dce_ctx);
+ info102->server_type = dcesrv_common_get_server_type(mem_ctx, dce_call->event_ctx, dce_ctx);
info102->comment = talloc_strdup(mem_ctx, lp_serverstring(dce_ctx->lp_ctx));
W_ERROR_HAVE_NO_MEMORY(info102->comment);
@@ -1829,7 +1829,7 @@ static WERROR dcesrv_srvsvc_NetShareEnum(struct dcesrv_call_state *dce_call, TAL
/* TODO: - paging of results
*/
- nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->conn->dce_ctx->lp_ctx, &sctx);
+ nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
if (!NT_STATUS_IS_OK(nterr)) {
return ntstatus_to_werror(nterr);
}
@@ -2292,7 +2292,7 @@ static WERROR dcesrv_srvsvc_NetShareDel(struct dcesrv_call_state *dce_call, TALL
NTSTATUS nterr;
struct share_context *sctx;
- nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->conn->dce_ctx->lp_ctx, &sctx);
+ nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
if (!NT_STATUS_IS_OK(nterr)) {
return ntstatus_to_werror(nterr);
}
diff --git a/source4/rpc_server/srvsvc/srvsvc_ntvfs.c b/source4/rpc_server/srvsvc/srvsvc_ntvfs.c
index 43fb24c0c3..f1cb35bdd8 100644
--- a/source4/rpc_server/srvsvc/srvsvc_ntvfs.c
+++ b/source4/rpc_server/srvsvc/srvsvc_ntvfs.c
@@ -62,7 +62,7 @@ NTSTATUS srvsvc_create_ntvfs_context(struct dcesrv_call_state *dce_call,
struct share_config *scfg;
const char *sharetype;
- status = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->conn->dce_ctx->lp_ctx, &sctx);
+ status = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
diff --git a/source4/rpc_server/winreg/rpc_winreg.c b/source4/rpc_server/winreg/rpc_winreg.c
index 9993dc14c1..22c60c354c 100644
--- a/source4/rpc_server/winreg/rpc_winreg.c
+++ b/source4/rpc_server/winreg/rpc_winreg.c
@@ -37,7 +37,7 @@ static NTSTATUS dcerpc_winreg_bind(struct dcesrv_call_state *dce_call,
WERROR err;
err = reg_open_samba(dce_call->context,
- &ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info,
+ &ctx, dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, dce_call->conn->auth_state.session_info,
NULL);
if (!W_ERROR_IS_OK(err)) {
diff --git a/source4/samba4-knownfail b/source4/samba4-knownfail
index 496af316ec..1f780f13f0 100644
--- a/source4/samba4-knownfail
+++ b/source4/samba4-knownfail
@@ -4,7 +4,8 @@ base.delaywrite.finfo update on close
base.delete.*.deltest20a
base.delete.*.deltest20b
rpc.winreg.*security
-local.registry.*.security # Not implemented yet
+samba4.local.registry.(dir|ldb).check hive security
+samba4.local.registry.local.security
rpc.wkssvc
rpc.handles.*.lsarpc-shared
rpc.handles.*.mixed-shared
@@ -33,3 +34,11 @@ rpc.netlogon.*.GetTrustPasswords
base.charset.*.Testing partial surrogate
.*net.api.delshare.* # DelShare isn't implemented yet
rap.*netservergetinfo
+smb2.persistent.handles1
+samba4.winbind.struct.*.LIST_GROUPS # Not yet working in winbind
+samba4.winbind.struct.*.SHOW_SEQUENCE # Not yet working in winbind
+samba4.winbind.struct.*.GETPWENT # Not yet working in winbind
+samba4.winbind.struct.*.SETPWENT # Not yet working in winbind
+samba4.winbind.struct.*.LOOKUP_NAME_SID # Not yet working in winbind
+
+
diff --git a/source4/samba4-skip b/source4/samba4-skip
index 19ff924794..4ac35a3c78 100644
--- a/source4/samba4-skip
+++ b/source4/samba4-skip
@@ -4,12 +4,13 @@ base.iometer
base.casetable
base.nttrans
.*base.bench.holdcon.* # Very slow
+raw.bench.lookup # Very slow
base.scan.maxfid
-raw.hold.oplock
-raw.ping.pong
+raw.hold.oplock # Not a test, but a way to block other clients for a test
+raw.ping.pong # Needs second server to test
rpc.samr_accessmask
raw.scan.eamax
-raw.qfileinfo.ipc
+samba4.ntvfs.cifs.raw.qfileinfo.ipc
base.utable
base.smb
smb2.notify
@@ -38,10 +39,14 @@ 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.base.samba3.* # Samba3-specific test
+^samba4.ntvfs.cifs.base.samba3.* # Samba3-specific test
+^samba4.raw.samba3.* # Samba3-specific test
+^samba4.ntvfs.cifs.raw.samba3.* # Samba3-specific test
+samba4.ntvfs.cifs.raw.
+^samba4.rpc..*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
samba4.samdb.python # Not finished yet
diff --git a/source4/script/harness2subunit.pl b/source4/script/harness2subunit.pl
index c14e4730e0..9f2391ad6c 100755
--- a/source4/script/harness2subunit.pl
+++ b/source4/script/harness2subunit.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
my $firstline = 1;
-
+my $error = 0;
while(<STDIN>) {
if ($firstline) {
$firstline = 0;
@@ -10,6 +10,7 @@ while(<STDIN>) {
if (/^not ok (\d+) - (.*)$/) {
print "test: $2\n";
print "failure: $2\n";
+ $error = 1;
} elsif (/^ok (\d+) - (.*)$/) {
print "test: $2\n";
print "success: $2\n";
@@ -22,7 +23,10 @@ while(<STDIN>) {
} elsif (/^not ok (\d+)$/) {
print "test: $1\n";
print "failure: $1\n";
+ $error = 1;
} else {
print;
}
}
+exit $error;
+
diff --git a/source4/script/installheader.pl b/source4/script/installheader.pl
index d1f96b2592..6b10bde65f 100755
--- a/source4/script/installheader.pl
+++ b/source4/script/installheader.pl
@@ -60,6 +60,8 @@ sub install_header($$)
while (<IN>) {
$lineno++;
+ die("Will not install autogenerated header $src") if (/This file was automatically generated by mkproto.pl. DO NOT EDIT/);
+
if (/^#include \"(.*)\"/) {
print OUT "#include <" . rewrite_include("$src:$lineno", $1) . ">\n";
} else {
diff --git a/source4/scripting/bin/minschema.py b/source4/scripting/bin/minschema.py
index fb9d7b05aa..111557126d 100755
--- a/source4/scripting/bin/minschema.py
+++ b/source4/scripting/bin/minschema.py
@@ -4,6 +4,12 @@
#
import optparse
+
+import os, sys
+
+# Find right directory when running from source tree
+sys.path.insert(0, "bin/python")
+
import samba
from samba import getopt as options
import sys
diff --git a/source4/scripting/bin/rpcclient b/source4/scripting/bin/rpcclient
index 34efafdf73..aba4f9ddb3 100755
--- a/source4/scripting/bin/rpcclient
+++ b/source4/scripting/bin/rpcclient
@@ -1,6 +1,10 @@
#!/usr/bin/python
import sys, os, string
+
+# Find right directory when running from source tree
+sys.path.insert(0, "bin/python")
+
from cmd import Cmd
from optparse import OptionParser
from pprint import pprint
diff --git a/source4/scripting/bin/samba3dump b/source4/scripting/bin/samba3dump
index 8f56d423d8..d89667233f 100755
--- a/source4/scripting/bin/samba3dump
+++ b/source4/scripting/bin/samba3dump
@@ -7,7 +7,10 @@
import optparse
import os, sys
-sys.path.append(os.path.join(os.path.dirname(__file__), "../python"))
+
+# Find right directory when running from source tree
+sys.path.insert(0, "bin/python")
+
import samba
import samba.samba3
diff --git a/source4/scripting/bin/samr.py b/source4/scripting/bin/samr.py
new file mode 100755
index 0000000000..e91b5bc312
--- /dev/null
+++ b/source4/scripting/bin/samr.py
@@ -0,0 +1,114 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Unix SMB/CIFS implementation.
+# Copyright © Jelmer Vernooij <jelmer@samba.org> 2008
+#
+# Based on samr.js © Andrew Tridgell <tridge@samba.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import sys
+
+sys.path.insert(0, "bin/python")
+
+from samba.dcerpc import samr, security, lsa
+
+def FillUserInfo(samr, dom_handle, users, level):
+ """fill a user array with user information from samrQueryUserInfo"""
+ for i in range(len(users)):
+ user_handle = samr.OpenUser(handle, security.SEC_FLAG_MAXIMUM_ALLOWED, users[i].idx)
+ info = samr.QueryUserInfo(user_handle, level)
+ info.name = users[i].name
+ info.idx = users[i].idx
+ users[i] = info
+ samr.Close(user_handle)
+
+def toArray((handle, array, num_entries)):
+ ret = []
+ for x in range(num_entries):
+ ret.append((array.entries[x].idx, array.entries[x].name))
+ return ret
+
+
+def test_Connect(samr):
+ """test the samr_Connect interface"""
+ print "Testing samr_Connect"
+ return samr.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED)
+
+def test_LookupDomain(samr, handle, domain):
+ """test the samr_LookupDomain interface"""
+ print "Testing samr_LookupDomain"
+ return samr.LookupDomain(handle, domain)
+
+def test_OpenDomain(samr, handle, sid):
+ """test the samr_OpenDomain interface"""
+ print "Testing samr_OpenDomain"
+ return samr.OpenDomain(handle, security.SEC_FLAG_MAXIMUM_ALLOWED, sid)
+
+def test_EnumDomainUsers(samr, dom_handle):
+ """test the samr_EnumDomainUsers interface"""
+ print "Testing samr_EnumDomainUsers"
+ users = toArray(samr.EnumDomainUsers(dom_handle, 0, 0, -1))
+ print "Found %d users" % len(users)
+ for idx, user in users:
+ print "\t%s\t(%d)" % (user, idx)
+
+def test_EnumDomainGroups(samr, dom_handle):
+ """test the samr_EnumDomainGroups interface"""
+ print "Testing samr_EnumDomainGroups"
+ groups = toArray(samr.EnumDomainGroups(dom_handle, 0, 0))
+ print "Found %d groups" % len(groups)
+ for idx, group in groups:
+ print "\t%s\t(%d)" % (group, idx)
+
+def test_domain_ops(samr, dom_handle):
+ """test domain specific ops"""
+ test_EnumDomainUsers(samr, dom_handle)
+ test_EnumDomainGroups(samr, dom_handle)
+
+def test_EnumDomains(samr, handle):
+ """test the samr_EnumDomains interface"""
+ print "Testing samr_EnumDomains"
+
+ domains = toArray(samr.EnumDomains(handle, 0, -1))
+ print "Found %d domains" % len(domains)
+ for idx, domain in domains:
+ print "\t%s (%d)" % (domain, idx)
+ for idx, domain in domains:
+ print "Testing domain %s" % domain
+ sid = samr.LookupDomain(handle, domain)
+ dom_handle = test_OpenDomain(samr, handle, sid)
+ test_domain_ops(samr, dom_handle)
+ samr.Close(dom_handle)
+
+if len(sys.argv) != 2:
+ print "Usage: samr.js <BINDING>"
+ sys.exit(1)
+
+binding = sys.argv[1]
+
+print "Connecting to " + binding
+try:
+ samr = samr.samr(binding)
+except Exception, e:
+ print "Failed to connect to %s: %s" % (binding, e.message)
+ sys.exit(1)
+
+handle = test_Connect(samr)
+test_EnumDomains(samr, handle)
+samr.Close(handle)
+
+print "All OK"
diff --git a/source4/scripting/bin/subunitrun b/source4/scripting/bin/subunitrun
index 11ac426589..6f1086ad37 100755
--- a/source4/scripting/bin/subunitrun
+++ b/source4/scripting/bin/subunitrun
@@ -17,9 +17,32 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-from subunit import SubunitTestRunner
import sys
+
+# Find right directory when running from source tree
+sys.path.insert(0, "bin/python")
+
+from subunit import SubunitTestRunner
from unittest import TestProgram
+import optparse
+import os
+from samba import param
+import samba.getopt as options
+import samba.tests
+
+parser = optparse.OptionParser("subunitrun [options] <tests>")
+credopts = options.CredentialsOptions(parser)
+parser.add_option_group(credopts)
+sambaopts = options.SambaOptions(parser)
+parser.add_option_group(sambaopts)
+parser.add_option_group(options.VersionOptions(parser))
+
+args = parser.parse_args()[1]
+
+samba.tests.cmdline_loadparm = sambaopts.get_loadparm()
+samba.tests.cmdline_credentials = credopts.get_credentials(samba.tests.cmdline_loadparm)
+
+param.cvar.default_config = samba.tests.cmdline_loadparm
runner = SubunitTestRunner()
-TestProgram(module=None, argv=sys.argv, testRunner=runner)
+program = TestProgram(module=None, argv=[sys.argv[0]] + args, testRunner=runner)
diff --git a/source4/scripting/bin/winreg.py b/source4/scripting/bin/winreg.py
index 1e39ee8f78..19d39e56ab 100755
--- a/source4/scripting/bin/winreg.py
+++ b/source4/scripting/bin/winreg.py
@@ -7,6 +7,10 @@
#
import sys
+
+# Find right directory when running from source tree
+sys.path.insert(0, "bin/python")
+
import winreg
import optparse
import samba.getopt as options
diff --git a/source4/scripting/ejs/config.mk b/source4/scripting/ejs/config.mk
index 33a4ac915f..c1a1ca1f0f 100644
--- a/source4/scripting/ejs/config.mk
+++ b/source4/scripting/ejs/config.mk
@@ -1,84 +1,86 @@
[SUBSYSTEM::EJSRPC]
-OBJ_FILES = \
- ejsrpc.o
+
+EJSRPC_OBJ_FILES = $(ejsscriptsrcdir)/ejsrpc.o
[MODULE::smbcalls_config]
-OBJ_FILES = smbcalls_config.o
OUTPUT_TYPE = MERGED_OBJ
SUBSYSTEM = smbcalls
INIT_FUNCTION = smb_setup_ejs_config
+smbcalls_config_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_config.o
+
[MODULE::smbcalls_ldb]
-OBJ_FILES = smbcalls_ldb.o
OUTPUT_TYPE = MERGED_OBJ
SUBSYSTEM = smbcalls
INIT_FUNCTION = smb_setup_ejs_ldb
PRIVATE_DEPENDENCIES = LIBLDB SAMDB LIBNDR
+smbcalls_ldb_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_ldb.o
+
[MODULE::smbcalls_reg]
-OBJ_FILES = smbcalls_reg.o
SUBSYSTEM = smbcalls
OUTPUT_TYPE = MERGED_OBJ
INIT_FUNCTION = smb_setup_ejs_reg
PRIVATE_DEPENDENCIES = registry SAMDB LIBNDR
+smbcalls_reg_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_reg.o
+
[MODULE::smbcalls_nbt]
-OBJ_FILES = smbcalls_nbt.o
SUBSYSTEM = smbcalls
OUTPUT_TYPE = MERGED_OBJ
INIT_FUNCTION = smb_setup_ejs_nbt
+smbcalls_nbt_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_nbt.o
+
[MODULE::smbcalls_rand]
-OBJ_FILES = smbcalls_rand.o
SUBSYSTEM = smbcalls
OUTPUT_TYPE = MERGED_OBJ
INIT_FUNCTION = smb_setup_ejs_random
+smbcalls_rand_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_rand.o
+
[MODULE::smbcalls_nss]
-OBJ_FILES = smbcalls_nss.o
SUBSYSTEM = smbcalls
OUTPUT_TYPE = MERGED_OBJ
INIT_FUNCTION = smb_setup_ejs_nss
PRIVATE_DEPENDENCIES = NSS_WRAPPER
+smbcalls_nss_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_nss.o
+
[MODULE::smbcalls_data]
-OBJ_FILES = smbcalls_data.o
SUBSYSTEM = smbcalls
OUTPUT_TYPE = MERGED_OBJ
INIT_FUNCTION = smb_setup_ejs_datablob
+smbcalls_data_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_data.o
+
[MODULE::smbcalls_auth]
-OBJ_FILES = smbcalls_auth.o
OUTPUT_TYPE = MERGED_OBJ
SUBSYSTEM = smbcalls
INIT_FUNCTION = smb_setup_ejs_auth
-PRIVATE_DEPENDENCIES = auth
+PRIVATE_DEPENDENCIES = service_auth
+
+smbcalls_auth_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_auth.o
+
+smbcalls_auth_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_auth.o
[MODULE::smbcalls_string]
-OBJ_FILES = smbcalls_string.o
SUBSYSTEM = smbcalls
OUTPUT_TYPE = MERGED_OBJ
INIT_FUNCTION = smb_setup_ejs_string
+smbcalls_string_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_string.o
+
[MODULE::smbcalls_sys]
-OBJ_FILES = smbcalls_sys.o
SUBSYSTEM = smbcalls
OUTPUT_TYPE = MERGED_OBJ
INIT_FUNCTION = smb_setup_ejs_system
+smbcalls_sys_OBJ_FILES = $(ejsscriptsrcdir)/smbcalls_sys.o
+
mkinclude ejsnet/config.mk
[SUBSYSTEM::smbcalls]
-PRIVATE_PROTO_HEADER = proto.h
-OBJ_FILES = \
- smbcalls.o \
- smbcalls_cli.o \
- smbcalls_rpc.o \
- smbcalls_options.o \
- smbcalls_creds.o \
- smbcalls_param.o \
- mprutil.o \
- literal.o
PRIVATE_DEPENDENCIES = \
EJS LIBSAMBA-UTIL \
EJSRPC MESSAGING \
@@ -87,12 +89,23 @@ PRIVATE_DEPENDENCIES = \
dcerpc \
NDR_TABLE
+smbcalls_OBJ_FILES = $(addprefix $(ejsscriptsrcdir)/, \
+ smbcalls.o \
+ smbcalls_cli.o \
+ smbcalls_rpc.o \
+ smbcalls_options.o \
+ smbcalls_creds.o \
+ smbcalls_param.o \
+ mprutil.o \
+ literal.o)
+
+$(eval $(call proto_header_template,$(ejsscriptsrcdir)/proto.h,$(smbcalls_OBJ_FILES:.o=.c)))
+
#######################
# Start BINARY SMBSCRIPT
[BINARY::smbscript]
-INSTALLDIR = BINDIR
-OBJ_FILES = \
- smbscript.o
PRIVATE_DEPENDENCIES = EJS LIBSAMBA-UTIL smbcalls LIBSAMBA-HOSTCONFIG
# End BINARY SMBSCRIPT
#######################
+
+smbscript_OBJ_FILES = $(ejsscriptsrcdir)/smbscript.o
diff --git a/source4/scripting/ejs/ejsnet/config.mk b/source4/scripting/ejs/ejsnet/config.mk
index 249a33121d..710221e37d 100644
--- a/source4/scripting/ejs/ejsnet/config.mk
+++ b/source4/scripting/ejs/ejsnet/config.mk
@@ -1,11 +1,13 @@
[MODULE::smbcalls_net]
-OBJ_FILES = \
+SUBSYSTEM = smbcalls
+INIT_FUNCTION = smb_setup_ejs_net
+PRIVATE_DEPENDENCIES = LIBSAMBA-NET LIBCLI_SMB CREDENTIALS
+
+smbcalls_net_OBJ_FILES = $(addprefix $(ejsscriptsrcdir)/ejsnet/, \
net_ctx.o \
net_user.o \
mpr_user.o \
net_host.o \
- mpr_host.o
-SUBSYSTEM = smbcalls
-INIT_FUNCTION = smb_setup_ejs_net
-PRIVATE_PROTO_HEADER = proto.h
-PRIVATE_DEPENDENCIES = LIBSAMBA-NET LIBCLI_SMB CREDENTIALS
+ mpr_host.o)
+
+$(eval $(call proto_header_template,$(ejsscriptsrcdir)/ejsnet/proto.h,$(smbcalls_net_OBJ_FILES:.o=.c)))
diff --git a/source4/scripting/ejs/ejsnet/net_ctx.c b/source4/scripting/ejs/ejsnet/net_ctx.c
index 99be1c4ef8..cbe163552e 100644
--- a/source4/scripting/ejs/ejsnet/net_ctx.c
+++ b/source4/scripting/ejs/ejsnet/net_ctx.c
@@ -50,7 +50,7 @@ static int ejs_net_context(MprVarHandle eid, int argc, struct MprVar **argv)
ejsSetErrorMsg(eid, "talloc_new() failed");
return -1;
}
- ev = event_context_find(event_mem_ctx);
+ ev = mprEventCtx();
ctx = libnet_context_init(ev, mprLpCtx());
/* IF we generated a new event context, it will be under here,
diff --git a/source4/scripting/ejs/ejsnet/net_user.c b/source4/scripting/ejs/ejsnet/net_user.c
index 57e538d3b4..0c32035c6c 100644
--- a/source4/scripting/ejs/ejsnet/net_user.c
+++ b/source4/scripting/ejs/ejsnet/net_user.c
@@ -268,8 +268,9 @@ static int ejs_net_userinfo(MprVarHandle eid, int argc, char **argv)
/* call the libnet function */
req.in.domain_name = userman_domain;
- req.in.user_name = username;
-
+ req.in.data.user_name = username;
+ req.in.level = USER_INFO_BY_NAME;
+
status = libnet_UserInfo(ctx, mem_ctx, &req);
if (!NT_STATUS_IS_OK(status)) {
ejsSetErrorMsg(eid, "%s", req.out.error_string);
diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c
index 63a80e17db..98d6be07bf 100644
--- a/source4/scripting/ejs/smbcalls.c
+++ b/source4/scripting/ejs/smbcalls.c
@@ -23,7 +23,6 @@
#include "includes.h"
#include "param/param.h"
#include "scripting/ejs/smbcalls.h"
-#include "build.h"
#include "version.h"
/*
@@ -173,6 +172,32 @@ _PUBLIC_ void ejs_exception(const char *reason)
*/
void smb_setup_ejs_functions(void (*exception_handler)(const char *))
{
+ extern NTSTATUS ejs_init_security(void);
+ extern NTSTATUS ejs_init_initshutdown(void);
+ extern NTSTATUS smb_setup_ejs_reg(void);
+ extern NTSTATUS smb_setup_ejs_string(void);
+ extern NTSTATUS ejs_init_lsarpc(void);
+ extern NTSTATUS ejs_init_rpcecho(void);
+ extern NTSTATUS ejs_init_winreg(void);
+ extern NTSTATUS smb_setup_ejs_random(void);
+ extern NTSTATUS smb_setup_ejs_config(void);
+ extern NTSTATUS ejs_init_misc(void);
+ extern NTSTATUS ejs_init_netdfs(void);
+ extern NTSTATUS smb_setup_ejs_datablob(void);
+ extern NTSTATUS smb_setup_ejs_auth(void);
+ extern NTSTATUS smb_setup_ejs_nss(void);
+ extern NTSTATUS ejs_init_samr(void);
+ extern NTSTATUS ejs_init_wkssvc(void);
+ extern NTSTATUS smb_setup_ejs_system(void);
+ extern NTSTATUS smb_setup_ejs_ldb(void);
+ extern NTSTATUS ejs_init_svcctl(void);
+ extern NTSTATUS smb_setup_ejs_nbt(void);
+ extern NTSTATUS smb_setup_ejs_net(void);
+ extern NTSTATUS ejs_init_srvsvc(void);
+ extern NTSTATUS ejs_init_netlogon(void);
+ extern NTSTATUS ejs_init_drsuapi(void);
+ extern NTSTATUS ejs_init_irpc(void);
+ extern NTSTATUS ejs_init_eventlog(void);
init_module_fn static_init[] = { STATIC_smbcalls_MODULES };
init_module_fn *shared_init;
diff --git a/source4/scripting/ejs/smbcalls_auth.c b/source4/scripting/ejs/smbcalls_auth.c
index 908a009159..b67bb7ed5b 100644
--- a/source4/scripting/ejs/smbcalls_auth.c
+++ b/source4/scripting/ejs/smbcalls_auth.c
@@ -55,7 +55,7 @@ static int ejs_doauth(MprVarHandle eid,
msg = c->msg_ctx;
} else {
/* Hope we can find the event context somewhere up there... */
- ev = event_context_find(tmp_ctx);
+ ev = mprEventCtx();
msg = messaging_client_init(tmp_ctx, lp_messaging_path(tmp_ctx, mprLpCtx()),
lp_iconv_convenience(mprLpCtx()), ev);
}
@@ -109,7 +109,7 @@ static int ejs_doauth(MprVarHandle eid,
goto done;
}
- nt_status = auth_generate_session_info(tmp_ctx, mprLpCtx(), server_info, &session_info);
+ nt_status = auth_generate_session_info(tmp_ctx, mprEventCtx(), mprLpCtx(), server_info, &session_info);
if (!NT_STATUS_IS_OK(nt_status)) {
mprSetPropertyValue(auth, "report", mprString("Session Info generation failed"));
mprSetPropertyValue(auth, "result", mprCreateBoolVar(false));
diff --git a/source4/scripting/ejs/smbcalls_ldb.c b/source4/scripting/ejs/smbcalls_ldb.c
index f47920b9bb..4a157945af 100644
--- a/source4/scripting/ejs/smbcalls_ldb.c
+++ b/source4/scripting/ejs/smbcalls_ldb.c
@@ -453,7 +453,7 @@ static int ejs_ldbConnect(MprVarHandle eid, int argc, char **argv)
dbfile = argv[0];
- ldb = ldb_wrap_connect(mprMemCtx(), mprLpCtx(), dbfile,
+ ldb = ldb_wrap_connect(mprMemCtx(), mprEventCtx(), mprLpCtx(), dbfile,
session_info, creds,
0, (const char **)(argv+1));
if (ldb == NULL) {
diff --git a/source4/scripting/ejs/smbcalls_nbt.c b/source4/scripting/ejs/smbcalls_nbt.c
index 67a85414ca..8c555bf821 100644
--- a/source4/scripting/ejs/smbcalls_nbt.c
+++ b/source4/scripting/ejs/smbcalls_nbt.c
@@ -70,7 +70,7 @@ static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv)
result = 0;
- nt_status = resolve_name(lp_resolve_context(mprLpCtx()), &name, tmp_ctx, &reply_addr, event_context_find(tmp_ctx));
+ nt_status = resolve_name(lp_resolve_context(mprLpCtx()), &name, tmp_ctx, &reply_addr, mprEventCtx());
if (NT_STATUS_IS_OK(nt_status)) {
mprSetPropertyValue(argv[0], "value", mprString(reply_addr));
diff --git a/source4/scripting/ejs/smbcalls_reg.c b/source4/scripting/ejs/smbcalls_reg.c
index e20d91ad2e..ed8653d3a7 100644
--- a/source4/scripting/ejs/smbcalls_reg.c
+++ b/source4/scripting/ejs/smbcalls_reg.c
@@ -70,7 +70,7 @@ static int ejs_reg_open(MprVarHandle eid, int argc, struct MprVar **argv)
struct registry_context *rctx;
WERROR error;
- error = reg_open_samba(mprMemCtx(), &rctx, mprLpCtx(), NULL, NULL);
+ error = reg_open_samba(mprMemCtx(), &rctx, mprEventCtx(), mprLpCtx(), NULL, NULL);
SMB_ASSERT(W_ERROR_IS_OK(error));
mprSetPtrChild(reg, "registry", rctx);
diff --git a/source4/scripting/ejs/smbcalls_rpc.c b/source4/scripting/ejs/smbcalls_rpc.c
index d1e49b4348..94774d708b 100644
--- a/source4/scripting/ejs/smbcalls_rpc.c
+++ b/source4/scripting/ejs/smbcalls_rpc.c
@@ -73,7 +73,7 @@ static int ejs_irpc_connect(MprVarHandle eid, int argc, char **argv)
p->server_name = argv[0];
- ev = event_context_find(p);
+ ev = mprEventCtx();
/* create a messaging context, looping as we have no way to
allocate temporary server ids automatically */
@@ -158,7 +158,7 @@ static int ejs_rpc_connect(MprVarHandle eid, int argc, char **argv)
cli_credentials_set_anonymous(creds);
}
- ev = event_context_find(mprMemCtx());
+ ev = mprEventCtx();
status = dcerpc_pipe_connect(this, &p, binding, iface, creds, ev,
mprLpCtx());
diff --git a/source4/scripting/libjs/provision.js b/source4/scripting/libjs/provision.js
deleted file mode 100644
index 51e2785762..0000000000
--- a/source4/scripting/libjs/provision.js
+++ /dev/null
@@ -1,1254 +0,0 @@
-/*
- backend code for provisioning a Samba4 server
- Copyright Andrew Tridgell 2005
- Released under the GNU GPL version 3 or later
-*/
-
-sys = sys_init();
-
-/*
- return true if the current install seems to be OK
-*/
-function install_ok(session_info, credentials)
-{
- var lp = loadparm_init();
- var ldb = ldb_init();
- ldb.session_info = session_info;
- ldb.credentials = credentials;
- if (lp.get("realm") == "") {
- return false;
- }
- var ok = ldb.connect(lp.get("sam database"));
- if (!ok) {
- return false;
- }
- var res = ldb.search("(cn=Administrator)");
- if (res.error != 0 || res.msgs.length != 1) {
- return false;
- }
- return true;
-}
-
-/*
- find a user or group from a list of possibilities
-*/
-function findnss()
-{
- var i;
- assert(arguments.length >= 2);
- var nssfn = arguments[0];
- for (i=1;i<arguments.length;i++) {
- if (nssfn(arguments[i]) != undefined) {
- return arguments[i];
- }
- }
- printf("Unable to find user/group for %s\n", arguments[1]);
- assert(i<arguments.length);
-}
-
-/*
- add a foreign security principle
- */
-function add_foreign(ldb, subobj, sid, desc)
-{
- var add = sprintf("
-dn: CN=%s,CN=ForeignSecurityPrincipals,%s
-objectClass: top
-objectClass: foreignSecurityPrincipal
-description: %s
-",
- sid, subobj.DOMAINDN, desc);
- /* deliberately ignore errors from this, as the records may
- already exist */
- ldb.add(add);
-}
-
-
-/*
- setup a mapping between a sam name and a unix name
- */
-function setup_name_mapping(info, ldb, sid, unixname)
-{
- var attrs = new Array("dn");
- var res = ldb.search(sprintf("objectSid=%s", sid),
- info.subobj.DOMAINDN, ldb.SCOPE_SUBTREE, attrs);
- if (res.error != 0 || res.msgs.length != 1) {
- info.message("Failed to find record for objectSid %s\n", sid);
- return false;
- }
- var mod = sprintf("
-dn: %s
-changetype: modify
-replace: unixName
-unixName: %s
-",
- res.msgs[0].dn, unixname);
- var ok = ldb.modify(mod);
- if (ok.error != 0) {
- info.message("name mapping for %s failed - %s\n",
- sid, ldb.errstring());
- return false;
- }
- return true;
-}
-
-/*
- return current time as a nt time string
-*/
-function nttime()
-{
- return "" + sys.nttime();
-}
-
-/*
- return current time as a ldap time string
-*/
-function ldaptime()
-{
- return sys.ldaptime(sys.nttime());
-}
-
-/*
- return a date string suitable for a dns zone serial number
-*/
-function datestring()
-{
- var t = sys.ntgmtime(sys.nttime());
- return sprintf("%04u%02u%02u%02u",
- t.tm_year+1900, t.tm_mon+1, t.tm_mday, t.tm_hour);
-}
-
-/*
- return first host IP
-*/
-function hostip()
-{
- var list = sys.interfaces();
- return list[0];
-}
-
-
-/*
- return first part of hostname
-*/
-function hostname()
-{
- var s = split(".", sys.hostname());
- return s[0];
-}
-
-/* the ldb is in bad shape, possibly due to being built from an
- incompatible previous version of the code, so delete it
- completely */
-function ldb_delete(info, ldb)
-{
- info.message("Deleting " + ldb.filename + "\n");
- var lp = loadparm_init();
- sys.unlink(sprintf("%s/%s", lp.get("private dir"), ldb.filename));
- ldb.transaction_cancel();
- ldb.close();
- var ok = ldb.connect(ldb.filename);
- ldb.transaction_start();
- assert(ok);
-}
-
-/*
- erase an ldb, removing all records
-*/
-function ldb_erase(info, ldb)
-{
- var res;
-
- /* delete the specials */
- ldb.del("@INDEXLIST");
- ldb.del("@ATTRIBUTES");
- ldb.del("@OPTIONS");
- ldb.del("@MODULES");
- ldb.del("@PARTITION");
- ldb.del("@KLUDGEACL");
-
- /* and the rest */
- attrs = new Array("dn");
- var basedn = "";
- var res = ldb.search("(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))", basedn, ldb.SCOPE_SUBTREE, attrs);
- var i;
- if (res.error != 0) {
- ldb_delete(info, ldb);
- return;
- }
- for (i=0;i<res.msgs.length;i++) {
- ldb.del(res.msgs[i].dn);
- }
-
- var res = ldb.search("(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))", basedn, ldb.SCOPE_SUBTREE, attrs);
- if (res.error != 0 || res.msgs.length != 0) {
- ldb_delete(info, ldb);
- return;
- }
- assert(res.msgs.length == 0);
-}
-
-/*
- erase an ldb, removing all records
-*/
-function ldb_erase_partitions(info, ldb, ldapbackend)
-{
- var rootDSE_attrs = new Array("namingContexts");
- var lp = loadparm_init();
- var j;
-
- var res = ldb.search("(objectClass=*)", "", ldb.SCOPE_BASE, rootDSE_attrs);
- if (res.error != 0) {
- info.message("rootdse search failed: " + res.errstr + "\n");
- assert(res.error == 0);
- }
- assert(res.msgs.length == 1);
- if (typeof(res.msgs[0].namingContexts) == "undefined") {
- return;
- }
- for (j=0; j<res.msgs[0].namingContexts.length; j++) {
- var anything = "(|(objectclass=*)(distinguishedName=*))";
- var attrs = new Array("distinguishedName");
- var basedn = res.msgs[0].namingContexts[j];
- var k;
- var previous_remaining = 1;
- var current_remaining = 0;
-
- if (ldapbackend && (basedn == info.subobj.DOMAINDN)) {
- /* Only delete objects that were created by provision */
- anything = "(objectcategory=*)";
- }
-
- for (k=0; k < 10 && (previous_remaining != current_remaining); k++) {
- /* and the rest */
- var res2 = ldb.search(anything, basedn, ldb.SCOPE_SUBTREE, attrs);
- var i;
- if (res2.error != 0) {
- if (res2.error == 32) {
- break;
- } else {
- info.message("ldb search(2) failed: " + res2.errstr + "\n");
- continue;
- }
- }
- previous_remaining = current_remaining;
- current_remaining = res2.msgs.length;
- for (i=0;i<res2.msgs.length;i++) {
- ldb.del(res2.msgs[i].dn);
- }
-
- var res3 = ldb.search(anything, basedn, ldb.SCOPE_SUBTREE, attrs);
- if (res3.error != 0) {
- info.message("ldb search(3) failed: " + res3.errstr + "\n");
- continue;
- }
- if (res3.msgs.length != 0) {
- info.message("Failed to delete all records under " + basedn + ", " + res3.msgs.length + " records remaining\n");
- }
- }
- }
-}
-
-function open_ldb(info, dbname, erase)
-{
- var ldb = ldb_init();
- ldb.session_info = info.session_info;
- ldb.credentials = info.credentials;
- ldb.filename = dbname;
-
- var connect_ok = ldb.connect(dbname);
- if (!connect_ok) {
- var lp = loadparm_init();
- sys.unlink(sprintf("%s/%s", lp.get("private dir"), dbname));
- connect_ok = ldb.connect(dbname);
- assert(connect_ok);
- }
-
- ldb.transaction_start();
-
- if (erase) {
- ldb_erase(info, ldb);
- }
- return ldb;
-}
-
-
-/*
- setup a ldb in the private dir
- */
-function setup_add_ldif(ldif, info, ldb, failok)
-{
- var lp = loadparm_init();
- var src = lp.get("setup directory") + "/" + ldif;
-
- var data = sys.file_load(src);
- data = substitute_var(data, info.subobj);
-
- var add_res = ldb.add(data);
- if (add_res.error != 0) {
- info.message("ldb load failed: " + add_res.errstr + "\n");
- if (!failok) {
- assert(add_res.error == 0);
- }
- }
- return (add_res.error == 0);
-}
-
-function setup_modify_ldif(ldif, info, ldb, failok)
-{
- var lp = loadparm_init();
- var src = lp.get("setup directory") + "/" + ldif;
-
- var data = sys.file_load(src);
- data = substitute_var(data, info.subobj);
-
- var mod_res = ldb.modify(data);
- if (mod_res.error != 0) {
- info.message("ldb load failed: " + mod_res.errstr + "\n");
- if (!failok) {
- assert(mod_res.error == 0);
- }
- }
- return (mod_res.error == 0);
-}
-
-
-function setup_ldb(ldif, info, dbname)
-{
- var erase = true;
- var failok = false;
-
- if (arguments.length >= 4) {
- erase = arguments[3];
- }
- if (arguments.length == 5) {
- failok = arguments[4];
- }
- var ldb = open_ldb(info, dbname, erase);
- if (setup_add_ldif(ldif, info, ldb, failok)) {
- var commit_ok = ldb.transaction_commit();
- if (!commit_ok) {
- info.message("ldb commit failed: " + ldb.errstring() + "\n");
- assert(commit_ok);
- }
- }
-}
-
-/*
- setup a ldb in the private dir
- */
-function setup_ldb_modify(ldif, info, ldb)
-{
- var lp = loadparm_init();
-
- var src = lp.get("setup directory") + "/" + ldif;
-
- var data = sys.file_load(src);
- data = substitute_var(data, info.subobj);
-
- var mod_res = ldb.modify(data);
- if (mod_res.error != 0) {
- info.message("ldb load failed: " + mod_res.errstr + "\n");
- return (mod_res.error == 0);
- }
- return (mod_res.error == 0);
-}
-
-/*
- setup a file in the private dir
- */
-function setup_file(template, message, fname, subobj)
-{
- var lp = loadparm_init();
- var f = fname;
- var src = lp.get("setup directory") + "/" + template;
-
- if (! sys.stat(src)) {
- message("Template file not found: %s\n",src);
- assert(0);
- }
-
- sys.unlink(f);
-
- var data = sys.file_load(src);
- data = substitute_var(data, subobj);
-
- ok = sys.file_save(f, data);
- if (!ok) {
- message("failed to create file: " + f + "\n");
- assert(ok);
- }
-}
-
-function provision_default_paths(subobj)
-{
- /* subobj.DNSDOMAIN isn't available at this point */
- var dnsdomain = strlower(subobj.REALM);
- var lp = loadparm_init();
- var paths = new Object();
- paths.smbconf = lp.filename()
- paths.shareconf = lp.get("private dir") + "/" + "share.ldb";
- paths.samdb = lp.get("sam database");
- paths.idmapdb = lp.get("idmap database");
- paths.secrets = lp.get("secrets database");
- paths.templates = lp.get("private dir") + "/" + "templates.ldb";
- paths.keytab = "secrets.keytab";
- paths.dns_keytab = "dns.keytab";
- paths.dns_keytab_abs = lp.get("private dir") + "/" + paths.dns_keytab;
- paths.dns = lp.get("private dir") + "/" + dnsdomain + ".zone";
- paths.named_conf = lp.get("private dir") + "/named.conf";
- paths.winsdb = "wins.ldb";
- paths.ldapdir = lp.get("private dir") + "/ldap";
-
- paths.s4_ldapi_socket = lp.get("private dir") + "/ldapi";
- paths.phpldapadminconfig = lp.get("private dir") + "/phpldapadmin-config.php";
-
- paths.sysvol = lp.get("sysvol", "path");
-
- if (paths.sysvol == undefined) {
- paths.sysvol = lp.get("lock dir") + "/sysvol";
- }
-
- paths.netlogon = lp.get("netlogon", "path");
-
- if (paths.netlogon == undefined) {
- paths.netlogon = paths.sysvol + "/" + dnsdomain + "/scripts";
- }
-
- return paths;
-}
-
-
-/*
- setup reasonable name mappings for sam names to unix names
-*/
-function setup_name_mappings(info, ldb)
-{
- var lp = loadparm_init();
- var attrs = new Array("objectSid");
- var subobj = info.subobj;
-
- res = ldb.search("objectSid=*", subobj.DOMAINDN, ldb.SCOPE_BASE, attrs);
- assert(res.error == 0);
- assert(res.msgs.length == 1 && res.msgs[0].objectSid != undefined);
- var sid = res.msgs[0].objectSid;
-
- /* add some foreign sids if they are not present already */
- add_foreign(ldb, subobj, "S-1-5-7", "Anonymous");
- add_foreign(ldb, subobj, "S-1-1-0", "World");
- add_foreign(ldb, subobj, "S-1-5-2", "Network");
- add_foreign(ldb, subobj, "S-1-5-18", "System");
- add_foreign(ldb, subobj, "S-1-5-11", "Authenticated Users");
-
- /* some well known sids */
- setup_name_mapping(info, ldb, "S-1-5-7", subobj.NOBODY);
- setup_name_mapping(info, ldb, "S-1-1-0", subobj.NOGROUP);
- setup_name_mapping(info, ldb, "S-1-5-2", subobj.NOGROUP);
- setup_name_mapping(info, ldb, "S-1-5-18", subobj.ROOT);
- setup_name_mapping(info, ldb, "S-1-5-11", subobj.USERS);
- setup_name_mapping(info, ldb, "S-1-5-32-544", subobj.WHEEL);
- setup_name_mapping(info, ldb, "S-1-5-32-545", subobj.USERS);
- setup_name_mapping(info, ldb, "S-1-5-32-546", subobj.NOGROUP);
- setup_name_mapping(info, ldb, "S-1-5-32-551", subobj.BACKUP);
-
- /* and some well known domain rids */
- setup_name_mapping(info, ldb, sid + "-500", subobj.ROOT);
- setup_name_mapping(info, ldb, sid + "-518", subobj.WHEEL);
- setup_name_mapping(info, ldb, sid + "-519", subobj.WHEEL);
- setup_name_mapping(info, ldb, sid + "-512", subobj.WHEEL);
- setup_name_mapping(info, ldb, sid + "-513", subobj.USERS);
- setup_name_mapping(info, ldb, sid + "-520", subobj.WHEEL);
-
- return true;
-}
-
-function provision_fix_subobj(subobj, paths)
-{
- var ldb = ldb_init();
-
- subobj.REALM = strupper(subobj.REALM);
- subobj.HOSTNAME = strlower(subobj.HOSTNAME);
- subobj.DOMAIN = strupper(subobj.DOMAIN);
- subobj.NETBIOSNAME = strupper(subobj.HOSTNAME);
- subobj.DNSDOMAIN = strlower(subobj.REALM);
- subobj.DNSNAME = sprintf("%s.%s",
- strlower(subobj.HOSTNAME),
- subobj.DNSDOMAIN);
- var rdn_list = split(".", subobj.DNSDOMAIN);
- subobj.DOMAINDN = "DC=" + join(",DC=", rdn_list);
- subobj.ROOTDN = subobj.DOMAINDN;
- subobj.CONFIGDN = "CN=Configuration," + subobj.ROOTDN;
- subobj.SCHEMADN = "CN=Schema," + subobj.CONFIGDN;
-
- subobj.MACHINEPASS_B64 = ldb.encode(subobj.MACHINEPASS);
- subobj.KRBTGTPASS_B64 = ldb.encode(subobj.KRBTGTPASS);
- subobj.ADMINPASS_B64 = ldb.encode(subobj.ADMINPASS);
- subobj.DNSPASS_B64 = ldb.encode(subobj.DNSPASS);
-
- subobj.SAM_LDB = "tdb://" + paths.samdb;
- subobj.SECRETS_KEYTAB = paths.keytab;
- subobj.DNS_KEYTAB = paths.dns_keytab;
- subobj.DNS_KEYTAB_ABS = paths.dns_keytab_abs;
-
- subobj.LDAPDIR = paths.ldapdir;
- var ldap_path_list = split("/", paths.ldapdir);
- subobj.LDAPI_URI = "ldapi://" + join("%2F", ldap_path_list) + "%2Fldapi";
-
- var s4ldap_path_list = split("/", paths.s4_ldapi_socket);
- subobj.S4_LDAPI_URI = "ldapi://" + join("%2F", s4ldap_path_list);
-
- subobj.LDAPMANAGERDN = "cn=Manager," + subobj.DOMAINDN;
-
- subobj.NETLOGONPATH = paths.netlogon;
- subobj.SYSVOLPATH = paths.sysvol;
-
- if (subobj.DOMAIN_CONF == undefined) {
- subobj.DOMAIN_CONF = subobj.DOMAIN;
- }
- if (subobj.REALM_CONF == undefined) {
- subobj.REALM_CONF = subobj.REALM;
- }
- if (strlower(subobj.SERVERROLE) != strlower("domain controller")) {
- subobj.REALM = subobj.HOSTNAME;
- subobj.DOMAIN = subobj.HOSTNAME;
- }
-
- return true;
-}
-
-function provision_become_dc(subobj, message, erase, paths, session_info)
-{
- var lp = loadparm_init();
- var sys = sys_init();
- var info = new Object();
-
- var ok = provision_fix_subobj(subobj, paths);
- assert(ok);
-
- if (subobj.BACKEND_MOD == undefined) {
- subobj.BACKEND_MOD = "repl_meta_data";
- }
-
- info.subobj = subobj;
- info.message = message;
- info.session_info = session_info;
-
- message("Setting up templates into " + paths.templates + "\n");
- setup_ldb("provision_templates.ldif", info, paths.templates);
-
- /* Also wipes the database */
- message("Setting up " + paths.samdb + " partitions\n");
- setup_ldb("provision_partitions.ldif", info, paths.samdb);
-
- var samdb = open_ldb(info, paths.samdb, false);
-
- message("Setting up " + paths.samdb + " attributes\n");
- setup_add_ldif("provision_init.ldif", info, samdb, false);
-
- message("Setting up " + paths.samdb + " rootDSE\n");
- setup_add_ldif("provision_rootdse_add.ldif", info, samdb, false);
-
- if (erase) {
- message("Erasing data from partitions\n");
- ldb_erase_partitions(info, samdb, undefined);
- }
-
- message("Setting up " + paths.samdb + " indexes\n");
- setup_add_ldif("provision_index.ldif", info, samdb, false);
-
- ok = samdb.transaction_commit();
- assert(ok);
-
- message("Setting up " + paths.secrets + "\n");
- setup_ldb("secrets_init.ldif", info, paths.secrets);
-
- setup_ldb("secrets.ldif", info, paths.secrets, false);
-
- setup_ldb("secrets_dc.ldif", info, paths.secrets, false);
-
- return true;
-}
-
-function load_schema(subobj, message, samdb)
-{
- var lp = loadparm_init();
- var src = lp.get("setup directory") + "/" + "schema.ldif";
-
- if (! sys.stat(src)) {
- message("Template file not found: %s\n",src);
- assert(0);
- }
-
- var schema_data = sys.file_load(src);
-
- src = lp.get("setup directory") + "/" + "schema_samba4.ldif";
-
- if (! sys.stat(src)) {
- message("Template file not found: %s\n",src);
- assert(0);
- }
-
- schema_data = schema_data + sys.file_load(src);
-
- schema_data = substitute_var(schema_data, subobj);
-
- src = lp.get("setup directory") + "/" + "provision_schema_basedn_modify.ldif";
-
- if (! sys.stat(src)) {
- message("Template file not found: %s\n",src);
- assert(0);
- }
-
- var head_data = sys.file_load(src);
- head_data = substitute_var(head_data, subobj);
-
- var ok = samdb.attach_dsdb_schema_from_ldif(head_data, schema_data);
- return ok;
-}
-
-
-/*
- provision samba4 - caution, this wipes all existing data!
-*/
-function provision(subobj, message, blank, paths, session_info, credentials, ldapbackend)
-{
- var lp = loadparm_init();
- var sys = sys_init();
- var info = new Object();
- random_init(local);
-
- var ok = provision_fix_subobj(subobj, paths);
- assert(ok);
-
- if (strlower(subobj.SERVERROLE) == strlower("domain controller")) {
- if (subobj.BACKEND_MOD == undefined) {
- subobj.BACKEND_MOD = "repl_meta_data";
- }
- } else {
- if (subobj.BACKEND_MOD == undefined) {
- subobj.BACKEND_MOD = "objectguid";
- }
- }
-
- if (subobj.DOMAINGUID != undefined) {
- subobj.DOMAINGUID_MOD = sprintf("replace: objectGUID\nobjectGUID: %s\n-", subobj.DOMAINGUID);
- } else {
- subobj.DOMAINGUID_MOD = "";
- }
-
- if (subobj.HOSTGUID != undefined) {
- subobj.HOSTGUID_ADD = sprintf("objectGUID: %s", subobj.HOSTGUID);
- } else {
- subobj.HOSTGUID_ADD = "";
- }
-
- info.subobj = subobj;
- info.message = message;
- info.credentials = credentials;
- info.session_info = session_info;
-
- /* only install a new smb.conf if there isn't one there already */
- var st = sys.stat(paths.smbconf);
- if (st == undefined) {
- var smbconfsuffix;
- if (strlower(subobj.SERVERROLE) == strlower("domain controller")) {
- smbconfsuffix = "dc";
- } else if (strlower(subobj.SERVERROLE) == strlower("member server")) {
- smbconfsuffix = "member";
- } else {
- smbconfsuffix = subobj.SERVERROLE;
- }
- message("Setting up " + paths.smbconf +"\n");
- setup_file("provision.smb.conf." + smbconfsuffix, info.message, paths.smbconf, subobj);
- lp.reload();
- }
- /* only install a new shares config db if there is none */
- st = sys.stat(paths.shareconf);
- if (st == undefined) {
- message("Setting up share.ldb\n");
- setup_ldb("share.ldif", info, paths.shareconf);
- }
-
- message("Setting up " + paths.secrets + "\n");
- setup_ldb("secrets_init.ldif", info, paths.secrets);
- setup_ldb("secrets.ldif", info, paths.secrets, false);
-
- message("Setting up the registry\n");
- var reg = reg_open();
- reg.apply_patchfile(lp.get("setup directory") + "/provision.reg")
-
- message("Setting up templates into " + paths.templates + "\n");
- setup_ldb("provision_templates.ldif", info, paths.templates);
-
- message("Setting up " + paths.idmapdb +"\n");
- setup_ldb("idmap_init.ldif", info, paths.idmapdb);
-
- message("Setting up sam.ldb partitions\n");
- /* Also wipes the database */
- setup_ldb("provision_partitions.ldif", info, paths.samdb);
-
- var samdb = open_ldb(info, paths.samdb, false);
-
- message("Setting up sam.ldb attributes\n");
- setup_add_ldif("provision_init.ldif", info, samdb, false);
-
- message("Setting up sam.ldb rootDSE\n");
- setup_add_ldif("provision_rootdse_add.ldif", info, samdb, false);
-
- message("Erasing data from partitions\n");
- ldb_erase_partitions(info, samdb, ldapbackend);
-
- // (hack) Reload, now we have the partitions and rootdse loaded.
- var commit_ok = samdb.transaction_commit();
- if (!commit_ok) {
- info.message("samdb commit failed: " + samdb.errstring() + "\n");
- assert(commit_ok);
- }
- samdb.close();
-
- message("Pre-loading the Samba4 and AD schema\n");
-
- samdb = open_ldb(info, paths.samdb, false);
-
- samdb.set_domain_sid(subobj.DOMAINSID);
-
- if (strlower(subobj.SERVERROLE) == strlower("domain controller")) {
- if (subobj.INVOCATIONID == undefined) {
- subobj.INVOCATIONID = randguid();
- }
- samdb.set_ntds_invocationId(subobj.INVOCATIONID);
- if (subobj.BACKEND_MOD == undefined) {
- subobj.BACKEND_MOD = "repl_meta_data";
- }
- } else {
- if (subobj.BACKEND_MOD == undefined) {
- subobj.BACKEND_MOD = "objectguid";
- }
- }
-
- var load_schema_ok = load_schema(subobj, message, samdb);
- assert(load_schema_ok.is_ok);
-
- message("Adding DomainDN: " + subobj.DOMAINDN + " (permitted to fail)\n");
- var add_ok = setup_add_ldif("provision_basedn.ldif", info, samdb, true);
- message("Modifying DomainDN: " + subobj.DOMAINDN + "\n");
- var modify_basedn_ok = setup_ldb_modify("provision_basedn_modify.ldif", info, samdb);
- if (!modify_basedn_ok) {
- if (!add_ok) {
- message("%s", "Failed to both add and modify " + subobj.DOMAINDN + " in target " + subobj.DOMAINDN_LDB + ": " + samdb.errstring() + "\n");
- message("Perhaps you need to run the provision script with the --ldap-base-dn option, and add this record to the backend manually\n");
- };
- assert(modify_basedn_ok);
- };
-
- message("Adding configuration container (permitted to fail)\n");
- var add_config_ok = setup_add_ldif("provision_configuration_basedn.ldif", info, samdb, true);
- message("Modifying configuration container\n");
- var modify_config_ok = setup_ldb_modify("provision_configuration_basedn_modify.ldif", info, samdb);
- if (!modify_config_ok) {
- if (!add_config_ok) {
- message("%s", "Failed to both add and modify " + subobj.CONFIGDN + " in target " + subobj.CONFIGDN_LDB + ": " + samdb.errstring() + "\n");
- message("Perhaps you need to run the provision script with the --ldap-base-dn option, and add this record to the backend manually\n");
- }
- assert(modify_config_ok);
- }
-
- message("Adding schema container (permitted to fail)\n");
- var add_schema_ok = setup_add_ldif("provision_schema_basedn.ldif", info, samdb, true);
- message("Modifying schema container\n");
- var modify_schema_ok = setup_ldb_modify("provision_schema_basedn_modify.ldif", info, samdb);
- if (!modify_schema_ok) {
- if (!add_schema_ok) {
- message("%s", "Failed to both add and modify " + subobj.SCHEMADN + " in target " + subobj.SCHEMADN_LDB + ": " + samdb.errstring() + "\n");
- message("Perhaps you need to run the provision script with the --ldap-base-dn option, and add this record to the backend manually\n");
- }
- message("Failed to modify the schema container: " + samdb.errstring() + "\n");
- assert(modify_schema_ok);
- }
-
- message("Setting up sam.ldb Samba4 schema\n");
- setup_add_ldif("schema_samba4.ldif", info, samdb, false);
- message("Setting up sam.ldb AD schema\n");
- setup_add_ldif("schema.ldif", info, samdb, false);
-
- message("Setting up sam.ldb configuration data\n");
- setup_add_ldif("provision_configuration.ldif", info, samdb, false);
-
- message("Setting up display specifiers\n");
- setup_add_ldif("display_specifiers.ldif", info, samdb, false);
-
- message("Adding users container (permitted to fail)\n");
- var add_users_ok = setup_add_ldif("provision_users_add.ldif", info, samdb, true);
- message("Modifying users container\n");
- var modify_users_ok = setup_ldb_modify("provision_users_modify.ldif", info, samdb);
- if (!modify_users_ok) {
- if (!add_users_ok) {
- message("Failed to both add and modify the users container\n");
- }
- assert(modify_users_ok);
- }
- message("Adding computers container (permitted to fail)\n");
- var add_computers_ok = setup_add_ldif("provision_computers_add.ldif", info, samdb, true);
- message("Modifying computers container\n");
- var modify_computers_ok = setup_ldb_modify("provision_computers_modify.ldif", info, samdb);
- if (!modify_computers_ok) {
- if (!add_computers_ok) {
- message("Failed to both add and modify the computers container\n");
- }
- assert(modify_computers_ok);
- }
-
- message("Setting up sam.ldb data\n");
- setup_add_ldif("provision.ldif", info, samdb, false);
-
- if (blank != false) {
- message("Setting up sam.ldb index\n");
- setup_add_ldif("provision_index.ldif", info, samdb, false);
-
- message("Setting up sam.ldb rootDSE marking as syncronized\n");
- setup_modify_ldif("provision_rootdse_modify.ldif", info, samdb, false);
-
- var commit_ok = samdb.transaction_commit();
- if (!commit_ok) {
- info.message("ldb commit failed: " + samdb.errstring() + "\n");
- assert(commit_ok);
- }
- return true;
- }
-
-// message("Activate schema module");
-// setup_modify_ldif("schema_activation.ldif", info, samdb, false);
-//
-// // (hack) Reload, now we have the schema loaded.
-// var commit_ok = samdb.transaction_commit();
-// if (!commit_ok) {
-// info.message("samdb commit failed: " + samdb.errstring() + "\n");
-// assert(commit_ok);
-// }
-// samdb.close();
-//
-// samdb = open_ldb(info, paths.samdb, false);
-//
- message("Setting up sam.ldb users and groups\n");
- setup_add_ldif("provision_users.ldif", info, samdb, false);
-
- if (strlower(subobj.SERVERROLE) == strlower("domain controller")) {
- message("Setting up self join\n");
- setup_add_ldif("provision_self_join.ldif", info, samdb, false);
- setup_add_ldif("provision_group_policy.ldif", info, samdb, false);
-
- sys.mkdir(paths.sysvol, 0755);
- sys.mkdir(paths.sysvol + "/"+ subobj.DNSDOMAIN, 0755);
- sys.mkdir(paths.sysvol + "/"+ subobj.DNSDOMAIN + "/Policies", 0755);
- sys.mkdir(paths.sysvol + "/"+ subobj.DNSDOMAIN + "/Policies/{" + subobj.POLICYGUID + "}", 0755);
- sys.mkdir(paths.sysvol + "/"+ subobj.DNSDOMAIN + "/Policies/{" + subobj.POLICYGUID + "}/Machine", 0755);
- sys.mkdir(paths.sysvol + "/"+ subobj.DNSDOMAIN + "/Policies/{" + subobj.POLICYGUID + "}/User", 0755);
-
- sys.mkdir(paths.netlogon, 0755);
-
- setup_ldb("secrets_dc.ldif", info, paths.secrets, false);
-
- }
-
- if (setup_name_mappings(info, samdb) == false) {
- return false;
- }
-
- message("Setting up sam.ldb index\n");
- setup_add_ldif("provision_index.ldif", info, samdb, false);
-
- message("Setting up sam.ldb rootDSE marking as syncronized\n");
- setup_modify_ldif("provision_rootdse_modify.ldif", info, samdb, false);
-
- var commit_ok = samdb.transaction_commit();
- if (!commit_ok) {
- info.message("samdb commit failed: " + samdb.errstring() + "\n");
- assert(commit_ok);
- }
-
- message("Setting up phpLDAPadmin configuration\n");
- setup_file("phpldapadmin-config.php", info.message, paths.phpldapadminconfig, subobj);
- message("Please install the phpLDAPadmin configuration located at " + paths.phpldapadminconfig + " into /etc/phpldapadmin/config.php\n");
-
- return true;
-}
-
-/*
- provision just the schema into a temporary ldb, so we can run ad2oLschema on it
-*/
-function provision_schema(subobj, message, tmp_schema_path, paths)
-{
- var lp = loadparm_init();
- var sys = sys_init();
- var info = new Object();
-
- var ok = provision_fix_subobj(subobj, paths);
- assert(ok);
-
- info.subobj = subobj;
- info.message = message;
-
- message("Setting up sam.ldb partitions\n");
-
- /* This will erase anything in the tmp db */
- var samdb = open_ldb(info, tmp_schema_path, true);
-
- message("Setting up sam.ldb attributes\n");
- setup_add_ldif("provision_init.ldif", info, samdb, false);
-
- message("Setting up sam.ldb rootDSE\n");
- setup_add_ldif("provision_rootdse_add.ldif", info, samdb, false);
-
- message("Adding schema container (permitted to fail)\n");
- var add_ok = setup_add_ldif("provision_schema_basedn.ldif", info, samdb, true);
- message("Modifying schema container\n");
- var modify_ok = setup_ldb_modify("provision_schema_basedn_modify.ldif", info, samdb);
- if (!modify_ok) {
- if (!add_ok) {
- message("Failed to both add and modify schema dn: " + samdb.errstring() + "\n");
- message("Perhaps you need to run the provision script with the --ldap-base-dn option, and add this record to the backend manually\n");
- assert(modify_ok);
- }
- message("Failed to modify the schema container: " + samdb.errstring() + "\n");
- assert(modify_ok);
- }
-
- message("Setting up sam.ldb Samba4 schema\n");
- setup_add_ldif("schema_samba4.ldif", info, samdb, false);
- message("Setting up sam.ldb AD schema\n");
- setup_add_ldif("schema.ldif", info, samdb, false);
-
- var commit_ok = samdb.transaction_commit();
- if (!commit_ok) {
- info.message("samdb commit failed: " + samdb.errstring() + "\n");
- assert(commit_ok);
- }
- samdb.close();
-}
-
-/* Write out a DNS zone file, from the info in the current database */
-function provision_dns(subobj, message, paths, session_info, credentials)
-{
- var lp = loadparm_init();
- if (strlower(subobj.SERVERROLE) != strlower("domain controller")) {
- message("No DNS zone required for role %s\n", subobj.SERVERROLE);
- return;
- }
- message("Setting up DNS zone: " + subobj.DNSDOMAIN + " \n");
- var ldb = ldb_init();
- ldb.session_info = session_info;
- ldb.credentials = credentials;
-
- /* connect to the sam */
- var ok = ldb.connect(paths.samdb);
- assert(ok);
-
- /* These values may have changed, due to an incoming SamSync,
- or may not have been specified, so fetch them from the database */
-
- var attrs = new Array("objectGUID");
- res = ldb.search("objectGUID=*", subobj.DOMAINDN, ldb.SCOPE_BASE, attrs);
- assert(res.error == 0);
- assert(res.msgs.length == 1);
- assert(res.msgs[0].objectGUID != undefined);
- subobj.DOMAINGUID = res.msgs[0].objectGUID;
-
- subobj.HOSTGUID = searchone(ldb, subobj.DOMAINDN, "(&(objectClass=computer)(cn=" + subobj.NETBIOSNAME + "))", "objectGUID");
- assert(subobj.HOSTGUID != undefined);
-
- setup_file("provision.zone",
- message, paths.dns,
- subobj);
-
- setup_file("named.conf",
- message, paths.named_conf,
- subobj);
-
- message("Please install the zone located in " + paths.dns + " into your DNS server. A sample BIND configuration snippit is at " + paths.named_conf + "\n");
-}
-
-
-/*
- guess reasonably default options for provisioning
-*/
-function provision_guess()
-{
- var subobj = new Object();
- var nss = nss_init();
- var lp = loadparm_init();
- var rdn_list;
- random_init(local);
-
- subobj.SERVERROLE = strlower(lp.get("server role"));
- subobj.REALM = strupper(lp.get("realm"));
- subobj.DOMAIN = lp.get("workgroup");
- subobj.HOSTNAME = hostname();
-
- assert(subobj.REALM);
- assert(subobj.DOMAIN);
- assert(subobj.HOSTNAME);
-
- subobj.VERSION = version();
- subobj.HOSTIP = hostip();
- subobj.DOMAINSID = randsid();
- subobj.POLICYGUID = randguid();
- subobj.KRBTGTPASS = randpass(12);
- subobj.MACHINEPASS = randpass(12);
- subobj.DNSPASS = randpass(12);
- subobj.ADMINPASS = randpass(12);
- subobj.LDAPMANAGERPASS = randpass(12);
- subobj.DEFAULTSITE = "Default-First-Site-Name";
- subobj.DATESTRING = datestring;
- subobj.ROOT = findnss(nss.getpwnam, "root");
- subobj.NOBODY = findnss(nss.getpwnam, "nobody");
- subobj.NOGROUP = findnss(nss.getgrnam, "nogroup", "nobody");
- subobj.WHEEL = findnss(nss.getgrnam, "wheel", "root", "staff", "adm");
- subobj.BACKUP = findnss(nss.getgrnam, "backup", "wheel", "root", "staff");
- subobj.USERS = findnss(nss.getgrnam, "users", "guest", "other", "unknown", "usr");
-
- //Add modules to the list to activate them by default
- //beware often order is important
- //
- // Some Known ordering constraints:
- // - rootdse must be first, as it makes redirects from "" -> cn=rootdse
- // - objectclass must be before password_hash, because password_hash checks
- // that the objectclass is of type person (filled in by the objectclass
- // module when expanding the objectclass list)
- // - partition must be last
- // - each partition has its own module list then
- var modules_list = new Array("rootdse",
- "paged_results",
- "ranged_results",
- "anr",
- "server_sort",
- "extended_dn",
- "asq",
- "samldb",
- "rdn_name",
- "objectclass",
- "kludge_acl",
- "operational");
- var tdb_modules_list = new Array("subtree_rename",
- "subtree_delete",
- "linked_attributes");
- var modules_list2 = new Array("show_deleted",
- "partition");
- subobj.MODULES_LIST = join(",", modules_list);
- subobj.TDB_MODULES_LIST = "," + join(",", tdb_modules_list);
- subobj.MODULES_LIST2 = join(",", modules_list2);
- subobj.DOMAINDN_LDB = "users.ldb";
- subobj.CONFIGDN_LDB = "configuration.ldb";
- subobj.SCHEMADN_LDB = "schema.ldb";
- subobj.DOMAINDN_MOD = "pdc_fsmo,password_hash,instancetype";
- subobj.CONFIGDN_MOD = "naming_fsmo,instancetype";
- subobj.SCHEMADN_MOD = "schema_fsmo,instancetype";
-
- subobj.ACI = "# no aci for local ldb";
-
- return subobj;
-}
-
-/*
- search for one attribute as a string
- */
-function searchone(ldb, basedn, expression, attribute)
-{
- var attrs = new Array(attribute);
- res = ldb.search(expression, basedn, ldb.SCOPE_SUBTREE, attrs);
- if (res.error != 0 ||
- res.msgs.length != 1 ||
- res.msgs[0][attribute] == undefined) {
- return undefined;
- }
- return res.msgs[0][attribute];
-}
-
-/*
- modify an account to remove the
-*/
-function enable_account(ldb, user_dn)
-{
- var attrs = new Array("userAccountControl");
- var res = ldb.search(NULL, user_dn, ldb.SCOPE_ONELEVEL, attrs);
- assert(res.error == 0);
- assert(res.msgs.length == 1);
- var userAccountControl = res.msgs[0].userAccountControl;
- userAccountControl = userAccountControl - 2; /* remove disabled bit */
- var mod = sprintf("
-dn: %s
-changetype: modify
-replace: userAccountControl
-userAccountControl: %u
-",
- user_dn, userAccountControl);
- var ok = ldb.modify(mod);
- return (ok.error == 0);
-}
-
-
-/*
- add a new user record
-*/
-function newuser(username, unixname, password, message, session_info, credentials)
-{
- var lp = loadparm_init();
- var samdb = lp.get("sam database");
- var ldb = ldb_init();
- random_init(local);
- ldb.session_info = session_info;
- ldb.credentials = credentials;
-
- /* connect to the sam */
- var ok = ldb.connect(samdb);
- assert(ok);
-
- ldb.transaction_start();
-
- /* find the DNs for the domain and the domain users group */
- var attrs = new Array("defaultNamingContext");
- res = ldb.search("defaultNamingContext=*", "", ldb.SCOPE_BASE, attrs);
- assert(res.error == 0);
- assert(res.msgs.length == 1 && res.msgs[0].defaultNamingContext != undefined);
- var domain_dn = res.msgs[0].defaultNamingContext;
- assert(domain_dn != undefined);
- var dom_users = searchone(ldb, domain_dn, "name=Domain Users", "dn");
- assert(dom_users != undefined);
-
- var user_dn = sprintf("CN=%s,CN=Users,%s", username, domain_dn);
-
-
- /*
- the new user record. note the reliance on the samdb module to fill
- in a sid, guid etc
- */
- var ldif = sprintf("
-dn: %s
-sAMAccountName: %s
-unixName: %s
-sambaPassword: %s
-objectClass: user
-",
- user_dn, username,
- unixname, password);
- /*
- add the user to the users group as well
- */
- var modgroup = sprintf("
-dn: %s
-changetype: modify
-add: member
-member: %s
-",
- dom_users, user_dn);
-
-
- /*
- now the real work
- */
- message("Adding user %s\n", user_dn);
- ok = ldb.add(ldif);
- if (ok.error != 0) {
- message("Failed to add %s - %s\n", user_dn, ok.errstr);
- return false;
- }
-
- message("Modifying group %s\n", dom_users);
- ok = ldb.modify(modgroup);
- if (ok.error != 0) {
- message("Failed to modify %s - %s\n", dom_users, ok.errstr);
- return false;
- }
-
- /*
- modify the userAccountControl to remove the disabled bit
- */
- ok = enable_account(ldb, user_dn);
- if (ok) {
- ldb.transaction_commit();
- }
- return ok;
-}
-
-// Check whether a name is valid as a NetBIOS name.
-// FIXME: There are probably more constraints here.
-// crh has a paragraph on this in his book (1.4.1.1)
-function valid_netbios_name(name)
-{
- if (strlen(name) > 15) return false;
- return true;
-}
-
-function provision_validate(subobj, message)
-{
- var lp = loadparm_init();
-
- if (!valid_netbios_name(subobj.DOMAIN)) {
- message("Invalid NetBIOS name for domain\n");
- return false;
- }
-
- if (!valid_netbios_name(subobj.NETBIOSNAME)) {
- message("Invalid NetBIOS name for host\n");
- return false;
- }
-
-
- if (strupper(lp.get("workgroup")) != strupper(subobj.DOMAIN_CONF)) {
- message("workgroup '%s' in smb.conf must match chosen domain '%s'\n",
- lp.get("workgroup"), subobj.DOMAIN_CONF);
- return false;
- }
-
- if (strupper(lp.get("realm")) != strupper(subobj.REALM_CONF)) {
- message("realm '%s' in smb.conf must match chosen realm '%s'\n",
- lp.get("realm"), subobj.REALM_CONF);
- return false;
- }
-
- if (strlower(lp.get("server role")) != strlower(subobj.SERVERROLE)) {
- message("server role '%s' in smb.conf must match chosen role '%s'\n",
- lp.get("server role"), subobj.SERVERROLE);
- return false;
- }
-
- return true;
-}
-
-function join_domain(domain, netbios_name, join_type, creds, message)
-{
- var ctx = NetContext(creds);
- var joindom = new Object();
- joindom.domain = domain;
- joindom.join_type = join_type;
- joindom.netbios_name = netbios_name;
- if (!ctx.JoinDomain(joindom)) {
- message("Domain Join failed: " + joindom.error_string);
- return false;
- }
- return true;
-}
-
-/* Vampire a remote domain. Session info and credentials are required for for
- * access to our local database (might be remote ldap)
- */
-
-function vampire(domain, session_info, credentials, message) {
- var ctx = NetContext(credentials);
- var vampire_ctx = new Object();
- var machine_creds = credentials_init();
- machine_creds.set_domain(form.DOMAIN);
- if (!machine_creds.set_machine_account()) {
- message("Failed to access domain join information!");
- return false;
- }
- vampire_ctx.machine_creds = machine_creds;
- vampire_ctx.session_info = session_info;
- if (!ctx.SamSyncLdb(vampire_ctx)) {
- message("Migration of remote domain to Samba failed: " + vampire_ctx.error_string);
- return false;
- }
-
- return true;
-}
-
-return 0;
diff --git a/source4/scripting/libjs/samr.js b/source4/scripting/libjs/samr.js
deleted file mode 100644
index 6e8c70af3c..0000000000
--- a/source4/scripting/libjs/samr.js
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- samr rpc utility functions
- Copyright Andrew Tridgell 2005
- released under the GNU GPL version 3 or later
-*/
-
-if (global["HAVE_SAMR_JS"] != undefined) {
- return;
-}
-HAVE_SAMR_JS=1
-
-/*
- return a list of names and indexes from a samArray
-*/
-function samArray(output)
-{
- var list = new Array(output.num_entries);
- if (output.sam == NULL) {
- return list;
- }
- var i, entries = output.sam.entries;
- for (i=0;i<output.num_entries;i++) {
- list[i] = new Object();
- list[i].name = entries[i].name;
- list[i].idx = entries[i].idx;
- }
- return list;
-}
-
-/*
- connect to the sam database
-*/
-function samrConnect(conn)
-{
- security_init(conn);
- var io = irpcObj();
- io.input.system_name = NULL;
- io.input.access_mask = conn.SEC_FLAG_MAXIMUM_ALLOWED;
- var status = conn.samr_Connect2(io);
- check_status_ok(status);
- return io.output.connect_handle;
-}
-
-/*
- close a handle
-*/
-function samrClose(conn, handle)
-{
- var io = irpcObj();
- io.input.handle = handle;
- var status = conn.samr_Close(io);
- check_status_ok(status);
-}
-
-/*
- get the sid for a domain
-*/
-function samrLookupDomain(conn, handle, domain)
-{
- var io = irpcObj();
- io.input.connect_handle = handle;
- io.input.domain_name = domain;
- var status = conn.samr_LookupDomain(io);
- check_status_ok(status);
- return io.output.sid;
-}
-
-/*
- open a domain by sid
-*/
-function samrOpenDomain(conn, handle, sid)
-{
- var io = irpcObj();
- io.input.connect_handle = handle;
- io.input.access_mask = conn.SEC_FLAG_MAXIMUM_ALLOWED;
- io.input.sid = sid;
- var status = conn.samr_OpenDomain(io);
- check_status_ok(status);
- return io.output.domain_handle;
-}
-
-/*
- open a user by rid
-*/
-function samrOpenUser(conn, handle, rid)
-{
- var io = irpcObj();
- io.input.domain_handle = handle;
- io.input.access_mask = conn.SEC_FLAG_MAXIMUM_ALLOWED;
- io.input.rid = rid;
- var status = conn.samr_OpenUser(io);
- check_status_ok(status);
- return io.output.user_handle;
-}
-
-/*
- return a list of all users
-*/
-function samrEnumDomainUsers(conn, dom_handle)
-{
- var io = irpcObj();
- io.input.domain_handle = dom_handle;
- io.input.resume_handle = 0;
- io.input.acct_flags = 0;
- io.input.max_size = -1;
- var status = conn.samr_EnumDomainUsers(io);
- check_status_ok(status);
- return samArray(io.output);
-}
-
-/*
- return a list of all groups
-*/
-function samrEnumDomainGroups(conn, dom_handle)
-{
- var io = irpcObj();
- io.input.domain_handle = dom_handle;
- io.input.resume_handle = 0;
- io.input.acct_flags = 0;
- io.input.max_size = -1;
- var status = conn.samr_EnumDomainGroups(io);
- check_status_ok(status);
- return samArray(io.output);
-}
-
-/*
- return a list of domains
-*/
-function samrEnumDomains(conn, handle)
-{
- var io = irpcObj();
- io.input.connect_handle = handle;
- io.input.resume_handle = 0;
- io.input.buf_size = -1;
- var status = conn.samr_EnumDomains(io);
- check_status_ok(status);
- return samArray(io.output);
-}
-
-/*
- return information about a user
-*/
-function samrQueryUserInfo(conn, user_handle, level)
-{
- var r, io = irpcObj();
- io.input.user_handle = user_handle;
- io.input.level = level;
- var status = conn.samr_QueryUserInfo(io);
- check_status_ok(status);
- return io.output.info.info3;
-}
-
-
-/*
- fill a user array with user information from samrQueryUserInfo
-*/
-function samrFillUserInfo(conn, dom_handle, users, level)
-{
- var i;
- for (i=0;i<users.length;i++) {
- var r, user_handle, info;
- user_handle = samrOpenUser(conn, dom_handle, users[i].idx);
- info = samrQueryUserInfo(conn, user_handle, level);
- info.name = users[i].name;
- info.idx = users[i].idx;
- users[i] = info;
- samrClose(conn, user_handle);
- }
-}
-
diff --git a/source4/scripting/libjs/winreg.js b/source4/scripting/libjs/winreg.js
deleted file mode 100644
index 9db415694d..0000000000
--- a/source4/scripting/libjs/winreg.js
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- winreg rpc utility functions
- Copyright Andrew Tridgell 2005
- released under the GNU GPL version 3 or later
-*/
-
-libinclude("base.js");
-
-/*
- close a handle
-*/
-function __winreg_close(handle)
-{
- var io = irpcObj();
- io.input.handle = handle;
- this.winreg_CloseKey(io);
-}
-
-
-/*
- open a hive
-*/
-function __winreg_open_hive(hive)
-{
- var io = irpcObj();
- io.input.system_name = NULL;
- io.input.access_mask = this.SEC_FLAG_MAXIMUM_ALLOWED;
- var status;
- if (hive == "HKLM") {
- status = this.winreg_OpenHKLM(io);
- } else if (hive == "HKCR") {
- status = this.winreg_OpenHKCR(io);
- } else if (hive == "HKPD") {
- status = this.winreg_OpenHKPD(io);
- } else if (hive == "HKU") {
- status = this.winreg_OpenHKU(io);
- } else {
- this._last_error = "Unknown hive " + hive;
- return undefined;
- }
- if (!status.is_ok) {
- return undefined;
- }
- return io.output.handle;
-}
-
-/*
- open a handle to a path
-*/
-function __winreg_open_path(path)
-{
- var s = string_init();
- var i, components = s.split('\\', path);
-
- /* cope with a leading slash */
- if (components[0] == '') {
- for (i=0;i<(components.length-1);i++) {
- components[i] = components[i+1];
- }
- delete(components[i]);
- }
-
- if (components.length == 0) {
- return undefined;
- }
-
- var handle = this.open_hive(components[0]);
- if (handle == undefined) {
- return undefined;
- }
-
- if (components.length == 1) {
- return handle;
- }
-
- var hpath = components[1];
-
- for (i=2;i<components.length;i++) {
- hpath = hpath + "\\" + components[i];
- }
-
- io = irpcObj();
- io.input.parent_handle = handle;
- io.input.keyname = hpath;
- io.input.unknown = 0;
- io.input.access_mask = this.SEC_FLAG_MAXIMUM_ALLOWED;
- var status = this.winreg_OpenKey(io);
-
- this.close(handle);
-
- if (!status.is_ok) {
- return undefined;
- }
- if (io.output.result != "WERR_OK") {
- return undefined;
- }
-
- return io.output.handle;
-}
-
-/*
- return a list of keys for a winreg server given a path
- usage:
- list = reg.enum_path(path);
-*/
-function __winreg_enum_path(path)
-{
- var list = new Array(0);
-
- if (path == null || path == "\\" || path == "") {
- return new Array("HKLM", "HKU");
- }
-
- var handle = this.open_path(path);
- if (handle == undefined) {
- return undefined;
- }
-
- var io = irpcObj();
- io.input.handle = handle;
- io.input.name = new Object();
- io.input.name.length = 0;
- io.input.name.size = 32;
- io.input.name.name = NULL;
- io.input.keyclass = new Object();
- io.input.keyclass.length = 0;
- io.input.keyclass.size = 1024;
- io.input.keyclass.name = NULL;
- io.input.last_changed_time = 0;
-
- var idx = 0;
- for (idx=0;idx >= 0;idx++) {
- io.input.enum_index = idx;
- var status = this.winreg_EnumKey(io);
- if (!status.is_ok) {
- this.close(handle);
- return list;
- }
- var out = io.output;
- if (out.result == "WERR_MORE_DATA") {
- io.input.name.size = io.input.name.size * 2;
- idx--;
- if (io.input.name.size > 32000) {
- this.close(handle);
- return list;
- }
- continue;
- }
- if (out.result != "WERR_OK") {
- this.close(handle);
- return list;
- }
- list[list.length] = out.name.name;
- }
-
- this.close(handle);
- return list;
-}
-
-
-/*
- return a list of values for a winreg server given a path
- usage:
- list = reg.enum_values(path);
-
- each returned list element is an object containing a name, a
- type and a value
-*/
-function __winreg_enum_values(path)
-{
- var data = datablob_init();
- var list = new Array(0);
-
- var handle = this.open_path(path);
- if (handle == undefined) {
- return undefined;
- }
-
- var io = irpcObj();
- io.input.handle = handle;
- io.input.name = new Object();
- io.input.name.length = 0;
- io.input.name.size = 128;
- io.input.name.name = "";
- io.input.type = 0;
- io.input.value = new Array(0);
- io.input.size = 1024;
- io.input.length = 0;
-
- var idx;
- for (idx=0;idx >= 0;idx++) {
- io.input.enum_index = idx;
- var status = this.winreg_EnumValue(io);
- if (!status.is_ok) {
- this.close(handle);
- return list;
- }
- var out = io.output;
- if (out.result == "WERR_MORE_DATA") {
- io.input.size = io.input.size * 2;
- io.input.name.size = io.input.name.size * 2;
- idx--;
- /* limit blobs to 1M */
- if (io.input.size > 1000000) {
- this.close(handle);
- return list;
- }
- continue;
- }
- if (out.result != "WERR_OK") {
- this.close(handle);
- return list;
- }
- var el = new Object();
- el.name = out.name.name;
- el.type = out.type;
- el.rawvalue = out.value;
- el.value = data.regToVar(el.rawvalue, el.type);
- el.size = out.size;
- list[list.length] = el;
- }
-
- this.close(handle);
- return list;
-}
-
-
-/*
- create a new key
- ok = reg.create_key(path, key);
-*/
-function __winreg_create_key(path, key)
-{
- var handle = this.open_path(path);
- if (handle == undefined) {
- return undefined;
- }
-
- var io = irpcObj();
- io.input.handle = handle;
- io.input.name = key;
- io.input.keyclass = NULL;
- io.input.options = 0;
- io.input.access_mask = this.SEC_FLAG_MAXIMUM_ALLOWED;
- io.input.secdesc = NULL;
- io.input.action_taken = 0;
-
- var status = this.winreg_CreateKey(io);
- this.close(handle);
- if (!status.is_ok) {
- return false;
- }
- if (io.output.result != "WERR_OK") {
- return false;
- }
- this.close(io.output.new_handle);
- return true;
-}
-
-
-/*
- return a string for a winreg type
-*/
-function __winreg_typestring(type)
-{
- return this.typenames[type];
-}
-
-/*
- initialise the winreg lib, returning an object
-*/
-function winregObj()
-{
- var reg = winreg_init();
- security_init(reg);
-
- reg.typenames = new Array("REG_NONE", "REG_SZ", "REG_EXPAND_SZ", "REG_BINARY",
- "REG_DWORD", "REG_DWORD_BIG_ENDIAN", "REG_LINK", "REG_MULTI_SZ",
- "REG_RESOURCE_LIST", "REG_FULL_RESOURCE_DESCRIPTOR",
- "REG_RESOURCE_REQUIREMENTS_LIST", "REG_QWORD");
-
- reg.close = __winreg_close;
- reg.open_hive = __winreg_open_hive;
- reg.open_path = __winreg_open_path;
- reg.enum_path = __winreg_enum_path;
- reg.enum_values = __winreg_enum_values;
- reg.create_key = __winreg_create_key;
- reg.typestring = __winreg_typestring;
-
- return reg;
-}
diff --git a/source4/scripting/python/config.m4 b/source4/scripting/python/config.m4
index 3790071ba8..b599aaefb0 100644
--- a/source4/scripting/python/config.m4
+++ b/source4/scripting/python/config.m4
@@ -5,7 +5,7 @@ AC_ARG_VAR([PYTHON_VERSION],[The installed Python
will be appended to the Python interpreter
canonical name.])
-AC_PROG_SWIG(1.3.31)
+AC_PROG_SWIG(1.3.35)
AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]])
if test -z "$PYTHON"; then
@@ -64,10 +64,14 @@ SMB_EXT_LIB(EXT_LIB_PYTHON, [$PYTHON_LDFLAGS], [$PYTHON_CFLAGS])
AC_MSG_CHECKING(working python module support)
if test $working_python = yes; then
SMB_ENABLE(EXT_LIB_PYTHON,YES)
- SMB_ENABLE(smbpython,YES)
SMB_ENABLE(LIBPYTHON,YES)
AC_MSG_RESULT([yes])
else
AC_MSG_ERROR([Python not found. Please install Python 2.x and its development headers/libraries.])
fi
+AC_MSG_CHECKING(python library directory)
+pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1, 0, '\\${prefix}')"`
+AC_MSG_RESULT($pythondir)
+
+AC_SUBST(pythondir)
diff --git a/source4/scripting/python/config.mk b/source4/scripting/python/config.mk
index 09c77813ca..b494ee6e8d 100644
--- a/source4/scripting/python/config.mk
+++ b/source4/scripting/python/config.mk
@@ -1,49 +1,37 @@
-[BINARY::smbpython]
-PRIVATE_DEPENDENCIES = LIBPYTHON
-OBJ_FILES = smbpython.o
-
[SUBSYSTEM::LIBPYTHON]
PUBLIC_DEPENDENCIES = EXT_LIB_PYTHON
+PRIVATE_DEPENDENCIES = PYTALLOC
INIT_FUNCTION_SENTINEL = { NULL, NULL }
-OBJ_FILES = modules.o pytalloc.o
+
+LIBPYTHON_OBJ_FILES = $(addprefix $(pyscriptsrcdir)/, modules.o)
+
+[SUBSYSTEM::PYTALLOC]
+PUBLIC_DEPENDENCIES = EXT_LIB_PYTHON LIBTALLOC
+
+PYTALLOC_OBJ_FILES = $(addprefix $(pyscriptsrcdir)/, pytalloc.o)
[PYTHON::python_uuid]
PRIVATE_DEPENDENCIES = LIBNDR
-OBJ_FILES = uuidmodule.o
+
+python_uuid_OBJ_FILES = $(pyscriptsrcdir)/uuidmodule.o
[PYTHON::python_misc]
+LIBRARY_REALNAME = samba/_misc.$(SHLIBEXT)
PRIVATE_DEPENDENCIES = LIBNDR LIBLDB SAMDB CREDENTIALS
-SWIG_FILE = misc.i
-
-# Swig extensions
-swig:: pythonmods
-
-.SUFFIXES: _wrap.c .i
-.i_wrap.c:
- [ "$(SWIG)" = "no" ] || $(SWIG) -O -Wall -I$(srcdir)/scripting/swig -python -keyword $<
+python_misc_OBJ_FILES = $(pyscriptsrcdir)/misc_wrap.o
-realdistclean::
- @echo "Removing SWIG output files"
- # FIXME: Remove _wrap.c files
+$(python_misc_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL)
-pythonmods:: $(PYTHON_DSOS) $(PYTHON_PYS)
+_PY_FILES = $(shell find $(pyscriptsrcdir)/samba $(pyscriptsrcdir)/subunit -name "*.py")
-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
+$(foreach pyfile, $(_PY_FILES),$(eval $(call python_py_module_template,$(patsubst $(pyscriptsrcdir)/%,%,$(pyfile)),$(pyfile))))
-pydoctor:: pythonmods
- 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))
+$(eval $(call python_py_module_template,samba/misc.py,$(pyscriptsrcdir)/misc.py))
-bin/python/%.py:
- mkdir -p $(@D)
- cp $< $@
+EPYDOC_OPTIONS = --no-private --url http://www.samba.org/ --no-sourcecode
-installpython:: pythonmods
- @$(SHELL) $(srcdir)/script/installpython.sh \
- $(INSTALLPERMS) \
- $(DESTDIR)$(PYTHONDIR) \
- scripting/python bin/python
+epydoc:: pythonmods
+ PYTHONPATH=$(pythonbuilddir) epydoc $(EPYDOC_OPTIONS) samba tdb ldb subunit
-clean::
- @echo "Removing python modules"
- @rm -rf bin/python/*
+install:: installpython
diff --git a/source4/scripting/python/misc.i b/source4/scripting/python/misc.i
index e04e6a6906..9a4c124121 100644
--- a/source4/scripting/python/misc.i
+++ b/source4/scripting/python/misc.i
@@ -40,6 +40,15 @@
%rename(random_password) generate_random_str;
char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len);
+%feature("docstring") ldb_set_credentials "S.set_credentials(credentials)\n"
+ "Set credentials to use when connecting.";
+
+%feature("docstring") ldb_set_session_info "S.set_session_info(session_info)\n"
+ "Set session info to use when connecting.";
+
+%feature("docstring") ldb_set_loadparm "S.set_loadparm(session_info)\n"
+ "Set loadparm context to use when connecting.";
+
%inline %{
void ldb_set_credentials(struct ldb_context *ldb, struct cli_credentials *creds)
{
@@ -58,14 +67,20 @@ void ldb_set_loadparm(struct ldb_context *ldb, struct loadparm_context *lp_ctx)
%}
+%feature("docstring") samdb_set_domain_sid "S.set_domain_sid(sid)\n"
+ "Set SID of domain to use.";
bool samdb_set_domain_sid(struct ldb_context *ldb,
const struct dom_sid *dom_sid_in);
WERROR dsdb_attach_schema_from_ldif_file(struct ldb_context *ldb, const char *pf, const char *df);
+%feature("docstring") samba_version_string "version()\n"
+ "Obtain the Samba version.";
%rename(version) samba_version_string;
const char *samba_version_string(void);
int dsdb_set_global_schema(struct ldb_context *ldb);
+%feature("docstring") ldb_register_samba_handlers "register_samba_handlers()\n"
+ "Register Samba-specific LDB modules and schemas.";
int ldb_register_samba_handlers(struct ldb_context *ldb);
%inline %{
@@ -78,3 +93,8 @@ bool dsdb_set_ntds_invocation_id(struct ldb_context *ldb, const char *guid)
return samdb_set_ntds_invocation_id(ldb, &invocation_id_in);
}
%}
+
+char *private_path(TALLOC_CTX* mem_ctx,
+ struct loadparm_context *lp_ctx,
+ const char *name);
+
diff --git a/source4/scripting/python/misc.py b/source4/scripting/python/misc.py
index 2fc7fe37e7..25e8d2de8c 100644
--- a/source4/scripting/python/misc.py
+++ b/source4/scripting/python/misc.py
@@ -1,5 +1,5 @@
# This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.33
+# Version 1.3.35
#
# Don't modify this file, modify the SWIG interface instead.
@@ -62,14 +62,51 @@ import credentials
import param
import security
random_password = _misc.random_password
-ldb_set_credentials = _misc.ldb_set_credentials
-ldb_set_session_info = _misc.ldb_set_session_info
-ldb_set_loadparm = _misc.ldb_set_loadparm
-samdb_set_domain_sid = _misc.samdb_set_domain_sid
+
+def ldb_set_credentials(*args, **kwargs):
+ """
+ S.set_credentials(credentials)
+ Set credentials to use when connecting.
+ """
+ return _misc.ldb_set_credentials(*args, **kwargs)
+
+def ldb_set_session_info(*args, **kwargs):
+ """
+ S.set_session_info(session_info)
+ Set session info to use when connecting.
+ """
+ return _misc.ldb_set_session_info(*args, **kwargs)
+
+def ldb_set_loadparm(*args, **kwargs):
+ """
+ S.set_loadparm(session_info)
+ Set loadparm context to use when connecting.
+ """
+ return _misc.ldb_set_loadparm(*args, **kwargs)
+
+def samdb_set_domain_sid(*args, **kwargs):
+ """
+ S.set_domain_sid(sid)
+ Set SID of domain to use.
+ """
+ return _misc.samdb_set_domain_sid(*args, **kwargs)
dsdb_attach_schema_from_ldif_file = _misc.dsdb_attach_schema_from_ldif_file
-version = _misc.version
+
+def version(*args):
+ """
+ version()
+ Obtain the Samba version.
+ """
+ return _misc.version(*args)
dsdb_set_global_schema = _misc.dsdb_set_global_schema
-ldb_register_samba_handlers = _misc.ldb_register_samba_handlers
+
+def ldb_register_samba_handlers(*args, **kwargs):
+ """
+ register_samba_handlers()
+ Register Samba-specific LDB modules and schemas.
+ """
+ return _misc.ldb_register_samba_handlers(*args, **kwargs)
dsdb_set_ntds_invocation_id = _misc.dsdb_set_ntds_invocation_id
+private_path = _misc.private_path
diff --git a/source4/scripting/python/misc_wrap.c b/source4/scripting/python/misc_wrap.c
index 579d1f379f..22a072fc6f 100644
--- a/source4/scripting/python/misc_wrap.c
+++ b/source4/scripting/python/misc_wrap.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.33
+ * Version 1.3.35
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
@@ -126,7 +126,7 @@
/* This should only be incremented when either the layout of swig_type_info changes,
or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "3"
+#define SWIG_RUNTIME_VERSION "4"
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
#ifdef SWIG_TYPE_TABLE
@@ -161,6 +161,7 @@
/* Flags for pointer conversions */
#define SWIG_POINTER_DISOWN 0x1
+#define SWIG_CAST_NEW_MEMORY 0x2
/* Flags for new pointer objects */
#define SWIG_POINTER_OWN 0x1
@@ -301,10 +302,10 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) {
extern "C" {
#endif
-typedef void *(*swig_converter_func)(void *);
+typedef void *(*swig_converter_func)(void *, int *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);
-/* Structure to store inforomation on one type */
+/* Structure to store information on one type */
typedef struct swig_type_info {
const char *name; /* mangled name of this type */
const char *str; /* human readable name of this type */
@@ -431,8 +432,8 @@ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
Cast a pointer up an inheritance hierarchy
*/
SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
- return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
+SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
}
/*
@@ -856,7 +857,7 @@ SWIG_Python_AddErrorMsg(const char* mesg)
Py_DECREF(old_str);
Py_DECREF(value);
} else {
- PyErr_Format(PyExc_RuntimeError, mesg);
+ PyErr_SetString(PyExc_RuntimeError, mesg);
}
}
@@ -1416,7 +1417,7 @@ PySwigObject_dealloc(PyObject *v)
{
PySwigObject *sobj = (PySwigObject *) v;
PyObject *next = sobj->next;
- if (sobj->own) {
+ if (sobj->own == SWIG_POINTER_OWN) {
swig_type_info *ty = sobj->ty;
PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
PyObject *destroy = data ? data->destroy : 0;
@@ -1434,12 +1435,13 @@ PySwigObject_dealloc(PyObject *v)
res = ((*meth)(mself, v));
}
Py_XDECREF(res);
- } else {
- const char *name = SWIG_TypePrettyName(ty);
+ }
#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
- printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
-#endif
+ else {
+ const char *name = SWIG_TypePrettyName(ty);
+ printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
}
+#endif
}
Py_XDECREF(next);
PyObject_DEL(v);
@@ -1944,7 +1946,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
SWIGRUNTIME int
SWIG_Python_AcquirePtr(PyObject *obj, int own) {
- if (own) {
+ if (own == SWIG_POINTER_OWN) {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
if (sobj) {
int oldown = sobj->own;
@@ -1965,6 +1967,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
return SWIG_OK;
} else {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+ if (own)
+ *own = 0;
while (sobj) {
void *vptr = sobj->ptr;
if (ty) {
@@ -1978,7 +1982,15 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
if (!tc) {
sobj = (PySwigObject *)sobj->next;
} else {
- if (ptr) *ptr = SWIG_TypeCast(tc,vptr);
+ if (ptr) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
+ assert(own);
+ if (own)
+ *own = *own | SWIG_CAST_NEW_MEMORY;
+ }
+ }
break;
}
}
@@ -1988,7 +2000,8 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
}
}
if (sobj) {
- if (own) *own = sobj->own;
+ if (own)
+ *own = *own | sobj->own;
if (flags & SWIG_POINTER_DISOWN) {
sobj->own = 0;
}
@@ -2053,8 +2066,13 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
}
if (ty) {
swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
- if (!tc) return SWIG_ERROR;
- *ptr = SWIG_TypeCast(tc,vptr);
+ if (tc) {
+ int newmemory = 0;
+ *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
+ assert(!newmemory); /* newmemory handling not yet implemented */
+ } else {
+ return SWIG_ERROR;
+ }
} else {
*ptr = vptr;
}
@@ -2519,7 +2537,7 @@ static swig_module_info swig_module = {swig_types, 27, 0, 0, 0, 0};
#define SWIG_name "_misc"
-#define SWIGVERSION 0x010333
+#define SWIGVERSION 0x010335
#define SWIG_VERSION SWIGVERSION
@@ -3153,17 +3171,80 @@ fail:
}
+SWIGINTERN PyObject *_wrap_private_path(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ TALLOC_CTX *arg1 = (TALLOC_CTX *) 0 ;
+ struct loadparm_context *arg2 = (struct loadparm_context *) 0 ;
+ char *arg3 = (char *) 0 ;
+ char *result = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ int res3 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "lp_ctx",(char *) "name", NULL
+ };
+
+ arg2 = loadparm_init(NULL);
+ arg1 = NULL;
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OO:private_path",kwnames,&obj0,&obj1)) SWIG_fail;
+ if (obj0) {
+ res2 = SWIG_ConvertPtr(obj0, &argp2,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "private_path" "', argument " "2"" of type '" "struct loadparm_context *""'");
+ }
+ arg2 = (struct loadparm_context *)(argp2);
+ }
+ if (obj1) {
+ res3 = SWIG_AsCharPtrAndSize(obj1, &buf3, NULL, &alloc3);
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "private_path" "', argument " "3"" of type '" "char const *""'");
+ }
+ arg3 = (char *)(buf3);
+ }
+ result = (char *)private_path(arg1,arg2,(char const *)arg3);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ return resultobj;
+fail:
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ return NULL;
+}
+
+
static PyMethodDef SwigMethods[] = {
{ (char *)"random_password", (PyCFunction) _wrap_random_password, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"ldb_set_credentials", (PyCFunction) _wrap_ldb_set_credentials, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"ldb_set_session_info", (PyCFunction) _wrap_ldb_set_session_info, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"ldb_set_loadparm", (PyCFunction) _wrap_ldb_set_loadparm, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"samdb_set_domain_sid", (PyCFunction) _wrap_samdb_set_domain_sid, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"ldb_set_credentials", (PyCFunction) _wrap_ldb_set_credentials, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_credentials(credentials)\n"
+ "Set credentials to use when connecting.\n"
+ ""},
+ { (char *)"ldb_set_session_info", (PyCFunction) _wrap_ldb_set_session_info, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_session_info(session_info)\n"
+ "Set session info to use when connecting.\n"
+ ""},
+ { (char *)"ldb_set_loadparm", (PyCFunction) _wrap_ldb_set_loadparm, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_loadparm(session_info)\n"
+ "Set loadparm context to use when connecting.\n"
+ ""},
+ { (char *)"samdb_set_domain_sid", (PyCFunction) _wrap_samdb_set_domain_sid, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "S.set_domain_sid(sid)\n"
+ "Set SID of domain to use.\n"
+ ""},
{ (char *)"dsdb_attach_schema_from_ldif_file", (PyCFunction) _wrap_dsdb_attach_schema_from_ldif_file, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"version", (PyCFunction)_wrap_version, METH_NOARGS, NULL},
+ { (char *)"version", (PyCFunction)_wrap_version, METH_NOARGS, (char *)"\n"
+ "version()\n"
+ "Obtain the Samba version.\n"
+ ""},
{ (char *)"dsdb_set_global_schema", (PyCFunction) _wrap_dsdb_set_global_schema, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"ldb_register_samba_handlers", (PyCFunction) _wrap_ldb_register_samba_handlers, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"ldb_register_samba_handlers", (PyCFunction) _wrap_ldb_register_samba_handlers, METH_VARARGS | METH_KEYWORDS, (char *)"\n"
+ "register_samba_handlers()\n"
+ "Register Samba-specific LDB modules and schemas.\n"
+ ""},
{ (char *)"dsdb_set_ntds_invocation_id", (PyCFunction) _wrap_dsdb_set_ntds_invocation_id, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"private_path", (PyCFunction) _wrap_private_path, METH_VARARGS | METH_KEYWORDS, NULL},
{ NULL, NULL, 0, NULL }
};
@@ -3180,7 +3261,7 @@ static swig_type_info _swigt__p_ldb_context = {"_p_ldb_context", "struct ldb_con
static swig_type_info _swigt__p_ldb_dn = {"_p_ldb_dn", "struct ldb_dn *|ldb_dn *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_ldif = {"_p_ldb_ldif", "struct ldb_ldif *|ldb_ldif *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_message = {"_p_ldb_message", "ldb_msg *|struct ldb_message *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_ldb_message_element = {"_p_ldb_message_element", "struct ldb_message_element *|ldb_msg_element *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_ldb_message_element = {"_p_ldb_message_element", "struct ldb_message_element *|ldb_message_element *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_ldb_result = {"_p_ldb_result", "struct ldb_result *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_loadparm_context = {"_p_loadparm_context", "struct loadparm_context *|loadparm_context *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_loadparm_service = {"_p_loadparm_service", "struct loadparm_service *|loadparm_service *", 0, 0, (void*)0, 0};
@@ -3352,7 +3433,7 @@ SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
- int found;
+ int found, init;
clientdata = clientdata;
@@ -3362,6 +3443,9 @@ SWIG_InitializeModule(void *clientdata) {
swig_module.type_initial = swig_type_initial;
swig_module.cast_initial = swig_cast_initial;
swig_module.next = &swig_module;
+ init = 1;
+ } else {
+ init = 0;
}
/* Try and load any already created modules */
@@ -3390,6 +3474,12 @@ SWIG_InitializeModule(void *clientdata) {
module_head->next = &swig_module;
}
+ /* When multiple interpeters are used, a module could have already been initialized in
+ a different interpreter, but not yet have a pointer in this interpreter.
+ In this case, we do not want to continue adding types... everything should be
+ set up already */
+ if (init == 0) return;
+
/* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: size %d\n", swig_module.size);
diff --git a/source4/scripting/python/modules.c b/source4/scripting/python/modules.c
index 2ecad20b8e..0fe15b2fda 100644
--- a/source4/scripting/python/modules.c
+++ b/source4/scripting/python/modules.c
@@ -19,7 +19,6 @@
#include "includes.h"
#include <Python.h>
-#include "build.h"
extern void init_ldb(void);
extern void init_security(void);
@@ -35,17 +34,19 @@ extern void init_events(void);
extern void inituuid(void);
extern void init_net(void);
extern void initecho(void);
+extern void initdfs(void);
+extern void initdrsuapi(void);
extern void initwinreg(void);
extern void initepmapper(void);
extern void initinitshutdown(void);
-static void initdcerpc_misc(void) {}
extern void initmgmt(void);
+extern void initnet(void);
extern void initatsvc(void);
extern void initsamr(void);
-static void initdcerpc_security(void) {}
extern void initlsa(void);
extern void initsvcctl(void);
extern void initwkssvc(void);
+extern void initunixinfo(void);
extern void init_libcli_nbt(void);
extern void init_libcli_smb(void);
diff --git a/source4/scripting/python/pyrpc.h b/source4/scripting/python/pyrpc.h
index 3a5d235cfc..93d583c10a 100644
--- a/source4/scripting/python/pyrpc.h
+++ b/source4/scripting/python/pyrpc.h
@@ -17,6 +17,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifndef _PYRPC_H_
+#define _PYRPC_H_
+
#define PY_CHECK_TYPE(type, var, fail) \
if (!type ## _Check(var)) {\
PyErr_Format(PyExc_TypeError, "Expected type %s", type ## _Type.tp_name); \
@@ -26,9 +29,11 @@
#define dom_sid2_Type dom_sid_Type
#define dom_sid28_Type dom_sid_Type
#define dom_sid2_Check dom_sid_Check
-#define dom_sid28_Check dom_sid28_Check
+#define dom_sid28_Check dom_sid_Check
/* This macro is only provided by Python >= 2.3 */
#ifndef PyAPI_DATA
# define PyAPI_DATA(RTYPE) extern RTYPE
#endif
+
+#endif /* _PYRPC_H_ */
diff --git a/source4/scripting/python/pytalloc.c b/source4/scripting/python/pytalloc.c
index d8d3efe69c..ca476e9604 100644
--- a/source4/scripting/python/pytalloc.c
+++ b/source4/scripting/python/pytalloc.c
@@ -24,6 +24,7 @@ void py_talloc_dealloc(PyObject* self)
{
py_talloc_Object *obj = (py_talloc_Object *)self;
talloc_free(obj->talloc_ctx);
+ obj->talloc_ctx = NULL;
PyObject_Del(self);
}
@@ -31,7 +32,13 @@ PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx,
void *ptr)
{
py_talloc_Object *ret = PyObject_New(py_talloc_Object, py_type);
- ret->talloc_ctx = talloc_reference(NULL, mem_ctx);
+ ret->talloc_ctx = talloc_new(NULL);
+ if (ret->talloc_ctx == NULL) {
+ return NULL;
+ }
+ if (talloc_reference(ret->talloc_ctx, mem_ctx) == NULL) {
+ return NULL;
+ }
ret->ptr = ptr;
return (PyObject *)ret;
}
@@ -39,7 +46,7 @@ PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx,
PyObject *py_talloc_default_repr(PyObject *py_obj)
{
py_talloc_Object *obj = (py_talloc_Object *)py_obj;
+ PyTypeObject *type = (PyTypeObject*)PyObject_Type((PyObject *)obj);
- return PyString_FromFormat("<talloc: %s>",
- talloc_get_name(obj->talloc_ctx));
+ return PyString_FromFormat("<%s talloc object at 0x%x>", type->tp_name, (intptr_t)py_obj);
}
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py
index b9d81c6c3c..94f9e4d005 100644
--- a/source4/scripting/python/samba/__init__.py
+++ b/source4/scripting/python/samba/__init__.py
@@ -20,6 +20,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+__docformat__ = "restructuredText"
+
import os
def _in_source_tree():
@@ -33,6 +35,8 @@ if _in_source_tree():
srcdir = "%s/../../.." % os.path.dirname(__file__)
sys.path.append("%s/bin/python" % srcdir)
default_ldb_modules_dir = "%s/bin/modules/ldb" % srcdir
+else:
+ default_ldb_modules_dir = None
import ldb
@@ -69,15 +73,15 @@ class Ldb(ldb.Ldb):
self.set_modules_dir(default_ldb_modules_dir)
if credentials is not None:
- self.set_credentials(self, credentials)
+ self.set_credentials(credentials)
if session_info is not None:
- self.set_session_info(self, session_info)
+ self.set_session_info(session_info)
assert misc.ldb_register_samba_handlers(self) == 0
if lp is not None:
- self.set_loadparm(self, lp)
+ self.set_loadparm(lp)
def msg(l,text):
print text
diff --git a/source4/scripting/python/samba/getopt.py b/source4/scripting/python/samba/getopt.py
index 82cb004b62..9ecb66e21c 100644
--- a/source4/scripting/python/samba/getopt.py
+++ b/source4/scripting/python/samba/getopt.py
@@ -17,10 +17,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+"""Support for parsing Samba-related command-line options."""
+
import optparse
from credentials import Credentials, AUTO_USE_KERBEROS, DONT_USE_KERBEROS, MUST_USE_KERBEROS
+__docformat__ = "restructuredText"
+
class SambaOptions(optparse.OptionGroup):
+ """General Samba-related command line options."""
def __init__(self, parser):
optparse.OptionGroup.__init__(self, parser, "Samba Common Options")
self.add_option("-s", "--configfile", action="callback",
@@ -29,26 +34,33 @@ class SambaOptions(optparse.OptionGroup):
self._configfile = None
def get_loadparm_path(self):
+ """Return the path to the smb.conf file specified on the command line. """
return self._configfile
def _load_configfile(self, option, opt_str, arg, parser):
self._configfile = arg
def get_loadparm(self):
- import param
+ """Return a loadparm object with data specified on the command line. """
+ import os, param
lp = param.LoadParm()
- if self._configfile is None:
- lp.load_default()
- else:
+ if self._configfile is not None:
lp.load(self._configfile)
+ elif os.getenv("SMB_CONF_PATH") is not None:
+ lp.load(os.getenv("SMB_CONF_PATH"))
+ else:
+ lp.load_default()
return lp
+
class VersionOptions(optparse.OptionGroup):
+ """Command line option for printing Samba version."""
def __init__(self, parser):
optparse.OptionGroup.__init__(self, parser, "Version Options")
class CredentialsOptions(optparse.OptionGroup):
+ """Command line options for specifying credentials."""
def __init__(self, parser):
self.no_pass = False
optparse.OptionGroup.__init__(self, parser, "Credentials Options")
@@ -89,6 +101,11 @@ class CredentialsOptions(optparse.OptionGroup):
self.creds.set_bind_dn(arg)
def get_credentials(self, lp):
+ """Obtain the credentials set on the command-line.
+
+ :param lp: Loadparm object to use.
+ :return: Credentials object
+ """
self.creds.guess(lp)
if not self.no_pass:
self.creds.set_cmdline_callbacks()
diff --git a/source4/scripting/python/samba/idmap.py b/source4/scripting/python/samba/idmap.py
index 355565968a..755ec52c7b 100644
--- a/source4/scripting/python/samba/idmap.py
+++ b/source4/scripting/python/samba/idmap.py
@@ -20,7 +20,10 @@
"""Convenience functions for using the idmap database."""
+__docformat__ = "restructuredText"
+
import samba
+import misc
import ldb
class IDmapDB(samba.Ldb):
@@ -37,11 +40,17 @@ class IDmapDB(samba.Ldb):
:param url: URL of the database.
"""
+ self.lp = lp
+
super(IDmapDB, self).__init__(session_info=session_info, credentials=credentials,
modules_dir=modules_dir, lp=lp)
if url:
self.connect(url)
+ else:
+ self.connect(lp.get("idmap database"))
+ def connect(self, url):
+ super(IDmapDB, self).connect(misc.private_path(self.lp, url))
def setup_name_mapping(self, sid, type, unixid):
"""Setup a mapping between a sam name and a unix name.
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 4d5a9cb1f1..fe9b582d56 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -43,6 +43,8 @@ from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, LdbError, \
"""Functions for setting up a Samba configuration."""
+__docformat__ = "restructuredText"
+
DEFAULTSITE = "Default-First-Site-Name"
class InvalidNetbiosName(Exception):
@@ -87,6 +89,7 @@ class ProvisionNames:
self.domain = None
self.hostname = None
self.sitename = None
+ self.smbconf = None
class ProvisionResult:
def __init__(self):
@@ -239,6 +242,8 @@ def provision_paths_from_lp(lp, dnsdomain):
paths.secrets = os.path.join(paths.private_dir, lp.get("secrets database") or "secrets.ldb")
paths.templates = os.path.join(paths.private_dir, "templates.ldb")
paths.dns = os.path.join(paths.private_dir, dnsdomain + ".zone")
+ paths.namedconf = os.path.join(paths.private_dir, "named.conf")
+ paths.krb5conf = os.path.join(paths.private_dir, "krb5.conf")
paths.winsdb = os.path.join(paths.private_dir, "wins.ldb")
paths.s4_ldapi_path = os.path.join(paths.private_dir, "ldapi")
paths.phpldapadminconfig = os.path.join(paths.private_dir,
@@ -266,12 +271,15 @@ def provision_paths_from_lp(lp, dnsdomain):
paths.netlogon = lp.get("path", "netlogon")
+ paths.smbconf = lp.configfile()
+
return paths
-def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None,
- serverrole=None, rootdn=None, domaindn=None, configdn=None,
- schemadn=None, sitename=None):
+def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None, serverrole=None,
+ rootdn=None, domaindn=None, configdn=None, schemadn=None, serverdn=None,
+ sitename=None):
+ """Guess configuration settings to use."""
if hostname is None:
hostname = socket.gethostname().split(".")[0].lower()
@@ -292,8 +300,8 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None,
realm = dnsdomain.upper()
if lp.get("realm").upper() != realm:
- raise Exception("realm '%s' must match chosen realm '%s'" %
- (lp.get("realm"), realm))
+ raise Exception("realm '%s' in %s must match chosen realm '%s'" %
+ (lp.get("realm"), lp.configfile(), realm))
dnsdomain = dnsdomain.lower()
@@ -338,6 +346,7 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None,
names.netbiosname = netbiosname
names.hostname = hostname
names.sitename = sitename
+ names.serverdn = "CN=%s,CN=Servers,CN=%s,CN=Sites,%s" % (netbiosname, sitename, configdn)
return names
@@ -390,6 +399,7 @@ def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
})
+
def setup_name_mappings(samdb, idmap, sid, domaindn, root_uid, nobody_uid,
users_gid, wheel_gid):
"""setup reasonable name mappings for sam names to unix names.
@@ -536,10 +546,7 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
samdb.load_ldif_file_add(setup_path("provision_init.ldif"))
message("Setting up sam.ldb rootDSE")
- setup_samdb_rootdse(samdb, setup_path, names.schemadn, names.domaindn,
- names.hostname, names.dnsdomain, names.realm,
- names.rootdn, names.configdn, names.netbiosname,
- names.sitename)
+ setup_samdb_rootdse(samdb, setup_path, names)
if erase:
message("Erasing data from partitions")
@@ -652,25 +659,22 @@ def setup_idmapdb(path, setup_path, session_info, credentials, lp):
return idmap_ldb
-def setup_samdb_rootdse(samdb, setup_path, schemadn, domaindn, hostname,
- dnsdomain, realm, rootdn, configdn, netbiosname,
- sitename):
+def setup_samdb_rootdse(samdb, setup_path, names):
"""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": sitename,
- "REALM": realm,
- "DNSNAME": "%s.%s" % (hostname, dnsdomain),
- "DOMAINDN": domaindn,
- "ROOTDN": rootdn,
- "CONFIGDN": configdn,
- "VERSION": samba.version(),
+ "SCHEMADN": names.schemadn,
+ "NETBIOSNAME": names.netbiosname,
+ "DNSDOMAIN": names.dnsdomain,
+ "REALM": names.realm,
+ "DNSNAME": "%s.%s" % (names.hostname, names.dnsdomain),
+ "DOMAINDN": names.domaindn,
+ "ROOTDN": names.rootdn,
+ "CONFIGDN": names.configdn,
+ "SERVERDN": names.serverdn,
})
@@ -679,10 +683,12 @@ def setup_self_join(samdb, names,
domainsid, invocationid, setup_path,
policyguid):
"""Join a host to its own domain."""
+ assert isinstance(invocationid, str)
setup_add_ldif(samdb, setup_path("provision_self_join.ldif"), {
"CONFIGDN": names.configdn,
"SCHEMADN": names.schemadn,
"DOMAINDN": names.domaindn,
+ "SERVERDN": names.serverdn,
"INVOCATIONID": invocationid,
"NETBIOSNAME": names.netbiosname,
"DEFAULTSITE": names.sitename,
@@ -730,8 +736,6 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
return samdb
message("Pre-loading the Samba 4 and AD schema")
- samdb = SamDB(path, session_info=session_info,
- credentials=credentials, lp=lp)
samdb.set_domain_sid(domainsid)
if serverrole == "domain controller":
samdb.set_invocation_id(invocationid)
@@ -767,6 +771,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
"NETBIOSNAME": names.netbiosname,
"DEFAULTSITE": names.sitename,
"CONFIGDN": names.configdn,
+ "SERVERDN": names.serverdn,
"POLICYGUID": policyguid,
"DOMAINDN": names.domaindn,
"DOMAINGUID_MOD": domainguid_mod,
@@ -797,6 +802,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
"NETBIOSNAME": names.netbiosname,
"DEFAULTSITE": names.sitename,
"CONFIGDN": names.configdn,
+ "SERVERDN": names.serverdn
})
message("Setting up sam.ldb Samba4 schema")
@@ -815,6 +821,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
"DOMAIN": names.domain,
"SCHEMADN": names.schemadn,
"DOMAINDN": names.domaindn,
+ "SERVERDN": names.serverdn
})
message("Setting up display specifiers")
@@ -839,6 +846,7 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
"NETBIOSNAME": names.netbiosname,
"DEFAULTSITE": names.sitename,
"CONFIGDN": names.configdn,
+ "SERVERDN": names.serverdn
})
if fill == FILL_FULL:
@@ -875,15 +883,15 @@ FILL_NT4SYNC = "NT4SYNC"
FILL_DRS = "DRS"
def provision(setup_dir, message, session_info,
- credentials, smbconf=None, targetdir=None, samdb_fill=FILL_FULL,
- realm=None, rootdn=None, domaindn=None, schemadn=None,
- configdn=None, domain=None, hostname=None, hostip=None,
- hostip6=None, domainsid=None, adminpass=None, krbtgtpass=None,
- domainguid=None, policyguid=None, invocationid=None,
- machinepass=None, dnspass=None, root=None, nobody=None,
- nogroup=None, users=None, wheel=None, backup=None, aci=None,
- serverrole=None, ldap_backend=None, ldap_backend_type=None,
- sitename=None):
+ credentials, smbconf=None, targetdir=None, samdb_fill=FILL_FULL, realm=None,
+ rootdn=None, domaindn=None, schemadn=None, configdn=None,
+ serverdn=None,
+ domain=None, hostname=None, hostip=None, hostip6=None,
+ domainsid=None, adminpass=None, krbtgtpass=None, domainguid=None,
+ policyguid=None, invocationid=None, machinepass=None,
+ dnspass=None, root=None, nobody=None, nogroup=None, users=None,
+ wheel=None, backup=None, aci=None, serverrole=None,
+ ldap_backend=None, ldap_backend_type=None, sitename=None):
"""Provision samba4
:note: caution, this wipes all existing data!
@@ -898,7 +906,7 @@ def provision(setup_dir, message, session_info,
domainsid = security.Sid(domainsid)
if policyguid is None:
- policyguid = uuid.random()
+ policyguid = str(uuid.uuid4())
if adminpass is None:
adminpass = misc.random_password(12)
if krbtgtpass is None:
@@ -930,9 +938,9 @@ def provision(setup_dir, message, session_info,
lp.load(smbconf)
names = guess_names(lp=lp, hostname=hostname, domain=domain,
- dnsdomain=realm, serverrole=serverrole,
- sitename=sitename, rootdn=rootdn, domaindn=domaindn,
- configdn=configdn, schemadn=schemadn)
+ dnsdomain=realm, serverrole=serverrole, sitename=sitename,
+ rootdn=rootdn, domaindn=domaindn, configdn=configdn, schemadn=schemadn,
+ serverdn=serverdn)
paths = provision_paths_from_lp(lp, names.dnsdomain)
@@ -950,7 +958,7 @@ def provision(setup_dir, message, session_info,
assert serverrole in ("domain controller", "member server", "standalone")
if invocationid is None and serverrole == "domain controller":
- invocationid = uuid.random()
+ invocationid = str(uuid.uuid4())
if not os.path.exists(paths.private_dir):
os.mkdir(paths.private_dir)
@@ -1000,20 +1008,25 @@ def provision(setup_dir, message, session_info,
ldap_backend_type=ldap_backend_type)
if lp.get("server role") == "domain controller":
- policy_path = os.path.join(paths.sysvol, names.dnsdomain, "Policies",
- "{" + policyguid + "}")
- os.makedirs(policy_path, 0755)
- os.makedirs(os.path.join(policy_path, "Machine"), 0755)
- os.makedirs(os.path.join(policy_path, "User"), 0755)
- if not os.path.isdir(paths.netlogon):
+ if paths.netlogon is None:
+ message("Existing smb.conf does not have a [netlogon] share, but you are configuring a DC.")
+ message("Please either remove %s or see the template at %s" %
+ ( paths.smbconf, setup_path("provision.smb.conf.dc")))
+ assert(paths.netlogon is not None)
+
+ if paths.sysvol is None:
+ message("Existing smb.conf does not have a [sysvol] share, but you are configuring a DC.")
+ message("Please either remove %s or see the template at %s" %
+ (paths.smbconf, setup_path("provision.smb.conf.dc")))
+ assert(paths.sysvol is not None)
+
+ policy_path = os.path.join(paths.sysvol, names.dnsdomain, "Policies",
+ "{" + policyguid + "}")
+ os.makedirs(policy_path, 0755)
+ os.makedirs(os.path.join(policy_path, "Machine"), 0755)
+ os.makedirs(os.path.join(policy_path, "User"), 0755)
+ if not os.path.isdir(paths.netlogon):
os.makedirs(paths.netlogon, 0755)
- secrets_ldb = Ldb(paths.secrets, session_info=session_info,
- credentials=credentials, lp=lp)
- secretsdb_become_dc(secrets_ldb, setup_path, domain=domain, realm=names.realm,
- netbiosname=names.netbiosname, domainsid=domainsid,
- keytab_path=paths.keytab, samdb_url=paths.samdb,
- dns_keytab_path=paths.dns_keytab, dnspass=dnspass,
- machinepass=machinepass, dnsdomain=names.dnsdomain)
if samdb_fill == FILL_FULL:
setup_name_mappings(samdb, idmap, str(domainsid), names.domaindn,
@@ -1025,6 +1038,14 @@ def provision(setup_dir, message, session_info,
# Only make a zone file on the first DC, it should be replicated with DNS replication
if serverrole == "domain controller":
+ secrets_ldb = Ldb(paths.secrets, session_info=session_info,
+ credentials=credentials, lp=lp)
+ secretsdb_become_dc(secrets_ldb, setup_path, domain=domain, realm=names.realm,
+ netbiosname=names.netbiosname, domainsid=domainsid,
+ keytab_path=paths.keytab, samdb_url=paths.samdb,
+ dns_keytab_path=paths.dns_keytab, dnspass=dnspass,
+ machinepass=machinepass, dnsdomain=names.dnsdomain)
+
samdb = SamDB(paths.samdb, session_info=session_info,
credentials=credentials, lp=lp)
@@ -1034,21 +1055,30 @@ def provision(setup_dir, message, session_info,
expression="(&(objectClass=computer)(cn=%s))" % names.hostname,
scope=SCOPE_SUBTREE)
assert isinstance(hostguid, str)
-
- create_zone_file(paths.dns, setup_path, samdb,
- hostname=names.hostname, hostip=hostip,
- hostip6=hostip6, dnsdomain=names.dnsdomain,
- domaindn=names.domaindn, dnspass=dnspass, realm=names.realm,
+
+ create_zone_file(paths.dns, setup_path, dnsdomain=names.dnsdomain,
+ domaindn=names.domaindn, hostip=hostip,
+ hostip6=hostip6, hostname=names.hostname,
+ dnspass=dnspass, realm=names.realm,
domainguid=domainguid, hostguid=hostguid)
message("Please install the zone located in %s into your DNS server" % paths.dns)
-
+
+ create_named_conf(paths.namedconf, setup_path, realm=names.realm,
+ dnsdomain=names.dnsdomain, private_dir=paths.private_dir,
+ keytab_name=paths.dns_keytab)
+ message("See %s for example configuration statements for secure GSS-TSIG updates" % paths.namedconf)
+
+ create_krb5_conf(paths.krb5conf, setup_path, dnsdomain=names.dnsdomain,
+ hostname=names.hostname, realm=names.realm)
+ message("A Kerberos configuration suitable for Samba 4 has been generated at %s" % paths.krb5conf)
+
create_phpldapadmin_config(paths.phpldapadminconfig, setup_path,
ldapi_url)
message("Please install the phpLDAPadmin configuration located at %s into /etc/phpldapadmin/config.php" % paths.phpldapadminconfig)
- message("Once the above files are installed, your server will be ready to use")
- message("Server Type: %s" % serverrole)
+ message("Once the above files are installed, your Samba4 server will be ready to use")
+ message("Server Role: %s" % serverrole)
message("Hostname: %s" % names.hostname)
message("NetBIOS Domain: %s" % names.domain)
message("DNS Domain: %s" % names.dnsdomain)
@@ -1062,27 +1092,33 @@ def provision(setup_dir, message, session_info,
result.samdb = samdb
return result
+
def provision_become_dc(setup_dir=None,
smbconf=None, targetdir=None, realm=None,
rootdn=None, domaindn=None, schemadn=None, configdn=None,
+ serverdn=None,
domain=None, hostname=None, domainsid=None,
adminpass=None, krbtgtpass=None, domainguid=None,
policyguid=None, invocationid=None, machinepass=None,
dnspass=None, root=None, nobody=None, nogroup=None, users=None,
wheel=None, backup=None, aci=None, serverrole=None,
- ldap_backend=None, ldap_backend_type=None, sitename=DEFAULTSITE):
+ ldap_backend=None, ldap_backend_type=None, sitename=None):
def message(text):
"""print a message if quiet is not set."""
print text
- provision(setup_dir, message, system_session(), None,
+ return provision(setup_dir, message, system_session(), None,
smbconf=smbconf, targetdir=targetdir, samdb_fill=FILL_DRS, realm=realm,
- rootdn=rootdn, domaindn=domaindn, schemadn=schemadn, configdn=configdn,
+ rootdn=rootdn, domaindn=domaindn, schemadn=schemadn, configdn=configdn, serverdn=serverdn,
domain=domain, hostname=hostname, hostip="127.0.0.1", domainsid=domainsid, machinepass=machinepass, serverrole="domain controller", sitename=sitename);
-def setup_db_config(setup_path, file, dbdir):
+def setup_db_config(setup_path, dbdir):
+ """Setup a Berkeley database.
+
+ :param setup_path: Setup path function.
+ :param dbdir: Database directory."""
if not os.path.isdir(os.path.join(dbdir, "bdb-logs")):
os.makedirs(os.path.join(dbdir, "bdb-logs"), 0700);
if not os.path.isdir(os.path.join(dbdir, "tmp")):
@@ -1097,7 +1133,7 @@ def provision_backend(setup_dir=None, message=None,
smbconf=None, targetdir=None, realm=None,
rootdn=None, domaindn=None, schemadn=None, configdn=None,
domain=None, hostname=None, adminpass=None, root=None, serverrole=None,
- ldap_backend_type=None):
+ ldap_backend_type=None, ldap_backend_port=None):
def setup_path(file):
return os.path.join(setup_dir, file)
@@ -1148,6 +1184,7 @@ def provision_backend(setup_dir=None, message=None,
"NETBIOSNAME": names.netbiosname,
"DEFAULTSITE": DEFAULTSITE,
"CONFIGDN": names.configdn,
+ "SERVERDN": names.serverdn
})
setup_add_ldif(schemadb, setup_path("schema_samba4.ldif"),
@@ -1156,7 +1193,12 @@ def provision_backend(setup_dir=None, message=None,
{"SCHEMADN": names.schemadn})
if ldap_backend_type == "fedora-ds":
- setup_file(setup_path("fedora-ds.inf"), paths.fedoradsinf,
+ if ldap_backend_port is not None:
+ serverport = "ServerPort=%d" % ldap_backend_port
+ else:
+ serverport = ""
+
+ setup_file(setup_path("fedorads.inf"), paths.fedoradsinf,
{"ROOT": root,
"HOSTNAME": hostname,
"DNSDOMAIN": names.dnsdomain,
@@ -1164,19 +1206,18 @@ def provision_backend(setup_dir=None, message=None,
"DOMAINDN": names.domaindn,
"LDAPMANAGERDN": names.ldapmanagerdn,
"LDAPMANAGERPASS": adminpass,
- "SERVERPORT": ""})
+ "SERVERPORT": serverport})
- setup_file(setup_path("fedora-partitions.ldif"), paths.fedoradspartitions,
+ setup_file(setup_path("fedorads-partitions.ldif"), paths.fedoradspartitions,
{"CONFIGDN": names.configdn,
"SCHEMADN": names.schemadn,
})
- setup_file(setup_path("fedora-partitions.ldif"), paths.fedoradspartitions,
- {"CONFIGDN": names.configdn,
- "SCHEMADN": names.schemadn,
- })
mapping = "schema-map-fedora-ds-1.0"
backend_schema = "99_ad.ldif"
+
+ slapdcommand="Initailise Fedora DS with: setup-ds.pl --file=%s" % paths.fedoradsinf
+
elif ldap_backend_type == "openldap":
attrs = ["linkID", "lDAPDisplayName"]
res = schemadb.search(expression="(&(&(linkID=*)(!(linkID:1.2.840.113556.1.4.803:=1)))(objectclass=attributeSchema))", base=names.schemadn, scope=SCOPE_SUBTREE, attrs=attrs);
@@ -1219,22 +1260,33 @@ refint_attributes""" + refint_attributes + "\n";
setup_file(setup_path("modules.conf"), paths.modulesconf,
{"REALM": names.realm})
- setup_db_config(setup_path, file, os.path.join(paths.ldapdir, "db", "user"))
- setup_db_config(setup_path, file, os.path.join(paths.ldapdir, "db", "config"))
- setup_db_config(setup_path, file, os.path.join(paths.ldapdir, "db", "schema"))
- mapping = "schema-map-openldap-2.3"
- backend_schema = "backend-schema.schema"
-
-
- ldapi_uri = "ldapi://" + urllib.quote(os.path.join(paths.private_dir, "ldap", "ldapi"), safe="")
- message("Start slapd with: slapd -f " + paths.ldapdir + "/slapd.conf -h " + ldapi_uri)
-
+ setup_db_config(setup_path, os.path.join(paths.ldapdir, os.path.join("db", "user")))
+ setup_db_config(setup_path, os.path.join(paths.ldapdir, os.path.join("db", "config")))
+ setup_db_config(setup_path, os.path.join(paths.ldapdir, os.path.join("db", "schema")))
+ mapping = "schema-map-openldap-2.3"
+ backend_schema = "backend-schema.schema"
+
+ ldapi_uri = "ldapi://" + urllib.quote(os.path.join(paths.private_dir, "ldap", "ldapi"), safe="")
+ if ldap_backend_port is not None:
+ server_port_string = " -h ldap://0.0.0.0:%d" % ldap_backend_port
+ else:
+ server_port_string = ""
+ slapdcommand="Start slapd with: slapd -f " + paths.ldapdir + "/slapd.conf -h " + ldapi_uri + server_port_string
schema_command = "bin/ad2oLschema --option=convert:target=" + ldap_backend_type + " -I " + setup_path(mapping) + " -H tdb://" + schemadb_path + " -O " + os.path.join(paths.ldapdir, backend_schema);
os.system(schema_command)
+ message("Your %s Backend for Samba4 is now configured, and is ready to be started" % ( ldap_backend_type) )
+ message("Server Role: %s" % serverrole)
+ message("Hostname: %s" % names.hostname)
+ message("DNS Domain: %s" % names.dnsdomain)
+ message("Base DN: %s" % names.domaindn)
+ message("LDAP admin DN: %s" % names.ldapmanagerdn)
+ message("LDAP admin password: %s" % adminpass)
+ message(slapdcommand)
+
def create_phpldapadmin_config(path, setup_path, ldapi_uri):
"""Create a PHP LDAP admin configuration file.
@@ -1246,13 +1298,12 @@ def create_phpldapadmin_config(path, setup_path, ldapi_uri):
{"S4_LDAPI_URI": ldapi_uri})
-def create_zone_file(path, setup_path, samdb, dnsdomain, domaindn,
- hostip, hostip6, hostname, dnspass, realm, domainguid, hostguid):
+def create_zone_file(path, setup_path, dnsdomain, domaindn,
+ hostip, hostip6, hostname, dnspass, realm, domainguid, hostguid):
"""Write out a DNS zone file, from the info in the current database.
-
- :param path: Path of the new file.
- :param setup_path": Setup path function.
- :param samdb: SamDB object
+
+ :param path: Path of the new zone file.
+ :param setup_path: Setup path function.
:param dnsdomain: DNS Domain name
:param domaindn: DN of the Domain
:param hostip: Local IPv4 IP
@@ -1286,6 +1337,44 @@ def create_zone_file(path, setup_path, samdb, dnsdomain, domaindn,
"HOSTIP6_HOST_LINE": hostip6_host_line,
})
+def create_named_conf(path, setup_path, realm, dnsdomain,
+ private_dir, keytab_name):
+ """Write out a file containing zone statements suitable for inclusion in a
+ named.conf file (including GSS-TSIG configuration).
+
+ :param path: Path of the new named.conf file.
+ :param setup_path: Setup path function.
+ :param realm: Realm name
+ :param dnsdomain: DNS Domain name
+ :param private_dir: Path to private directory
+ :param keytab_name: File name of DNS keytab file
+ """
+
+ setup_file(setup_path("named.conf"), path, {
+ "DNSDOMAIN": dnsdomain,
+ "REALM": realm,
+ "REALM_WC": "*." + ".".join(realm.split(".")[1:]),
+ "DNS_KEYTAB": keytab_name,
+ "DNS_KEYTAB_ABS": os.path.join(private_dir, keytab_name),
+ })
+
+def create_krb5_conf(path, setup_path, dnsdomain, hostname, realm):
+ """Write out a file containing zone statements suitable for inclusion in a
+ named.conf file (including GSS-TSIG configuration).
+
+ :param path: Path of the new named.conf file.
+ :param setup_path: Setup path function.
+ :param dnsdomain: DNS Domain name
+ :param hostname: Local hostname
+ :param realm: Realm name
+ """
+
+ setup_file(setup_path("krb5.conf"), path, {
+ "DNSDOMAIN": dnsdomain,
+ "HOSTNAME": hostname,
+ "REALM": realm,
+ })
+
def load_schema(setup_path, samdb, schemadn, netbiosname, configdn, sitename):
"""Load schema for the SamDB.
diff --git a/source4/scripting/python/samba/samba3.py b/source4/scripting/python/samba/samba3.py
index cffedb54af..c1340b7760 100644
--- a/source4/scripting/python/samba/samba3.py
+++ b/source4/scripting/python/samba/samba3.py
@@ -19,6 +19,8 @@
"""Support for reading Samba 3 data files."""
+__docformat__ = "restructuredText"
+
REGISTRY_VALUE_PREFIX = "SAMBA_REGVAL"
REGISTRY_DB_VERSION = 1
@@ -307,6 +309,7 @@ class ShareInfoDatabase(TdbDatabase):
class Shares:
+ """Container for share objects."""
def __init__(self, lp, shareinfo):
self.lp = lp
self.shareinfo = shareinfo
@@ -492,6 +495,7 @@ class TdbSam(TdbDatabase):
assert self.version in (0, 1, 2)
def usernames(self):
+ """Iterate over the usernames in this Tdb database."""
for k in self.tdb.keys():
if k.startswith(TDBSAM_USER_PREFIX):
yield k[len(TDBSAM_USER_PREFIX):].rstrip("\0")
@@ -633,6 +637,7 @@ class WinsDatabase:
return iter(self.entries)
def items(self):
+ """Return the entries in this WINS database."""
return self.entries.items()
def close(self): # for consistency
diff --git a/source4/scripting/python/samba/samdb.py b/source4/scripting/python/samba/samdb.py
index bc3eef7879..6465f49519 100644
--- a/source4/scripting/python/samba/samdb.py
+++ b/source4/scripting/python/samba/samdb.py
@@ -25,20 +25,31 @@
import samba
import misc
import ldb
+from samba.idmap import IDmapDB
+import pwd
+
+__docformat__ = "restructuredText"
class SamDB(samba.Ldb):
"""The SAM database."""
+
def __init__(self, url=None, session_info=None, credentials=None,
modules_dir=None, lp=None):
"""Open the Sam Database.
:param url: URL of the database.
"""
+ self.lp = lp
super(SamDB, self).__init__(session_info=session_info, credentials=credentials,
modules_dir=modules_dir, lp=lp)
assert misc.dsdb_set_global_schema(self) == 0
if url:
self.connect(url)
+ else:
+ self.connect(lp.get("sam database"))
+
+ def connect(self, url):
+ super(SamDB, self).connect(misc.private_path(self.lp, url))
def add_foreign(self, domaindn, sid, desc):
"""Add a foreign security principle."""
@@ -101,10 +112,27 @@ userAccountControl: %u
# now the real work
self.add({"dn": user_dn,
"sAMAccountName": username,
- "unixName": unixname,
"sambaPassword": password,
"objectClass": "user"})
+ res = self.search(user_dn, scope=ldb.SCOPE_BASE,
+ expression="objectclass=*",
+ attrs=["objectSid"])
+ assert(len(res) == 1)
+ user_sid = self.schema_format_value("objectSid", res[0]["objectSid"][0])
+
+
+ try:
+ idmap = IDmapDB(lp=self.lp)
+
+ user = pwd.getpwnam(unixname)
+ # setup ID mapping for this UID
+
+ idmap.setup_name_mapping(user_sid, idmap.TYPE_UID, user[2])
+
+ except KeyError:
+ pass
+
# modify the userAccountControl to remove the disabled bit
self.enable_account(user_dn)
self.transaction_commit()
diff --git a/source4/scripting/python/samba/tests/__init__.py b/source4/scripting/python/samba/tests/__init__.py
index c8673d3fae..e29b4a87d5 100644
--- a/source4/scripting/python/samba/tests/__init__.py
+++ b/source4/scripting/python/samba/tests/__init__.py
@@ -85,8 +85,13 @@ class LdbExtensionTests(TestCaseInTempDir):
os.unlink(path)
-def get_loadparm():
- import param
- lp = param.LoadParm()
- lp.load(os.getenv("SMB_CONF_PATH"))
- return lp
+cmdline_loadparm = None
+cmdline_credentials = None
+
+class RpcInterfaceTestCase(unittest.TestCase):
+ def get_loadparm(self):
+ assert cmdline_loadparm is not None
+ return cmdline_loadparm
+
+ def get_credentials(self):
+ return cmdline_credentials
diff --git a/source4/scripting/python/samba/tests/dcerpc/registry.py b/source4/scripting/python/samba/tests/dcerpc/registry.py
index 147acc5098..81133ff641 100644
--- a/source4/scripting/python/samba/tests/dcerpc/registry.py
+++ b/source4/scripting/python/samba/tests/dcerpc/registry.py
@@ -17,15 +17,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-import winreg
-from param import LoadParm
+from samba.dcerpc import winreg
import unittest
-from samba.tests import get_loadparm
+from samba.tests import RpcInterfaceTestCase
-class WinregTests(unittest.TestCase):
+class WinregTests(RpcInterfaceTestCase):
def setUp(self):
- lp_ctx = get_loadparm()
- self.conn = winreg.winreg("ncalrpc:", lp_ctx)
+ self.conn = winreg.winreg("ncalrpc:", self.get_loadparm(),
+ self.get_credentials())
def get_hklm(self):
return self.conn.OpenHKLM(None,
diff --git a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py
index 8c1a8bec71..3b37f8a9bc 100644
--- a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py
+++ b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py
@@ -17,20 +17,19 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-import echo
+from samba.dcerpc import echo
import unittest
-from samba.tests import get_loadparm
+from samba.tests import RpcInterfaceTestCase
-class RpcEchoTests(unittest.TestCase):
+class RpcEchoTests(RpcInterfaceTestCase):
def setUp(self):
- lp_ctx = get_loadparm()
- self.conn = echo.rpcecho("ncalrpc:", lp_ctx)
+ self.conn = echo.rpcecho("ncalrpc:", self.get_loadparm())
def test_addone(self):
self.assertEquals(2, self.conn.AddOne(1))
def test_echodata(self):
- self.assertEquals([1,2,3], self.conn.EchoData(3, [1, 2, 3]))
+ self.assertEquals([1,2,3], self.conn.EchoData([1, 2, 3]))
def test_call(self):
self.assertEquals(u"foobar", self.conn.TestCall(u"foobar"))
diff --git a/source4/scripting/python/samba/tests/dcerpc/sam.py b/source4/scripting/python/samba/tests/dcerpc/sam.py
index 96348f2f69..50e00a3f9e 100644
--- a/source4/scripting/python/samba/tests/dcerpc/sam.py
+++ b/source4/scripting/python/samba/tests/dcerpc/sam.py
@@ -1,7 +1,8 @@
#!/usr/bin/python
+# -*- coding: utf-8 -*-
# Unix SMB/CIFS implementation.
-# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
+# Copyright © Jelmer Vernooij <jelmer@samba.org> 2008
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -17,13 +18,29 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-import samr
-import unittest
-from samba.tests import get_loadparm
+from samba.dcerpc import samr, security
+from samba.tests import RpcInterfaceTestCase
-class SamrTests(unittest.TestCase):
+# FIXME: Pidl should be doing this for us
+def toArray((handle, array, num_entries)):
+ ret = []
+ for x in range(num_entries):
+ ret.append((array.entries[x].idx, array.entries[x].name))
+ return ret
+
+
+class SamrTests(RpcInterfaceTestCase):
def setUp(self):
- self.conn = samr.samr("ncalrpc:", get_loadparm())
+ self.conn = samr.samr("ncalrpc:", self.get_loadparm())
def test_connect5(self):
(level, info, handle) = self.conn.Connect5(None, 0, 1, samr.ConnectInfo1())
+
+ def test_connect2(self):
+ handle = self.conn.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED)
+
+ def test_EnumDomains(self):
+ handle = self.conn.Connect2(None, security.SEC_FLAG_MAXIMUM_ALLOWED)
+ domains = toArray(self.conn.EnumDomains(handle, 0, -1))
+ self.conn.Close(handle)
+
diff --git a/source4/scripting/python/samba/tests/dcerpc/unix.py b/source4/scripting/python/samba/tests/dcerpc/unix.py
new file mode 100644
index 0000000000..aa47b71b16
--- /dev/null
+++ b/source4/scripting/python/samba/tests/dcerpc/unix.py
@@ -0,0 +1,37 @@
+#!/usr/bin/python
+
+# Unix SMB/CIFS implementation.
+# 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 samba.dcerpc import unixinfo
+from samba.tests import RpcInterfaceTestCase
+
+class UnixinfoTests(RpcInterfaceTestCase):
+ def setUp(self):
+ self.conn = unixinfo.unixinfo("ncalrpc:", self.get_loadparm())
+
+ def test_getpwuid(self):
+ infos = self.conn.GetPWUid(range(512))
+ self.assertEquals(512, len(infos))
+ self.assertEquals("/bin/false", infos[0].shell)
+ self.assertTrue(isinstance(infos[0].homedir, unicode))
+
+ def test_gidtosid(self):
+ self.conn.GidToSid(1000)
+
+ def test_uidtosid(self):
+ self.conn.UidToSid(1000)
diff --git a/source4/scripting/python/samba/tests/provision.py b/source4/scripting/python/samba/tests/provision.py
index 514582cbe4..76c10145f0 100644
--- a/source4/scripting/python/samba/tests/provision.py
+++ b/source4/scripting/python/samba/tests/provision.py
@@ -21,10 +21,10 @@ import os
from samba.provision import setup_secretsdb, secretsdb_become_dc, findnss
import samba.tests
from ldb import Dn
-import param
+from samba import param
import unittest
-lp = samba.tests.get_loadparm()
+lp = samba.tests.cmdline_loadparm
setup_dir = "setup"
def setup_path(file):
diff --git a/source4/scripting/python/samba/tests/samdb.py b/source4/scripting/python/samba/tests/samdb.py
index 3745dba6fc..0d4f7bde0e 100644
--- a/source4/scripting/python/samba/tests/samdb.py
+++ b/source4/scripting/python/samba/tests/samdb.py
@@ -21,7 +21,7 @@ from credentials import Credentials
import os
from samba.provision import setup_samdb
from samba.samdb import SamDB
-from samba.tests import get_loadparm, TestCaseInTempDir
+from samba.tests import cmdline_loadparm, TestCaseInTempDir
import security
from unittest import TestCase
import uuid
@@ -29,21 +29,21 @@ import uuid
class SamDBTestCase(TestCaseInTempDir):
def setUp(self):
super(SamDBTestCase, self).setUp()
- invocationid = uuid.random()
+ invocationid = str(uuid.uuid4())
domaindn = "DC=COM,DC=EXAMPLE"
self.domaindn = domaindn
configdn = "CN=Configuration," + domaindn
schemadn = "CN=Schema," + configdn
- domainguid = uuid.random()
- policyguid = uuid.random()
+ domainguid = str(uuid.uuid4())
+ policyguid = str(uuid.uuid4())
setup_path = lambda x: os.path.join("setup", x)
creds = Credentials()
creds.set_anonymous()
domainsid = security.random_sid()
- hostguid = uuid.random()
+ hostguid = str(uuid.uuid4())
path = os.path.join(self.tempdir, "samdb.ldb")
self.samdb = setup_samdb(path, setup_path, system_session(), creds,
- get_loadparm(), schemadn, configdn,
+ cmdline_loadparm, schemadn, configdn,
self.domaindn, "example.com", "EXAMPLE.COM",
"FOO", lambda x: None, "foo", domaindn,
False, domainsid, "# no aci", domainguid,
diff --git a/source4/scripting/python/samba/upgrade.py b/source4/scripting/python/samba/upgrade.py
index f40f2cffe7..0c83604e82 100644
--- a/source4/scripting/python/samba/upgrade.py
+++ b/source4/scripting/python/samba/upgrade.py
@@ -7,6 +7,8 @@
"""Support code for upgrading from Samba 3 to Samba 4."""
+__docformat__ = "restructuredText"
+
from provision import findnss, provision, FILL_DRS
import grp
import ldb
diff --git a/source4/scripting/python/smbpython.c b/source4/scripting/python/smbpython.c
deleted file mode 100644
index c5de53fd60..0000000000
--- a/source4/scripting/python/smbpython.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba utility functions
- 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/>.
-*/
-
-#include "includes.h"
-#include <Python.h>
-#include "scripting/python/modules.h"
-
-int main(int argc, char **argv)
-{
- py_load_samba_modules();
- Py_Initialize();
- if (strchr(argv[0], '/') != NULL) {
- char *bindir = strndup(argv[0], strrchr(argv[0], '/')-argv[0]);
- py_update_path(bindir);
- free(bindir);
- }
- return Py_Main(argc,argv);
-}
diff --git a/source4/scripting/python/uuidmodule.c b/source4/scripting/python/uuidmodule.c
index cd9a1cb4d5..98ef9adaa9 100644
--- a/source4/scripting/python/uuidmodule.c
+++ b/source4/scripting/python/uuidmodule.c
@@ -27,7 +27,7 @@ static PyObject *uuid_random(PyObject *self, PyObject *args)
PyObject *pyobj;
char *str;
- if (!PyArg_ParseTuple(args, (char *)""))
+ if (!PyArg_ParseTuple(args, ""))
return NULL;
guid = GUID_random();
@@ -46,13 +46,13 @@ static PyObject *uuid_random(PyObject *self, PyObject *args)
}
static PyMethodDef methods[] = {
- { "random", (PyCFunction)uuid_random, METH_VARARGS, NULL},
+ { "uuid4", (PyCFunction)uuid_random, METH_VARARGS, NULL},
{ NULL, NULL }
};
void inituuid(void)
{
- PyObject *mod = Py_InitModule3((char *)"uuid", methods, "UUID helper routines");
+ PyObject *mod = Py_InitModule3("uuid", methods, "UUID helper routines");
if (mod == NULL)
return;
}
diff --git a/source4/selftest/README b/source4/selftest/README
index e8e87c8b3f..f8be20a569 100644
--- a/source4/selftest/README
+++ b/source4/selftest/README
@@ -3,15 +3,70 @@
This directory contains test scripts that are useful for running a
bunch of tests all at once.
-===============
-Available tests
-===============
-The available tests are obtained from a script, usually
-selftest/samba{3,4}_tests.sh. This script should for each test output
+Available testsuites
+====================
+The available testsuites are obtained from a script, usually
+selftest/samba{3,4}_tests.sh. This script should for each testsuite output
the name of the test, the command to run and the environment that should be
-provided.
+provided. Use the included "plantest" function to generate the required output.
+
+Testsuite behaviour
+================================
+
+Exit code
+------------
+The testsuites should exit with a non-zero exit code if at least one
+test failed. Skipped tests should not influence the exit code.
+
+Output format
+-------------
+Testsuites can simply use the exit code to indicate whether all of their
+tests have succeeded or one or more have failed. It is also possible to
+provide more granular information using the Subunit protocol.
+
+This protocol works by writing simple messages to standard output. Any
+messages that can not be interpreted by this protocol are considered comments
+for the last announced test.
+
+Accepted commands are:
+
+test
+~~~~~~~~~~~~
+test: <NAME>
+
+Announce that a new test with the specified name is starting
+
+success
+~~~~~~~~~~~~~~~
+success: <NAME>
+
+Announce that the test with the specified name is done and ran successfully.
+
+failure
+~~~~~~~~~~~~~~~
+failure: <NAME>
+failure: <NAME> [ REASON ]
+
+Announce that the test with the specified name failed. Optionally, it is
+possible to specify a reason it failed.
+
+skip
+~~~~~~~~~~~~
+skip: <NAME>
+skip: <NAME> [ REASON ]
+
+Announce that the test with the specified name was skipped. Optionally a
+reason can be specified.
+
+knownfail
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+knownfail: <NAME>
+knownfail: <NAME> [ REASON ]
+
+Announce that the test with the specified name was run and failed as expected.
+Alternatively it is also possible to simply return "failure:" here but
+specify in the samba4-knownfailures file that it is failing.
-============
Environments
============
Tests often need to run against a server with particular things set up,
@@ -23,6 +78,7 @@ The following environments are currently available:
- none: No server set up, no variables set.
- dc: Domain controller set up. The following environment variables will
be set:
+
* USERNAME: Administrator user name
* PASSWORD: Administrator password
* DOMAIN: Domain name
@@ -34,6 +90,7 @@ The following environments are currently available:
- member: Domain controller and member server that is joined to it set up. The
following environment variables will be set:
+
* USERNAME: Domain administrator user name
* PASSWORD: Domain administrator password
* DOMAIN: Domain name
@@ -41,22 +98,22 @@ The following environments are currently available:
* SERVER: Name of the member server
-=============
Running tests
=============
-To run all the tests use:
+To run all the tests use::
make test
-To run a quick subset (aiming for about 1 minute of testing) run:
+To run a quick subset (aiming for about 1 minute of testing) run::
make quicktest
-To run a specific test, use this syntax
+To run a specific test, use this syntax::
make test TESTS=testname
-for example
+for example::
make test TESTS=samba4.BASE-DELETE
+
diff --git a/source4/selftest/Subunit.pm b/source4/selftest/Subunit.pm
index e5c61ca9ba..05e51da541 100644
--- a/source4/selftest/Subunit.pm
+++ b/source4/selftest/Subunit.pm
@@ -20,15 +20,22 @@ sub parse_results($$$$$)
$msg_ops->control_msg($_);
$msg_ops->start_test($open_tests, $1);
push (@$open_tests, $1);
- } elsif (/^(success|successful|failure|skip|error): (.*?)( \[)?([ \t]*)\n/) {
+ } elsif (/^(success|successful|failure|skip|knownfail|error): (.*?)( \[)?([ \t]*)\n/) {
$msg_ops->control_msg($_);
my $reason = undef;
if ($3) {
$reason = "";
# reason may be specified in next lines
+ my $terminated = 0;
while(<$fh>) {
$msg_ops->control_msg($_);
- if ($_ eq "]\n") { last; } else { $reason .= $_; }
+ if ($_ eq "]\n") { $terminated = 1; last; } else { $reason .= $_; }
+ }
+
+ unless ($terminated) {
+ $statistics->{TESTS_ERROR}++;
+ $msg_ops->end_test($open_tests, $2, $1, 1, "reason interrupted");
+ return 1;
}
}
my $result = $1;
@@ -53,6 +60,10 @@ sub parse_results($$$$$)
$msg_ops->end_test($open_tests, $2, $1, 1, $reason);
$unexpected_fail++;
}
+ } elsif ($1 eq "knownfail") {
+ pop(@$open_tests); #FIXME: Check that popped value == $2
+ $statistics->{TESTS_EXPECTED_FAIL}++;
+ $msg_ops->end_test($open_tests, $2, $1, 0, $reason);
} elsif ($1 eq "skip") {
$statistics->{TESTS_SKIP}++;
pop(@$open_tests); #FIXME: Check that popped value == $2
diff --git a/source4/selftest/output/plain.pm b/source4/selftest/output/plain.pm
index 25ff74792e..4bec4e0fdc 100644
--- a/source4/selftest/output/plain.pm
+++ b/source4/selftest/output/plain.pm
@@ -81,6 +81,9 @@ sub end_testsuite($$$$$)
my $out = "";
if ($unexpected) {
+ if ($result eq "success" and not defined($reason)) {
+ $reason = "Expected negative exit code, got positive exit code";
+ }
$self->output_msg("ERROR: $reason\n");
push (@{$self->{suitesfailed}}, $name);
} else {
@@ -120,7 +123,9 @@ sub end_test($$$$$)
return;
}
- $append = "UNEXPECTED($result): $testname\n";
+ my $fullname = join(".", @$parents).".$testname";
+
+ $append = "UNEXPECTED($result): $testname ($fullname)\n";
$self->{test_output}->{$self->{NAME}} .= $append;
diff --git a/source4/selftest/samba4_tests.sh b/source4/selftest/samba4_tests.sh
index 64b2c7b564..36cf2adccb 100755
--- a/source4/selftest/samba4_tests.sh
+++ b/source4/selftest/samba4_tests.sh
@@ -64,8 +64,7 @@ SCRIPTDIR=$samba4srcdir/../testprogs/ejs
smb4torture="$samba4bindir/smbtorture $TORTURE_OPTIONS"
plantest "js.base" dc "$SCRIPTDIR/base.js" $CONFIGURATION
-plantest "js.samr" dc "$SCRIPTDIR/samr.js" $CONFIGURATION ncalrpc: -U\$USERNAME%\$PASSWORD
-plantest "js.echo" dc "$SCRIPTDIR/echo.js" $CONFIGURATION ncalrpc: -U\$USERNAME%\$PASSWORD
+plantest "samr.python" dc "$samba4bindir/../scripting/bin/samr.py" ncalrpc:
#plantest "ejsnet.js" dc "$SCRIPTDIR/ejsnet.js" $CONFIGURATION -U\$USERNAME%\$PASSWORD \$DOMAIN ejstestuser
plantest "js.ldb" none "$SCRIPTDIR/ldb.js" `pwd` $CONFIGURATION -d 10
plantest "js.winreg" dc $samba4srcdir/scripting/bin/winreg $CONFIGURATION ncalrpc: 'HKLM' -U\$USERNAME%\$PASSWORD
@@ -219,13 +218,16 @@ plantest "rpc.echo on ncacn_np over smb2" dc $smb4torture ncacn_np:"\$SERVER[smb
# Tests against the NTVFS POSIX backend
NTVFSARGS="--option=torture:sharedelay=100000 --option=torture:oplocktimeout=3"
smb2=`$smb4torture --list | grep "^SMB2-" | xargs`
-raw=`$smb4torture --list | grep "^RAW-" | xargs`
+#The QFILEINFO-IPC test needs to be on ipc$
+raw=`$smb4torture --list | grep "^RAW-" | grep -v "RAW-QFILEINFO-IPC"| xargs`
base=`$smb4torture --list | grep "^BASE-" | xargs`
for t in $base $raw $smb2; do
plansmbtorturetest "$t" dc $ADDARGS //\$SERVER/tmp -U"\$USERNAME"%"\$PASSWORD" $NTVFSARGS
done
+plansmbtorturetest "RAW-QFILEINFO-IPC" dc $ADDARGS //\$SERVER/ipc$ -U"\$USERNAME"%"\$PASSWORD"
+
rap=`$smb4torture --list | grep "^RAP-" | xargs`
for t in $rap; do
plansmbtorturetest "$t" dc $ADDARGS //\$SERVER/IPC\\\$ -U"\$USERNAME"%"\$PASSWORD"
@@ -265,6 +267,7 @@ fi
bbdir=$incdir/../../testprogs/blackbox
+plantest "blackbox.ndrdump" dc $bbdir/test_ndrdump.sh
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" $CONFIGURATION
plantest "blackbox.cifsdd" dc $bbdir/test_cifsdd.sh "\$SERVER" "\$USERNAME" "\$PASSWORD" "\$DOMAIN"
@@ -273,6 +276,8 @@ plantest "blackbox.nmblookup" member $samba4srcdir/utils/tests/test_nmblookup.sh
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"
+plantest "blackbox.wbinfo" dc $bbdir/test_wbinfo.sh "\$DOMAIN" "\$USERNAME" "\$PASSWORD" "dc"
+plantest "blackbox.wbinfo" member $bbdir/test_wbinfo.sh "\$DOMAIN" "\$DC_USERNAME" "\$DC_PASSWORD" "member"
# Tests using the "Simple" NTVFS backend
@@ -282,7 +287,7 @@ done
DATADIR=$samba4srcdir/../testdata
-plantest "js.samba3sam" none $SCRIPTDIR/samba3sam.js $CONFIGURATION `pwd` $DATADIR/samba3/
+plantest "js.samba3sam" none $samba4bindir/smbscript $SCRIPTDIR/samba3sam.js $CONFIGURATION `pwd` $DATADIR/samba3/
# Domain Member Tests
@@ -291,7 +296,6 @@ plantest "rpc.echo against member server with domain creds" member $VALGRIND $sm
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`
@@ -299,9 +303,9 @@ for t in $NBT_TESTS; do
plansmbtorturetest "$t" dc //\$SERVER/_none_ -U\$USERNAME%\$PASSWORD
done
-WB_OPTS="--option=\"torture:strict mode=yes\""
+WB_OPTS="--option=\"torture:strict mode=no\""
WB_OPTS="${WB_OPTS} --option=\"torture:timelimit=1\""
-WB_OPTS="${WB_OPTS} --option=\"torture:winbindd separator=\\\\\""
+WB_OPTS="${WB_OPTS} --option=\"torture:winbindd separator=/\""
WB_OPTS="${WB_OPTS} --option=\"torture:winbindd private pipe dir=\$WINBINDD_PRIV_PIPE_DIR\""
WB_OPTS="${WB_OPTS} --option=\"torture:winbindd netbios name=\$SERVER\""
WB_OPTS="${WB_OPTS} --option=\"torture:winbindd netbios domain=\$DOMAIN\""
@@ -323,7 +327,7 @@ then
plantest "nss.test using winbind" member $VALGRIND $samba4bindir/nsstest $samba4bindir/shared/libnss_winbind.so
fi
-PYTHON=bin/smbpython
+PYTHON=/usr/bin/python
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
@@ -338,14 +342,17 @@ 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 "unixinfo.python" dc $SUBUNITRUN samba.tests.dcerpc.unix
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 "winreg.python" dc $SUBUNITRUN -U\$USERNAME%\$PASSWORD 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
+plantest "blackbox.upgrade" none $PYTHON setup/upgrade $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"
+plantest "blackbox.setpassword.py" none PYTHON="$PYTHON" $samba4srcdir/setup/tests/blackbox_setpassword.sh "$PREFIX/provision" "$CONFIGURATION"
+plantest "blackbox.newuser.py" none PYTHON="$PYTHON" $samba4srcdir/setup/tests/blackbox_newuser.sh "$PREFIX/provision" "$CONFIGURATION"
diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl
index 39a1b5a450..5854a94b8d 100755
--- a/source4/selftest/selftest.pl
+++ b/source4/selftest/selftest.pl
@@ -238,7 +238,13 @@ sub run_testsuite($$$$$$)
$msg_ops->start_test([], $name);
- open(RESULT, "$cmd 2>&1|");
+ unless (open(RESULT, "$cmd 2>&1|")) {
+ $statistics->{TESTS_ERROR}++;
+ $msg_ops->end_test([], $name, "error", 1, "Unable to run $cmd: $!");
+ $statistics->{SUITES_FAIL}++;
+ return 0;
+ }
+
my $expected_ret = parse_results(
$msg_ops, $statistics, *RESULT, \&expecting_failure, [$name]);
@@ -250,17 +256,17 @@ sub run_testsuite($$$$$$)
my $ret = close(RESULT);
$ret = 0 unless $ret == 1;
+ my $exitcode = $? >> 8;
+
if ($ret == 1) {
- $msg_ops->end_test([], $name, "success", $expected_ret != $ret, undef);
+ $msg_ops->end_test([], $name, "success", $expected_ret != $ret, undef);
} else {
- $msg_ops->end_test([], $name, "failure", $expected_ret != $ret,
- "Returned $ret");
+ $msg_ops->end_test([], $name, "failure", $expected_ret != $ret, "Exit code was $exitcode");
}
cleanup_pcap($pcap_file, $expected_ret, $ret);
- if (not $opt_socket_wrapper_keep_pcap and
- defined($pcap_file)) {
+ if (not $opt_socket_wrapper_keep_pcap and defined($pcap_file)) {
$msg_ops->output_msg("PCAP FILE: $pcap_file\n");
}
@@ -401,13 +407,19 @@ my $tls_enabled = not $opt_quick;
$ENV{TLS_ENABLED} = ($tls_enabled?"yes":"no");
$ENV{LDB_MODULES_PATH} = "$old_pwd/bin/modules/ldb";
$ENV{LD_SAMBA_MODULE_PATH} = "$old_pwd/bin/modules";
-if (defined($ENV{PKG_CONFIG_PATH})) {
- $ENV{PKG_CONFIG_PATH} = "$old_pwd/bin/pkgconfig:$ENV{PKG_CONFIG_PATH}";
-} else {
- $ENV{PKG_CONFIG_PATH} = "$old_pwd/bin/pkgconfig";
+sub prefix_pathvar($$)
+{
+ my ($name, $newpath) = @_;
+ if (defined($ENV{$name})) {
+ $ENV{$name} = "$newpath:$ENV{$name}";
+ } else {
+ $ENV{$name} = $newpath;
+ }
}
+prefix_pathvar("PKG_CONFIG_PATH", "$old_pwd/bin/pkgconfig");
# Required for smbscript:
-$ENV{PATH} = "$old_pwd/bin:$old_pwd:$ENV{PATH}";
+prefix_pathvar("PATH", "$old_pwd/bin");
+prefix_pathvar("PYTHONPATH", "$old_pwd/bin/python");
if ($opt_socket_wrapper_keep_pcap) {
# Socket wrapper keep pcap implies socket wrapper pcap
diff --git a/source4/selftest/target/Samba4.pm b/source4/selftest/target/Samba4.pm
index 262c8035f6..a12939b0a1 100644
--- a/source4/selftest/target/Samba4.pm
+++ b/source4/selftest/target/Samba4.pm
@@ -201,8 +201,6 @@ sub mk_fedora_ds($$$)
my $pidfile = "$fedora_ds_dir/logs/slapd-samba4.pid";
- system("$self->{bindir}/ad2oLschema $configuration -H $ldapdir/schema-tmp.ldb --option=convert:target=fedora-ds -I $self->{setupdir}/schema-map-fedora-ds-1.0 -O $ldapdir/99_ad.ldif >&2") == 0 or die("schema conversion for Fedora DS failed");
-
my $dir = getcwd();
chdir "$ENV{FEDORA_DS_ROOT}/bin" || die;
if (system("perl $ENV{FEDORA_DS_ROOT}/sbin/setup-ds.pl --silent --file=$fedora_ds_inf >&2") != 0) {
@@ -222,9 +220,6 @@ sub mk_openldap($$$)
my $pidfile = "$ldapdir/slapd.pid";
my $modconf = "$ldapdir/modules.conf";
- #This uses the backend provision we just did, to read out the schema
- system("$self->{bindir}/ad2oLschema $configuration --option=convert:target=openldap -H $ldapdir/schema-tmp.ldb -I $self->{setupdir}/schema-map-openldap-2.3 -O $ldapdir/backend-schema.schema >&2") == 0 or die("schema conversion for OpenLDAP failed");
-
my $oldpath = $ENV{PATH};
my $olpath = "";
my $olroot = "";
@@ -526,7 +521,7 @@ sub provision($$$$$$)
my $ncalrpcdir = "$prefix_abs/ncalrpc";
my $lockdir = "$prefix_abs/lockdir";
my $winbindd_socket_dir = "$prefix_abs/winbind_socket";
- my $winbindd_priv_pipe_dir = "$piddir/smbd.tmp/winbind_pipe";
+ my $winbindd_priv_pipe_dir = "$privatedir/smbd.tmp/winbind_pipe";
my $nsswrap_passwd = "$etcdir/passwd";
my $nsswrap_group = "$etcdir/group";
@@ -700,11 +695,17 @@ 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{GDB_PROVISION})) {
+ push (@provision_options, "gdb --args");
+ }
+ if (defined($ENV{VALGRIND_PROVISION})) {
+ push (@provision_options, "valgrind");
+ }
if (defined($ENV{PROVISION_EJS})) {
push (@provision_options, "$self->{bindir}/smbscript");
push (@provision_options, "$self->{setupdir}/provision.js");
} else {
- push (@provision_options, "$self->{bindir}/smbpython");
+# push (@provision_options, "$self->{bindir}/smbpython");
push (@provision_options, "$self->{setupdir}/provision");
}
push (@provision_options, split(' ', $configuration));
diff --git a/source4/setup/enableaccount b/source4/setup/enableaccount
index 849b515675..061997b804 100644..100755
--- a/source4/setup/enableaccount
+++ b/source4/setup/enableaccount
@@ -5,17 +5,19 @@
# Copyright Jelmer Vernooij 2008
# Released under the GNU GPL version 3 or later
#
+import os, sys
+
+sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), "../bin/python"))
import samba.getopt as options
import optparse
import pwd
-import sys
import ldb
-from auth import system_session
+from samba.auth import system_session
from samba.samdb import SamDB
-parser = optparse.OptionParser("setpassword [username] [options]")
+parser = optparse.OptionParser("enableaccount [username] [options]")
sambaopts = options.SambaOptions(parser)
parser.add_option_group(sambaopts)
parser.add_option_group(options.VersionOptions(parser))
diff --git a/source4/setup/idmap_init.ldif b/source4/setup/idmap_init.ldif
index a397cfd0d2..43e5b65562 100644
--- a/source4/setup/idmap_init.ldif
+++ b/source4/setup/idmap_init.ldif
@@ -1,5 +1,4 @@
dn: CN=CONFIG
cn: CONFIG
-lowerBound: 10000
-upperBound: 20000
-
+lowerBound: 3000000
+upperBound: 4000000
diff --git a/source4/setup/krb5.conf b/source4/setup/krb5.conf
new file mode 100644
index 0000000000..7dad63de73
--- /dev/null
+++ b/source4/setup/krb5.conf
@@ -0,0 +1,17 @@
+[libdefaults]
+ default_realm = ${REALM}
+ dns_lookup_realm = false
+ dns_lookup_kdc = false
+ ticket_lifetime = 24h
+ forwardable = yes
+
+[realms]
+ ${REALM} = {
+ kdc = ${HOSTNAME}.${DNSDOMAIN}:88
+ admin_server = ${HOSTNAME}.${DNSDOMAIN}:749
+ default_domain = ${DNSDOMAIN}
+ }
+
+[domain_realm]
+ .${DNSDOMAIN} = ${REALM}
+ ${DNSDOMAIN} = ${REALM}
diff --git a/source4/setup/named.conf b/source4/setup/named.conf
index 025788093e..4f98bbd914 100644
--- a/source4/setup/named.conf
+++ b/source4/setup/named.conf
@@ -3,35 +3,102 @@
# the BIND nameserver.
#
-# If you have a very recent BIND, supporting GSS-TSIG,
-# insert this into options {} (otherwise omit, it is not required if we don't accept updates)
-tkey-gssapi-credential "DNS/${DNSDOMAIN}";
-tkey-domain "${REALM}";
-
-# You should always include the actual zone configuration reference:
+# You should always include the actual forward zone configuration:
zone "${DNSDOMAIN}." IN {
- type master;
- file "${DNSDOMAIN}.zone";
+ type master;
+ file "${DNSDOMAIN}.zone";
update-policy {
- /* use ANY only for Domain controllers for now */
- /* for normal machines A AAAA PTR is probbaly all is needed */
- grant ${HOSTNAME}.${DNSDOMAIN}@${REALM} name ${HOSTNAME}.${DNSDOMAIN} ANY;
+ /*
+ * A rather long description here, as the "ms-self" option does
+ * not appear in any docs yet (it can only be found in the
+ * source code).
+ *
+ * The short of it is that each host is allowed to update its
+ * own A and AAAA records, when the update request is properly
+ * signed by the host itself.
+ *
+ * The long description is (look at the
+ * dst_gssapi_identitymatchesrealmms() call in lib/dns/ssu.c and
+ * its definition in lib/dns/gssapictx.c for details):
+ *
+ * A GSS-TSIG update request will be signed by a given signer
+ * (e.g. machine-name$@${REALM}). The signer name is split into
+ * the machine component (e.g. "machine-name") and the realm
+ * component (e.g. "${REALM}"). The update is allowed if the
+ * following conditions are met:
+ *
+ * 1) The machine component of the signer name matches the first
+ * (host) component of the FQDN that is being updated.
+ *
+ * 2) The realm component of the signer name matches the realm
+ * in the grant statement below (${REALM}).
+ *
+ * 3) The domain component of the FQDN that is being updated
+ * matches the realm in the grant statement below.
+ *
+ * If the 3 conditions above are satisfied, the update succeeds.
+ */
+ grant ${REALM} ms-self * A AAAA;
};
};
-# Also, you need to change your init scripts to set this environment variable
-# for named: KRB5_KTNAME so that it points to the keytab generated.
-# In RedHat derived systems such RHEL/CentOS/Fedora you can add the following
-# line to the /etc/sysconfig/named file:
-# export KRB5_KTNAME=${DNS_KEYTAB_ABS}
-#
-# Please note that most distributions have BIND configured to run under
-# a non-root user account. For example, Fedora Core 6 (FC6) runs BIND as
-# the user "named" once the daemon relinquishes its rights. Therefore,
-# the file "${DNS_KEYTAB}" must be readable by the user that BIND run as.
-# If BIND is running as a non-root user, the "${DNS_KEYTAB}" file must have its
-# permissions altered to allow the daemon to read it. In the FC6
-# example, execute the commands:
-#
-# chgrp named ${DNS_KEYTAB_ABS}
-# chmod g+r ${DNS_KEYTAB_ABS}
+# The reverse zone configuration is optional. The following example assumes a
+# subnet of 192.168.123.0/24:
+zone "123.168.192.in-addr.arpa" in {
+ type master;
+ file "123.168.192.in-addr.arpa.zone";
+ update-policy {
+ grant ${REALM_WC} wildcard *.123.168.192.in-addr.arpa. PTR;
+ };
+};
+# Note that the reverse zone file is not created during the provision process.
+
+# The most recent BIND version (9.5.0a5 or later) supports secure GSS-TSIG
+# updates. If you are running an earlier version of BIND, or if you do not wish
+# to use secure GSS-TSIG updates, you may remove the update-policy sections in
+# both examples above.
+
+# If you are running a capable version of BIND and you wish to support secure
+# GSS-TSIG updates, you must make the following configuration changes:
+
+# - Insert the following lines into the options {} section of your named.conf
+# file:
+tkey-gssapi-credential "DNS/${DNSDOMAIN}";
+tkey-domain "${REALM}";
+
+# - Modify BIND init scripts to pass the location of the generated keytab file.
+# Fedora 8 & later provide a variable named KEYTAB_FILE in /etc/sysconfig/named
+# for this purpose:
+KEYTAB_FILE="${DNS_KEYTAB_ABS}"
+# Note that the Fedora scripts translate KEYTAB_FILE behind the scenes into a
+# variable named KRB5_KTNAME, which is ultimately passed to the BIND daemon. If
+# your distribution does not provide a variable like KEYTAB_FILE to pass a
+# keytab file to the BIND daemon, a workaround is to place the following line in
+# BIND's sysconfig file or in the init script for BIND:
+export KRB5_KTNAME="${DNS_KEYTAB_ABS}"
+
+# - Set appropriate ownership and permissions on the ${DNS_KEYTAB} file. Note
+# that most distributions have BIND configured to run under a non-root user
+# account. For example, Fedora 9 runs BIND as the user "named" once the daemon
+# relinquishes its rights. Therefore, the file ${DNS_KEYTAB} must be readable
+# by the user that BIND run as. If BIND is running as a non-root user, the
+# "${DNS_KEYTAB}" file must have its permissions altered to allow the daemon to
+# read it. Under Fedora 9, execute the following commands:
+chgrp named ${DNS_KEYTAB_ABS}
+chmod g+r ${DNS_KEYTAB_ABS}
+
+# - Ensure the BIND zone file(s) that will be dynamically updated are in a
+# directory where the BIND daemon can write. When BIND performs dynamic
+# updates, it not only needs to update the zone file itself but it must also
+# create a journal (.jnl) file to track the dynamic updates as they occur.
+# Under Fedora 9, the /var/named directory can not be written to by the "named"
+# user. However, the directory /var/named/dynamic directory does provide write
+# access. Therefore the zone files were placed under the /var/named/dynamic
+# directory. The file directives in both example zone statements at the
+# beginning of this file were changed by prepending the directory "dynamic/".
+
+# - If SELinux is enabled, ensure that all files have the appropriate SELinux
+# file contexts. The ${DNS_KEYTAB} file must be accessible by the BIND daemon
+# and should have a SELinux type of named_conf_t. This can be set with the
+# following command:
+chcon -t named_conf_t ${DNS_KEYTAB_ABS}
diff --git a/source4/setup/newuser b/source4/setup/newuser
index f622058a5d..991afa36d8 100755
--- a/source4/setup/newuser
+++ b/source4/setup/newuser
@@ -6,12 +6,16 @@
# Released under the GNU GPL version 3 or later
#
+import sys
+
+# Find right directory when running from source tree
+sys.path.insert(0, "bin/python")
+
import samba.getopt as options
import optparse
import pwd
-import sys
from getpass import getpass
-from auth import system_session
+from samba.auth import system_session
from samba.samdb import SamDB
parser = optparse.OptionParser("newuser [options] <username> [<password>]")
@@ -45,15 +49,9 @@ else:
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()
+creds = credopts.get_credentials(lp)
+
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/provision b/source4/setup/provision
index 259bd814a4..c1d6cd157a 100755
--- a/source4/setup/provision
+++ b/source4/setup/provision
@@ -26,15 +26,20 @@ import getopt
import optparse
import os, sys
+# Find right directory when running from source tree
+sys.path.insert(0, "bin/python")
+
import samba
-import param
-from auth import system_session
+from samba.auth import system_session
import samba.getopt as options
+from samba import param
from samba.provision import (provision,
FILL_FULL, FILL_NT4SYNC,
FILL_DRS)
+# how do we make this case insensitive??
+
parser = optparse.OptionParser("provision [options]")
sambaopts = options.SambaOptions(parser)
parser.add_option_group(sambaopts)
diff --git a/source4/setup/provision-backend b/source4/setup/provision-backend
index ada6dcef8d..54dc5839bf 100755
--- a/source4/setup/provision-backend
+++ b/source4/setup/provision-backend
@@ -22,14 +22,17 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+import os, sys
+
+sys.path.insert(0, "bin/python")
+
import getopt
import optparse
-import os, sys
import samba
-import param
+from samba import param
-from auth import system_session
+from samba.auth import system_session
import samba.getopt as options
from samba.provision import (provision_backend)
@@ -54,6 +57,8 @@ parser.add_option("--quiet", help="Be quiet", action="store_true")
parser.add_option("--ldap-backend-type", type="choice", metavar="LDAP-BACKEND-TYPE",
help="LDB mapping module to use for the LDAP backend",
choices=["fedora-ds", "openldap"])
+parser.add_option("--ldap-backend-port", type="int", metavar="PORT",
+ help="TCP Port LDAP server should listen to (default ldapi only)")
parser.add_option("--server-role", type="choice", metavar="ROLE",
choices=["domain controller", "dc", "member server", "member", "standalone"],
help="Set server role to provision for (default standalone)")
@@ -89,10 +94,9 @@ if setup_dir is None:
setup_dir = "setup"
provision_backend(setup_dir=setup_dir, message=message, smbconf=smbconf, targetdir=opts.targetdir,
- realm=opts.realm, domain=opts.domain,
- hostname=opts.host_name,
- adminpass=opts.ldap_manager_pass,
- root=opts.root, serverrole=server_role,
- ldap_backend_type=opts.ldap_backend_type)
-
-message("All OK")
+ realm=opts.realm, domain=opts.domain,
+ hostname=opts.host_name,
+ adminpass=opts.ldap_manager_pass,
+ root=opts.root, serverrole=server_role,
+ ldap_backend_type=opts.ldap_backend_type,
+ ldap_backend_port=opts.ldap_backend_port)
diff --git a/source4/setup/provision-backend.js b/source4/setup/provision-backend.js
deleted file mode 100644
index 9482d8c435..0000000000
--- a/source4/setup/provision-backend.js
+++ /dev/null
@@ -1,188 +0,0 @@
-#!/bin/sh
-exec smbscript "$0" ${1+"$@"}
-/*
- provision a Samba4 server
- Copyright Andrew Tridgell 2005
- Released under the GNU GPL version 3 or later
-*/
-
-options = GetOptions(ARGV,
- "POPT_AUTOHELP",
- "POPT_COMMON_SAMBA",
- "POPT_COMMON_VERSION",
- "POPT_COMMON_CREDENTIALS",
- 'realm=s',
- 'host-name=s',
- 'ldap-manager-pass=s',
- 'root=s',
- 'quiet',
- 'ldap-backend-type=s',
- 'ldap-backend-port=i');
-
-if (options == undefined) {
- println("Failed to parse options");
- return -1;
-}
-
-sys = sys_init();
-
-libinclude("base.js");
-libinclude("provision.js");
-
-/*
- print a message if quiet is not set
-*/
-function message()
-{
- if (options["quiet"] == undefined) {
- print(vsprintf(arguments));
- }
-}
-
-/*
- show some help
-*/
-function ShowHelp()
-{
- print("
-Samba4 provisioning
-
-provision [options]
- --realm REALM set realm
- --host-name HOSTNAME set hostname
- --ldap-manager-pass PASSWORD choose LDAP Manager password (otherwise random)
- --root USERNAME choose 'root' unix username
- --quiet Be quiet
- --ldap-backend-type LDAPSERVER Select either \"openldap\" or \"fedora-ds\" as a target to configure
- --ldap-backend-port PORT Select the TCP port (if any) that the LDAP backend should listen on (Fedora DS only)
-You must provide at least a realm and ldap-backend-type
-
-");
- exit(1);
-}
-
-if (options['host-name'] == undefined) {
- options['host-name'] = hostname();
-}
-
-/*
- main program
-*/
-if (options["realm"] == undefined ||
- options["ldap-backend-type"] == undefined ||
- options["host-name"] == undefined) {
- ShowHelp();
-}
-
-/* cope with an initially blank smb.conf */
-var lp = loadparm_init();
-lp.set("realm", options.realm);
-lp.reload();
-
-var subobj = provision_guess();
-for (r in options) {
- var key = strupper(join("", split("-", r)));
- subobj[key] = options[r];
-}
-
-
-
-var paths = provision_default_paths(subobj);
-provision_fix_subobj(subobj, paths);
-message("Provisioning LDAP backend for %s in realm %s into %s\n", subobj.HOSTNAME, subobj.REALM, subobj.LDAPDIR);
-message("Using %s password: %s\n", subobj.LDAPMANAGERDN, subobj.LDAPMANAGERPASS);
-var tmp_schema_ldb = subobj.LDAPDIR + "/schema-tmp.ldb";
-sys.mkdir(subobj.LDAPDIR, 0700);
-
-provision_schema(subobj, message, tmp_schema_ldb, paths);
-
-var mapping;
-var backend_schema;
-var slapd_command;
-if (options["ldap-backend-type"] == "fedora-ds") {
- mapping = "schema-map-fedora-ds-1.0";
- backend_schema = "99_ad.ldif";
- if (options["ldap-backend-port"] != undefined) {
- message("Will listen on TCP port " + options["ldap-backend-port"] + "\n");
- subobj.SERVERPORT="ServerPort = " + options["ldap-backend-port"];
- } else {
- message("Will listen on LDAPI only\n");
- subobj.SERVERPORT="";
- }
- setup_file("fedorads.inf", message, subobj.LDAPDIR + "/fedorads.inf", subobj);
- setup_file("fedorads-partitions.ldif", message, subobj.LDAPDIR + "/fedorads-partitions.ldif", subobj);
-
- slapd_command = "(see documentation)";
-} else if (options["ldap-backend-type"] == "openldap") {
- mapping = "schema-map-openldap-2.3";
- backend_schema = "backend-schema.schema";
- setup_file("slapd.conf", message, subobj.LDAPDIR + "/slapd.conf", subobj);
- setup_file("modules.conf", message, subobj.LDAPDIR + "/modules.conf", subobj);
- sys.mkdir(subobj.LDAPDIR + "/db", 0700);
- subobj.LDAPDBDIR = subobj.LDAPDIR + "/db/user";
- sys.mkdir(subobj.LDAPDBDIR, 0700);
- sys.mkdir(subobj.LDAPDBDIR + "/bdb-logs", 0700);
- sys.mkdir(subobj.LDAPDBDIR + "/tmp", 0700);
- setup_file("DB_CONFIG", message, subobj.LDAPDBDIR + "/DB_CONFIG", subobj);
- subobj.LDAPDBDIR = subobj.LDAPDIR + "/db/config";
- sys.mkdir(subobj.LDAPDBDIR, 0700);
- sys.mkdir(subobj.LDAPDBDIR + "/bdb-logs", 0700);
- sys.mkdir(subobj.LDAPDBDIR + "/tmp", 0700);
- setup_file("DB_CONFIG", message, subobj.LDAPDBDIR + "/DB_CONFIG", subobj);
- subobj.LDAPDBDIR = subobj.LDAPDIR + "/db/schema";
- sys.mkdir(subobj.LDAPDBDIR, 0700);
- sys.mkdir(subobj.LDAPDBDIR + "/tmp", 0700);
- sys.mkdir(subobj.LDAPDBDIR + "/bdb-logs", 0700);
- setup_file("DB_CONFIG", message, subobj.LDAPDBDIR + "/DB_CONFIG", subobj);
- if (options["ldap-backend-port"] != undefined) {
- message("\nStart slapd with: \n");
- slapd_command = "slapd -f " + subobj.LDAPDIR + "/slapd.conf -h \"ldap://0.0.0.0:" + options["ldap-backend-port"] + " " + subobj.LDAPI_URI "\"";
- } else {
- slapd_command = "slapd -f " + subobj.LDAPDIR + "/slapd.conf -h " + subobj.LDAPI_URI;
- }
-
- var ldb = ldb_init();
- ldb.filename = tmp_schema_ldb;
-
- var connect_ok = ldb.connect(ldb.filename);
- assert(connect_ok);
- var attrs = new Array("linkID", "lDAPDisplayName");
- var res = ldb.search("(&(&(linkID=*)(!(linkID:1.2.840.113556.1.4.803:=1)))(objectclass=attributeSchema))", subobj.SCHEMADN, ldb.SCOPE_SUBTREE, attrs);
- assert(res.error == 0);
- var memberof_config = "";
- var refint_attributes = "";
- for (i=0; i < res.msgs.length; i++) {
- var target = searchone(ldb, subobj.SCHEMADN, "(&(objectclass=attributeSchema)(linkID=" + (res.msgs[i].linkID + 1) + "))", "lDAPDisplayName");
- if (target != undefined) {
- refint_attributes = refint_attributes + " " + target + " " + res.msgs[i].lDAPDisplayName;
- memberof_config = memberof_config + "overlay memberof
-memberof-dangling error
-memberof-refint TRUE
-memberof-group-oc top
-memberof-member-ad " + res.msgs[i].lDAPDisplayName + "
-memberof-memberof-ad " + target + "
-memberof-dangling-error 32
-
-";
- }
- }
-
- memberof_config = memberof_config + "
-overlay refint
-refint_attributes" + refint_attributes + "
-";
-
- ok = sys.file_save(subobj.LDAPDIR + "/memberof.conf", memberof_config);
- if (!ok) {
- message("failed to create file: " + f + "\n");
- assert(ok);
- }
-
-}
-var schema_command = "ad2oLschema --option=convert:target=" + options["ldap-backend-type"] + " -I " + lp.get("setup directory") + "/" + mapping + " -H tdb://" + tmp_schema_ldb + " -O " + subobj.LDAPDIR + "/" + backend_schema;
-
-message("\nCreate a suitable schema file with:\n%s\n", schema_command);
-message("\nStart slapd with: \n%s\n", slapd_command);
-
-message("All OK\n");
-return 0;
diff --git a/source4/setup/provision.ldif b/source4/setup/provision.ldif
index 37b6bdaa60..2f734e83b2 100644
--- a/source4/setup/provision.ldif
+++ b/source4/setup/provision.ldif
@@ -30,7 +30,7 @@ objectclass: rIDManager
cn: RID Manager$
systemFlags: 2348810240
isCriticalSystemObject: TRUE
-fSMORoleOwner: CN=NTDS Settings,CN=${NETBIOSNAME},CN=Servers,CN=${DEFAULTSITE},CN=Sites,${CONFIGDN}
+fSMORoleOwner: CN=NTDS Settings,${SERVERDN}
rIDAvailablePool: 4611686014132423217
dn: CN=DomainUpdates,CN=System,${DOMAINDN}
@@ -50,7 +50,7 @@ objectclass: infrastructureUpdate
cn: Infrastructure
systemFlags: 2348810240
isCriticalSystemObject: TRUE
-fSMORoleOwner: CN=NTDS Settings,CN=${NETBIOSNAME},CN=Servers,CN=${DEFAULTSITE},CN=Sites,${CONFIGDN}
+fSMORoleOwner: CN=NTDS Settings,${SERVERDN}
dn: CN=Builtin,${DOMAINDN}
objectClass: top
diff --git a/source4/setup/provision_basedn_modify.ldif b/source4/setup/provision_basedn_modify.ldif
index dadfda720e..63332e937b 100644
--- a/source4/setup/provision_basedn_modify.ldif
+++ b/source4/setup/provision_basedn_modify.ldif
@@ -65,7 +65,7 @@ replace: objectCategory
objectCategory: CN=Domain-DNS,${SCHEMADN}
-
replace: fSMORoleOwner
-fSMORoleOwner: CN=NTDS Settings,CN=${NETBIOSNAME},CN=Servers,CN=${DEFAULTSITE},CN=Sites,${CONFIGDN}
+fSMORoleOwner: CN=NTDS Settings,${SERVERDN}
-
replace: isCriticalSystemObject
isCriticalSystemObject: TRUE
@@ -75,6 +75,6 @@ subRefs: ${CONFIGDN}
subRefs: ${SCHEMADN}
-
replace: gPLink
-gPLink: [LDAP://CN={${POLICYGUID}},CN=Policies,CN=System,${DOMAINDN};2]
+gPLink: [LDAP://CN={${POLICYGUID}},CN=Policies,CN=System,${DOMAINDN};0]
-
${DOMAINGUID_MOD}
diff --git a/source4/setup/provision_configuration.ldif b/source4/setup/provision_configuration.ldif
index 0fe90b0739..2a7357d7ad 100644
--- a/source4/setup/provision_configuration.ldif
+++ b/source4/setup/provision_configuration.ldif
@@ -7,7 +7,7 @@ objectClass: crossRefContainer
cn: Partitions
systemFlags: 2147483648
msDS-Behavior-Version: 0
-fSMORoleOwner: CN=NTDS Settings,CN=${NETBIOSNAME},CN=Servers,CN=${DEFAULTSITE},CN=Sites,${CONFIGDN}
+fSMORoleOwner: CN=NTDS Settings,${SERVERDN}
dn: CN=Enterprise Configuration,CN=Partitions,${CONFIGDN}
objectClass: top
diff --git a/source4/setup/provision_rootdse_add.ldif b/source4/setup/provision_rootdse_add.ldif
index 9f19796ec6..14e0d71df6 100644
--- a/source4/setup/provision_rootdse_add.ldif
+++ b/source4/setup/provision_rootdse_add.ldif
@@ -1,7 +1,7 @@
# the rootDSE module looks in this record for its base data
dn: @ROOTDSE
subschemaSubentry: CN=Aggregate,${SCHEMADN}
-dsServiceName: CN=NTDS Settings,CN=${NETBIOSNAME},CN=Servers,CN=${DEFAULTSITE},CN=Sites,${CONFIGDN}
+dsServiceName: CN=NTDS Settings,${SERVERDN}
defaultNamingContext: ${DOMAINDN}
rootDomainNamingContext: ${ROOTDN}
configurationNamingContext: ${CONFIGDN}
@@ -9,10 +9,9 @@ schemaNamingContext: ${SCHEMADN}
supportedLDAPVersion: 3
dnsHostName: ${DNSNAME}
ldapServiceName: ${DNSDOMAIN}:${NETBIOSNAME}$@${REALM}
-serverName: CN=${NETBIOSNAME},CN=Servers,CN=${DEFAULTSITE},CN=Sites,${CONFIGDN}
+serverName: ${SERVERDN}
domainFunctionality: 0
forestFunctionality: 0
domainControllerFunctionality: 2
isSynchronized: FALSE
vendorName: Samba Team (http://samba.org)
-vendorVersion: ${VERSION}
diff --git a/source4/setup/provision_schema_basedn_modify.ldif b/source4/setup/provision_schema_basedn_modify.ldif
index 4e690376d7..4e8267a303 100644
--- a/source4/setup/provision_schema_basedn_modify.ldif
+++ b/source4/setup/provision_schema_basedn_modify.ldif
@@ -4,7 +4,7 @@
dn: ${SCHEMADN}
changetype: modify
replace: fSMORoleOwner
-fSMORoleOwner: CN=NTDS Settings,CN=${NETBIOSNAME},CN=Servers,CN=${DEFAULTSITE},CN=Sites,${CONFIGDN}
+fSMORoleOwner: CN=NTDS Settings,${SERVERDN}
-
replace: objectVersion
objectVersion: 30
diff --git a/source4/setup/provision_self_join.ldif b/source4/setup/provision_self_join.ldif
index a0cfa7eb23..c91e2f4c19 100644
--- a/source4/setup/provision_self_join.ldif
+++ b/source4/setup/provision_self_join.ldif
@@ -36,7 +36,7 @@ isCriticalSystemObject: TRUE
sambaPassword:: ${DNSPASS_B64}
showInAdvancedViewOnly: TRUE
-dn: CN=${NETBIOSNAME},CN=Servers,CN=${DEFAULTSITE},CN=Sites,${CONFIGDN}
+dn: ${SERVERDN}
objectClass: top
objectClass: server
cn: ${NETBIOSNAME}
@@ -44,7 +44,7 @@ systemFlags: 1375731712
dNSHostName: ${DNSNAME}
serverReference: CN=${NETBIOSNAME},OU=Domain Controllers,${DOMAINDN}
-dn: CN=NTDS Settings,CN=${NETBIOSNAME},CN=Servers,CN=${DEFAULTSITE},CN=Sites,${CONFIGDN}
+dn: CN=NTDS Settings,${SERVERDN}
objectClass: top
objectClass: applicationSettings
objectClass: nTDSDSA
diff --git a/source4/setup/secrets_dc.ldif b/source4/setup/secrets_dc.ldif
index 71c7fc2f5b..abc5860cf7 100644
--- a/source4/setup/secrets_dc.ldif
+++ b/source4/setup/secrets_dc.ldif
@@ -33,6 +33,7 @@ objectClass: secret
objectClass: kerberosSecret
realm: ${REALM}
servicePrincipalName: DNS/${DNSDOMAIN}
+msDS-KeyVersionNumber: 1
privateKeytab: ${DNS_KEYTAB}
secret:: ${DNSPASS_B64}
diff --git a/source4/setup/setpassword b/source4/setup/setpassword
index 31b2f73a25..65770e1f4d 100644
--- a/source4/setup/setpassword
+++ b/source4/setup/setpassword
@@ -6,12 +6,17 @@
# Released under the GNU GPL version 3 or later
#
+import os, sys
+
+# Find right directory when running from source tree
+sys.path.insert(0, "bin/python")
+
import samba.getopt as options
import optparse
import pwd
import sys
from getpass import getpass
-from auth import system_session
+from samba.auth import system_session
from samba.samdb import SamDB
parser = optparse.OptionParser("setpassword [username] [options]")
@@ -36,7 +41,7 @@ if len(args) == 0:
parser.print_usage()
sys.exit(1)
-password = opts.password;
+password = opts.newpassword;
if password is None:
password = getpass("New Password: ")
@@ -47,12 +52,12 @@ if filter is None:
if username is None:
print "Either username or --filter must be specified"
- filter = "(&(objectclass=user)(samAccountName=" + username + "))"
+ filter = "(&(objectclass=user)(samAccountName=%s))" % (username)
-creds = credopts.get_credentials()
-
lp = sambaopts.get_loadparm()
+creds = credopts.get_credentials(lp)
+
samdb = SamDB(url=lp.get("sam database"), session_info=system_session(),
credentials=creds, lp=lp)
samdb.setpassword(filter, password)
diff --git a/source4/setup/tests/blackbox_newuser.sh b/source4/setup/tests/blackbox_newuser.sh
new file mode 100755
index 0000000000..fed5f7d263
--- /dev/null
+++ b/source4/setup/tests/blackbox_newuser.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+if [ $# -lt 2 ]; then
+cat <<EOF
+Usage: blackbox_newuser.sh PREFIX CONFIGURATION
+EOF
+exit 1;
+fi
+
+PREFIX="$1"
+CONFIGURATION="$2"
+shift 2
+
+. `dirname $0`/../../../testprogs/blackbox/subunit.sh
+
+
+testit "simple-dc" $PYTHON ./setup/provision $CONFIGURATION --server-role="dc" --domain=FOO --realm=foo.example.com --domain-sid=S-1-5-21-4177067393-1453636373-93818738 --targetdir=$PREFIX/simple-dc
+
+testit "newuser" $PYTHON ./setup/newuser --configfile=$PREFIX/simple-dc/etc/smb.conf testuser testpass
+
+exit $failed
diff --git a/source4/setup/tests/blackbox_provision.sh b/source4/setup/tests/blackbox_provision.sh
index 75d4fcfcb4..2afa9dc952 100755
--- a/source4/setup/tests/blackbox_provision.sh
+++ b/source4/setup/tests/blackbox_provision.sh
@@ -11,26 +11,14 @@ 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
-}
+. `dirname $0`/../../../testprogs/blackbox/subunit.sh
testit "simple-default" $PYTHON ./setup/provision $CONFIGURATION --domain=FOO --realm=foo.example.com --targetdir=$PREFIX/simple-default
testit "simple-dc" $PYTHON ./setup/provision $CONFIGURATION --server-role="dc" --domain=FOO --realm=foo.example.com --domain-sid=S-1-5-21-4177067393-1453636373-93818738 --targetdir=$PREFIX/simple-dc
testit "simple-member" $PYTHON ./setup/provision $CONFIGURATION --server-role="member" --domain=FOO --realm=foo.example.com --targetdir=$PREFIX/simple-member
testit "simple-standalone" $PYTHON ./setup/provision $CONFIGURATION --server-role="standalone" --domain=FOO --realm=foo.example.com --targetdir=$PREFIX/simple-standalone
+testit "blank-dc" $PYTHON ./setup/provision $CONFIGURATION --server-role="dc" --domain=FOO --realm=foo.example.com --domain-sid=S-1-5-21-4177067393-1453636373-93818738 --targetdir=$PREFIX/blank-dc --blank
+testit "partitions-only-dc" $PYTHON ./setup/provision $CONFIGURATION --server-role="dc" --domain=FOO --realm=foo.example.com --domain-sid=S-1-5-21-4177067393-1453636373-93818738 --targetdir=$PREFIX/partitions-only-dc --partitions-only
reprovision() {
$PYTHON ./setup/provision $CONFIGURATION --domain=FOO --realm=foo.example.com --targetdir="$PREFIX/reprovision"
diff --git a/source4/setup/tests/blackbox_setpassword.sh b/source4/setup/tests/blackbox_setpassword.sh
new file mode 100755
index 0000000000..725466150c
--- /dev/null
+++ b/source4/setup/tests/blackbox_setpassword.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if [ $# -lt 2 ]; then
+cat <<EOF
+Usage: blackbox_setpassword.sh PREFIX CONFIGURATION
+EOF
+exit 1;
+fi
+
+PREFIX="$1"
+CONFIGURATION="$2"
+shift 2
+
+. `dirname $0`/../../../testprogs/blackbox/subunit.sh
+
+testit "simple-dc" $PYTHON ./setup/provision $CONFIGURATION --server-role="dc" --domain=FOO --realm=foo.example.com --domain-sid=S-1-5-21-4177067393-1453636373-93818738 --targetdir=$PREFIX/simple-dc
+
+testit "newuser" $PYTHON ./setup/newuser --configfile=$PREFIX/simple-dc/etc/smb.conf testuser testpass
+
+testit "setpassword" $PYTHON ./setup/setpassword --configfile=$PREFIX/simple-dc/etc/smb.conf testuser --newpassword=testpass
+
+exit $failed
diff --git a/source4/setup/upgrade.py b/source4/setup/upgrade
index 3bcc57ab64..03c6747d4e 100755
--- a/source4/setup/upgrade.py
+++ b/source4/setup/upgrade
@@ -7,10 +7,14 @@
import getopt
import optparse
import os, sys
-import param
+
+# Find right directory when running from source tree
+sys.path.insert(0, "bin/python")
+
import samba
import samba.getopt as options
-from auth import system_session
+from samba import param
+from samba.auth import system_session
parser = optparse.OptionParser("upgrade [options] <libdir> <smbconf>")
sambaopts = options.SambaOptions(parser)
diff --git a/source4/setup/vampire.py b/source4/setup/vampire.py
deleted file mode 100755
index 728c53146a..0000000000
--- a/source4/setup/vampire.py
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/python
-
-# Unix SMB/CIFS implementation.
-# Vampire a remote domain
-# 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/>.
-#
-
-from net import libnet
-import optparse
-import samba.getopt as options
-import param
-from auth import system_session
-import sys
-
-parser = optparse.OptionParser("vampire [options] <domain>")
-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)
-
-opts, args = parser.parse_args()
-
-if len(args) < 1:
- parser.print_usage()
- sys.exit(1)
-
-def vampire(domain, session_info, credentials, lp):
- ctx = libnet(lp_ctx=lp)
- ctx.cred = credentials
- machine_creds = Credentials();
- machine_creds.set_domain(domain);
- if not machine_creds.set_machine_account():
- raise Exception("Failed to access domain join information!")
- ctx.samsync_ldb(vampire_ctx, machine_creds=machine_creds,
- session_info=session_info)
-
-lp = sambaopts.get_loadparm()
-vampire(args[0], session_info=system_session(),
- credentials=credopts.get_credentials(), lp=lp)
diff --git a/source4/smb_server/blob.c b/source4/smb_server/blob.c
index 8834c4483c..368b81d18e 100644
--- a/source4/smb_server/blob.c
+++ b/source4/smb_server/blob.c
@@ -476,12 +476,12 @@ NTSTATUS smbsrv_push_passthru_fileinfo(TALLOC_CTX *mem_ctx,
}
list_size = ea_list_size_chained(st->all_eas.out.num_eas,
- st->all_eas.out.eas);
+ st->all_eas.out.eas, 4);
BLOB_CHECK(smbsrv_blob_grow_data(mem_ctx, blob, list_size));
ea_put_list_chained(blob->data,
st->all_eas.out.num_eas,
- st->all_eas.out.eas);
+ st->all_eas.out.eas, 4);
return NT_STATUS_OK;
case RAW_FILEINFO_SMB2_ALL_INFORMATION:
@@ -503,7 +503,8 @@ NTSTATUS smbsrv_push_passthru_fileinfo(TALLOC_CTX *mem_ctx,
SIVAL(blob->data, 0x48, st->all_info2.out.ea_size);
SIVAL(blob->data, 0x4C, st->all_info2.out.access_mask);
SBVAL(blob->data, 0x50, st->all_info2.out.position);
- SBVAL(blob->data, 0x58, st->all_info2.out.mode);
+ SIVAL(blob->data, 0x58, st->all_info2.out.mode);
+ SIVAL(blob->data, 0x5C, st->all_info2.out.alignment_requirement);
BLOB_CHECK(smbsrv_blob_append_string(mem_ctx, blob,
st->all_info2.out.fname.s,
0x60, default_str_flags,
diff --git a/source4/smb_server/config.mk b/source4/smb_server/config.mk
index 85c969df59..e11968a100 100644
--- a/source4/smb_server/config.mk
+++ b/source4/smb_server/config.mk
@@ -2,21 +2,16 @@
#
[MODULE::SERVICE_SMB]
INIT_FUNCTION = server_service_smb_init
-SUBSYSTEM = service
-OBJ_FILES = smb_server.o
-PRIVATE_PROTO_HEADER = service_smb_proto.h
+SUBSYSTEM = smbd
PRIVATE_DEPENDENCIES = SMB_SERVER
+SERVICE_SMB_OBJ_FILES = $(smb_serversrcdir)/smb_server.o
+
+$(eval $(call proto_header_template,$(smb_serversrcdir)/service_smb_proto.h,$(SERVICE_SMB_OBJ_FILES:.o=.c)))
+
#######################
# Start SUBSYSTEM SMB
[SUBSYSTEM::SMB_SERVER]
-OBJ_FILES = \
- handle.o \
- tcon.o \
- session.o \
- blob.o \
- management.o
-PRIVATE_PROTO_HEADER = smb_server_proto.h
PUBLIC_DEPENDENCIES = \
share \
LIBPACKET \
@@ -25,5 +20,14 @@ PUBLIC_DEPENDENCIES = \
# End SUBSYSTEM SMB
#######################
+SMB_SERVER_OBJ_FILES = $(addprefix $(smb_serversrcdir)/, \
+ handle.o \
+ tcon.o \
+ session.o \
+ blob.o \
+ management.o)
+
+$(eval $(call proto_header_template,$(smb_serversrcdir)/smb_server_proto.h,$(SMB_SERVER_OBJ_FILES:.o=.c)))
+
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 7927f295b9..9adf334850 100644
--- a/source4/smb_server/smb/config.mk
+++ b/source4/smb_server/smb/config.mk
@@ -1,8 +1,12 @@
#######################
# Start SUBSYSTEM SMB_PROTOCOL
[SUBSYSTEM::SMB_PROTOCOL]
-PRIVATE_PROTO_HEADER = smb_proto.h
-OBJ_FILES = \
+PUBLIC_DEPENDENCIES = \
+ ntvfs LIBPACKET CREDENTIALS
+# End SUBSYSTEM SMB_PROTOCOL
+#######################
+
+SMB_PROTOCOL_OBJ_FILES = $(addprefix $(smb_serversrcdir)/smb/, \
receive.o \
negprot.o \
nttrans.o \
@@ -13,8 +17,6 @@ OBJ_FILES = \
sesssetup.o \
srvtime.o \
trans2.o \
- signing.o
-PUBLIC_DEPENDENCIES = \
- ntvfs LIBPACKET CREDENTIALS
-# End SUBSYSTEM SMB_PROTOCOL
-#######################
+ signing.o)
+
+$(eval $(call proto_header_template,$(smb_serversrcdir)/smb/smb_proto.h,$(SMB_PROTOCOL_OBJ_FILES:.o=.c)))
diff --git a/source4/smb_server/smb/receive.c b/source4/smb_server/smb/receive.c
index e3d247cbc0..0afa3a652d 100644
--- a/source4/smb_server/smb/receive.c
+++ b/source4/smb_server/smb/receive.c
@@ -65,111 +65,16 @@ NTSTATUS smbsrv_send_oplock_break(void *p, struct ntvfs_handle *ntvfs, uint8_t l
static void switch_message(int type, struct smbsrv_request *req);
-/****************************************************************************
-receive a SMB request header from the wire, forming a request_context
-from the result
-****************************************************************************/
-NTSTATUS smbsrv_recv_smb_request(void *private, DATA_BLOB blob)
-{
- struct smbsrv_connection *smb_conn = talloc_get_type(private, struct smbsrv_connection);
- struct smbsrv_request *req;
- struct timeval cur_time = timeval_current();
- uint8_t command;
-
- smb_conn->statistics.last_request_time = cur_time;
-
- /* see if its a special NBT packet */
- if (CVAL(blob.data, 0) != 0) {
- req = smbsrv_init_request(smb_conn);
- NT_STATUS_HAVE_NO_MEMORY(req);
-
- ZERO_STRUCT(req->in);
-
- req->in.buffer = talloc_steal(req, blob.data);
- req->in.size = blob.length;
- req->request_time = cur_time;
-
- smbsrv_reply_special(req);
- return NT_STATUS_OK;
- }
-
- if ((NBT_HDR_SIZE + MIN_SMB_SIZE) > blob.length) {
- DEBUG(2,("Invalid SMB packet: length %ld\n", (long)blob.length));
- smbsrv_terminate_connection(smb_conn, "Invalid SMB packet");
- return NT_STATUS_OK;
- }
-
- /* Make sure this is an SMB packet */
- if (IVAL(blob.data, NBT_HDR_SIZE) != SMB_MAGIC) {
- DEBUG(2,("Non-SMB packet of length %ld. Terminating connection\n",
- (long)blob.length));
- smbsrv_terminate_connection(smb_conn, "Non-SMB packet");
- return NT_STATUS_OK;
- }
-
- req = smbsrv_init_request(smb_conn);
- NT_STATUS_HAVE_NO_MEMORY(req);
-
- req->in.buffer = talloc_steal(req, blob.data);
- req->in.size = blob.length;
- req->request_time = cur_time;
- req->chained_fnum = -1;
- req->in.allocated = req->in.size;
- req->in.hdr = req->in.buffer + NBT_HDR_SIZE;
- req->in.vwv = req->in.hdr + HDR_VWV;
- req->in.wct = CVAL(req->in.hdr, HDR_WCT);
- if (req->in.vwv + VWV(req->in.wct) <= req->in.buffer + req->in.size) {
- req->in.data = req->in.vwv + VWV(req->in.wct) + 2;
- req->in.data_size = SVAL(req->in.vwv, VWV(req->in.wct));
-
- /* the bcc length is only 16 bits, but some packets
- (such as SMBwriteX) can be much larger than 64k. We
- detect this by looking for a large non-chained NBT
- packet (at least 64k bigger than what is
- specified). If it is detected then the NBT size is
- used instead of the bcc size */
- if (req->in.data_size + 0x10000 <=
- req->in.size - PTR_DIFF(req->in.data, req->in.buffer) &&
- (req->in.wct < 1 || SVAL(req->in.vwv, VWV(0)) == SMB_CHAIN_NONE)) {
- /* its an oversized packet! fun for all the family */
- req->in.data_size = req->in.size - PTR_DIFF(req->in.data,req->in.buffer);
- }
- }
-
- if (NBT_HDR_SIZE + MIN_SMB_SIZE + 2*req->in.wct > req->in.size) {
- DEBUG(2,("Invalid SMB word count %d\n", req->in.wct));
- smbsrv_terminate_connection(req->smb_conn, "Invalid SMB packet");
- return NT_STATUS_OK;
- }
-
- if (NBT_HDR_SIZE + MIN_SMB_SIZE + 2*req->in.wct + req->in.data_size > req->in.size) {
- DEBUG(2,("Invalid SMB buffer length count %d\n",
- (int)req->in.data_size));
- smbsrv_terminate_connection(req->smb_conn, "Invalid SMB packet");
- return NT_STATUS_OK;
- }
-
- 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;
- }
-
- command = CVAL(req->in.hdr, HDR_COM);
- switch_message(command, req);
- return NT_STATUS_OK;
-}
-
/*
These flags determine some of the permissions required to do an operation
*/
#define NEED_SESS (1<<0)
#define NEED_TCON (1<<1)
#define SIGNING_NO_REPLY (1<<2)
+/* does VWV(0) of the request hold chaining information */
+#define AND_X (1<<3)
+/* The 64Kb question: are requests > 64K valid? */
+#define LARGE_REQUEST (1<<4)
/*
define a list of possible SMB messages and their corresponding
@@ -180,6 +85,7 @@ static const struct smb_message_struct
{
const char *name;
void (*fn)(struct smbsrv_request *);
+#define message_flags(type) smb_messages[(type) & 0xff].flags
int flags;
}
smb_messages[256] = {
@@ -219,7 +125,7 @@ static const struct smb_message_struct
/* 0x21 */ { NULL, NULL, 0 },
/* 0x22 */ { "SMBsetattrE", smbsrv_reply_setattrE, NEED_SESS|NEED_TCON },
/* 0x23 */ { "SMBgetattrE", smbsrv_reply_getattrE, NEED_SESS|NEED_TCON },
-/* 0x24 */ { "SMBlockingX", smbsrv_reply_lockingX, NEED_SESS|NEED_TCON },
+/* 0x24 */ { "SMBlockingX", smbsrv_reply_lockingX, NEED_SESS|NEED_TCON|AND_X },
/* 0x25 */ { "SMBtrans", smbsrv_reply_trans, NEED_SESS|NEED_TCON },
/* 0x26 */ { "SMBtranss", smbsrv_reply_transs, NEED_SESS|NEED_TCON },
/* 0x27 */ { "SMBioctl", smbsrv_reply_ioctl, NEED_SESS|NEED_TCON },
@@ -228,9 +134,9 @@ static const struct smb_message_struct
/* 0x2a */ { "SMBmove", NULL, NEED_SESS|NEED_TCON },
/* 0x2b */ { "SMBecho", smbsrv_reply_echo, 0 },
/* 0x2c */ { "SMBwriteclose", smbsrv_reply_writeclose, NEED_SESS|NEED_TCON },
-/* 0x2d */ { "SMBopenX", smbsrv_reply_open_and_X, NEED_SESS|NEED_TCON },
-/* 0x2e */ { "SMBreadX", smbsrv_reply_read_and_X, NEED_SESS|NEED_TCON },
-/* 0x2f */ { "SMBwriteX", smbsrv_reply_write_and_X, NEED_SESS|NEED_TCON},
+/* 0x2d */ { "SMBopenX", smbsrv_reply_open_and_X, NEED_SESS|NEED_TCON|AND_X },
+/* 0x2e */ { "SMBreadX", smbsrv_reply_read_and_X, NEED_SESS|NEED_TCON|AND_X },
+/* 0x2f */ { "SMBwriteX", smbsrv_reply_write_and_X, NEED_SESS|NEED_TCON|AND_X|LARGE_REQUEST},
/* 0x30 */ { NULL, NULL, 0 },
/* 0x31 */ { NULL, NULL, 0 },
/* 0x32 */ { "SMBtrans2", smbsrv_reply_trans2, NEED_SESS|NEED_TCON },
@@ -298,9 +204,9 @@ static const struct smb_message_struct
/* 0x70 */ { "SMBtcon", smbsrv_reply_tcon, NEED_SESS },
/* 0x71 */ { "SMBtdis", smbsrv_reply_tdis, NEED_TCON },
/* 0x72 */ { "SMBnegprot", smbsrv_reply_negprot, 0 },
-/* 0x73 */ { "SMBsesssetupX", smbsrv_reply_sesssetup, 0 },
-/* 0x74 */ { "SMBulogoffX", smbsrv_reply_ulogoffX, NEED_SESS }, /* ulogoff doesn't give a valid TID */
-/* 0x75 */ { "SMBtconX", smbsrv_reply_tcon_and_X, NEED_SESS },
+/* 0x73 */ { "SMBsesssetupX", smbsrv_reply_sesssetup, AND_X },
+/* 0x74 */ { "SMBulogoffX", smbsrv_reply_ulogoffX, NEED_SESS|AND_X }, /* ulogoff doesn't give a valid TID */
+/* 0x75 */ { "SMBtconX", smbsrv_reply_tcon_and_X, NEED_SESS|AND_X },
/* 0x76 */ { NULL, NULL, 0 },
/* 0x77 */ { NULL, NULL, 0 },
/* 0x78 */ { NULL, NULL, 0 },
@@ -343,9 +249,9 @@ static const struct smb_message_struct
/* 0x9d */ { NULL, NULL, 0 },
/* 0x9e */ { NULL, NULL, 0 },
/* 0x9f */ { NULL, NULL, 0 },
-/* 0xa0 */ { "SMBnttrans", smbsrv_reply_nttrans, NEED_SESS|NEED_TCON },
+/* 0xa0 */ { "SMBnttrans", smbsrv_reply_nttrans, NEED_SESS|NEED_TCON|LARGE_REQUEST },
/* 0xa1 */ { "SMBnttranss", smbsrv_reply_nttranss, NEED_SESS|NEED_TCON },
-/* 0xa2 */ { "SMBntcreateX", smbsrv_reply_ntcreate_and_X, NEED_SESS|NEED_TCON },
+/* 0xa2 */ { "SMBntcreateX", smbsrv_reply_ntcreate_and_X, NEED_SESS|NEED_TCON|AND_X },
/* 0xa3 */ { NULL, NULL, 0 },
/* 0xa4 */ { "SMBntcancel", smbsrv_reply_ntcancel, NEED_SESS|NEED_TCON|SIGNING_NO_REPLY },
/* 0xa5 */ { "SMBntrename", smbsrv_reply_ntrename, NEED_SESS|NEED_TCON },
@@ -442,6 +348,111 @@ static const struct smb_message_struct
};
/****************************************************************************
+receive a SMB request header from the wire, forming a request_context
+from the result
+****************************************************************************/
+NTSTATUS smbsrv_recv_smb_request(void *private, DATA_BLOB blob)
+{
+ struct smbsrv_connection *smb_conn = talloc_get_type(private, struct smbsrv_connection);
+ struct smbsrv_request *req;
+ struct timeval cur_time = timeval_current();
+ uint8_t command;
+
+ smb_conn->statistics.last_request_time = cur_time;
+
+ /* see if its a special NBT packet */
+ if (CVAL(blob.data, 0) != 0) {
+ req = smbsrv_init_request(smb_conn);
+ NT_STATUS_HAVE_NO_MEMORY(req);
+
+ ZERO_STRUCT(req->in);
+
+ req->in.buffer = talloc_steal(req, blob.data);
+ req->in.size = blob.length;
+ req->request_time = cur_time;
+
+ smbsrv_reply_special(req);
+ return NT_STATUS_OK;
+ }
+
+ if ((NBT_HDR_SIZE + MIN_SMB_SIZE) > blob.length) {
+ DEBUG(2,("Invalid SMB packet: length %ld\n", (long)blob.length));
+ smbsrv_terminate_connection(smb_conn, "Invalid SMB packet");
+ return NT_STATUS_OK;
+ }
+
+ /* Make sure this is an SMB packet */
+ if (IVAL(blob.data, NBT_HDR_SIZE) != SMB_MAGIC) {
+ DEBUG(2,("Non-SMB packet of length %ld. Terminating connection\n",
+ (long)blob.length));
+ smbsrv_terminate_connection(smb_conn, "Non-SMB packet");
+ return NT_STATUS_OK;
+ }
+
+ req = smbsrv_init_request(smb_conn);
+ NT_STATUS_HAVE_NO_MEMORY(req);
+
+ req->in.buffer = talloc_steal(req, blob.data);
+ req->in.size = blob.length;
+ req->request_time = cur_time;
+ req->chained_fnum = -1;
+ req->in.allocated = req->in.size;
+ req->in.hdr = req->in.buffer + NBT_HDR_SIZE;
+ req->in.vwv = req->in.hdr + HDR_VWV;
+ req->in.wct = CVAL(req->in.hdr, HDR_WCT);
+
+ command = CVAL(req->in.hdr, HDR_COM);
+
+ if (req->in.vwv + VWV(req->in.wct) <= req->in.buffer + req->in.size) {
+ req->in.data = req->in.vwv + VWV(req->in.wct) + 2;
+ req->in.data_size = SVAL(req->in.vwv, VWV(req->in.wct));
+
+ /* the bcc length is only 16 bits, but some packets
+ (such as SMBwriteX) can be much larger than 64k. We
+ detect this by looking for a large non-chained NBT
+ packet (at least 64k bigger than what is
+ specified). If it is detected then the NBT size is
+ used instead of the bcc size */
+ if (req->in.data_size + 0x10000 <=
+ req->in.size - PTR_DIFF(req->in.data, req->in.buffer) &&
+ ( message_flags(command) & LARGE_REQUEST) &&
+ ( !(message_flags(command) & AND_X) ||
+ (req->in.wct < 1 || SVAL(req->in.vwv, VWV(0)) == SMB_CHAIN_NONE) )
+ ) {
+ /* its an oversized packet! fun for all the family */
+ req->in.data_size = req->in.size - PTR_DIFF(req->in.data,req->in.buffer);
+ }
+ }
+
+ if (NBT_HDR_SIZE + MIN_SMB_SIZE + 2*req->in.wct > req->in.size) {
+ DEBUG(2,("Invalid SMB word count %d\n", req->in.wct));
+ smbsrv_terminate_connection(req->smb_conn, "Invalid SMB packet");
+ return NT_STATUS_OK;
+ }
+
+ if (NBT_HDR_SIZE + MIN_SMB_SIZE + 2*req->in.wct + req->in.data_size > req->in.size) {
+ DEBUG(2,("Invalid SMB buffer length count %d\n",
+ (int)req->in.data_size));
+ smbsrv_terminate_connection(req->smb_conn, "Invalid SMB packet");
+ return NT_STATUS_OK;
+ }
+
+ 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;
+ }
+
+ command = CVAL(req->in.hdr, HDR_COM);
+ switch_message(command, req);
+ return NT_STATUS_OK;
+}
+
+/****************************************************************************
return a string containing the function name of a SMB command
****************************************************************************/
static const char *smb_fn_name(uint8_t type)
@@ -497,7 +508,8 @@ static void switch_message(int type, struct smbsrv_request *req)
}
}
- DEBUG(5,("switch message %s (task_id %d)\n",smb_fn_name(type), req->smb_conn->connection->server_id.id));
+ DEBUG(5,("switch message %s (task_id %u)\n",
+ smb_fn_name(type), (unsigned)req->smb_conn->connection->server_id.id));
/* this must be called before we do any reply */
if (flags & SIGNING_NO_REPLY) {
diff --git a/source4/smb_server/smb/request.c b/source4/smb_server/smb/request.c
index 87073517dd..c7fa2d7d8a 100644
--- a/source4/smb_server/smb/request.c
+++ b/source4/smb_server/smb/request.c
@@ -651,10 +651,10 @@ bool req_data_oob(struct request_bufinfo *bufinfo, const uint8_t *ptr, uint32_t
}
/* be careful with wraparound! */
- if (ptr < bufinfo->data ||
- ptr >= bufinfo->data + bufinfo->data_size ||
+ if ((uintptr_t)ptr < (uintptr_t)bufinfo->data ||
+ (uintptr_t)ptr >= (uintptr_t)bufinfo->data + bufinfo->data_size ||
count > bufinfo->data_size ||
- ptr + count > bufinfo->data + bufinfo->data_size) {
+ (uintptr_t)ptr + count > (uintptr_t)bufinfo->data + bufinfo->data_size) {
return true;
}
return false;
diff --git a/source4/smb_server/smb/sesssetup.c b/source4/smb_server/smb/sesssetup.c
index de2141b808..2c4068bda5 100644
--- a/source4/smb_server/smb/sesssetup.c
+++ b/source4/smb_server/smb/sesssetup.c
@@ -70,7 +70,7 @@ static void sesssetup_old_send(struct auth_check_password_request *areq,
if (!NT_STATUS_IS_OK(status)) goto failed;
/* This references server_info into session_info */
- status = auth_generate_session_info(req, req->smb_conn->lp_ctx,
+ status = auth_generate_session_info(req, req->smb_conn->connection->event.ctx, req->smb_conn->lp_ctx,
server_info, &session_info);
if (!NT_STATUS_IS_OK(status)) goto failed;
@@ -166,7 +166,8 @@ static void sesssetup_nt1_send(struct auth_check_password_request *areq,
if (!NT_STATUS_IS_OK(status)) goto failed;
/* This references server_info into session_info */
- status = auth_generate_session_info(req, req->smb_conn->lp_ctx,
+ status = auth_generate_session_info(req, req->smb_conn->connection->event.ctx,
+ req->smb_conn->lp_ctx,
server_info, &session_info);
if (!NT_STATUS_IS_OK(status)) goto failed;
diff --git a/source4/smb_server/smb2/config.mk b/source4/smb_server/smb2/config.mk
index d5ba43b3a8..68ee6e58f6 100644
--- a/source4/smb_server/smb2/config.mk
+++ b/source4/smb_server/smb2/config.mk
@@ -1,8 +1,12 @@
#######################
# Start SUBSYSTEM SMB2_PROTOCOL
[SUBSYSTEM::SMB2_PROTOCOL]
-PRIVATE_PROTO_HEADER = smb2_proto.h
-OBJ_FILES = \
+PUBLIC_DEPENDENCIES = \
+ ntvfs LIBPACKET LIBCLI_SMB2
+# End SUBSYSTEM SMB2_PROTOCOL
+#######################
+
+SMB2_PROTOCOL_OBJ_FILES = $(addprefix $(smb_serversrcdir)/smb2/, \
receive.o \
negprot.o \
sesssetup.o \
@@ -10,8 +14,6 @@ OBJ_FILES = \
fileio.o \
fileinfo.o \
find.o \
- keepalive.o
-PUBLIC_DEPENDENCIES = \
- ntvfs LIBPACKET LIBCLI_SMB2
-# End SUBSYSTEM SMB2_PROTOCOL
-#######################
+ keepalive.o)
+
+$(eval $(call proto_header_template,$(smb_serversrcdir)/smb2/smb2_proto.h,$(SMB2_PROTOCOL_OBJ_FILES:.o=.c)))
diff --git a/source4/smb_server/smb2/fileio.c b/source4/smb_server/smb2/fileio.c
index 0e3df56b42..5ab217bbfd 100644
--- a/source4/smb_server/smb2/fileio.c
+++ b/source4/smb_server/smb2/fileio.c
@@ -79,6 +79,7 @@ void smb2srv_create_recv(struct smb2srv_request *req)
SMB2SRV_CHECK(smb2_pull_o32s32_blob(&req->in, io, req->in.body+0x30, &blob));
/* TODO: parse the blob */
ZERO_STRUCT(io->smb2.in.eas);
+ ZERO_STRUCT(io->smb2.in.blobs);
/* the VFS backend does not yet handle NULL filenames */
if (io->smb2.in.fname == NULL) {
@@ -134,7 +135,7 @@ static void smb2srv_flush_send(struct ntvfs_request *ntvfs)
SMB2SRV_CHECK_ASYNC_STATUS(io, union smb_flush);
SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x04, false, 0));
- SSVAL(req->out.body, 0x02, 0);
+ SSVAL(req->out.body, 0x02, io->smb2.out.reserved);
smb2srv_send_reply(req);
}
@@ -142,15 +143,14 @@ static void smb2srv_flush_send(struct ntvfs_request *ntvfs)
void smb2srv_flush_recv(struct smb2srv_request *req)
{
union smb_flush *io;
- uint16_t _pad;
SMB2SRV_CHECK_BODY_SIZE(req, 0x18, false);
SMB2SRV_TALLOC_IO_PTR(io, union smb_flush);
SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_flush_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
io->smb2.level = RAW_FLUSH_SMB2;
- _pad = SVAL(req->in.body, 0x02);
- io->smb2.in.unknown = IVAL(req->in.body, 0x04);
+ io->smb2.in.reserved1 = SVAL(req->in.body, 0x02);
+ io->smb2.in.reserved2 = IVAL(req->in.body, 0x04);
io->smb2.in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x08);
SMB2SRV_CHECK_FILE_HANDLE(io->smb2.in.file.ntvfs);
@@ -167,7 +167,8 @@ static void smb2srv_read_send(struct ntvfs_request *ntvfs)
/* TODO: avoid the memcpy */
SMB2SRV_CHECK(smb2_push_o16s32_blob(&req->out, 0x02, io->smb2.out.data));
- SBVAL(req->out.body, 0x08, io->smb2.out.unknown1);
+ SIVAL(req->out.body, 0x08, io->smb2.out.remaining);
+ SIVAL(req->out.body, 0x0C, io->smb2.out.reserved);
smb2srv_send_reply(req);
}
@@ -185,8 +186,11 @@ void smb2srv_read_recv(struct smb2srv_request *req)
io->smb2.in.length = IVAL(req->in.body, 0x04);
io->smb2.in.offset = BVAL(req->in.body, 0x08);
io->smb2.in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x10);
- io->smb2.in.unknown1 = BVAL(req->in.body, 0x20);
- io->smb2.in.unknown2 = BVAL(req->in.body, 0x28);
+ io->smb2.in.min_count = IVAL(req->in.body, 0x20);
+ io->smb2.in.channel = IVAL(req->in.body, 0x24);
+ io->smb2.in.remaining = IVAL(req->in.body, 0x28);
+ io->smb2.in.channel_offset = SVAL(req->in.body, 0x2C);
+ io->smb2.in.channel_length = SVAL(req->in.body, 0x2E);
SMB2SRV_CHECK_FILE_HANDLE(io->smb2.in.file.ntvfs);
@@ -242,7 +246,7 @@ static void smb2srv_lock_send(struct ntvfs_request *ntvfs)
SMB2SRV_CHECK_ASYNC_STATUS_ERR(io, union smb_lock);
SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x04, false, 0));
- SSVAL(req->out.body, 0x02, io->smb2.out.unknown1);
+ SSVAL(req->out.body, 0x02, io->smb2.out.reserved);
smb2srv_send_reply(req);
}
@@ -250,20 +254,34 @@ static void smb2srv_lock_send(struct ntvfs_request *ntvfs)
void smb2srv_lock_recv(struct smb2srv_request *req)
{
union smb_lock *io;
+ int i;
SMB2SRV_CHECK_BODY_SIZE(req, 0x30, false);
SMB2SRV_TALLOC_IO_PTR(io, union smb_lock);
SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_lock_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
io->smb2.level = RAW_LOCK_SMB2;
-
- io->smb2.in.unknown1 = SVAL(req->in.body, 0x02);
- io->smb2.in.unknown2 = IVAL(req->in.body, 0x04);
+ io->smb2.in.lock_count = SVAL(req->in.body, 0x02);
+ io->smb2.in.reserved = IVAL(req->in.body, 0x04);
io->smb2.in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x08);
- io->smb2.in.offset = BVAL(req->in.body, 0x18);
- io->smb2.in.count = BVAL(req->in.body, 0x20);
- io->smb2.in.unknown5 = IVAL(req->in.body, 0x24);
- io->smb2.in.flags = IVAL(req->in.body, 0x28);
+ if (req->in.body_size < 24 + 24*(uint64_t)io->smb2.in.lock_count) {
+ DEBUG(0,("%s: lock buffer too small\n", __location__));
+ smb2srv_send_error(req, NT_STATUS_FOOBAR);
+ return;
+ }
+ io->smb2.in.locks = talloc_array(io, struct smb2_lock_element,
+ io->smb2.in.lock_count);
+ if (io->smb2.in.locks == NULL) {
+ smb2srv_send_error(req, NT_STATUS_NO_MEMORY);
+ return;
+ }
+
+ for (i=0;i<io->smb2.in.lock_count;i++) {
+ io->smb2.in.locks[i].offset = BVAL(req->in.body, 24 + i*24);
+ io->smb2.in.locks[i].length = BVAL(req->in.body, 32 + i*24);
+ io->smb2.in.locks[i].flags = IVAL(req->in.body, 40 + i*24);
+ io->smb2.in.locks[i].reserved = IVAL(req->in.body, 44 + i*24);
+ }
SMB2SRV_CHECK_FILE_HANDLE(io->smb2.in.file.ntvfs);
SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_lock(req->ntvfs, io));
@@ -405,7 +423,36 @@ void smb2srv_notify_recv(struct smb2srv_request *req)
SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_notify(req->ntvfs, io));
}
+static void smb2srv_break_send(struct ntvfs_request *ntvfs)
+{
+ struct smb2srv_request *req;
+ union smb_lock *io;
+
+ SMB2SRV_CHECK_ASYNC_STATUS_ERR(io, union smb_lock);
+ SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x18, false, 0));
+
+ SCVAL(req->out.body, 0x02, io->smb2_break.out.oplock_level);
+ SCVAL(req->out.body, 0x03, io->smb2_break.out.reserved);
+ SIVAL(req->out.body, 0x04, io->smb2_break.out.reserved2);
+ smb2srv_push_handle(req->out.body, 0x08,io->smb2_break.out.file.ntvfs);
+
+ smb2srv_send_reply(req);
+}
+
void smb2srv_break_recv(struct smb2srv_request *req)
{
- smb2srv_send_error(req, NT_STATUS_NOT_IMPLEMENTED);
+ union smb_lock *io;
+
+ SMB2SRV_CHECK_BODY_SIZE(req, 0x18, false);
+ SMB2SRV_TALLOC_IO_PTR(io, union smb_lock);
+ SMB2SRV_SETUP_NTVFS_REQUEST(smb2srv_break_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
+
+ io->smb2_break.level = RAW_LOCK_SMB2_BREAK;
+ io->smb2_break.in.oplock_level = CVAL(req->in.body, 0x02);
+ io->smb2_break.in.reserved = CVAL(req->in.body, 0x03);
+ io->smb2_break.in.reserved2 = IVAL(req->in.body, 0x04);
+ io->smb2_break.in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x08);
+
+ SMB2SRV_CHECK_FILE_HANDLE(io->smb2_break.in.file.ntvfs);
+ SMB2SRV_CALL_NTVFS_BACKEND(ntvfs_lock(req->ntvfs, io));
}
diff --git a/source4/smb_server/smb2/find.c b/source4/smb_server/smb2/find.c
index 6018f1958f..32b280c5c2 100644
--- a/source4/smb_server/smb2/find.c
+++ b/source4/smb_server/smb2/find.c
@@ -112,7 +112,7 @@ static NTSTATUS smb2srv_find_backend(struct smb2srv_find_state *state)
return NT_STATUS_FOOBAR;
}
- if (info->in.continue_flags & SMB2_CONTINUE_FLAG_NEW) {
+ if (info->in.continue_flags & SMB2_CONTINUE_FLAG_REOPEN) {
state->ff = talloc(state, union smb_search_first);
NT_STATUS_HAVE_NO_MEMORY(state->ff);
@@ -156,7 +156,7 @@ void smb2srv_find_recv(struct smb2srv_request *req)
info->data_level = RAW_SEARCH_DATA_GENERIC;/* will be overwritten later */
info->in.level = CVAL(req->in.body, 0x02);
info->in.continue_flags = CVAL(req->in.body, 0x03);
- info->in.unknown = IVAL(req->in.body, 0x04);
+ info->in.file_index = IVAL(req->in.body, 0x04);
info->in.file.ntvfs = smb2srv_pull_handle(req, req->in.body, 0x08);
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);
diff --git a/source4/smb_server/smb2/negprot.c b/source4/smb_server/smb2/negprot.c
index e7352f7c42..4479ae2da1 100644
--- a/source4/smb_server/smb2/negprot.c
+++ b/source4/smb_server/smb2/negprot.c
@@ -114,9 +114,12 @@ static NTSTATUS smb2srv_negprot_backend(struct smb2srv_request *req, struct smb2
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.max_transact_size = lp_parm_ulong(req->smb_conn->lp_ctx, NULL,
+ "smb2", "max transaction size", 0x10000);
+ io->out.max_read_size = lp_parm_ulong(req->smb_conn->lp_ctx, NULL,
+ "smb2", "max read size", 0x10000);
+ io->out.max_write_size = lp_parm_ulong(req->smb_conn->lp_ctx, NULL,
+ "smb2", "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;
diff --git a/source4/smb_server/smb2/smb2_server.h b/source4/smb_server/smb2/smb2_server.h
index 2f347d3876..ae4abbd71e 100644
--- a/source4/smb_server/smb2/smb2_server.h
+++ b/source4/smb_server/smb2/smb2_server.h
@@ -70,7 +70,7 @@ struct smbsrv_request;
#include "smb_server/smb2/smb2_proto.h"
-/* useful way of catching wct errors with file and line number */
+/* useful way of catching field size errors with file and line number */
#define SMB2SRV_CHECK_BODY_SIZE(req, size, dynamic) do { \
size_t is_size = req->in.body_size; \
uint16_t field_size = SVAL(req->in.body, 0); \
@@ -78,13 +78,13 @@ struct smbsrv_request;
if (is_size < (size)) { \
DEBUG(0,("%s: buffer too small 0x%x. Expected 0x%x\n", \
__location__, (unsigned)is_size, (unsigned)want_size)); \
- smb2srv_send_error(req, NT_STATUS_FOOBAR); \
+ smb2srv_send_error(req, NT_STATUS_INVALID_PARAMETER); \
return; \
}\
if (field_size != want_size) { \
DEBUG(0,("%s: unexpected fixed body size 0x%x. Expected 0x%x\n", \
__location__, (unsigned)field_size, (unsigned)want_size)); \
- smb2srv_send_error(req, NT_STATUS_FOOBAR); \
+ smb2srv_send_error(req, NT_STATUS_INVALID_PARAMETER); \
return; \
} \
} while (0)
diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c
index 4f8e628f74..367557dbb7 100644
--- a/source4/smb_server/smb_server.c
+++ b/source4/smb_server/smb_server.c
@@ -157,6 +157,7 @@ static void smbsrv_accept(struct stream_connection *conn)
smbsrv_management_init(smb_conn);
if (!NT_STATUS_IS_OK(share_get_context_by_name(smb_conn, lp_share_backend(smb_conn->lp_ctx),
+ smb_conn->connection->event.ctx,
smb_conn->lp_ctx, &(smb_conn->share_context)))) {
smbsrv_terminate_connection(smb_conn, "share_init failed!");
return;
@@ -206,7 +207,7 @@ static void smbsrv_preopen_ldb(struct task_server *task)
/* yes, this looks strange. It is a hack to preload the
schema. I'd like to share most of the ldb context with the
child too. That will come later */
- talloc_free(samdb_connect(task, task->lp_ctx, NULL));
+ talloc_free(samdb_connect(task, task->event_ctx, task->lp_ctx, NULL));
}
/*
diff --git a/source4/smbd/config.mk b/source4/smbd/config.mk
index 6cbfa16045..e60f444456 100644
--- a/source4/smbd/config.mk
+++ b/source4/smbd/config.mk
@@ -1,34 +1,26 @@
# server subsystem
-################################################
-# Start MODULE service_auth
-[MODULE::service_auth]
-INIT_FUNCTION = server_service_auth_init
-SUBSYSTEM = service
+[SUBSYSTEM::service]
PRIVATE_DEPENDENCIES = \
- auth
-# End MODULE server_auth
-################################################
+ MESSAGING samba-socket
-[SUBSYSTEM::service]
-PRIVATE_PROTO_HEADER = service_proto.h
-OBJ_FILES = \
+service_OBJ_FILES = $(addprefix $(smbdsrcdir)/, \
service.o \
service_stream.o \
- service_task.o
-PRIVATE_DEPENDENCIES = \
- MESSAGING samba-socket
+ service_task.o)
+
+$(eval $(call proto_header_template,$(smbdsrcdir)/service_proto.h,$(service_OBJ_FILES:.o=.c)))
[SUBSYSTEM::PIDFILE]
-OBJ_FILES = pidfile.o
-PRIVATE_PROTO_HEADER = pidfile.h
+
+PIDFILE_OBJ_FILES = $(smbdsrcdir)/pidfile.o
+
+$(eval $(call proto_header_template,$(smbdsrcdir)/pidfile.h,$(PIDFILE_OBJ_FILES:.o=.c)))
#################################
# Start BINARY smbd
[BINARY::smbd]
INSTALLDIR = SBINDIR
-OBJ_FILES = \
- server.o
PRIVATE_DEPENDENCIES = \
process_model \
service \
@@ -44,6 +36,8 @@ PRIVATE_DEPENDENCIES = \
share \
CLUSTER
-MANPAGES += smbd/smbd.8
+smbd_OBJ_FILES = $(smbdsrcdir)/server.o
+
+MANPAGES += $(smbdsrcdir)/smbd.8
# End BINARY smbd
#################################
diff --git a/source4/smbd/process_model.c b/source4/smbd/process_model.c
index fcbe2d9872..e631975b37 100644
--- a/source4/smbd/process_model.c
+++ b/source4/smbd/process_model.c
@@ -20,7 +20,6 @@
#include "includes.h"
#include "smbd/process_model.h"
-#include "build.h"
#include "param/param.h"
/*
@@ -82,6 +81,9 @@ _PUBLIC_ NTSTATUS register_process_model(const void *_ops)
_PUBLIC_ NTSTATUS process_model_init(struct loadparm_context *lp_ctx)
{
+ extern NTSTATUS process_model_standard_init(void);
+ extern NTSTATUS process_model_prefork_init(void);
+ extern NTSTATUS process_model_single_init(void);
init_module_fn static_init[] = { STATIC_process_model_MODULES };
init_module_fn *shared_init = load_samba_modules(NULL, lp_ctx, "process_model");
diff --git a/source4/smbd/process_model.mk b/source4/smbd/process_model.mk
index d559ce1577..5ed8471a9d 100644
--- a/source4/smbd/process_model.mk
+++ b/source4/smbd/process_model.mk
@@ -5,45 +5,46 @@
[MODULE::process_model_single]
INIT_FUNCTION = process_model_single_init
SUBSYSTEM = process_model
-OBJ_FILES = \
- process_single.o
# End MODULE process_model_single
################################################
+process_model_single_OBJ_FILES = $(smbdsrcdir)/process_single.o
+
################################################
# Start MODULE process_model_standard
[MODULE::process_model_standard]
INIT_FUNCTION = process_model_standard_init
SUBSYSTEM = process_model
-OBJ_FILES = \
- process_standard.o
PRIVATE_DEPENDENCIES = SETPROCTITLE
# End MODULE process_model_standard
################################################
+process_model_standard_OBJ_FILES = $(smbdsrcdir)/process_standard.o
+
################################################
# Start MODULE process_model_thread
[MODULE::process_model_thread]
INIT_FUNCTION = process_model_thread_init
SUBSYSTEM = process_model
-OBJ_FILES = \
- process_thread.o
PRIVATE_DEPENDENCIES = PTHREAD
# End MODULE process_model_thread
################################################
+process_model_thread_OBJ_FILES = $(smbdsrcdir)/process_thread.o
+
################################################
# Start MODULE process_model_prefork
[MODULE::process_model_prefork]
INIT_FUNCTION = process_model_prefork_init
SUBSYSTEM = process_model
-OBJ_FILES = \
- process_prefork.o
# End MODULE process_model_thread
################################################
+process_model_prefork_OBJ_FILES = $(smbdsrcdir)/process_prefork.o
+
[SUBSYSTEM::process_model]
-PRIVATE_PROTO_HEADER = process_model_proto.h
-OBJ_FILES = \
- process_model.o
PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBSAMBA-HOSTCONFIG
+
+process_model_OBJ_FILES = $(smbdsrcdir)/process_model.o
+
+$(eval $(call proto_header_template,$(smbdsrcdir)/process_model_proto.h,$(process_model_OBJ_FILES:.o=.c)))
diff --git a/source4/smbd/server.c b/source4/smbd/server.c
index d6e2fb19e4..e1ebd133ce 100644
--- a/source4/smbd/server.c
+++ b/source4/smbd/server.c
@@ -28,7 +28,6 @@
#include "lib/cmdline/popt_common.h"
#include "system/dir.h"
#include "system/filesys.h"
-#include "build.h"
#include "ldb/include/ldb.h"
#include "registry/registry.h"
#include "ntvfs/ntvfs.h"
@@ -187,7 +186,19 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
bool opt_interactive = false;
int opt;
poptContext pc;
- init_module_fn static_init[] = { STATIC_service_MODULES };
+ extern NTSTATUS server_service_wrepl_init(void);
+ extern NTSTATUS server_service_kdc_init(void);
+ extern NTSTATUS server_service_ldap_init(void);
+ extern NTSTATUS server_service_web_init(void);
+ extern NTSTATUS server_service_ldap_init(void);
+ extern NTSTATUS server_service_winbind_init(void);
+ extern NTSTATUS server_service_nbtd_init(void);
+ extern NTSTATUS server_service_auth_init(void);
+ extern NTSTATUS server_service_cldapd_init(void);
+ extern NTSTATUS server_service_smb_init(void);
+ extern NTSTATUS server_service_drepl_init(void);
+ extern NTSTATUS server_service_rpc_init(void);
+ init_module_fn static_init[] = { STATIC_smbd_MODULES };
init_module_fn *shared_init;
struct event_context *event_ctx;
NTSTATUS status;
diff --git a/source4/smbd/service_stream.c b/source4/smbd/service_stream.c
index 9f744efa81..e27d87ec75 100644
--- a/source4/smbd/service_stream.c
+++ b/source4/smbd/service_stream.c
@@ -119,6 +119,7 @@ void stream_io_handler_callback(void *private, uint16_t flags)
a server connection
*/
NTSTATUS stream_new_connection_merge(struct event_context *ev,
+ struct loadparm_context *lp_ctx,
const struct model_ops *model_ops,
struct socket_context *sock,
const struct stream_server_ops *stream_ops,
@@ -140,6 +141,7 @@ NTSTATUS stream_new_connection_merge(struct event_context *ev,
srv_conn->ops = stream_ops;
srv_conn->msg_ctx = msg_ctx;
srv_conn->event.ctx = ev;
+ srv_conn->lp_ctx = lp_ctx;
srv_conn->event.fde = event_add_fd(ev, srv_conn, socket_get_fd(sock),
EVENT_FD_READ,
stream_io_handler_fde, srv_conn);
diff --git a/source4/smbd/service_stream.h b/source4/smbd/service_stream.h
index 04d23a56f2..d57a54cdc9 100644
--- a/source4/smbd/service_stream.h
+++ b/source4/smbd/service_stream.h
@@ -50,6 +50,12 @@ struct stream_connection {
struct messaging_context *msg_ctx;
struct loadparm_context *lp_ctx;
+ /*
+ * this transport layer session info, normally NULL
+ * which means the same as an anonymous session info
+ */
+ struct auth_session_info *session_info;
+
bool processing;
const char *terminate;
};
diff --git a/source4/static_deps.mk b/source4/static_deps.mk
index ade41614c2..7eb8fa10fe 100644
--- a/source4/static_deps.mk
+++ b/source4/static_deps.mk
@@ -11,7 +11,6 @@ lib/charset/charset.h: lib/charset/charset_proto.h
include/includes.h: \
include/config.h \
lib/charset/charset.h \
- param/proto.h \
librpc/gen_ndr/misc.h
heimdal_basics: \
@@ -39,8 +38,5 @@ heimdal_basics: \
heimdal/lib/hx509/hx509_err.h \
heimdal/lib/wind/wind_err.h
-proto: basics
-basics: include/includes.h \
- idl \
- $(PROTO_HEADERS) \
- heimdal_basics
+proto::
+basics:: include/includes.h idl proto heimdal_basics
diff --git a/source4/torture/auth/ntlmssp.c b/source4/torture/auth/ntlmssp.c
index 9366de986a..739a048d29 100644
--- a/source4/torture/auth/ntlmssp.c
+++ b/source4/torture/auth/ntlmssp.c
@@ -33,7 +33,8 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
TALLOC_CTX *mem_ctx = tctx;
torture_assert_ntstatus_ok(tctx,
- gensec_client_start(mem_ctx, &gensec_security, NULL, tctx->lp_ctx),
+ gensec_client_start(mem_ctx, &gensec_security,
+ tctx->ev, tctx->lp_ctx),
"gensec client start");
gensec_set_credentials(gensec_security, cmdline_credentials);
@@ -69,7 +70,7 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
torture_assert_int_equal(tctx, sig.length, expected_sig.length, "Wrong sig length");
- torture_assert(tctx, 0 == memcmp(sig.data, expected_sig.data, sig.length),
+ torture_assert_mem_equal(tctx, sig.data, expected_sig.data, sig.length,
"data mismatch");
torture_assert_ntstatus_equal(tctx,
@@ -87,7 +88,8 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
talloc_free(gensec_security);
torture_assert_ntstatus_ok(tctx,
- gensec_client_start(mem_ctx, &gensec_security, NULL, tctx->lp_ctx),
+ gensec_client_start(mem_ctx, &gensec_security,
+ tctx->ev, tctx->lp_ctx),
"Failed to start GENSEC for NTLMSSP");
gensec_set_credentials(gensec_security, cmdline_credentials);
@@ -123,7 +125,7 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx)
torture_assert_int_equal(tctx, sig.length, expected_sig.length, "Wrong sig length");
- torture_assert(tctx, 0 == memcmp(sig.data+8, expected_sig.data+8, sig.length-8),
+ torture_assert_mem_equal(tctx, sig.data+8, expected_sig.data+8, sig.length-8,
"data mismatch");
torture_assert_ntstatus_equal(tctx,
diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index ac71d14116..2ab3f9ca91 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -19,7 +19,7 @@
*/
#include "includes.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "torture/basic/proto.h"
#include "libcli/libcli.h"
#include "libcli/raw/raw_proto.h"
@@ -55,7 +55,8 @@ static struct smbcli_state *open_nbt_connection(struct torture_context *tctx)
lp_smbcli_options(tctx->lp_ctx, &options);
- if (!smbcli_socket_connect(cli, host, lp_smb_ports(tctx->lp_ctx), lp_resolve_context(tctx->lp_ctx), &options)) {
+ if (!smbcli_socket_connect(cli, host, lp_smb_ports(tctx->lp_ctx), tctx->ev,
+ lp_resolve_context(tctx->lp_ctx), &options)) {
torture_comment(tctx, "Failed to connect with %s\n", host);
goto failed;
}
@@ -590,7 +591,7 @@ static bool rw_torture2(struct torture_context *tctx,
break;
}
- torture_assert(tctx, memcmp(buf_rd, buf, buf_size) == 0,
+ torture_assert_mem_equal(tctx, buf_rd, buf, buf_size,
"read/write compare failed\n");
}
diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c
index e3d63c09ec..84adfef61a 100644
--- a/source4/torture/basic/delaywrite.c
+++ b/source4/torture/basic/delaywrite.c
@@ -40,7 +40,12 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
int fnum1 = -1;
bool ret = true;
ssize_t written;
- time_t t;
+ struct timeval start;
+ struct timeval end;
+ int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
+ int normal_delay = 2000000;
+ double sec = ((double)used_delay) / ((double)normal_delay);
+ int msec = 1000 * sec;
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
@@ -68,7 +73,7 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
/* 3 second delay to ensure we get past any 2 second time
granularity (older systems may have that) */
- sleep(3);
+ msleep(3 * msec);
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
@@ -78,9 +83,9 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
return false;
}
- t = time(NULL);
-
- while (time(NULL) < t+120) {
+ start = timeval_current();
+ end = timeval_add(&start, (120*sec), 0);
+ while (!timeval_expired(&end)) {
status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
if (!NT_STATUS_IS_OK(status)) {
@@ -91,20 +96,22 @@ static bool test_delayed_write_update(struct torture_context *tctx, struct smbcl
torture_comment(tctx, "write time %s\n",
nt_time_string(tctx, finfo2.basic_info.out.write_time));
if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
- int diff = time(NULL) - t;
- if (diff < 2) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- diff);
+ double diff = timeval_elapsed(&start);
+ if (diff < (2 * sec * 0.75)) { /* 0.75 to cope with vmware timing */
+ torture_comment(tctx, "Server updated write_time after %.2f seconds"
+ "(1 sec == %.2f)(wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- torture_comment(tctx, "Server updated write_time after %d seconds (correct)\n",
- diff);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds"
+ "(1 sec == %.2f)(correct)\n",
+ diff, sec);
break;
}
- sleep(1);
fflush(stdout);
+ msleep(1 * msec);
}
if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
@@ -135,7 +142,12 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
int fnum2 = -1;
bool ret = true;
ssize_t written;
- time_t t;
+ struct timeval start;
+ struct timeval end;
+ int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
+ int normal_delay = 2000000;
+ double sec = ((double)used_delay) / ((double)normal_delay);
+ int msec = 1000 * sec;
union smb_flush flsh;
if (!torture_setup_dir(cli, BASEDIR)) {
@@ -164,7 +176,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
/* 3 second delay to ensure we get past any 2 second time
granularity (older systems may have that) */
- sleep(3);
+ msleep(3 * msec);
{
/* Try using setfileinfo instead of write to update write time. */
@@ -251,12 +263,11 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
return false;
}
- t = time(NULL);
-
/* Once the time was set using setfileinfo then it stays set - writes
don't have any effect. But make sure. */
-
- while (time(NULL) < t+15) {
+ start = timeval_current();
+ end = timeval_add(&start, (15*sec), 0);
+ while (!timeval_expired(&end)) {
status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
if (!NT_STATUS_IS_OK(status)) {
@@ -267,13 +278,15 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
torture_comment(tctx, "write time %s\n",
nt_time_string(tctx, finfo2.basic_info.out.write_time));
if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- (int)(time(NULL) - t));
+ double diff = timeval_elapsed(&start);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds"
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- sleep(1);
fflush(stdout);
+ msleep(1 * msec);
}
if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
@@ -339,12 +352,11 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
ret = false;
}
- t = time(NULL);
-
/* Once the time was set using setfileinfo then it stays set - writes
don't have any effect. But make sure. */
-
- while (time(NULL) < t+15) {
+ start = timeval_current();
+ end = timeval_add(&start, (15*sec), 0);
+ while (!timeval_expired(&end)) {
status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
if (!NT_STATUS_IS_OK(status)) {
@@ -355,13 +367,15 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
torture_comment(tctx, "write time %s\n",
nt_time_string(tctx, finfo2.basic_info.out.write_time));
if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- (int)(time(NULL) - t));
+ double diff = timeval_elapsed(&start);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- sleep(1);
fflush(stdout);
+ msleep(1 * msec);
}
if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
@@ -393,7 +407,7 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
torture_comment(tctx, "Second open initial write time %s\n",
nt_time_string(tctx, finfo1.basic_info.out.write_time));
- sleep(10);
+ msleep(10 * msec);
torture_comment(tctx, "Doing a 10 byte write to extend the file to see if this changes the last write time.\n");
written = smbcli_write(cli->tree, fnum1, 0, "0123456789", 31, 10);
@@ -420,11 +434,10 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
ret = false;
}
- t = time(NULL);
-
/* Now the write time should be updated again */
-
- while (time(NULL) < t+15) {
+ start = timeval_current();
+ end = timeval_add(&start, (15*sec), 0);
+ while (!timeval_expired(&end)) {
status = smb_raw_fileinfo(cli->tree, tctx, &finfo2);
if (!NT_STATUS_IS_OK(status)) {
@@ -435,20 +448,22 @@ static bool test_delayed_write_update2(struct torture_context *tctx, struct smbc
torture_comment(tctx, "write time %s\n",
nt_time_string(tctx, finfo2.basic_info.out.write_time));
if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) {
- int diff = time(NULL) - t;
- if (diff < 2) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- diff);
+ double diff = timeval_elapsed(&start);
+ if (diff < (2 * sec * 0.75)) { /* 0.75 to cope with vmware timing */
+ torture_comment(tctx, "Server updated write_time after %.2f seconds"
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- torture_comment(tctx, "Server updated write_time after %d seconds (correct)\n",
- diff);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds"
+ "(1sec == %.2f) (correct)\n",
+ diff, sec);
break;
}
- sleep(1);
fflush(stdout);
+ msleep(1*msec);
}
if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) {
@@ -490,6 +505,10 @@ static bool test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
int fnum2;
bool ret = true;
ssize_t written;
+ int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
+ int normal_delay = 2000000;
+ double sec = ((double)used_delay) / ((double)normal_delay);
+ int msec = 1000 * sec;
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
@@ -513,7 +532,7 @@ static bool test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
goto done;
}
- msleep(1000);
+ msleep(1 * msec);
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
@@ -613,12 +632,23 @@ static bool test_finfo_after_write(struct torture_context *tctx, struct smbcli_s
}
#define COMPARE_WRITE_TIME_CMP(given, correct, cmp) do { \
+ uint64_t r = 10*1000*1000; \
NTTIME g = (given).basic_info.out.write_time; \
+ NTTIME gr = (g / r) * r; \
NTTIME c = (correct).basic_info.out.write_time; \
- if (g cmp c) { \
- torture_result(tctx, TORTURE_FAIL, __location__": wrong write_time (%s)%s %s (%s)%s", \
- #given, nt_time_string(tctx, g), \
- #cmp, #correct, nt_time_string(tctx, c)); \
+ NTTIME cr = (c / r) * r; \
+ bool strict = torture_setting_bool(tctx, "strict mode", false); \
+ bool err = false; \
+ if (strict && (g cmp c)) { \
+ err = true; \
+ } else if (gr cmp cr) { \
+ /* handle filesystem without high resolution timestamps */ \
+ err = true; \
+ } \
+ if (err) { \
+ torture_result(tctx, TORTURE_FAIL, __location__": wrong write_time (%s)%s(%llu) %s (%s)%s(%llu)", \
+ #given, nt_time_string(tctx, g), (unsigned long long)g, \
+ #cmp, #correct, nt_time_string(tctx, c), (unsigned long long)c); \
ret = false; \
goto done; \
} \
@@ -724,7 +754,12 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
int fnum1 = -1;
bool ret = true;
ssize_t written;
- time_t t;
+ struct timeval start;
+ struct timeval end;
+ int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
+ int normal_delay = 2000000;
+ double sec = ((double)used_delay) / ((double)normal_delay);
+ int msec = 1000 * sec;
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
@@ -760,8 +795,9 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
* calcuated from the first write
* (but expect upto 5 seconds extra time for a busy server)
*/
- t = time(NULL);
- while (time(NULL) < t+7) {
+ start = timeval_current();
+ end = timeval_add(&start, 7 * sec, 0);
+ while (!timeval_expired(&end)) {
/* do a write */
torture_comment(tctx, "Do a write on the file handle\n");
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
@@ -774,26 +810,29 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
GET_INFO_FILE(finfo1);
if (finfo1.basic_info.out.write_time > finfo0.basic_info.out.write_time) {
- int diff = time(NULL) - t;
- if (diff < 2) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- diff);
+ double diff = timeval_elapsed(&start);
+ if (diff < (2 * sec * 0.75)) { /* 0.75 to cope with vmware timing */
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- torture_comment(tctx, "Server updated write_time after %d seconds (correct)\n",
- diff);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (correct)\n",
+ diff, sec);
break;
}
- msleep(500);
+ msleep(0.5 * msec);
}
GET_INFO_BOTH(finfo1,pinfo1);
/* sure any further write doesn't update the write time */
- t = time(NULL);
- while (time(NULL) < t+15) {
+ start = timeval_current();
+ end = timeval_add(&start, 15 * sec, 0);
+ while (!timeval_expired(&end)) {
/* do a write */
torture_comment(tctx, "Do a write on the file handle\n");
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
@@ -806,12 +845,14 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
GET_INFO_BOTH(finfo2,pinfo2);
if (finfo2.basic_info.out.write_time > finfo1.basic_info.out.write_time) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- (int)(time(NULL) - t));
+ double diff = timeval_elapsed(&start);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- msleep(2000);
+ msleep(2 * msec);
}
GET_INFO_BOTH(finfo2,pinfo2);
@@ -821,7 +862,7 @@ static bool test_delayed_write_update3(struct torture_context *tctx,
}
/* sleep */
- msleep(5000);
+ msleep(5 * msec);
GET_INFO_BOTH(finfo3,pinfo3);
COMPARE_WRITE_TIME_EQUAL(finfo3, finfo2);
@@ -860,7 +901,12 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
int fnum1 = -1;
bool ret = true;
ssize_t written;
- time_t t;
+ struct timeval start;
+ struct timeval end;
+ int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
+ int normal_delay = 2000000;
+ double sec = ((double)used_delay) / ((double)normal_delay);
+ int msec = 1000 * sec;
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
@@ -892,7 +938,7 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
GET_INFO_BOTH(finfo0,pinfo0);
/* sleep a bit */
- msleep(5000);
+ msleep(5 * msec);
/* do a write */
torture_comment(tctx, "Do a write on the file handle\n");
@@ -911,32 +957,36 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
* calcuated from the first write
* (but expect upto 3 seconds extra time for a busy server)
*/
- t = time(NULL);
- while (time(NULL) < t+5) {
+ start = timeval_current();
+ end = timeval_add(&start, 5 * sec, 0);
+ while (!timeval_expired(&end)) {
/* get the times after the first write */
GET_INFO_FILE(finfo1);
if (finfo1.basic_info.out.write_time > finfo0.basic_info.out.write_time) {
- int diff = time(NULL) - t;
- if (diff < 2) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- diff);
+ double diff = timeval_elapsed(&start);
+ if (diff < (2 * sec * 0.75)) { /* 0.75 to cope with vmware timing */
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- torture_comment(tctx, "Server updated write_time after %d seconds (correct)\n",
- diff);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (correct)\n",
+ diff, sec);
break;
}
- msleep(500);
+ msleep(0.5 * msec);
}
GET_INFO_BOTH(finfo1,pinfo1);
/* sure any further write doesn't update the write time */
- t = time(NULL);
- while (time(NULL) < t+15) {
+ start = timeval_current();
+ end = timeval_add(&start, 15 * sec, 0);
+ while (!timeval_expired(&end)) {
/* do a write */
torture_comment(tctx, "Do a write on the file handle\n");
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
@@ -949,12 +999,14 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
GET_INFO_BOTH(finfo2,pinfo2);
if (finfo2.basic_info.out.write_time > finfo1.basic_info.out.write_time) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- (int)(time(NULL) - t));
+ double diff = timeval_elapsed(&start);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- msleep(2000);
+ msleep(2 * msec);
}
GET_INFO_BOTH(finfo2,pinfo2);
@@ -964,7 +1016,7 @@ static bool test_delayed_write_update4(struct torture_context *tctx,
}
/* sleep */
- msleep(5000);
+ msleep(5 * msec);
GET_INFO_BOTH(finfo3,pinfo3);
COMPARE_WRITE_TIME_EQUAL(finfo3, finfo2);
@@ -1003,7 +1055,12 @@ static bool test_delayed_write_update5(struct torture_context *tctx,
int fnum1 = -1;
bool ret = true;
ssize_t written;
- time_t t;
+ struct timeval start;
+ struct timeval end;
+ int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
+ int normal_delay = 2000000;
+ double sec = ((double)used_delay) / ((double)normal_delay);
+ int msec = 1000 * sec;
if (!torture_setup_dir(cli, BASEDIR)) {
return false;
@@ -1059,19 +1116,22 @@ static bool test_delayed_write_update5(struct torture_context *tctx,
COMPARE_WRITE_TIME_LESS(finfo2, finfo1);
/* make sure the 2 second delay from the first write are canceled */
- t = time(NULL);
- while (time(NULL) < t+15) {
+ start = timeval_current();
+ end = timeval_add(&start, 15 * sec, 0);
+ while (!timeval_expired(&end)) {
/* get the times after the first write */
GET_INFO_BOTH(finfo3,pinfo3);
if (finfo3.basic_info.out.write_time > finfo2.basic_info.out.write_time) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- (int)(time(NULL) - t));
+ double diff = timeval_elapsed(&start);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- msleep(2000);
+ msleep(2 * msec);
}
GET_INFO_BOTH(finfo3,pinfo3);
@@ -1081,8 +1141,9 @@ static bool test_delayed_write_update5(struct torture_context *tctx,
}
/* sure any further write doesn't update the write time */
- t = time(NULL);
- while (time(NULL) < t+15) {
+ start = timeval_current();
+ end = timeval_add(&start, 15 * sec, 0);
+ while (!timeval_expired(&end)) {
/* do a write */
torture_comment(tctx, "Do a write on the file handle\n");
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
@@ -1095,12 +1156,14 @@ static bool test_delayed_write_update5(struct torture_context *tctx,
GET_INFO_BOTH(finfo4,pinfo4);
if (finfo4.basic_info.out.write_time > finfo3.basic_info.out.write_time) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- (int)(time(NULL) - t));
+ double diff = timeval_elapsed(&start);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- msleep(2000);
+ msleep(2 * msec);
}
GET_INFO_BOTH(finfo4,pinfo4);
@@ -1110,7 +1173,7 @@ static bool test_delayed_write_update5(struct torture_context *tctx,
}
/* sleep */
- msleep(5000);
+ msleep(5 * msec);
GET_INFO_BOTH(finfo5,pinfo5);
COMPARE_WRITE_TIME_EQUAL(finfo5, finfo4);
@@ -1149,7 +1212,12 @@ static bool test_delayed_write_update6(struct torture_context *tctx,
int fnum2 = -1;
bool ret = true;
ssize_t written;
- time_t t;
+ struct timeval start;
+ struct timeval end;
+ int used_delay = torture_setting_int(tctx, "writetimeupdatedelay", 2000000);
+ int normal_delay = 2000000;
+ double sec = ((double)used_delay) / ((double)normal_delay);
+ int msec = 1000 * sec;
bool first = true;
if (!torture_setup_dir(cli, BASEDIR)) {
@@ -1217,19 +1285,22 @@ again:
COMPARE_WRITE_TIME_LESS(finfo2, finfo1);
/* make sure the 2 second delay from the first write are canceled */
- t = time(NULL);
- while (time(NULL) < t+15) {
+ start = timeval_current();
+ end = timeval_add(&start, 15 * sec, 0);
+ while (!timeval_expired(&end)) {
/* get the times after the first write */
GET_INFO_BOTH(finfo3,pinfo3);
if (finfo3.basic_info.out.write_time > finfo2.basic_info.out.write_time) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- (int)(time(NULL) - t));
+ double diff = timeval_elapsed(&start);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- msleep(2000);
+ msleep(2 * msec);
}
GET_INFO_BOTH(finfo3,pinfo3);
@@ -1239,8 +1310,9 @@ again:
}
/* sure any further write doesn't update the write time */
- t = time(NULL);
- while (time(NULL) < t+15) {
+ start = timeval_current();
+ end = timeval_add(&start, 15 * sec, 0);
+ while (!timeval_expired(&end)) {
/* do a write */
torture_comment(tctx, "Do a write on the file handle\n");
written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1);
@@ -1253,12 +1325,14 @@ again:
GET_INFO_BOTH(finfo4,pinfo4);
if (finfo4.basic_info.out.write_time > finfo3.basic_info.out.write_time) {
- torture_comment(tctx, "Server updated write_time after %d seconds (wrong!)\n",
- (int)(time(NULL) - t));
+ double diff = timeval_elapsed(&start);
+ torture_comment(tctx, "Server updated write_time after %.2f seconds "
+ "(1sec == %.2f) (wrong!)\n",
+ diff, sec);
ret = false;
break;
}
- msleep(2000);
+ msleep(2 * msec);
}
GET_INFO_BOTH(finfo4,pinfo4);
@@ -1268,7 +1342,7 @@ again:
}
/* sleep */
- msleep(5000);
+ msleep(5 * msec);
GET_INFO_BOTH(finfo5,pinfo5);
COMPARE_WRITE_TIME_EQUAL(finfo5, finfo4);
diff --git a/source4/torture/basic/locking.c b/source4/torture/basic/locking.c
index 2e2585b976..3f399c97ef 100644
--- a/source4/torture/basic/locking.c
+++ b/source4/torture/basic/locking.c
@@ -23,9 +23,8 @@
#include "includes.h"
#include "libcli/raw/libcliraw.h"
#include "libcli/libcli.h"
-#include "torture/ui.h"
+#include "torture/smbtorture.h"
#include "torture/util.h"
-#include "torture/torture.h"
#include "system/time.h"
#include "system/filesys.h"
diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c
index 188fc1bc69..24e0324bc3 100644
--- a/source4/torture/basic/misc.c
+++ b/source4/torture/basic/misc.c
@@ -30,7 +30,7 @@
#include "libcli/resolve/resolve.h"
#include "auth/credentials/credentials.h"
#include "librpc/gen_ndr/ndr_nbt.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "torture/util.h"
#include "libcli/smb_composite/smb_composite.h"
#include "libcli/composite/composite.h"
diff --git a/source4/torture/config.mk b/source4/torture/config.mk
index 1d09d74f99..2857b99582 100644
--- a/source4/torture/config.mk
+++ b/source4/torture/config.mk
@@ -1,51 +1,14 @@
-# TORTURE subsystem
-[LIBRARY::torture]
-SO_VERSION = 0
-VERSION = 0.0.1
-PC_FILE = torture.pc
-PRIVATE_PROTO_HEADER = proto.h
-OBJ_FILES = \
- torture.o \
- ui.o
-PUBLIC_DEPENDENCIES = \
- LIBSAMBA-HOSTCONFIG \
- LIBSAMBA-UTIL \
- LIBTALLOC \
- LIBPOPT
-
-PUBLIC_HEADERS += torture/torture.h torture/ui.h
-
[SUBSYSTEM::TORTURE_UTIL]
-OBJ_FILES = util_smb.o util_provision.o
-PRIVATE_DEPENDENCIES = LIBCLI_RAW LIBPYTHON smbcalls
+PRIVATE_DEPENDENCIES = LIBCLI_RAW LIBPYTHON smbcalls PROVISION
PUBLIC_DEPENDENCIES = POPT_CREDENTIALS
+TORTURE_UTIL_OBJ_FILES = $(addprefix $(torturesrcdir)/, util_smb.o)
+
#################################
# Start SUBSYSTEM TORTURE_BASIC
[MODULE::TORTURE_BASIC]
-SUBSYSTEM = torture
+SUBSYSTEM = smbtorture
INIT_FUNCTION = torture_base_init
-PRIVATE_PROTO_HEADER = \
- basic/proto.h
-OBJ_FILES = \
- basic/base.o \
- basic/misc.o \
- basic/scanner.o \
- basic/utable.o \
- basic/charset.o \
- basic/mangle_test.o \
- basic/denytest.o \
- basic/aliases.o \
- basic/locking.o \
- basic/secleak.o \
- basic/rename.o \
- basic/dir.o \
- basic/delete.o \
- basic/unlink.o \
- basic/disconnect.o \
- basic/delaywrite.o \
- basic/attr.o \
- basic/properties.o
PRIVATE_DEPENDENCIES = \
LIBCLI_SMB POPT_CREDENTIALS \
TORTURE_UTIL LIBCLI_RAW \
@@ -53,117 +16,89 @@ PRIVATE_DEPENDENCIES = \
# End SUBSYSTEM TORTURE_BASIC
#################################
+TORTURE_BASIC_OBJ_FILES = $(addprefix $(torturesrcdir)/basic/, \
+ base.o \
+ misc.o \
+ scanner.o \
+ utable.o \
+ charset.o \
+ mangle_test.o \
+ denytest.o \
+ aliases.o \
+ locking.o \
+ secleak.o \
+ rename.o \
+ dir.o \
+ delete.o \
+ unlink.o \
+ disconnect.o \
+ delaywrite.o \
+ attr.o \
+ properties.o)
+
+$(eval $(call proto_header_template,$(torturesrcdir)/basic/proto.h,$(TORTURE_BASIC_OBJ_FILES:.o=.c)))
+
#################################
# Start SUBSYSTEM TORTURE_RAW
[MODULE::TORTURE_RAW]
-SUBSYSTEM = torture
+SUBSYSTEM = smbtorture
INIT_FUNCTION = torture_raw_init
-PRIVATE_PROTO_HEADER = \
- raw/proto.h
-OBJ_FILES = \
- raw/qfsinfo.o \
- raw/qfileinfo.o \
- raw/setfileinfo.o \
- raw/search.o \
- raw/close.o \
- raw/open.o \
- raw/mkdir.o \
- raw/oplock.o \
- raw/notify.o \
- raw/mux.o \
- raw/ioctl.o \
- raw/chkpath.o \
- raw/unlink.o \
- raw/read.o \
- raw/context.o \
- raw/write.o \
- raw/lock.o \
- raw/pingpong.o \
- raw/lockbench.o \
- raw/openbench.o \
- raw/rename.o \
- raw/eas.o \
- raw/streams.o \
- raw/acls.o \
- raw/seek.o \
- raw/samba3hide.o \
- raw/samba3misc.o \
- raw/composite.o \
- raw/raw.o \
- raw/offline.o
PRIVATE_DEPENDENCIES = \
LIBCLI_SMB LIBCLI_LSA LIBCLI_SMB_COMPOSITE \
POPT_CREDENTIALS TORTURE_UTIL
# End SUBSYSTEM TORTURE_RAW
#################################
+TORTURE_RAW_OBJ_FILES = $(addprefix $(torturesrcdir)/raw/, \
+ qfsinfo.o \
+ qfileinfo.o \
+ setfileinfo.o \
+ search.o \
+ close.o \
+ open.o \
+ mkdir.o \
+ oplock.o \
+ notify.o \
+ mux.o \
+ ioctl.o \
+ chkpath.o \
+ unlink.o \
+ read.o \
+ context.o \
+ write.o \
+ lock.o \
+ pingpong.o \
+ lockbench.o \
+ lookuprate.o \
+ tconrate.o \
+ openbench.o \
+ rename.o \
+ eas.o \
+ streams.o \
+ acls.o \
+ seek.o \
+ samba3hide.o \
+ samba3misc.o \
+ composite.o \
+ raw.o \
+ offline.o)
+
+$(eval $(call proto_header_template,$(torturesrcdir)/raw/proto.h,$(TORTURE_RAW_OBJ_FILES:.o=.c)))
+
mkinclude smb2/config.mk
mkinclude winbind/config.mk
[SUBSYSTEM::TORTURE_NDR]
-PRIVATE_PROTO_HEADER = ndr/proto.h
-OBJ_FILES = ndr/ndr.o \
- ndr/winreg.o \
- ndr/atsvc.o \
- ndr/lsa.o \
- ndr/epmap.o \
- ndr/dfs.o \
- ndr/netlogon.o \
- ndr/drsuapi.o \
- ndr/spoolss.o \
- ndr/samr.o
+
+TORTURE_NDR_OBJ_FILES = $(addprefix $(torturesrcdir)/ndr/, ndr.o winreg.o atsvc.o lsa.o epmap.o dfs.o netlogon.o drsuapi.o spoolss.o samr.o)
+
+$(eval $(call proto_header_template,$(torturesrcdir)/ndr/proto.h,$(TORTURE_NDR_OBJ_FILES:.o=.c)))
[MODULE::torture_rpc]
# TORTURE_NET and TORTURE_NBT use functions from torture_rpc...
#OUTPUT_TYPE = MERGED_OBJ
-SUBSYSTEM = torture
+SUBSYSTEM = smbtorture
INIT_FUNCTION = torture_rpc_init
-PRIVATE_PROTO_HEADER = \
- rpc/proto.h
-OBJ_FILES = \
- rpc/join.o \
- rpc/lsa.o \
- rpc/lsa_lookup.o \
- rpc/session_key.o \
- rpc/echo.o \
- rpc/dfs.o \
- rpc/drsuapi.o \
- rpc/drsuapi_cracknames.o \
- rpc/dssync.o \
- rpc/spoolss.o \
- rpc/spoolss_notify.o \
- rpc/spoolss_win.o \
- rpc/unixinfo.o \
- rpc/samr.o \
- rpc/samr_accessmask.o \
- rpc/wkssvc.o \
- rpc/srvsvc.o \
- rpc/svcctl.o \
- rpc/atsvc.o \
- rpc/eventlog.o \
- rpc/epmapper.o \
- rpc/winreg.o \
- rpc/initshutdown.o \
- rpc/oxidresolve.o \
- rpc/remact.o \
- rpc/mgmt.o \
- rpc/scanner.o \
- rpc/autoidl.o \
- rpc/countcalls.o \
- rpc/testjoin.o \
- rpc/schannel.o \
- rpc/netlogon.o \
- rpc/samlogon.o \
- rpc/samsync.o \
- rpc/bind.o \
- rpc/dssetup.o \
- rpc/alter_context.o \
- rpc/bench.o \
- rpc/samba3rpc.o \
- rpc/rpc.o \
- rpc/async_bind.o \
- rpc/handles.o \
- rpc/frsapi.o
PRIVATE_DEPENDENCIES = \
NDR_TABLE RPC_NDR_UNIXINFO dcerpc_samr RPC_NDR_WINREG RPC_NDR_INITSHUTDOWN \
RPC_NDR_OXIDRESOLVER RPC_NDR_EVENTLOG RPC_NDR_ECHO RPC_NDR_SVCCTL \
@@ -172,128 +107,108 @@ PRIVATE_DEPENDENCIES = \
RPC_NDR_SRVSVC RPC_NDR_WKSSVC RPC_NDR_ROT RPC_NDR_DSSETUP \
RPC_NDR_REMACT RPC_NDR_OXIDRESOLVER WB_HELPER LIBSAMBA-NET \
LIBCLI_AUTH POPT_CREDENTIALS TORTURE_LDAP TORTURE_UTIL TORTURE_RAP \
- dcerpc_server service process_model
+ dcerpc_server service process_model ntvfs SERVICE_SMB
+
+torture_rpc_OBJ_FILES = $(addprefix $(torturesrcdir)/rpc/, \
+ join.o lsa.o lsa_lookup.o session_key.o echo.o dfs.o drsuapi.o \
+ drsuapi_cracknames.o dssync.o spoolss.o spoolss_notify.o spoolss_win.o \
+ unixinfo.o samr.o samr_accessmask.o wkssvc.o srvsvc.o svcctl.o atsvc.o \
+ eventlog.o epmapper.o winreg.o initshutdown.o oxidresolve.o remact.o mgmt.o \
+ scanner.o autoidl.o countcalls.o testjoin.o schannel.o netlogon.o samlogon.o \
+ samsync.o bind.o dssetup.o alter_context.o bench.o samba3rpc.o rpc.o async_bind.o \
+ handles.o frsapi.o)
+
+$(eval $(call proto_header_template,$(torturesrcdir)/rpc/proto.h,$(torture_rpc_OBJ_FILES:.o=.c)))
#################################
# Start SUBSYSTEM TORTURE_RAP
[MODULE::TORTURE_RAP]
-SUBSYSTEM = torture
+SUBSYSTEM = smbtorture
INIT_FUNCTION = torture_rap_init
-PRIVATE_PROTO_HEADER = \
- rap/proto.h
-OBJ_FILES = \
- rap/rap.o
PRIVATE_DEPENDENCIES = TORTURE_UTIL LIBCLI_SMB
# End SUBSYSTEM TORTURE_RAP
#################################
+TORTURE_RAP_OBJ_FILES = $(torturesrcdir)/rap/rap.o
+
+$(eval $(call proto_header_template,$(torturesrcdir)/rap/proto.h,$(TORTURE_RAP_OBJ_FILES:.o=.c)))
+
#################################
# Start SUBSYSTEM TORTURE_AUTH
[MODULE::TORTURE_AUTH]
-SUBSYSTEM = torture
-PRIVATE_PROTO_HEADER = \
- auth/proto.h
-OBJ_FILES = \
- auth/ntlmssp.o \
- auth/pac.o
+SUBSYSTEM = smbtorture
PRIVATE_DEPENDENCIES = \
LIBCLI_SMB gensec auth KERBEROS \
POPT_CREDENTIALS SMBPASSWD
# End SUBSYSTEM TORTURE_AUTH
#################################
+TORTURE_AUTH_OBJ_FILES = $(addprefix $(torturesrcdir)/auth/, ntlmssp.o pac.o)
+
+$(eval $(call proto_header_template,$(torturesrcdir)/auth/proto.h,$(TORTURE_AUTH_OBJ_FILES:.o=.c)))
+
mkinclude local/config.mk
#################################
# Start MODULE TORTURE_NBENCH
[MODULE::TORTURE_NBENCH]
-SUBSYSTEM = torture
+SUBSYSTEM = smbtorture
INIT_FUNCTION = torture_nbench_init
PRIVATE_DEPENDENCIES = TORTURE_UTIL
-PRIVATE_PROTO_HEADER = \
- nbench/proto.h
-OBJ_FILES = \
- nbench/nbio.o \
- nbench/nbench.o
# End MODULE TORTURE_NBENCH
#################################
+TORTURE_NBENCH_OBJ_FILES = $(addprefix $(torturesrcdir)/nbench/, nbio.o nbench.o)
+
+$(eval $(call proto_header_template,$(torturesrcdir)/nbench/proto.h,$(TORTURE_NBENCH_OBJ_FILES:.o=.c)))
+
#################################
# Start MODULE TORTURE_UNIX
[MODULE::TORTURE_UNIX]
-SUBSYSTEM = torture
+SUBSYSTEM = smbtorture
INIT_FUNCTION = torture_unix_init
PRIVATE_DEPENDENCIES = TORTURE_UTIL
-PRIVATE_PROTO_HEADER = \
- unix/proto.h
-OBJ_FILES = \
- unix/unix.o \
- unix/whoami.o \
- unix/unix_info2.o
# End MODULE TORTURE_UNIX
#################################
+TORTURE_UNIX_OBJ_FILES = $(addprefix $(torturesrcdir)/unix/, unix.o whoami.o unix_info2.o)
+
+$(eval $(call proto_header_template,$(torturesrcdir)/unix/proto.h,$(TORTURE_UNIX_OBJ_FILES:.o=.c)))
+
#################################
# Start SUBSYSTEM TORTURE_LDAP
[MODULE::TORTURE_LDAP]
-SUBSYSTEM = torture
+SUBSYSTEM = smbtorture
INIT_FUNCTION = torture_ldap_init
-PRIVATE_PROTO_HEADER = \
- ldap/proto.h
-OBJ_FILES = \
- ldap/common.o \
- ldap/basic.o \
- ldap/schema.o \
- ldap/uptodatevector.o \
- ldap/cldap.o \
- ldap/cldapbench.o
PRIVATE_DEPENDENCIES = \
LIBCLI_LDAP LIBCLI_CLDAP SAMDB POPT_CREDENTIALS
# End SUBSYSTEM TORTURE_LDAP
#################################
+TORTURE_LDAP_OBJ_FILES = $(addprefix $(torturesrcdir)/ldap/, common.o basic.o schema.o uptodatevector.o cldap.o cldapbench.o)
+
+$(eval $(call proto_header_template,$(torturesrcdir)/ldap/proto.h,$(TORTURE_LDAP_OBJ_FILES:.o=.c)))
+
#################################
# Start SUBSYSTEM TORTURE_NBT
[MODULE::TORTURE_NBT]
-SUBSYSTEM = torture
+SUBSYSTEM = smbtorture
INIT_FUNCTION = torture_nbt_init
-PRIVATE_PROTO_HEADER = \
- nbt/proto.h
-OBJ_FILES = \
- nbt/query.o \
- nbt/register.o \
- nbt/wins.o \
- nbt/winsbench.o \
- nbt/winsreplication.o \
- nbt/dgram.o \
- nbt/nbt.o
PRIVATE_DEPENDENCIES = \
LIBCLI_SMB LIBCLI_NBT LIBCLI_DGRAM LIBCLI_WREPL torture_rpc
# End SUBSYSTEM TORTURE_NBT
#################################
+TORTURE_NBT_OBJ_FILES = $(addprefix $(torturesrcdir)/nbt/, query.o register.o \
+ wins.o winsbench.o winsreplication.o dgram.o nbt.o)
+
+$(eval $(call proto_header_template,$(torturesrcdir)/nbt/proto.h,$(TORTURE_NBT_OBJ_FILES:.o=.c)))
+
#################################
# Start SUBSYSTEM TORTURE_NET
[MODULE::TORTURE_NET]
-SUBSYSTEM = torture
+SUBSYSTEM = smbtorture
INIT_FUNCTION = torture_net_init
-PRIVATE_PROTO_HEADER = \
- libnet/proto.h
-OBJ_FILES = \
- libnet/libnet.o \
- libnet/utils.o \
- libnet/userinfo.o \
- libnet/userman.o \
- libnet/groupinfo.o \
- libnet/groupman.o \
- libnet/domain.o \
- libnet/libnet_lookup.o \
- libnet/libnet_user.o \
- libnet/libnet_group.o \
- libnet/libnet_share.o \
- libnet/libnet_rpc.o \
- libnet/libnet_domain.o \
- libnet/libnet_BecomeDC.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-NET \
POPT_CREDENTIALS \
@@ -301,12 +216,17 @@ PRIVATE_DEPENDENCIES = \
# End SUBSYSTEM TORTURE_NET
#################################
+TORTURE_NET_OBJ_FILES = $(addprefix $(torturesrcdir)/libnet/, libnet.o \
+ utils.o userinfo.o userman.o groupinfo.o groupman.o \
+ domain.o libnet_lookup.o libnet_user.o libnet_group.o \
+ libnet_share.o libnet_rpc.o libnet_domain.o libnet_BecomeDC.o)
+
+$(eval $(call proto_header_template,$(torturesrcdir)/libnet/proto.h,$(TORTURE_NET_OBJ_FILES:.o=.c)))
+
#################################
# Start BINARY smbtorture
[BINARY::smbtorture]
INSTALLDIR = BINDIR
-OBJ_FILES = \
- smbtorture.o
PRIVATE_DEPENDENCIES = \
torture \
LIBPOPT \
@@ -318,14 +238,15 @@ PRIVATE_DEPENDENCIES = \
# End BINARY smbtorture
#################################
-MANPAGES += torture/man/smbtorture.1
+smbtorture_OBJ_FILES = $(torturesrcdir)/smbtorture.o $(torturesrcdir)/torture.o
+
+PUBLIC_HEADERS += $(torturesrcdir)/smbtorture.h
+MANPAGES += $(torturesrcdir)/man/smbtorture.1
#################################
# Start BINARY gentest
[BINARY::gentest]
INSTALLDIR = BINDIR
-OBJ_FILES = \
- gentest.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-HOSTCONFIG \
LIBSAMBA-UTIL \
@@ -337,14 +258,31 @@ PRIVATE_DEPENDENCIES = \
# End BINARY gentest
#################################
-MANPAGES += torture/man/gentest.1
+gentest_OBJ_FILES = $(torturesrcdir)/gentest.o
+
+MANPAGES += $(torturesrcdir)/man/gentest.1
+
+#################################
+# Start BINARY gentest_smb2
+[BINARY::gentest_smb2]
+INSTALLDIR = BINDIR
+PRIVATE_DEPENDENCIES = \
+ LIBSAMBA-HOSTCONFIG \
+ LIBSAMBA-UTIL \
+ LIBPOPT \
+ POPT_SAMBA \
+ POPT_CREDENTIALS \
+ LIBCLI_SMB \
+ LIBCLI_RAW
+# End BINARY gentest_smb2
+#################################
+
+gentest_smb2_OBJ_FILES = $(torturesrcdir)/gentest_smb2.o
#################################
# Start BINARY masktest
[BINARY::masktest]
INSTALLDIR = BINDIR
-OBJ_FILES = \
- masktest.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-HOSTCONFIG \
LIBSAMBA-UTIL \
@@ -355,14 +293,14 @@ PRIVATE_DEPENDENCIES = \
# End BINARY masktest
#################################
-MANPAGES += torture/man/masktest.1
+masktest_OBJ_FILES = $(torturesrcdir)/masktest.o
+
+MANPAGES += $(torturesrcdir)/man/masktest.1
#################################
# Start BINARY locktest
[BINARY::locktest]
INSTALLDIR = BINDIR
-OBJ_FILES = \
- locktest.o
PRIVATE_DEPENDENCIES = \
LIBPOPT \
POPT_SAMBA \
@@ -373,34 +311,44 @@ PRIVATE_DEPENDENCIES = \
# End BINARY locktest
#################################
-MANPAGES += torture/man/locktest.1
+locktest_OBJ_FILES = $(torturesrcdir)/locktest.o
-COV_TARGET = test
+MANPAGES += $(torturesrcdir)/man/locktest.1
+
+GCOV=0
+
+ifeq ($(MAKECMDGOALS),gcov)
+GCOV=1
+endif
+
+ifeq ($(MAKECMDGOALS),lcov)
+GCOV=1
+endif
-COV_VARS = \
- CFLAGS="$(CFLAGS) --coverage" \
- LDFLAGS="$(LDFLAGS) --coverage"
+ifeq ($(MAKECMDGOALS),testcov-html)
+GCOV=1
+endif
-test_cov:
- -$(MAKE) $(COV_TARGET) $(COV_VARS)
+ifeq ($(GCOV),1)
+CFLAGS += --coverage
+LDFLAGS += --coverage
+endif
-gcov: test_cov
+COV_TARGET = test
+
+gcov: test
for I in $(sort $(dir $(ALL_OBJS))); \
do $(GCOV) -p -o $$I $$I/*.c; \
done
-lcov-split:
- rm -f samba.info
- @$(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
+samba.info: test
-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
+
+lcov: samba.info
+ genhtml -o coverage $<
testcov-html:: lcov
+
+clean::
+ @rm -f samba.info
diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c
index d5fc855f17..ae18fe809c 100644
--- a/source4/torture/gentest.c
+++ b/source4/torture/gentest.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "lib/cmdline/popt_common.h"
+#include "lib/events/events.h"
#include "system/time.h"
#include "system/filesys.h"
#include "libcli/raw/request.h"
@@ -36,18 +37,18 @@
/* global options */
static struct gentest_options {
- bool showall;
- bool analyze;
- bool analyze_always;
- bool analyze_continuous;
+ int showall;
+ int analyze;
+ int analyze_always;
+ int analyze_continuous;
uint_t max_open_handles;
uint_t seed;
uint_t numops;
- bool use_oplocks;
+ int use_oplocks;
char **ignore_patterns;
const char *seeds_file;
- bool use_preset_seeds;
- bool fast_reconnect;
+ int use_preset_seeds;
+ int fast_reconnect;
} options;
/* mapping between open handles on the server and local handles */
@@ -154,7 +155,8 @@ static bool connect_servers_fast(void)
/*****************************************************
connect to the servers
*******************************************************/
-static bool connect_servers(struct loadparm_context *lp_ctx)
+static bool connect_servers(struct event_context *ev,
+ struct loadparm_context *lp_ctx)
{
int i, j;
@@ -193,7 +195,7 @@ static bool connect_servers(struct loadparm_context *lp_ctx)
servers[i].share_name, NULL,
servers[i].credentials,
lp_resolve_context(lp_ctx),
- NULL, &smb_options);
+ ev, &smb_options);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to \\\\%s\\%s - %s\n",
servers[i].server_name, servers[i].share_name,
@@ -1937,11 +1939,11 @@ static struct {
run the test with the current set of op_parms parameters
return the number of operations that completed successfully
*/
-static int run_test(struct loadparm_context *lp_ctx)
+static int run_test(struct event_context *ev, struct loadparm_context *lp_ctx)
{
int op, i;
- if (!connect_servers(lp_ctx)) {
+ if (!connect_servers(ev, lp_ctx)) {
printf("Failed to connect to servers\n");
exit(1);
}
@@ -2018,7 +2020,8 @@ static int run_test(struct loadparm_context *lp_ctx)
perform a backtracking analysis of the minimal set of operations
to generate an error
*/
-static void backtrack_analyze(struct loadparm_context *lp_ctx)
+static void backtrack_analyze(struct event_context *ev,
+ struct loadparm_context *lp_ctx)
{
int chunk, ret;
@@ -2039,7 +2042,7 @@ static void backtrack_analyze(struct loadparm_context *lp_ctx)
}
printf("Testing %d ops with %d-%d disabled\n",
options.numops, base, max-1);
- ret = run_test(lp_ctx);
+ ret = run_test(ev, lp_ctx);
printf("Completed %d of %d ops\n", ret, options.numops);
for (i=base;i<max; i++) {
op_parms[i].disabled = false;
@@ -2071,7 +2074,7 @@ static void backtrack_analyze(struct loadparm_context *lp_ctx)
} while (chunk > 0);
printf("Reduced to %d ops\n", options.numops);
- ret = run_test(lp_ctx);
+ ret = run_test(ev, lp_ctx);
if (ret != options.numops - 1) {
printf("Inconsistent result? ret=%d numops=%d\n", ret, options.numops);
}
@@ -2080,7 +2083,8 @@ static void backtrack_analyze(struct loadparm_context *lp_ctx)
/*
start the main gentest process
*/
-static bool start_gentest(struct loadparm_context *lp_ctx)
+static bool start_gentest(struct event_context *ev,
+ struct loadparm_context *lp_ctx)
{
int op;
int ret;
@@ -2116,15 +2120,15 @@ static bool start_gentest(struct loadparm_context *lp_ctx)
}
}
- ret = run_test(lp_ctx);
+ ret = run_test(ev, lp_ctx);
if (ret != options.numops && options.analyze) {
options.numops = ret+1;
- backtrack_analyze(lp_ctx);
+ backtrack_analyze(ev, lp_ctx);
} else if (options.analyze_always) {
- backtrack_analyze(lp_ctx);
+ backtrack_analyze(ev, lp_ctx);
} else if (options.analyze_continuous) {
- while (run_test(lp_ctx) == options.numops) ;
+ while (run_test(ev, lp_ctx) == options.numops) ;
}
return ret == options.numops;
@@ -2171,6 +2175,7 @@ static bool split_unc_name(const char *unc, char **server, char **share)
int i, username_count=0;
bool ret;
char *ignore_file=NULL;
+ struct event_context *ev;
struct loadparm_context *lp_ctx;
poptContext pc;
int argc_new;
@@ -2278,9 +2283,11 @@ static bool split_unc_name(const char *unc, char **server, char **share)
printf("seed=%u\n", options.seed);
+ ev = event_context_init(talloc_autofree_context());
+
gensec_init(lp_ctx);
- ret = start_gentest(lp_ctx);
+ ret = start_gentest(ev, lp_ctx);
if (ret) {
printf("gentest completed - no errors\n");
diff --git a/source4/torture/gentest_smb2.c b/source4/torture/gentest_smb2.c
new file mode 100644
index 0000000000..6546ba6768
--- /dev/null
+++ b/source4/torture/gentest_smb2.c
@@ -0,0 +1,1907 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ generic testing tool - version with SMB2 support
+
+ Copyright (C) Andrew Tridgell 2003-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 "lib/cmdline/popt_common.h"
+#include "lib/events/events.h"
+#include "system/time.h"
+#include "system/filesys.h"
+#include "libcli/raw/request.h"
+#include "libcli/libcli.h"
+#include "libcli/raw/libcliraw.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+#include "librpc/gen_ndr/security.h"
+#include "auth/credentials/credentials.h"
+#include "libcli/resolve/resolve.h"
+#include "auth/gensec/gensec.h"
+#include "param/param.h"
+#include "dynconfig.h"
+
+#define NSERVERS 2
+#define NINSTANCES 2
+
+/* global options */
+static struct gentest_options {
+ int showall;
+ int analyze;
+ int analyze_always;
+ int analyze_continuous;
+ uint_t max_open_handles;
+ uint_t seed;
+ uint_t numops;
+ int use_oplocks;
+ char **ignore_patterns;
+ const char *seeds_file;
+ int use_preset_seeds;
+ int fast_reconnect;
+ int mask_indexing;
+ int no_eas;
+} options;
+
+/* mapping between open handles on the server and local handles */
+static struct {
+ bool active;
+ uint_t instance;
+ struct smb2_handle server_handle[NSERVERS];
+ const char *name;
+} *open_handles;
+static uint_t num_open_handles;
+
+/* state information for the servers. We open NINSTANCES connections to
+ each server */
+static struct {
+ struct smb2_tree *tree[NINSTANCES];
+ char *server_name;
+ char *share_name;
+ struct cli_credentials *credentials;
+} servers[NSERVERS];
+
+/* the seeds and flags for each operation */
+static struct {
+ uint_t seed;
+ bool disabled;
+} *op_parms;
+
+
+/* oplock break info */
+static struct {
+ bool got_break;
+ struct smb2_handle server_handle;
+ uint16_t handle;
+ uint8_t level;
+ bool do_close;
+} oplocks[NSERVERS][NINSTANCES];
+
+/* change notify reply info */
+static struct {
+ int notify_count;
+ NTSTATUS status;
+ union smb_notify notify;
+} notifies[NSERVERS][NINSTANCES];
+
+/* info relevant to the current operation */
+static struct {
+ const char *name;
+ uint_t seed;
+ NTSTATUS status;
+ uint_t opnum;
+ TALLOC_CTX *mem_ctx;
+} current_op;
+
+static struct smb2_handle bad_smb2_handle;
+
+
+#define BAD_HANDLE 0xFFFE
+
+static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private);
+static void idle_func(struct smb2_transport *transport, void *private);
+
+/*
+ check if a string should be ignored. This is used as the basis
+ for all error ignore settings
+*/
+static bool ignore_pattern(const char *str)
+{
+ int i;
+ if (!options.ignore_patterns) return false;
+
+ for (i=0;options.ignore_patterns[i];i++) {
+ if (strcmp(options.ignore_patterns[i], str) == 0 ||
+ gen_fnmatch(options.ignore_patterns[i], str) == 0) {
+ DEBUG(2,("Ignoring '%s'\n", str));
+ return true;
+ }
+ }
+ return false;
+}
+
+/*****************************************************
+connect to the servers
+*******************************************************/
+static bool connect_servers_fast(void)
+{
+ int h, i;
+
+ /* close all open files */
+ for (h=0;h<options.max_open_handles;h++) {
+ if (!open_handles[h].active) continue;
+ for (i=0;i<NSERVERS;i++) {
+ NTSTATUS status = smb2_util_close(servers[i].tree[open_handles[h].instance],
+ open_handles[h].server_handle[i]);
+ if (NT_STATUS_IS_ERR(status)) {
+ return false;
+ }
+ open_handles[h].active = false;
+ }
+ }
+
+ return true;
+}
+
+
+
+
+/*****************************************************
+connect to the servers
+*******************************************************/
+static bool connect_servers(struct event_context *ev,
+ struct loadparm_context *lp_ctx)
+{
+ int i, j;
+
+ if (options.fast_reconnect && servers[0].tree[0]) {
+ if (connect_servers_fast()) {
+ return true;
+ }
+ }
+
+ /* close any existing connections */
+ for (i=0;i<NSERVERS;i++) {
+ for (j=0;j<NINSTANCES;j++) {
+ if (servers[i].tree[j]) {
+ smb2_tdis(servers[i].tree[j]);
+ talloc_free(servers[i].tree[j]);
+ servers[i].tree[j] = NULL;
+ }
+ }
+ }
+
+ for (i=0;i<NSERVERS;i++) {
+ for (j=0;j<NINSTANCES;j++) {
+ NTSTATUS status;
+ printf("Connecting to \\\\%s\\%s as %s - instance %d\n",
+ servers[i].server_name, servers[i].share_name,
+ servers[i].credentials->username, j);
+
+ cli_credentials_set_workstation(servers[i].credentials,
+ "gentest", CRED_SPECIFIED);
+
+ status = smb2_connect(NULL, servers[i].server_name,
+ servers[i].share_name,
+ lp_resolve_context(lp_ctx),
+ servers[i].credentials,
+ &servers[i].tree[j],
+ ev);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Failed to connect to \\\\%s\\%s - %s\n",
+ servers[i].server_name, servers[i].share_name,
+ nt_errstr(status));
+ return false;
+ }
+
+// smb2_oplock_handler(servers[i].cli[j]->transport, oplock_handler, NULL);
+ smb2_transport_idle_handler(servers[i].tree[j]->session->transport, idle_func, 50000, NULL);
+ }
+ }
+
+ return true;
+}
+
+/*
+ work out the time skew between the servers - be conservative
+*/
+static uint_t time_skew(void)
+{
+ uint_t ret;
+ ret = labs(servers[0].tree[0]->session->transport->negotiate.system_time -
+ servers[1].tree[0]->session->transport->negotiate.system_time);
+ return ret + 300;
+}
+
+
+static bool smb2_handle_equal(const struct smb2_handle *h1, const struct smb2_handle *h2)
+{
+ return memcmp(h1, h2, sizeof(struct smb2_handle)) == 0;
+}
+
+/*
+ turn a server handle into a local handle
+*/
+static uint_t fnum_to_handle(int server, int instance, struct smb2_handle server_handle)
+{
+ uint_t i;
+ for (i=0;i<options.max_open_handles;i++) {
+ if (!open_handles[i].active ||
+ instance != open_handles[i].instance) continue;
+ if (smb2_handle_equal(&open_handles[i].server_handle[server], &server_handle)) {
+ return i;
+ }
+ }
+ printf("Invalid server handle in fnum_to_handle on server %d instance %d\n",
+ server, instance);
+ return BAD_HANDLE;
+}
+
+/*
+ add some newly opened handles
+*/
+static void gen_add_handle(int instance, const char *name, struct smb2_handle handles[NSERVERS])
+{
+ int i, h;
+ for (h=0;h<options.max_open_handles;h++) {
+ if (!open_handles[h].active) break;
+ }
+ if (h == options.max_open_handles) {
+ /* we have to force close a random handle */
+ h = random() % options.max_open_handles;
+ for (i=0;i<NSERVERS;i++) {
+ NTSTATUS status;
+ status = smb2_util_close(servers[i].tree[open_handles[h].instance],
+ open_handles[h].server_handle[i]);
+ if (NT_STATUS_IS_ERR(status)) {
+ printf("INTERNAL ERROR: Close failed when recovering handle! - %s\n",
+ nt_errstr(status));
+ }
+ }
+ printf("Recovered handle %d\n", h);
+ num_open_handles--;
+ }
+ for (i=0;i<NSERVERS;i++) {
+ open_handles[h].server_handle[i] = handles[i];
+ open_handles[h].instance = instance;
+ open_handles[h].active = true;
+ open_handles[h].name = name;
+ }
+ num_open_handles++;
+
+ printf("OPEN num_open_handles=%d h=%d (%s)\n",
+ num_open_handles, h, name);
+}
+
+/*
+ remove a closed handle
+*/
+static void gen_remove_handle(int instance, struct smb2_handle handles[NSERVERS])
+{
+ int h;
+ for (h=0;h<options.max_open_handles;h++) {
+ if (instance == open_handles[h].instance &&
+ smb2_handle_equal(&open_handles[h].server_handle[0], &handles[0])) {
+ open_handles[h].active = false;
+ num_open_handles--;
+ printf("CLOSE num_open_handles=%d h=%d (%s)\n",
+ num_open_handles, h,
+ open_handles[h].name);
+ return;
+ }
+ }
+ printf("Removing invalid handle!?\n");
+ exit(1);
+}
+
+/*
+ return true with 'chance' probability as a percentage
+*/
+static bool gen_chance(uint_t chance)
+{
+ return ((random() % 100) <= chance);
+}
+
+/*
+ map an internal handle number to a server handle
+*/
+static struct smb2_handle gen_lookup_handle(int server, uint16_t handle)
+{
+ if (handle == BAD_HANDLE) return bad_smb2_handle;
+ return open_handles[handle].server_handle[server];
+}
+
+/*
+ return a file handle
+*/
+static uint16_t gen_fnum(int instance)
+{
+ uint16_t h;
+ int count = 0;
+
+ if (gen_chance(20)) return BAD_HANDLE;
+
+ while (num_open_handles > 0 && count++ < 10*options.max_open_handles) {
+ h = random() % options.max_open_handles;
+ if (open_handles[h].active &&
+ open_handles[h].instance == instance) {
+ return h;
+ }
+ }
+ return BAD_HANDLE;
+}
+
+/*
+ return a file handle, but skewed so we don't close the last
+ couple of handles too readily
+*/
+static uint16_t gen_fnum_close(int instance)
+{
+ if (num_open_handles < 5) {
+ if (gen_chance(90)) return BAD_HANDLE;
+ }
+
+ return gen_fnum(instance);
+}
+
+/*
+ generate an integer in a specified range
+*/
+static int gen_int_range(uint64_t min, uint64_t max)
+{
+ uint_t r = random();
+ return min + (r % (1+max-min));
+}
+
+/*
+ return a fnum for use as a root fid
+ be careful to call GEN_SET_FNUM() when you use this!
+*/
+static uint16_t gen_root_fid(int instance)
+{
+ if (gen_chance(5)) return gen_fnum(instance);
+ return 0;
+}
+
+/*
+ generate a file offset
+*/
+static int gen_offset(void)
+{
+ if (gen_chance(20)) return 0;
+// if (gen_chance(5)) return gen_int_range(0, 0xFFFFFFFF);
+ return gen_int_range(0, 1024*1024);
+}
+
+/*
+ generate a io count
+*/
+static int gen_io_count(void)
+{
+ if (gen_chance(20)) return 0;
+// if (gen_chance(5)) return gen_int_range(0, 0xFFFFFFFF);
+ return gen_int_range(0, 4096);
+}
+
+/*
+ generate a filename
+*/
+static const char *gen_fname(void)
+{
+ const char *names[] = {"gentest\\gentest.dat",
+ "gentest\\foo",
+ "gentest\\foo2.sym",
+ "gentest\\foo3.dll",
+ "gentest\\foo4",
+ "gentest\\foo4:teststream1",
+ "gentest\\foo4:teststream2",
+ "gentest\\foo5.exe",
+ "gentest\\foo5.exe:teststream3",
+ "gentest\\foo5.exe:teststream4",
+ "gentest\\foo6.com",
+ "gentest\\blah",
+ "gentest\\blah\\blergh.txt",
+ "gentest\\blah\\blergh2",
+ "gentest\\blah\\blergh3.txt",
+ "gentest\\blah\\blergh4",
+ "gentest\\blah\\blergh5.txt",
+ "gentest\\blah\\blergh5",
+ "gentest\\blah\\.",
+#if 0
+ /* this causes problem with w2k3 */
+ "gentest\\blah\\..",
+#endif
+ "gentest\\a_very_long_name.bin",
+ "gentest\\x.y",
+ "gentest\\blah"};
+ int i;
+
+ do {
+ i = gen_int_range(0, ARRAY_SIZE(names)-1);
+ } while (ignore_pattern(names[i]));
+
+ return names[i];
+}
+
+/*
+ generate a filename with a higher chance of choosing an already
+ open file
+*/
+static const char *gen_fname_open(int instance)
+{
+ uint16_t h;
+ h = gen_fnum(instance);
+ if (h == BAD_HANDLE) {
+ return gen_fname();
+ }
+ return open_handles[h].name;
+}
+
+/*
+ generate a wildcard pattern
+*/
+static const char *gen_pattern(void)
+{
+ int i;
+ const char *names[] = {"gentest\\*.dat",
+ "gentest\\*",
+ "gentest\\*.*",
+ "gentest\\blah\\*.*",
+ "gentest\\blah\\*",
+ "gentest\\?"};
+
+ if (gen_chance(50)) return gen_fname();
+
+ do {
+ i = gen_int_range(0, ARRAY_SIZE(names)-1);
+ } while (ignore_pattern(names[i]));
+
+ return names[i];
+}
+
+static uint32_t gen_bits_levels(int nlevels, ...)
+{
+ va_list ap;
+ uint32_t pct;
+ uint32_t mask;
+ int i;
+ va_start(ap, nlevels);
+ for (i=0;i<nlevels;i++) {
+ pct = va_arg(ap, uint32_t);
+ mask = va_arg(ap, uint32_t);
+ if (pct == 100 || gen_chance(pct)) {
+ va_end(ap);
+ return mask & random();
+ }
+ }
+ va_end(ap);
+ return 0;
+}
+
+/*
+ generate a bitmask
+*/
+static uint32_t gen_bits_mask(uint_t mask)
+{
+ uint_t ret = random();
+ return ret & mask;
+}
+
+/*
+ generate a bitmask with high probability of the first mask
+ and low of the second
+*/
+static uint32_t gen_bits_mask2(uint32_t mask1, uint32_t mask2)
+{
+ if (gen_chance(10)) return gen_bits_mask(mask2);
+ return gen_bits_mask(mask1);
+}
+
+/*
+ generate a boolean
+*/
+static bool gen_bool(void)
+{
+ return gen_bits_mask2(0x1, 0xFF);
+}
+
+/*
+ generate ntrename flags
+*/
+static uint16_t gen_rename_flags(void)
+{
+ if (gen_chance(30)) return RENAME_FLAG_RENAME;
+ if (gen_chance(30)) return RENAME_FLAG_HARD_LINK;
+ if (gen_chance(30)) return RENAME_FLAG_COPY;
+ return gen_bits_mask(0xFFFF);
+}
+
+
+/*
+ return a set of lock flags
+*/
+static uint16_t gen_lock_flags(void)
+{
+ if (gen_chance(5)) return gen_bits_mask(0xFFFF);
+ if (gen_chance(20)) return gen_bits_mask(0x1F);
+ if (gen_chance(50)) return SMB2_LOCK_FLAG_UNLOCK;
+ return gen_bits_mask(SMB2_LOCK_FLAG_SHARED |
+ SMB2_LOCK_FLAG_EXCLUSIVE |
+ SMB2_LOCK_FLAG_FAIL_IMMEDIATELY);
+}
+
+/*
+ generate a lock count
+*/
+static off_t gen_lock_count(void)
+{
+ return gen_int_range(0, 3);
+}
+
+/*
+ generate a ntcreatex flags field
+*/
+static uint32_t gen_ntcreatex_flags(void)
+{
+ if (gen_chance(70)) return NTCREATEX_FLAGS_EXTENDED;
+ return gen_bits_mask2(0x1F, 0xFFFFFFFF);
+}
+
+/*
+ generate a NT access mask
+*/
+static uint32_t gen_access_mask(void)
+{
+ if (gen_chance(70)) return SEC_FLAG_MAXIMUM_ALLOWED;
+ if (gen_chance(70)) return SEC_FILE_ALL;
+ return gen_bits_mask(0xFFFFFFFF);
+}
+
+/*
+ generate a ntcreatex create options bitfield
+*/
+static uint32_t gen_create_options(void)
+{
+ if (gen_chance(20)) return gen_bits_mask(0xFFFFFFFF);
+ if (gen_chance(50)) return 0;
+ return gen_bits_mask(NTCREATEX_OPTIONS_DELETE_ON_CLOSE | NTCREATEX_OPTIONS_DIRECTORY);
+}
+
+/*
+ generate a ntcreatex open disposition
+*/
+static uint32_t gen_open_disp(void)
+{
+ if (gen_chance(50)) return NTCREATEX_DISP_OPEN_IF;
+ if (gen_chance(10)) return gen_bits_mask(0xFFFFFFFF);
+ return gen_int_range(0, 5);
+}
+
+/*
+ generate a file attrib combination
+*/
+static uint32_t gen_attrib(void)
+{
+ if (gen_chance(20)) return gen_bits_mask(0xFFFFFFFF);
+ return gen_bits_mask(FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY);
+}
+
+/*
+ generate a unix timestamp
+*/
+static time_t gen_timet(void)
+{
+ if (gen_chance(30)) return 0;
+ return (time_t)random();
+}
+
+/*
+ generate a unix timestamp
+*/
+static NTTIME gen_nttime(void)
+{
+ NTTIME ret;
+ unix_to_nt_time(&ret, gen_timet());
+ return ret;
+}
+
+/*
+ generate a milliseconds protocol timeout
+*/
+static uint32_t gen_timeout(void)
+{
+ if (gen_chance(98)) return 0;
+ return random() % 50;
+}
+
+/*
+ generate a file allocation size
+*/
+static uint_t gen_alloc_size(void)
+{
+ uint_t ret;
+
+ if (gen_chance(30)) return 0;
+
+ ret = random() % 4*1024*1024;
+ /* give a high chance of a round number */
+ if (gen_chance(60)) {
+ ret &= ~(1024*1024 - 1);
+ }
+ return ret;
+}
+
+/*
+ generate an ea_struct
+*/
+static struct ea_struct gen_ea_struct(void)
+{
+ struct ea_struct ea;
+ const char *names[] = {"EAONE",
+ "",
+ "FOO!",
+ " WITH SPACES ",
+ ".",
+ "AVERYLONGATTRIBUTENAME"};
+ const char *values[] = {"VALUE1",
+ "",
+ "NOT MUCH FOO",
+ " LEADING SPACES ",
+ ":",
+ "ASOMEWHATLONGERATTRIBUTEVALUE"};
+ int i;
+
+ ZERO_STRUCT(ea);
+
+ do {
+ i = gen_int_range(0, ARRAY_SIZE(names)-1);
+ } while (ignore_pattern(names[i]));
+
+ ea.name.s = names[i];
+
+ do {
+ i = gen_int_range(0, ARRAY_SIZE(values)-1);
+ } while (ignore_pattern(values[i]));
+
+ ea.value = data_blob(values[i], strlen(values[i]));
+
+ if (gen_chance(10)) ea.flags = gen_bits_mask(0xFF);
+ ea.flags = 0;
+
+ return ea;
+}
+
+/*
+ generate an ea_struct
+*/
+static struct smb_ea_list gen_ea_list(void)
+{
+ struct smb_ea_list eas;
+ int i;
+ if (options.no_eas) {
+ ZERO_STRUCT(eas);
+ return eas;
+ }
+ eas.num_eas = gen_int_range(0, 3);
+ eas.eas = talloc_array(current_op.mem_ctx, struct ea_struct, eas.num_eas);
+ for (i=0;i<eas.num_eas;i++) {
+ eas.eas[i] = gen_ea_struct();
+ }
+ return eas;
+}
+
+/*
+ the idle function tries to cope with getting an oplock break on a connection, and
+ an operation on another connection blocking until that break is acked
+ we check for operations on all transports in the idle function
+*/
+static void idle_func(struct smb2_transport *transport, void *private)
+{
+ int i, j;
+ for (i=0;i<NSERVERS;i++) {
+ for (j=0;j<NINSTANCES;j++) {
+ if (servers[i].tree[j] &&
+ transport != servers[i].tree[j]->session->transport) {
+ // smb2_transport_process(servers[i].tree[j]->session->transport);
+ }
+ }
+ }
+
+}
+
+
+/*
+ compare NTSTATUS, using checking ignored patterns
+*/
+static bool compare_status(NTSTATUS status1, NTSTATUS status2)
+{
+ if (NT_STATUS_EQUAL(status1, status2)) return true;
+
+ /* one code being an error and the other OK is always an error */
+ if (NT_STATUS_IS_OK(status1) || NT_STATUS_IS_OK(status2)) return false;
+
+ /* if we are ignoring one of the status codes then consider this a match */
+ if (ignore_pattern(nt_errstr(status1)) ||
+ ignore_pattern(nt_errstr(status2))) {
+ return true;
+ }
+ return false;
+}
+
+
+/*
+ check for pending packets on all connections
+*/
+static void check_pending(void)
+{
+ int i, j;
+
+ msleep(20);
+
+ for (j=0;j<NINSTANCES;j++) {
+ for (i=0;i<NSERVERS;i++) {
+ // smb2_transport_process(servers[i].tree[j]->session->transport);
+ }
+ }
+}
+
+/*
+ check that the same oplock breaks have been received by all instances
+*/
+static bool check_oplocks(const char *call)
+{
+#if 0
+ int i, j;
+ int tries = 0;
+
+again:
+ check_pending();
+
+ for (j=0;j<NINSTANCES;j++) {
+ for (i=1;i<NSERVERS;i++) {
+ if (oplocks[0][j].got_break != oplocks[i][j].got_break ||
+ oplocks[0][j].handle != oplocks[i][j].handle ||
+ oplocks[0][j].level != oplocks[i][j].level) {
+ if (tries++ < 10) goto again;
+ printf("oplock break inconsistent - %d/%d/%d vs %d/%d/%d\n",
+ oplocks[0][j].got_break,
+ oplocks[0][j].handle,
+ oplocks[0][j].level,
+ oplocks[i][j].got_break,
+ oplocks[i][j].handle,
+ oplocks[i][j].level);
+ return false;
+ }
+ }
+ }
+
+ /* if we got a break and closed then remove the handle */
+ for (j=0;j<NINSTANCES;j++) {
+ if (oplocks[0][j].got_break &&
+ oplocks[0][j].do_close) {
+ uint16_t fnums[NSERVERS];
+ for (i=0;i<NSERVERS;i++) {
+ fnums[i] = oplocks[i][j].fnum;
+ }
+ gen_remove_handle(j, fnums);
+ break;
+ }
+ }
+#endif
+ return true;
+}
+
+
+/*
+ check that the same change notify info has been received by all instances
+*/
+static bool check_notifies(const char *call)
+{
+#if 0
+ int i, j;
+ int tries = 0;
+
+again:
+ check_pending();
+
+ for (j=0;j<NINSTANCES;j++) {
+ for (i=1;i<NSERVERS;i++) {
+ int n;
+ union smb_notify not1, not2;
+
+ if (notifies[0][j].notify_count != notifies[i][j].notify_count) {
+ if (tries++ < 10) goto again;
+ printf("Notify count inconsistent %d %d\n",
+ notifies[0][j].notify_count,
+ notifies[i][j].notify_count);
+ return false;
+ }
+
+ if (notifies[0][j].notify_count == 0) continue;
+
+ if (!NT_STATUS_EQUAL(notifies[0][j].status,
+ notifies[i][j].status)) {
+ printf("Notify status mismatch - %s - %s\n",
+ nt_errstr(notifies[0][j].status),
+ nt_errstr(notifies[i][j].status));
+ return false;
+ }
+
+ if (!NT_STATUS_IS_OK(notifies[0][j].status)) {
+ continue;
+ }
+
+ not1 = notifies[0][j].notify;
+ not2 = notifies[i][j].notify;
+
+ for (n=0;n<not1.nttrans.out.num_changes;n++) {
+ if (not1.nttrans.out.changes[n].action !=
+ not2.nttrans.out.changes[n].action) {
+ printf("Notify action %d inconsistent %d %d\n", n,
+ not1.nttrans.out.changes[n].action,
+ not2.nttrans.out.changes[n].action);
+ return false;
+ }
+ if (strcmp(not1.nttrans.out.changes[n].name.s,
+ not2.nttrans.out.changes[n].name.s)) {
+ printf("Notify name %d inconsistent %s %s\n", n,
+ not1.nttrans.out.changes[n].name.s,
+ not2.nttrans.out.changes[n].name.s);
+ return false;
+ }
+ if (not1.nttrans.out.changes[n].name.private_length !=
+ not2.nttrans.out.changes[n].name.private_length) {
+ printf("Notify name length %d inconsistent %d %d\n", n,
+ not1.nttrans.out.changes[n].name.private_length,
+ not2.nttrans.out.changes[n].name.private_length);
+ return false;
+ }
+ }
+ }
+ }
+
+ ZERO_STRUCT(notifies);
+
+#endif
+ return true;
+}
+
+#define GEN_COPY_PARM do { \
+ int i; \
+ for (i=1;i<NSERVERS;i++) { \
+ parm[i] = parm[0]; \
+ } \
+} while (0)
+
+#define GEN_CALL(call) do { \
+ int i; \
+ ZERO_STRUCT(oplocks); \
+ ZERO_STRUCT(notifies); \
+ for (i=0;i<NSERVERS;i++) { \
+ struct smb2_tree *tree = servers[i].tree[instance]; \
+ status[i] = call; \
+ } \
+ current_op.status = status[0]; \
+ for (i=1;i<NSERVERS;i++) { \
+ if (!compare_status(status[i], status[0])) { \
+ printf("status different in %s - %s %s\n", #call, \
+ nt_errstr(status[0]), nt_errstr(status[i])); \
+ return false; \
+ } \
+ } \
+ if (!check_oplocks(#call)) return false; \
+ if (!check_notifies(#call)) return false; \
+ if (!NT_STATUS_IS_OK(status[0])) { \
+ return true; \
+ } \
+} while(0)
+
+#define ADD_HANDLE(name, field) do { \
+ struct smb2_handle handles[NSERVERS]; \
+ int i; \
+ for (i=0;i<NSERVERS;i++) { \
+ handles[i] = parm[i].field; \
+ } \
+ gen_add_handle(instance, name, handles); \
+} while(0)
+
+#define REMOVE_HANDLE(field) do { \
+ struct smb2_handle handles[NSERVERS]; \
+ int i; \
+ for (i=0;i<NSERVERS;i++) { \
+ handles[i] = parm[i].field; \
+ } \
+ gen_remove_handle(instance, handles); \
+} while(0)
+
+#define GEN_SET_FNUM(field) do { \
+ int i; \
+ for (i=0;i<NSERVERS;i++) { \
+ parm[i].field = gen_lookup_handle(i, parm[i].field.data[0]); \
+ } \
+} while(0)
+
+#define CHECK_EQUAL(field) do { \
+ if (parm[0].field != parm[1].field && !ignore_pattern(#field)) { \
+ printf("Mismatch in %s - 0x%llx 0x%llx\n", #field, \
+ (unsigned long long)parm[0].field, (unsigned long long)parm[1].field); \
+ return false; \
+ } \
+} while(0)
+
+#define CHECK_ATTRIB(field) do { \
+ if (!options.mask_indexing) { \
+ CHECK_EQUAL(field); \
+ } else if ((~FILE_ATTRIBUTE_NONINDEXED & parm[0].field) != (~FILE_ATTRIBUTE_NONINDEXED & parm[1].field) && !ignore_pattern(#field)) { \
+ printf("Mismatch in %s - 0x%x 0x%x\n", #field, \
+ (int)parm[0].field, (int)parm[1].field); \
+ return false; \
+ } \
+} while(0)
+
+#define CHECK_WSTR_EQUAL(field) do { \
+ if ((!parm[0].field.s && parm[1].field.s) || (parm[0].field.s && !parm[1].field.s)) { \
+ printf("%s is NULL!\n", #field); \
+ return false; \
+ } \
+ if (parm[0].field.s && strcmp(parm[0].field.s, parm[1].field.s) != 0 && !ignore_pattern(#field)) { \
+ printf("Mismatch in %s - %s %s\n", #field, \
+ parm[0].field.s, parm[1].field.s); \
+ return false; \
+ } \
+ CHECK_EQUAL(field.private_length); \
+} while(0)
+
+#define CHECK_BLOB_EQUAL(field) do { \
+ if (memcmp(parm[0].field.data, parm[1].field.data, parm[0].field.length) != 0 && !ignore_pattern(#field)) { \
+ printf("Mismatch in %s\n", #field); \
+ return false; \
+ } \
+ CHECK_EQUAL(field.length); \
+} while(0)
+
+#define CHECK_TIMES_EQUAL(field) do { \
+ if (labs(parm[0].field - parm[1].field) > time_skew() && \
+ !ignore_pattern(#field)) { \
+ printf("Mismatch in %s - 0x%x 0x%x\n", #field, \
+ (int)parm[0].field, (int)parm[1].field); \
+ return false; \
+ } \
+} while(0)
+
+#define CHECK_NTTIMES_EQUAL(field) do { \
+ if (labs(nt_time_to_unix(parm[0].field) - \
+ nt_time_to_unix(parm[1].field)) > time_skew() && \
+ !ignore_pattern(#field)) { \
+ printf("Mismatch in %s - 0x%x 0x%x\n", #field, \
+ (int)nt_time_to_unix(parm[0].field), \
+ (int)nt_time_to_unix(parm[1].field)); \
+ return false; \
+ } \
+} while(0)
+
+/*
+ generate ntcreatex operations
+*/
+static bool handler_create(int instance)
+{
+ struct smb2_create parm[NSERVERS];
+ NTSTATUS status[NSERVERS];
+
+ ZERO_STRUCT(parm[0]);
+ parm[0].in.security_flags = gen_bits_levels(3, 90, 0x0, 70, 0x3, 100, 0xFF);
+ parm[0].in.oplock_level = gen_bits_levels(3, 90, 0x0, 70, 0x9, 100, 0xFF);
+ parm[0].in.impersonation_level = gen_bits_levels(3, 90, 0x0, 70, 0x3, 100, 0xFFFFFFFF);
+ parm[0].in.create_flags = gen_bits_levels(2, 90, 0x0, 100, 0xFFFFFFFF);
+ if (gen_chance(2)) {
+ parm[0].in.create_flags |= gen_bits_mask(0xFFFFFFFF);
+ }
+ parm[0].in.reserved = gen_bits_levels(2, 95, 0x0, 100, 0xFFFFFFFF);
+ if (gen_chance(2)) {
+ parm[0].in.reserved |= gen_bits_mask(0xFFFFFFFF);
+ }
+ parm[0].in.desired_access = gen_access_mask();
+ parm[0].in.file_attributes = gen_attrib();
+ parm[0].in.share_access = gen_bits_mask2(0x7, 0xFFFFFFFF);
+ parm[0].in.create_disposition = gen_open_disp();
+ parm[0].in.create_options = gen_create_options();
+ parm[0].in.fname = gen_fname_open(instance);
+ parm[0].in.eas = gen_ea_list();
+
+ if (!options.use_oplocks) {
+ /* mask out oplocks */
+ parm[0].in.oplock_level = 0;
+ }
+
+ GEN_COPY_PARM;
+ GEN_CALL(smb2_create(tree, current_op.mem_ctx, &parm[i]));
+
+ CHECK_EQUAL(out.oplock_level);
+ CHECK_EQUAL(out.reserved);
+ CHECK_EQUAL(out.create_action);
+ CHECK_NTTIMES_EQUAL(out.create_time);
+ CHECK_NTTIMES_EQUAL(out.access_time);
+ CHECK_NTTIMES_EQUAL(out.write_time);
+ CHECK_NTTIMES_EQUAL(out.change_time);
+ CHECK_EQUAL(out.alloc_size);
+ CHECK_EQUAL(out.size);
+ CHECK_ATTRIB(out.file_attr);
+ CHECK_EQUAL(out.reserved2);
+
+ /* ntcreatex creates a new file handle */
+ ADD_HANDLE(parm[0].in.fname, out.file.handle);
+
+ return true;
+}
+
+/*
+ generate close operations
+*/
+static bool handler_close(int instance)
+{
+ struct smb2_close parm[NSERVERS];
+ NTSTATUS status[NSERVERS];
+
+ ZERO_STRUCT(parm[0]);
+ parm[0].in.file.handle.data[0] = gen_fnum_close(instance);
+ parm[0].in.flags = gen_bits_mask2(0x1, 0xFFFF);
+
+ GEN_COPY_PARM;
+ GEN_SET_FNUM(in.file.handle);
+ GEN_CALL(smb2_close(tree, &parm[i]));
+
+ CHECK_EQUAL(out.flags);
+ CHECK_EQUAL(out._pad);
+ CHECK_NTTIMES_EQUAL(out.create_time);
+ CHECK_NTTIMES_EQUAL(out.access_time);
+ CHECK_NTTIMES_EQUAL(out.write_time);
+ CHECK_NTTIMES_EQUAL(out.change_time);
+ CHECK_EQUAL(out.alloc_size);
+ CHECK_EQUAL(out.size);
+ CHECK_ATTRIB(out.file_attr);
+
+ REMOVE_HANDLE(in.file.handle);
+
+ return true;
+}
+
+/*
+ generate read operations
+*/
+static bool handler_read(int instance)
+{
+ struct smb2_read parm[NSERVERS];
+ NTSTATUS status[NSERVERS];
+
+ parm[0].in.file.handle.data[0] = gen_fnum(instance);
+ parm[0].in.reserved = gen_bits_mask2(0x0, 0xFF);
+ parm[0].in.length = gen_io_count();
+ parm[0].in.offset = gen_offset();
+ parm[0].in.min_count = gen_io_count();
+ parm[0].in.channel = gen_bits_mask2(0x0, 0xFFFFFFFF);
+ parm[0].in.remaining = gen_bits_mask2(0x0, 0xFFFFFFFF);
+ parm[0].in.channel_offset = gen_bits_mask2(0x0, 0xFFFF);
+ parm[0].in.channel_length = gen_bits_mask2(0x0, 0xFFFF);
+
+ GEN_COPY_PARM;
+ GEN_SET_FNUM(in.file.handle);
+ GEN_CALL(smb2_read(tree, current_op.mem_ctx, &parm[i]));
+
+ CHECK_EQUAL(out.remaining);
+ CHECK_EQUAL(out.reserved);
+ CHECK_EQUAL(out.data.length);
+
+ return true;
+}
+
+/*
+ generate write operations
+*/
+static bool handler_write(int instance)
+{
+ struct smb2_write parm[NSERVERS];
+ NTSTATUS status[NSERVERS];
+
+ parm[0].in.file.handle.data[0] = gen_fnum(instance);
+ parm[0].in.offset = gen_offset();
+ parm[0].in.unknown1 = gen_bits_mask2(0, 0xFFFFFFFF);
+ parm[0].in.unknown2 = gen_bits_mask2(0, 0xFFFFFFFF);
+ parm[0].in.data = data_blob_talloc(current_op.mem_ctx, NULL,
+ gen_io_count());
+
+ GEN_COPY_PARM;
+ GEN_SET_FNUM(in.file.handle);
+ GEN_CALL(smb2_write(tree, &parm[i]));
+
+ CHECK_EQUAL(out._pad);
+ CHECK_EQUAL(out.nwritten);
+ CHECK_EQUAL(out.unknown1);
+
+ return true;
+}
+
+/*
+ generate lockingx operations
+*/
+static bool handler_lock(int instance)
+{
+ struct smb2_lock parm[NSERVERS];
+ NTSTATUS status[NSERVERS];
+ int n;
+
+ parm[0].level = RAW_LOCK_LOCKX;
+ parm[0].in.file.handle.data[0] = gen_fnum(instance);
+ parm[0].in.lock_count = gen_lock_count();
+ parm[0].in.reserved = gen_bits_mask2(0, 0xFFFFFFFF);
+
+ parm[0].in.locks = talloc_array(current_op.mem_ctx,
+ struct smb2_lock_element,
+ parm[0].in.lock_count);
+ for (n=0;n<parm[0].in.lock_count;n++) {
+ parm[0].in.locks[n].offset = gen_offset();
+ parm[0].in.locks[n].length = gen_io_count();
+ /* don't yet cope with async replies */
+ parm[0].in.locks[n].flags = gen_lock_flags() |
+ SMB2_LOCK_FLAG_FAIL_IMMEDIATELY;
+ parm[0].in.locks[n].reserved = gen_bits_mask2(0x0, 0xFFFFFFFF);
+ }
+
+ GEN_COPY_PARM;
+ GEN_SET_FNUM(in.file.handle);
+ GEN_CALL(smb2_lock(tree, &parm[i]));
+
+ return true;
+}
+
+/*
+ generate flush operations
+*/
+static bool handler_flush(int instance)
+{
+ struct smb2_flush parm[NSERVERS];
+ NTSTATUS status[NSERVERS];
+
+ ZERO_STRUCT(parm[0]);
+ parm[0].in.file.handle.data[0] = gen_fnum(instance);
+ parm[0].in.reserved1 = gen_bits_mask2(0x0, 0xFFFF);
+ parm[0].in.reserved2 = gen_bits_mask2(0x0, 0xFFFFFFFF);
+
+ GEN_COPY_PARM;
+ GEN_SET_FNUM(in.file.handle);
+ GEN_CALL(smb2_flush(tree, &parm[i]));
+
+ CHECK_EQUAL(out.reserved);
+
+ return true;
+}
+
+/*
+ generate echo operations
+*/
+static bool handler_echo(int instance)
+{
+ NTSTATUS status[NSERVERS];
+
+ GEN_CALL(smb2_keepalive(tree->session->transport));
+
+ return true;
+}
+
+
+
+/*
+ generate a fileinfo query structure
+*/
+static void gen_fileinfo(int instance, union smb_fileinfo *info)
+{
+ int i;
+ #define LVL(v) {RAW_FILEINFO_ ## v, "RAW_FILEINFO_" #v}
+ struct {
+ enum smb_fileinfo_level level;
+ const char *name;
+ } levels[] = {
+ LVL(BASIC_INFORMATION),
+ LVL(STANDARD_INFORMATION), LVL(INTERNAL_INFORMATION), LVL(EA_INFORMATION),
+ LVL(ACCESS_INFORMATION), LVL(NAME_INFORMATION), LVL(POSITION_INFORMATION),
+ LVL(MODE_INFORMATION), LVL(ALIGNMENT_INFORMATION), LVL(SMB2_ALL_INFORMATION),
+ LVL(ALT_NAME_INFORMATION), LVL(STREAM_INFORMATION), LVL(COMPRESSION_INFORMATION),
+ LVL(NETWORK_OPEN_INFORMATION), LVL(ATTRIBUTE_TAG_INFORMATION),
+ LVL(SMB2_ALL_EAS), LVL(SMB2_ALL_INFORMATION),
+ };
+ do {
+ i = gen_int_range(0, ARRAY_SIZE(levels)-1);
+ } while (ignore_pattern(levels[i].name));
+
+ info->generic.level = levels[i].level;
+}
+
+/*
+ compare returned fileinfo structures
+*/
+static bool cmp_fileinfo(int instance,
+ union smb_fileinfo parm[NSERVERS],
+ NTSTATUS status[NSERVERS])
+{
+ int i;
+
+ switch (parm[0].generic.level) {
+ case RAW_FILEINFO_GENERIC:
+ return false;
+
+ case RAW_FILEINFO_BASIC_INFORMATION:
+ CHECK_NTTIMES_EQUAL(basic_info.out.create_time);
+ CHECK_NTTIMES_EQUAL(basic_info.out.access_time);
+ CHECK_NTTIMES_EQUAL(basic_info.out.write_time);
+ CHECK_NTTIMES_EQUAL(basic_info.out.change_time);
+ CHECK_ATTRIB(basic_info.out.attrib);
+ break;
+
+ case RAW_FILEINFO_STANDARD_INFORMATION:
+ CHECK_EQUAL(standard_info.out.alloc_size);
+ CHECK_EQUAL(standard_info.out.size);
+ CHECK_EQUAL(standard_info.out.nlink);
+ CHECK_EQUAL(standard_info.out.delete_pending);
+ CHECK_EQUAL(standard_info.out.directory);
+ break;
+
+ case RAW_FILEINFO_EA_INFORMATION:
+ CHECK_EQUAL(ea_info.out.ea_size);
+ break;
+
+ case RAW_FILEINFO_NAME_INFORMATION:
+ CHECK_WSTR_EQUAL(name_info.out.fname);
+ break;
+
+ case RAW_FILEINFO_ALT_NAME_INFORMATION:
+ CHECK_WSTR_EQUAL(alt_name_info.out.fname);
+ break;
+
+ case RAW_FILEINFO_STREAM_INFORMATION:
+ CHECK_EQUAL(stream_info.out.num_streams);
+ for (i=0;i<parm[0].stream_info.out.num_streams;i++) {
+ CHECK_EQUAL(stream_info.out.streams[i].size);
+ CHECK_EQUAL(stream_info.out.streams[i].alloc_size);
+ CHECK_WSTR_EQUAL(stream_info.out.streams[i].stream_name);
+ }
+ break;
+
+ case RAW_FILEINFO_COMPRESSION_INFORMATION:
+ CHECK_EQUAL(compression_info.out.compressed_size);
+ CHECK_EQUAL(compression_info.out.format);
+ CHECK_EQUAL(compression_info.out.unit_shift);
+ CHECK_EQUAL(compression_info.out.chunk_shift);
+ CHECK_EQUAL(compression_info.out.cluster_shift);
+ break;
+
+ case RAW_FILEINFO_INTERNAL_INFORMATION:
+ CHECK_EQUAL(internal_information.out.file_id);
+ break;
+
+ case RAW_FILEINFO_ACCESS_INFORMATION:
+ CHECK_EQUAL(access_information.out.access_flags);
+ break;
+
+ case RAW_FILEINFO_POSITION_INFORMATION:
+ CHECK_EQUAL(position_information.out.position);
+ break;
+
+ case RAW_FILEINFO_MODE_INFORMATION:
+ CHECK_EQUAL(mode_information.out.mode);
+ break;
+
+ case RAW_FILEINFO_ALIGNMENT_INFORMATION:
+ CHECK_EQUAL(alignment_information.out.alignment_requirement);
+ break;
+
+ case RAW_FILEINFO_NETWORK_OPEN_INFORMATION:
+ CHECK_NTTIMES_EQUAL(network_open_information.out.create_time);
+ CHECK_NTTIMES_EQUAL(network_open_information.out.access_time);
+ CHECK_NTTIMES_EQUAL(network_open_information.out.write_time);
+ CHECK_NTTIMES_EQUAL(network_open_information.out.change_time);
+ CHECK_EQUAL(network_open_information.out.alloc_size);
+ CHECK_EQUAL(network_open_information.out.size);
+ CHECK_ATTRIB(network_open_information.out.attrib);
+ break;
+
+ case RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION:
+ CHECK_ATTRIB(attribute_tag_information.out.attrib);
+ CHECK_EQUAL(attribute_tag_information.out.reparse_tag);
+ break;
+
+ case RAW_FILEINFO_ALL_INFORMATION:
+ case RAW_FILEINFO_SMB2_ALL_INFORMATION:
+ CHECK_NTTIMES_EQUAL(all_info2.out.create_time);
+ CHECK_NTTIMES_EQUAL(all_info2.out.access_time);
+ CHECK_NTTIMES_EQUAL(all_info2.out.write_time);
+ CHECK_NTTIMES_EQUAL(all_info2.out.change_time);
+ CHECK_ATTRIB(all_info2.out.attrib);
+ CHECK_EQUAL(all_info2.out.unknown1);
+ CHECK_EQUAL(all_info2.out.alloc_size);
+ CHECK_EQUAL(all_info2.out.size);
+ CHECK_EQUAL(all_info2.out.nlink);
+ CHECK_EQUAL(all_info2.out.delete_pending);
+ CHECK_EQUAL(all_info2.out.directory);
+ CHECK_EQUAL(all_info2.out.file_id);
+ CHECK_EQUAL(all_info2.out.ea_size);
+ CHECK_EQUAL(all_info2.out.access_mask);
+ CHECK_EQUAL(all_info2.out.position);
+ CHECK_EQUAL(all_info2.out.mode);
+ CHECK_EQUAL(all_info2.out.alignment_requirement);
+ CHECK_WSTR_EQUAL(all_info2.out.fname);
+ break;
+
+ case RAW_FILEINFO_SMB2_ALL_EAS:
+ CHECK_EQUAL(all_eas.out.num_eas);
+ for (i=0;i<parm[0].all_eas.out.num_eas;i++) {
+ CHECK_EQUAL(all_eas.out.eas[i].flags);
+ CHECK_WSTR_EQUAL(all_eas.out.eas[i].name);
+ CHECK_BLOB_EQUAL(all_eas.out.eas[i].value);
+ }
+ break;
+
+ /* Unhandled levels */
+
+ case RAW_FILEINFO_SEC_DESC:
+ case RAW_FILEINFO_EA_LIST:
+ case RAW_FILEINFO_UNIX_BASIC:
+ case RAW_FILEINFO_UNIX_LINK:
+ case RAW_FILEINFO_UNIX_INFO2:
+ break;
+ }
+
+ return true;
+}
+
+/*
+ generate qfileinfo operations
+*/
+static bool handler_qfileinfo(int instance)
+{
+ union smb_fileinfo parm[NSERVERS];
+ NTSTATUS status[NSERVERS];
+
+ parm[0].generic.in.file.handle.data[0] = gen_fnum(instance);
+
+ gen_fileinfo(instance, &parm[0]);
+
+ GEN_COPY_PARM;
+ GEN_SET_FNUM(generic.in.file.handle);
+ GEN_CALL(smb2_getinfo_file(tree, current_op.mem_ctx, &parm[i]));
+
+ return cmp_fileinfo(instance, parm, status);
+}
+
+
+/*
+ generate a fileinfo query structure
+*/
+static void gen_setfileinfo(int instance, union smb_setfileinfo *info)
+{
+ int i;
+ #undef LVL
+ #define LVL(v) {RAW_SFILEINFO_ ## v, "RAW_SFILEINFO_" #v}
+ struct {
+ enum smb_setfileinfo_level level;
+ const char *name;
+ } levels[] = {
+ LVL(BASIC_INFORMATION),
+ LVL(RENAME_INFORMATION), LVL(DISPOSITION_INFORMATION),
+ LVL(POSITION_INFORMATION), LVL(MODE_INFORMATION),
+ LVL(ALLOCATION_INFORMATION), LVL(END_OF_FILE_INFORMATION),
+ LVL(1023), LVL(1025), LVL(1029), LVL(1032), LVL(1039), LVL(1040)
+ };
+ do {
+ i = gen_int_range(0, ARRAY_SIZE(levels)-1);
+ } while (ignore_pattern(levels[i].name));
+
+ info->generic.level = levels[i].level;
+
+ switch (info->generic.level) {
+ case RAW_SFILEINFO_BASIC_INFORMATION:
+ info->basic_info.in.create_time = gen_nttime();
+ info->basic_info.in.access_time = gen_nttime();
+ info->basic_info.in.write_time = gen_nttime();
+ info->basic_info.in.change_time = gen_nttime();
+ info->basic_info.in.attrib = gen_attrib();
+ break;
+ case RAW_SFILEINFO_DISPOSITION_INFORMATION:
+ info->disposition_info.in.delete_on_close = gen_bool();
+ break;
+ case RAW_SFILEINFO_ALLOCATION_INFORMATION:
+ info->allocation_info.in.alloc_size = gen_alloc_size();
+ break;
+ case RAW_SFILEINFO_END_OF_FILE_INFORMATION:
+ 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);
+ break;
+ case RAW_SFILEINFO_POSITION_INFORMATION:
+ info->position_information.in.position = gen_offset();
+ break;
+ case RAW_SFILEINFO_MODE_INFORMATION:
+ info->mode_information.in.mode = gen_bits_mask(0xFFFFFFFF);
+ break;
+ case RAW_SFILEINFO_GENERIC:
+ case RAW_SFILEINFO_SEC_DESC:
+ case RAW_SFILEINFO_1023:
+ case RAW_SFILEINFO_1025:
+ case RAW_SFILEINFO_1029:
+ case RAW_SFILEINFO_1032:
+ case RAW_SFILEINFO_1039:
+ case RAW_SFILEINFO_1040:
+ /* Untested */
+ break;
+ }
+}
+
+/*
+ generate setfileinfo operations
+*/
+static bool handler_sfileinfo(int instance)
+{
+ union smb_setfileinfo parm[NSERVERS];
+ NTSTATUS status[NSERVERS];
+
+ parm[0].generic.in.file.fnum = gen_fnum(instance);
+
+ gen_setfileinfo(instance, &parm[0]);
+
+ GEN_COPY_PARM;
+ GEN_SET_FNUM(generic.in.file.handle);
+ GEN_CALL(smb2_setinfo_file(tree, &parm[i]));
+
+ return true;
+}
+
+/*
+ wipe any relevant files
+*/
+static void wipe_files(void)
+{
+ int i;
+ NTSTATUS status;
+
+ for (i=0;i<NSERVERS;i++) {
+ int n = smb2_deltree(servers[i].tree[0], "gentest");
+ if (n == -1) {
+ printf("Failed to wipe tree on server %d\n", i);
+ exit(1);
+ }
+ status = smb2_util_mkdir(servers[i].tree[0], "gentest");
+ if (NT_STATUS_IS_ERR(status)) {
+ printf("Failed to create gentest on server %d - %s\n", i, nt_errstr(status));
+ exit(1);
+ }
+ if (n > 0) {
+ printf("Deleted %d files on server %d\n", n, i);
+ }
+ }
+}
+
+/*
+ dump the current seeds - useful for continuing a backtrack
+*/
+static void dump_seeds(void)
+{
+ int i;
+ FILE *f;
+
+ if (!options.seeds_file) {
+ return;
+ }
+ f = fopen("seeds.tmp", "w");
+ if (!f) return;
+
+ for (i=0;i<options.numops;i++) {
+ fprintf(f, "%u\n", op_parms[i].seed);
+ }
+ fclose(f);
+ rename("seeds.tmp", options.seeds_file);
+}
+
+
+
+/*
+ the list of top-level operations that we will generate
+*/
+static struct {
+ const char *name;
+ bool (*handler)(int instance);
+ int count, success_count;
+} gen_ops[] = {
+ {"CREATE", handler_create},
+ {"CLOSE", handler_close},
+ {"READ", handler_read},
+ {"WRITE", handler_write},
+ {"LOCK", handler_lock},
+ {"FLUSH", handler_flush},
+ {"ECHO", handler_echo},
+ {"QFILEINFO", handler_qfileinfo},
+ {"SFILEINFO", handler_sfileinfo},
+};
+
+
+/*
+ run the test with the current set of op_parms parameters
+ return the number of operations that completed successfully
+*/
+static int run_test(struct event_context *ev, struct loadparm_context *lp_ctx)
+{
+ int op, i;
+
+ if (!connect_servers(ev, lp_ctx)) {
+ printf("Failed to connect to servers\n");
+ exit(1);
+ }
+
+ dump_seeds();
+
+ /* wipe any leftover files from old runs */
+ wipe_files();
+
+ /* reset the open handles array */
+ memset(open_handles, 0, options.max_open_handles * sizeof(open_handles[0]));
+ num_open_handles = 0;
+
+ for (i=0;i<ARRAY_SIZE(gen_ops);i++) {
+ gen_ops[i].count = 0;
+ gen_ops[i].success_count = 0;
+ }
+
+ for (op=0; op<options.numops; op++) {
+ int instance, which_op;
+ bool ret;
+
+ if (op_parms[op].disabled) continue;
+
+ srandom(op_parms[op].seed);
+
+ instance = gen_int_range(0, NINSTANCES-1);
+
+ /* generate a non-ignored operation */
+ do {
+ which_op = gen_int_range(0, ARRAY_SIZE(gen_ops)-1);
+ } while (ignore_pattern(gen_ops[which_op].name));
+
+ DEBUG(3,("Generating op %s on instance %d\n",
+ gen_ops[which_op].name, instance));
+
+ current_op.seed = op_parms[op].seed;
+ current_op.opnum = op;
+ current_op.name = gen_ops[which_op].name;
+ current_op.status = NT_STATUS_OK;
+ current_op.mem_ctx = talloc_named(NULL, 0, "%s", current_op.name);
+
+ ret = gen_ops[which_op].handler(instance);
+
+ talloc_free(current_op.mem_ctx);
+
+ gen_ops[which_op].count++;
+ if (NT_STATUS_IS_OK(current_op.status)) {
+ gen_ops[which_op].success_count++;
+ }
+
+ if (!ret) {
+ printf("Failed at operation %d - %s\n",
+ op, gen_ops[which_op].name);
+ return op;
+ }
+
+ if (op % 100 == 0) {
+ printf("%d\n", op);
+ }
+ }
+
+ for (i=0;i<ARRAY_SIZE(gen_ops);i++) {
+ printf("Op %-10s got %d/%d success\n",
+ gen_ops[i].name,
+ gen_ops[i].success_count,
+ gen_ops[i].count);
+ }
+
+ return op;
+}
+
+/*
+ perform a backtracking analysis of the minimal set of operations
+ to generate an error
+*/
+static void backtrack_analyze(struct event_context *ev,
+ struct loadparm_context *lp_ctx)
+{
+ int chunk, ret;
+
+ chunk = options.numops / 2;
+
+ do {
+ int base;
+ for (base=0;
+ chunk > 0 && base+chunk < options.numops && options.numops > 1; ) {
+ int i, max;
+
+ chunk = MIN(chunk, options.numops / 2);
+
+ /* mark this range as disabled */
+ max = MIN(options.numops, base+chunk);
+ for (i=base;i<max; i++) {
+ op_parms[i].disabled = true;
+ }
+ printf("Testing %d ops with %d-%d disabled\n",
+ options.numops, base, max-1);
+ ret = run_test(ev, lp_ctx);
+ printf("Completed %d of %d ops\n", ret, options.numops);
+ for (i=base;i<max; i++) {
+ op_parms[i].disabled = false;
+ }
+ if (ret == options.numops) {
+ /* this chunk is needed */
+ base += chunk;
+ } else if (ret < base) {
+ printf("damn - inconsistent errors! found early error\n");
+ options.numops = ret+1;
+ base = 0;
+ } else {
+ /* it failed - this chunk isn't needed for a failure */
+ memmove(&op_parms[base], &op_parms[max],
+ sizeof(op_parms[0]) * (options.numops - max));
+ options.numops = (ret+1) - (max - base);
+ }
+ }
+
+ if (chunk == 2) {
+ chunk = 1;
+ } else {
+ chunk *= 0.4;
+ }
+
+ if (options.analyze_continuous && chunk == 0 && options.numops != 1) {
+ chunk = 1;
+ }
+ } while (chunk > 0);
+
+ printf("Reduced to %d ops\n", options.numops);
+ ret = run_test(ev, lp_ctx);
+ if (ret != options.numops - 1) {
+ printf("Inconsistent result? ret=%d numops=%d\n", ret, options.numops);
+ }
+}
+
+/*
+ start the main gentest process
+*/
+static bool start_gentest(struct event_context *ev,
+ struct loadparm_context *lp_ctx)
+{
+ int op;
+ int ret;
+
+ /* allocate the open_handles array */
+ open_handles = calloc(options.max_open_handles, sizeof(open_handles[0]));
+
+ srandom(options.seed);
+ op_parms = calloc(options.numops, sizeof(op_parms[0]));
+
+ /* generate the seeds - after this everything is deterministic */
+ if (options.use_preset_seeds) {
+ int numops;
+ char **preset = file_lines_load(options.seeds_file, &numops, NULL);
+ if (!preset) {
+ printf("Failed to load %s - %s\n", options.seeds_file, strerror(errno));
+ exit(1);
+ }
+ if (numops < options.numops) {
+ options.numops = numops;
+ }
+ for (op=0;op<options.numops;op++) {
+ if (!preset[op]) {
+ printf("Not enough seeds in %s\n", options.seeds_file);
+ exit(1);
+ }
+ op_parms[op].seed = atoi(preset[op]);
+ }
+ printf("Loaded %d seeds from %s\n", options.numops, options.seeds_file);
+ } else {
+ for (op=0; op<options.numops; op++) {
+ op_parms[op].seed = random();
+ }
+ }
+
+ ret = run_test(ev, lp_ctx);
+
+ if (ret != options.numops && options.analyze) {
+ options.numops = ret+1;
+ backtrack_analyze(ev, lp_ctx);
+ } else if (options.analyze_always) {
+ backtrack_analyze(ev, lp_ctx);
+ } else if (options.analyze_continuous) {
+ while (run_test(ev, lp_ctx) == options.numops) ;
+ }
+
+ return ret == options.numops;
+}
+
+
+static void usage(poptContext pc)
+{
+ printf(
+"Usage:\n\
+ gentest //server1/share1 //server2/share2 [options..]\n\
+");
+ poptPrintUsage(pc, stdout, 0);
+}
+
+/**
+ split a UNC name into server and share names
+*/
+static bool split_unc_name(const char *unc, char **server, char **share)
+{
+ char *p = strdup(unc);
+ if (!p) return false;
+ all_string_sub(p, "\\", "/", 0);
+ if (strncmp(p, "//", 2) != 0) return false;
+
+ (*server) = p+2;
+ p = strchr(*server, '/');
+ if (!p) return false;
+
+ *p = 0;
+ (*share) = p+1;
+
+ return true;
+}
+
+
+
+/****************************************************************************
+ main program
+****************************************************************************/
+ int main(int argc, char *argv[])
+{
+ int opt;
+ int i, username_count=0;
+ bool ret;
+ char *ignore_file=NULL;
+ struct event_context *ev;
+ 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]" },
+ {"maskindexing", 0, POPT_ARG_NONE, &options.mask_indexing, 0, "mask out the indexed file attrib", NULL},
+ {"noeas", 0, POPT_ARG_NONE, &options.no_eas, 0, "don't use extended attributes", NULL},
+ POPT_COMMON_SAMBA
+ POPT_COMMON_CONNECTION
+ POPT_COMMON_CREDENTIALS
+ POPT_COMMON_VERSION
+ { NULL }
+ };
+
+ memset(&bad_smb2_handle, 0xFF, sizeof(bad_smb2_handle));
+
+ setlinebuf(stdout);
+ options.seed = time(NULL);
+ options.numops = 1000;
+ options.max_open_handles = 20;
+ options.seeds_file = "gentest_seeds.dat";
+
+ pc = poptGetContext("gentest", argc, (const char **) argv, long_options,
+ POPT_CONTEXT_KEEP_FIRST);
+
+ 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);
+
+ 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(pc);
+ exit(1);
+ }
+ cli_credentials_parse_string(servers[username_count].credentials, poptGetOptArg(pc), CRED_SPECIFIED);
+ username_count++;
+ break;
+ }
+ }
+
+ 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;
+ }
+ }
+
+ 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(pc);
+ return -1;
+ }
+ if (username_count == 1) {
+ servers[1].credentials = servers[0].credentials;
+ }
+
+ printf("seed=%u\n", options.seed);
+
+ ev = event_context_init(talloc_autofree_context());
+
+ gensec_init(lp_ctx);
+
+ ret = start_gentest(ev, lp_ctx);
+
+ if (ret) {
+ printf("gentest completed - no errors\n");
+ } else {
+ printf("gentest failed\n");
+ }
+
+ return ret?0:-1;
+}
diff --git a/source4/torture/ldap/cldap.c b/source4/torture/ldap/cldap.c
index dbe9d2f9a4..5d4acd581b 100644
--- a/source4/torture/ldap/cldap.c
+++ b/source4/torture/ldap/cldap.c
@@ -38,18 +38,21 @@
*/
static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest)
{
- struct cldap_socket *cldap = cldap_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ struct cldap_socket *cldap;
NTSTATUS status;
struct cldap_netlogon search, empty_search;
- union nbt_cldap_netlogon n1;
+ struct netlogon_samlogon_response n1;
struct GUID guid;
int i;
+ cldap = cldap_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
ZERO_STRUCT(search);
search.in.dest_address = dest;
search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
search.in.acct_control = -1;
- search.in.version = 6;
+ search.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX;
+ search.in.map_response = true;
empty_search = search;
@@ -61,7 +64,7 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest)
n1 = search.out.netlogon;
search.in.user = "Administrator";
- search.in.realm = n1.logon5.dns_domain;
+ search.in.realm = n1.nt5_ex.dns_domain;
search.in.host = "__cldap_torture__";
printf("Scanning for netlogon levels\n");
@@ -80,7 +83,8 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest)
CHECK_STATUS(status, NT_STATUS_OK);
}
- search.in.version = 0x20000006;
+ search.in.version = NETLOGON_NT_VERSION_5|NETLOGON_NT_VERSION_5EX|NETLOGON_NT_VERSION_IP;
+
status = cldap_netlogon(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
@@ -89,8 +93,8 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest)
search.in.user = NULL;
status = cldap_netlogon(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_STRING(search.out.netlogon.logon5.user_name, "");
- CHECK_VAL(search.out.netlogon.logon5.type, NETLOGON_RESPONSE_FROM_PDC2);
+ CHECK_STRING(search.out.netlogon.nt5_ex.user_name, "");
+ CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX);
printf("Trying with User=Administrator\n");
@@ -98,10 +102,10 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest)
status = cldap_netlogon(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_STRING(search.out.netlogon.logon5.user_name, search.in.user);
- CHECK_VAL(search.out.netlogon.logon5.type, NETLOGON_RESPONSE_FROM_PDC_USER);
+ CHECK_STRING(search.out.netlogon.nt5_ex.user_name, search.in.user);
+ CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX);
- search.in.version = 6;
+ search.in.version = NETLOGON_NT_VERSION_5;
status = cldap_netlogon(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
@@ -110,8 +114,8 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest)
search.in.user = NULL;
status = cldap_netlogon(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_STRING(search.out.netlogon.logon5.user_name, "");
- CHECK_VAL(search.out.netlogon.logon5.type, NETLOGON_RESPONSE_FROM_PDC2);
+ CHECK_STRING(search.out.netlogon.nt5_ex.user_name, "");
+ CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE);
printf("Trying with User=Administrator\n");
@@ -119,16 +123,18 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest)
status = cldap_netlogon(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_STRING(search.out.netlogon.logon5.user_name, search.in.user);
- CHECK_VAL(search.out.netlogon.logon5.type, NETLOGON_RESPONSE_FROM_PDC_USER);
+ CHECK_STRING(search.out.netlogon.nt5_ex.user_name, search.in.user);
+ CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN);
+
+ search.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX;
printf("Trying with a GUID\n");
search.in.realm = NULL;
- search.in.domain_guid = GUID_string(tctx, &n1.logon5.domain_uuid);
+ search.in.domain_guid = GUID_string(tctx, &n1.nt5_ex.domain_uuid);
status = cldap_netlogon(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_VAL(search.out.netlogon.logon5.type, NETLOGON_RESPONSE_FROM_PDC_USER);
- CHECK_STRING(GUID_string(tctx, &search.out.netlogon.logon5.domain_uuid), search.in.domain_guid);
+ CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX);
+ CHECK_STRING(GUID_string(tctx, &search.out.netlogon.nt5_ex.domain_uuid), search.in.domain_guid);
printf("Trying with a incorrect GUID\n");
guid = GUID_random();
@@ -138,33 +144,54 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest)
CHECK_STATUS(status, NT_STATUS_NOT_FOUND);
printf("Trying with a AAC\n");
- search.in.acct_control = 0x180;
- search.in.realm = n1.logon5.dns_domain;
+ search.in.acct_control = ACB_WSTRUST|ACB_SVRTRUST;
+ search.in.realm = n1.nt5_ex.dns_domain;
+ status = cldap_netlogon(cldap, tctx, &search);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX);
+ CHECK_STRING(search.out.netlogon.nt5_ex.user_name, "");
+
+ printf("Trying with a zero AAC\n");
+ search.in.acct_control = 0x0;
+ search.in.realm = n1.nt5_ex.dns_domain;
status = cldap_netlogon(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_VAL(search.out.netlogon.logon5.type, NETLOGON_RESPONSE_FROM_PDC2);
- CHECK_STRING(search.out.netlogon.logon5.user_name, "");
+ CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX);
+ CHECK_STRING(search.out.netlogon.nt5_ex.user_name, "");
+
+ printf("Trying with a zero AAC and user=Administrator\n");
+ search.in.acct_control = 0x0;
+ search.in.user = "Administrator";
+ search.in.realm = n1.nt5_ex.dns_domain;
+ status = cldap_netlogon(cldap, tctx, &search);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX);
+ CHECK_STRING(search.out.netlogon.nt5_ex.user_name, "Administrator");
printf("Trying with a bad AAC\n");
+ search.in.user = NULL;
search.in.acct_control = 0xFF00FF00;
- search.in.realm = n1.logon5.dns_domain;
+ search.in.realm = n1.nt5_ex.dns_domain;
status = cldap_netlogon(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX);
+ CHECK_STRING(search.out.netlogon.nt5_ex.user_name, "");
printf("Trying with a user only\n");
search = empty_search;
search.in.user = "Administrator";
status = cldap_netlogon(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_STRING(search.out.netlogon.logon5.dns_domain, n1.logon5.dns_domain);
- CHECK_STRING(search.out.netlogon.logon5.user_name, search.in.user);
+ CHECK_STRING(search.out.netlogon.nt5_ex.dns_domain, n1.nt5_ex.dns_domain);
+ CHECK_STRING(search.out.netlogon.nt5_ex.user_name, search.in.user);
printf("Trying with just a bad username\n");
search.in.user = "___no_such_user___";
status = cldap_netlogon(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_STRING(search.out.netlogon.logon5.user_name, search.in.user);
- CHECK_STRING(search.out.netlogon.logon5.dns_domain, n1.logon5.dns_domain);
+ CHECK_STRING(search.out.netlogon.nt5_ex.user_name, search.in.user);
+ CHECK_STRING(search.out.netlogon.nt5_ex.dns_domain, n1.nt5_ex.dns_domain);
+ CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN_EX);
printf("Trying with just a bad domain\n");
search = empty_search;
@@ -173,29 +200,29 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest)
CHECK_STATUS(status, NT_STATUS_NOT_FOUND);
printf("Trying with a incorrect domain and correct guid\n");
- search.in.domain_guid = GUID_string(tctx, &n1.logon5.domain_uuid);
+ search.in.domain_guid = GUID_string(tctx, &n1.nt5_ex.domain_uuid);
status = cldap_netlogon(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_STRING(search.out.netlogon.logon5.dns_domain, n1.logon5.dns_domain);
- CHECK_STRING(search.out.netlogon.logon5.user_name, "");
- CHECK_VAL(search.out.netlogon.logon5.type, NETLOGON_RESPONSE_FROM_PDC2);
+ CHECK_STRING(search.out.netlogon.nt5_ex.dns_domain, n1.nt5_ex.dns_domain);
+ CHECK_STRING(search.out.netlogon.nt5_ex.user_name, "");
+ CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX);
printf("Trying with a incorrect domain and incorrect guid\n");
search.in.domain_guid = GUID_string(tctx, &guid);
status = cldap_netlogon(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_NOT_FOUND);
- CHECK_STRING(search.out.netlogon.logon5.dns_domain, n1.logon5.dns_domain);
- CHECK_STRING(search.out.netlogon.logon5.user_name, "");
- CHECK_VAL(search.out.netlogon.logon5.type, NETLOGON_RESPONSE_FROM_PDC2);
+ CHECK_STRING(search.out.netlogon.nt5_ex.dns_domain, n1.nt5_ex.dns_domain);
+ CHECK_STRING(search.out.netlogon.nt5_ex.user_name, "");
+ CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX);
printf("Trying with a incorrect GUID and correct domain\n");
search.in.domain_guid = GUID_string(tctx, &guid);
- search.in.realm = n1.logon5.dns_domain;
+ search.in.realm = n1.nt5_ex.dns_domain;
status = cldap_netlogon(cldap, tctx, &search);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_STRING(search.out.netlogon.logon5.dns_domain, n1.logon5.dns_domain);
- CHECK_STRING(search.out.netlogon.logon5.user_name, "");
- CHECK_VAL(search.out.netlogon.logon5.type, NETLOGON_RESPONSE_FROM_PDC2);
+ CHECK_STRING(search.out.netlogon.nt5_ex.dns_domain, n1.nt5_ex.dns_domain);
+ CHECK_STRING(search.out.netlogon.nt5_ex.user_name, "");
+ CHECK_VAL(search.out.netlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX);
return true;
}
@@ -244,13 +271,15 @@ static void cldap_dump_results(struct cldap_search *search)
*/
static bool test_cldap_generic(struct torture_context *tctx, const char *dest)
{
- struct cldap_socket *cldap = cldap_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ struct cldap_socket *cldap;
NTSTATUS status;
struct cldap_search search;
const char *attrs1[] = { "currentTime", "highestCommittedUSN", NULL };
const char *attrs2[] = { "currentTime", "highestCommittedUSN", "netlogon", NULL };
const char *attrs3[] = { "netlogon", NULL };
+ cldap = cldap_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
ZERO_STRUCT(search);
search.in.dest_address = dest;
search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
diff --git a/source4/torture/ldap/cldapbench.c b/source4/torture/ldap/cldapbench.c
index 83e505e164..df2a5b0551 100644
--- a/source4/torture/ldap/cldapbench.c
+++ b/source4/torture/ldap/cldapbench.c
@@ -51,7 +51,7 @@ static void request_handler(struct cldap_request *req)
*/
static bool bench_cldap(struct torture_context *tctx, const char *address)
{
- struct cldap_socket *cldap = cldap_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ struct cldap_socket *cldap;
int num_sent=0;
struct timeval tv = timeval_current();
bool ret = true;
@@ -59,6 +59,8 @@ static bool bench_cldap(struct torture_context *tctx, const char *address)
struct cldap_netlogon search;
struct bench_state *state;
+ cldap = cldap_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
state = talloc_zero(tctx, struct bench_state);
ZERO_STRUCT(search);
@@ -116,7 +118,7 @@ bool torture_bench_cldap(struct torture_context *torture)
make_nbt_name_server(&name, torture_setting_string(torture, "host", NULL));
/* do an initial name resolution to find its IP */
- status = resolve_name(lp_resolve_context(torture->lp_ctx), &name, torture, &address, event_context_find(torture));
+ status = resolve_name(lp_resolve_context(torture->lp_ctx), &name, torture, &address, torture->ev);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to resolve %s - %s\n",
name.name, nt_errstr(status));
diff --git a/source4/torture/ldap/common.c b/source4/torture/ldap/common.c
index 65b02ed5e8..2c11de729c 100644
--- a/source4/torture/ldap/common.c
+++ b/source4/torture/ldap/common.c
@@ -22,7 +22,7 @@
#include "includes.h"
#include "libcli/ldap/ldap_client.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "torture/ldap/proto.h"
NTSTATUS torture_ldap_bind(struct ldap_connection *conn, const char *userdn, const char *password)
@@ -65,7 +65,7 @@ NTSTATUS torture_ldap_connection(struct torture_context *tctx,
return NT_STATUS_INVALID_PARAMETER;
}
- *conn = ldap4_new_connection(tctx, tctx->lp_ctx, NULL);
+ *conn = ldap4_new_connection(tctx, tctx->lp_ctx, tctx->ev);
status = ldap_connect(*conn, url);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source4/torture/ldap/schema.c b/source4/torture/ldap/schema.c
index 4cfce11eb5..8437e7f79d 100644
--- a/source4/torture/ldap/schema.c
+++ b/source4/torture/ldap/schema.c
@@ -376,7 +376,7 @@ bool torture_ldap_schema(struct torture_context *torture)
url = talloc_asprintf(torture, "ldap://%s/", host);
- ldb = ldb_wrap_connect(torture, torture->lp_ctx, url,
+ ldb = ldb_wrap_connect(torture, torture->ev, torture->lp_ctx, url,
NULL,
cmdline_credentials,
0, NULL);
diff --git a/source4/torture/ldap/uptodatevector.c b/source4/torture/ldap/uptodatevector.c
index cec330b2f6..87b7e09e13 100644
--- a/source4/torture/ldap/uptodatevector.c
+++ b/source4/torture/ldap/uptodatevector.c
@@ -162,7 +162,7 @@ bool torture_ldap_uptodatevector(struct torture_context *torture)
url = talloc_asprintf(torture, "ldap://%s/", host);
if (!url) goto failed;
- ldb = ldb_wrap_connect(torture, torture->lp_ctx, url,
+ ldb = ldb_wrap_connect(torture, torture->ev, torture->lp_ctx, url,
NULL,
cmdline_credentials,
0, NULL);
diff --git a/source4/torture/libnet/domain.c b/source4/torture/libnet/domain.c
index ff1fbcab78..ab7846e5e1 100644
--- a/source4/torture/libnet/domain.c
+++ b/source4/torture/libnet/domain.c
@@ -74,7 +74,6 @@ bool torture_domainopen(struct torture_context *torture)
{
NTSTATUS status;
struct libnet_context *net_ctx;
- struct event_context *evt_ctx;
TALLOC_CTX *mem_ctx;
bool ret = true;
struct policy_handle h;
@@ -82,8 +81,7 @@ bool torture_domainopen(struct torture_context *torture)
mem_ctx = talloc_init("test_domain_open");
- evt_ctx = event_context_find(torture);
- net_ctx = libnet_context_init(evt_ctx, torture->lp_ctx);
+ net_ctx = libnet_context_init(torture->ev, torture->lp_ctx);
status = torture_rpc_connection(torture,
&net_ctx->samr.pipe,
diff --git a/source4/torture/libnet/libnet.c b/source4/torture/libnet/libnet.c
index 3a75ffcae3..8c8353e8d6 100644
--- a/source4/torture/libnet/libnet.c
+++ b/source4/torture/libnet/libnet.c
@@ -18,7 +18,7 @@
*/
#include "includes.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "librpc/rpc/dcerpc.h"
#include "librpc/gen_ndr/security.h"
#include "librpc/gen_ndr/lsa.h"
diff --git a/source4/torture/libnet/libnet_BecomeDC.c b/source4/torture/libnet/libnet_BecomeDC.c
index 3f8edd40e8..bc92b4ebc2 100644
--- a/source4/torture/libnet/libnet_BecomeDC.c
+++ b/source4/torture/libnet/libnet_BecomeDC.c
@@ -38,6 +38,7 @@
#include "auth/auth.h"
#include "param/param.h"
#include "torture/util.h"
+#include "param/provision.h"
struct test_become_dc_state {
struct libnet_context *ctx;
@@ -66,16 +67,9 @@ static NTSTATUS test_become_dc_prepare_db(void *private_data,
{
struct test_become_dc_state *s = talloc_get_type(private_data, struct test_become_dc_state);
struct provision_settings settings;
+ struct provision_result result;
NTSTATUS status;
- bool ok;
- struct loadparm_context *lp_ctx = loadparm_init(s);
- char *smbconf;
-
- if (!lp_ctx) {
- return NT_STATUS_NO_MEMORY;
- }
- 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;
@@ -84,40 +78,14 @@ static NTSTATUS test_become_dc_prepare_db(void *private_data,
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.server_dn_str = torture_join_server_dn_str(s->tj);
settings.machine_password = cli_credentials_get_password(s->machine_account);
settings.targetdir = s->targetdir;
- status = provision_bare(s, s->lp_ctx, &settings);
+ status = provision_bare(s, s->lp_ctx, &settings, &result);
- smbconf = talloc_asprintf(lp_ctx, "%s/%s", s->targetdir, "/etc/smb.conf");
-
- ok = lp_load(lp_ctx, smbconf);
- if (!ok) {
- DEBUG(0,("Failed load freshly generated smb.conf '%s'\n", smbconf));
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- s->ldb = ldb_wrap_connect(s, lp_ctx, lp_sam_url(lp_ctx),
- system_session(s, lp_ctx),
- NULL, 0, NULL);
- if (!s->ldb) {
- DEBUG(0,("Failed to open '%s'\n", lp_sam_url(lp_ctx)));
- 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;
- }
-
- s->lp_ctx = lp_ctx;
-
+ s->ldb = result.samdb;
+ s->lp_ctx = result.lp_ctx;
return NT_STATUS_OK;
@@ -354,7 +322,7 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s,
sam_ldb_path = talloc_asprintf(s, "%s/%s", s->targetdir, "private/sam.ldb");
DEBUG(0,("Reopen the SAM LDB with system credentials and a already stored schema: %s\n", sam_ldb_path));
- s->ldb = ldb_wrap_connect(s, s->tctx->lp_ctx, sam_ldb_path,
+ s->ldb = ldb_wrap_connect(s, s->tctx->ev, s->tctx->lp_ctx, sam_ldb_path,
system_session(s, s->tctx->lp_ctx),
NULL, 0, NULL);
if (!s->ldb) {
@@ -686,7 +654,7 @@ bool torture_net_become_dc(struct torture_context *torture)
sam_ldb_path = talloc_asprintf(s, "%s/%s", s->targetdir, "private/sam.ldb");
DEBUG(0,("Reopen the SAM LDB with system credentials and all replicated data: %s\n", sam_ldb_path));
- s->ldb = ldb_wrap_connect(s, s->lp_ctx, sam_ldb_path,
+ s->ldb = ldb_wrap_connect(s, s->tctx->ev, s->lp_ctx, sam_ldb_path,
system_session(s, s->lp_ctx),
NULL, 0, NULL);
if (!s->ldb) {
diff --git a/source4/torture/libnet/libnet_domain.c b/source4/torture/libnet/libnet_domain.c
index 3c8d574f0e..7d5be368c2 100644
--- a/source4/torture/libnet/libnet_domain.c
+++ b/source4/torture/libnet/libnet_domain.c
@@ -136,7 +136,7 @@ bool torture_domain_open_lsa(struct torture_context *torture)
of specific server name. */
domain_name = lp_workgroup(torture->lp_ctx);
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
if (ctx == NULL) {
d_printf("failed to create libnet context\n");
return false;
@@ -190,7 +190,7 @@ bool torture_domain_close_lsa(struct torture_context *torture)
return false;
}
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
if (ctx == NULL) {
d_printf("failed to create libnet context\n");
ret = false;
@@ -201,7 +201,7 @@ bool torture_domain_close_lsa(struct torture_context *torture)
mem_ctx = talloc_init("torture_domain_close_lsa");
status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_lsarpc,
- cmdline_credentials, NULL, torture->lp_ctx);
+ cmdline_credentials, torture->ev, torture->lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
d_printf("failed to connect to server: %s\n", nt_errstr(status));
ret = false;
@@ -245,7 +245,6 @@ bool torture_domain_open_samr(struct torture_context *torture)
{
NTSTATUS status;
struct libnet_context *ctx;
- struct event_context *evt_ctx=NULL;
TALLOC_CTX *mem_ctx;
struct policy_handle domain_handle, handle;
struct libnet_DomainOpen io;
@@ -255,7 +254,7 @@ bool torture_domain_open_samr(struct torture_context *torture)
mem_ctx = talloc_init("test_domainopen_lsa");
- ctx = libnet_context_init(evt_ctx, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
/* we're accessing domain controller so the domain name should be
@@ -320,7 +319,7 @@ bool torture_domain_close_samr(struct torture_context *torture)
return false;
}
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
if (ctx == NULL) {
d_printf("failed to create libnet context\n");
ret = false;
@@ -331,7 +330,7 @@ bool torture_domain_close_samr(struct torture_context *torture)
mem_ctx = talloc_init("torture_domain_close_samr");
status = dcerpc_pipe_connect_b(mem_ctx, &p, binding, &ndr_table_samr,
- ctx->cred, NULL, torture->lp_ctx);
+ ctx->cred, torture->ev, torture->lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
d_printf("failed to connect to server: %s\n", nt_errstr(status));
ret = false;
@@ -388,7 +387,7 @@ bool torture_domain_list(struct torture_context *torture)
return false;
}
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
if (ctx == NULL) {
d_printf("failed to create libnet context\n");
ret = false;
diff --git a/source4/torture/libnet/libnet_group.c b/source4/torture/libnet/libnet_group.c
index cabccdbe66..12b8167a86 100644
--- a/source4/torture/libnet/libnet_group.c
+++ b/source4/torture/libnet/libnet_group.c
@@ -235,7 +235,7 @@ bool torture_groupinfo_api(struct torture_context *torture)
prep_mem_ctx = talloc_init("prepare torture group info");
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
status = torture_rpc_connection(torture,
@@ -300,7 +300,7 @@ bool torture_grouplist(struct torture_context *torture)
struct libnet_GroupList req;
int i;
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
domain_name.string = lp_workgroup(torture->lp_ctx);
@@ -361,7 +361,7 @@ bool torture_creategroup(struct torture_context *torture)
mem_ctx = talloc_init("test_creategroup");
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
req.in.group_name = TEST_GROUPNAME;
diff --git a/source4/torture/libnet/libnet_lookup.c b/source4/torture/libnet/libnet_lookup.c
index 9167d1de3e..b25b51b7d9 100644
--- a/source4/torture/libnet/libnet_lookup.c
+++ b/source4/torture/libnet/libnet_lookup.c
@@ -40,7 +40,7 @@ bool torture_lookup(struct torture_context *torture)
mem_ctx = talloc_init("test_lookup");
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
lookup.in.hostname = torture_setting_string(torture, "host", NULL);
@@ -84,7 +84,7 @@ bool torture_lookup_host(struct torture_context *torture)
mem_ctx = talloc_init("test_lookup_host");
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
lookup.in.hostname = torture_setting_string(torture, "host", NULL);
@@ -127,7 +127,7 @@ bool torture_lookup_pdc(struct torture_context *torture)
mem_ctx = talloc_init("test_lookup_pdc");
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
talloc_steal(ctx, mem_ctx);
@@ -171,7 +171,7 @@ bool torture_lookup_sam_name(struct torture_context *torture)
struct libnet_context *ctx;
struct libnet_LookupName r;
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
mem_ctx = talloc_init("torture lookup sam name");
diff --git a/source4/torture/libnet/libnet_rpc.c b/source4/torture/libnet/libnet_rpc.c
index 282837d3fe..f25c1ecc48 100644
--- a/source4/torture/libnet/libnet_rpc.c
+++ b/source4/torture/libnet/libnet_rpc.c
@@ -89,7 +89,7 @@ static bool torture_rpc_connect(struct torture_context *torture,
{
struct libnet_context *ctx;
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
d_printf("Testing connection to LSA interface\n");
diff --git a/source4/torture/libnet/libnet_share.c b/source4/torture/libnet/libnet_share.c
index eb1edff18d..6bc5be40a6 100644
--- a/source4/torture/libnet/libnet_share.c
+++ b/source4/torture/libnet/libnet_share.c
@@ -131,7 +131,7 @@ bool torture_listshares(struct torture_context *torture)
goto done;
}
- libnetctx = libnet_context_init(NULL, torture->lp_ctx);
+ libnetctx = libnet_context_init(torture->ev, torture->lp_ctx);
if (!libnetctx) {
printf("Couldn't allocate libnet context\n");
ret = false;
@@ -210,7 +210,7 @@ bool torture_delshare(struct torture_context *torture)
status = torture_rpc_binding(torture, &binding);
torture_assert_ntstatus_ok(torture, status, "Failed to get binding");
- libnetctx = libnet_context_init(NULL, torture->lp_ctx);
+ libnetctx = libnet_context_init(torture->ev, torture->lp_ctx);
libnetctx->cred = cmdline_credentials;
status = torture_rpc_connection(torture,
diff --git a/source4/torture/libnet/libnet_user.c b/source4/torture/libnet/libnet_user.c
index 5446087034..6d3e682976 100644
--- a/source4/torture/libnet/libnet_user.c
+++ b/source4/torture/libnet/libnet_user.c
@@ -241,7 +241,7 @@ bool torture_createuser(struct torture_context *torture)
mem_ctx = talloc_init("test_createuser");
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
req.in.user_name = TEST_USERNAME;
@@ -287,7 +287,7 @@ bool torture_deleteuser(struct torture_context *torture)
prep_mem_ctx = talloc_init("prepare test_deleteuser");
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
req.in.user_name = TEST_USERNAME;
@@ -482,7 +482,7 @@ bool torture_modifyuser(struct torture_context *torture)
prep_mem_ctx = talloc_init("prepare test_deleteuser");
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
status = torture_rpc_connection(torture,
@@ -530,7 +530,8 @@ bool torture_modifyuser(struct torture_context *torture)
ZERO_STRUCT(user_req);
user_req.in.domain_name = lp_workgroup(torture->lp_ctx);
- user_req.in.user_name = name;
+ user_req.in.data.user_name = name;
+ user_req.in.level = USER_INFO_BY_NAME;
status = libnet_UserInfo(ctx, torture, &user_req);
if (!NT_STATUS_IS_OK(status)) {
@@ -616,7 +617,7 @@ bool torture_userinfo_api(struct torture_context *torture)
prep_mem_ctx = talloc_init("prepare torture user info");
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
status = torture_rpc_connection(torture,
@@ -642,7 +643,8 @@ bool torture_userinfo_api(struct torture_context *torture)
ZERO_STRUCT(req);
req.in.domain_name = domain_name.string;
- req.in.user_name = name;
+ req.in.data.user_name = name;
+ req.in.level = USER_INFO_BY_NAME;
status = libnet_UserInfo(ctx, mem_ctx, &req);
if (!NT_STATUS_IS_OK(status)) {
@@ -681,7 +683,7 @@ bool torture_userlist(struct torture_context *torture)
struct libnet_UserList req;
int i;
- ctx = libnet_context_init(NULL, torture->lp_ctx);
+ ctx = libnet_context_init(torture->ev, torture->lp_ctx);
ctx->cred = cmdline_credentials;
domain_name.string = lp_workgroup(torture->lp_ctx);
diff --git a/source4/torture/local/config.mk b/source4/torture/local/config.mk
index 4143d415cf..cd1c7b1422 100644
--- a/source4/torture/local/config.mk
+++ b/source4/torture/local/config.mk
@@ -1,39 +1,8 @@
#################################
# Start SUBSYSTEM TORTURE_LOCAL
[MODULE::TORTURE_LOCAL]
-SUBSYSTEM = torture
+SUBSYSTEM = smbtorture
INIT_FUNCTION = torture_local_init
-PRIVATE_PROTO_HEADER = \
- proto.h
-OBJ_FILES = \
- ../../lib/charset/tests/iconv.o \
- ../../lib/talloc/testsuite.o \
- ../../lib/replace/test/getifaddrs.o \
- ../../lib/replace/test/os2_delete.o \
- ../../lib/replace/test/strptime.o \
- ../../lib/replace/test/testsuite.o \
- ../../lib/messaging/tests/messaging.o \
- ../../lib/messaging/tests/irpc.o \
- ../../librpc/tests/binding_string.o \
- ../../lib/util/tests/idtree.o \
- ../../lib/socket/testsuite.o \
- ../../lib/socket_wrapper/testsuite.o \
- ../../libcli/resolve/testsuite.o \
- ../../lib/util/tests/strlist.o \
- ../../lib/util/tests/str.o \
- ../../lib/util/tests/file.o \
- ../../lib/util/tests/genrand.o \
- ../../lib/compression/testsuite.o \
- ../../lib/charset/tests/charset.o \
- ../../libcli/security/tests/sddl.o \
- ../../lib/tdr/testsuite.o \
- ../../lib/events/testsuite.o \
- ../../param/tests/share.o \
- ../../param/tests/loadparm.o \
- ../../auth/credentials/tests/simple.o \
- local.o \
- dbspeed.o \
- torture.o
PRIVATE_DEPENDENCIES = \
RPC_NDR_ECHO \
TDR \
@@ -48,3 +17,36 @@ PRIVATE_DEPENDENCIES = \
torture_registry
# End SUBSYSTEM TORTURE_LOCAL
#################################
+
+TORTURE_LOCAL_OBJ_FILES = \
+ $(torturesrcdir)/../lib/charset/tests/iconv.o \
+ $(torturesrcdir)/../lib/talloc/testsuite.o \
+ $(torturesrcdir)/../lib/replace/test/getifaddrs.o \
+ $(torturesrcdir)/../lib/replace/test/os2_delete.o \
+ $(torturesrcdir)/../lib/replace/test/strptime.o \
+ $(torturesrcdir)/../lib/replace/test/testsuite.o \
+ $(torturesrcdir)/../lib/messaging/tests/messaging.o \
+ $(torturesrcdir)/../lib/messaging/tests/irpc.o \
+ $(torturesrcdir)/../librpc/tests/binding_string.o \
+ $(torturesrcdir)/../lib/util/tests/idtree.o \
+ $(torturesrcdir)/../lib/socket/testsuite.o \
+ $(torturesrcdir)/../lib/socket_wrapper/testsuite.o \
+ $(torturesrcdir)/../libcli/resolve/testsuite.o \
+ $(torturesrcdir)/../lib/util/tests/strlist.o \
+ $(torturesrcdir)/../lib/util/tests/str.o \
+ $(torturesrcdir)/../lib/util/tests/file.o \
+ $(torturesrcdir)/../lib/util/tests/genrand.o \
+ $(torturesrcdir)/../lib/compression/testsuite.o \
+ $(torturesrcdir)/../lib/charset/tests/charset.o \
+ $(torturesrcdir)/../libcli/security/tests/sddl.o \
+ $(torturesrcdir)/../lib/tdr/testsuite.o \
+ $(torturesrcdir)/../lib/events/testsuite.o \
+ $(torturesrcdir)/../param/tests/share.o \
+ $(torturesrcdir)/../param/tests/loadparm.o \
+ $(torturesrcdir)/../auth/credentials/tests/simple.o \
+ $(torturesrcdir)/local/local.o \
+ $(torturesrcdir)/local/dbspeed.o \
+ $(torturesrcdir)/local/torture.o
+
+
+$(eval $(call proto_header_template,$(torturesrcdir)/local/proto.h,$(TORTURE_LOCAL_OBJ_FILES:.o=.c)))
diff --git a/source4/torture/local/dbspeed.c b/source4/torture/local/dbspeed.c
index 34083cd204..017c8568f4 100644
--- a/source4/torture/local/dbspeed.c
+++ b/source4/torture/local/dbspeed.c
@@ -26,7 +26,7 @@
#include "lib/ldb/include/ldb_errors.h"
#include "lib/ldb_wrap.h"
#include "lib/tdb_wrap.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "param/param.h"
float tdb_speed;
@@ -176,7 +176,7 @@ static bool test_ldb_speed(struct torture_context *torture, const void *_data)
torture_comment(torture, "Testing ldb speed for sidmap\n");
- ldb = ldb_wrap_connect(tmp_ctx, torture->lp_ctx, "tdb://test.ldb",
+ ldb = ldb_wrap_connect(tmp_ctx, torture->ev, torture->lp_ctx, "tdb://test.ldb",
NULL, NULL, LDB_FLG_NOSYNC, NULL);
if (!ldb) {
unlink("./test.ldb");
diff --git a/source4/torture/local/local.c b/source4/torture/local/local.c
index e4dfadd3d1..1c3274adcd 100644
--- a/source4/torture/local/local.c
+++ b/source4/torture/local/local.c
@@ -18,7 +18,7 @@
*/
#include "includes.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "torture/local/proto.h"
#include "torture/ndr/ndr.h"
#include "torture/ndr/proto.h"
diff --git a/source4/torture/local/torture.c b/source4/torture/local/torture.c
index bb6e21ed4f..7935f6cc35 100644
--- a/source4/torture/local/torture.c
+++ b/source4/torture/local/torture.c
@@ -25,6 +25,7 @@
#include "lib/events/events.h"
#include "libcli/raw/libcliraw.h"
#include "torture/util.h"
+#include "param/provision.h"
static bool test_tempdir(struct torture_context *tctx)
{
@@ -42,30 +43,34 @@ static bool test_tempdir(struct torture_context *tctx)
static bool test_provision(struct torture_context *tctx)
{
NTSTATUS status;
- struct provision_settings settings;
- char *location = NULL;
- torture_assert_ntstatus_ok(tctx, torture_temp_dir(tctx, "torture_provision", &location),
+ struct provision_settings *settings = talloc_zero(tctx, struct provision_settings);
+ struct provision_result result;
+ char *targetdir = NULL;
+
+ torture_assert_ntstatus_ok(tctx, torture_temp_dir(tctx, "torture_provision", &targetdir),
"torture_temp_dir should return NT_STATUS_OK" );
+ settings->targetdir = talloc_steal(settings, targetdir);
- 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.targetdir = location;
+ 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->netbios_name = "torture";
+ settings->ntds_dn_str = NULL;
+ settings->machine_password = "geheim";
- status = provision_bare(tctx, tctx->lp_ctx, &settings);
+ status = provision_bare(settings, tctx->lp_ctx, settings, &result);
torture_assert_ntstatus_ok(tctx, status, "provision");
+ torture_assert_str_equal(tctx, result.domaindn, "DC=EXAMPLE,DC=COM",
+ "domaindn incorrect");
+
return true;
}
diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c
index 618568acf9..8959232edb 100644
--- a/source4/torture/locktest.c
+++ b/source4/torture/locktest.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "lib/cmdline/popt_common.h"
+#include "lib/events/events.h"
#include "system/filesys.h"
#include "system/time.h"
#include "pstring.h"
@@ -107,7 +108,8 @@ static struct record *recorded;
/*****************************************************
return a connection to a server
*******************************************************/
-static struct smbcli_state *connect_one(struct loadparm_context *lp_ctx,
+static struct smbcli_state *connect_one(struct event_context *ev,
+ struct loadparm_context *lp_ctx,
char *share, int snum, int conn)
{
struct smbcli_state *c;
@@ -162,7 +164,7 @@ static struct smbcli_state *connect_one(struct loadparm_context *lp_ctx,
share, NULL,
servers[snum],
lp_resolve_context(lp_ctx),
- NULL, &options);
+ ev, &options);
if (!NT_STATUS_IS_OK(status)) {
sleep(2);
}
@@ -176,7 +178,8 @@ static struct smbcli_state *connect_one(struct loadparm_context *lp_ctx,
}
-static void reconnect(struct loadparm_context *lp_ctx,
+static void reconnect(struct event_context *ev,
+ struct loadparm_context *lp_ctx,
struct smbcli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NSERVERS][NCONNECTIONS][NFILES],
char *share[NSERVERS])
{
@@ -193,7 +196,7 @@ static void reconnect(struct loadparm_context *lp_ctx,
}
talloc_free(cli[server][conn]);
}
- cli[server][conn] = connect_one(lp_ctx, share[server],
+ cli[server][conn] = connect_one(ev, lp_ctx, share[server],
server, conn);
if (!cli[server][conn]) {
DEBUG(0,("Failed to connect to %s\n", share[server]));
@@ -396,7 +399,9 @@ 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 int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
+static int test_locks(struct event_context *ev,
+ struct loadparm_context *lp_ctx,
+ char *share[NSERVERS])
{
struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
int fnum[NSERVERS][NCONNECTIONS][NFILES];
@@ -447,7 +452,7 @@ static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
#endif
}
- reconnect(lp_ctx, cli, fnum, share);
+ reconnect(ev, lp_ctx, cli, fnum, share);
open_files(cli, fnum);
n = retest(cli, fnum, numops);
@@ -465,7 +470,7 @@ static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
n1 = n;
close_files(cli, fnum);
- reconnect(lp_ctx, cli, fnum, share);
+ reconnect(ev, lp_ctx, cli, fnum, share);
open_files(cli, fnum);
for (i=0;i<n-skip;i+=skip) {
@@ -503,7 +508,7 @@ static int test_locks(struct loadparm_context *lp_ctx, char *share[NSERVERS])
}
close_files(cli, fnum);
- reconnect(lp_ctx, cli, fnum, share);
+ reconnect(ev, lp_ctx, cli, fnum, share);
open_files(cli, fnum);
showall = true;
n1 = retest(cli, fnum, n);
@@ -543,6 +548,7 @@ static void usage(poptContext pc)
int opt;
int seed, server;
int username_count=0;
+ struct event_context *ev;
struct loadparm_context *lp_ctx;
poptContext pc;
int argc_new, i;
@@ -631,12 +637,14 @@ static void usage(poptContext pc)
servers[1] = servers[0];
}
+ ev = event_context_init(talloc_autofree_context());
+
gensec_init(lp_ctx);
DEBUG(0,("seed=%u base=%d range=%d min_length=%d\n",
seed, lock_base, lock_range, min_length));
srandom(seed);
- return test_locks(lp_ctx, share);
+ return test_locks(ev, lp_ctx, share);
}
diff --git a/source4/torture/locktest2.c b/source4/torture/locktest2.c
index 0fe3725385..1784a0a729 100644
--- a/source4/torture/locktest2.c
+++ b/source4/torture/locktest2.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "system/passwd.h"
+#include "lib/events/events.h"
static fstring password;
static fstring username;
@@ -137,7 +138,8 @@ static bool try_unlock(struct smbcli_state *c, int fstype,
return a connection to a server
*******************************************************/
static struct smbcli_state *connect_one(char *share, const char **ports,
- struct smb_options *options)
+ struct smb_options *optionsi,
+ struct event_context *ev)
{
struct smbcli_state *c;
char *server_n;
@@ -165,7 +167,7 @@ static struct smbcli_state *connect_one(char *share, const char **ports,
nt_status = smbcli_full_connection(NULL,
&c, myname, server_n, ports, share, NULL,
- username, lp_workgroup(), password, NULL,
+ username, lp_workgroup(), password, ev,
options);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0, ("smbcli_full_connection failed with error %s\n", nt_errstr(nt_status)));
@@ -183,6 +185,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES],
const char **ports,
struct smbcli_options *options,
+ struct event_context *ev,
char *share1, char *share2)
{
int server, conn, f, fstype;
@@ -201,7 +204,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS],
smbcli_ulogoff(cli[server][conn]);
talloc_free(cli[server][conn]);
}
- cli[server][conn] = connect_one(share[server], ports, options);
+ cli[server][conn] = connect_one(share[server], ports, options, ev);
if (!cli[server][conn]) {
DEBUG(0,("Failed to connect to %s\n", share[server]));
exit(1);
@@ -347,7 +350,11 @@ 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(char *share1, char *share2, char *nfspath1, char *nfspath2, const char **ports, struct smbcli_options *options)
+static void test_locks(char *share1, char *share2,
+ char *nfspath1, char *nfspath2,
+ const char **ports,
+ struct smbcli_options *options,
+ struct event_context *ev)
{
struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
char *nfs[NSERVERS];
@@ -376,7 +383,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
recorded[n].needed = true;
}
- reconnect(cli, nfs, fnum, ports, options, share1, share2);
+ reconnect(cli, nfs, fnum, ports, options, ev, share1, share2);
open_files(cli, nfs, fnum);
n = retest(cli, nfs, fnum, numops);
@@ -387,7 +394,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
n1 = n;
close_files(cli, nfs, fnum);
- reconnect(cli, nfs, fnum, ports, options, share1, share2);
+ reconnect(cli, nfs, fnum, ports, options, ev, share1, share2);
open_files(cli, nfs, fnum);
for (i=0;i<n-1;i++) {
@@ -414,7 +421,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath
}
close_files(cli, nfs, fnum);
- reconnect(cli, nfs, fnum, ports, options, share1, share2);
+ reconnect(cli, nfs, fnum, ports, options, ev, share1, share2);
open_files(cli, nfs, fnum);
showall = true;
n1 = retest(cli, nfs, fnum, n);
@@ -466,6 +473,7 @@ static void usage(void)
char *p;
int seed;
struct loadparm_context *lp_ctx;
+ struct event_context *ev;
setlinebuf(stdout);
@@ -542,10 +550,12 @@ static void usage(void)
DEBUG(0,("seed=%u\n", seed));
srandom(seed);
+ ev = event_context_init(talloc_autofree_context());
+
locking_init(1);
lp_smbcli_options(lp_ctx, &options);
test_locks(share1, share2, nfspath1, nfspath2, lp_smb_ports(lp_ctx),
- &options);
+ &options, ev);
return(0);
}
diff --git a/source4/torture/masktest.c b/source4/torture/masktest.c
index ac7029aa50..39b1296dbe 100644
--- a/source4/torture/masktest.c
+++ b/source4/torture/masktest.c
@@ -30,6 +30,7 @@
#include "param/param.h"
#include "dynconfig.h"
#include "libcli/resolve/resolve.h"
+#include "lib/events/events.h"
static bool showall = false;
static bool old_list = false;
@@ -73,6 +74,7 @@ static char *reg_test(struct smbcli_state *cli, char *pattern, char *long_name,
return a connection to a server
*******************************************************/
static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx,
+ struct event_context *ev,
char *share, const char **ports,
struct smbcli_options *options)
{
@@ -92,7 +94,7 @@ static struct smbcli_state *connect_one(struct resolve_context *resolve_ctx,
server,
ports,
share, NULL,
- cmdline_credentials, resolve_ctx, NULL,
+ cmdline_credentials, resolve_ctx, ev,
options);
if (!NT_STATUS_IS_OK(status)) {
@@ -291,6 +293,7 @@ static void usage(poptContext pc)
struct smbcli_state *cli;
int opt;
int seed;
+ struct event_context *ev;
struct loadparm_context *lp_ctx;
struct smbcli_options options;
poptContext pc;
@@ -352,11 +355,13 @@ static void usage(poptContext pc)
lp_ctx = cmdline_lp_ctx;
+ ev = event_context_init(talloc_autofree_context());
+
gensec_init(lp_ctx);
lp_smbcli_options(lp_ctx, &options);
- cli = connect_one(lp_resolve_context(lp_ctx), share,
+ cli = connect_one(lp_resolve_context(lp_ctx), ev, share,
lp_smb_ports(lp_ctx), &options);
if (!cli) {
DEBUG(0,("Failed to connect to %s\n", share));
diff --git a/source4/torture/nbench/nbench.c b/source4/torture/nbench/nbench.c
index e9bd32cce0..96144c4773 100644
--- a/source4/torture/nbench/nbench.c
+++ b/source4/torture/nbench/nbench.c
@@ -19,9 +19,8 @@
#include "includes.h"
#include "libcli/libcli.h"
-#include "torture/ui.h"
#include "torture/util.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "system/filesys.h"
#include "system/locale.h"
#include "pstring.h"
diff --git a/source4/torture/nbt/browse.c b/source4/torture/nbt/browse.c
index e609e72055..a0e7b7d9ca 100644
--- a/source4/torture/nbt/browse.c
+++ b/source4/torture/nbt/browse.c
@@ -40,7 +40,7 @@ bool torture_nbt_browse(struct torture_context *torture)
name.scope = NULL;
/* do an initial name resolution to find its IP */
- status = resolve_name(&name, mem_ctx, &address, NULL);
+ status = resolve_name(&name, mem_ctx, &address, torture->ev);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to resolve %s - %s\n",
name.name, nt_errstr(status));
diff --git a/source4/torture/nbt/dgram.c b/source4/torture/nbt/dgram.c
index e1680877e8..887c6f32ab 100644
--- a/source4/torture/nbt/dgram.c
+++ b/source4/torture/nbt/dgram.c
@@ -42,21 +42,24 @@ static void netlogon_handler(struct dgram_mailslot_handler *dgmslot,
struct socket_address *src)
{
NTSTATUS status;
- struct nbt_netlogon_packet netlogon;
- int *replies = (int *)dgmslot->private;
+ struct nbt_netlogon_response *netlogon = dgmslot->private;
+ dgmslot->private = netlogon = talloc(dgmslot, struct nbt_netlogon_response);
+
+ if (!dgmslot->private) {
+ return;
+ }
+
printf("netlogon reply from %s:%d\n", src->addr, src->port);
- status = dgram_mailslot_netlogon_parse(dgmslot, dgmslot, packet, &netlogon);
+ /* Fills in the netlogon pointer */
+ status = dgram_mailslot_netlogon_parse_response(dgmslot, netlogon, packet, netlogon);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to parse netlogon packet from %s:%d\n",
src->addr, src->port);
return;
}
- NDR_PRINT_DEBUG(nbt_netlogon_packet, &netlogon);
-
- (*replies)++;
}
@@ -64,15 +67,15 @@ static void netlogon_handler(struct dgram_mailslot_handler *dgmslot,
static bool nbt_test_netlogon(struct torture_context *tctx)
{
struct dgram_mailslot_handler *dgmslot;
- struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL,
+ struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, tctx->ev,
lp_iconv_convenience(tctx->lp_ctx));
struct socket_address *dest;
const char *myaddress;
struct nbt_netlogon_packet logon;
+ struct nbt_netlogon_response *response;
struct nbt_name myname;
NTSTATUS status;
struct timeval tv = timeval_current();
- int replies = 0;
struct socket_address *socket_address;
@@ -80,14 +83,14 @@ static bool nbt_test_netlogon(struct torture_context *tctx)
struct nbt_name name;
struct interface *ifaces;
-
+
name.name = lp_workgroup(tctx->lp_ctx);
name.type = NBT_NAME_LOGON;
name.scope = NULL;
/* do an initial name resolution to find its IP */
torture_assert_ntstatus_ok(tctx,
- resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, event_context_find(tctx)),
+ resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, tctx->ev),
talloc_asprintf(tctx, "Failed to resolve %s", name.name));
load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
@@ -101,7 +104,7 @@ static bool nbt_test_netlogon(struct torture_context *tctx)
/* try receiving replies on port 138 first, which will only
work if we are root and smbd/nmbd are not running - fall
back to listening on any port, which means replies from
- some windows versions won't be seen */
+ most windows versions won't be seen */
status = socket_listen(dgmsock->sock, socket_address, 0, 0);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(socket_address);
@@ -114,10 +117,10 @@ static bool nbt_test_netlogon(struct torture_context *tctx)
/* setup a temporary mailslot listener for replies */
dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC,
- netlogon_handler, &replies);
+ netlogon_handler, NULL);
ZERO_STRUCT(logon);
- logon.command = NETLOGON_QUERY_FOR_PDC;
+ logon.command = LOGON_PRIMARY_QUERY;
logon.req.pdc.computer_name = TEST_NAME;
logon.req.pdc.mailslot_name = dgmslot->mailslot_name;
logon.req.pdc.unicode_name = TEST_NAME;
@@ -132,13 +135,21 @@ static bool nbt_test_netlogon(struct torture_context *tctx)
torture_assert(tctx, dest != NULL, "Error getting address");
status = dgram_mailslot_netlogon_send(dgmsock, &name, dest,
+ NBT_MAILSLOT_NETLOGON,
&myname, &logon);
torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request");
- while (timeval_elapsed(&tv) < 5 && replies == 0) {
+ while (timeval_elapsed(&tv) < 5 && !dgmslot->private) {
event_loop_once(dgmsock->event_ctx);
}
+ response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response);
+
+ torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet");
+
+ torture_assert(tctx, response->response_type == NETLOGON_GET_PDC, "Got incorrect type of netlogon response");
+ torture_assert(tctx, response->get_pdc.command == NETLOGON_RESPONSE_FROM_PDC, "Got incorrect netlogon response command");
+
return true;
}
@@ -147,15 +158,15 @@ static bool nbt_test_netlogon(struct torture_context *tctx)
static bool nbt_test_netlogon2(struct torture_context *tctx)
{
struct dgram_mailslot_handler *dgmslot;
- struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL,
+ struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, tctx->ev,
lp_iconv_convenience(tctx->lp_ctx));
struct socket_address *dest;
const char *myaddress;
struct nbt_netlogon_packet logon;
+ struct nbt_netlogon_response *response;
struct nbt_name myname;
NTSTATUS status;
struct timeval tv = timeval_current();
- int replies = 0;
struct socket_address *socket_address;
@@ -163,6 +174,9 @@ static bool nbt_test_netlogon2(struct torture_context *tctx)
struct nbt_name name;
struct interface *ifaces;
+ struct test_join *join_ctx;
+ struct cli_credentials *machine_credentials;
+ const struct dom_sid *dom_sid;
name.name = lp_workgroup(tctx->lp_ctx);
name.type = NBT_NAME_LOGON;
@@ -170,7 +184,7 @@ static bool nbt_test_netlogon2(struct torture_context *tctx)
/* do an initial name resolution to find its IP */
torture_assert_ntstatus_ok(tctx,
- resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, event_context_find(tctx)),
+ resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, tctx->ev),
talloc_asprintf(tctx, "Failed to resolve %s", name.name));
load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
@@ -196,18 +210,18 @@ static bool nbt_test_netlogon2(struct torture_context *tctx)
/* setup a temporary mailslot listener for replies */
dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC,
- netlogon_handler, &replies);
+ netlogon_handler, NULL);
ZERO_STRUCT(logon);
- logon.command = NETLOGON_QUERY_FOR_PDC2;
- logon.req.pdc2.request_count = 0;
- logon.req.pdc2.computer_name = TEST_NAME;
- logon.req.pdc2.user_name = "";
- logon.req.pdc2.mailslot_name = dgmslot->mailslot_name;
- logon.req.pdc2.nt_version = 11;
- logon.req.pdc2.lmnt_token = 0xFFFF;
- logon.req.pdc2.lm20_token = 0xFFFF;
+ logon.command = LOGON_SAM_LOGON_REQUEST;
+ logon.req.logon.request_count = 0;
+ logon.req.logon.computer_name = TEST_NAME;
+ logon.req.logon.user_name = "";
+ logon.req.logon.mailslot_name = dgmslot->mailslot_name;
+ logon.req.logon.nt_version = NETLOGON_NT_VERSION_5EX_WITH_IP|NETLOGON_NT_VERSION_5|NETLOGON_NT_VERSION_1;
+ logon.req.logon.lmnt_token = 0xFFFF;
+ logon.req.logon.lm20_token = 0xFFFF;
make_nbt_name_client(&myname, TEST_NAME);
@@ -216,40 +230,191 @@ static bool nbt_test_netlogon2(struct torture_context *tctx)
torture_assert(tctx, dest != NULL, "Error getting address");
status = dgram_mailslot_netlogon_send(dgmsock, &name, dest,
+ NBT_MAILSLOT_NETLOGON,
&myname, &logon);
torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request");
- while (timeval_elapsed(&tv) < 5 && replies == 0) {
+ while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) {
event_loop_once(dgmsock->event_ctx);
}
- return true;
-}
+ response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response);
+ torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet");
-/*
- reply handler for ntlogon request
-*/
-static void ntlogon_handler(struct dgram_mailslot_handler *dgmslot,
- struct nbt_dgram_packet *packet,
- struct socket_address *src)
-{
- NTSTATUS status;
- struct nbt_ntlogon_packet ntlogon;
- int *replies = (int *)dgmslot->private;
+ torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response");
+ map_netlogon_samlogon_response(&response->samlogon);
- printf("ntlogon reply from %s:%d\n", src->addr, src->port);
+ torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE_EX, "Got incorrect netlogon response command");
+ torture_assert_int_equal(tctx, response->samlogon.nt5_ex.nt_version, NETLOGON_NT_VERSION_5EX_WITH_IP|NETLOGON_NT_VERSION_5EX|NETLOGON_NT_VERSION_1, "Got incorrect netlogon response command");
- status = dgram_mailslot_ntlogon_parse(dgmslot, dgmslot, packet, &ntlogon);
- if (!NT_STATUS_IS_OK(status)) {
- printf("Failed to parse ntlogon packet from %s:%d\n",
- src->addr, src->port);
- return;
+ /* setup (another) temporary mailslot listener for replies */
+ dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC,
+ netlogon_handler, NULL);
+
+ ZERO_STRUCT(logon);
+ logon.command = LOGON_SAM_LOGON_REQUEST;
+ logon.req.logon.request_count = 0;
+ logon.req.logon.computer_name = TEST_NAME;
+ logon.req.logon.user_name = TEST_NAME"$";
+ logon.req.logon.mailslot_name = dgmslot->mailslot_name;
+ logon.req.logon.nt_version = 1;
+ logon.req.logon.lmnt_token = 0xFFFF;
+ logon.req.logon.lm20_token = 0xFFFF;
+
+ make_nbt_name_client(&myname, TEST_NAME);
+
+ dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name,
+ address, lp_dgram_port(tctx->lp_ctx));
+
+ torture_assert(tctx, dest != NULL, "Error getting address");
+ status = dgram_mailslot_netlogon_send(dgmsock, &name, dest,
+ NBT_MAILSLOT_NETLOGON,
+ &myname, &logon);
+ torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request");
+
+ while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) {
+ event_loop_once(dgmsock->event_ctx);
+ }
+
+ response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response);
+
+ torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet");
+
+ torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response");
+ map_netlogon_samlogon_response(&response->samlogon);
+
+ torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN, "Got incorrect netlogon response command");
+
+ torture_assert_str_equal(tctx, response->samlogon.nt5_ex.user_name, TEST_NAME"$", "Got incorrect user in netlogon response");
+
+ join_ctx = torture_join_domain(tctx, TEST_NAME,
+ ACB_WSTRUST, &machine_credentials);
+
+ dom_sid = torture_join_sid(join_ctx);
+
+ /* setup (another) temporary mailslot listener for replies */
+ dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC,
+ netlogon_handler, NULL);
+
+ ZERO_STRUCT(logon);
+ logon.command = LOGON_SAM_LOGON_REQUEST;
+ logon.req.logon.request_count = 0;
+ logon.req.logon.computer_name = TEST_NAME;
+ logon.req.logon.user_name = TEST_NAME"$";
+ logon.req.logon.mailslot_name = dgmslot->mailslot_name;
+ logon.req.logon.sid = *dom_sid;
+ logon.req.logon.nt_version = 1;
+ logon.req.logon.lmnt_token = 0xFFFF;
+ logon.req.logon.lm20_token = 0xFFFF;
+
+ make_nbt_name_client(&myname, TEST_NAME);
+
+ dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name,
+ address, lp_dgram_port(tctx->lp_ctx));
+
+ torture_assert(tctx, dest != NULL, "Error getting address");
+ status = dgram_mailslot_netlogon_send(dgmsock, &name, dest,
+ NBT_MAILSLOT_NETLOGON,
+ &myname, &logon);
+ torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request");
+
+
+ while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) {
+ event_loop_once(dgmsock->event_ctx);
+ }
+
+ response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response);
+
+ torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet");
+
+ torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response");
+ map_netlogon_samlogon_response(&response->samlogon);
+
+ torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN, "Got incorrect netlogon response command");
+
+ /* setup (another) temporary mailslot listener for replies */
+ dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC,
+ netlogon_handler, NULL);
+
+ ZERO_STRUCT(logon);
+ logon.command = LOGON_SAM_LOGON_REQUEST;
+ logon.req.logon.request_count = 0;
+ logon.req.logon.computer_name = TEST_NAME;
+ logon.req.logon.user_name = TEST_NAME"$";
+ logon.req.logon.mailslot_name = dgmslot->mailslot_name;
+ logon.req.logon.sid = *dom_sid;
+ logon.req.logon.acct_control = ACB_WSTRUST;
+ logon.req.logon.nt_version = 1;
+ logon.req.logon.lmnt_token = 0xFFFF;
+ logon.req.logon.lm20_token = 0xFFFF;
+
+ make_nbt_name_client(&myname, TEST_NAME);
+
+ dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name,
+ address, lp_dgram_port(tctx->lp_ctx));
+
+ torture_assert(tctx, dest != NULL, "Error getting address");
+ status = dgram_mailslot_netlogon_send(dgmsock, &name, dest,
+ NBT_MAILSLOT_NETLOGON,
+ &myname, &logon);
+ torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request");
+
+
+ while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) {
+ event_loop_once(dgmsock->event_ctx);
+ }
+
+ response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response);
+
+ torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet");
+
+ torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response");
+ map_netlogon_samlogon_response(&response->samlogon);
+
+ torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE, "Got incorrect netlogon response command");
+
+ dgmslot->private = NULL;
+
+ ZERO_STRUCT(logon);
+ logon.command = LOGON_SAM_LOGON_REQUEST;
+ logon.req.logon.request_count = 0;
+ logon.req.logon.computer_name = TEST_NAME;
+ logon.req.logon.user_name = TEST_NAME"$";
+ logon.req.logon.mailslot_name = dgmslot->mailslot_name;
+ logon.req.logon.sid = *dom_sid;
+ logon.req.logon.acct_control = ACB_NORMAL;
+ logon.req.logon.nt_version = 1;
+ logon.req.logon.lmnt_token = 0xFFFF;
+ logon.req.logon.lm20_token = 0xFFFF;
+
+ make_nbt_name_client(&myname, TEST_NAME);
+
+ dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name,
+ address, lp_dgram_port(tctx->lp_ctx));
+
+ torture_assert(tctx, dest != NULL, "Error getting address");
+ status = dgram_mailslot_netlogon_send(dgmsock, &name, dest,
+ NBT_MAILSLOT_NETLOGON,
+ &myname, &logon);
+ torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request");
+
+
+ while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) {
+ event_loop_once(dgmsock->event_ctx);
}
- NDR_PRINT_DEBUG(nbt_ntlogon_packet, &ntlogon);
+ response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response);
+
+ torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet");
- (*replies)++;
+ torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response");
+ map_netlogon_samlogon_response(&response->samlogon);
+
+ torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_USER_UNKNOWN, "Got incorrect netlogon response command");
+
+ torture_leave_domain(join_ctx);
+ return true;
}
@@ -257,19 +422,19 @@ static void ntlogon_handler(struct dgram_mailslot_handler *dgmslot,
static bool nbt_test_ntlogon(struct torture_context *tctx)
{
struct dgram_mailslot_handler *dgmslot;
- struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL,
+ struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, tctx->ev,
lp_iconv_convenience(tctx->lp_ctx));
struct socket_address *dest;
struct test_join *join_ctx;
- struct cli_credentials *machine_credentials;
const struct dom_sid *dom_sid;
+ struct cli_credentials *machine_credentials;
const char *myaddress;
- struct nbt_ntlogon_packet logon;
+ struct nbt_netlogon_packet logon;
+ struct nbt_netlogon_response *response;
struct nbt_name myname;
NTSTATUS status;
struct timeval tv = timeval_current();
- int replies = 0;
struct socket_address *socket_address;
const char *address;
@@ -283,7 +448,7 @@ static bool nbt_test_ntlogon(struct torture_context *tctx)
/* do an initial name resolution to find its IP */
torture_assert_ntstatus_ok(tctx,
- resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, event_context_find(tctx)),
+ resolve_name(lp_resolve_context(tctx->lp_ctx), &name, tctx, &address, tctx->ev),
talloc_asprintf(tctx, "Failed to resolve %s", name.name));
load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
@@ -296,7 +461,7 @@ static bool nbt_test_ntlogon(struct torture_context *tctx)
/* try receiving replies on port 138 first, which will only
work if we are root and smbd/nmbd are not running - fall
back to listening on any port, which means replies from
- some windows versions won't be seen */
+ most windows versions won't be seen */
status = socket_listen(dgmsock->sock, socket_address, 0, 0);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(socket_address);
@@ -309,24 +474,25 @@ static bool nbt_test_ntlogon(struct torture_context *tctx)
join_ctx = torture_join_domain(tctx, TEST_NAME,
ACB_WSTRUST, &machine_credentials);
+ dom_sid = torture_join_sid(join_ctx);
+
torture_assert(tctx, join_ctx != NULL,
talloc_asprintf(tctx, "Failed to join domain %s as %s\n",
lp_workgroup(tctx->lp_ctx), TEST_NAME));
- dom_sid = torture_join_sid(join_ctx);
-
/* setup a temporary mailslot listener for replies */
dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC,
- ntlogon_handler, &replies);
+ netlogon_handler, NULL);
ZERO_STRUCT(logon);
- logon.command = NTLOGON_SAM_LOGON;
+ logon.command = LOGON_SAM_LOGON_REQUEST;
logon.req.logon.request_count = 0;
logon.req.logon.computer_name = TEST_NAME;
logon.req.logon.user_name = TEST_NAME"$";
logon.req.logon.mailslot_name = dgmslot->mailslot_name;
logon.req.logon.acct_control = ACB_WSTRUST;
+ /* Try with a SID this time */
logon.req.logon.sid = *dom_sid;
logon.req.logon.nt_version = 1;
logon.req.logon.lmnt_token = 0xFFFF;
@@ -337,15 +503,145 @@ static bool nbt_test_ntlogon(struct torture_context *tctx)
dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name,
address, lp_dgram_port(tctx->lp_ctx));
torture_assert(tctx, dest != NULL, "Error getting address");
- status = dgram_mailslot_ntlogon_send(dgmsock, DGRAM_DIRECT_UNIQUE,
- &name, dest, &myname, &logon);
+ status = dgram_mailslot_netlogon_send(dgmsock,
+ &name, dest,
+ NBT_MAILSLOT_NTLOGON,
+ &myname, &logon);
+ torture_assert_ntstatus_ok(tctx, status, "Failed to send ntlogon request");
+
+ while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) {
+ event_loop_once(dgmsock->event_ctx);
+ }
+
+ response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response);
+
+ torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet");
+
+ torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response");
+ map_netlogon_samlogon_response(&response->samlogon);
+
+ torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE, "Got incorrect netlogon response command");
+
+ torture_assert_str_equal(tctx, response->samlogon.nt5_ex.user_name, TEST_NAME"$", "Got incorrect user in netlogon response");
+
+
+ /* setup a temporary mailslot listener for replies */
+ dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC,
+ netlogon_handler, NULL);
+
+
+ ZERO_STRUCT(logon);
+ logon.command = LOGON_SAM_LOGON_REQUEST;
+ logon.req.logon.request_count = 0;
+ logon.req.logon.computer_name = TEST_NAME;
+ logon.req.logon.user_name = TEST_NAME"$";
+ logon.req.logon.mailslot_name = dgmslot->mailslot_name;
+ logon.req.logon.acct_control = ACB_WSTRUST;
+ /* Leave sid as all zero */
+ logon.req.logon.nt_version = 1;
+ logon.req.logon.lmnt_token = 0xFFFF;
+ logon.req.logon.lm20_token = 0xFFFF;
+
+ make_nbt_name_client(&myname, TEST_NAME);
+
+ dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name,
+ address, lp_dgram_port(tctx->lp_ctx));
+ torture_assert(tctx, dest != NULL, "Error getting address");
+ status = dgram_mailslot_netlogon_send(dgmsock,
+ &name, dest,
+ NBT_MAILSLOT_NTLOGON,
+ &myname, &logon);
+ torture_assert_ntstatus_ok(tctx, status, "Failed to send ntlogon request");
+
+ while (timeval_elapsed(&tv) < 5 && dgmslot->private == NULL) {
+ event_loop_once(dgmsock->event_ctx);
+ }
+
+ response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response);
+
+ torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet");
+
+ torture_assert_int_equal(tctx, response->response_type, NETLOGON_SAMLOGON, "Got incorrect type of netlogon response");
+ map_netlogon_samlogon_response(&response->samlogon);
+
+ torture_assert_int_equal(tctx, response->samlogon.nt5_ex.command, LOGON_SAM_LOGON_RESPONSE, "Got incorrect netlogon response command");
+
+ torture_assert_str_equal(tctx, response->samlogon.nt5_ex.user_name, TEST_NAME"$", "Got incorrect user in netlogon response");
+
+
+ /* setup (another) temporary mailslot listener for replies */
+ dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC,
+ netlogon_handler, NULL);
+
+ ZERO_STRUCT(logon);
+ logon.command = LOGON_PRIMARY_QUERY;
+ logon.req.pdc.computer_name = TEST_NAME;
+ logon.req.pdc.mailslot_name = dgmslot->mailslot_name;
+ logon.req.pdc.unicode_name = TEST_NAME;
+ logon.req.pdc.nt_version = 1;
+ logon.req.pdc.lmnt_token = 0xFFFF;
+ logon.req.pdc.lm20_token = 0xFFFF;
+
+ make_nbt_name_client(&myname, TEST_NAME);
+
+ dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name,
+ address, lp_dgram_port(tctx->lp_ctx));
+ torture_assert(tctx, dest != NULL, "Error getting address");
+ status = dgram_mailslot_netlogon_send(dgmsock,
+ &name, dest,
+ NBT_MAILSLOT_NTLOGON,
+ &myname, &logon);
torture_assert_ntstatus_ok(tctx, status, "Failed to send ntlogon request");
- while (timeval_elapsed(&tv) < 5 && replies == 0) {
+ while (timeval_elapsed(&tv) < 5 && !dgmslot->private) {
event_loop_once(dgmsock->event_ctx);
}
+ response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response);
+
+ torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet");
+
+ torture_assert_int_equal(tctx, response->response_type, NETLOGON_GET_PDC, "Got incorrect type of ntlogon response");
+ torture_assert_int_equal(tctx, response->get_pdc.command, NETLOGON_RESPONSE_FROM_PDC, "Got incorrect ntlogon response command");
+
torture_leave_domain(join_ctx);
+
+ /* setup (another) temporary mailslot listener for replies */
+ dgmslot = dgram_mailslot_temp(dgmsock, NBT_MAILSLOT_GETDC,
+ netlogon_handler, NULL);
+
+ ZERO_STRUCT(logon);
+ logon.command = LOGON_PRIMARY_QUERY;
+ logon.req.pdc.computer_name = TEST_NAME;
+ logon.req.pdc.mailslot_name = dgmslot->mailslot_name;
+ logon.req.pdc.unicode_name = TEST_NAME;
+ logon.req.pdc.nt_version = 1;
+ logon.req.pdc.lmnt_token = 0xFFFF;
+ logon.req.pdc.lm20_token = 0xFFFF;
+
+ make_nbt_name_client(&myname, TEST_NAME);
+
+ dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name,
+ address, lp_dgram_port(tctx->lp_ctx));
+ torture_assert(tctx, dest != NULL, "Error getting address");
+ status = dgram_mailslot_netlogon_send(dgmsock,
+ &name, dest,
+ NBT_MAILSLOT_NTLOGON,
+ &myname, &logon);
+ torture_assert_ntstatus_ok(tctx, status, "Failed to send ntlogon request");
+
+ while (timeval_elapsed(&tv) < 5 && !dgmslot->private) {
+ event_loop_once(dgmsock->event_ctx);
+ }
+
+ response = talloc_get_type(dgmslot->private, struct nbt_netlogon_response);
+
+ torture_assert(tctx, response != NULL, "Failed to receive a netlogon reply packet");
+
+ torture_assert_int_equal(tctx, response->response_type, NETLOGON_GET_PDC, "Got incorrect type of ntlogon response");
+ torture_assert_int_equal(tctx, response->get_pdc.command, NETLOGON_RESPONSE_FROM_PDC, "Got incorrect ntlogon response command");
+
+
return true;
}
diff --git a/source4/torture/nbt/nbt.c b/source4/torture/nbt/nbt.c
index 6cb9507398..422261884f 100644
--- a/source4/torture/nbt/nbt.c
+++ b/source4/torture/nbt/nbt.c
@@ -21,7 +21,7 @@
#include "libcli/nbt/libnbt.h"
#include "torture/torture.h"
#include "torture/nbt/proto.h"
-#include "torture/ui.h"
+#include "torture/smbtorture.h"
#include "libcli/resolve/resolve.h"
#include "param/param.h"
@@ -34,7 +34,7 @@ bool torture_nbt_get_name(struct torture_context *tctx,
/* do an initial name resolution to find its IP */
torture_assert_ntstatus_ok(tctx,
- resolve_name(lp_resolve_context(tctx->lp_ctx), name, tctx, address, NULL),
+ resolve_name(lp_resolve_context(tctx->lp_ctx), name, tctx, address, tctx->ev),
talloc_asprintf(tctx,
"Failed to resolve %s", name->name));
diff --git a/source4/torture/nbt/query.c b/source4/torture/nbt/query.c
index 1ba6172e5c..3f3a15cca5 100644
--- a/source4/torture/nbt/query.c
+++ b/source4/torture/nbt/query.c
@@ -47,7 +47,7 @@ static void increment_handler(struct nbt_name_request *req)
*/
static bool bench_namequery(struct torture_context *tctx)
{
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL,
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev,
lp_iconv_convenience(tctx->lp_ctx));
int num_sent=0;
struct result_struct *result;
diff --git a/source4/torture/nbt/register.c b/source4/torture/nbt/register.c
index b9f06c479d..a8681f828f 100644
--- a/source4/torture/nbt/register.c
+++ b/source4/torture/nbt/register.c
@@ -44,7 +44,7 @@ static bool nbt_register_own(struct torture_context *tctx)
{
struct nbt_name_register io;
NTSTATUS status;
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL,
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev,
lp_iconv_convenience(tctx->lp_ctx));
struct socket_address *socket_address;
struct nbt_name name;
@@ -114,7 +114,7 @@ static bool nbt_refresh_own(struct torture_context *tctx)
{
struct nbt_name_refresh io;
NTSTATUS status;
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL,
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev,
lp_iconv_convenience(tctx->lp_ctx));
const char *myaddress;
struct socket_address *socket_address;
diff --git a/source4/torture/nbt/wins.c b/source4/torture/nbt/wins.c
index 059b2dc919..ae20de6e2f 100644
--- a/source4/torture/nbt/wins.c
+++ b/source4/torture/nbt/wins.c
@@ -53,7 +53,7 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address
struct nbt_name_refresh_wins refresh;
struct nbt_name_release release;
NTSTATUS status;
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
const char *myaddress;
struct socket_address *socket_address;
struct interface *ifaces;
diff --git a/source4/torture/nbt/winsbench.c b/source4/torture/nbt/winsbench.c
index ea4abaf21b..a0d90fb653 100644
--- a/source4/torture/nbt/winsbench.c
+++ b/source4/torture/nbt/winsbench.c
@@ -225,7 +225,7 @@ static void generate_request(struct nbt_name_socket *nbtsock, struct wins_state
*/
static bool bench_wins(struct torture_context *tctx)
{
- struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
int num_sent=0;
struct timeval tv = timeval_current();
bool ret = true;
diff --git a/source4/torture/nbt/winsreplication.c b/source4/torture/nbt/winsreplication.c
index 470eee8310..ee7a1510d5 100644
--- a/source4/torture/nbt/winsreplication.c
+++ b/source4/torture/nbt/winsreplication.c
@@ -103,8 +103,8 @@ static bool test_assoc_ctx1(struct torture_context *tctx)
torture_comment(tctx, "Test if assoc_ctx is only valid on the conection it was created on\n");
- wrepl_socket1 = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
- wrepl_socket2 = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ wrepl_socket1 = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+ wrepl_socket2 = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
torture_comment(tctx, "Setup 2 wrepl connections\n");
status = wrepl_connect(wrepl_socket1, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
@@ -186,7 +186,7 @@ static bool test_assoc_ctx2(struct torture_context *tctx)
torture_comment(tctx, "Test if we always get back the same assoc_ctx\n");
- wrepl_socket = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ wrepl_socket = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
torture_comment(tctx, "Setup wrepl connections\n");
status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
@@ -255,7 +255,7 @@ static bool test_wins_replication(struct torture_context *tctx)
torture_comment(tctx, "Test one pull replication cycle\n");
- wrepl_socket = wrepl_socket_init(tctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ wrepl_socket = wrepl_socket_init(tctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
torture_comment(tctx, "Setup wrepl connections\n");
status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, address), address);
@@ -553,7 +553,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
if (!ctx) return NULL;
ctx->address = address;
- ctx->pull = wrepl_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ ctx->pull = wrepl_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
if (!ctx->pull) return NULL;
torture_comment(tctx, "Setup wrepl conflict pull connection\n");
@@ -610,7 +610,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
talloc_free(pull_table.out.partners);
- ctx->nbtsock = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ ctx->nbtsock = nbt_name_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
if (!ctx->nbtsock) return NULL;
load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
@@ -628,7 +628,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
status = socket_listen(ctx->nbtsock->sock, ctx->myaddr, 0, 0);
if (!NT_STATUS_IS_OK(status)) return NULL;
- ctx->nbtsock_srv = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ ctx->nbtsock_srv = nbt_name_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
if (!ctx->nbtsock_srv) return NULL;
/* Make a port 137 version of ctx->myaddr */
@@ -645,7 +645,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(
}
if (ctx->myaddr2 && ctx->nbtsock_srv) {
- ctx->nbtsock2 = nbt_name_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ ctx->nbtsock2 = nbt_name_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
if (!ctx->nbtsock2) return NULL;
status = socket_listen(ctx->nbtsock2->sock, ctx->myaddr2, 0, 0);
@@ -722,7 +722,7 @@ static bool test_wrepl_update_one(struct torture_context *tctx,
uint32_t assoc_ctx;
NTSTATUS status;
- wrepl_socket = wrepl_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ wrepl_socket = wrepl_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
status = wrepl_connect(wrepl_socket, lp_resolve_context(tctx->lp_ctx), wrepl_best_ip(tctx->lp_ctx, ctx->address), ctx->address);
CHECK_STATUS(tctx, status, NT_STATUS_OK);
diff --git a/source4/torture/ndr/ndr.c b/source4/torture/ndr/ndr.c
index 55b00d1fb8..63636f8c5f 100644
--- a/source4/torture/ndr/ndr.c
+++ b/source4/torture/ndr/ndr.c
@@ -21,7 +21,7 @@
#include "includes.h"
#include "torture/ndr/ndr.h"
#include "torture/ndr/proto.h"
-#include "torture/ui.h"
+#include "torture/torture.h"
#include "util/dlinklist.h"
#include "param/param.h"
diff --git a/source4/torture/ndr/netlogon.c b/source4/torture/ndr/netlogon.c
index 2f01a9d009..a5221f71e9 100644
--- a/source4/torture/ndr/netlogon.c
+++ b/source4/torture/ndr/netlogon.c
@@ -46,7 +46,7 @@ static bool netrserverauthenticate3_in_check(struct torture_context *tctx,
torture_assert_int_equal(tctx, r->in.secure_channel_type, 2, "secure channel type");
torture_assert_str_equal(tctx, r->in.computer_name, "NATIVE-2K", "computer name");
torture_assert_int_equal(tctx, *r->in.negotiate_flags, 0x6007ffff, "negotiate flags");
- torture_assert(tctx, memcmp(cred_expected, r->in.credentials->data, 8) == 0, "credentials");
+ torture_assert_mem_equal(tctx, cred_expected, r->in.credentials->data, 8, "credentials");
return true;
}
@@ -59,7 +59,7 @@ static bool netrserverauthenticate3_out_check(struct torture_context *tctx,
struct netr_ServerAuthenticate3 *r)
{
uint8_t cred_expected[8] = { 0x22, 0x0c, 0x86, 0x8a, 0xe9, 0x92, 0x93, 0xc9 };
- torture_assert(tctx, memcmp(cred_expected, r->out.credentials->data, 8) == 0, "credentials");
+ torture_assert_mem_equal(tctx, cred_expected, r->out.credentials->data, 8, "credentials");
torture_assert_int_equal(tctx, *r->out.negotiate_flags, 0x6007ffff, "negotiate flags");
torture_assert_int_equal(tctx, *r->out.rid, 0x454, "rid");
torture_assert_ntstatus_ok(tctx, r->out.result, "return code");
@@ -80,12 +80,12 @@ static const uint8_t netrserverreqchallenge_in_data[] = {
};
static bool netrserverreqchallenge_in_check(struct torture_context *tctx,
- struct netr_ServerReqChallenge *r)
+ struct netr_ServerReqChallenge *r)
{
uint8_t cred_expected[8] = { 0xa3, 0x2c, 0xa2, 0x95, 0x40, 0xcc, 0xb7, 0xbb };
torture_assert_str_equal(tctx, r->in.server_name, "\\\\NATIVE-DC.NATIVE.BASE", "server name");
torture_assert_str_equal(tctx, r->in.computer_name, "NATIVE-2K", "account name");
- torture_assert(tctx, memcmp(cred_expected, r->in.credentials->data, 8) == 0, "credentials");
+ torture_assert_mem_equal(tctx, cred_expected, r->in.credentials->data, 8, "credentials");
return true;
}
@@ -95,10 +95,10 @@ static const uint8_t netrserverreqchallenge_out_data[] = {
};
static bool netrserverreqchallenge_out_check(struct torture_context *tctx,
- struct netr_ServerReqChallenge *r)
+ struct netr_ServerReqChallenge *r)
{
uint8_t cred_expected[8] = { 0x22, 0xfc, 0xc1, 0x17, 0xc0, 0xae, 0x27, 0x8e };
- torture_assert(tctx, memcmp(cred_expected, r->out.credentials->data, 8) == 0, "credentials");
+ torture_assert_mem_equal(tctx, cred_expected, r->out.credentials->data, 8, "credentials");
torture_assert_ntstatus_ok(tctx, r->out.result, "return code");
return true;
diff --git a/source4/torture/rap/rap.c b/source4/torture/rap/rap.c
index 4b5f4b582c..1ccd1254dd 100644
--- a/source4/torture/rap/rap.c
+++ b/source4/torture/rap/rap.c
@@ -21,7 +21,7 @@
#include "includes.h"
#include "libcli/libcli.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "torture/util.h"
#include "libcli/rap/rap.h"
#include "libcli/raw/libcliraw.h"
diff --git a/source4/torture/raw/composite.c b/source4/torture/raw/composite.c
index 1f31fbc515..d73ac1327e 100644
--- a/source4/torture/raw/composite.c
+++ b/source4/torture/raw/composite.c
@@ -296,7 +296,7 @@ static bool test_appendacl(struct smbcli_state *cli, struct torture_context *tct
c[i]->async.private_data = count;
}
- event_ctx = talloc_reference(tctx, cli->tree->session->transport->socket->event.ctx);
+ event_ctx = tctx->ev;
printf("waiting for completion\n");
while (*count != num_ops) {
event_loop_once(event_ctx);
@@ -354,7 +354,7 @@ static bool test_fsinfo(struct smbcli_state *cli, struct torture_context *tctx)
printf("testing parallel queryfsinfo [Object ID] with %d ops\n", torture_numops);
- event_ctx = talloc_reference(tctx, cli->tree->session->transport->socket->event.ctx);
+ event_ctx = tctx->ev;
c = talloc_array(tctx, struct composite_context *, torture_numops);
for (i=0; i<torture_numops; i++) {
diff --git a/source4/torture/raw/lockbench.c b/source4/torture/raw/lockbench.c
index 86030c538a..21541d003b 100644
--- a/source4/torture/raw/lockbench.c
+++ b/source4/torture/raw/lockbench.c
@@ -316,7 +316,6 @@ bool torture_bench_lock(struct torture_context *torture)
int i;
int timelimit = torture_setting_int(torture, "timelimit", 10);
struct timeval tv;
- struct event_context *ev = event_context_find(mem_ctx);
struct benchlock_state *state;
int total = 0, minops=0;
struct smbcli_state *cli;
@@ -333,8 +332,8 @@ bool torture_bench_lock(struct torture_context *torture)
state[i].tctx = torture;
state[i].mem_ctx = talloc_new(state);
state[i].client_num = i;
- state[i].ev = ev;
- if (!torture_open_connection_ev(&cli, i, torture, ev)) {
+ state[i].ev = torture->ev;
+ if (!torture_open_connection_ev(&cli, i, torture, torture->ev)) {
return false;
}
talloc_steal(mem_ctx, state);
@@ -375,12 +374,12 @@ bool torture_bench_lock(struct torture_context *torture)
tv = timeval_current();
if (progress) {
- event_add_timed(ev, state, timeval_current_ofs(1, 0), report_rate, state);
+ event_add_timed(torture->ev, state, timeval_current_ofs(1, 0), report_rate, state);
}
printf("Running for %d seconds\n", timelimit);
while (timeval_elapsed(&tv) < timelimit) {
- event_loop_once(ev);
+ event_loop_once(torture->ev);
if (lock_failed) {
DEBUG(0,("locking failed\n"));
diff --git a/source4/torture/raw/lookuprate.c b/source4/torture/raw/lookuprate.c
new file mode 100644
index 0000000000..782cb1b31b
--- /dev/null
+++ b/source4/torture/raw/lookuprate.c
@@ -0,0 +1,320 @@
+/*
+ File lookup rate test.
+
+ Copyright (C) James Peach 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 "param/param.h"
+#include "system/filesys.h"
+#include "torture/smbtorture.h"
+#include "torture/basic/proto.h"
+#include "libcli/libcli.h"
+#include "torture/util.h"
+#include "lib/cmdline/popt_common.h"
+#include "auth/credentials/credentials.h"
+
+#define BASEDIR "\\lookuprate"
+#define MISSINGNAME BASEDIR "\\foo"
+
+#define FUZZ_PERCENT 10
+
+#define usec_to_sec(s) ((s) / 1000000)
+#define sec_to_usec(s) ((s) * 1000000)
+
+struct rate_record
+{
+ unsigned dirent_count;
+ unsigned querypath_persec;
+ unsigned findfirst_persec;
+};
+
+static struct rate_record records[] =
+{
+ { 0, 0, 0 }, /* Base (optimal) lookup rate. */
+ { 100, 0, 0},
+ { 1000, 0, 0},
+ { 10000, 0, 0},
+ { 100000, 0, 0}
+};
+
+typedef NTSTATUS lookup_function(struct smbcli_tree *tree, const char * path);
+
+/* Test whether rhs is within fuzz% of lhs. */
+static bool fuzzily_equal(unsigned lhs, unsigned rhs, int percent)
+{
+ double fuzz = (double)lhs * (double)percent/100.0;
+
+ if (((double)rhs >= ((double)lhs - fuzz)) &&
+ ((double)rhs <= ((double)lhs + fuzz))) {
+ return true;
+ }
+
+ return false;
+
+}
+
+static NTSTATUS fill_directory(struct smbcli_tree *tree,
+ const char * path, unsigned count)
+{
+ NTSTATUS status;
+ char *fname = NULL;
+ unsigned i;
+ unsigned current;
+
+ struct timeval start;
+ struct timeval now;
+
+ status = smbcli_mkdir(tree, path);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ printf("filling directory %s with %u files... ", path, count);
+ fflush(stdout);
+
+ current = random();
+ start = timeval_current();
+
+ for (i = 0; i < count; ++i) {
+ int fnum;
+
+ ++current;
+ fname = talloc_asprintf(NULL, "%s\\fill%u",
+ path, current);
+
+ fnum = smbcli_open(tree, fname, O_RDONLY|O_CREAT,
+ OPENX_MODE_DENY_NONE);
+ if (fnum < 0) {
+ talloc_free(fname);
+ return smbcli_nt_error(tree);
+ }
+
+ smbcli_close(tree, fnum);
+ talloc_free(fname);
+ }
+
+ if (count) {
+ double rate;
+ now = timeval_current();
+ rate = (double)count / usec_to_sec((double)usec_time_diff(&now, &start));
+ printf("%u/sec\n", (unsigned)rate);
+ } else {
+ printf("done\n");
+ }
+
+ return NT_STATUS_OK;
+}
+
+static NTSTATUS squash_lookup_error(NTSTATUS status)
+{
+ if (NT_STATUS_IS_OK(status)) {
+ return NT_STATUS_OK;
+ }
+
+ /* We don't care if the file isn't there. */
+ if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_PATH_NOT_FOUND)) {
+ return NT_STATUS_OK;
+ }
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+ return NT_STATUS_OK;
+ }
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NO_SUCH_FILE)) {
+ return NT_STATUS_OK;
+ }
+
+ return status;
+}
+
+/* Look up a pathname using TRANS2_QUERY_PATH_INFORMATION. */
+static NTSTATUS querypath_lookup(struct smbcli_tree *tree, const char * path)
+{
+ NTSTATUS status;
+ time_t ftimes[3];
+ size_t fsize;
+ uint16_t fmode;
+
+ status = smbcli_qpathinfo(tree, path, &ftimes[0], &ftimes[1], &ftimes[2],
+ &fsize, &fmode);
+
+ return squash_lookup_error(status);
+}
+
+/* Look up a pathname using TRANS2_FIND_FIRST2. */
+static NTSTATUS findfirst_lookup(struct smbcli_tree *tree, const char * path)
+{
+ NTSTATUS status = NT_STATUS_OK;
+
+ if (smbcli_list(tree, path, 0, NULL, NULL) < 0) {
+ status = smbcli_nt_error(tree);
+ }
+
+ return squash_lookup_error(status);
+}
+
+static NTSTATUS lookup_rate_convert(struct smbcli_tree *tree,
+ lookup_function lookup, const char * path, unsigned * rate)
+{
+ NTSTATUS status;
+
+ struct timeval start;
+ struct timeval now;
+ unsigned count = 0;
+ int64_t elapsed = 0;
+
+#define LOOKUP_PERIOD_SEC (2)
+
+ start = timeval_current();
+ while (elapsed < sec_to_usec(LOOKUP_PERIOD_SEC)) {
+
+ status = lookup(tree, path);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ ++count;
+ now = timeval_current();
+ elapsed = usec_time_diff(&now, &start);
+ }
+
+#undef LOOKUP_PERIOD_SEC
+
+ *rate = (unsigned)((double)count / (double)usec_to_sec(elapsed));
+ return NT_STATUS_OK;
+}
+
+static bool remove_working_directory(struct smbcli_tree *tree,
+ const char * path)
+{
+ int tries;
+
+ /* Using smbcli_deltree to delete a very large number of files
+ * doesn't work against all servers. Work around this by
+ * retrying.
+ */
+ for (tries = 0; tries < 5; ) {
+ int ret;
+
+ ret = smbcli_deltree(tree, BASEDIR);
+ if (ret == -1) {
+ tries++;
+ printf("(%s) failed to deltree %s: %s\n",
+ __location__, BASEDIR,
+ smbcli_errstr(tree));
+ continue;
+ }
+
+ return true;
+ }
+
+ return false;
+
+}
+
+/* Verify that looking up a file name takes constant time.
+ *
+ * This test samples the lookup rate for a non-existant filename in a
+ * directory, while varying the number of files in the directory. The
+ * lookup rate should continue to approximate the lookup rate for the
+ * empty directory case.
+ */
+bool torture_bench_lookup(struct torture_context *torture)
+{
+ NTSTATUS status;
+ bool result = false;
+
+ int i, tries;
+ struct smbcli_state *cli = NULL;
+
+ if (!torture_open_connection(&cli, torture, 0)) {
+ goto done;
+ }
+
+ remove_working_directory(cli->tree, BASEDIR);
+
+ for (i = 0; i < ARRAY_SIZE(records); ++i) {
+ printf("testing lookup rate with %u directory entries\n",
+ records[i].dirent_count);
+
+ status = fill_directory(cli->tree, BASEDIR,
+ records[i].dirent_count);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("failed to fill directory: %s\n", nt_errstr(status));
+ goto done;
+ }
+
+ status = lookup_rate_convert(cli->tree, querypath_lookup,
+ MISSINGNAME, &records[i].querypath_persec);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("querypathinfo of %s failed: %s\n",
+ MISSINGNAME, nt_errstr(status));
+ goto done;
+ }
+
+ status = lookup_rate_convert(cli->tree, findfirst_lookup,
+ MISSINGNAME, &records[i].findfirst_persec);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("findfirst of %s failed: %s\n",
+ MISSINGNAME, nt_errstr(status));
+ goto done;
+ }
+
+ printf("entries = %u, querypath = %u/sec, findfirst = %u/sec\n",
+ records[i].dirent_count,
+ records[i].querypath_persec,
+ records[i].findfirst_persec);
+
+ if (!remove_working_directory(cli->tree, BASEDIR)) {
+ goto done;
+ }
+ }
+
+ /* Ok. We have run all our tests. Walk through the records we
+ * accumulated and figure out whether the lookups took constant
+ * time of not.
+ */
+ for (i = 0; i < ARRAY_SIZE(records); ++i) {
+ if (!fuzzily_equal(records[0].querypath_persec,
+ records[i].querypath_persec,
+ FUZZ_PERCENT)) {
+ printf("querypath rate for %d entries differed by "
+ "more than %d%% from base rate\n",
+ records[i].dirent_count, FUZZ_PERCENT);
+ result = false;
+ }
+
+ if (!fuzzily_equal(records[0].findfirst_persec,
+ records[i].findfirst_persec,
+ FUZZ_PERCENT)) {
+ printf("findfirst rate for %d entries differed by "
+ "more than %d%% from base rate\n",
+ records[i].dirent_count, FUZZ_PERCENT);
+ result = false;
+ }
+ }
+
+done:
+ if (cli) {
+ remove_working_directory(cli->tree, BASEDIR);
+ talloc_free(cli);
+ }
+
+ return result;
+}
+
+/* vim: set sts=8 sw=8 : */
diff --git a/source4/torture/raw/offline.c b/source4/torture/raw/offline.c
index 1340692faa..9c66c3be9c 100644
--- a/source4/torture/raw/offline.c
+++ b/source4/torture/raw/offline.c
@@ -389,7 +389,6 @@ bool torture_test_offline(struct torture_context *torture)
int i;
int timelimit = torture_setting_int(torture, "timelimit", 10);
struct timeval tv;
- struct event_context *ev = event_context_find(mem_ctx);
struct offline_state *state;
struct smbcli_state *cli;
bool progress;
@@ -404,8 +403,8 @@ bool torture_test_offline(struct torture_context *torture)
for (i=0;i<nconnections;i++) {
state[i].tctx = torture;
state[i].mem_ctx = talloc_new(state);
- state[i].ev = ev;
- if (!torture_open_connection_ev(&cli, i, torture, ev)) {
+ state[i].ev = torture->ev;
+ if (!torture_open_connection_ev(&cli, i, torture, torture->ev)) {
return false;
}
state[i].tree = cli->tree;
@@ -418,7 +417,7 @@ bool torture_test_offline(struct torture_context *torture)
for (i=nconnections;i<numstates;i++) {
state[i].tctx = torture;
state[i].mem_ctx = talloc_new(state);
- state[i].ev = ev;
+ state[i].ev = torture->ev;
state[i].tree = state[i % nconnections].tree;
state[i].client = i;
}
@@ -468,12 +467,12 @@ bool torture_test_offline(struct torture_context *torture)
tv = timeval_current();
if (progress) {
- event_add_timed(ev, state, timeval_current_ofs(1, 0), report_rate, state);
+ event_add_timed(torture->ev, state, timeval_current_ofs(1, 0), report_rate, state);
}
printf("Running for %d seconds\n", timelimit);
while (timeval_elapsed(&tv) < timelimit) {
- event_loop_once(ev);
+ event_loop_once(torture->ev);
if (test_failed) {
DEBUG(0,("test failed\n"));
@@ -487,7 +486,7 @@ bool torture_test_offline(struct torture_context *torture)
while (state[i].loadfile ||
state[i].savefile ||
state[i].req) {
- event_loop_once(ev);
+ event_loop_once(torture->ev);
}
}
diff --git a/source4/torture/raw/open.c b/source4/torture/raw/open.c
index d28a8bd14e..c6ba0d2571 100644
--- a/source4/torture/raw/open.c
+++ b/source4/torture/raw/open.c
@@ -1350,21 +1350,19 @@ static bool test_raw_open_multi(struct torture_context *tctx)
const char *host = torture_setting_string(tctx, "host", NULL);
const char *share = torture_setting_string(tctx, "share", NULL);
int i, num_files = 3;
- struct event_context *ev;
int num_ok = 0;
int num_collision = 0;
- ev = cli_credentials_get_event_context(cmdline_credentials);
clients = talloc_array(mem_ctx, struct smbcli_state *, num_files);
requests = talloc_array(mem_ctx, struct smbcli_request *, num_files);
ios = talloc_array(mem_ctx, union smb_open, num_files);
- if ((ev == NULL) || (clients == NULL) || (requests == NULL) ||
+ if ((tctx->ev == NULL) || (clients == NULL) || (requests == NULL) ||
(ios == NULL)) {
DEBUG(0, ("talloc failed\n"));
return false;
}
- if (!torture_open_connection_share(mem_ctx, &cli, tctx, host, share, ev)) {
+ if (!torture_open_connection_share(mem_ctx, &cli, tctx, host, share, tctx->ev)) {
return false;
}
@@ -1372,7 +1370,7 @@ static bool test_raw_open_multi(struct torture_context *tctx)
for (i=0; i<num_files; i++) {
if (!torture_open_connection_share(mem_ctx, &(clients[i]),
- tctx, host, share, ev)) {
+ tctx, host, share, tctx->ev)) {
DEBUG(0, ("Could not open %d'th connection\n", i));
return false;
}
@@ -1441,7 +1439,7 @@ static bool test_raw_open_multi(struct torture_context *tctx)
break;
}
- if (event_loop_once(ev) != 0) {
+ if (event_loop_once(tctx->ev) != 0) {
DEBUG(0, ("event_loop_once failed\n"));
return false;
}
diff --git a/source4/torture/raw/openbench.c b/source4/torture/raw/openbench.c
index a5b1434a47..26b862c33f 100644
--- a/source4/torture/raw/openbench.c
+++ b/source4/torture/raw/openbench.c
@@ -369,7 +369,6 @@ bool torture_bench_open(struct torture_context *torture)
int i;
int timelimit = torture_setting_int(torture, "timelimit", 10);
struct timeval tv;
- struct event_context *ev = event_context_find(mem_ctx);
struct benchopen_state *state;
int total = 0;
int total_retries = 0;
@@ -387,8 +386,8 @@ bool torture_bench_open(struct torture_context *torture)
state[i].tctx = torture;
state[i].mem_ctx = talloc_new(state);
state[i].client_num = i;
- state[i].ev = ev;
- if (!torture_open_connection_ev(&state[i].cli, i, torture, ev)) {
+ state[i].ev = torture->ev;
+ if (!torture_open_connection_ev(&state[i].cli, i, torture, torture->ev)) {
return false;
}
talloc_steal(mem_ctx, state);
@@ -428,13 +427,13 @@ bool torture_bench_open(struct torture_context *torture)
tv = timeval_current();
if (progress) {
- report_te = event_add_timed(ev, state, timeval_current_ofs(1, 0),
+ report_te = event_add_timed(torture->ev, state, timeval_current_ofs(1, 0),
report_rate, state);
}
printf("Running for %d seconds\n", timelimit);
while (timeval_elapsed(&tv) < timelimit) {
- event_loop_once(ev);
+ event_loop_once(torture->ev);
if (open_failed) {
DEBUG(0,("open failed\n"));
diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c
index 1927a0f027..fd8d292980 100644
--- a/source4/torture/raw/oplock.c
+++ b/source4/torture/raw/oplock.c
@@ -2841,13 +2841,12 @@ bool torture_bench_oplock(struct torture_context *torture)
int timelimit = torture_setting_int(torture, "timelimit", 10);
union smb_open io;
struct timeval tv;
- struct event_context *ev = event_context_find(mem_ctx);
cli = talloc_array(mem_ctx, struct smbcli_state *, torture_nprocs);
torture_comment(torture, "Opening %d connections\n", torture_nprocs);
for (i=0;i<torture_nprocs;i++) {
- if (!torture_open_connection_ev(&cli[i], i, torture, ev)) {
+ if (!torture_open_connection_ev(&cli[i], i, torture, torture->ev)) {
return false;
}
talloc_steal(mem_ctx, cli[i]);
diff --git a/source4/torture/raw/raw.c b/source4/torture/raw/raw.c
index bb3dde728f..0a7fc3ebfd 100644
--- a/source4/torture/raw/raw.c
+++ b/source4/torture/raw/raw.c
@@ -18,10 +18,10 @@
*/
#include "includes.h"
-#include "torture/torture.h"
#include "libcli/raw/libcliraw.h"
-#include "torture/raw/proto.h"
#include "torture/util.h"
+#include "torture/smbtorture.h"
+#include "torture/raw/proto.h"
NTSTATUS torture_raw_init(void)
{
@@ -33,6 +33,10 @@ NTSTATUS torture_raw_init(void)
torture_suite_add_simple_test(suite, "PING-PONG", torture_ping_pong);
torture_suite_add_simple_test(suite, "BENCH-LOCK", torture_bench_lock);
torture_suite_add_simple_test(suite, "BENCH-OPEN", torture_bench_open);
+ torture_suite_add_simple_test(suite, "BENCH-LOOKUP",
+ torture_bench_lookup);
+ torture_suite_add_simple_test(suite, "BENCH-TCON",
+ torture_bench_treeconnect);
torture_suite_add_simple_test(suite, "OFFLINE", torture_test_offline);
torture_suite_add_1smb_test(suite, "QFSINFO", torture_raw_qfsinfo);
torture_suite_add_1smb_test(suite, "QFILEINFO", torture_raw_qfileinfo);
diff --git a/source4/torture/raw/samba3hide.c b/source4/torture/raw/samba3hide.c
index 814b5f57f4..1f1501045c 100644
--- a/source4/torture/raw/samba3hide.c
+++ b/source4/torture/raw/samba3hide.c
@@ -136,7 +136,7 @@ bool torture_samba3_hide(struct torture_context *torture)
if (!torture_open_connection_share(
torture, &cli, torture, torture_setting_string(torture, "host", NULL),
- torture_setting_string(torture, "share", NULL), NULL)) {
+ torture_setting_string(torture, "share", NULL), torture->ev)) {
d_printf("torture_open_connection_share failed\n");
return false;
}
diff --git a/source4/torture/raw/samba3misc.c b/source4/torture/raw/samba3misc.c
index 15a7f6c4a3..27b4d42dd8 100644
--- a/source4/torture/raw/samba3misc.c
+++ b/source4/torture/raw/samba3misc.c
@@ -56,7 +56,7 @@ bool torture_samba3_checkfsp(struct torture_context *torture)
if (!torture_open_connection_share(
torture, &cli, torture, torture_setting_string(torture, "host", NULL),
- torture_setting_string(torture, "share", NULL), NULL)) {
+ torture_setting_string(torture, "share", NULL), torture->ev)) {
d_printf("torture_open_connection_share failed\n");
ret = false;
goto done;
diff --git a/source4/torture/raw/streams.c b/source4/torture/raw/streams.c
index 1dab36c28b..8b2d327653 100644
--- a/source4/torture/raw/streams.c
+++ b/source4/torture/raw/streams.c
@@ -135,6 +135,11 @@ static bool check_stream_list(struct smbcli_state *cli, const char *fname,
goto fail;
}
+ if (num_exp == 0) {
+ ret = true;
+ goto fail;
+ }
+
exp_sort = talloc_memdup(tmp_ctx, exp, num_exp * sizeof(*exp));
if (exp_sort == NULL) {
@@ -170,7 +175,81 @@ static bool check_stream_list(struct smbcli_state *cli, const char *fname,
}
/*
- test basic io on streams
+ test bahavior of streams on directories
+*/
+static bool test_stream_dir(struct torture_context *tctx,
+ struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+{
+ NTSTATUS status;
+ union smb_open io;
+ const char *fname = BASEDIR "\\stream.txt";
+ const char *sname1;
+ bool ret = true;
+ const char *basedir_data;
+
+ basedir_data = talloc_asprintf(mem_ctx, "%s::$DATA", BASEDIR);
+ sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "Stream One");
+
+ printf("(%s) opening non-existant directory stream\n", __location__);
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.flags = 0;
+ io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA;
+ io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = 0;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = sname1;
+ status = smb_raw_open(cli->tree, mem_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY);
+
+ printf("(%s) opening basedir stream\n", __location__);
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.flags = 0;
+ io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA;
+ io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_DIRECTORY;
+ io.ntcreatex.in.share_access = 0;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = basedir_data;
+ status = smb_raw_open(cli->tree, mem_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY);
+
+ printf("(%s) opening basedir ::$DATA stream\n", __location__);
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.flags = 0x10;
+ io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.file_attr = 0;
+ io.ntcreatex.in.share_access = 0;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = basedir_data;
+ status = smb_raw_open(cli->tree, mem_ctx, &io);
+ if (torture_setting_bool(tctx, "samba3", false)) {
+ CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
+ } else {
+ CHECK_STATUS(status, NT_STATUS_FILE_IS_A_DIRECTORY);
+ }
+
+ printf("(%s) list the streams on the basedir\n", __location__);
+ ret &= check_stream_list(cli, BASEDIR, 0, NULL);
+done:
+ return ret;
+}
+
+/*
+ test basic behavior of streams on directories
*/
static bool test_stream_io(struct torture_context *tctx,
struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
@@ -191,12 +270,12 @@ static bool test_stream_io(struct torture_context *tctx,
sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "Stream One");
sname2 = talloc_asprintf(mem_ctx, "%s:%s:$DaTa", fname, "Second Stream");
- printf("(%s) opening non-existant directory stream\n", __location__);
+ printf("(%s) creating a stream on a non-existant file\n", __location__);
io.generic.level = RAW_OPEN_NTCREATEX;
io.ntcreatex.in.root_fid = 0;
io.ntcreatex.in.flags = 0;
io.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA;
- io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+ io.ntcreatex.in.create_options = 0;
io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
io.ntcreatex.in.share_access = 0;
io.ntcreatex.in.alloc_size = 0;
@@ -205,12 +284,6 @@ static bool test_stream_io(struct torture_context *tctx,
io.ntcreatex.in.security_flags = 0;
io.ntcreatex.in.fname = sname1;
status = smb_raw_open(cli->tree, mem_ctx, &io);
- CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY);
-
- printf("(%s) creating a stream on a non-existant file\n", __location__);
- io.ntcreatex.in.create_options = 0;
- io.ntcreatex.in.fname = sname1;
- status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
fnum = io.ntcreatex.out.file.fnum;
@@ -423,7 +496,7 @@ static bool test_stream_delete(struct torture_context *tctx,
sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "Stream One");
- printf("(%s) opening non-existant directory stream\n", __location__);
+ printf("(%s) opening non-existant file stream\n", __location__);
io.generic.level = RAW_OPEN_NTCREATEX;
io.ntcreatex.in.root_fid = 0;
io.ntcreatex.in.flags = 0;
@@ -559,6 +632,8 @@ bool torture_raw_streams(struct torture_context *torture,
return false;
}
+ ret &= test_stream_dir(torture, cli, torture);
+ smb_raw_exit(cli->session);
ret &= test_stream_io(torture, cli, torture);
smb_raw_exit(cli->session);
ret &= test_stream_sharemodes(torture, cli, torture);
diff --git a/source4/torture/raw/tconrate.c b/source4/torture/raw/tconrate.c
new file mode 100644
index 0000000000..6f0ba0d617
--- /dev/null
+++ b/source4/torture/raw/tconrate.c
@@ -0,0 +1,201 @@
+/*
+ SMB tree connection rate test
+
+ Copyright (C) 2006-2007 James Peach
+
+ 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 "libcli/libcli.h"
+#include "libcli/resolve/resolve.h"
+#include "torture/smbtorture.h"
+#include "lib/cmdline/popt_common.h"
+#include "param/param.h"
+
+#include "system/filesys.h"
+#include "system/shmem.h"
+
+#define TIME_LIMIT_SECS 30
+#define usec_to_sec(s) ((s) / 1000000)
+#define sec_to_usec(s) ((s) * 1000000)
+
+/* Map a shared memory buffer of at least nelem counters. */
+static void * map_count_buffer(unsigned nelem, size_t elemsz)
+{
+ void * buf;
+ size_t bufsz;
+ size_t pagesz = getpagesize();
+
+ bufsz = nelem * elemsz;
+ bufsz = (bufsz + pagesz) % pagesz; /* round up to pagesz */
+
+#ifdef MAP_ANON
+ /* BSD */
+ buf = mmap(NULL, bufsz, PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED,
+ -1 /* fd */, 0 /* offset */);
+#else
+ buf = mmap(NULL, bufsz, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED,
+ open("/dev/zero", O_RDWR), 0 /* offset */);
+#endif
+
+ if (buf == MAP_FAILED) {
+ printf("failed to map count buffer: %s\n",
+ strerror(errno));
+ return NULL;
+ }
+
+ return buf;
+
+}
+
+static int fork_tcon_client(struct torture_context *tctx,
+ int *tcon_count, unsigned tcon_timelimit,
+ const char *host, const char *share)
+{
+ pid_t child;
+ struct smbcli_state *cli;
+ struct timeval end;
+ struct timeval now;
+ struct smbcli_options options;
+
+ lp_smbcli_options(tctx->lp_ctx, &options);
+
+ child = fork();
+ if (child == -1) {
+ printf("failed to fork child: %s\n,", strerror(errno));
+ return -1;
+ } else if (child != 0) {
+ /* Parent, just return. */
+ return 0;
+ }
+
+ /* Child. Just make as many connections as possible within the
+ * time limit. Don't bother synchronising the child start times
+ * because it's probably not work the effort, and a bit of startup
+ * jitter is probably a more realistic test.
+ */
+
+
+ end = timeval_current();
+ now = timeval_current();
+ end.tv_sec += tcon_timelimit;
+ *tcon_count = 0;
+
+ while (timeval_compare(&now, &end) == -1) {
+ NTSTATUS status;
+
+ status = smbcli_full_connection(NULL, &cli,
+ host, lp_smb_ports(tctx->lp_ctx), share,
+ NULL, cmdline_credentials,
+ lp_resolve_context(tctx->lp_ctx),
+ tctx->ev, &options);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("failed to connect to //%s/%s: %s\n",
+ host, share, nt_errstr(status));
+ goto done;
+ }
+
+ smbcli_tdis(cli);
+
+ *tcon_count = *tcon_count + 1;
+ now = timeval_current();
+ }
+
+done:
+ exit(0);
+}
+
+static bool children_remain(void)
+{
+ /* Reap as many children as possible. */
+ for (;;) {
+ pid_t ret = waitpid(-1, NULL, WNOHANG);
+ if (ret == 0) {
+ /* no children ready */
+ return true;
+ }
+ if (ret == -1) {
+ /* no children left. maybe */
+ return errno == ECHILD ? false : true;
+ }
+ }
+
+ /* notreached */
+ return false;
+}
+
+static double rate_convert_secs(unsigned count,
+ const struct timeval *start, const struct timeval *end)
+{
+ return (double)count /
+ usec_to_sec((double)usec_time_diff(end, start));
+}
+
+/* Test the rate at which the server will accept connections. */
+bool torture_bench_treeconnect(struct torture_context *tctx)
+{
+ const char *host = torture_setting_string(tctx, "host", NULL);
+ const char *share = torture_setting_string(tctx, "share", NULL);
+
+ int timelimit = torture_setting_int(tctx, "timelimit",
+ TIME_LIMIT_SECS);
+ int nprocs = torture_setting_int(tctx, "nprocs", 4);
+
+ int *curr_counts = map_count_buffer(nprocs, sizeof(int));
+ int *last_counts = talloc_array(NULL, int, nprocs);
+
+ struct timeval now, last, start;
+ int i, delta;
+
+ torture_assert(tctx, nprocs > 0, "bad proc count");
+ torture_assert(tctx, timelimit > 0, "bad timelimit");
+ torture_assert(tctx, curr_counts, "allocation failure");
+ torture_assert(tctx, last_counts, "allocation failure");
+
+ start = last = timeval_current();
+ for (i = 0; i < nprocs; ++i) {
+ fork_tcon_client(tctx, &curr_counts[i], timelimit, host, share);
+ }
+
+ while (children_remain()) {
+
+ sleep(1);
+ now = timeval_current();
+
+ for (i = 0, delta = 0; i < nprocs; ++i) {
+ delta += curr_counts[i] - last_counts[i];
+ }
+
+ printf("%u connections/sec\n",
+ (unsigned)rate_convert_secs(delta, &last, &now));
+
+ memcpy(last_counts, curr_counts, nprocs * sizeof(int));
+ last = timeval_current();
+ }
+
+ now = timeval_current();
+
+ for (i = 0, delta = 0; i < nprocs; ++i) {
+ delta += curr_counts[i];
+ }
+
+ printf("TOTAL: %u connections/sec over %u secs\n",
+ (unsigned)rate_convert_secs(delta, &start, &now),
+ timelimit);
+ return true;
+}
+
+/* vim: set sts=8 sw=8 : */
diff --git a/source4/torture/rpc/async_bind.c b/source4/torture/rpc/async_bind.c
index 1ca3c62df0..0ebbef1ce6 100644
--- a/source4/torture/rpc/async_bind.c
+++ b/source4/torture/rpc/async_bind.c
@@ -39,7 +39,6 @@ bool torture_async_bind(struct torture_context *torture)
{
NTSTATUS status;
TALLOC_CTX *mem_ctx;
- struct event_context *evt_ctx;
int i;
const char *binding_string;
struct cli_credentials *creds;
@@ -70,15 +69,11 @@ bool torture_async_bind(struct torture_context *torture)
/* credentials */
creds = cmdline_credentials;
- /* event context */
- evt_ctx = cli_credentials_get_event_context(creds);
- if (evt_ctx == NULL) return false;
-
/* send bind requests */
for (i = 0; i < torture_numasync; i++) {
table[i] = &ndr_table_lsarpc;
bind_req[i] = dcerpc_pipe_connect_send(mem_ctx, binding_string,
- table[i], creds, evt_ctx, torture->lp_ctx);
+ table[i], creds, torture->ev, torture->lp_ctx);
}
/* recv bind requests */
diff --git a/source4/torture/rpc/dfs.c b/source4/torture/rpc/dfs.c
index 9cfdd80578..1c81766ebe 100644
--- a/source4/torture/rpc/dfs.c
+++ b/source4/torture/rpc/dfs.c
@@ -56,7 +56,7 @@ static bool test_NetShareAdd(TALLOC_CTX *mem_ctx,
printf("Creating share %s\n", sharename);
- if (!(libnetctx = libnet_context_init(NULL, tctx->lp_ctx))) {
+ if (!(libnetctx = libnet_context_init(tctx->ev, tctx->lp_ctx))) {
return false;
}
@@ -96,7 +96,7 @@ static bool test_NetShareDel(TALLOC_CTX *mem_ctx,
printf("Deleting share %s\n", sharename);
- if (!(libnetctx = libnet_context_init(NULL, tctx->lp_ctx))) {
+ if (!(libnetctx = libnet_context_init(tctx->ev, tctx->lp_ctx))) {
return false;
}
@@ -124,7 +124,7 @@ static bool test_CreateDir(TALLOC_CTX *mem_ctx,
{
printf("Creating directory %s\n", dir);
- if (!torture_open_connection_share(mem_ctx, cli, tctx, host, share, NULL)) {
+ if (!torture_open_connection_share(mem_ctx, cli, tctx, host, share, tctx->ev)) {
return false;
}
@@ -494,7 +494,7 @@ static void test_cleanup_stdroot(struct dcerpc_pipe *p,
test_RemoveStdRoot(p, mem_ctx, host, sharename);
test_NetShareDel(mem_ctx, tctx, host, sharename);
- torture_open_connection_share(mem_ctx, &cli, tctx, host, "C$", NULL);
+ torture_open_connection_share(mem_ctx, &cli, tctx, host, "C$", tctx->ev);
test_DeleteDir(cli, dir);
torture_close_connection(cli);
}
diff --git a/source4/torture/rpc/dssync.c b/source4/torture/rpc/dssync.c
index b28e429a75..989a1faf27 100644
--- a/source4/torture/rpc/dssync.c
+++ b/source4/torture/rpc/dssync.c
@@ -178,12 +178,11 @@ static bool _test_DsBind(struct torture_context *tctx,
{
NTSTATUS status;
bool ret = true;
- struct event_context *event = NULL;
status = dcerpc_pipe_connect_b(ctx,
&b->pipe, ctx->drsuapi_binding,
&ndr_table_drsuapi,
- credentials, event, tctx->lp_ctx);
+ credentials, tctx->ev, tctx->lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status));
@@ -254,10 +253,11 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx)
struct drsuapi_DsCrackNames r;
struct drsuapi_DsNameString names[1];
bool ret = true;
-
- struct cldap_socket *cldap = cldap_socket_init(ctx, NULL, lp_iconv_convenience(tctx->lp_ctx));
+ struct cldap_socket *cldap;
struct cldap_netlogon search;
-
+
+ cldap = cldap_socket_init(ctx, tctx->ev, lp_iconv_convenience(tctx->lp_ctx));
+
r.in.bind_handle = &ctx->admin.drsuapi.bind_handle;
r.in.level = 1;
r.in.req.req1.codepage = 1252; /* western european */
@@ -288,16 +288,17 @@ static bool test_GetInfo(struct torture_context *tctx, struct DsSyncTest *ctx)
search.in.dest_address = ctx->drsuapi_binding->host;
search.in.dest_port = lp_cldap_port(tctx->lp_ctx);
search.in.acct_control = -1;
- search.in.version = 6;
+ search.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX;
+ search.in.map_response = true;
status = cldap_netlogon(cldap, ctx, &search);
if (!NT_STATUS_IS_OK(status)) {
const char *errstr = nt_errstr(status);
ctx->site_name = talloc_asprintf(ctx, "%s", "Default-First-Site-Name");
printf("cldap_netlogon() returned %s. Defaulting to Site-Name: %s\n", errstr, ctx->site_name);
} else {
- ctx->site_name = talloc_steal(ctx, search.out.netlogon.logon5.client_site);
+ ctx->site_name = talloc_steal(ctx, search.out.netlogon.nt5_ex.client_site);
printf("cldap_netlogon() returned Client Site-Name: %s.\n",ctx->site_name);
- printf("cldap_netlogon() returned Server Site-Name: %s.\n",search.out.netlogon.logon5.server_site);
+ printf("cldap_netlogon() returned Server Site-Name: %s.\n",search.out.netlogon.nt5_ex.server_site);
}
return ret;
diff --git a/source4/torture/rpc/join.c b/source4/torture/rpc/join.c
index 849b9fd1e9..cd5eb32fa8 100644
--- a/source4/torture/rpc/join.c
+++ b/source4/torture/rpc/join.c
@@ -39,7 +39,7 @@ bool torture_rpc_join(struct torture_context *torture)
"IPC$", NULL,
machine_account,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
TORTURE_NETBIOS_NAME));
@@ -65,7 +65,7 @@ bool torture_rpc_join(struct torture_context *torture)
"IPC$", NULL,
machine_account,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n",
TORTURE_NETBIOS_NAME));
diff --git a/source4/torture/rpc/rpc.c b/source4/torture/rpc/rpc.c
index 6e38d0465a..acc1220ccc 100644
--- a/source4/torture/rpc/rpc.c
+++ b/source4/torture/rpc/rpc.c
@@ -23,7 +23,7 @@
#include "lib/cmdline/popt_common.h"
#include "librpc/rpc/dcerpc.h"
#include "torture/rpc/rpc.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "librpc/ndr/ndr_table.h"
#include "lib/util/dlinklist.h"
@@ -83,7 +83,7 @@ _PUBLIC_ NTSTATUS torture_rpc_connection(struct torture_context *tctx,
status = dcerpc_pipe_connect_b(tctx,
p, binding, table,
- cmdline_credentials, NULL, tctx->lp_ctx);
+ cmdline_credentials, tctx->ev, tctx->lp_ctx);
if (NT_STATUS_IS_ERR(status)) {
printf("Failed to connect to remote server: %s %s\n",
@@ -113,7 +113,7 @@ NTSTATUS torture_rpc_connection_transport(struct torture_context *tctx,
binding->assoc_group_id = assoc_group_id;
status = dcerpc_pipe_connect_b(tctx, p, binding, table,
- cmdline_credentials, NULL, tctx->lp_ctx);
+ cmdline_credentials, tctx->ev, tctx->lp_ctx);
if (NT_STATUS_IS_ERR(status)) {
*p = NULL;
@@ -147,7 +147,7 @@ static bool torture_rpc_setup_machine(struct torture_context *tctx,
&(tcase_data->pipe),
binding,
tcase->table,
- tcase_data->credentials, NULL, tctx->lp_ctx);
+ tcase_data->credentials, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status, "Error connecting to server");
@@ -205,7 +205,7 @@ static bool torture_rpc_setup_anonymous(struct torture_context *tctx,
&(tcase_data->pipe),
binding,
tcase->table,
- tcase_data->credentials, NULL, tctx->lp_ctx);
+ tcase_data->credentials, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status, "Error connecting to server");
@@ -399,6 +399,7 @@ NTSTATUS torture_rpc_init(void)
torture_suite_add_simple_test(suite, "SAMSYNC", torture_rpc_samsync);
torture_suite_add_simple_test(suite, "SCHANNEL", torture_rpc_schannel);
torture_suite_add_simple_test(suite, "SCHANNEL2", torture_rpc_schannel2);
+ torture_suite_add_simple_test(suite, "BENCH-SCHANNEL1", torture_rpc_schannel_bench1);
torture_suite_add_suite(suite, torture_rpc_srvsvc(suite));
torture_suite_add_suite(suite, torture_rpc_svcctl(suite));
torture_suite_add_suite(suite, torture_rpc_samr_accessmask(suite));
diff --git a/source4/torture/rpc/rpc.h b/source4/torture/rpc/rpc.h
index d0a0727787..48db814b7a 100644
--- a/source4/torture/rpc/rpc.h
+++ b/source4/torture/rpc/rpc.h
@@ -28,7 +28,7 @@
#include "librpc/rpc/dcerpc.h"
#include "libcli/raw/libcliraw.h"
#include "torture/rpc/proto.h"
-#include "torture/ui.h"
+#include "torture/torture.h"
struct torture_rpc_tcase {
struct torture_tcase tcase;
diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c
index 8eb1f54b4f..17342f9b86 100644
--- a/source4/torture/rpc/samba3rpc.c
+++ b/source4/torture/rpc/samba3rpc.c
@@ -89,7 +89,7 @@ bool torture_bind_authcontext(struct torture_context *torture)
lp_smb_ports(torture->lp_ctx),
"IPC$", NULL, cmdline_credentials,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_full_connection failed: %s\n",
nt_errstr(status));
@@ -303,7 +303,7 @@ bool torture_bind_samba3(struct torture_context *torture)
lp_smb_ports(torture->lp_ctx),
"IPC$", NULL, cmdline_credentials,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_full_connection failed: %s\n",
nt_errstr(status));
@@ -426,7 +426,7 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli,
"builtin") ? 1:0;
l.in.connect_handle = &conn_handle;
- domain_name.string = enumdom.out.sam->entries[0].name.string;
+ domain_name.string = enumdom.out.sam->entries[dom_idx].name.string;
*domain = talloc_strdup(mem_ctx, domain_name.string);
l.in.domain_name = &domain_name;
@@ -1220,7 +1220,7 @@ bool torture_netlogon_samba3(struct torture_context *torture)
lp_smb_ports(torture->lp_ctx),
"IPC$", NULL, anon_creds,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_full_connection failed: %s\n",
nt_errstr(status));
@@ -1307,7 +1307,7 @@ static bool test_join3(struct torture_context *tctx,
lp_smb_ports(tctx->lp_ctx),
"IPC$", NULL, smb_creds,
lp_resolve_context(tctx->lp_ctx),
- NULL, &options);
+ tctx->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("smbcli_full_connection failed: %s\n",
nt_errstr(status));
@@ -1682,7 +1682,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
lp_smb_ports(torture->lp_ctx),
"IPC$", NULL, cmdline_credentials,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) smbcli_full_connection failed: %s\n",
__location__, nt_errstr(status));
@@ -1709,7 +1709,7 @@ bool torture_samba3_rpc_getusername(struct torture_context *torture)
lp_smb_ports(torture->lp_ctx),
"IPC$", NULL, anon_creds,
lp_resolve_context(torture->lp_ctx),
- NULL, &options);
+ torture->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
d_printf("(%s) anon smbcli_full_connection failed: %s\n",
__location__, nt_errstr(status));
@@ -1924,7 +1924,7 @@ bool torture_samba3_rpc_srvsvc(struct torture_context *torture)
if (!(torture_open_connection_share(
mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
- "IPC$", NULL))) {
+ "IPC$", torture->ev))) {
talloc_free(mem_ctx);
return false;
}
@@ -1986,7 +1986,7 @@ bool torture_samba3_rpc_randomauth2(struct torture_context *torture)
if (!(torture_open_connection_share(
mem_ctx, &cli,
torture, torture_setting_string(torture, "host", NULL),
- "IPC$", NULL))) {
+ "IPC$", torture->ev))) {
d_printf("IPC$ connection failed\n");
goto done;
}
@@ -2281,7 +2281,7 @@ bool torture_samba3_rpc_sharesec(struct torture_context *torture)
if (!(torture_open_connection_share(
mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
- "IPC$", NULL))) {
+ "IPC$", torture->ev))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
return false;
@@ -2329,7 +2329,7 @@ bool torture_samba3_rpc_lsa(struct torture_context *torture)
if (!(torture_open_connection_share(
mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
- "IPC$", NULL))) {
+ "IPC$", torture->ev))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
return false;
@@ -2611,7 +2611,7 @@ bool torture_samba3_rpc_spoolss(struct torture_context *torture)
if (!(torture_open_connection_share(
mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
- "IPC$", NULL))) {
+ "IPC$", torture->ev))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
return false;
@@ -2797,7 +2797,7 @@ bool torture_samba3_rpc_wkssvc(struct torture_context *torture)
if (!(torture_open_connection_share(
mem_ctx, &cli, torture, torture_setting_string(torture, "host", NULL),
- "IPC$", NULL))) {
+ "IPC$", torture->ev))) {
d_printf("IPC$ connection failed\n");
talloc_free(mem_ctx);
return false;
diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c
index 24b2511bc7..ab3283a952 100644
--- a/source4/torture/rpc/samlogon.c
+++ b/source4/torture/rpc/samlogon.c
@@ -1602,7 +1602,7 @@ bool torture_rpc_samlogon(struct torture_context *torture)
status = dcerpc_pipe_connect_b(mem_ctx, &p, b,
&ndr_table_netlogon,
- machine_credentials, NULL, torture->lp_ctx);
+ machine_credentials, torture->ev, torture->lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
d_printf("RPC pipe connect as domain member failed: %s\n", nt_errstr(status));
diff --git a/source4/torture/rpc/samsync.c b/source4/torture/rpc/samsync.c
index 3b152d92aa..9705f7b0de 100644
--- a/source4/torture/rpc/samsync.c
+++ b/source4/torture/rpc/samsync.c
@@ -1560,7 +1560,7 @@ bool torture_rpc_samsync(struct torture_context *torture)
status = dcerpc_pipe_connect_b(samsync_state,
&samsync_state->p, b,
&ndr_table_netlogon,
- credentials, NULL, torture->lp_ctx);
+ credentials, torture->ev, torture->lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status));
@@ -1598,7 +1598,7 @@ bool torture_rpc_samsync(struct torture_context *torture)
&samsync_state->p_netlogon_wksta,
b_netlogon_wksta,
&ndr_table_netlogon,
- credentials_wksta, NULL, torture->lp_ctx);
+ credentials_wksta, torture->ev, torture->lp_ctx);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to server as a Workstation: %s\n", nt_errstr(status));
diff --git a/source4/torture/rpc/schannel.c b/source4/torture/rpc/schannel.c
index 19b871f9c0..a8f70b2ea9 100644
--- a/source4/torture/rpc/schannel.c
+++ b/source4/torture/rpc/schannel.c
@@ -33,6 +33,8 @@
#include "param/param.h"
#include "librpc/rpc/dcerpc_proto.h"
#include "auth/gensec/gensec.h"
+#include "libcli/composite/composite.h"
+#include "lib/events/events.h"
#define TEST_MACHINE_NAME "schannel"
@@ -258,7 +260,7 @@ static bool test_schannel(struct torture_context *tctx,
b->flags |= dcerpc_flags;
status = dcerpc_pipe_connect_b(tctx, &p, b, &ndr_table_samr,
- credentials, NULL, tctx->lp_ctx);
+ credentials, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status,
"Failed to connect with schannel");
@@ -270,7 +272,7 @@ static bool test_schannel(struct torture_context *tctx,
* the second */
/* Swap the binding details from SAMR to NETLOGON */
- status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, NULL, tctx->lp_ctx);
+ status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status, "epm map");
status = dcerpc_secondary_connection(p, &p_netlogon,
@@ -296,7 +298,7 @@ static bool test_schannel(struct torture_context *tctx,
"Failed to process schannel secured NETLOGON EX ops");
/* Swap the binding details from SAMR to LSARPC */
- status = dcerpc_epm_map_binding(tctx, b, &ndr_table_lsarpc, NULL, tctx->lp_ctx);
+ status = dcerpc_epm_map_binding(tctx, b, &ndr_table_lsarpc, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status, "epm map");
status = dcerpc_secondary_connection(p, &p_lsa,
@@ -328,7 +330,7 @@ static bool test_schannel(struct torture_context *tctx,
b->flags |= dcerpc_flags;
status = dcerpc_pipe_connect_b(tctx, &p_samr2, b, &ndr_table_samr,
- credentials, NULL, tctx->lp_ctx);
+ credentials, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status,
"Failed to connect with schannel");
@@ -337,7 +339,7 @@ static bool test_schannel(struct torture_context *tctx,
"Failed to process schannel secured SAMR ops (on fresh connection)");
/* Swap the binding details from SAMR to NETLOGON */
- status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, NULL, tctx->lp_ctx);
+ status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status, "epm");
status = dcerpc_secondary_connection(p_samr2, &p_netlogon2,
@@ -370,7 +372,7 @@ static bool test_schannel(struct torture_context *tctx,
b->flags &= ~DCERPC_AUTH_OPTIONS;
status = dcerpc_pipe_connect_b(tctx, &p_netlogon3, b, &ndr_table_netlogon,
- credentials, NULL, tctx->lp_ctx);
+ credentials, tctx->ev, tctx->lp_ctx);
torture_assert_ntstatus_ok(tctx, status, "Failed to connect without schannel");
torture_assert(tctx, !test_netlogon_ex_ops(p_netlogon3, tctx, credentials, creds),
@@ -453,12 +455,12 @@ bool torture_rpc_schannel2(struct torture_context *torture)
printf("Opening first connection\n");
status = dcerpc_pipe_connect_b(torture, &p1, b, &ndr_table_netlogon,
- credentials1, NULL, torture->lp_ctx);
+ credentials1, torture->ev, torture->lp_ctx);
torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel");
torture_comment(torture, "Opening second connection\n");
status = dcerpc_pipe_connect_b(torture, &p2, b, &ndr_table_netlogon,
- credentials2, NULL, torture->lp_ctx);
+ credentials2, torture->ev, torture->lp_ctx);
torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel");
credentials1->netlogon_creds = NULL;
@@ -484,3 +486,350 @@ bool torture_rpc_schannel2(struct torture_context *torture)
return true;
}
+struct torture_schannel_bench;
+
+struct torture_schannel_bench_conn {
+ struct torture_schannel_bench *s;
+ int index;
+ struct cli_credentials *wks_creds;
+ struct dcerpc_pipe *pipe;
+ struct netr_LogonSamLogonEx r;
+ struct netr_NetworkInfo ninfo;
+ TALLOC_CTX *tmp;
+ uint64_t total;
+ uint32_t count;
+};
+
+struct torture_schannel_bench {
+ struct torture_context *tctx;
+ bool progress;
+ int timelimit;
+ int nprocs;
+ int nconns;
+ struct torture_schannel_bench_conn *conns;
+ struct test_join *join_ctx1;
+ struct cli_credentials *wks_creds1;
+ struct test_join *join_ctx2;
+ struct cli_credentials *wks_creds2;
+ struct cli_credentials *user1_creds;
+ struct cli_credentials *user2_creds;
+ struct dcerpc_binding *b;
+ NTSTATUS error;
+ uint64_t total;
+ uint32_t count;
+ bool stopped;
+};
+
+static void torture_schannel_bench_connected(struct composite_context *c)
+{
+ struct torture_schannel_bench_conn *conn =
+ (struct torture_schannel_bench_conn *)c->async.private_data;
+ struct torture_schannel_bench *s = talloc_get_type(conn->s,
+ struct torture_schannel_bench);
+
+ s->error = dcerpc_pipe_connect_b_recv(c, s->conns, &conn->pipe);
+ torture_comment(s->tctx, "conn[%u]: %s\n", conn->index, nt_errstr(s->error));
+ if (NT_STATUS_IS_OK(s->error)) {
+ s->nconns++;
+ }
+}
+
+static void torture_schannel_bench_recv(struct rpc_request *req);
+
+static bool torture_schannel_bench_start(struct torture_schannel_bench_conn *conn)
+{
+ struct torture_schannel_bench *s = conn->s;
+ NTSTATUS status;
+ DATA_BLOB names_blob, chal, lm_resp, nt_resp;
+ int flags = CLI_CRED_NTLM_AUTH;
+ struct rpc_request *req;
+ struct cli_credentials *user_creds;
+
+ if (conn->total % 2) {
+ user_creds = s->user1_creds;
+ } else {
+ user_creds = s->user2_creds;
+ }
+
+ if (lp_client_lanman_auth(s->tctx->lp_ctx)) {
+ flags |= CLI_CRED_LANMAN_AUTH;
+ }
+
+ if (lp_client_ntlmv2_auth(s->tctx->lp_ctx)) {
+ flags |= CLI_CRED_NTLMv2_AUTH;
+ }
+
+ talloc_free(conn->tmp);
+ conn->tmp = talloc_new(s);
+ ZERO_STRUCT(conn->ninfo);
+ ZERO_STRUCT(conn->r);
+
+ cli_credentials_get_ntlm_username_domain(user_creds, conn->tmp,
+ &conn->ninfo.identity_info.account_name.string,
+ &conn->ninfo.identity_info.domain_name.string);
+
+ generate_random_buffer(conn->ninfo.challenge,
+ sizeof(conn->ninfo.challenge));
+ chal = data_blob_const(conn->ninfo.challenge,
+ sizeof(conn->ninfo.challenge));
+
+ names_blob = NTLMv2_generate_names_blob(conn->tmp, lp_iconv_convenience(s->tctx->lp_ctx),
+ cli_credentials_get_workstation(conn->wks_creds),
+ cli_credentials_get_domain(conn->wks_creds));
+
+ status = cli_credentials_get_ntlm_response(user_creds, conn->tmp,
+ &flags,
+ chal,
+ names_blob,
+ &lm_resp, &nt_resp,
+ NULL, NULL);
+ torture_assert_ntstatus_ok(s->tctx, status,
+ "cli_credentials_get_ntlm_response failed");
+
+ conn->ninfo.lm.data = lm_resp.data;
+ conn->ninfo.lm.length = lm_resp.length;
+
+ conn->ninfo.nt.data = nt_resp.data;
+ conn->ninfo.nt.length = nt_resp.length;
+
+ conn->ninfo.identity_info.parameter_control = 0;
+ conn->ninfo.identity_info.logon_id_low = 0;
+ conn->ninfo.identity_info.logon_id_high = 0;
+ conn->ninfo.identity_info.workstation.string = cli_credentials_get_workstation(conn->wks_creds);
+
+ conn->r.in.server_name = talloc_asprintf(conn->tmp, "\\\\%s", dcerpc_server_name(conn->pipe));
+ conn->r.in.computer_name = cli_credentials_get_workstation(conn->wks_creds);
+ conn->r.in.logon_level = 2;
+ conn->r.in.logon.network = &conn->ninfo;
+ conn->r.in.flags = 0;
+ conn->r.in.validation_level = 2;
+
+ req = dcerpc_netr_LogonSamLogonEx_send(conn->pipe, conn->tmp, &conn->r);
+ torture_assert(s->tctx, req, "Failed to setup LogonSamLogonEx request");
+
+ req->async.callback = torture_schannel_bench_recv;
+ req->async.private_data = conn;
+
+ return true;
+}
+
+static void torture_schannel_bench_recv(struct rpc_request *req)
+{
+ bool ret;
+ struct torture_schannel_bench_conn *conn =
+ (struct torture_schannel_bench_conn *)req->async.private_data;
+ struct torture_schannel_bench *s = talloc_get_type(conn->s,
+ struct torture_schannel_bench);
+
+ s->error = dcerpc_ndr_request_recv(req);
+ if (!NT_STATUS_IS_OK(s->error)) {
+ return;
+ }
+
+ conn->total++;
+ conn->count++;
+
+ if (s->stopped) {
+ return;
+ }
+
+ ret = torture_schannel_bench_start(conn);
+ if (!ret) {
+ s->error = NT_STATUS_INTERNAL_ERROR;
+ }
+}
+
+/*
+ test multiple schannel connection in parallel
+ */
+bool torture_rpc_schannel_bench1(struct torture_context *torture)
+{
+ bool ret = true;
+ NTSTATUS status;
+ const char *binding = torture_setting_string(torture, "binding", NULL);
+ struct torture_schannel_bench *s;
+ struct timeval start;
+ struct timeval end;
+ int i;
+ const char *tmp;
+
+ s = talloc_zero(torture, struct torture_schannel_bench);
+ s->tctx = torture;
+ s->progress = torture_setting_bool(torture, "progress", true);
+ s->timelimit = torture_setting_int(torture, "timelimit", 10);
+ s->nprocs = torture_setting_int(torture, "nprocs", 4);
+ s->conns = talloc_zero_array(s, struct torture_schannel_bench_conn, s->nprocs);
+
+ s->user1_creds = (struct cli_credentials *)talloc_memdup(s,
+ cmdline_credentials,
+ sizeof(*s->user1_creds));
+ tmp = torture_setting_string(s->tctx, "extra_user1", NULL);
+ if (tmp) {
+ cli_credentials_parse_string(s->user1_creds, tmp, CRED_SPECIFIED);
+ }
+ s->user2_creds = (struct cli_credentials *)talloc_memdup(s,
+ cmdline_credentials,
+ sizeof(*s->user1_creds));
+ tmp = torture_setting_string(s->tctx, "extra_user2", NULL);
+ if (tmp) {
+ cli_credentials_parse_string(s->user1_creds, tmp, CRED_SPECIFIED);
+ }
+
+ s->join_ctx1 = torture_join_domain(s->tctx, talloc_asprintf(s, "%sb", TEST_MACHINE_NAME),
+ ACB_WSTRUST, &s->wks_creds1);
+ torture_assert(torture, s->join_ctx1 != NULL,
+ "Failed to join domain with acct_flags=ACB_WSTRUST");
+ s->join_ctx2 = torture_join_domain(s->tctx, talloc_asprintf(s, "%sc", TEST_MACHINE_NAME),
+ ACB_WSTRUST, &s->wks_creds2);
+ torture_assert(torture, s->join_ctx2 != NULL,
+ "Failed to join domain with acct_flags=ACB_WSTRUST");
+
+ cli_credentials_set_kerberos_state(s->wks_creds1, CRED_DONT_USE_KERBEROS);
+ cli_credentials_set_kerberos_state(s->wks_creds2, CRED_DONT_USE_KERBEROS);
+
+ for (i=0; i < s->nprocs; i++) {
+ s->conns[i].s = s;
+ s->conns[i].index = i;
+ s->conns[i].wks_creds = (struct cli_credentials *)talloc_memdup(
+ s->conns, s->wks_creds1,sizeof(*s->wks_creds1));
+ if ((i % 2) && (torture_setting_bool(torture, "multijoin", false))) {
+ memcpy(s->conns[i].wks_creds, s->wks_creds2,
+ talloc_get_size(s->conns[i].wks_creds));
+ }
+ s->conns[i].wks_creds->netlogon_creds = NULL;
+ }
+
+ status = dcerpc_parse_binding(s, binding, &s->b);
+ torture_assert_ntstatus_ok(torture, status, "Bad binding string");
+ s->b->flags &= ~DCERPC_AUTH_OPTIONS;
+ s->b->flags |= DCERPC_SCHANNEL | DCERPC_SIGN;
+
+ torture_comment(torture, "Opening %d connections in parallel\n", s->nprocs);
+ for (i=0; i < s->nprocs; i++) {
+#if 1
+ s->error = dcerpc_pipe_connect_b(s->conns, &s->conns[i].pipe, s->b,
+ &ndr_table_netlogon,
+ s->conns[i].wks_creds,
+ torture->ev, torture->lp_ctx);
+ torture_assert_ntstatus_ok(torture, s->error, "Failed to connect with schannel");
+#else
+ /*
+ * This path doesn't work against windows,
+ * because of windows drops the connections
+ * which haven't reached a session setup yet
+ *
+ * The same as the reset on zero vc stuff.
+ */
+ struct composite_context *c;
+ c = dcerpc_pipe_connect_b_send(s->conns, s->b,
+ &ndr_table_netlogon,
+ s->conns[i].wks_creds,
+ torture->ev,
+ torture->lp_ctx);
+ torture_assert(torture, c != NULL, "Failed to setup connect");
+ c->async.fn = torture_schannel_bench_connected;
+ c->async.private_data = &s->conns[i];
+ }
+
+ while (NT_STATUS_IS_OK(s->error) && s->nprocs != s->nconns) {
+ int ev_ret = event_loop_once(torture->ev);
+ torture_assert(torture, ev_ret == 0, "event_loop_once failed");
+#endif
+ }
+ torture_assert_ntstatus_ok(torture, s->error, "Failed establish a connect");
+
+ /*
+ * Change the workstation password after establishing the netlogon
+ * schannel connections to prove that existing connections are not
+ * affected by a wks pwchange.
+ */
+
+ {
+ struct netr_ServerPasswordSet pwset;
+ char *password = generate_random_str(s->join_ctx1, 8);
+ struct creds_CredentialState *creds_state;
+ struct dcerpc_pipe *net_pipe;
+
+ status = dcerpc_pipe_connect_b(s, &net_pipe, s->b,
+ &ndr_table_netlogon,
+ s->wks_creds1,
+ torture->ev, torture->lp_ctx);
+
+ torture_assert_ntstatus_ok(torture, status,
+ "dcerpc_pipe_connect_b failed");
+
+ pwset.in.server_name = talloc_asprintf(
+ net_pipe, "\\\\%s", dcerpc_server_name(net_pipe));
+ pwset.in.computer_name =
+ cli_credentials_get_workstation(s->wks_creds1);
+ pwset.in.account_name = talloc_asprintf(
+ net_pipe, "%s$", pwset.in.computer_name);
+ pwset.in.secure_channel_type = SEC_CHAN_WKSTA;
+ E_md4hash(password, pwset.in.new_password.hash);
+
+ creds_state = cli_credentials_get_netlogon_creds(
+ s->wks_creds1);
+ creds_des_encrypt(creds_state, &pwset.in.new_password);
+ creds_client_authenticator(creds_state, &pwset.in.credential);
+
+ status = dcerpc_netr_ServerPasswordSet(net_pipe, torture, &pwset);
+ torture_assert_ntstatus_ok(torture, status,
+ "ServerPasswordSet failed");
+
+ if (!creds_client_check(creds_state,
+ &pwset.out.return_authenticator.cred)) {
+ printf("Credential chaining failed\n");
+ }
+
+ cli_credentials_set_password(s->wks_creds1, password,
+ CRED_SPECIFIED);
+
+ talloc_free(net_pipe);
+
+ /* Just as a test, connect with the new creds */
+
+ talloc_free(s->wks_creds1->netlogon_creds);
+ s->wks_creds1->netlogon_creds = NULL;
+
+ status = dcerpc_pipe_connect_b(s, &net_pipe, s->b,
+ &ndr_table_netlogon,
+ s->wks_creds1,
+ torture->ev, torture->lp_ctx);
+
+ torture_assert_ntstatus_ok(torture, status,
+ "dcerpc_pipe_connect_b failed");
+
+ talloc_free(net_pipe);
+ }
+
+ torture_comment(torture, "Start looping LogonSamLogonEx on %d connections for %d secs\n",
+ s->nprocs, s->timelimit);
+ for (i=0; i < s->nprocs; i++) {
+ ret = torture_schannel_bench_start(&s->conns[i]);
+ torture_assert(torture, ret, "Failed to setup LogonSamLogonEx");
+ }
+
+ start = timeval_current();
+ end = timeval_add(&start, s->timelimit, 0);
+
+ while (NT_STATUS_IS_OK(s->error) && !timeval_expired(&end)) {
+ int ev_ret = event_loop_once(torture->ev);
+ torture_assert(torture, ev_ret == 0, "event_loop_once failed");
+ }
+ torture_assert_ntstatus_ok(torture, s->error, "Failed some request");
+ s->stopped = true;
+ talloc_free(s->conns);
+
+ for (i=0; i < s->nprocs; i++) {
+ s->total += s->conns[i].total;
+ }
+
+ torture_comment(torture,
+ "Total ops[%llu] (%u ops/s)\n",
+ (unsigned long long)s->total,
+ (unsigned)s->total/s->timelimit);
+
+ torture_leave_domain(s->join_ctx1);
+ torture_leave_domain(s->join_ctx2);
+ return true;
+}
diff --git a/source4/torture/rpc/session_key.c b/source4/torture/rpc/session_key.c
index fcb828ddb2..0df7e576ee 100644
--- a/source4/torture/rpc/session_key.c
+++ b/source4/torture/rpc/session_key.c
@@ -158,7 +158,11 @@ static bool test_secrets(struct torture_context *torture, const void *_data)
binding->flags |= settings->bindoptions;
torture_assert_ntstatus_ok(torture,
- dcerpc_pipe_connect_b(torture, &p, binding, &ndr_table_lsarpc, cmdline_credentials, NULL, torture->lp_ctx),
+ dcerpc_pipe_connect_b(torture, &p, binding,
+ &ndr_table_lsarpc,
+ cmdline_credentials,
+ torture->ev,
+ torture->lp_ctx),
"connect");
if (!test_lsa_OpenPolicy2(p, torture, &handle)) {
diff --git a/source4/torture/rpc/spoolss_notify.c b/source4/torture/rpc/spoolss_notify.c
index 19cff53d84..ab6309d55f 100644
--- a/source4/torture/rpc/spoolss_notify.c
+++ b/source4/torture/rpc/spoolss_notify.c
@@ -21,7 +21,6 @@
#include "includes.h"
#include "torture/torture.h"
-#include "torture/ui.h"
#include "torture/rpc/rpc.h"
#include "librpc/gen_ndr/ndr_spoolss_c.h"
#include "rpc_server/dcerpc_server.h"
diff --git a/source4/torture/rpc/spoolss_win.c b/source4/torture/rpc/spoolss_win.c
index 9e2921d406..9ce9fb7526 100644
--- a/source4/torture/rpc/spoolss_win.c
+++ b/source4/torture/rpc/spoolss_win.c
@@ -20,7 +20,6 @@
#include "includes.h"
#include "torture/torture.h"
-#include "torture/ui.h"
#include "torture/rpc/rpc.h"
#include "librpc/gen_ndr/ndr_spoolss_c.h"
#include "rpc_server/dcerpc_server.h"
diff --git a/source4/torture/rpc/testjoin.c b/source4/torture/rpc/testjoin.c
index 02f04946d6..51efd99bd8 100644
--- a/source4/torture/rpc/testjoin.c
+++ b/source4/torture/rpc/testjoin.c
@@ -311,7 +311,7 @@ _PUBLIC_ struct test_join *torture_join_domain(struct torture_context *tctx,
struct samr_SetUserInfo s;
union samr_UserInfo u;
- tj = talloc(NULL, struct test_join);
+ tj = talloc(tctx, struct test_join);
if (!tj) return NULL;
libnet_r = talloc(tj, struct libnet_JoinDomain);
@@ -320,7 +320,7 @@ _PUBLIC_ struct test_join *torture_join_domain(struct torture_context *tctx,
return NULL;
}
- libnet_ctx = libnet_context_init(NULL, tctx->lp_ctx);
+ libnet_ctx = libnet_context_init(tctx->ev, tctx->lp_ctx);
if (!libnet_ctx) {
talloc_free(tj);
return NULL;
@@ -508,9 +508,11 @@ _PUBLIC_ void torture_leave_domain(struct test_join *join)
/* Delete machine account */
status = dcerpc_samr_DeleteUser(join->p, join, &d);
if (!NT_STATUS_IS_OK(status)) {
- printf("Delete of machine account failed\n");
+ printf("Delete of machine account %s failed\n",
+ join->netbios_name);
} else {
- printf("Delete of machine account was successful.\n");
+ printf("Delete of machine account %s was successful.\n",
+ join->netbios_name);
}
if (join->libnet_r) {
@@ -553,6 +555,14 @@ const char *torture_join_dom_dns_name(struct test_join *join)
return join->dom_dns_name;
}
+const char *torture_join_server_dn_str(struct test_join *join)
+{
+ if (join->libnet_r) {
+ return join->libnet_r->out.server_dn_str;
+ }
+ return NULL;
+}
+
#if 0 /* Left as the documentation of the join process, but see new implementation in libnet_become_dc.c */
struct test_join_ads_dc {
diff --git a/source4/torture/smb2/config.mk b/source4/torture/smb2/config.mk
index 7463a31318..11c4e1fa2c 100644
--- a/source4/torture/smb2/config.mk
+++ b/source4/torture/smb2/config.mk
@@ -2,11 +2,14 @@
#################################
# Start SUBSYSTEM TORTURE_SMB2
[MODULE::TORTURE_SMB2]
-SUBSYSTEM = torture
+SUBSYSTEM = smbtorture
INIT_FUNCTION = torture_smb2_init
-PRIVATE_PROTO_HEADER = \
- proto.h
-OBJ_FILES = \
+PRIVATE_DEPENDENCIES = \
+ LIBCLI_SMB2 POPT_CREDENTIALS
+# End SUBSYSTEM TORTURE_SMB2
+#################################
+
+TORTURE_SMB2_OBJ_FILES = $(addprefix $(torturesrcdir)/smb2/, \
connect.o \
scan.o \
util.o \
@@ -15,8 +18,9 @@ OBJ_FILES = \
find.o \
lock.o \
notify.o \
- smb2.o
-PRIVATE_DEPENDENCIES = \
- LIBCLI_SMB2 POPT_CREDENTIALS
-# End SUBSYSTEM TORTURE_SMB2
-#################################
+ smb2.o \
+ persistent_handles.o \
+ oplocks.o)
+
+
+$(eval $(call proto_header_template,$(torturesrcdir)/smb2/proto.h,$(TORTURE_SMB2_OBJ_FILES:.o=.c)))
diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c
index c47a26277c..906d6e4f8d 100644
--- a/source4/torture/smb2/getinfo.c
+++ b/source4/torture/smb2/getinfo.c
@@ -51,9 +51,9 @@ static struct {
{ LEVEL(RAW_FILEINFO_COMPRESSION_INFORMATION) },
{ LEVEL(RAW_FILEINFO_NETWORK_OPEN_INFORMATION) },
{ LEVEL(RAW_FILEINFO_ATTRIBUTE_TAG_INFORMATION) },
-/*
-disabled until we know how the alignment now works
-{ LEVEL(RAW_FILEINFO_SMB2_ALL_EAS) }, */
+/*
+ { LEVEL(RAW_FILEINFO_SMB2_ALL_EAS) },
+*/
{ LEVEL(RAW_FILEINFO_SMB2_ALL_INFORMATION) },
{ LEVEL(RAW_FILEINFO_SEC_DESC) }
};
@@ -107,9 +107,6 @@ static bool torture_smb2_fileinfo(struct torture_context *tctx, struct smb2_tree
file_levels[i].dinfo.query_secdesc.in.secinfo_flags = 0x7;
}
if (file_levels[i].level == RAW_FILEINFO_SMB2_ALL_EAS) {
- if (torture_setting_bool(tctx, "samba4", false)) {
- continue;
- }
file_levels[i].finfo.all_eas.in.continue_flags =
SMB2_CONTINUE_FLAG_RESTART;
file_levels[i].dinfo.all_eas.in.continue_flags =
@@ -183,6 +180,9 @@ bool torture_smb2_getinfo(struct torture_context *torture)
return false;
}
+ smb2_deltree(tree, FNAME);
+ smb2_deltree(tree, DNAME);
+
status = torture_setup_complex_file(tree, FNAME);
if (!NT_STATUS_IS_OK(status)) {
return false;
diff --git a/source4/torture/smb2/lock.c b/source4/torture/smb2/lock.c
index 3cf2e93ee0..1a56cb9cad 100644
--- a/source4/torture/smb2/lock.c
+++ b/source4/torture/smb2/lock.c
@@ -51,6 +51,7 @@ static bool test_valid_request(struct torture_context *torture, struct smb2_tree
struct smb2_handle h;
uint8_t buf[200];
struct smb2_lock lck;
+ struct smb2_lock_element el[1];
ZERO_STRUCT(buf);
@@ -60,126 +61,132 @@ static bool test_valid_request(struct torture_context *torture, struct smb2_tree
status = smb2_util_write(tree, h, buf, 0, ARRAY_SIZE(buf));
CHECK_STATUS(status, NT_STATUS_OK);
- lck.in.unknown1 = 0x0000;
- lck.in.unknown2 = 0x00000000;
+ lck.in.locks = el;
+
+ lck.in.lock_count = 0x0000;
+ lck.in.reserved = 0x00000000;
lck.in.file.handle = h;
- lck.in.offset = 0x0000000000000000;
- lck.in.count = 0x0000000000000000;
- lck.in.unknown5 = 0x0000000000000000;
- lck.in.flags = 0x00000000;
+ el[0].offset = 0x0000000000000000;
+ el[0].length = 0x0000000000000000;
+ el[0].reserved = 0x0000000000000000;
+ el[0].flags = 0x00000000;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
- lck.in.unknown1 = 0x0001;
- lck.in.unknown2 = 0x00000000;
+ lck.in.lock_count = 0x0001;
+ lck.in.reserved = 0x00000000;
lck.in.file.handle = h;
- lck.in.offset = 0;
- lck.in.count = 0;
- lck.in.unknown5 = 0x00000000;
- lck.in.flags = SMB2_LOCK_FLAG_NONE;
+ el[0].offset = 0;
+ el[0].length = 0;
+ el[0].reserved = 0x00000000;
+ el[0].flags = SMB2_LOCK_FLAG_NONE;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_VALUE(lck.out.unknown1, 0);
+ CHECK_VALUE(lck.out.reserved, 0);
lck.in.file.handle.data[0] +=1;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_FILE_CLOSED);
lck.in.file.handle.data[0] -=1;
- lck.in.unknown1 = 0x0001;
- lck.in.unknown2 = 0xFFFFFFFF;
+ lck.in.lock_count = 0x0001;
+ lck.in.reserved = 0x123ab1;
lck.in.file.handle = h;
- lck.in.offset = UINT64_MAX;
- lck.in.count = UINT64_MAX;
- lck.in.unknown5 = 0x00000000;
- lck.in.flags = SMB2_LOCK_FLAG_EXCLUSIV|SMB2_LOCK_FLAG_NO_PENDING;
+ el[0].offset = UINT64_MAX;
+ el[0].length = UINT64_MAX;
+ el[0].reserved = 0x00000000;
+ el[0].flags = SMB2_LOCK_FLAG_EXCLUSIVE|SMB2_LOCK_FLAG_FAIL_IMMEDIATELY;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_VALUE(lck.out.unknown1, 0);
+ CHECK_VALUE(lck.out.reserved, 0);
+ lck.in.reserved = 0x123ab2;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
+ lck.in.reserved = 0x123ab3;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_VALUE(lck.out.unknown1, 0);
+ CHECK_VALUE(lck.out.reserved, 0);
+ lck.in.reserved = 0x123ab4;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
+ lck.in.reserved = 0x123ab5;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_VALUE(lck.out.unknown1, 0);
+ CHECK_VALUE(lck.out.reserved, 0);
- lck.in.unknown1 = 0x0001;
- lck.in.unknown2 = 0x12345678;
+ lck.in.lock_count = 0x0001;
+ lck.in.reserved = 0x12345678;
lck.in.file.handle = h;
- lck.in.offset = UINT32_MAX;
- lck.in.count = UINT32_MAX;
- lck.in.unknown5 = 0x87654321;
- lck.in.flags = SMB2_LOCK_FLAG_EXCLUSIV|SMB2_LOCK_FLAG_NO_PENDING;
+ el[0].offset = UINT32_MAX;
+ el[0].length = UINT32_MAX;
+ el[0].reserved = 0x87654321;
+ el[0].flags = SMB2_LOCK_FLAG_EXCLUSIVE|SMB2_LOCK_FLAG_FAIL_IMMEDIATELY;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_VALUE(lck.out.unknown1, 0);
+ CHECK_VALUE(lck.out.reserved, 0);
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_VALUE(lck.out.unknown1, 0);
+ CHECK_VALUE(lck.out.reserved, 0);
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_LOCK_NOT_GRANTED);
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_VALUE(lck.out.unknown1, 0);
+ CHECK_VALUE(lck.out.reserved, 0);
- lck.in.flags = 0x00000000;
+ el[0].flags = 0x00000000;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_VALUE(lck.out.unknown1, 0);
+ CHECK_VALUE(lck.out.reserved, 0);
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_VALUE(lck.out.unknown1, 0);
+ CHECK_VALUE(lck.out.reserved, 0);
- lck.in.flags = 0x00000001;
+ el[0].flags = 0x00000001;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_VALUE(lck.out.unknown1, 0);
+ CHECK_VALUE(lck.out.reserved, 0);
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_VALUE(lck.out.unknown1, 0);
+ CHECK_VALUE(lck.out.reserved, 0);
- lck.in.unknown1 = 0x0001;
- lck.in.unknown2 = 0x87654321;
+ lck.in.lock_count = 0x0001;
+ lck.in.reserved = 0x87654321;
lck.in.file.handle = h;
- lck.in.offset = 0x00000000FFFFFFFF;
- lck.in.count = 0x00000000FFFFFFFF;
- lck.in.unknown5 = 0x12345678;
- lck.in.flags = SMB2_LOCK_FLAG_UNLOCK;
+ el[0].offset = 0x00000000FFFFFFFF;
+ el[0].length = 0x00000000FFFFFFFF;
+ el[0].reserved = 0x1234567;
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
status = smb2_lock(tree, &lck);
- CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+ CHECK_STATUS(status, NT_STATUS_OK);
- lck.in.unknown1 = 0x0001;
- lck.in.unknown2 = 0x12345678;
+ lck.in.lock_count = 0x0001;
+ lck.in.reserved = 0x1234567;
lck.in.file.handle = h;
- lck.in.offset = 0x00000000FFFFFFFF;
- lck.in.count = 0x00000000FFFFFFFF;
- lck.in.unknown5 = 0x00000000;
- lck.in.flags = SMB2_LOCK_FLAG_UNLOCK;
+ el[0].offset = 0x00000000FFFFFFFF;
+ el[0].length = 0x00000000FFFFFFFF;
+ el[0].reserved = 0x00000000;
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
status = smb2_lock(tree, &lck);
- CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+ CHECK_STATUS(status, NT_STATUS_OK);
status = smb2_lock(tree, &lck);
- CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+ CHECK_STATUS(status, NT_STATUS_OK);
status = smb2_lock(tree, &lck);
- CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+ CHECK_STATUS(status, NT_STATUS_OK);
status = smb2_lock(tree, &lck);
- CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED);
+ CHECK_STATUS(status, NT_STATUS_OK);
done:
return ret;
@@ -206,6 +213,9 @@ static bool test_lock_read_write(struct torture_context *torture,
struct smb2_create cr;
struct smb2_write wr;
struct smb2_read rd;
+ struct smb2_lock_element el[1];
+
+ lck.in.locks = el;
ZERO_STRUCT(buf);
@@ -215,27 +225,27 @@ static bool test_lock_read_write(struct torture_context *torture,
status = smb2_util_write(tree, h1, buf, 0, ARRAY_SIZE(buf));
CHECK_STATUS(status, NT_STATUS_OK);
- lck.in.unknown1 = 0x0001;
- lck.in.unknown2 = 0x00000000;
+ lck.in.lock_count = 0x0001;
+ lck.in.reserved = 0x00000000;
lck.in.file.handle = h1;
- lck.in.offset = 0;
- lck.in.count = ARRAY_SIZE(buf)/2;
- lck.in.unknown5 = 0x00000000;
- lck.in.flags = s->lock_flags;
+ el[0].offset = 0;
+ el[0].length = ARRAY_SIZE(buf)/2;
+ el[0].reserved = 0x00000000;
+ el[0].flags = s->lock_flags;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_VALUE(lck.out.unknown1, 0);
+ CHECK_VALUE(lck.out.reserved, 0);
- lck.in.unknown1 = 0x0001;
- lck.in.unknown2 = 0x00000000;
+ lck.in.lock_count = 0x0001;
+ lck.in.reserved = 0x00000000;
lck.in.file.handle = h1;
- lck.in.offset = ARRAY_SIZE(buf)/2;
- lck.in.count = ARRAY_SIZE(buf)/2;
- lck.in.unknown5 = 0x00000000;
- lck.in.flags = s->lock_flags;
+ el[0].offset = ARRAY_SIZE(buf)/2;
+ el[0].length = ARRAY_SIZE(buf)/2;
+ el[0].reserved = 0x00000000;
+ el[0].flags = s->lock_flags;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_VALUE(lck.out.unknown1, 0);
+ CHECK_VALUE(lck.out.reserved, 0);
ZERO_STRUCT(cr);
cr.in.oplock_level = 0;
@@ -286,16 +296,16 @@ static bool test_lock_read_write(struct torture_context *torture,
status = smb2_read(tree, tree, &rd);
CHECK_STATUS(status, s->read_h2_status);
- lck.in.unknown1 = 0x0001;
- lck.in.unknown2 = 0x00000000;
+ lck.in.lock_count = 0x0001;
+ lck.in.reserved = 0x00000000;
lck.in.file.handle = h1;
- lck.in.offset = ARRAY_SIZE(buf)/2;
- lck.in.count = ARRAY_SIZE(buf)/2;
- lck.in.unknown5 = 0x00000000;
- lck.in.flags = SMB2_LOCK_FLAG_UNLOCK;
+ el[0].offset = ARRAY_SIZE(buf)/2;
+ el[0].length = ARRAY_SIZE(buf)/2;
+ el[0].reserved = 0x00000000;
+ el[0].flags = SMB2_LOCK_FLAG_UNLOCK;
status = smb2_lock(tree, &lck);
CHECK_STATUS(status, NT_STATUS_OK);
- CHECK_VALUE(lck.out.unknown1, 0);
+ CHECK_VALUE(lck.out.reserved, 0);
ZERO_STRUCT(wr);
wr.in.file.handle = h2;
@@ -349,7 +359,7 @@ static bool test_lock_rw_exclusiv(struct torture_context *torture, struct smb2_t
{
struct test_lock_read_write_state s = {
.fname = "lock_rw_exclusiv.dat",
- .lock_flags = SMB2_LOCK_FLAG_EXCLUSIV,
+ .lock_flags = SMB2_LOCK_FLAG_EXCLUSIVE,
.write_h1_status = NT_STATUS_OK,
.read_h1_status = NT_STATUS_OK,
.write_h2_status = NT_STATUS_FILE_LOCK_CONFLICT,
diff --git a/source4/torture/smb2/oplocks.c b/source4/torture/smb2/oplocks.c
new file mode 100644
index 0000000000..9a06ae1f19
--- /dev/null
+++ b/source4/torture/smb2/oplocks.c
@@ -0,0 +1,178 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ test suite for SMB2 oplocks
+
+ Copyright (C) Stefan Metzmacher 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 "librpc/gen_ndr/security.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+#include "torture/torture.h"
+#include "torture/smb2/proto.h"
+#include "param/param.h"
+
+#define CHECK_VAL(v, correct) do { \
+ if ((v) != (correct)) { \
+ torture_result(tctx, TORTURE_FAIL, "(%s): wrong value for %s got 0x%x - should be 0x%x\n", \
+ __location__, #v, (int)v, (int)correct); \
+ ret = false; \
+ }} while (0)
+
+#define CHECK_STATUS(status, correct) do { \
+ if (!NT_STATUS_EQUAL(status, correct)) { \
+ torture_result(tctx, TORTURE_FAIL, __location__": Incorrect status %s - should be %s", \
+ nt_errstr(status), nt_errstr(correct)); \
+ ret = false; \
+ goto done; \
+ }} while (0)
+
+static struct {
+ struct smb2_handle handle;
+ uint8_t level;
+ struct smb2_break br;
+ int count;
+ int failures;
+} break_info;
+
+static void torture_oplock_break_callback(struct smb2_request *req)
+{
+ NTSTATUS status;
+ struct smb2_break br;
+
+ ZERO_STRUCT(br);
+ status = smb2_break_recv(req, &break_info.br);
+ if (!NT_STATUS_IS_OK(status)) {
+ break_info.failures++;
+ }
+
+ return;
+}
+
+/* a oplock break request handler */
+static bool torture_oplock_handler(struct smb2_transport *transport,
+ const struct smb2_handle *handle,
+ uint8_t level, void *private_data)
+{
+ struct smb2_tree *tree = private_data;
+ const char *name;
+ struct smb2_request *req;
+
+ break_info.handle = *handle;
+ break_info.level = level;
+ break_info.count++;
+
+ switch (level) {
+ case SMB2_OPLOCK_LEVEL_II:
+ name = "level II";
+ break;
+ case SMB2_OPLOCK_LEVEL_NONE:
+ name = "none";
+ break;
+ default:
+ name = "unknown";
+ break_info.failures++;
+ }
+ printf("Acking to %s [0x%02X] in oplock handler\n",
+ name, level);
+
+ ZERO_STRUCT(break_info.br);
+ break_info.br.in.file.handle = *handle;
+ break_info.br.in.oplock_level = level;
+ break_info.br.in.reserved = 0;
+ break_info.br.in.reserved2 = 0;
+
+ req = smb2_break_send(tree, &break_info.br);
+ req->async.fn = torture_oplock_break_callback;
+ req->async.private_data = NULL;
+
+ return true;
+}
+
+bool torture_smb2_oplock_batch1(struct torture_context *tctx,
+ struct smb2_tree *tree)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(tctx);
+ struct smb2_handle h1, h2;
+ struct smb2_create io;
+ NTSTATUS status;
+ const char *fname = "oplock.dat";
+ bool ret = true;
+
+ tree->session->transport->oplock.handler = torture_oplock_handler;
+ tree->session->transport->oplock.private_data = tree;
+
+ smb2_util_unlink(tree, fname);
+
+ ZERO_STRUCT(break_info);
+
+ ZERO_STRUCT(io);
+ io.in.security_flags = 0x00;
+ io.in.oplock_level = SMB2_OPLOCK_LEVEL_BATCH;
+ io.in.impersonation_level = NTCREATEX_IMPERSONATION_IMPERSONATION;
+ io.in.create_flags = 0x00000000;
+ io.in.reserved = 0x00000000;
+ io.in.desired_access = SEC_RIGHTS_FILE_ALL;
+ io.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ io.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
+ NTCREATEX_SHARE_ACCESS_WRITE |
+ NTCREATEX_SHARE_ACCESS_DELETE;
+ io.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.in.create_options = NTCREATEX_OPTIONS_SEQUENTIAL_ONLY |
+ NTCREATEX_OPTIONS_ASYNC_ALERT |
+ NTCREATEX_OPTIONS_NON_DIRECTORY_FILE |
+ 0x00200000;
+ io.in.fname = fname;
+
+ status = smb2_create(tree, mem_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VAL(io.out.oplock_level, SMB2_OPLOCK_LEVEL_BATCH);
+ /*CHECK_VAL(io.out.reserved, 0);*/
+ CHECK_VAL(io.out.create_action, NTCREATEX_ACTION_CREATED);
+ CHECK_VAL(io.out.alloc_size, 0);
+ CHECK_VAL(io.out.size, 0);
+ CHECK_VAL(io.out.file_attr, FILE_ATTRIBUTE_ARCHIVE);
+ CHECK_VAL(io.out.reserved2, 0);
+ CHECK_VAL(break_info.count, 0);
+
+ h1 = io.out.file.handle;
+
+ ZERO_STRUCT(io.in.blobs);
+ status = smb2_create(tree, mem_ctx, &io);
+ CHECK_VAL(break_info.count, 1);
+ CHECK_VAL(break_info.failures, 0);
+ CHECK_VAL(break_info.level, SMB2_OPLOCK_LEVEL_II);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VAL(io.out.oplock_level, SMB2_OPLOCK_LEVEL_II);
+ /*CHECK_VAL(io.out.reserved, 0);*/
+ CHECK_VAL(io.out.create_action, NTCREATEX_ACTION_EXISTED);
+ CHECK_VAL(io.out.alloc_size, 0);
+ CHECK_VAL(io.out.size, 0);
+ CHECK_VAL(io.out.file_attr, FILE_ATTRIBUTE_ARCHIVE);
+ CHECK_VAL(io.out.reserved2, 0);
+
+ h2 = io.out.file.handle;
+
+done:
+ talloc_free(mem_ctx);
+
+ smb2_util_close(tree, h1);
+ smb2_util_close(tree, h2);
+ smb2_util_unlink(tree, fname);
+ return ret;
+}
diff --git a/source4/torture/smb2/persistent_handles.c b/source4/torture/smb2/persistent_handles.c
new file mode 100644
index 0000000000..249ddd1733
--- /dev/null
+++ b/source4/torture/smb2/persistent_handles.c
@@ -0,0 +1,184 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ test suite for SMB2 persistent file handles
+
+ Copyright (C) Stefan Metzmacher 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 "librpc/gen_ndr/security.h"
+#include "libcli/smb2/smb2.h"
+#include "libcli/smb2/smb2_calls.h"
+#include "torture/torture.h"
+#include "torture/smb2/proto.h"
+#include "param/param.h"
+
+#define CHECK_VAL(v, correct) do { \
+ if ((v) != (correct)) { \
+ torture_result(tctx, TORTURE_FAIL, "(%s): wrong value for %s got 0x%x - should be 0x%x\n", \
+ __location__, #v, (int)v, (int)correct); \
+ ret = false; \
+ }} while (0)
+
+#define CHECK_STATUS(status, correct) do { \
+ if (!NT_STATUS_EQUAL(status, correct)) { \
+ torture_result(tctx, TORTURE_FAIL, __location__": Incorrect status %s - should be %s", \
+ nt_errstr(status), nt_errstr(correct)); \
+ ret = false; \
+ goto done; \
+ }} while (0)
+
+/*
+ basic testing of SMB2 persistent file handles
+ regarding the position information on the handle
+*/
+bool torture_smb2_persistent_handles1(struct torture_context *tctx,
+ struct smb2_tree *tree1,
+ struct smb2_tree *tree2)
+{
+ TALLOC_CTX *mem_ctx = talloc_new(tctx);
+ struct smb2_handle h1, h2;
+ struct smb2_create io1, io2;
+ NTSTATUS status;
+ const char *fname = "persistent_handles.dat";
+ DATA_BLOB b;
+ union smb_fileinfo qfinfo;
+ union smb_setfileinfo sfinfo;
+ bool ret = true;
+ uint64_t pos;
+
+ smb2_util_unlink(tree1, fname);
+
+ ZERO_STRUCT(io1);
+ io1.in.security_flags = 0x00;
+ io1.in.oplock_level = SMB2_OPLOCK_LEVEL_BATCH;
+ io1.in.impersonation_level = NTCREATEX_IMPERSONATION_IMPERSONATION;
+ io1.in.create_flags = 0x00000000;
+ io1.in.reserved = 0x00000000;
+ io1.in.desired_access = SEC_RIGHTS_FILE_ALL;
+ io1.in.file_attributes = FILE_ATTRIBUTE_NORMAL;
+ io1.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
+ NTCREATEX_SHARE_ACCESS_WRITE |
+ NTCREATEX_SHARE_ACCESS_DELETE;
+ io1.in.create_disposition = NTCREATEX_DISP_OPEN_IF;
+ io1.in.create_options = NTCREATEX_OPTIONS_SEQUENTIAL_ONLY |
+ NTCREATEX_OPTIONS_ASYNC_ALERT |
+ NTCREATEX_OPTIONS_NON_DIRECTORY_FILE |
+ 0x00200000;
+ io1.in.fname = fname;
+
+ b = data_blob_talloc(mem_ctx, NULL, 16);
+ SBVAL(b.data, 0, 0);
+ SBVAL(b.data, 8, 0);
+
+ status = smb2_create_blob_add(tree1, &io1.in.blobs,
+ SMB2_CREATE_TAG_DHNQ,
+ b);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ status = smb2_create(tree1, mem_ctx, &io1);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VAL(io1.out.oplock_level, SMB2_OPLOCK_LEVEL_BATCH);
+ /*CHECK_VAL(io1.out.reserved, 0);*/
+ CHECK_VAL(io1.out.create_action, NTCREATEX_ACTION_CREATED);
+ CHECK_VAL(io1.out.alloc_size, 0);
+ CHECK_VAL(io1.out.size, 0);
+ CHECK_VAL(io1.out.file_attr, FILE_ATTRIBUTE_ARCHIVE);
+ CHECK_VAL(io1.out.reserved2, 0);
+
+ /* TODO: check extra blob content */
+
+ h1 = io1.out.file.handle;
+
+ ZERO_STRUCT(qfinfo);
+ qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
+ qfinfo.generic.in.file.handle = h1;
+ status = smb2_getinfo_file(tree1, mem_ctx, &qfinfo);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VAL(qfinfo.position_information.out.position, 0);
+ pos = qfinfo.position_information.out.position;
+ torture_comment(tctx, "position: %llu\n",
+ (unsigned long long)pos);
+
+ ZERO_STRUCT(sfinfo);
+ sfinfo.generic.level = RAW_SFILEINFO_POSITION_INFORMATION;
+ sfinfo.generic.in.file.handle = h1;
+ sfinfo.position_information.in.position = 0x1000;
+ status = smb2_setinfo_file(tree1, &sfinfo);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ ZERO_STRUCT(qfinfo);
+ qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
+ qfinfo.generic.in.file.handle = h1;
+ status = smb2_getinfo_file(tree1, mem_ctx, &qfinfo);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VAL(qfinfo.position_information.out.position, 0x1000);
+ pos = qfinfo.position_information.out.position;
+ torture_comment(tctx, "position: %llu\n",
+ (unsigned long long)pos);
+
+ talloc_free(tree1);
+ tree1 = NULL;
+
+ ZERO_STRUCT(qfinfo);
+ qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
+ qfinfo.generic.in.file.handle = h1;
+ status = smb2_getinfo_file(tree2, mem_ctx, &qfinfo);
+ CHECK_STATUS(status, NT_STATUS_FILE_CLOSED);
+
+ ZERO_STRUCT(io2);
+ io2.in.fname = fname;
+
+ b = data_blob_talloc(tctx, NULL, 16);
+ SBVAL(b.data, 0, h1.data[0]);
+ SBVAL(b.data, 8, h1.data[1]);
+
+ status = smb2_create_blob_add(tree2, &io2.in.blobs,
+ SMB2_CREATE_TAG_DHNC,
+ b);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ status = smb2_create(tree2, mem_ctx, &io2);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VAL(io2.out.oplock_level, SMB2_OPLOCK_LEVEL_BATCH);
+ CHECK_VAL(io2.out.reserved, 0x00);
+ CHECK_VAL(io2.out.create_action, NTCREATEX_ACTION_EXISTED);
+ CHECK_VAL(io2.out.alloc_size, 0);
+ CHECK_VAL(io2.out.size, 0);
+ CHECK_VAL(io2.out.file_attr, FILE_ATTRIBUTE_ARCHIVE);
+ CHECK_VAL(io2.out.reserved2, 0);
+
+ h2 = io2.out.file.handle;
+
+ ZERO_STRUCT(qfinfo);
+ qfinfo.generic.level = RAW_FILEINFO_POSITION_INFORMATION;
+ qfinfo.generic.in.file.handle = h2;
+ status = smb2_getinfo_file(tree2, mem_ctx, &qfinfo);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_VAL(qfinfo.position_information.out.position, 0x1000);
+ pos = qfinfo.position_information.out.position;
+ torture_comment(tctx, "position: %llu\n",
+ (unsigned long long)pos);
+
+ smb2_util_close(tree2, h2);
+
+ talloc_free(mem_ctx);
+
+ smb2_util_unlink(tree2, fname);
+done:
+ return ret;
+}
diff --git a/source4/torture/smb2/scan.c b/source4/torture/smb2/scan.c
index 0f4c9fefdf..889d343a49 100644
--- a/source4/torture/smb2/scan.c
+++ b/source4/torture/smb2/scan.c
@@ -207,7 +207,7 @@ bool torture_smb2_scan(struct torture_context *torture)
status = smb2_connect(mem_ctx, host, share,
lp_resolve_context(torture->lp_ctx),
credentials, &tree,
- event_context_find(mem_ctx));
+ torture->ev);
if (!NT_STATUS_IS_OK(status)) {
printf("Connection failed - %s\n", nt_errstr(status));
return false;
@@ -224,7 +224,7 @@ bool torture_smb2_scan(struct torture_context *torture)
status = smb2_connect(mem_ctx, host, share,
lp_resolve_context(torture->lp_ctx),
credentials, &tree,
- event_context_find(mem_ctx));
+ torture->ev);
if (!NT_STATUS_IS_OK(status)) {
printf("Connection failed - %s\n", nt_errstr(status));
return false;
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c
index d07611264b..37eadcf7fd 100644
--- a/source4/torture/smb2/smb2.c
+++ b/source4/torture/smb2/smb2.c
@@ -21,7 +21,7 @@
#include "libcli/smb2/smb2.h"
#include "libcli/smb2/smb2_calls.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "torture/smb2/proto.h"
#include "lib/util/dlinklist.h"
@@ -47,9 +47,9 @@ static bool wrap_simple_1smb2_test(struct torture_context *torture_ctx,
}
struct torture_test *torture_suite_add_1smb2_test(struct torture_suite *suite,
- const char *name,
- bool (*run) (struct torture_context *,
- struct smb2_tree *))
+ const char *name,
+ bool (*run)(struct torture_context *,
+ struct smb2_tree *))
{
struct torture_test *test;
struct torture_tcase *tcase;
@@ -69,6 +69,61 @@ struct torture_test *torture_suite_add_1smb2_test(struct torture_suite *suite,
return test;
}
+
+static bool wrap_simple_2smb2_test(struct torture_context *torture_ctx,
+ struct torture_tcase *tcase,
+ struct torture_test *test)
+{
+ bool (*fn) (struct torture_context *, struct smb2_tree *, struct smb2_tree *);
+ bool ret;
+
+ struct smb2_tree *tree1;
+ struct smb2_tree *tree2;
+ TALLOC_CTX *mem_ctx = talloc_new(torture_ctx);
+
+ if (!torture_smb2_connection(torture_ctx, &tree1) ||
+ !torture_smb2_connection(torture_ctx, &tree2)) {
+ return false;
+ }
+
+ talloc_steal(mem_ctx, tree1);
+ talloc_steal(mem_ctx, tree2);
+
+ fn = test->fn;
+
+ ret = fn(torture_ctx, tree1, tree2);
+
+ /* the test may already closed some of the connections */
+ talloc_free(mem_ctx);
+
+ return ret;
+}
+
+
+_PUBLIC_ struct torture_test *torture_suite_add_2smb2_test(struct torture_suite *suite,
+ const char *name,
+ bool (*run)(struct torture_context *,
+ struct smb2_tree *,
+ struct smb2_tree *))
+{
+ struct torture_test *test;
+ struct torture_tcase *tcase;
+
+ tcase = torture_suite_add_tcase(suite, name);
+
+ test = talloc(tcase, struct torture_test);
+
+ test->name = talloc_strdup(test, name);
+ test->description = NULL;
+ test->run = wrap_simple_2smb2_test;
+ test->fn = run;
+ test->dangerous = false;
+
+ DLIST_ADD_END(tcase->tests, test, struct torture_test *);
+
+ return test;
+}
+
NTSTATUS torture_smb2_init(void)
{
struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "SMB2");
@@ -82,6 +137,8 @@ NTSTATUS torture_smb2_init(void)
torture_suite_add_simple_test(suite, "FIND", torture_smb2_find);
torture_suite_add_suite(suite, torture_smb2_lock_init());
torture_suite_add_simple_test(suite, "NOTIFY", torture_smb2_notify);
+ torture_suite_add_2smb2_test(suite, "PERSISTENT-HANDLES1", torture_smb2_persistent_handles1);
+ torture_suite_add_1smb2_test(suite, "OPLOCK-BATCH1", torture_smb2_oplock_batch1);
suite->description = talloc_strdup(suite, "SMB2-specific tests");
diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c
index f85b1c42ff..af4f345104 100644
--- a/source4/torture/smb2/util.c
+++ b/source4/torture/smb2/util.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "libcli/smb2/smb2.h"
#include "libcli/smb2/smb2_calls.h"
+#include "libcli/smb_composite/smb_composite.h"
#include "lib/cmdline/popt_common.h"
#include "lib/events/events.h"
#include "system/time.h"
@@ -34,47 +35,6 @@
/*
- close a handle with SMB2
-*/
-NTSTATUS smb2_util_close(struct smb2_tree *tree, struct smb2_handle h)
-{
- struct smb2_close c;
-
- ZERO_STRUCT(c);
- c.in.file.handle = h;
-
- return smb2_close(tree, &c);
-}
-
-/*
- unlink a file with SMB2
-*/
-NTSTATUS smb2_util_unlink(struct smb2_tree *tree, const char *fname)
-{
- struct smb2_create io;
- NTSTATUS status;
-
- ZERO_STRUCT(io);
- 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|
- NTCREATEX_SHARE_ACCESS_WRITE;
- io.in.create_options = NTCREATEX_OPTIONS_DELETE_ON_CLOSE;
- io.in.fname = fname;
-
- status = smb2_create(tree, tree, &io);
- if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
- return NT_STATUS_OK;
- }
- NT_STATUS_NOT_OK_RETURN(status);
-
- return smb2_util_close(tree, io.out.file.handle);
-}
-
-/*
write to a file on SMB2
*/
NTSTATUS smb2_util_write(struct smb2_tree *tree,
@@ -314,7 +274,7 @@ bool torture_smb2_connection(struct torture_context *tctx, struct smb2_tree **tr
status = smb2_connect(tctx, host, share,
lp_resolve_context(tctx->lp_ctx),
credentials, tree,
- event_context_find(tctx));
+ tctx->ev);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
host, share, nt_errstr(status));
diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c
index 4eeea73003..44daa89e44 100644
--- a/source4/torture/smbtorture.c
+++ b/source4/torture/smbtorture.c
@@ -2,7 +2,7 @@
Unix SMB/CIFS implementation.
SMB torture tester
Copyright (C) Andrew Tridgell 1997-2003
- Copyright (C) Jelmer Vernooij 2006
+ Copyright (C) Jelmer Vernooij 2006-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
@@ -30,12 +30,13 @@
#include "lib/events/events.h"
#include "dynconfig.h"
-#include "torture/torture.h"
-#include "build.h"
+#include "torture/smbtorture.h"
#include "lib/util/dlinklist.h"
#include "librpc/rpc/dcerpc.h"
#include "param/param.h"
+#include "auth/credentials/credentials.h"
+
static bool run_matching(struct torture_context *torture,
const char *prefix,
const char *expr,
@@ -374,11 +375,24 @@ static void subunit_suite_start(struct torture_context *ctx,
{
}
+static void subunit_print_testname(struct torture_context *ctx,
+ struct torture_tcase *tcase,
+ struct torture_test *test)
+{
+ if (!strcmp(tcase->name, test->name)) {
+ printf("%s", test->name);
+ } else {
+ printf("%s.%s", tcase->name, test->name);
+ }
+}
+
static void subunit_test_start(struct torture_context *ctx,
struct torture_tcase *tcase,
struct torture_test *test)
{
- printf("test: %s\n", test->name);
+ printf("test: ");
+ subunit_print_testname(ctx, tcase, test);
+ printf("\n");
}
static void subunit_test_result(struct torture_context *context,
@@ -386,18 +400,20 @@ static void subunit_test_result(struct torture_context *context,
{
switch (res) {
case TORTURE_OK:
- printf("success: %s", context->active_test->name);
+ printf("success: ");
break;
case TORTURE_FAIL:
- printf("failure: %s", context->active_test->name);
+ printf("failure: ");
break;
case TORTURE_ERROR:
- printf("error: %s", context->active_test->name);
+ printf("error: ");
break;
case TORTURE_SKIP:
- printf("skip: %s", context->active_test->name);
+ printf("skip: ");
break;
}
+ subunit_print_testname(context, context->active_tcase, context->active_test);
+
if (reason)
printf(" [\n%s\n]", reason);
printf("\n");
@@ -673,7 +689,7 @@ int main(int argc,char *argv[])
exit(1);
}
- torture = torture_context_init(talloc_autofree_context(), ui_ops);
+ torture = torture_context_init(event_context_init(NULL), ui_ops);
if (basedir != NULL) {
if (basedir[0] != '/') {
fprintf(stderr, "Please specify an absolute path to --basedir\n");
diff --git a/source4/torture/torture.h b/source4/torture/smbtorture.h
index 26ecdb567b..3b5a573d83 100644
--- a/source4/torture/torture.h
+++ b/source4/torture/smbtorture.h
@@ -18,10 +18,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef __TORTURE_H__
-#define __TORTURE_H__
+#ifndef __SMBTORTURE_H__
+#define __SMBTORTURE_H__
-#include "torture/ui.h"
+#include "torture/torture.h"
struct smbcli_state;
@@ -37,5 +37,4 @@ struct torture_test;
int torture_init(void);
bool torture_register_suite(struct torture_suite *suite);
-
-#endif /* __TORTURE_H__ */
+#endif /* __SMBTORTURE_H__ */
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index ea8efaa8c3..54fe0ead27 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -21,7 +21,6 @@
#include "includes.h"
#include "system/time.h"
#include "torture/torture.h"
-#include "build.h"
#include "lib/util/dlinklist.h"
#include "param/param.h"
#include "lib/cmdline/popt_common.h"
@@ -48,7 +47,19 @@ bool torture_register_suite(struct torture_suite *suite)
_PUBLIC_ int torture_init(void)
{
- init_module_fn static_init[] = { STATIC_torture_MODULES };
+ extern NTSTATUS torture_base_init(void);
+ extern NTSTATUS torture_ldap_init(void);
+ extern NTSTATUS torture_local_init(void);
+ extern NTSTATUS torture_nbt_init(void);
+ extern NTSTATUS torture_nbench_init(void);
+ extern NTSTATUS torture_rap_init(void);
+ extern NTSTATUS torture_rpc_init(void);
+ extern NTSTATUS torture_smb2_init(void);
+ extern NTSTATUS torture_net_init(void);
+ extern NTSTATUS torture_raw_init(void);
+ extern NTSTATUS torture_unix_init(void);
+ extern NTSTATUS torture_winbind_init(void);
+ init_module_fn static_init[] = { STATIC_smbtorture_MODULES };
init_module_fn *shared_init = load_samba_modules(NULL, cmdline_lp_ctx, "torture");
run_init_functions(static_init);
diff --git a/source4/torture/unix/unix.c b/source4/torture/unix/unix.c
index 05ea27db02..661e337270 100644
--- a/source4/torture/unix/unix.c
+++ b/source4/torture/unix/unix.c
@@ -18,7 +18,7 @@
*/
#include "includes.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "torture/unix/proto.h"
NTSTATUS torture_unix_init(void)
diff --git a/source4/torture/unix/unix_info2.c b/source4/torture/unix/unix_info2.c
index c14be9e2d0..d7482ddcf1 100644
--- a/source4/torture/unix/unix_info2.c
+++ b/source4/torture/unix/unix_info2.c
@@ -63,8 +63,8 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx)
lp_smb_ports(tctx->lp_ctx),
share, NULL,
cmdline_credentials,
- lp_resolve_context(tctx->lp_ctx), NULL,
- &options);
+ lp_resolve_context(tctx->lp_ctx),
+ tctx->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
printf("failed to connect to //%s/%s: %s\n",
diff --git a/source4/torture/unix/whoami.c b/source4/torture/unix/whoami.c
index a1333ac5bd..d4f19bb57a 100644
--- a/source4/torture/unix/whoami.c
+++ b/source4/torture/unix/whoami.c
@@ -84,7 +84,7 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx,
lp_smb_ports(tctx->lp_ctx),
share, NULL,
creds, lp_resolve_context(tctx->lp_ctx),
- NULL, &options);
+ tctx->ev, &options);
if (!NT_STATUS_IS_OK(status)) {
printf("failed to connect to //%s/%s: %s\n",
diff --git a/source4/torture/util.h b/source4/torture/util.h
index 477a828120..9dc948ade5 100644
--- a/source4/torture/util.h
+++ b/source4/torture/util.h
@@ -20,27 +20,10 @@
#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 *host_ip;
- const char *realm;
- const char *domain;
- const struct GUID *ntds_guid;
- const char *ntds_dn_str;
- const char *machine_password;
- const char *targetdir;
-};
-
-NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
- struct provision_settings *settings);
+#include "torture/torture.h"
+struct smbcli_state;
+struct smbcli_tree;
/**
setup a directory ready for a test
diff --git a/source4/torture/util_smb.c b/source4/torture/util_smb.c
index 513070500e..938e7d6c03 100644
--- a/source4/torture/util_smb.c
+++ b/source4/torture/util_smb.c
@@ -28,7 +28,6 @@
#include "system/shmem.h"
#include "system/wait.h"
#include "system/time.h"
-#include "torture/ui.h"
#include "torture/torture.h"
#include "util/dlinklist.h"
#include "auth/credentials/credentials.h"
@@ -553,8 +552,7 @@ _PUBLIC_ bool torture_open_connection_ev(struct smbcli_state **c,
_PUBLIC_ bool torture_open_connection(struct smbcli_state **c, struct torture_context *tctx, int conn_index)
{
- return torture_open_connection_ev(c, conn_index, tctx,
- cli_credentials_get_event_context(cmdline_credentials));
+ return torture_open_connection_ev(c, conn_index, tctx, tctx->ev);
}
diff --git a/source4/torture/winbind/config.mk b/source4/torture/winbind/config.mk
index b64b0647fc..15bc51daba 100644
--- a/source4/torture/winbind/config.mk
+++ b/source4/torture/winbind/config.mk
@@ -2,14 +2,14 @@
#################################
# Start SUBSYSTEM TORTURE_WINBIND
[MODULE::TORTURE_WINBIND]
-SUBSYSTEM = torture
+SUBSYSTEM = smbtorture
INIT_FUNCTION = torture_winbind_init
-PRIVATE_PROTO_HEADER = \
- proto.h
-OBJ_FILES = \
- winbind.o \
- struct_based.o
PRIVATE_DEPENDENCIES = \
LIBWINBIND-CLIENT
# End SUBSYSTEM TORTURE_WINBIND
#################################
+
+TORTURE_WINBIND_OBJ_FILES = $(addprefix $(torturesrcdir)/winbind/, winbind.o struct_based.o)
+
+$(eval $(call proto_header_template,$(torturesrcdir)/winbind/proto.h,$(TORTURE_WINBIND_OBJ_FILES:.o=.c)))
+
diff --git a/source4/torture/winbind/struct_based.c b/source4/torture/winbind/struct_based.c
index 0fe2148b75..31c5b8cf96 100644
--- a/source4/torture/winbind/struct_based.c
+++ b/source4/torture/winbind/struct_based.c
@@ -26,7 +26,7 @@
#include "libcli/security/security.h"
#include "librpc/gen_ndr/netlogon.h"
#include "param/param.h"
-#include "auth/pam_errors.h"
+#include "auth/ntlm/pam_errors.h"
#define DO_STRUCT_REQ_REP_EXT(op,req,rep,expected,strict,warnaction,cmt) do { \
NSS_STATUS __got, __expected = (expected); \
@@ -181,7 +181,8 @@ static bool torture_winbind_struct_netbios_name(struct torture_context *torture)
expected = torture_setting_string(torture,
"winbindd netbios name",
lp_netbios_name(torture->lp_ctx));
-
+ expected = strupper_talloc(torture, expected);
+
torture_assert_str_equal(torture,
rep.data.netbios_name, expected,
"winbindd's netbios name doesn't match");
@@ -261,7 +262,7 @@ static bool torture_winbind_struct_check_machacc(struct torture_context *torture
torture_assert_str_equal(torture,
rep.data.auth.error_string,
- nt_errstr(NT_STATUS_OK),
+ get_friendly_nt_error_msg(NT_STATUS_OK),
"WINBINDD_CHECK_MACHACC ok: error_string");
torture_assert_int_equal(torture,
@@ -294,6 +295,10 @@ static bool get_trusted_domains(struct torture_context *torture,
DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep);
extra_data = (char *)rep.extra_data.data;
+ if (!extra_data) {
+ return true;
+ }
+
torture_assert(torture, extra_data, "NULL trust list");
while (next_token(&extra_data, line, "\n", sizeof(fstring))) {
@@ -355,7 +360,6 @@ static bool torture_winbind_struct_list_trustdom(struct torture_context *torture
DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep);
list1 = (char *)rep.extra_data.data;
- torture_assert(torture, list1, "NULL trust list");
torture_comment(torture, "%s\n", list1);
@@ -367,7 +371,6 @@ static bool torture_winbind_struct_list_trustdom(struct torture_context *torture
DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep);
list2 = (char *)rep.extra_data.data;
- torture_assert(torture, list2, "NULL trust list");
/*
* The list_all_domains parameter should be ignored
@@ -380,7 +383,7 @@ static bool torture_winbind_struct_list_trustdom(struct torture_context *torture
ok = get_trusted_domains(torture, &listd);
torture_assert(torture, ok, "failed to get trust list");
- for (i=0; listd[i].netbios_name; i++) {
+ for (i=0; listd && listd[i].netbios_name; i++) {
if (i == 0) {
struct dom_sid *builtin_sid;
@@ -423,7 +426,7 @@ static bool torture_winbind_struct_domain_info(struct torture_context *torture)
ok = get_trusted_domains(torture, &listd);
torture_assert(torture, ok, "failed to get trust list");
- for (i=0; listd[i].netbios_name; i++) {
+ for (i=0; listd && listd[i].netbios_name; i++) {
struct winbindd_request req;
struct winbindd_response rep;
struct dom_sid *sid;
@@ -484,14 +487,14 @@ static bool torture_winbind_struct_getdcname(struct torture_context *torture)
bool ok;
bool strict = torture_setting_bool(torture, "strict mode", false);
struct torture_trust_domain *listd = NULL;
- uint32_t i;
+ uint32_t i, count = 0;
torture_comment(torture, "Running WINBINDD_GETDCNAME (struct based)\n");
ok = get_trusted_domains(torture, &listd);
torture_assert(torture, ok, "failed to get trust list");
- for (i=0; listd[i].netbios_name; i++) {
+ for (i=0; listd && listd[i].netbios_name; i++) {
struct winbindd_request req;
struct winbindd_response rep;
@@ -511,8 +514,13 @@ static bool torture_winbind_struct_getdcname(struct torture_context *torture)
/* TODO: check rep.data.dc_name; */
torture_comment(torture, "DOMAIN '%s' => DCNAME '%s'\n",
req.domain_name, rep.data.dc_name);
+ count++;
}
+ if (strict) {
+ torture_assert(torture, count > 0,
+ "WiNBINDD_GETDCNAME was not tested");
+ }
return true;
}
@@ -529,7 +537,7 @@ static bool torture_winbind_struct_dsgetdcname(struct torture_context *torture)
ok = get_trusted_domains(torture, &listd);
torture_assert(torture, ok, "failed to get trust list");
- for (i=0; listd[i].netbios_name; i++) {
+ for (i=0; listd && listd[i].netbios_name; i++) {
struct winbindd_request req;
struct winbindd_response rep;
diff --git a/source4/torture/winbind/winbind.c b/source4/torture/winbind/winbind.c
index e283602337..b12e92552e 100644
--- a/source4/torture/winbind/winbind.c
+++ b/source4/torture/winbind/winbind.c
@@ -18,7 +18,7 @@
*/
#include "includes.h"
-#include "torture/torture.h"
+#include "torture/smbtorture.h"
#include "torture/winbind/proto.h"
NTSTATUS torture_winbind_init(void)
diff --git a/source4/utils/config.mk b/source4/utils/config.mk
index 9dea2c5af3..d47b36ea7c 100644
--- a/source4/utils/config.mk
+++ b/source4/utils/config.mk
@@ -4,8 +4,6 @@
# Start BINARY ntlm_auth
[BINARY::ntlm_auth]
INSTALLDIR = BINDIR
-OBJ_FILES = \
- ntlm_auth.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-HOSTCONFIG \
LIBSAMBA-UTIL \
@@ -15,19 +13,20 @@ PRIVATE_DEPENDENCIES = \
gensec \
LIBCLI_RESOLVE \
auth \
+ ntlm_check \
MESSAGING \
LIBEVENTS
# End BINARY ntlm_auth
#################################
-MANPAGES += utils/man/ntlm_auth.1
+ntlm_auth_OBJ_FILES = $(utilssrcdir)/ntlm_auth.o
+
+MANPAGES += $(utilssrcdir)/man/ntlm_auth.1
#################################
# Start BINARY getntacl
[BINARY::getntacl]
INSTALLDIR = BINDIR
-OBJ_FILES = \
- getntacl.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-HOSTCONFIG \
LIBSAMBA-UTIL \
@@ -35,37 +34,37 @@ PRIVATE_DEPENDENCIES = \
WRAP_XATTR \
LIBSAMBA-ERRORS
+getntacl_OBJ_FILES = $(utilssrcdir)/getntacl.o
+
# End BINARY getntacl
#################################
-MANPAGES += utils/man/getntacl.1
+MANPAGES += $(utilssrcdir)/man/getntacl.1
#################################
# Start BINARY setntacl
[BINARY::setntacl]
# disabled until rewritten
#INSTALLDIR = BINDIR
-OBJ_FILES = \
- setntacl.o
# End BINARY setntacl
#################################
+setntacl_OBJ_FILES = $(utilssrcdir)/setntacl.o
+
#################################
# Start BINARY setnttoken
[BINARY::setnttoken]
INSTALLDIR = BINDIR
-OBJ_FILES = \
- setnttoken.o
PRIVATE_DEPENDENCIES =
# End BINARY setnttoken
#################################
+setnttoken_OBJ_FILES = $(utilssrcdir)/setnttoken.o
+
#################################
# Start BINARY nmblookup
[BINARY::nmblookup]
INSTALLDIR = BINDIR
-OBJ_FILES = \
- nmblookup.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-HOSTCONFIG \
LIBSAMBA-UTIL \
@@ -77,12 +76,12 @@ PRIVATE_DEPENDENCIES = \
# End BINARY nmblookup
#################################
+nmblookup_OBJ_FILES = $(utilssrcdir)/nmblookup.o
+
#################################
# Start BINARY testparm
[BINARY::testparm]
INSTALLDIR = BINDIR
-OBJ_FILES = \
- testparm.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-HOSTCONFIG \
LIBSAMBA-UTIL \
@@ -93,3 +92,5 @@ PRIVATE_DEPENDENCIES = \
CHARSET
# End BINARY testparm
#################################
+
+testparm_OBJ_FILES = $(utilssrcdir)/testparm.o
diff --git a/source4/utils/net/config.mk b/source4/utils/net/config.mk
index ced0710ae0..93b51e1e28 100644
--- a/source4/utils/net/config.mk
+++ b/source4/utils/net/config.mk
@@ -1,17 +1,9 @@
-# utils/net subsystem
+# $(utilssrcdir)/net subsystem
#################################
# Start BINARY net
[BINARY::net]
INSTALLDIR = BINDIR
-PRIVATE_PROTO_HEADER = net_proto.h
-OBJ_FILES = \
- net.o \
- net_password.o \
- net_time.o \
- net_join.o \
- net_vampire.o \
- net_user.o
PRIVATE_DEPENDENCIES = \
LIBSAMBA-HOSTCONFIG \
LIBSAMBA-UTIL \
@@ -21,3 +13,14 @@ PRIVATE_DEPENDENCIES = \
POPT_CREDENTIALS
# End BINARY net
#################################
+
+net_OBJ_FILES = $(addprefix $(utilssrcdir)/net/, \
+ net.o \
+ net_password.o \
+ net_time.o \
+ net_join.o \
+ net_vampire.o \
+ net_user.o)
+
+
+$(eval $(call proto_header_template,$(utilssrcdir)/net/net_proto.h,$(net_OBJ_FILES:.o=.c)))
diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c
index e0865c4416..a87b266568 100644
--- a/source4/utils/net/net.c
+++ b/source4/utils/net/net.c
@@ -46,6 +46,8 @@
#include "lib/ldb/include/ldb.h"
#include "librpc/rpc/dcerpc.h"
#include "param/param.h"
+#include "lib/events/events.h"
+#include "auth/credentials/credentials.h"
/*
run a function from a function table. If not found then
@@ -102,7 +104,8 @@ static const struct net_functable net_functable[] = {
{"time", "get remote server's time\n", net_time, net_time_usage},
{"join", "join a domain\n", net_join, net_join_usage},
{"samdump", "dump the sam of a domain\n", net_samdump, net_samdump_usage},
- {"samsync", "synchronise into the local ldb the sam of a domain\n", net_samsync_ldb, net_samsync_ldb_usage},
+ {"vampire", "join and syncronise an AD domain onto the local server\n", net_vampire, net_vampire_usage},
+ {"samsync", "synchronise into the local ldb the sam of an NT4 domain\n", net_samsync_ldb, net_samsync_ldb_usage},
{"user", "manage user accounts\n", net_user, net_user_usage},
{NULL, NULL, NULL, NULL}
};
@@ -139,7 +142,7 @@ static int binary_net(int argc, const char **argv)
int rc;
int argc_new;
const char **argv_new;
- TALLOC_CTX *mem_ctx;
+ struct event_context *ev;
struct net_context *ctx = NULL;
poptContext pc;
struct poptOption long_options[] = {
@@ -182,17 +185,21 @@ static int binary_net(int argc, const char **argv)
dcerpc_init();
- mem_ctx = talloc_init("net_context");
- ctx = talloc(mem_ctx, struct net_context);
+ ev = event_context_init(NULL);
+ if (!ev) {
+ d_printf("Failed to create an event context\n");
+ exit(1);
+ }
+ ctx = talloc(ev, struct net_context);
if (!ctx) {
- d_printf("talloc_init(net_context) failed\n");
+ d_printf("Failed to talloc a net_context\n");
exit(1);
}
ZERO_STRUCTP(ctx);
- ctx->mem_ctx = mem_ctx;
ctx->lp_ctx = cmdline_lp_ctx;
ctx->credentials = cmdline_credentials;
+ ctx->event_ctx = ev;
rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage);
@@ -200,7 +207,7 @@ static int binary_net(int argc, const char **argv)
DEBUG(0,("return code = %d\n", rc));
}
- talloc_free(mem_ctx);
+ talloc_free(ev);
return rc;
}
diff --git a/source4/utils/net/net.h b/source4/utils/net/net.h
index 8c4fbd7fdd..309bee277c 100644
--- a/source4/utils/net/net.h
+++ b/source4/utils/net/net.h
@@ -22,9 +22,9 @@
#define _UTIL_NET_H
struct net_context {
- TALLOC_CTX *mem_ctx;
struct cli_credentials *credentials;
struct loadparm_context *lp_ctx;
+ struct event_context *event_ctx;
};
struct net_functable {
diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c
index 08a4fbd4a1..ad63340089 100644
--- a/source4/utils/net/net_join.c
+++ b/source4/utils/net/net_join.c
@@ -24,6 +24,7 @@
#include "libnet/libnet.h"
#include "libcli/security/security.h"
#include "param/param.h"
+#include "lib/events/events.h"
int net_join(struct net_context *ctx, int argc, const char **argv)
{
@@ -38,10 +39,10 @@ int net_join(struct net_context *ctx, int argc, const char **argv)
case 0: /* no args -> fail */
return net_join_usage(ctx, argc, argv);
case 1: /* only DOMAIN */
- tmp = talloc_strdup(ctx->mem_ctx, argv[0]);
+ tmp = talloc_strdup(ctx, argv[0]);
break;
case 2: /* DOMAIN and role */
- tmp = talloc_strdup(ctx->mem_ctx, argv[0]);
+ tmp = talloc_strdup(ctx, argv[0]);
if (strcasecmp(argv[1], "BDC") == 0) {
secure_channel_type = SEC_CHAN_BDC;
} else if (strcasecmp(argv[1], "MEMBER") == 0) {
@@ -57,12 +58,12 @@ int net_join(struct net_context *ctx, int argc, const char **argv)
domain_name = tmp;
- libnetctx = libnet_context_init(NULL, ctx->lp_ctx);
+ libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
if (!libnetctx) {
return -1;
}
libnetctx->cred = ctx->credentials;
- r = talloc(ctx->mem_ctx, struct libnet_Join);
+ r = talloc(ctx, struct libnet_Join);
if (!r) {
return -1;
}
@@ -83,7 +84,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv)
talloc_free(libnetctx);
return -1;
}
- d_printf("Joined domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx->mem_ctx, r->out.domain_sid));
+ d_printf("Joined domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx, r->out.domain_sid));
talloc_free(libnetctx);
return 0;
@@ -100,3 +101,70 @@ int net_join_help(struct net_context *ctx, int argc, const char **argv)
d_printf("Joins domain as either member or backup domain controller.\n");
return 0;
}
+
+int net_vampire(struct net_context *ctx, int argc, const char **argv)
+{
+ NTSTATUS status;
+ struct libnet_context *libnetctx;
+ struct libnet_Vampire *r;
+ char *tmp, *targetdir = NULL;
+ const char *domain_name;
+
+ switch (argc) {
+ case 0: /* no args -> fail */
+ return net_vampire_usage(ctx, argc, argv);
+ case 1: /* only DOMAIN */
+ tmp = talloc_strdup(ctx, argv[0]);
+ break;
+ case 2: /* domain and target dir */
+ tmp = talloc_strdup(ctx, argv[0]);
+ targetdir = talloc_strdup(ctx, argv[1]);
+ break;
+ default: /* too many args -> fail */
+ return net_vampire_usage(ctx, argc, argv);
+ }
+
+ domain_name = tmp;
+
+ libnetctx = libnet_context_init(NULL, ctx->lp_ctx);
+ if (!libnetctx) {
+ return -1;
+ }
+ libnetctx->cred = ctx->credentials;
+ r = talloc(ctx, struct libnet_Vampire);
+ if (!r) {
+ return -1;
+ }
+ /* prepare parameters for the vampire */
+ r->in.netbios_name = lp_netbios_name(ctx->lp_ctx);
+ r->in.domain_name = domain_name;
+ r->in.targetdir = targetdir;
+ r->out.error_string = NULL;
+
+ /* do the domain vampire */
+ status = libnet_Vampire(libnetctx, r, r);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, "Vampire of domain failed: %s\n",
+ r->out.error_string ? r->out.error_string : nt_errstr(status));
+ talloc_free(r);
+ talloc_free(libnetctx);
+ return -1;
+ }
+ d_printf("Vampired domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx, r->out.domain_sid));
+
+ talloc_free(libnetctx);
+ return 0;
+}
+
+int net_vampire_usage(struct net_context *ctx, int argc, const char **argv)
+{
+ d_printf("net vampire <domain> [options]\n");
+ return 0;
+}
+
+int net_vampire_help(struct net_context *ctx, int argc, const char **argv)
+{
+ d_printf("Vampires domain as either member or backup domain controller.\n");
+ return 0;
+}
diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c
index 1fcb772e4c..55f7c3c31d 100644
--- a/source4/utils/net/net_password.c
+++ b/source4/utils/net/net_password.c
@@ -22,6 +22,7 @@
#include "utils/net/net.h"
#include "libnet/libnet.h"
#include "system/filesys.h"
+#include "lib/events/events.h"
#include "auth/credentials/credentials.h"
/*
@@ -46,13 +47,13 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a
if (argc > 0 && argv[0]) {
new_password = argv[0];
} else {
- password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:",
+ password_prompt = talloc_asprintf(ctx, "Enter new password for account [%s\\%s]:",
cli_credentials_get_domain(ctx->credentials),
cli_credentials_get_username(ctx->credentials));
new_password = getpass(password_prompt);
}
- libnetctx = libnet_context_init(NULL, ctx->lp_ctx);
+ libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
if (!libnetctx) {
return -1;
}
@@ -66,7 +67,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a
r.generic.in.newpassword = new_password;
/* do password change */
- status = libnet_ChangePassword(libnetctx, ctx->mem_ctx, &r);
+ status = libnet_ChangePassword(libnetctx, ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("net_password_change: %s\n",r.generic.out.error_string));
return -1;
@@ -101,10 +102,10 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv
case 0: /* no args -> fail */
return net_password_set_usage(ctx, argc, argv);
case 1: /* only DOM\\user; prompt for password */
- tmp = talloc_strdup(ctx->mem_ctx, argv[0]);
+ tmp = talloc_strdup(ctx, argv[0]);
break;
case 2: /* DOM\\USER and password */
- tmp = talloc_strdup(ctx->mem_ctx, argv[0]);
+ tmp = talloc_strdup(ctx, argv[0]);
new_password = argv[1];
break;
default: /* too mayn args -> fail */
@@ -115,19 +116,19 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv
if ((p = strchr_m(tmp,'\\'))) {
*p = 0;
domain_name = tmp;
- account_name = talloc_strdup(ctx->mem_ctx, p+1);
+ account_name = talloc_strdup(ctx, p+1);
} else {
account_name = tmp;
domain_name = cli_credentials_get_domain(ctx->credentials);
}
if (!new_password) {
- password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:",
+ password_prompt = talloc_asprintf(ctx, "Enter new password for account [%s\\%s]:",
domain_name, account_name);
new_password = getpass(password_prompt);
}
- libnetctx = libnet_context_init(NULL, ctx->lp_ctx);
+ libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
if (!libnetctx) {
return -1;
}
@@ -140,7 +141,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv
r.generic.in.newpassword = new_password;
/* do password change */
- status = libnet_SetPassword(libnetctx, ctx->mem_ctx, &r);
+ status = libnet_SetPassword(libnetctx, ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("net_password_set: %s\n",r.generic.out.error_string));
return -1;
diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c
index 1f4bb3ed71..92e6e77481 100644
--- a/source4/utils/net/net_time.c
+++ b/source4/utils/net/net_time.c
@@ -22,6 +22,7 @@
#include "libnet/libnet.h"
#include "utils/net/net.h"
#include "system/time.h"
+#include "lib/events/events.h"
/*
* Code for getting the remote time
@@ -42,7 +43,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv)
return net_time_usage(ctx, argc, argv);
}
- libnetctx = libnet_context_init(NULL, ctx->lp_ctx);
+ libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
if (!libnetctx) {
return -1;
}
@@ -53,7 +54,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv)
r.generic.in.server_name = server_name;
/* get the time */
- status = libnet_RemoteTOD(libnetctx, ctx->mem_ctx, &r);
+ status = libnet_RemoteTOD(libnetctx, ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("net_time: %s\n",r.generic.out.error_string));
return -1;
diff --git a/source4/utils/net/net_user.c b/source4/utils/net/net_user.c
index 39d50e7d8b..c4b8ecb0c2 100644
--- a/source4/utils/net/net_user.c
+++ b/source4/utils/net/net_user.c
@@ -21,6 +21,7 @@
#include "includes.h"
#include "utils/net/net.h"
#include "libnet/libnet.h"
+#include "lib/events/events.h"
#include "auth/credentials/credentials.h"
static int net_user_add(struct net_context *ctx, int argc, const char **argv)
@@ -36,14 +37,14 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv)
return net_user_usage(ctx, argc, argv);
break;
case 1:
- user_name = talloc_strdup(ctx->mem_ctx, argv[0]);
+ user_name = talloc_strdup(ctx, argv[0]);
break;
default:
return net_user_usage(ctx, argc, argv);
}
/* libnet context init and its params */
- lnet_ctx = libnet_context_init(NULL, ctx->lp_ctx);
+ lnet_ctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
if (!lnet_ctx) return -1;
lnet_ctx->cred = ctx->credentials;
@@ -52,7 +53,7 @@ static int net_user_add(struct net_context *ctx, int argc, const char **argv)
r.in.user_name = user_name;
r.in.domain_name = cli_credentials_get_domain(lnet_ctx->cred);
- status = libnet_CreateUser(lnet_ctx, ctx->mem_ctx, &r);
+ status = libnet_CreateUser(lnet_ctx, ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Failed to add user account: %s\n",
r.out.error_string));
@@ -76,14 +77,14 @@ static int net_user_delete(struct net_context *ctx, int argc, const char **argv)
return net_user_usage(ctx, argc, argv);
break;
case 1:
- user_name = talloc_strdup(ctx->mem_ctx, argv[0]);
+ user_name = talloc_strdup(ctx, argv[0]);
break;
default:
return net_user_usage(ctx, argc, argv);
}
/* libnet context init and its params */
- lnet_ctx = libnet_context_init(NULL, ctx->lp_ctx);
+ lnet_ctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
if (!lnet_ctx) return -1;
lnet_ctx->cred = ctx->credentials;
@@ -92,7 +93,7 @@ static int net_user_delete(struct net_context *ctx, int argc, const char **argv)
r.in.user_name = user_name;
r.in.domain_name = cli_credentials_get_domain(lnet_ctx->cred);
- status = libnet_DeleteUser(lnet_ctx, ctx->mem_ctx, &r);
+ status = libnet_DeleteUser(lnet_ctx, ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Failed to delete user account: %s\n",
r.out.error_string));
diff --git a/source4/utils/net/net_vampire.c b/source4/utils/net/net_vampire.c
index c798112d7b..14f6a07e4b 100644
--- a/source4/utils/net/net_vampire.c
+++ b/source4/utils/net/net_vampire.c
@@ -25,6 +25,7 @@
#include "librpc/gen_ndr/samr.h"
#include "auth/auth.h"
#include "param/param.h"
+#include "lib/events/events.h"
static int net_samdump_keytab_usage(struct net_context *ctx, int argc, const char **argv)
{
@@ -53,7 +54,7 @@ static int net_samdump_keytab(struct net_context *ctx, int argc, const char **ar
break;
}
- libnetctx = libnet_context_init(NULL, ctx->lp_ctx);
+ libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
if (!libnetctx) {
return -1;
}
@@ -63,7 +64,7 @@ static int net_samdump_keytab(struct net_context *ctx, int argc, const char **ar
r.in.machine_account = NULL;
r.in.binding_string = NULL;
- status = libnet_SamDump_keytab(libnetctx, ctx->mem_ctx, &r);
+ status = libnet_SamDump_keytab(libnetctx, ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("libnet_SamDump returned %s: %s\n",
nt_errstr(status),
@@ -99,7 +100,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv)
return rc;
}
- libnetctx = libnet_context_init(NULL, ctx->lp_ctx);
+ libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
if (!libnetctx) {
return -1;
}
@@ -109,7 +110,7 @@ int net_samdump(struct net_context *ctx, int argc, const char **argv)
r.in.machine_account = NULL;
r.in.binding_string = NULL;
- status = libnet_SamDump(libnetctx, ctx->mem_ctx, &r);
+ status = libnet_SamDump(libnetctx, ctx, &r);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("libnet_SamDump returned %s: %s\n",
nt_errstr(status),
@@ -141,7 +142,7 @@ int net_samsync_ldb(struct net_context *ctx, int argc, const char **argv)
struct libnet_context *libnetctx;
struct libnet_samsync_ldb r;
- libnetctx = libnet_context_init(NULL, ctx->lp_ctx);
+ libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
if (!libnetctx) {
return -1;
}
@@ -169,7 +170,7 @@ int net_samsync_ldb(struct net_context *ctx, int argc, const char **argv)
int net_samsync_ldb_usage(struct net_context *ctx, int argc, const char **argv)
{
- d_printf("net samsync_ldb\n");
+ d_printf("net samsync\n");
return 0;
}
diff --git a/source4/utils/nmblookup.c b/source4/utils/nmblookup.c
index fe03e0dbbe..980e06602d 100644
--- a/source4/utils/nmblookup.c
+++ b/source4/utils/nmblookup.c
@@ -24,6 +24,7 @@
#include "includes.h"
#include "lib/cmdline/popt_common.h"
#include "lib/socket/socket.h"
+#include "lib/events/events.h"
#include "system/network.h"
#include "system/locale.h"
#include "lib/socket/netif.h"
@@ -180,7 +181,7 @@ static NTSTATUS do_node_query(struct nbt_name_socket *nbtsock,
}
-static bool process_one(struct loadparm_context *lp_ctx,
+static bool process_one(struct loadparm_context *lp_ctx, struct event_context *ev,
struct interface *ifaces, const char *name, int nbt_port)
{
TALLOC_CTX *tmp_ctx = talloc_new(NULL);
@@ -211,7 +212,7 @@ static bool process_one(struct loadparm_context *lp_ctx,
node_name = talloc_strdup(tmp_ctx, name);
}
- nbtsock = nbt_name_socket_init(tmp_ctx, NULL, lp_iconv_convenience(lp_ctx));
+ nbtsock = nbt_name_socket_init(tmp_ctx, ev, lp_iconv_convenience(lp_ctx));
if (options.root_port) {
all_zero_addr = socket_address_from_strings(tmp_ctx, nbtsock->sock->backend_name,
@@ -271,6 +272,7 @@ int main(int argc, const char *argv[])
{
bool ret = true;
struct interface *ifaces;
+ struct event_context *ev;
poptContext pc;
int opt;
enum {
@@ -356,13 +358,17 @@ int main(int argc, const char *argv[])
}
load_interfaces(NULL, lp_interfaces(cmdline_lp_ctx), &ifaces);
-
+
+ ev = event_context_init(talloc_autofree_context());
+
while (poptPeekArg(pc)) {
const char *name = poptGetArg(pc);
- ret &= process_one(cmdline_lp_ctx, ifaces, name, lp_nbt_port(cmdline_lp_ctx));
+ ret &= process_one(cmdline_lp_ctx, ev, ifaces, name, lp_nbt_port(cmdline_lp_ctx));
}
+ talloc_free(ev);
+
talloc_free(ifaces);
poptFreeContext(pc);
diff --git a/source4/utils/ntlm_auth.c b/source4/utils/ntlm_auth.c
index 0c9a41fd70..95029deffa 100644
--- a/source4/utils/ntlm_auth.c
+++ b/source4/utils/ntlm_auth.c
@@ -30,6 +30,7 @@
#include "auth/auth.h"
#include "librpc/gen_ndr/ndr_netlogon.h"
#include "auth/auth_sam.h"
+#include "auth/ntlm/ntlm_check.h"
#include "pstring.h"
#include "libcli/auth/libcli_auth.h"
#include "libcli/security/security.h"
@@ -461,6 +462,10 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
return;
}
+ ev = event_context_init(state);
+ if (!ev) {
+ exit(1);
+ }
/* setup gensec */
if (!(state->gensec_state)) {
switch (stdio_helper_mode) {
@@ -468,7 +473,7 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
case NTLMSSP_CLIENT_1:
/* setup the client side */
- nt_status = gensec_client_start(NULL, &state->gensec_state, NULL, lp_ctx);
+ nt_status = gensec_client_start(NULL, &state->gensec_state, ev, lp_ctx);
if (!NT_STATUS_IS_OK(nt_status)) {
exit(1);
}
@@ -476,10 +481,6 @@ static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
break;
case GSS_SPNEGO_SERVER:
case SQUID_2_5_NTLMSSP:
- ev = event_context_init(state);
- if (!ev) {
- exit(1);
- }
msg = messaging_client_init(state, lp_messaging_path(state, lp_ctx),
lp_iconv_convenience(lp_ctx), ev);
if (!msg) {
diff --git a/source4/web_server/config.mk b/source4/web_server/config.mk
index 7f38b085f2..fe78687794 100644
--- a/source4/web_server/config.mk
+++ b/source4/web_server/config.mk
@@ -4,11 +4,11 @@
# Start SUBSYSTEM WEB
[MODULE::WEB]
INIT_FUNCTION = server_service_web_init
-SUBSYSTEM = service
-PRIVATE_PROTO_HEADER = proto.h
-OBJ_FILES = \
- web_server.o \
- http.o
+SUBSYSTEM = smbd
PRIVATE_DEPENDENCIES = ESP LIBTLS smbcalls process_model
# End SUBSYSTEM WEB
#######################
+
+WEB_OBJ_FILES = $(addprefix $(web_serversrcdir)/, web_server.o http.o)
+
+$(eval $(call proto_header_template,$(web_serversrcdir)/proto.h,$(WEB_OBJ_FILES:.o=.c)))
diff --git a/source4/winbind/config.mk b/source4/winbind/config.mk
index 8c9b3f1225..b5eb2c23f0 100644
--- a/source4/winbind/config.mk
+++ b/source4/winbind/config.mk
@@ -4,9 +4,20 @@
# Start SUBSYSTEM WINBIND
[MODULE::WINBIND]
INIT_FUNCTION = server_service_winbind_init
-SUBSYSTEM = service
-PRIVATE_PROTO_HEADER = wb_proto.h
-OBJ_FILES = \
+SUBSYSTEM = smbd
+PRIVATE_DEPENDENCIES = \
+ WB_HELPER \
+ IDMAP \
+ NDR_WINBIND \
+ process_model \
+ RPC_NDR_LSA \
+ dcerpc_samr \
+ PAM_ERRORS \
+ LIBCLI_LDAP
+# End SUBSYSTEM WINBIND
+#######################
+
+WINBIND_OBJ_FILES = $(addprefix $(winbindsrcdir)/, \
wb_server.o \
wb_irpc.o \
wb_samba3_protocol.o \
@@ -36,36 +47,28 @@ OBJ_FILES = \
wb_cmd_setpwent.o \
wb_cmd_getpwent.o \
wb_pam_auth.o \
- wb_sam_logon.o
-PRIVATE_DEPENDENCIES = \
- WB_HELPER \
- IDMAP \
- NDR_WINBIND \
- process_model \
- RPC_NDR_LSA \
- dcerpc_samr \
- PAM_ERRORS \
- LIBCLI_LDAP
-# End SUBSYSTEM WINBIND
-#######################
+ wb_sam_logon.o)
+
+$(eval $(call proto_header_template,$(winbindsrcdir)/wb_proto.h,$(WINBIND_OBJ_FILES:.o=.c)))
################################################
# Start SUBYSTEM WB_HELPER
[SUBSYSTEM::WB_HELPER]
-PRIVATE_PROTO_HEADER = wb_helper.h
-OBJ_FILES = \
- wb_async_helpers.o \
- wb_utils.o
PUBLIC_DEPENDENCIES = RPC_NDR_LSA dcerpc_samr
# End SUBSYSTEM WB_HELPER
################################################
+WB_HELPER_OBJ_FILES = $(addprefix $(winbindsrcdir)/, wb_async_helpers.o wb_utils.o)
+
+$(eval $(call proto_header_template,$(winbindsrcdir)/wb_helper.h,$(WB_HELPER_OBJ_FILES:.o=.c)))
+
################################################
# Start SUBYSTEM IDMAP
[SUBSYSTEM::IDMAP]
-PRIVATE_PROTO_HEADER = idmap_proto.h
-OBJ_FILES = \
- idmap.o
PUBLIC_DEPENDENCIES = SAMDB_COMMON
# End SUBSYSTEM IDMAP
################################################
+
+IDMAP_OBJ_FILES = $(winbindsrcdir)/idmap.o
+
+$(eval $(call proto_header_template,$(winbindsrcdir)/idmap_proto.h,$(IDMAP_OBJ_FILES:.o=.c)))
diff --git a/source4/winbind/idmap.c b/source4/winbind/idmap.c
index 92ac41f1d2..333a86445a 100644
--- a/source4/winbind/idmap.c
+++ b/source4/winbind/idmap.c
@@ -158,6 +158,7 @@ static struct dom_sid *idmap_msg_get_dom_sid(TALLOC_CTX *mem_ctx,
* \return allocated idmap_context on success, NULL on error
*/
struct idmap_context *idmap_init(TALLOC_CTX *mem_ctx,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx)
{
struct idmap_context *idmap_ctx;
@@ -169,7 +170,7 @@ struct idmap_context *idmap_init(TALLOC_CTX *mem_ctx,
idmap_ctx->lp_ctx = lp_ctx;
- idmap_ctx->ldb_ctx = ldb_wrap_connect(mem_ctx, lp_ctx,
+ idmap_ctx->ldb_ctx = ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx,
lp_idmap_url(lp_ctx),
system_session(mem_ctx, lp_ctx),
NULL, 0, NULL);
@@ -654,7 +655,7 @@ NTSTATUS idmap_xids_to_sids(struct idmap_context *idmap_ctx,
&id[i].sid);
}
if (!NT_STATUS_IS_OK(id[i].status)) {
- DEBUG(1, ("idmapping failed for id[%d]\n", i));
+ DEBUG(1, ("idmapping xid_to_sid failed for id[%d]\n", i));
error_count++;
}
}
@@ -699,7 +700,7 @@ NTSTATUS idmap_sids_to_xids(struct idmap_context *idmap_ctx,
&id[i].unixid);
}
if (!NT_STATUS_IS_OK(id[i].status)) {
- DEBUG(1, ("idmapping failed for id[%d]\n", i));
+ DEBUG(1, ("idmapping sid_to_xid failed for id[%d]\n", i));
error_count++;
}
}
diff --git a/source4/winbind/idmap.h b/source4/winbind/idmap.h
index 6eae92cc68..13dbe0b921 100644
--- a/source4/winbind/idmap.h
+++ b/source4/winbind/idmap.h
@@ -31,6 +31,8 @@ struct idmap_context {
struct dom_sid *unix_users_sid;
};
+struct event_context;
+
#include "winbind/idmap_proto.h"
#endif
diff --git a/source4/winbind/wb_async_helpers.c b/source4/winbind/wb_async_helpers.c
index 662dd111dd..25d52a16b5 100644
--- a/source4/winbind/wb_async_helpers.c
+++ b/source4/winbind/wb_async_helpers.c
@@ -305,73 +305,6 @@ NTSTATUS wb_lsa_lookupnames_recv(struct composite_context *c,
talloc_free(c);
return status;
}
-
-
-#if 0
-
-struct cmd_checkmachacc_state {
- struct composite_context *ctx;
- struct wbsrv_call *call;
- struct wbsrv_domain *domain;
-};
-
-static void cmd_checkmachacc_recv_init(struct composite_context *ctx);
-
- struct composite_context *wb_cmd_checkmachacc_send(struct wbsrv_call *call)
-{
- struct composite_context *result, *ctx;
- struct cmd_checkmachacc_state *state;
- struct wbsrv_service *service = call->wbconn->listen_socket->service;
-
- result = composite_create(mem_ctx, call->event_ctx;
- if (result == NULL) goto failed;
-
- state = talloc(result, struct cmd_checkmachacc_state);
- if (state == NULL) goto failed;
- state->ctx = result;
- result->private_data = state;
- state->call = call;
-
- state->domain = service->domains;
-
- ctx = wb_init_domain_send(service, state->domain);
- if (ctx == NULL) goto failed;
- ctx->async.fn = cmd_checkmachacc_recv_init;
- ctx->async.private_data = state;
-
- return result;
-
- failed:
- talloc_free(result);
- return NULL;
-}
-
-static void cmd_checkmachacc_recv_init(struct composite_context *ctx)
-{
- struct cmd_checkmachacc_state *state =
- talloc_get_type(ctx->async.private_data,
- struct cmd_checkmachacc_state);
-
- state->ctx->status = wb_init_domain_recv(ctx);
- if (!composite_is_ok(state->ctx)) return;
-
- composite_done(state->ctx);
-}
-
- NTSTATUS wb_cmd_checkmachacc_recv(struct composite_context *c)
-{
- NTSTATUS status = composite_wait(c);
- talloc_free(c);
- return status;
-}
-
- NTSTATUS wb_cmd_checkmachacc(struct wbsrv_call *call)
-{
- struct composite_context *c = wb_cmd_checkmachacc_send(call);
- return wb_cmd_checkmachacc_recv(c);
-}
-#endif
-
struct samr_getuserdomgroups_state {
struct composite_context *ctx;
struct dcerpc_pipe *samr_pipe;
diff --git a/source4/winbind/wb_cmd_getpwnam.c b/source4/winbind/wb_cmd_getpwnam.c
index fb2dc197c9..7d821537f0 100644
--- a/source4/winbind/wb_cmd_getpwnam.c
+++ b/source4/winbind/wb_cmd_getpwnam.c
@@ -92,7 +92,8 @@ static void cmd_getpwnam_recv_domain(struct composite_context *ctx)
return;
}
- user_info->in.user_name = user_name;
+ user_info->in.level = USER_INFO_BY_NAME;
+ user_info->in.data.user_name = user_name;
user_info->in.domain_name = domain->libnet_ctx->samr.name;
state->workgroup_name = talloc_strdup(state,
domain->libnet_ctx->samr.name);
diff --git a/source4/winbind/wb_cmd_getpwuid.c b/source4/winbind/wb_cmd_getpwuid.c
index c250af1b56..15cc592cf6 100644
--- a/source4/winbind/wb_cmd_getpwuid.c
+++ b/source4/winbind/wb_cmd_getpwuid.c
@@ -34,6 +34,7 @@ struct cmd_getpwuid_state {
struct composite_context *ctx;
struct wbsrv_service *service;
uid_t uid;
+ struct dom_sid *sid;
char *workgroup;
struct wbsrv_domain *domain;
@@ -81,14 +82,13 @@ static void cmd_getpwuid_recv_sid(struct composite_context *ctx)
struct cmd_getpwuid_state *state =
talloc_get_type(ctx->async.private_data,
struct cmd_getpwuid_state);
- struct dom_sid *sid;
DEBUG(5, ("cmd_getpwuid_recv_sid called %p\n", ctx->private_data));
- state->ctx->status = wb_uid2sid_recv(ctx, state, &sid);
+ state->ctx->status = wb_uid2sid_recv(ctx, state, &state->sid);
if (!composite_is_ok(state->ctx)) return;
- ctx = wb_sid2domain_send(state, state->service, sid);
+ ctx = wb_sid2domain_send(state, state->service, state->sid);
composite_continue(state->ctx, ctx, cmd_getpwuid_recv_domain, state);
}
@@ -110,7 +110,8 @@ static void cmd_getpwuid_recv_domain(struct composite_context *ctx)
user_info = talloc(state, struct libnet_UserInfo);
if (composite_nomem(user_info, state->ctx)) return;
- user_info->in.user_name = state->domain->libnet_ctx->cred->username;
+ user_info->in.level = USER_INFO_BY_SID;
+ user_info->in.data.user_sid = state->sid;
user_info->in.domain_name = state->domain->libnet_ctx->samr.name;
/* We need the workgroup later, so copy it */
diff --git a/source4/winbind/wb_cmd_list_trustdom.c b/source4/winbind/wb_cmd_list_trustdom.c
index 83bd517a02..8d0c1bd947 100644
--- a/source4/winbind/wb_cmd_list_trustdom.c
+++ b/source4/winbind/wb_cmd_list_trustdom.c
@@ -143,7 +143,8 @@ static void cmd_list_trustdoms_recv_doms(struct rpc_request *req)
state->domains = talloc_realloc(state, state->domains,
struct wb_dom_info *,
state->num_domains);
- if (composite_nomem(state->domains, state->ctx)) return;
+ if (state->num_domains &&
+ composite_nomem(state->domains, state->ctx)) return;
for (i=0; i<state->r.out.domains->count; i++) {
int j = i+old_num_domains;
diff --git a/source4/winbind/wb_connect_lsa.c b/source4/winbind/wb_connect_lsa.c
index 61b123a502..a728f8abe4 100644
--- a/source4/winbind/wb_connect_lsa.c
+++ b/source4/winbind/wb_connect_lsa.c
@@ -62,8 +62,11 @@ struct composite_context *wb_init_lsa_send(TALLOC_CTX *mem_ctx,
/* this will make the secondary connection on the same IPC$ share,
secured with SPNEGO or NTLMSSP */
- ctx = dcerpc_secondary_connection_send(domain->netlogon_pipe,
- domain->lsa_binding);
+ ctx = dcerpc_secondary_auth_connection_send(domain->netlogon_pipe,
+ domain->lsa_binding,
+ &ndr_table_lsarpc,
+ domain->libnet_ctx->cred,
+ domain->libnet_ctx->lp_ctx);
composite_continue(state->ctx, ctx, init_lsa_recv_pipe, state);
return result;
@@ -79,8 +82,8 @@ static void init_lsa_recv_pipe(struct composite_context *ctx)
talloc_get_type(ctx->async.private_data,
struct init_lsa_state);
- state->ctx->status = dcerpc_secondary_connection_recv(ctx,
- &state->lsa_pipe);
+ state->ctx->status = dcerpc_secondary_auth_connection_recv(ctx, state,
+ &state->lsa_pipe);
if (!composite_is_ok(state->ctx)) return;
state->handle = talloc(state, struct policy_handle);
diff --git a/source4/winbind/wb_init_domain.c b/source4/winbind/wb_init_domain.c
index fc35f11db6..8b82ab711e 100644
--- a/source4/winbind/wb_init_domain.c
+++ b/source4/winbind/wb_init_domain.c
@@ -151,8 +151,6 @@ struct composite_context *wb_init_domain_send(TALLOC_CTX *mem_ctx,
state->domain->libnet_ctx->cred = cli_credentials_init(state->domain);
if (state->domain->libnet_ctx->cred == NULL) goto failed;
- cli_credentials_set_event_context(state->domain->libnet_ctx->cred, service->task->event_ctx);
-
cli_credentials_set_conf(state->domain->libnet_ctx->cred, service->task->lp_ctx);
/* Connect the machine account to the credentials */
@@ -211,7 +209,6 @@ static void init_domain_recv_netlogonpipe(struct composite_context *ctx)
&state->domain->netlogon_pipe);
if (!composite_is_ok(state->ctx)) {
- talloc_free(state->domain->netlogon_binding);
return;
}
talloc_steal(state->domain->netlogon_pipe, state->domain->netlogon_binding);
diff --git a/source4/winbind/wb_pam_auth.c b/source4/winbind/wb_pam_auth.c
index 62744297c6..ee54bcd58f 100644
--- a/source4/winbind/wb_pam_auth.c
+++ b/source4/winbind/wb_pam_auth.c
@@ -214,14 +214,11 @@ NTSTATUS wb_cmd_pam_auth_crap_recv(struct composite_context *c,
struct composite_context *wb_cmd_pam_auth_send(TALLOC_CTX *mem_ctx,
struct wbsrv_service *service,
- const char *domain,
- const char *user,
- const char *password)
+ struct cli_credentials *credentials)
{
- struct cli_credentials *credentials;
const char *workstation;
NTSTATUS status;
-
+ const char *user, *domain;
DATA_BLOB chal, nt_resp, lm_resp, names_blob;
int flags = CLI_CRED_NTLM_AUTH;
if (lp_client_lanman_auth(service->task->lp_ctx)) {
@@ -234,16 +231,6 @@ struct composite_context *wb_cmd_pam_auth_send(TALLOC_CTX *mem_ctx,
DEBUG(5, ("wbsrv_samba3_pam_auth called\n"));
- credentials = cli_credentials_init(mem_ctx);
- if (!credentials) {
- return NULL;
- }
- cli_credentials_set_conf(credentials, service->task->lp_ctx);
- cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED);
- cli_credentials_set_username(credentials, user, CRED_SPECIFIED);
-
- cli_credentials_set_password(credentials, password, CRED_SPECIFIED);
-
chal = data_blob_talloc(mem_ctx, NULL, 8);
if (!chal.data) {
return NULL;
@@ -269,7 +256,7 @@ struct composite_context *wb_cmd_pam_auth_send(TALLOC_CTX *mem_ctx,
return NULL;
}
return wb_cmd_pam_auth_crap_send(mem_ctx, service,
- 0 /* logon parameters */,
+ MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT|MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT /* logon parameters */,
domain, user, workstation,
chal, nt_resp, lm_resp);
}
diff --git a/source4/winbind/wb_samba3_cmd.c b/source4/winbind/wb_samba3_cmd.c
index 24074700fc..5ef0339ecb 100644
--- a/source4/winbind/wb_samba3_cmd.c
+++ b/source4/winbind/wb_samba3_cmd.c
@@ -29,7 +29,9 @@
#include "version.h"
#include "librpc/gen_ndr/netlogon.h"
#include "libcli/security/security.h"
-#include "auth/pam_errors.h"
+#include "auth/ntlm/pam_errors.h"
+#include "auth/credentials/credentials.h"
+#include "smbd/service_task.h"
/*
Send off the reply to an async Samba3 query, handling filling in the PAM, NTSTATUS and string errors.
@@ -41,13 +43,14 @@ static void wbsrv_samba3_async_auth_epilogue(NTSTATUS status,
struct winbindd_response *resp = &s3call->response;
if (!NT_STATUS_IS_OK(status)) {
resp->result = WINBINDD_ERROR;
- WBSRV_SAMBA3_SET_STRING(resp->data.auth.nt_status_string,
- nt_errstr(status));
- WBSRV_SAMBA3_SET_STRING(resp->data.auth.error_string,
- get_friendly_nt_error_msg(status));
} else {
resp->result = WINBINDD_OK;
}
+
+ WBSRV_SAMBA3_SET_STRING(resp->data.auth.nt_status_string,
+ nt_errstr(status));
+ WBSRV_SAMBA3_SET_STRING(resp->data.auth.error_string,
+ get_friendly_nt_error_msg(status));
resp->data.auth.pam_error = nt_status_to_pam(status);
resp->data.auth.nt_status = NT_STATUS_V(status);
@@ -110,10 +113,12 @@ NTSTATUS wbsrv_samba3_netbios_name(struct wbsrv_samba3_call *s3call)
NTSTATUS wbsrv_samba3_priv_pipe_dir(struct wbsrv_samba3_call *s3call)
{
- s3call->response.result = WINBINDD_OK;
- s3call->response.extra_data.data =
- smbd_tmp_path(s3call, s3call->wbconn->lp_ctx, WINBINDD_SAMBA3_PRIVILEGED_SOCKET);
- NT_STATUS_HAVE_NO_MEMORY(s3call->response.extra_data.data);
+ char *path = smbd_tmp_path(s3call, s3call->wbconn->lp_ctx, WINBINDD_SAMBA3_PRIVILEGED_SOCKET);
+ NT_STATUS_HAVE_NO_MEMORY(path);
+ s3call->response.result = WINBINDD_OK;
+ s3call->response.extra_data.data = path;
+
+ s3call->response.length += strlen(path) + 1;
return NT_STATUS_OK;
}
@@ -123,41 +128,65 @@ NTSTATUS wbsrv_samba3_ping(struct wbsrv_samba3_call *s3call)
return NT_STATUS_OK;
}
-#if 0
-/*
- Validate that we have a working pipe to the domain controller.
- Return any NT error found in the process
+/* Plaintext authentication
+
+ This interface is used by ntlm_auth in it's 'basic' authentication
+ mode, as well as by pam_winbind to authenticate users where we are
+ given a plaintext password.
*/
-static void checkmachacc_recv_creds(struct composite_context *ctx);
+static void check_machacc_recv(struct composite_context *ctx);
NTSTATUS wbsrv_samba3_check_machacc(struct wbsrv_samba3_call *s3call)
{
+ NTSTATUS status;
+ struct cli_credentials *creds;
struct composite_context *ctx;
+ struct wbsrv_service *service =
+ s3call->wbconn->listen_socket->service;
+
+ /* Create a credentials structure */
+ creds = cli_credentials_init(s3call);
+ if (creds == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
- DEBUG(5, ("wbsrv_samba3_check_machacc called\n"));
+ cli_credentials_set_conf(creds, service->task->lp_ctx);
- ctx = wb_cmd_checkmachacc_send(s3call->call);
- NT_STATUS_HAVE_NO_MEMORY(ctx);
+ /* Connect the machine account to the credentials */
+ status = cli_credentials_set_machine_account(creds, service->task->lp_ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(creds);
+ return status;
+ }
- ctx->async.fn = checkmachacc_recv_creds;
+ ctx = wb_cmd_pam_auth_send(s3call, service, creds);
+
+ if (!ctx) {
+ talloc_free(creds);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ ctx->async.fn = check_machacc_recv;
ctx->async.private_data = s3call;
- s3call->call->flags |= WBSRV_CALL_FLAGS_REPLY_ASYNC;
+ s3call->flags |= WBSRV_CALL_FLAGS_REPLY_ASYNC;
return NT_STATUS_OK;
}
-
-static void checkmachacc_recv_creds(struct composite_context *ctx)
+
+static void check_machacc_recv(struct composite_context *ctx)
{
struct wbsrv_samba3_call *s3call =
talloc_get_type(ctx->async.private_data,
struct wbsrv_samba3_call);
NTSTATUS status;
- status = wb_cmd_checkmachacc_recv(ctx);
+ status = wb_cmd_pam_auth_recv(ctx);
+
+ if (!NT_STATUS_IS_OK(status)) goto done;
+ done:
wbsrv_samba3_async_auth_epilogue(status, s3call);
}
-#endif
/*
Find the name of a suitable domain controller, by query on the
@@ -543,6 +572,7 @@ NTSTATUS wbsrv_samba3_pam_auth(struct wbsrv_samba3_call *s3call)
struct composite_context *ctx;
struct wbsrv_service *service =
s3call->wbconn->listen_socket->service;
+ struct cli_credentials *credentials;
char *user, *domain;
if (!wb_samba3_split_username(s3call, s3call->wbconn->lp_ctx,
@@ -551,8 +581,17 @@ NTSTATUS wbsrv_samba3_pam_auth(struct wbsrv_samba3_call *s3call)
return NT_STATUS_NO_SUCH_USER;
}
- ctx = wb_cmd_pam_auth_send(s3call, service, domain, user,
- s3call->request.data.auth.pass);
+ credentials = cli_credentials_init(s3call);
+ if (!credentials) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ cli_credentials_set_conf(credentials, service->task->lp_ctx);
+ cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED);
+ cli_credentials_set_username(credentials, user, CRED_SPECIFIED);
+
+ cli_credentials_set_password(credentials, s3call->request.data.auth.pass, CRED_SPECIFIED);
+
+ ctx = wb_cmd_pam_auth_send(s3call, service, credentials);
NT_STATUS_HAVE_NO_MEMORY(ctx);
ctx->async.fn = pam_auth_recv;
@@ -681,6 +720,9 @@ static void list_users_recv(struct composite_context *ctx)
if (NT_STATUS_IS_OK(status)) {
s3call->response.extra_data.data = extra_data;
s3call->response.length += extra_data_len;
+ if (extra_data) {
+ s3call->response.length += 1;
+ }
}
wbsrv_samba3_async_epilogue(status, s3call);
diff --git a/source4/winbind/wb_samba3_protocol.c b/source4/winbind/wb_samba3_protocol.c
index b252273cb6..3b97dff276 100644
--- a/source4/winbind/wb_samba3_protocol.c
+++ b/source4/winbind/wb_samba3_protocol.c
@@ -78,10 +78,8 @@ NTSTATUS wbsrv_samba3_handle_call(struct wbsrv_samba3_call *s3call)
case WINBINDD_INTERFACE_VERSION:
return wbsrv_samba3_interface_version(s3call);
-#if 0
case WINBINDD_CHECK_MACHACC:
return wbsrv_samba3_check_machacc(s3call);
-#endif
case WINBINDD_PING:
return wbsrv_samba3_ping(s3call);
@@ -187,7 +185,6 @@ NTSTATUS wbsrv_samba3_handle_call(struct wbsrv_samba3_call *s3call)
case WINBINDD_SET_MAPPING:
case WINBINDD_SET_HWM:
case WINBINDD_DUMP_MAPS:
- case WINBINDD_CHECK_MACHACC:
case WINBINDD_DOMAIN_INFO:
case WINBINDD_SHOW_SEQUENCE:
case WINBINDD_WINS_BYIP:
diff --git a/source4/winbind/wb_server.c b/source4/winbind/wb_server.c
index 99191f3c6c..f84dece11c 100644
--- a/source4/winbind/wb_server.c
+++ b/source4/winbind/wb_server.c
@@ -149,7 +149,7 @@ static void winbind_task_init(struct task_server *task)
return;
}
- service->idmap_ctx = idmap_init(service, task->lp_ctx);
+ service->idmap_ctx = idmap_init(service, task->event_ctx, task->lp_ctx);
if (service->idmap_ctx == NULL) {
task_server_terminate(task, "Failed to load idmap database");
return;
diff --git a/source4/winbind/wb_sids2xids.c b/source4/winbind/wb_sids2xids.c
index 302b915ff5..6b89caf465 100644
--- a/source4/winbind/wb_sids2xids.c
+++ b/source4/winbind/wb_sids2xids.c
@@ -67,15 +67,13 @@ NTSTATUS wb_sids2xids_recv(struct composite_context *ctx,
struct id_mapping **ids)
{
NTSTATUS status = composite_wait(ctx);
+ struct sids2xids_state *state = talloc_get_type(ctx->private_data,
+ struct sids2xids_state);
DEBUG(5, ("wb_sids2xids_recv called\n"));
- if (NT_STATUS_IS_OK(status)) {
- struct sids2xids_state *state =
- talloc_get_type(ctx->private_data,
- struct sids2xids_state);
- *ids = state->ids;
- }
+ *ids = state->ids;
+
talloc_free(ctx);
return status;
}
diff --git a/source4/winbind/wb_xids2sids.c b/source4/winbind/wb_xids2sids.c
index 1be394d276..a1cf2667ff 100644
--- a/source4/winbind/wb_xids2sids.c
+++ b/source4/winbind/wb_xids2sids.c
@@ -67,15 +67,13 @@ NTSTATUS wb_xids2sids_recv(struct composite_context *ctx,
struct id_mapping **ids)
{
NTSTATUS status = composite_wait(ctx);
+ struct xids2sids_state *state = talloc_get_type(ctx->private_data,
+ struct xids2sids_state);
DEBUG(5, ("wb_xids2sids_recv called.\n"));
- if (NT_STATUS_IS_OK(status)) {
- struct xids2sids_state *state =
- talloc_get_type(ctx->private_data,
- struct xids2sids_state);
- *ids = state->ids;
- }
+ *ids = state->ids;
+
talloc_free(ctx);
return status;
}
diff --git a/source4/wrepl_server/config.mk b/source4/wrepl_server/config.mk
index a2a6a72fe3..235a897503 100644
--- a/source4/wrepl_server/config.mk
+++ b/source4/wrepl_server/config.mk
@@ -4,8 +4,13 @@
# Start SUBSYSTEM WREPL_SRV
[MODULE::WREPL_SRV]
INIT_FUNCTION = server_service_wrepl_init
-SUBSYSTEM = service
-OBJ_FILES = \
+SUBSYSTEM = smbd
+PRIVATE_DEPENDENCIES = \
+ LIBCLI_WREPL WINSDB process_model
+# End SUBSYSTEM WREPL_SRV
+#######################
+
+WREPL_SRV_OBJ_FILES = $(addprefix $(wrepl_serversrcdir)/, \
wrepl_server.o \
wrepl_in_connection.o \
wrepl_in_call.o \
@@ -14,9 +19,6 @@ OBJ_FILES = \
wrepl_scavenging.o \
wrepl_out_pull.o \
wrepl_out_push.o \
- wrepl_out_helpers.o
-PRIVATE_PROTO_HEADER = wrepl_server_proto.h
-PRIVATE_DEPENDENCIES = \
- LIBCLI_WREPL WINSDB process_model
-# End SUBSYSTEM WREPL_SRV
-#######################
+ wrepl_out_helpers.o)
+
+$(eval $(call proto_header_template,$(wrepl_serversrcdir)/wrepl_server_proto.h,$(WREPL_SRV_OBJ_FILES:.o=.c)))
diff --git a/source4/wrepl_server/wrepl_in_connection.c b/source4/wrepl_server/wrepl_in_connection.c
index 34d94d73a6..25227481b8 100644
--- a/source4/wrepl_server/wrepl_in_connection.c
+++ b/source4/wrepl_server/wrepl_in_connection.c
@@ -230,7 +230,7 @@ NTSTATUS wreplsrv_in_connection_merge(struct wreplsrv_partner *partner,
wrepl_in->service = service;
wrepl_in->partner = partner;
- status = stream_new_connection_merge(service->task->event_ctx, model_ops,
+ status = stream_new_connection_merge(service->task->event_ctx, service->task->lp_ctx, model_ops,
sock, &wreplsrv_stream_ops, service->task->msg_ctx,
wrepl_in, &conn);
NT_STATUS_NOT_OK_RETURN(status);
diff --git a/source4/wrepl_server/wrepl_server.c b/source4/wrepl_server/wrepl_server.c
index e750d9355a..b703066986 100644
--- a/source4/wrepl_server/wrepl_server.c
+++ b/source4/wrepl_server/wrepl_server.c
@@ -35,9 +35,10 @@
#include "lib/socket/netif.h"
static struct ldb_context *wins_config_db_connect(TALLOC_CTX *mem_ctx,
+ struct event_context *ev_ctx,
struct loadparm_context *lp_ctx)
{
- return ldb_wrap_connect(mem_ctx, lp_ctx, private_path(mem_ctx,
+ return ldb_wrap_connect(mem_ctx, ev_ctx, lp_ctx, private_path(mem_ctx,
lp_ctx, lp_wins_config_url(lp_ctx)),
system_session(mem_ctx, lp_ctx), NULL, 0, NULL);
}
@@ -83,12 +84,12 @@ static NTSTATUS wreplsrv_open_winsdb(struct wreplsrv_service *service,
owner = iface_n_ip(ifaces, 0);
}
- service->wins_db = winsdb_connect(service, lp_ctx, owner, WINSDB_HANDLE_CALLER_WREPL);
+ service->wins_db = winsdb_connect(service, service->task->event_ctx, lp_ctx, owner, WINSDB_HANDLE_CALLER_WREPL);
if (!service->wins_db) {
return NT_STATUS_INTERNAL_DB_ERROR;
}
- service->config.ldb = wins_config_db_connect(service, lp_ctx);
+ service->config.ldb = wins_config_db_connect(service, service->task->event_ctx, lp_ctx);
if (!service->config.ldb) {
return NT_STATUS_INTERNAL_DB_ERROR;
}
diff --git a/testdata/samba3/provision_samba3sam_templates.ldif b/testdata/samba3/provision_samba3sam_templates.ldif
index 368c78d727..4fe6571eef 100644
--- a/testdata/samba3/provision_samba3sam_templates.ldif
+++ b/testdata/samba3/provision_samba3sam_templates.ldif
@@ -33,7 +33,6 @@ pwdLastSet: 0
primaryGroupID: 513
accountExpires: -1
logonCount: 0
-sAMAccountType: 805306368
objectCategory: CN=Person,CN=Schema,CN=Configuration,${BASEDN}
dn: CN=TemplateComputer,CN=Templates
@@ -55,7 +54,6 @@ pwdLastSet: 0
primaryGroupID: 513
accountExpires: -1
logonCount: 0
-sAMAccountType: 805306369
objectCategory: CN=Computer,CN=Schema,CN=Configuration,${BASEDN}
dn: CN=TemplateTrustingDomain,CN=Templates
@@ -74,7 +72,6 @@ lastLogon: 0
primaryGroupID: 513
accountExpires: -1
logonCount: 0
-sAMAccountType: 805306370
dn: CN=TemplateGroup,CN=Templates
objectClass: top
@@ -83,7 +80,6 @@ objectClass: groupTemplate
cn: TemplateGroup
instanceType: 4
groupType: -2147483646
-sAMAccountType: 268435456
objectCategory: CN=Group,CN=Schema,CN=Configuration,${BASEDN}
# Currently this isn't used, we don't have a way to detect it different from an incoming alias
@@ -95,7 +91,6 @@ objectCategory: CN=Group,CN=Schema,CN=Configuration,${BASEDN}
# cn: TemplateAlias
# instanceType: 4
# groupType: -2147483644
-# sAMAccountType: 268435456
dn: CN=TemplateForeignSecurityPrincipal,CN=Templates
objectClass: top
diff --git a/testprogs/blackbox/ndrdump/samr-CreateUser-in.dat b/testprogs/blackbox/ndrdump/samr-CreateUser-in.dat
new file mode 100644
index 0000000000..a5840e1f7f
--- /dev/null
+++ b/testprogs/blackbox/ndrdump/samr-CreateUser-in.dat
Binary files differ
diff --git a/testprogs/blackbox/ndrdump/samr-CreateUser-out.dat b/testprogs/blackbox/ndrdump/samr-CreateUser-out.dat
new file mode 100644
index 0000000000..cf9131dba9
--- /dev/null
+++ b/testprogs/blackbox/ndrdump/samr-CreateUser-out.dat
Binary files differ
diff --git a/testprogs/blackbox/subunit.sh b/testprogs/blackbox/subunit.sh
new file mode 100755
index 0000000000..100dfd1a46
--- /dev/null
+++ b/testprogs/blackbox/subunit.sh
@@ -0,0 +1,67 @@
+#
+# subunit.sh: shell functions to report test status via the subunit protocol.
+# Copyright (C) 2006 Robert Collins <robertc@robertcollins.net>
+# Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+subunit_start_test () {
+ # emit the current protocol start-marker for test $1
+ echo "test: $1"
+}
+
+
+subunit_pass_test () {
+ # emit the current protocol test passed marker for test $1
+ echo "success: $1"
+}
+
+
+subunit_fail_test () {
+ # emit the current protocol fail-marker for test $1, and emit stdin as
+ # the error text.
+ # we use stdin because the failure message can be arbitrarily long, and this
+ # makes it convenient to write in scripts (using <<END syntax.
+ echo "failure: $1 ["
+ cat -
+ echo "]"
+}
+
+
+subunit_error_test () {
+ # emit the current protocol error-marker for test $1, and emit stdin as
+ # the error text.
+ # we use stdin because the failure message can be arbitrarily long, and this
+ # makes it convenient to write in scripts (using <<END syntax.
+ echo "error: $1 ["
+ cat -
+ echo "]"
+}
+
+testit () {
+ name="$1"
+ shift
+ cmdline="$*"
+ subunit_start_test "$name"
+ output=`$cmdline 2>&1`
+ status=$?
+ if [ x$status = x0 ]; then
+ subunit_pass_test "$name"
+ else
+ echo $output | subunit_fail_test "$name"
+ fi
+ return $status
+}
diff --git a/testprogs/blackbox/test_cifsdd.sh b/testprogs/blackbox/test_cifsdd.sh
index 23df04c84c..43564a0c77 100755
--- a/testprogs/blackbox/test_cifsdd.sh
+++ b/testprogs/blackbox/test_cifsdd.sh
@@ -14,40 +14,24 @@ USERNAME=$2
PASSWORD=$3
DOMAIN=$4
+. `dirname $0`/subunit.sh
+
samba4bindir=`dirname $0`/../../source/bin
DD=$samba4bindir/cifsdd
SHARE=tmp
DEBUGLEVEL=1
-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
-}
-
runcopy() {
message="$1"
shift
testit "$message" $VALGRIND $DD $CONFIGURATION --debuglevel=$DEBUGLEVEL -W "$DOMAIN" -U "$USERNAME"%"$PASSWORD" \
- "$@"
+ "$@" || failed=`expr $failed + 1`
}
compare() {
- testit "$1" cmp "$2" "$3"
+ testit "$1" cmp "$2" "$3" || failed=`expr $failed + 1`
}
sourcepath=tempfile.src.$$
diff --git a/testprogs/blackbox/test_gentest.sh b/testprogs/blackbox/test_gentest.sh
index 89cc8c2795..ec6f0e422b 100755
--- a/testprogs/blackbox/test_gentest.sh
+++ b/testprogs/blackbox/test_gentest.sh
@@ -20,20 +20,7 @@ failed=0
samba4bindir=`dirname $0`/../../source/bin
gentest=$samba4bindir/gentest
-testit() {
- name="$1"
- shift
- cmdline="$*"
- echo "test: $name"
- $cmdline
- status=$?
- if [ x$status = x0 ]; then
- echo "success: $name"
- else
- echo "failure: $name"
- fi
- return $status
-}
+. `dirname $0`/subunit.sh
cat <<EOF > st/gentest.ignore
all_info.out.fname
diff --git a/testprogs/blackbox/test_kinit.sh b/testprogs/blackbox/test_kinit.sh
index dbcdcf1112..d3cece0af7 100755
--- a/testprogs/blackbox/test_kinit.sh
+++ b/testprogs/blackbox/test_kinit.sh
@@ -23,23 +23,9 @@ samba4bindir=`dirname $0`/../../source/bin
smbclient=$samba4bindir/smbclient
samba4kinit=$samba4bindir/samba4kinit
net=$samba4bindir/net
-enableaccount="$samba4bindir/smbpython `dirname $0`/../../source/setup/enableaccount"
-
-testit() {
- name="$1"
- shift
- cmdline="$*"
- echo "test: $name"
- $cmdline
- status=$?
- if [ x$status = x0 ]; then
- echo "success: $name"
- else
- echo "failure: $name"
- fi
- return $status
-}
+enableaccount="$PYTHON `dirname $0`/../../source/setup/enableaccount"
+. `dirname $0`/subunit.sh
test_smbclient() {
name="$1"
@@ -86,6 +72,14 @@ testit "kinit with user password" $samba4bindir/samba4kinit --password-file=./tm
test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
+NEWUSERPASS=testPaSS@34%
+testit "change user password" $VALGRIND $net password change -W$DOMAIN -U$DOMAIN\\nettestuser%$USERPASS $CONFIGURATION -k no $NEWUSERPASS $@ || failed=`expr $failed + 1`
+
+echo $NEWUSERPASS > ./tmpuserpassfile
+testit "kinit with user password" $samba4bindir/samba4kinit --password-file=./tmpuserpassfile --request-pac nettestuser@$REALM || failed=`expr $failed + 1`
+
+test_smbclient "Test login with user kerberos ccache" 'ls' -k yes || failed=`expr $failed + 1`
+
KRB5CCNAME="$PREFIX/tmpccache"
export KRB5CCNAME
diff --git a/testprogs/blackbox/test_ldb.sh b/testprogs/blackbox/test_ldb.sh
index 4067a7fc43..8e1af99719 100755
--- a/testprogs/blackbox/test_ldb.sh
+++ b/testprogs/blackbox/test_ldb.sh
@@ -14,6 +14,8 @@ PREFIX=$3
shift 2
options="$*"
+. `dirname $0`/subunit.sh
+
check() {
name="$1"
shift
diff --git a/testprogs/blackbox/test_locktest.sh b/testprogs/blackbox/test_locktest.sh
index c08b408107..88fa0ef892 100755
--- a/testprogs/blackbox/test_locktest.sh
+++ b/testprogs/blackbox/test_locktest.sh
@@ -21,20 +21,7 @@ failed=0
samba4bindir=`dirname $0`/../../source/bin
locktest=$samba4bindir/locktest
-testit() {
- name="$1"
- shift
- cmdline="$*"
- echo "test: $name"
- $cmdline
- status=$?
- if [ x$status = x0 ]; then
- echo "success: $name"
- else
- echo "failure: $name"
- fi
- return $status
-}
+. `dirname $0`/subunit.sh
testit "locktest" $VALGRIND $locktest //$SERVER/test1 //$SERVER/test2 --num-ops=100 -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@ || failed=`expr $failed + 1`
diff --git a/testprogs/blackbox/test_masktest.sh b/testprogs/blackbox/test_masktest.sh
index ef429a1fb0..c1f765c1dd 100755
--- a/testprogs/blackbox/test_masktest.sh
+++ b/testprogs/blackbox/test_masktest.sh
@@ -21,20 +21,7 @@ failed=0
samba4bindir=`dirname $0`/../../source/bin
masktest=$samba4bindir/masktest
-testit() {
- name="$1"
- shift
- cmdline="$*"
- echo "test: $name"
- $cmdline
- status=$?
- if [ x$status = x0 ]; then
- echo "success: $name"
- else
- echo "failure: $name"
- fi
- return $status
-}
+. `dirname $0`/subunit.sh
testit "masktest" $VALGRIND $masktest //$SERVER/tmp --num-ops=200 --dieonerror -W "$DOMAIN" -U"$USERNAME%$PASSWORD" $@ || failed=`expr $failed + 1`
diff --git a/testprogs/blackbox/test_ndrdump.sh b/testprogs/blackbox/test_ndrdump.sh
new file mode 100755
index 0000000000..089a7c3a2b
--- /dev/null
+++ b/testprogs/blackbox/test_ndrdump.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+# Blackbox tests for masktest
+# Copyright (C) 2008 Andrew Tridgell
+# Copyright (C) 2008 Andrew Bartlett
+# based on test_smbclient.sh
+
+. `dirname $0`/subunit.sh
+
+failed=0
+
+samba4bindir=`dirname $0`/../../source/bin
+ndrdump=$samba4bindir/ndrdump
+files=`dirname $0`/ndrdump
+
+testit "ndrdump with in" $VALGRIND $ndrdump samr samr_CreateUser in $files/samr-CreateUser-in.dat $@ || failed=`expr $failed + 1`
+testit "ndrdump with out" $VALGRIND $ndrdump samr samr_CreateUser out $files/samr-CreateUser-out.dat $@ || failed=`expr $failed + 1`
+testit "ndrdump with --context-file" $VALGRIND $ndrdump --context-file $files/samr-CreateUser-in.dat samr samr_CreateUser out $files/samr-CreateUser-out.dat $@ || failed=`expr $failed + 1`
+testit "ndrdump with validate" $VALGRIND $ndrdump --validate samr samr_CreateUser in $files/samr-CreateUser-in.dat $@ || failed=`expr $failed + 1`
+
+exit $failed
diff --git a/testprogs/blackbox/test_smbclient.sh b/testprogs/blackbox/test_smbclient.sh
index a803d83363..d2c5c675e2 100755
--- a/testprogs/blackbox/test_smbclient.sh
+++ b/testprogs/blackbox/test_smbclient.sh
@@ -21,20 +21,7 @@ failed=0
samba4bindir=`dirname $0`/../../source/bin
smbclient=$samba4bindir/smbclient
-testit() {
- name="$1"
- shift
- cmdline="$*"
- echo "test: $name"
- $cmdline
- status=$?
- if [ x$status = x0 ]; then
- echo "success: $name"
- else
- echo "failure: $name"
- fi
- return $status
-}
+. `dirname $0`/subunit.sh
runcmd() {
name="$1"
@@ -86,11 +73,29 @@ testit "Comparing files" diff tmpfile-old tmpfile || failed=`expr $failed + 1`
runcmd "Creating directory, Changing directory, Going back" 'mkdir bla; cd bla; cd ..; rmdir bla' || failed=`expr $failed + 1`
# enable recurse, create nested directory
runcmd "Creating nested directory" 'mkdir bla/bloe' || failed=`expr $failed + 1`
-# remove parent directory
-runcmd "Removing directory" 'rmdir bla/bloe' || failed=`expr $failed + 1`
# remove child directory
+runcmd "Removing directory" 'rmdir bla/bloe' || failed=`expr $failed + 1`
+# remove parent directory
runcmd "Removing directory" 'rmdir bla'|| failed=`expr $failed + 1`
+# enable recurse, create nested directory
+runcmd "Creating nested directory" 'mkdir bla' || failed=`expr $failed + 1`
+# rename bla to bla2
+runcmd "rename of nested directory" 'rename bla bla2' || failed=`expr $failed + 1`
+# deltree
+runcmd "deltree of nested directory" 'deltree bla2' || failed=`expr $failed + 1`
# run fsinfo
+runcmd "Getting file system info" 'fsinfo allocation'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo volume'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo volumeinfo'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo sizeinfo'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo deviceinfo'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo attributeinfo'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo volume-information'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo size-information'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo device-information'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo attribute-information'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo quota-information'|| failed=`expr $failed + 1`
+runcmd "Getting file system info" 'fsinfo fullsize-information'|| failed=`expr $failed + 1`
runcmd "Getting file system info" 'fsinfo objectid'|| failed=`expr $failed + 1`
# put that file
@@ -98,6 +103,7 @@ runcmd "Putting file" 'put tmpfile'|| failed=`expr $failed + 1`
# get that file
mv tmpfile tmpfile-old
runcmd "Getting file" 'get tmpfile'|| failed=`expr $failed + 1`
+runcmd "Getting file EA info" 'eainfo tmpfile'|| failed=`expr $failed + 1`
# remove that file
runcmd "Removing file" 'rm tmpfile' || failed=`expr $failed + 1`
# compare locally
@@ -111,6 +117,11 @@ testit "Comparing files" diff tmpfilex tmpfile || failed=`expr $failed + 1`
# remove that file
runcmd "Removing file" 'rm tmpfilex'|| failed=`expr $failed + 1`
+runcmd "Lookup name" "lookup $DOMAIN\\$USERNAME" || failed=`expr $failed + 1`
+
+#Fails unless there are privilages
+#runcmd "Lookup privs of name" "privileges $DOMAIN\\$USERNAME" || failed=`expr $failed + 1`
+
# do some simple operations using old protocol versions
runcmd "List directory with LANMAN1" 'ls' -m LANMAN1 || failed=`expr $failed + 1`
runcmd "List directory with LANMAN2" 'ls' -m LANMAN2 || failed=`expr $failed + 1`
diff --git a/testprogs/blackbox/test_wbinfo.sh b/testprogs/blackbox/test_wbinfo.sh
new file mode 100755
index 0000000000..ec8b9ebd44
--- /dev/null
+++ b/testprogs/blackbox/test_wbinfo.sh
@@ -0,0 +1,187 @@
+#!/bin/sh
+# Blackbox test for wbinfo
+if [ $# -lt 4 ]; then
+cat <<EOF
+Usage: test_wbinfo.sh DOMAIN USERNAME PASSWORD TARGET
+EOF
+exit 1;
+fi
+
+DOMAIN=$1
+USERNAME=$2
+PASSWORD=$3
+TARGET=$4
+shift 4
+
+failed=0
+samba4bindir=`dirname $0`/../../source/bin
+wbinfo=$samba4bindir/wbinfo
+
+. `dirname $0`/subunit.sh
+
+testfail() {
+ name="$1"
+ shift
+ cmdline="$*"
+ echo "test: $name"
+ $cmdline
+ status=$?
+ if [ x$status = x0 ]; then
+ echo "failure: $name"
+ else
+ echo "success: $name"
+ fi
+ return $status
+}
+
+knownfail() {
+ name="$1"
+ shift
+ cmdline="$*"
+ echo "test: $name"
+ $cmdline
+ status=$?
+ if [ x$status = x0 ]; then
+ echo "failure: $name [unexpected success]"
+ status=1
+ else
+ echo "knownfail: $name"
+ status=0
+ fi
+ return $status
+}
+
+
+testit "wbinfo -u against $TARGET" $wbinfo -u || failed=`expr $failed + 1`
+# Does not work yet
+knownfail "wbinfo -g against $TARGET" $wbinfo -g || failed=`expr $failed + 1`
+knownfail "wbinfo -N against $TARGET" $wbinfo -N || failed=`expr $failed + 1`
+knownfail "wbinfo -I against $TARGET" $wbinfo -I || failed=`expr $failed + 1`
+testit "wbinfo -n against $TARGET" $wbinfo -n "$DOMAIN/$USERNAME" || failed=`expr $failed + 1`
+admin_sid=`$wbinfo -n "$DOMAIN/$USERNAME" | cut -d " " -f1`
+echo "$DOMAIN/$USERNAME resolved to $admin_sid"
+
+testit "wbinfo -s $admin_sid against $TARGET" $wbinfo -s $admin_sid || failed=`expr $failed + 1`
+admin_name=`wbinfo -s $admin_sid | cut -d " " -f1| tr a-z A-Z`
+echo "$admin_sid resolved to $admin_name"
+
+tested_name=`echo $DOMAIN/$USERNAME | tr a-z A-Z`
+
+echo "test: wbinfo -s check for sane mapping"
+if test x$admin_name != x$tested_name; then
+ echo "$admin_name does not match $tested_name"
+ echo "failure: wbinfo -s check for sane mapping"
+ failed=`expr $failed + 1`
+else
+ echo "success: wbinfo -s check for sane mapping"
+fi
+
+testit "wbinfo -n on the returned name against $TARGET" $wbinfo -n $admin_name || failed=`expr $failed + 1`
+test_sid=`$wbinfo -n $tested_name | cut -d " " -f1`
+
+echo "test: wbinfo -n check for sane mapping"
+if test x$admin_sid != x$test_sid; then
+ echo "$admin_sid does not match $test_sid"
+ echo "failure: wbinfo -n check for sane mapping"
+ failed=`expr $failed + 1`
+else
+ echo "success: wbinfo -n check for sane mapping"
+fi
+
+testit "wbinfo -U against $TARGET" $wbinfo -U 30000 || failed=`expr $failed + 1`
+
+echo "test: wbinfo -U check for sane mapping"
+sid_for_30000=`$wbinfo -U 30000`
+if test x$sid_for_30000 != "xS-1-22-1-30000"; then
+ echo "uid 30000 mapped to $sid_for_30000, not S-1-22-1-30000"
+ echo "failure: wbinfo -U check for sane mapping"
+ failed=`expr $failed + 1`
+else
+ echo "success: wbinfo -U check for sane mapping"
+fi
+
+admin_uid=`wbinfo -U $admin_sid`
+
+testit "wbinfo -G against $TARGET" $wbinfo -G 30000 || failed=`expr $failed + 1`
+
+echo "test: wbinfo -G check for sane mapping"
+sid_for_30000=`$wbinfo -G 30000`
+if test x$sid_for_30000 != "xS-1-22-2-30000"; then
+ echo "gid 30000 mapped to $sid_for_30000, not S-1-22-2-30000"
+ echo "failure: wbinfo -G check for sane mapping"
+ failed=`expr $failed + 1`
+else
+ echo "success: wbinfo -G check for sane mapping"
+fi
+
+testit "wbinfo -S against $TARGET" $wbinfo -S "S-1-22-1-30000" || failed=`expr $failed + 1`
+
+echo "test: wbinfo -S check for sane mapping"
+uid_for_sid=`$wbinfo -S S-1-22-1-30000`
+if test 0$uid_for_sid -ne 30000; then
+ echo "S-1-22-1-30000 mapped to $uid_for_sid, not 30000"
+ echo "failure: wbinfo -S check for sane mapping"
+ failed=`expr $failed + 1`
+else
+ echo "success: wbinfo -S check for sane mapping"
+fi
+
+testfail "wbinfo -S against $TARGET using invalid SID" $wbinfo -S "S-1-22-2-30000" && failed=`expr $failed + 1`
+
+testit "wbinfo -Y against $TARGET" $wbinfo -Y "S-1-22-2-30000" || failed=`expr $failed + 1`
+
+echo "test: wbinfo -Y check for sane mapping"
+gid_for_sid=`$wbinfo -Y S-1-22-2-30000`
+if test 0$gid_for_sid -ne 30000; then
+ echo "S-1-22-2-30000 mapped to $gid_for_sid, not 30000"
+ echo "failure: wbinfo -Y check for sane mapping"
+ failed=`expr $failed + 1`
+else
+ echo "success: wbinfo -Y check for sane mapping"
+fi
+
+testfail "wbinfo -Y against $TARGET using invalid SID" $wbinfo -Y "S-1-22-1-30000" && failed=`expr $failed + 1`
+
+testit "wbinfo -t against $TARGET" $wbinfo -t || failed=`expr $failed + 1`
+
+testit "wbinfo --trusted-domains against $TARGET" $wbinfo --trusted-domains || failed=`expr $failed + 1`
+testit "wbinfo --all-domains against $TARGET" $wbinfo --all-domains || failed=`expr $failed + 1`
+testit "wbinfo --own-domain against $TARGET" $wbinfo --own-domain || failed=`expr $failed + 1`
+
+echo "test: wbinfo --own-domain against $TARGET check output"
+own_domain=`wbinfo --own-domain`
+if test x$own_domain = x$DOMAIN; then
+ echo "success: wbinfo --own-domain against $TARGET check output"
+else
+ echo "Own domain reported as $own_domain instead of $DOMAIN"
+ echo "failure: wbinfo --own-domain against $TARGET check output"
+fi
+
+# this does not work
+knownfail "wbinfo --sequence against $TARGET" $wbinfo --sequence
+knownfail "wbinfo -D against $TARGET" $wbinfo -D $DOMAIN || failed=`expr $failed + 1`
+
+testit "wbinfo -i against $TARGET" $wbinfo -i "$DOMAIN/$USERNAME" || failed=`expr $failed + 1`
+
+# this does not work
+knownfail "wbinfo --uid-info against $TARGET" $wbinfo --uid-info $admin_sid
+knownfail "wbinfo --group-info against $TARGET" $wbinfo --group-info "S-1-22-2-0"
+knownfail "wbinfo -r against $TARGET" $wbinfo -r "$DOMAIN/$USERNAME"
+
+testit "wbinfo --user-domgroups against $TARGET" $wbinfo --user-domgroups $admin_sid || failed=`expr $failed + 1`
+
+testit "wbinfo --user-sids against $TARGET" $wbinfo --user-sids $admin_sid || failed=`expr $failed + 1`
+
+testit "wbinfo -a against $TARGET with domain creds" $wbinfo -a "$DOMAIN/$USERNAME"%"$PASSWORD" || failed=`expr $failed + 1`
+
+# this does not work
+knwonfail "wbinfo --getdcname against $TARGET" $wbinfo --getdcname=$DOMAIN
+
+testit "wbinfo -p against $TARGET" $wbinfo -p || failed=`expr $failed + 1`
+
+testit "wbinfo -K against $TARGET with domain creds" $wbinfo -K "$DOMAIN/$USERNAME"%"$PASSWORD" || failed=`expr $failed + 1`
+
+testit "wbinfo --separator against $TARGET" $wbinfo --separator || failed=`expr $failed + 1`
+
+exit $failed
+
diff --git a/testprogs/ejs/echo.js b/testprogs/ejs/echo.js
deleted file mode 100755
index 3750baf0fb..0000000000
--- a/testprogs/ejs/echo.js
+++ /dev/null
@@ -1,235 +0,0 @@
-#!/usr/bin/env smbscript
-/*
- test echo pipe calls from ejs
-*/
-
-var options = GetOptions(ARGV,
- "POPT_AUTOHELP",
- "POPT_COMMON_SAMBA",
- "POPT_COMMON_CREDENTIALS");
-if (options == undefined) {
- println("Failed to parse options");
- return -1;
-}
-
-libinclude("base.js");
-
-/*
- generate a ramp as an integer array
- */
-function ramp_array(N)
-{
- var a = new Array(N);
- var data = datablob_init();
- for (i=0;i<N;i++) {
- a[i] = i;
- }
- return data.blobFromArray(a);
-}
-
-
-/*
- test the echo_AddOne interface
-*/
-function test_AddOne(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_AddOne\n");
-
- for (i=0;i<10;i++) {
- io.input.in_data = i;
- status = echo.echo_AddOne(io);
- check_status_ok(status);
- assert(io.output.out_data == i + 1);
- }
-}
-
-/*
- test the echo_EchoData interface
-*/
-function test_EchoData(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_EchoData\n");
-
- for (i=0; i<30; i=i+5) {
- io.input.len = i;
- io.input.in_data = ramp_array(i);
- status = echo.echo_EchoData(io);
- check_status_ok(status);
- assert(true == echo.blobCompare(io.input.in_data, io.output.out_data));
- }
-}
-
-
-/*
- test the echo_SinkData interface
-*/
-function test_SinkData(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_SinkData\n");
-
- for (i=0; i<30; i=i+5) {
- io.input.len = i;
- io.input.data = ramp_array(i);
- status = echo.echo_SinkData(io);
- check_status_ok(status);
- }
-}
-
-
-/*
- test the echo_SourceData interface
-*/
-function test_SourceData(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_SourceData\n");
-
- for (i=0; i<30; i=i+5) {
- io.input.len = i;
- status = echo.echo_SourceData(io);
- check_status_ok(status);
- correct = ramp_array(i);
- assert(true == echo.blobCompare(correct, io.output.data));
- }
-}
-
-
-/*
- test the echo_TestCall interface
-*/
-function test_TestCall(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_TestCall\n");
-
- io.input.s1 = "my test string";
- status = echo.echo_TestCall(io);
- check_status_ok(status);
- assert("this is a test string" == io.output.s2);
-}
-
-/*
- test the echo_TestCall2 interface
-*/
-function test_TestCall2(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_TestCall2\n");
-
- for (i=1;i<=7;i++) {
- io.input.level = i;
- status = echo.echo_TestCall2(io);
- check_status_ok(status);
- }
-}
-
-/*
- test the echo_TestSleep interface
-*/
-function test_TestSleep(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_TestSleep\n");
-
- io.input.seconds = 1;
- status = echo.echo_TestSleep(io);
- check_status_ok(status);
-}
-
-/*
- test the echo_TestEnum interface
-*/
-function test_TestEnum(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_TestEnum\n");
-
- io.input.foo1 = echo.ECHO_ENUM1;
- io.input.foo2 = new Object();
- io.input.foo2.e1 = echo.ECHO_ENUM1;
- io.input.foo2.e2 = echo.ECHO_ENUM1_32;
- io.input.foo3 = new Object();
- io.input.foo3.e1 = echo.ECHO_ENUM2;
- status = echo.echo_TestEnum(io);
- check_status_ok(status);
- assert(io.output.foo1 == echo.ECHO_ENUM1);
- assert(io.output.foo2.e1 == echo.ECHO_ENUM2);
- assert(io.output.foo2.e2 == echo.ECHO_ENUM1_32);
- assert(io.output.foo3.e1 == echo.ECHO_ENUM2);
-}
-
-/*
- test the echo_TestSurrounding interface
-*/
-function test_TestSurrounding(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_TestSurrounding\n");
-
- io.input.data = new Object();
- io.input.data.x = 10;
- io.input.data.surrounding = new Array(10);
- status = echo.echo_TestSurrounding(io);
- check_status_ok(status);
- assert(io.output.data.surrounding.length == 20);
- check_array_zero(io.output.data.surrounding);
-}
-
-/*
- test the echo_TestDoublePointer interface
-*/
-function test_TestDoublePointer(echo)
-{
- var io = irpcObj();
-
- print("Testing echo_TestDoublePointer\n");
-
- io.input.data = 7;
- status = echo.echo_TestDoublePointer(io);
- check_status_ok(status);
- assert(io.input.data == io.input.data);
-}
-
-
-if (options.ARGV.length != 1) {
- println("Usage: echo.js <BINDING>");
- return -1;
-}
-var binding = options.ARGV[0];
-var echo = rpcecho_init();
-datablob_init(echo);
-
-print("Connecting to " + binding + "\n");
-status = echo.connect(binding);
-if (status.is_ok != true) {
- printf("Failed to connect to %s - %s\n", binding, status.errstr);
- return;
-}
-
-test_AddOne(echo);
-test_EchoData(echo);
-test_SinkData(echo);
-test_SourceData(echo);
-
-print("SKIPPING test_TestCall as pidl cannot generate code for it\n");
-/* test_TestCall(echo); */
-test_TestCall2(echo);
-test_TestSleep(echo);
-test_TestEnum(echo);
-test_TestSurrounding(echo);
-test_TestDoublePointer(echo);
-
-println("All OK\n");
-return 0;
diff --git a/testprogs/ejs/loadparm.js b/testprogs/ejs/loadparm.js
deleted file mode 100644
index f56ca9f7fc..0000000000
--- a/testprogs/ejs/loadparm.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- demonstrate access to loadparm functions from ejs
-*/
-
-loadparm_init(local);
-
-function showParameter(name) {
- print(name + ": ");
- printVars(get(name));
-}
-
-for (v in ARGV) {
- showParameter(ARGV[v]);
-}
-
-print("defined services: ");
-printVars(services());
-
-showParameter("server services");
-showParameter("netbios name");
-showParameter("security");
-showParameter("workgroup");
-showParameter("log level");
-showParameter("server signing");
-showParameter("interfaces");
diff --git a/testprogs/ejs/resolveName.js b/testprogs/ejs/resolveName.js
deleted file mode 100644
index 1619b69d69..0000000000
--- a/testprogs/ejs/resolveName.js
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- Demonstrate use of resolveName() js function
-*/
-
-var result = new Object();
-
-res = resolveName(result, ARGV[0]);
-
-if (res.is_ok) {
- println(result.value);
-} else {
- println(res.errstr);
-}
diff --git a/testprogs/ejs/samr.js b/testprogs/ejs/samr.js
deleted file mode 100755
index fbdae974be..0000000000
--- a/testprogs/ejs/samr.js
+++ /dev/null
@@ -1,126 +0,0 @@
-#!/usr/bin/env smbscript
-/*
- test samr calls from ejs
-*/
-
-var options = GetOptions(ARGV,
- "POPT_AUTOHELP",
- "POPT_COMMON_SAMBA",
- "POPT_COMMON_CREDENTIALS");
-if (options == undefined) {
- println("Failed to parse options");
- return -1;
-}
-
-libinclude("base.js");
-libinclude("samr.js");
-
-
-/*
- test the samr_Connect interface
-*/
-function test_Connect(samr)
-{
- print("Testing samr_Connect\n");
- return samrConnect(samr);
-}
-
-
-/*
- test the samr_LookupDomain interface
-*/
-function test_LookupDomain(samr, handle, domain)
-{
- print("Testing samr_LookupDomain\n");
- return samrLookupDomain(samr, handle, domain);
-}
-
-/*
- test the samr_OpenDomain interface
-*/
-function test_OpenDomain(samr, handle, sid)
-{
- print("Testing samr_OpenDomain\n");
- return samrOpenDomain(samr, handle, sid);
-}
-
-/*
- test the samr_EnumDomainUsers interface
-*/
-function test_EnumDomainUsers(samr, dom_handle)
-{
- var i, users;
- print("Testing samr_EnumDomainUsers\n");
- users = samrEnumDomainUsers(samr, dom_handle);
- print("Found " + users.length + " users\n");
- for (i=0;i<users.length;i++) {
- println("\t" + users[i].name + "\t(" + users[i].idx + ")");
- }
-}
-
-/*
- test the samr_EnumDomainGroups interface
-*/
-function test_EnumDomainGroups(samr, dom_handle)
-{
- print("Testing samr_EnumDomainGroups\n");
- var i, groups = samrEnumDomainGroups(samr, dom_handle);
- print("Found " + groups.length + " groups\n");
- for (i=0;i<groups.length;i++) {
- println("\t" + groups[i].name + "\t(" + groups[i].idx + ")");
- }
-}
-
-/*
- test domain specific ops
-*/
-function test_domain_ops(samr, dom_handle)
-{
- test_EnumDomainUsers(samr, dom_handle);
- test_EnumDomainGroups(samr, dom_handle);
-}
-
-
-
-/*
- test the samr_EnumDomains interface
-*/
-function test_EnumDomains(samr, handle)
-{
- var i, domains;
- print("Testing samr_EnumDomains\n");
-
- domains = samrEnumDomains(samr, handle);
- print("Found " + domains.length + " domains\n");
- for (i=0;i<domains.length;i++) {
- print("\t" + domains[i].name + "\n");
- }
- for (i=0;i<domains.length;i++) {
- print("Testing domain " + domains[i].name + "\n");
- sid = samrLookupDomain(samr, handle, domains[i].name);
- dom_handle = test_OpenDomain(samr, handle, sid);
- test_domain_ops(samr, dom_handle);
- samrClose(samr, dom_handle);
- }
-}
-
-if (options.ARGV.length != 1) {
- println("Usage: samr.js <BINDING>");
- return -1;
-}
-var binding = options.ARGV[0];
-var samr = samr_init();
-
-print("Connecting to " + binding + "\n");
-status = samr.connect(binding);
-if (status.is_ok != true) {
- print("Failed to connect to " + binding + " - " + status.errstr + "\n");
- return -1;
-}
-
-handle = test_Connect(samr);
-test_EnumDomains(samr, handle);
-samrClose(samr, handle);
-
-print("All OK\n");
-return 0;